Skip to content

Conversation

@sno-windy
Copy link

@sno-windy sno-windy commented Aug 23, 2025

This PR addresses MissingOverrideAttribute errors reported by Psalm by adding #[\Override] where appropriate.

  • No functional changes were made; this should have no impact on existing behavior.
  • This is my first contribution to the project, so please let me know if there are any issues with the approach or conventions.

Thank you for your time and consideration!

@sno-windy sno-windy marked this pull request as draft August 23, 2025 15:09
@sno-windy sno-windy changed the title Add #[\Override] attribute Fix MissingOverrideAttribute errors by adding #[\Override] Aug 23, 2025
@sno-windy sno-windy marked this pull request as ready for review August 23, 2025 15:15
@coveralls
Copy link

coveralls commented Nov 3, 2025

Coverage Status

coverage: 99.608%. remained the same
when pulling 575d27c on sno-windy:feature/add-override-attribute
into 18d0fe0 on slimphp:4.x.

@akrabat
Copy link
Member

akrabat commented Nov 3, 2025

This seems useful as a way to spot when the method of a parent class has been changed and the children haven't been all updated.

I have fixed-up the PR to be current and enabled the relevant PHPStan configuration so that CI would pick it up.

The only thing I'm unsure of is whether this is a problem we have that wouldn't be caught in another way.

@odan
Copy link
Contributor

odan commented Nov 5, 2025

I think in most cases we define interfaces to avoid such issues. If a method or the signature does not fit, PHP (and PHPStan) will report this anyway. Tests should also cover such mistakes. So I don´t see a huge profit for now.

@akrabat
Copy link
Member

akrabat commented Nov 5, 2025

I think in most cases we define interfaces to avoid such issues. If a method or the signature does not fit, PHP (and PHPStan) will report this anyway. Tests should also cover such mistakes. So I don't see a huge profit for now.

I agree. While reflecting on it while playing with it it seems to me that #[\Override] is most useful for methods in a class where the parent is in another package and isn't covered by an interface.

Internally within Slim we should not be in a situation where we are override a non-interface method in a child class.

@akrabat
Copy link
Member

akrabat commented Nov 5, 2025

I'm closing this based on the discussion. This is no reflection on your work @sno-windy and entirely related to what we want in the project.

Thank you for working with Slim and I hope that this doesn't put you off contributing in the future.

@akrabat akrabat closed this Nov 5, 2025
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

Successfully merging this pull request may close these issues.

5 participants