Skip to content
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

Closure::bind() and array type hinting inside closure #4906

Closed
mente opened this issue Apr 26, 2021 · 5 comments
Closed

Closure::bind() and array type hinting inside closure #4906

mente opened this issue Apr 26, 2021 · 5 comments
Labels
Milestone

Comments

@mente
Copy link

mente commented Apr 26, 2021

Bug report

With latest upgrade to 0.12.84 (by probably fixing #4808) PHPStan loses the typing of an array coming from an upper class.

Code snippet that reproduces the problem

https://phpstan.org/r/d4e5e3e8-57f6-4f1b-88e6-cfcd73e8c8ef

Expected output

No errors reports.

PS Simple type hinting of $connectionParameters inside Closure:bind would have helped, but fixing type erasure will be a proper solution.

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Apr 26, 2021
@phpstan-bot
Copy link
Contributor

@mente After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
+10: Property Connection::$params is unused.
+18: Property HelloWorld::$connectionParameters is never written, only read.
+20: Method HelloWorld::overrideConnectionParameters() is unused.
 24: Array (array<string, mixed>) does not accept key (int|string).
Full report
Line Error
10 Property Connection::$params is unused.
18 Property HelloWorld::$connectionParameters is never written, only read.
20 Method HelloWorld::overrideConnectionParameters() is unused.
24 `Array (array<string, mixed>) does not accept key (int

@phpstan-bot
Copy link
Contributor

@mente After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-24: Array (array<string, mixed>) does not accept key (int|string).
+10: Property Connection::$params is unused.
+24: Array (array<string, mixed>) does not accept key (int|string).
+18: Property HelloWorld::$connectionParameters is never written, only read.
+20: Method HelloWorld::overrideConnectionParameters() is unused.
Full report
Line Error
10 Property Connection::$params is unused.
24 `Array (array<string, mixed>) does not accept key (int
18 Property HelloWorld::$connectionParameters is never written, only read.
20 Method HelloWorld::overrideConnectionParameters() is unused.

@phpstan-bot
Copy link
Contributor

@mente After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-24: Array (array<string, mixed>) does not accept key (int|string).
+10: Property Connection::$params is unused.
+18: Property HelloWorld::$connectionParameters is never written, only read.
+20: Method HelloWorld::overrideConnectionParameters() is unused.
Full report
Line Error
10 Property Connection::$params is unused.
18 Property HelloWorld::$connectionParameters is never written, only read.
20 Method HelloWorld::overrideConnectionParameters() is unused.

@mente
Copy link
Author

mente commented Jan 9, 2022

Nice, looks like fixed, so closing

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants