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

Improve constant array as callable with unions of constant strings #2343

Closed
ondrejmirtes opened this issue Jul 31, 2019 · 10 comments · Fixed by phpstan/phpstan-src#1529
Closed
Labels
Milestone

Comments

@ondrejmirtes
Copy link
Member

Bug report

Code snippet that reproduces the problem

https://phpstan.org/r/34956aa9-a75c-42f8-a12f-67d1625cb327

Expected output

No errors

@marc-mabe
Copy link
Contributor

marc-mabe commented Jan 13, 2020

Here is a more simple case using [static::class, 'staticFunc']
https://phpstan.org/r/5c021762-60c2-49fe-aada-b723f2780c28

@ondrejmirtes
Copy link
Member Author

@marc-mabe This is a separate issue, please open a new issue for that. Thanks.

@marc-mabe
Copy link
Contributor

@ondrejmirtes ok I did here #2846

@phpstan-bot
Copy link
Contributor

@ondrejmirtes PHPStan now reports different result with your code snippet:

@@ @@
+PHP 8.0 (4 errors)
+==========
+
+ 6: Method Sample\A::say() has no return typehint specified.
+10: Method Sample\A::bye() has no return typehint specified.
+14: Method Sample\A::all() has no return typehint specified.
+23: Parameter #1 $callback of function call_user_func expects callable(): mixed, array('Sample\\A', 'bye'|'say') given.
+
+PHP 7.1 – 7.4 (4 errors)
+==========
+
+ 6: Method Sample\A::say() has no return typehint specified.
+10: Method Sample\A::bye() has no return typehint specified.
+14: Method Sample\A::all() has no return typehint specified.
 23: Parameter #1 $function of function call_user_func expects callable(): mixed, array('Sample\\A', 'bye'|'say') given.
Full report

PHP 8.0 (4 errors)

Line Error
6 Parameter #1 $function of function call_user_func expects callable(): mixed, array('Sample\A', 'bye'
10 Parameter #1 $function of function call_user_func expects callable(): mixed, array('Sample\A', 'bye'
14 Parameter #1 $function of function call_user_func expects callable(): mixed, array('Sample\A', 'bye'
23 Parameter #1 $function of function call_user_func expects callable(): mixed, array('Sample\A', 'bye'

PHP 7.1 – 7.4 (4 errors)

Line Error
6 Parameter #1 $callback of function call_user_func expects callable(): mixed, array('Sample\A', 'bye'
10 Parameter #1 $callback of function call_user_func expects callable(): mixed, array('Sample\A', 'bye'
14 Parameter #1 $callback of function call_user_func expects callable(): mixed, array('Sample\A', 'bye'
23 Parameter #1 $callback of function call_user_func expects callable(): mixed, array('Sample\A', 'bye'

@phpstan-bot
Copy link
Contributor

@marc-mabe PHPStan now reports different result with your code snippet:

@@ @@
-6: Parameter #1 $function of function call_user_func expects callable(): mixed, array(class-string<static(Test)>, 'staticFunc') given.
+No errors

@phpstan-bot
Copy link
Contributor

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

@@ @@
+PHP 8.0 (4 errors)
+==========
+
+ 6: Method Sample\A::say() has no return type specified.
+10: Method Sample\A::bye() has no return type specified.
+14: Method Sample\A::all() has no return type specified.
+23: Parameter #1 $callback of function call_user_func expects callable(): mixed, array('Sample\\A', 'bye'|'say') given.
+
+PHP 7.1 – 7.4 (4 errors)
+==========
+
+ 6: Method Sample\A::say() has no return type specified.
+10: Method Sample\A::bye() has no return type specified.
+14: Method Sample\A::all() has no return type specified.
 23: Parameter #1 $function of function call_user_func expects callable(): mixed, array('Sample\\A', 'bye'|'say') given.
Full report

PHP 8.0 (4 errors)

Line Error
6 Method Sample\A::say() has no return type specified.
10 Method Sample\A::bye() has no return type specified.
14 Method Sample\A::all() has no return type specified.
23 `Parameter #1 $callback of function call_user_func expects callable(): mixed, array('Sample\A', 'bye'

PHP 7.1 – 7.4 (4 errors)

Line Error
6 Method Sample\A::say() has no return type specified.
10 Method Sample\A::bye() has no return type specified.
14 Method Sample\A::all() has no return type specified.
23 `Parameter #1 $function of function call_user_func expects callable(): mixed, array('Sample\A', 'bye'

@phpstan-bot
Copy link
Contributor

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

@@ @@
-23: Parameter #1 $function of function call_user_func expects callable(): mixed, array('Sample\\A', 'bye'|'say') given.
+PHP 8.0 (4 errors)
+==========
+
+ 6: Method Sample\A::say() has no return type specified.
+10: Method Sample\A::bye() has no return type specified.
+14: Method Sample\A::all() has no return type specified.
+23: Parameter #1 $callback of function call_user_func expects callable(): mixed, array{'Sample\\A', 'bye'|'say'} given.
+
+PHP 7.1 – 7.4 (4 errors)
+==========
+
+ 6: Method Sample\A::say() has no return type specified.
+10: Method Sample\A::bye() has no return type specified.
+14: Method Sample\A::all() has no return type specified.
+23: Parameter #1 $function of function call_user_func expects callable(): mixed, array{'Sample\\A', 'bye'|'say'} given.
Full report

PHP 8.0 (4 errors)

Line Error
6 Method Sample\A::say() has no return type specified.
10 Method Sample\A::bye() has no return type specified.
14 Method Sample\A::all() has no return type specified.
23 `Parameter #1 $callback of function call_user_func expects callable(): mixed, array{'Sample\A', 'bye'

PHP 7.1 – 7.4 (4 errors)

Line Error
6 Method Sample\A::say() has no return type specified.
10 Method Sample\A::bye() has no return type specified.
14 Method Sample\A::all() has no return type specified.
23 `Parameter #1 $function of function call_user_func expects callable(): mixed, array{'Sample\A', 'bye'

@phpstan-bot
Copy link
Contributor

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

@@ @@
-23: Parameter #1 $function of function call_user_func expects callable(): mixed, array('Sample\\A', 'bye'|'say') given.
+PHP 8.0 – 8.1 (4 errors)
+==========
+
+ 6: Method Sample\A::say() has no return type specified.
+10: Method Sample\A::bye() has no return type specified.
+14: Method Sample\A::all() has no return type specified.
+23: Parameter #1 $callback of function call_user_func expects callable(): mixed, array{'Sample\\A', 'bye'|'say'} given.
+
+PHP 7.1 – 7.4 (4 errors)
+==========
+
+ 6: Method Sample\A::say() has no return type specified.
+10: Method Sample\A::bye() has no return type specified.
+14: Method Sample\A::all() has no return type specified.
+23: Parameter #1 $function of function call_user_func expects callable(): mixed, array{'Sample\\A', 'bye'|'say'} given.
Full report

PHP 8.0 – 8.1 (4 errors)

Line Error
6 Method Sample\A::say() has no return type specified.
10 Method Sample\A::bye() has no return type specified.
14 Method Sample\A::all() has no return type specified.
23 `Parameter #1 $callback of function call_user_func expects callable(): mixed, array{'Sample\A', 'bye'

PHP 7.1 – 7.4 (4 errors)

Line Error
6 Method Sample\A::say() has no return type specified.
10 Method Sample\A::bye() has no return type specified.
14 Method Sample\A::all() has no return type specified.
23 `Parameter #1 $function of function call_user_func expects callable(): mixed, array{'Sample\A', 'bye'

@phpstan-bot
Copy link
Contributor

@ondrejmirtes After the latest push in 1.8.x, PHPStan now reports different result with your code snippet:

@@ @@
-23: Parameter #1 $function of function call_user_func expects callable(): mixed, array('Sample\\A', 'bye'|'say') given.
+PHP 8.0 – 8.2 (4 errors)
+==========
+
+ 6: Method Sample\A::say() has no return type specified.
+10: Method Sample\A::bye() has no return type specified.
+14: Method Sample\A::all() has no return type specified.
+23: Parameter #1 $callback of function call_user_func expects callable(): mixed, array{'Sample\\A', 'bye'|'say'} given.
+
+PHP 7.1 – 7.4 (4 errors)
+==========
+
+ 6: Method Sample\A::say() has no return type specified.
+10: Method Sample\A::bye() has no return type specified.
+14: Method Sample\A::all() has no return type specified.
+23: Parameter #1 $function of function call_user_func expects callable(): mixed, array{'Sample\\A', 'bye'|'say'} given.
Full report

PHP 8.0 – 8.2 (4 errors)

Line Error
6 Method Sample\A::say() has no return type specified.
10 Method Sample\A::bye() has no return type specified.
14 Method Sample\A::all() has no return type specified.
23 `Parameter #1 $callback of function call_user_func expects callable(): mixed, array{'Sample\A', 'bye'

PHP 7.1 – 7.4 (4 errors)

Line Error
6 Method Sample\A::say() has no return type specified.
10 Method Sample\A::bye() has no return type specified.
14 Method Sample\A::all() has no return type specified.
23 `Parameter #1 $function of function call_user_func expects callable(): mixed, array{'Sample\A', 'bye'

@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 Aug 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants