-
Notifications
You must be signed in to change notification settings - Fork 10
add configurable order function for Alphabetical Use Statement Sniff, fixes #5 #44
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
add configurable order function for Alphabetical Use Statement Sniff, fixes #5 #44
Conversation
README.md
Outdated
* in arrays, the key and `=>` operator must be on the same line | ||
* each consecutive variable assignment must align at the assignment operator | ||
* use statements must be sorted lexicographically | ||
* use statements must be sorted lexicographically, the order function can be configured |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how? ;)
4465223
to
ca937b5
Compare
@Ma27 👓 ! 😸 |
} else if ('string-case-insensitive' === $this->order) { | ||
return strcasecmp($a, $b); | ||
} else { | ||
return $this->dictionaryCompare($a, $b); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method falls back to dictionary
as validation approach by default. I've seen that PHPCS loves to mutate public properties using an XML, however I wonder if some kind of validation (e.g. throw an exception in here if order
has an invalid value) makes sense to avoid unexpected behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the check to register()
ca937b5
to
0e7bc21
Compare
* | ||
* @return int | ||
*/ | ||
private function dictionaryCompare($a, $b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aoldemeier could you check the correctness of this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After having realized I was confused about the signature of substr I am now convinced that the function is correct (making common sense assumptions about how dictionaryCompare should work)...
@xalopp please rebase :) |
920f2f9
to
daafdf0
Compare
class AlphabeticalUseStatementsSniff extends UseDeclarationSniff | ||
{ | ||
|
||
const NAMESPACE_SEPRATOR_STRING = '\\'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: "SEPRATOR" ->"SEPARATOR"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me (though fixing the typo would be nice to have)
* | ||
* @return int | ||
*/ | ||
private function dictionaryCompare($a, $b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After having realized I was confused about the signature of substr I am now convinced that the function is correct (making common sense assumptions about how dictionaryCompare should work)...
No description provided.