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

Update return type of spl_autoload_functions on PHP8.0+ #2810

Merged

Conversation

ManuelHu
Copy link
Contributor

@ManuelHu ManuelHu commented Dec 8, 2023

The PHP documentation states that spl_autoload_functions might only return false on PHP versions up to 7.4; it will return an empty array on PHP8+.

  • functionMap.php contains the PHP 7.4 signature. This is unchanged. Is this correct?
  • The updated signature was only added to functionMap_php80delta.php
  • The PHP8.x stubs already have the (only) correct native return type array specified. Before this PR, PHPStan assumes a return type of array (as list<...>|false in functionMap.php is not a subtype of the native type array)
  • with this change the functionMap type should be a proper subtype of the native return type from the subs.

This PR also fixes some static analysis errors in PHPStan's source code that resulted from the functionMap changes.

@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x.

@ManuelHu ManuelHu changed the base branch from 1.11.x to 1.10.x December 8, 2023 12:12
The documentation states that spl_autoload_functions might only return
false on PHP versions up to 7.4; it will return an empty array on PHP8+.
@ManuelHu ManuelHu force-pushed the return-type-spl_autoload_functions-php8 branch from 29bf778 to 0b4373f Compare September 26, 2024 18:06
@ManuelHu ManuelHu changed the base branch from 1.10.x to 1.12.x September 26, 2024 18:07
@ManuelHu
Copy link
Contributor Author

@ondrejmirtes This (already very old) PR should now be ready for review and merging. I hope I did everythng right for the version specific signatures, at least it seems to work.

This might break some custom @var type annotations (like here in PHPStan), should this maybe go into bleeding edge for now?

@ondrejmirtes ondrejmirtes merged commit 5ac7a1c into phpstan:1.12.x Oct 6, 2024
481 of 499 checks passed
@ondrejmirtes
Copy link
Member

This is okay, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants