Skip to content

Commit

Permalink
Refactor Inflector Filter
Browse files Browse the repository at this point in the history
- Removes all getters and setters
- Requires a plugin manager in the constructor
- Makes the `target` option required
- Removes the ability to use a reference for the target
- Adds a factory for the filter

Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed Jan 7, 2025
1 parent 8c66c54 commit 4df1539
Show file tree
Hide file tree
Showing 9 changed files with 444 additions and 922 deletions.
144 changes: 0 additions & 144 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,99 +218,6 @@
<code><![CDATA[(string) $value]]></code>
</RedundantCastGivenDocblockType>
</file>
<file src="src/Inflector.php">
<ArgumentTypeCoercion>
<code><![CDATA[$options['pluginManager']]]></code>
</ArgumentTypeCoercion>
<DeprecatedClass>
<code><![CDATA[AbstractFilter]]></code>
</DeprecatedClass>
<InvalidArgument>
<code><![CDATA[array_values($processedParts)]]></code>
</InvalidArgument>
<InvalidArrayAccess>
<code><![CDATA[$spec[0]]]></code>
</InvalidArrayAccess>
<InvalidArrayOffset>
<code><![CDATA[$value[ltrim($sourceName, ':')]]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$options['pluginManager']]]></code>
<code><![CDATA[$options['rules']]]></code>
<code><![CDATA[$options['target']]]></code>
<code><![CDATA[$options['targetReplacementIdentifier']]]></code>
<code><![CDATA[$options['throwTargetExceptionsOn']]]></code>
<code><![CDATA[$processedPart]]></code>
<code><![CDATA[$rule]]></code>
<code><![CDATA[$rules[$spec]]]></code>
<code><![CDATA[$spec]]></code>
<code><![CDATA[$value[$ruleName]]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$sourceName]]></code>
<code><![CDATA[$spec]]></code>
</MixedArgumentTypeCoercion>
<MixedArrayAssignment>
<code><![CDATA[$this->rules[$spec][]]]></code>
</MixedArrayAssignment>
<MixedAssignment>
<code><![CDATA[$processedPart]]></code>
<code><![CDATA[$processedPart]]></code>
<code><![CDATA[$rule]]></code>
<code><![CDATA[$ruleFilter]]></code>
<code><![CDATA[$ruleValue]]></code>
<code><![CDATA[$sourceValue]]></code>
<code><![CDATA[$temp['rules']]]></code>
<code><![CDATA[$temp['target']]]></code>
<code><![CDATA[$temp['targetReplacementIdentifier']]]></code>
<code><![CDATA[$temp['throwTargetExceptionsOn']]]></code>
<code><![CDATA[$value[ltrim($sourceName, ':')]]]></code>
</MixedAssignment>
<MixedFunctionCall>
<code><![CDATA[$ruleFilter($processedPart)]]></code>
</MixedFunctionCall>
<MixedInferredReturnType>
<code><![CDATA[FilterInterface|callable(mixed): mixed]]></code>
<code><![CDATA[FilterInterface|false]]></code>
<code><![CDATA[array|false]]></code>
</MixedInferredReturnType>
<MixedMethodCall>
<code><![CDATA[new $options['pluginManager']()]]></code>
</MixedMethodCall>
<MixedReturnStatement>
<code><![CDATA[$this->getPluginManager()->get($rule)]]></code>
<code><![CDATA[$this->getPluginManager()->get($rule)]]></code>
<code><![CDATA[$this->rules[$spec]]]></code>
<code><![CDATA[$this->rules[$spec][$index]]]></code>
</MixedReturnStatement>
<MixedStringOffsetAssignment>
<code><![CDATA[$value[ltrim($sourceName, ':')]]]></code>
</MixedStringOffsetAssignment>
<MoreSpecificImplementedParamType>
<code><![CDATA[$value]]></code>
</MoreSpecificImplementedParamType>
<PossiblyUnusedReturnValue>
<code><![CDATA[self]]></code>
</PossiblyUnusedReturnValue>
<PropertyNotSetInConstructor>
<code><![CDATA[$pluginManager]]></code>
<code><![CDATA[$target]]></code>
</PropertyNotSetInConstructor>
<RedundantCast>
<code><![CDATA[(string) $targetReplacementIdentifier]]></code>
</RedundantCast>
<RedundantCastGivenDocblockType>
<code><![CDATA[(bool) $throwTargetExceptionsOn]]></code>
<code><![CDATA[(string) $rule]]></code>
<code><![CDATA[(string) $spec]]></code>
<code><![CDATA[(string) $target]]></code>
<code><![CDATA[(string) $value]]></code>
</RedundantCastGivenDocblockType>
<UnusedParam>
<code><![CDATA[$reference]]></code>
<code><![CDATA[$target]]></code>
</UnusedParam>
</file>
<file src="src/Module.php">
<UnusedClass>
<code><![CDATA[Module]]></code>
Expand Down Expand Up @@ -393,55 +300,4 @@
<code><![CDATA[setQuoteStyle]]></code>
</DeprecatedMethod>
</file>
<file src="test/InflectorTest.php">
<DocblockTypeContradiction>
<code><![CDATA[assertNull]]></code>
<code><![CDATA[assertSame]]></code>
</DocblockTypeContradiction>
<InvalidCast>
<code><![CDATA[$rule]]></code>
<code><![CDATA[$rule]]></code>
</InvalidCast>
<MissingParamType>
<code><![CDATA[$inflector]]></code>
</MissingParamType>
<MissingReturnType>
<code><![CDATA[_testOptions]]></code>
</MissingReturnType>
<MixedArgument>
<code><![CDATA[$options['rules'][':action']]]></code>
<code><![CDATA[$options['rules'][':controller']]]></code>
<code><![CDATA[$rules['controller']]]></code>
<code><![CDATA[$rules['controller']]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$rule]]></code>
<code><![CDATA[$rule]]></code>
</MixedArgumentTypeCoercion>
<MixedAssignment>
<code><![CDATA[$filtered]]></code>
<code><![CDATA[$filtered]]></code>
<code><![CDATA[$filtered]]></code>
<code><![CDATA[$rules]]></code>
</MixedAssignment>
<MixedMethodCall>
<code><![CDATA[getPluginManager]]></code>
<code><![CDATA[getRules]]></code>
<code><![CDATA[getTarget]]></code>
<code><![CDATA[getTargetReplacementIdentifier]]></code>
<code><![CDATA[isThrowTargetExceptionsOn]]></code>
</MixedMethodCall>
<MixedOperand>
<code><![CDATA[$rule]]></code>
</MixedOperand>
<PossiblyFalseArgument>
<code><![CDATA[$rules]]></code>
<code><![CDATA[$rules]]></code>
</PossiblyFalseArgument>
<UnusedVariable>
<code><![CDATA[$filtered]]></code>
<code><![CDATA[$rule]]></code>
<code><![CDATA[$target]]></code>
</UnusedVariable>
</file>
</files>
2 changes: 1 addition & 1 deletion src/FilterPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class FilterPluginManager extends AbstractPluginManager
ForceUriScheme::class => InvokableFactory::class,
HtmlEntities::class => InvokableFactory::class,
ImmutableFilterChain::class => ImmutableFilterChainFactory::class,
Inflector::class => InvokableFactory::class,
Inflector::class => InflectorFactory::class,
ToFloat::class => InvokableFactory::class,
MonthSelect::class => InvokableFactory::class,
UpperCaseWords::class => InvokableFactory::class,
Expand Down
Loading

0 comments on commit 4df1539

Please sign in to comment.