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

net_get_interfaces() function and bleading edge #9535

Closed
mvorisek opened this issue Jun 29, 2023 · 9 comments
Closed

net_get_interfaces() function and bleading edge #9535

mvorisek opened this issue Jun 29, 2023 · 9 comments
Labels
Milestone

Comments

@mvorisek
Copy link
Contributor

mvorisek commented Jun 29, 2023

Bug report

Present only with a bleading edge enabled. I do not fully understand what phpstan tries to tell here and I belive there should be no error.

Code snippet that reproduces the problem

https://phpstan.org/r/66728891-b329-4df3-ab1c-c49238e10308

Expected output

no error

@ondrejmirtes
Copy link
Member

Something about the name offset is off: https://phpstan.org/r/fde60006-e4fd-47c6-ac64-193c9e2d01a6

@mvorisek
Copy link
Contributor Author

mvorisek commented Jun 29, 2023

simplified repro: https://phpstan.org/r/78e22dfe-8656-40f0-8a7b-044bc9f37eb1

an earlier assertion might be helpful as any type with *ERROR* is probably wrong

@mvorisek mvorisek changed the title "function uasort contains unresolvable type" and bleading edge "net_get_interfaces()" and bleading edge Jun 29, 2023
@mvorisek mvorisek changed the title "net_get_interfaces()" and bleading edge net_get_interfaces() and bleading edge Jun 29, 2023
@mvorisek mvorisek changed the title net_get_interfaces() and bleading edge net_get_interfaces() function and bleading edge Jun 29, 2023
@ondrejmirtes
Copy link
Member

The reason (higher level than 6): https://phpstan.org/r/7dff3f5f-d99f-49bc-a5e4-4c19383f688a

Of course the behaviour could be improved.

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Jun 29, 2023
@phpstan-bot
Copy link
Contributor

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

@@ @@
-PHP 8.0 – 8.3 (2 errors)
+PHP 7.3 – 8.3
 ==========
 
-23: Parameter #1 $array of function uasort contains unresolvable type.
-23: Parameter #2 $callback of function uasort contains unresolvable type.
-
-PHP 7.3 – 7.4 (2 errors)
-==========
-
-23: Parameter #1 $array_arg of function uasort contains unresolvable type.
-23: Parameter #2 $callback of function uasort contains unresolvable type.
+No errors
 
 PHP 7.2 (3 errors)
 ==========
Full report

PHP 7.3 – 8.3

No errors

PHP 7.2 (3 errors)

Line Error
4 Function net_get_interfaces not found.
23 Parameter #1 $array_arg of function uasort contains unresolvable type.
23 Parameter #2 $callback of function uasort contains unresolvable type.

@phpstan-bot
Copy link
Contributor

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

@@ @@
-PHP 8.0 – 8.3 (3 errors)
+PHP 7.3 – 8.3 (1 error)
 ==========
 
-24: Dumped type: list<array{name: *ERROR*, ip: mixed~null, mask: mixed~null, family: mixed~null}>
-25: Parameter #1 $array of function uasort contains unresolvable type.
-25: Parameter #2 $callback of function uasort contains unresolvable type.
-
-PHP 7.3 – 7.4 (3 errors)
-==========
-
-24: Dumped type: list<array{name: *ERROR*, ip: mixed~null, mask: mixed~null, family: mixed~null}>
-25: Parameter #1 $array_arg of function uasort contains unresolvable type.
-25: Parameter #2 $callback of function uasort contains unresolvable type.
+24: Dumped type: list<array{name: (int|string), ip: mixed~null, mask: mixed~null, family: mixed~null}>
 
 PHP 7.2 (4 errors)
 ==========
Full report

PHP 7.3 – 8.3 (1 error)

Line Error
24 `Dumped type: list<array{name: (int

PHP 7.2 (4 errors)

Line Error
4 Function net_get_interfaces not found.
24 Dumped type: list<array{name: *ERROR*, ip: mixed~null, mask: mixed~null, family: mixed~null}>
25 Parameter #1 $array_arg of function uasort contains unresolvable type.
25 Parameter #2 $callback of function uasort contains unresolvable type.

@phpstan-bot
Copy link
Contributor

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

@@ @@
 PHP 7.3 – 8.3 (1 error)
 ==========
 
-4: Dumped type: *ERROR*
+4: Dumped type: (int|string)
 
 PHP 7.2 (2 errors)
 ==========
Full report

PHP 7.3 – 8.3 (1 error)

Line Error
4 `Dumped type: (int

PHP 7.2 (2 errors)

Line Error
3 Function net_get_interfaces not found.
4 Dumped type: *ERROR*

@phpstan-bot
Copy link
Contributor

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

@@ @@
 ==========
 
 3: Argument of an invalid type array|false supplied for foreach, only iterables are supported.
-4: Dumped type: *ERROR*
+4: Dumped type: (int|string)
 
 PHP 7.2 (2 errors)
 ==========
Full report

PHP 7.3 – 8.3 (2 errors)

Line Error
3 `Argument of an invalid type array
4 `Dumped type: (int

PHP 7.2 (2 errors)

Line Error
3 Function net_get_interfaces not found.
4 Dumped type: *ERROR*

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@cb5a2b4

@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 Jul 31, 2023
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