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

Unexpected problem reported for the SplTempFileObject::fstat() method #5404

Closed
Kolyunya opened this issue Aug 1, 2021 · 6 comments
Closed
Labels
Milestone

Comments

@Kolyunya
Copy link
Contributor

Kolyunya commented Aug 1, 2021

Bug report

Code snippet that reproduces the problem

https://phpstan.org/r/db3231ce-001d-4349-b052-b3eb5eec046e

$file = new SplTempFileObject();
$info = $file->fstat();
$size = $info['size'];

Expected output

According to the docs fstat() returns array, not array|false.
Also according to the docs the array has a size key.
So, no problems are expected to be reported.

Actual output

Cannot access offset 'size' on array(0 => int, 1 => int, 2 => int, 3 => int, 4 => int, 5 => int, 6 => int, 7 => int, ...)|false.

Did PHPStan help you today? Did it make you happy in any way?

PHPStan helps me every day a ton. The best tool in my toolbox.

@mergeable
Copy link

mergeable bot commented Aug 1, 2021

This bug report is missing a link to reproduction on phpstan.org.

It will most likely be closed after manual review.

@ondrejmirtes
Copy link
Member

Please follow this issue template: https://github.com/phpstan/phpstan/issues/new?assignees=&labels=&template=Function_signature_mismatch.md

Please send a pull request in phpstan/phpstan-src that updates file resources/functionMap.php instead. Thank you.

Thanks.

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

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

@@ @@
-5: Cannot access offset 'size' on array(0 => int, 1 => int, 2 => int, 3 => int, 4 => int, 5 => int, 6 => int, 7 => int, ...)|false.
+5: Cannot access offset 'size' on array{0: int, 1: int, 2: int, 3: int, 4: int, 5: int, 6: int, 7: int, ...}|false.
Full report
Line Error
5 `Cannot access offset 'size' on array{0: int, 1: int, 2: int, 3: int, 4: int, 5: int, 6: int, 7: int, ...}

@phpstan-bot
Copy link
Contributor

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

@@ @@
-5: Cannot access offset 'size' on array(0 => int, 1 => int, 2 => int, 3 => int, 4 => int, 5 => int, 6 => int, 7 => int, ...)|false.
+No errors

@ondrejmirtes
Copy link
Member

Fixed by: phpstan/phpstan-src#996

@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 Mar 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