cocur / slugify

Converts a string to a slug. Includes integrations for Symfony, Silex, Laravel, Zend Framework 2, Twig, Nette and Latte.
MIT License
2.89k stars 252 forks source link

Add handling for undefined rulesets #309

Closed aadmathijssen closed 2 years ago

aadmathijssen commented 2 years ago

When supplying the ruleset option with an unknown ruleset to \Cocur\Slugify\Slugify::__construct, the following error occurs:

Notice: Undefined index: foo in /path/to/vendor/cocur/slugify/src/RuleProvider/DefaultRuleProvider.php on line 8616
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Cocur\Slugify\Slugify::addRules() must be of the type array, null given, called in /path/to/vendor/cocur/slugify/src/Slugify.php on line 178 and defined in /path/to/vendor/cocur/slugify/src/Slugify.php:162

This PR detects this and throws and OutOfBoundsException instead.

florianeckerstorfer commented 2 years ago

@aadmathijssen Thank you very much for the PR 👏