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

[ErrorHandler] DebugClassLoader reports bad static method should be implemented #35836

Closed
alekitto opened this issue Feb 23, 2020 · 2 comments · Fixed by #35870
Closed

[ErrorHandler] DebugClassLoader reports bad static method should be implemented #35836

alekitto opened this issue Feb 23, 2020 · 2 comments · Fixed by #35870

Comments

@alekitto
Copy link
Contributor

Symfony version(s) affected: 5.0.4

Description
If a @method annotation with static return type is present on an interface, the DebugClassLoader reports Class Foo should implement method static FooInterface::method().

As per phpDocumentor method tag if a method is static the return type is mandatory. This implies that

 * @method static getInstance()

should be parsed as non-static method with static return type, but now is parsed as static untyped method.

Possible Solution
The @method parse regex on DebugClassLoader.php:L430 should capture return type and check it while determining if a method should be static or not.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Feb 26, 2020

if a method is static the return type is mandatory

cool, that's the rule we missed implementing. Up for a PR @alekitto?

(branch 4.4)

@alekitto
Copy link
Contributor Author

alekitto commented Feb 26, 2020

Up for a PR @alekitto?

👍 opened #35870

nicolas-grekas added a commit that referenced this issue Feb 26, 2020
… method annotation (alekitto)

This PR was merged into the 4.4 branch.

Discussion
----------

[ErrorHandler] fix parsing static return type on interface method annotation

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35836
| License       | MIT

As suggested in the issue, the regex has been adapted to capture the return type, then it will be checked while determining if the method to be implemented should be static or just returns an instance of `static`.

Commits
-------

55734a2 [ErrorHandler] fix parsing static return type on interface method annotation (fix #35836)
fabpot added a commit that referenced this issue Feb 29, 2020
* 4.4:
  [Dotenv] Documentation improvement
  [DI] Clarified deprecation for TypedReference in 4.4
  [Validator] Add missing vietnamese translations
  add German translation
  add missing Messenger options to XML schema definition
  [Validator][ConstraintValidator] Update wrong PRETTY_DATE doc
  [DomCrawler][Form] Fix PHPDoc on get & offsetGet
  [ErrorHandler] fix parsing static return type on interface method annotation (fix #35836)
  prevent method calls on null values
  Return int if scale = 0
fabpot added a commit that referenced this issue Feb 29, 2020
* 5.0:
  [Dotenv] Documentation improvement
  [DI] Clarified deprecation for TypedReference in 4.4
  [Validator] Add missing vietnamese translations
  add German translation
  add missing Messenger options to XML schema definition
  [5.0] Remove some unused variables
  [Validator][ConstraintValidator] Update wrong PRETTY_DATE doc
  [DomCrawler][Form] Fix PHPDoc on get & offsetGet
  [ErrorHandler] fix parsing static return type on interface method annotation (fix #35836)
  prevent method calls on null values
  Return int if scale = 0
hultberg pushed a commit to hultberg/symfony that referenced this issue Sep 17, 2021
* 4.4:
  [Dotenv] Documentation improvement
  [DI] Clarified deprecation for TypedReference in 4.4
  [Validator] Add missing vietnamese translations
  add German translation
  add missing Messenger options to XML schema definition
  [Validator][ConstraintValidator] Update wrong PRETTY_DATE doc
  [DomCrawler][Form] Fix PHPDoc on get & offsetGet
  [ErrorHandler] fix parsing static return type on interface method annotation (fix symfony#35836)
  prevent method calls on null values
  Return int if scale = 0
hultberg pushed a commit to hultberg/symfony that referenced this issue Sep 17, 2021
* 5.0:
  [Dotenv] Documentation improvement
  [DI] Clarified deprecation for TypedReference in 4.4
  [Validator] Add missing vietnamese translations
  add German translation
  add missing Messenger options to XML schema definition
  [5.0] Remove some unused variables
  [Validator][ConstraintValidator] Update wrong PRETTY_DATE doc
  [DomCrawler][Form] Fix PHPDoc on get & offsetGet
  [ErrorHandler] fix parsing static return type on interface method annotation (fix symfony#35836)
  prevent method calls on null values
  Return int if scale = 0
PhilETaylor pushed a commit to PhilETaylor/symfony that referenced this issue Sep 6, 2023
PhilETaylor pushed a commit to PhilETaylor/symfony that referenced this issue Sep 6, 2023
* 4.4:
  [Dotenv] Documentation improvement
  [DI] Clarified deprecation for TypedReference in 4.4
  [Validator] Add missing vietnamese translations
  add German translation
  add missing Messenger options to XML schema definition
  [Validator][ConstraintValidator] Update wrong PRETTY_DATE doc
  [DomCrawler][Form] Fix PHPDoc on get & offsetGet
  [ErrorHandler] fix parsing static return type on interface method annotation (fix symfony#35836)
  prevent method calls on null values
  Return int if scale = 0
PhilETaylor pushed a commit to PhilETaylor/symfony that referenced this issue Sep 6, 2023
* 5.0:
  [Dotenv] Documentation improvement
  [DI] Clarified deprecation for TypedReference in 4.4
  [Validator] Add missing vietnamese translations
  add German translation
  add missing Messenger options to XML schema definition
  [5.0] Remove some unused variables
  [Validator][ConstraintValidator] Update wrong PRETTY_DATE doc
  [DomCrawler][Form] Fix PHPDoc on get & offsetGet
  [ErrorHandler] fix parsing static return type on interface method annotation (fix symfony#35836)
  prevent method calls on null values
  Return int if scale = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants