Skip to content

Conversation

localheinz
Copy link
Contributor

This PR

  • adds a failing test demonstrating that PSR1_Sniffs_Methods_CamelCapsMethodNameSniff incorrectly determines that o_toString is a magic method while it shouldn't be
  • fixes the determination whether a string is a magic method
@localheinz localheinz force-pushed the fix/psr1-camel-caps-non-magic-methods branch from 3d74a34 to 66f9cb5 Compare February 16, 2015 15:26
@aik099
Copy link
Contributor

aik099 commented Feb 16, 2015

In other words the PSR1.Methods.CamelCapsMethodName sniff is considering o_toString a magic method and reports it as an error?

@localheinz
Copy link
Contributor Author

@aik099

Exactly!

@localheinz localheinz force-pushed the fix/psr1-camel-caps-non-magic-methods branch 2 times, most recently from 4ebb23d to 70624ab Compare February 16, 2015 15:46
@localheinz localheinz changed the title [WIP] Fix: PSR1_Sniffs_Methods_CamelCapsMethodNameSniff and magic method detections Fix: PSR1_Sniffs_Methods_CamelCapsMethodNameSniff and magic method detections Feb 16, 2015
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would this be worth pulling up into Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff?

@localheinz localheinz force-pushed the fix/psr1-camel-caps-non-magic-methods branch 3 times, most recently from 426a1bd to 70624ab Compare February 16, 2015 16:23
@localheinz localheinz force-pushed the fix/psr1-camel-caps-non-magic-methods branch from 70624ab to 92d524d Compare February 16, 2015 16:25
@aik099
Copy link
Contributor

aik099 commented Feb 16, 2015

Do we have any other magic method related code in other sniffs, that needs fixing in the same manner?

@localheinz
Copy link
Contributor Author

@aik099

Doesn't look like it, but there is a lot of repetition - maybe it's worth pulling this into a utility class?

@aik099
Copy link
Contributor

aik099 commented Feb 16, 2015

What I was thinking if there are similar magic method code in other sniffs. I haven't checked myself.

@aik099
Copy link
Contributor

aik099 commented Feb 16, 2015

But they look solid by matching __ just at the beginning of the method name.

gsherwood added a commit that referenced this pull request Feb 16, 2015
…-methods Fix: PSR1_Sniffs_Methods_CamelCapsMethodNameSniff and magic method detections
@gsherwood gsherwood merged commit 7a37034 into squizlabs:master Feb 16, 2015
@gsherwood
Copy link
Member

Thanks for the fix and the test.

@gsherwood gsherwood changed the title Fix: PSR1_Sniffs_Methods_CamelCapsMethodNameSniff and magic method detections PSR1_Sniffs_Methods_CamelCapsMethodNameSniff false positives for some magic method detection Feb 16, 2015
@localheinz localheinz deleted the fix/psr1-camel-caps-non-magic-methods branch February 16, 2015 21:56
Th3Mouk added a commit to Th3Mouk/PHP_CodeSniffer that referenced this pull request Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants