Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor #6629 Update options_resolver.rst (atailouloute)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #6629). Discussion ---------- Update options_resolver.rst The old code will not work as expected if the `host` option starts with `https`, the `substr` function will return `https:/` and not `https://`. ```php $resolver = new Symfony\Component\OptionsResolver\OptionsResolver; $resolver->setDefined(['host', 'encryption']); $resolver->setNormalizer('host', function (Options $options, $value) { if (!in_array(substr($value, 0, 7), array('http://', 'https://'))) { if ('ssl' === $options['encryption']) { $value = 'https://'.$value; } else { $value = 'http://'.$value; } } return $value; });; $options = $resolver->resolve(array( 'host' => 'https://symfony.com/', 'encryption' => 'ssl' )); echo $options['host']; // Expected value : https://symfony.com/ // Result : https://https://symfony.com/ ``` Commits ------- a474785 Update options_resolver.rst
- Loading branch information