diff --git a/README.rst b/README.rst index 200c97ce45f..b8dc3271c81 100644 --- a/README.rst +++ b/README.rst @@ -423,7 +423,8 @@ Choose from the list of available rules: * **constant_case** [@PSR2, @Symfony, @PhpCsFixer] - The PHP constants ``true``, ``false``, and ``null`` MUST be in lower case. + The PHP constants ``true``, ``false``, and ``null`` MUST be written using the + correct casing. Configuration options: diff --git a/src/Fixer/Casing/ConstantCaseFixer.php b/src/Fixer/Casing/ConstantCaseFixer.php index 98b57829700..c476269b595 100644 --- a/src/Fixer/Casing/ConstantCaseFixer.php +++ b/src/Fixer/Casing/ConstantCaseFixer.php @@ -23,9 +23,9 @@ use PhpCsFixer\Tokenizer\Tokens; /** - * Fixer for rules defined in PSR2 ¶2.5. + * Fixer for constants case. * - * @author Dariusz Rumiński + * @author Pol Dellaiera */ final class ConstantCaseFixer extends AbstractFixer implements ConfigurationDefinitionFixerInterface { @@ -44,11 +44,15 @@ public function configure(array $configuration = null) parent::configure($configuration); if ('lower' === $this->configuration['case']) { - $this->fixFunction = 'strtolower'; + $this->fixFunction = static function ($token) { + return strtolower($token); + }; } if ('upper' === $this->configuration['case']) { - $this->fixFunction = 'strtoupper'; + $this->fixFunction = static function ($token) { + return strtoupper($token); + }; } } @@ -58,7 +62,7 @@ public function configure(array $configuration = null) public function getDefinition() { return new FixerDefinition( - 'The PHP constants `true`, `false`, and `null` MUST be in lower case.', + 'The PHP constants `true`, `false`, and `null` MUST be written using the correct casing.', [new CodeSample("