[CodingStandard] Add ClassNameSuffixByParentFixer #633
Conversation
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.
Nice to have this one 👏
$classTokensAnalyzer = ClassWrapper::createFromTokensArrayStartPosition($tokens, $index); | ||
dump($classTokensAnalyzer->getName()); | ||
dump($classTokensAnalyzer->getParentClassName()); | ||
die; |
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 looks like debug code
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.
Yep, sorry
'<?php | ||
class SomeClass extends Command | ||
{ | ||
}' |
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.
Personally I recommend using NEWDOC syntax for multiline strings.
public function configure(?array $configuration = null): void | ||
{ | ||
if ($configuration === null) { | ||
return; |
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.
I don't think this does what it's supposed to. Quoting from ConfigurableFixerInterface::configure()
:
* New configuration must override current one, not patch it.
* Using `null` makes fixer to use default configuration (or reset configuration from previously configured back
* to default one).
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 the code should look like then?
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.
From what I see in default fixtures it should call $this->configuration = $this->getConfigurationDefinition()->resolve([]);
. However it is not too important because
@trigger_error(
'Passing NULL to set default configuration is deprecated and will not be supported in 3.0, use an empty array instead.',
E_USER_DEPRECATED
);
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.
Alright, I already call that in ctor to prevent missed configuration call.
So here it doesn't have sense anymore
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.
Alright, I already call that in ctor to prevent missed configuration call.
So here it doesn't have sense anymore
I've added support for interface types as well. Any ideas to improve default type map? /**
* @var string[]
*/
private $defaultParentClassToSuffixMap = [
'*Command' => 'Command',
'*Controller' => 'Controller',
'*Repository' => 'Repository',
'*Presenter' => 'Presenter',
'*Request' => 'Request',
'*EventSubscriber' => 'EventSubscriber',
'*FixerInterface' => 'Fixer',
'*Sniff' => 'Sniff',
]; |
Maybe this should be added.
|
@enumag Yes, thanks! |
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.
I like the idea! It will be useful in my projects as well.
@lexinek Thanks bro! Any thing to add to the list? CommandHandler maybe? |
Yeah i was thinking about it, but i think these are more specific and i think more individual. Could be There are really alot of them, are you sure you would like to add them all here instead of giving more freedom to users? Because naming conventions can be very different in different companies. |
@lexinek Well, the fixer is customizable, so anyone can use anything they like 🏳️ |
I liked
|
I've added support for interface version as well So |
Closes #607