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 8.3 Support: Marking overridden methods (#[\Override]) #6701 #6873

Merged
merged 4 commits into from
Dec 23, 2023

Conversation

junichi11
Copy link
Member

Fix the Overriding Methods feature

  • Don't handle private methods as overridden/overriding methods
  • Handle also methods of Enum
  • Improve results of unit tests
  • Add/Fix unit tests

PHP 8.3 Support: Marking overridden methods (#[\Override]) (Part 1)

  • Add the hasOverrideAttribute() method to the PhpVersion
  • Add the AddOverrideAttributeHint
  • Add unit tests
  • Increment spec versions

nb-php83-override-attribute

Note:
If some trait methods have #[\Override], we should also check wheter the parent class has them.
However, attributes are not indexed at the moment. So, we should improve the indexer.
(Currently, the following case is not supported.)

e.g.

trait T {
    #[\Override]
    public function traitMethod(): void {}
}
class C {
    // Fatal error:  C::traitMethod() has #[\Override] attribute, but no matching parent method exists
    use T;
}

PHP 8.3 Support: Marking overridden methods (#[\Override]) (Part 2)

  • Fix the code generator, code completion, and ImplementAbstractMethodsHintError
  • Add/Fix unit tests

Code Generator:

nb-php83-override-attribute-codegen

Code Completion:

nb-php83-override-attribute-cc

Hint:

nb-php83-override-attribute-hint

- Don't handle private methods as overridden/overriding methods
- Handle also methods of Enum
- Improve results of unit tests
- Add/Fix unit tests
@junichi11 junichi11 added the PHP [ci] enable extra PHP tests (php/php.editor) label Dec 22, 2023
@junichi11 junichi11 added this to the NB21 milestone Dec 22, 2023
@junichi11
Copy link
Member Author

@tmysik I may have missed something, but I've added as many unit tests as possible.
Need not hurry, of course :) Thanks!

@junichi11
Copy link
Member Author

Will fix failed tests later.

- apache#6701
- https://wiki.php.net/rfc/marking_overriden_methods
- Add the `hasOverrideAttribute()` method to the `PhpVersion`
- Add the `AddOverrideAttributeHint`
- Add unit tests
- Increment spec versions

Note:
If some trait methods have `#[\Override]`, we should also check wheter the parent class has them.
However, attributes are not indexed at the moment. So, we should improve the indexer.
(Currently, the following case is not supported.)

e.g.
```php
trait T {
    #[\Override]
    public function traitMethod(): void {}
}
class C {
    // Fatal error:  C::traitMethod() has #[\Override] attribute, but no matching parent method exists
    use T;
}
```
- apache#6701
- https://wiki.php.net/rfc/marking_overriden_methods
- Fix the code generator, code completion, and `ImplementAbstractMethodsHintError`
- Add/Fix unit tests
@junichi11 junichi11 force-pushed the php83-marking-overridden-methods branch from 9a45ad2 to fd64377 Compare December 22, 2023 09:08
@junichi11 junichi11 mentioned this pull request Dec 22, 2023
3 tasks
Copy link
Member

@tmysik tmysik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of tests is amazing, we should be safe here 🙂

@junichi11 Thanks for your perfect work!

@junichi11
Copy link
Member Author

@tmysik Thank you for your review and your time :)

@junichi11 junichi11 merged commit 2141d37 into apache:master Dec 23, 2023
34 checks passed
@junichi11 junichi11 deleted the php83-marking-overridden-methods branch December 23, 2023 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PHP [ci] enable extra PHP tests (php/php.editor)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants