We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
There seems to be an issue assigning array shapes with optional parameters using the coalescing operator.
/** * @phpstan-type OwnerBackup array{name: string, isTest?: bool} */ class ClassA { /** @var OwnerBackup */ public array $ownerBackup; /** * @param OwnerBackup|null $ownerBackup */ public function __construct(?array $ownerBackup) { $this->ownerBackup = $ownerBackup ?? [ 'name' => 'Deleted', ]; } }
https://phpstan.org/r/71144b90-6376-4cc5-b07e-1c5553a9530e
No error
Yes!
The text was updated successfully, but these errors were encountered:
@glaubinix After the latest push in 1.9.x, PHPStan now reports different result with your code snippet:
@@ @@ -16: Property ClassA::$ownerBackup (array{name: string, isTest?: bool}) does not accept array<'isTest'|'name', bool|string>. -27: Property ClassA::$ownerBackup (array{name: string, isTest?: bool}) does not accept non-empty-array<'isTest'|'name', bool|string>. +16: Property ClassA::$ownerBackup (array{name: string, isTest?: bool}) does not accept array{}|array{name: string, isTest?: bool}.
Sorry, something went wrong.
Fixed: phpstan/phpstan-src#2708
Fixed: phpstan/phpstan-src#2710
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
No branches or pull requests
Bug report
There seems to be an issue assigning array shapes with optional parameters using the coalescing operator.
Code snippet that reproduces the problem
https://phpstan.org/r/71144b90-6376-4cc5-b07e-1c5553a9530e
Expected output
No error
Did PHPStan help you today? Did it make you happy in any way?
Yes!
The text was updated successfully, but these errors were encountered: