Skip to content

Commit

Permalink
minor #5733 [Components][OptionsResolver] adding type hint to normali…
Browse files Browse the repository at this point in the history
…zer callback (xabbuh)

This PR was merged into the 2.7 branch.

Discussion
----------

[Components][OptionsResolver] adding type hint to normalizer callback

Technically, the type hint is not necessary but it makes the code more
readable.

Commits
-------

8996aa9 adding type hint to normalizer callback
  • Loading branch information
xabbuh committed Oct 5, 2015
2 parents 11033bd + 8996aa9 commit fdbc41c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/options_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ that, you can write normalizers. Normalizers are executed after validating an
option. You can configure a normalizer by calling
:method:`Symfony\\Component\\OptionsResolver\\OptionsResolver::setNormalizer`::

use Symfony\Component\OptionsResolver\Options;

// ...
class Mailer
{
Expand All @@ -436,7 +438,7 @@ option. You can configure a normalizer by calling
{
// ...

$resolver->setNormalizer('host', function ($options, $value) {
$resolver->setNormalizer('host', function (Options $options, $value) {
if ('http://' !== substr($value, 0, 7)) {
$value = 'http://'.$value;
}
Expand All @@ -462,7 +464,7 @@ if you need to use other options during normalization::
public function configureOptions(OptionsResolver $resolver)
{
// ...
$resolver->setNormalizer('host', function ($options, $value) {
$resolver->setNormalizer('host', function (Options $options, $value) {
if (!in_array(substr($value, 0, 7), array('http://', 'https://'))) {
if ('ssl' === $options['encryption']) {
$value = 'https://'.$value;
Expand Down

0 comments on commit fdbc41c

Please sign in to comment.