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

php type resource hidden by class Resource #10399

Closed
dbu opened this issue Jan 6, 2024 · 3 comments
Closed

php type resource hidden by class Resource #10399

dbu opened this issue Jan 6, 2024 · 3 comments

Comments

@dbu
Copy link

dbu commented Jan 6, 2024

Bug report

the doc states that phpstan will assume resource to mean the php type resource unless the FQN is used.

however, current versions seem to do the opposite

when i have a class Resource in the same namespace, i can't specify resource and get an error that the case is incorrect. i tried \resource as well, but that gives Parameter $data of method Foo\HelloWorld::sayHello() has invalid type resource.

Code snippet that reproduces the problem

https://phpstan.org/r/67bc0abd-313b-41ca-ae65-7833ff531f35

Expected output

  • no errors -

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

❤️

ondrejmirtes added a commit to phpstan/phpstan-src that referenced this issue Jan 7, 2024
@ondrejmirtes
Copy link
Member

Hi, yeah, this doesn't have a great solution because PHPDoc types need to be case-insensitive and there's already a class in the same namespace, leaving resource to be ambiguous.

Fortunately there's closed-resource type with the same semantics that you can use to represent the proper PHP resource type.

I just also added open-resource: phpstan/phpstan-src@bbd9a68

@dbu
Copy link
Author

dbu commented Jan 8, 2024

thanks for the quick answer.

i created a pull request to clarify this in the documentation.

dbu added a commit to doctrine/phpcr-odm that referenced this issue Jan 8, 2024
adjust phpdoc annotations to work around phpstan/phpstan#10399
dbu added a commit to doctrine/phpcr-odm that referenced this issue Jan 8, 2024
adjust phpdoc annotations to work around phpstan/phpstan#10399
dbu added a commit to doctrine/phpcr-odm that referenced this issue Jan 8, 2024
adjust phpdoc annotations to work around phpstan/phpstan#10399
dbu added a commit to doctrine/phpcr-odm that referenced this issue Jan 8, 2024
adjust phpdoc annotations to work around phpstan/phpstan#10399
dbu added a commit to doctrine/phpcr-odm that referenced this issue Jan 8, 2024
adjust phpdoc annotations to work around phpstan/phpstan#10399
dbu added a commit to doctrine/phpcr-odm that referenced this issue Jan 8, 2024
adjust phpdoc annotations to work around phpstan/phpstan#10399
Copy link

github-actions bot commented Feb 9, 2024

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 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants