-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feature/phpstan generics for collection #64
Feature/phpstan generics for collection #64
Conversation
Update collection repo from head repo
*/ | ||
public function __construct(array $elements = [], string $iteratorClass = \ArrayIterator::class) | ||
final public function __construct(array $elements = [], string $iteratorClass = \ArrayIterator::class) |
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.
Made this final cause the following phpstan message:
331 Unsafe usage of new static().
💡 Consider making the class or the constructor final.
Alternatively we can change new static() to new self() on line 367 and remove the unit tests that test this behaviour
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.
Looks fine to me 👍
Hi @aeviiq, With the merge method is it possible to merge other collection instances into the collection with other instances. Whats your opinion about this? By merging this merge request it's no longer possible to merge 2 different instances into 1 collection. Example: /** @var PersonCollection<Person> $personCollection */
$personCollection = new PersonCollection();
$person = new Person();
$a = new Collection([$person]);
$a->merge($personCollection); // should work
/** @var ProductCollection<Product> $otherCollection */
$otherCollection = new ProductCollection();
$a->merge($otherCollection); // should give phpstan error (expects Person, ProductCollection given.) |
Fix #63 . Add phpstan and psalm generics for the collections.