Skip to content

PHP 8.3 Support: Marking overridden methods (#[\Override]) #6701#6873

Merged
junichi11 merged 4 commits intoapache:masterfrom
junichi11:php83-marking-overridden-methods
Dec 23, 2023
Merged

PHP 8.3 Support: Marking overridden methods (#[\Override]) #6701#6873
junichi11 merged 4 commits intoapache:masterfrom
junichi11:php83-marking-overridden-methods

Conversation

@junichi11
Copy link
Copy Markdown
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 junichi11 requested a review from tmysik December 22, 2023 06:23
@junichi11
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

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

@junichi11 junichi11 merged commit 2141d37 into apache:master Dec 23, 2023
@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