Closed jtojnar closed 1 year ago
Actually, I am not sure if argument names are considered a part of the public API. But with PHP 8’s support for named parameters, they probably should be anyway.
Edit: Looks like it is indeed the case and some projects are using @no-named-arguments
as an annotation to disable that. So I would suggest supporting all classes whose constructor is not annotated with that.
The
Expect::from
is nice, but it does not really work for immutable objects like the following:Version without readonly
```php name; } public function getPrice(): Money { return $this->price; } public function getAmount(): int { return $this->amount; } } ```It would be nice to have
Expect::fromClass(InvoiceItem::class)
, that would check the constructor arguments instead of the public properties likeExpect::from
does.I can try to implement this, if you think this is a good idea.