Skip to content

Commit fdbc41c

Browse files
committed
minor #5733 [Components][OptionsResolver] adding type hint to normalizer 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
2 parents 11033bd + 8996aa9 commit fdbc41c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

components/options_resolver.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,8 @@ that, you can write normalizers. Normalizers are executed after validating an
427427
option. You can configure a normalizer by calling
428428
:method:`Symfony\\Component\\OptionsResolver\\OptionsResolver::setNormalizer`::
429429

430+
use Symfony\Component\OptionsResolver\Options;
431+
430432
// ...
431433
class Mailer
432434
{
@@ -436,7 +438,7 @@ option. You can configure a normalizer by calling
436438
{
437439
// ...
438440

439-
$resolver->setNormalizer('host', function ($options, $value) {
441+
$resolver->setNormalizer('host', function (Options $options, $value) {
440442
if ('http://' !== substr($value, 0, 7)) {
441443
$value = 'http://'.$value;
442444
}
@@ -462,7 +464,7 @@ if you need to use other options during normalization::
462464
public function configureOptions(OptionsResolver $resolver)
463465
{
464466
// ...
465-
$resolver->setNormalizer('host', function ($options, $value) {
467+
$resolver->setNormalizer('host', function (Options $options, $value) {
466468
if (!in_array(substr($value, 0, 7), array('http://', 'https://'))) {
467469
if ('ssl' === $options['encryption']) {
468470
$value = 'https://'.$value;

0 commit comments

Comments
 (0)