-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solve some PHPStan baseline errors #10242
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,7 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec | |
* | ||
* @param EntityManagerInterface $em The EntityManager the collection will be associated with. | ||
* @param ClassMetadata $class The class descriptor of the entity type of this collection. | ||
* @psalm-param Collection<TKey, T> $collection The collection elements. | ||
* @psalm-param Collection<TKey, T>&Selectable<TKey, T> $collection The collection elements. | ||
*/ | ||
public function __construct(EntityManagerInterface $em, $class, Collection $collection) | ||
{ | ||
|
@@ -675,11 +675,12 @@ public function matching(Criteria $criteria): Collection | |
/** | ||
* Retrieves the wrapped Collection instance. | ||
* | ||
* @return Collection<TKey, T> | ||
* @return Collection<TKey, T>&Selectable<TKey, T> | ||
*/ | ||
public function unwrap(): Collection | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the matching method, there is the code
So, unwrap need to return a Selectable if we want to call |
||
{ | ||
assert($this->collection !== null); | ||
assert($this->collection instanceof Collection); | ||
assert($this->collection instanceof Selectable); | ||
|
||
return $this->collection; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,14 +222,14 @@ class UnitOfWork implements PropertyChangedListener | |
/** | ||
* All pending collection deletions. | ||
* | ||
* @psalm-var array<int, Collection<array-key, object>> | ||
* @psalm-var array<int, PersistentCollection<array-key, object>> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only add PersistentCollection to this array
|
||
*/ | ||
private $collectionDeletions = []; | ||
|
||
/** | ||
* All pending collection updates. | ||
* | ||
* @psalm-var array<int, Collection<array-key, object>> | ||
* @psalm-var array<int, PersistentCollection<array-key, object>> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only add PersistentCollection to this array
|
||
*/ | ||
private $collectionUpdates = []; | ||
|
||
|
@@ -238,7 +238,7 @@ class UnitOfWork implements PropertyChangedListener | |
* At the end of the UnitOfWork all these collections will make new snapshots | ||
* of their data. | ||
* | ||
* @psalm-var array<int, Collection<array-key, object>> | ||
* @psalm-var array<int, PersistentCollection<array-key, object>> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only add PersistentCollection to this array
|
||
*/ | ||
private $visitedCollections = []; | ||
|
||
|
@@ -419,12 +419,6 @@ public function commit($entity = null) | |
try { | ||
// Collection deletions (deletions of complete collections) | ||
foreach ($this->collectionDeletions as $collectionToDelete) { | ||
if (! $collectionToDelete instanceof PersistentCollection) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not possible since
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code was deliberately added in #7861, which is a bit worrying, but also, the test that was added in that PR still passes, so I guess it's fine? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I would say that the developer wanted to be BC
But it's not possible to have something else than PersistentCollection ^^ |
||
$this->getCollectionPersister($collectionToDelete->getMapping())->delete($collectionToDelete); | ||
|
||
continue; | ||
} | ||
|
||
// Deferred explicit tracked collections can be removed only when owning relation was persisted | ||
$owner = $collectionToDelete->getOwner(); | ||
|
||
|
@@ -3376,7 +3370,7 @@ public function getScheduledEntityDeletions() | |
/** | ||
* Gets the currently scheduled complete collection deletions | ||
* | ||
* @psalm-return array<int, Collection<array-key, object>> | ||
* @psalm-return array<int, PersistentCollection<array-key, object>> | ||
*/ | ||
public function getScheduledCollectionDeletions() | ||
{ | ||
|
@@ -3386,7 +3380,7 @@ public function getScheduledCollectionDeletions() | |
/** | ||
* Gets the currently scheduled collection inserts, updates and deletes. | ||
* | ||
* @psalm-return array<int, Collection<array-key, object>> | ||
* @psalm-return array<int, PersistentCollection<array-key, object>> | ||
*/ | ||
public function getScheduledCollectionUpdates() | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
unwrap
need to return a Selectable (cf next comment), we need to only accepts selectable.