stitcher.io icon indicating copy to clipboard operation
stitcher.io copied to clipboard

Override article could need some more explanation

Open NicoHaase opened this issue 1 year ago • 1 comments

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?

NicoHaase avatar Feb 22 '24 08:02 NicoHaase

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.

Jacobs63 avatar Mar 11 '24 13:03 Jacobs63