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
Array created with values should be marked as non-empty #5382
Comments
I think this is specific to handling of the |
All the ternaries are affected: https://phpstan.org/r/55ae7f8b-313e-4b7a-a155-72c4bf71ac70 |
Even before any ternary the type is not inferred correctly, the intersection with |
That's not the reason, ConstantArrayType knows if it's empty or not by itself, it doesn't need the |
You're right, removing the null coalescing shows both of them working: https://phpstan.org/r/a805b504-a3bb-40ca-8a28-e32b97dd2d9e |
@b1rdex After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-15: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
+-1: Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40
+Run PHPStan with --debug option and post the stack trace to:
+https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md Full report
|
@AlexandruGG After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-19: Dumped type: array<int, stdClass>&nonEmpty
-20: Dumped type: array(stdClass)
-23: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
+-1: Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40
+Run PHPStan with --debug option and post the stack trace to:
+https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md Full report
|
@AlexandruGG After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-13: Constructor of class HelloWorld has an unused parameter $providers.
-19: Dumped type: array<int, stdClass>&nonEmpty
-20: Dumped type: array(stdClass)
+-1: Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40
+Run PHPStan with --debug option and post the stack trace to:
+https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md Full report
|
@b1rdex After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-15: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
+15: Property HelloWorld::$providers (non-empty-array<int, stdClass>) does not accept array<int, stdClass>. Full report
|
@b1rdex After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-15: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
-19: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
-23: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
-30: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
+15: Property HelloWorld::$providers (non-empty-array<int, stdClass>) does not accept array<int, stdClass>.
+19: Property HelloWorld::$providers (non-empty-array<int, stdClass>) does not accept array<int, stdClass>.
+23: Property HelloWorld::$providers (non-empty-array<int, stdClass>) does not accept array<int, stdClass>.
+30: Property HelloWorld::$providers (non-empty-array<int, stdClass>) does not accept array<int, stdClass>. Full report
|
@AlexandruGG After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-19: Dumped type: array<int, stdClass>&nonEmpty
+19: Dumped type: non-empty-array<int, stdClass>
20: Dumped type: array(stdClass)
-23: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
+23: Property HelloWorld::$providers (non-empty-array<int, stdClass>) does not accept array<int, stdClass>. Full report
|
@AlexandruGG After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
13: Constructor of class HelloWorld has an unused parameter $providers.
-19: Dumped type: array<int, stdClass>&nonEmpty
+19: Dumped type: non-empty-array<int, stdClass>
20: Dumped type: array(stdClass) Full report
|
@AlexandruGG After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-19: Dumped type: array<int, stdClass>&nonEmpty
-20: Dumped type: array(stdClass)
-23: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
+19: Dumped type: non-empty-array<int, stdClass>
+20: Dumped type: array{stdClass}
+23: Property HelloWorld::$providers (non-empty-array<int, stdClass>) does not accept array<int, stdClass>. Full report
|
@AlexandruGG After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
13: Constructor of class HelloWorld has an unused parameter $providers.
-19: Dumped type: array<int, stdClass>&nonEmpty
-20: Dumped type: array(stdClass)
+19: Dumped type: non-empty-array<int, stdClass>
+20: Dumped type: array{stdClass} Full report
|
@b1rdex After the latest commit in 1.6.x, PHPStan now reports different result with your code snippet: @@ @@
-15: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
+No errors |
@b1rdex After the latest commit in 1.6.x, PHPStan now reports different result with your code snippet: @@ @@
-15: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
-19: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
-23: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
-30: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
+No errors |
@AlexandruGG After the latest commit in 1.6.x, PHPStan now reports different result with your code snippet: @@ @@
-19: Dumped type: array<int, stdClass>&nonEmpty
-20: Dumped type: array(stdClass)
-23: Property HelloWorld::$providers (array<int, stdClass>&nonEmpty) does not accept array<int, stdClass>.
+19: Dumped type: non-empty-array<int, stdClass>
+20: Dumped type: array{stdClass} Full report
|
Closes phpstan/phpstan#6383 Closes phpstan/phpstan#5933 Closes phpstan/phpstan#5382 Closes phpstan/phpstan#6379 Closes phpstan/phpstan#3284
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. |
Bug report
Code snippet that reproduces the problem
https://phpstan.org/r/61906720-950c-49db-889b-07e62d97761f
Expected output
No errors
Did PHPStan help you today? Did it make you happy in any way?
Sure!
The text was updated successfully, but these errors were encountered: