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

Override article could need some more explanation #250

Open
NicoHaase opened this issue Feb 22, 2024 · 1 comment
Open

Override article could need some more explanation #250

NicoHaase opened this issue Feb 22, 2024 · 1 comment

Comments

@NicoHaase
Copy link

I'm currently upgrading a first application to use PHP 8.3, and Rector recommends to use #[Override]. Gathering some pros and cons about this, I've found your article at https://stitcher.io/blog/override-in-php-83 that states:

I use an IDE that prevents me from making these kinds of mistakes

Can you explain this further? How could your IDE inform you that a parent classes method was renamed and you might consider renaming the method in your own class? How could a static analyzer detect this better?

@Jacobs63
Copy link

Jacobs63 commented Mar 11, 2024

The IDE would not really inform you that a method was renamed, however:

  • If my method is overriding the parent's method I can see a clear icon indicator:
image
  • Unlike for a method that is not overriding anything:
image
  • If my method is being overridden by another class, I can also clearly see that:
image
  • If I'd like to rename a method, I should utilize the Rename refactorings shortcut, which would automatically rename the method in all classes that override it.

In summary, my IDE prevents me making mistakes while also providing me with additional information.

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

No branches or pull requests

2 participants