vendor/symfony/config/Definition/Builder/NormalizationBuilder.php line 51

  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Config\Definition\Builder;
  11. /**
  12.  * This class builds normalization conditions.
  13.  *
  14.  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  15.  */
  16. class NormalizationBuilder
  17. {
  18.     protected $node;
  19.     public $before = [];
  20.     public $declaredTypes = [];
  21.     public $remappings = [];
  22.     public function __construct(NodeDefinition $node)
  23.     {
  24.         $this->node $node;
  25.     }
  26.     /**
  27.      * Registers a key to remap to its plural form.
  28.      *
  29.      * @param string      $key    The key to remap
  30.      * @param string|null $plural The plural of the key in case of irregular plural
  31.      *
  32.      * @return $this
  33.      */
  34.     public function remap(string $keystring $plural null): static
  35.     {
  36.         $this->remappings[] = [$keynull === $plural $key.'s' $plural];
  37.         return $this;
  38.     }
  39.     /**
  40.      * Registers a closure to run before the normalization or an expression builder to build it if null is provided.
  41.      *
  42.      * @return ExprBuilder|$this
  43.      */
  44.     public function before(\Closure $closure null): ExprBuilder|static
  45.     {
  46.         if (null !== $closure) {
  47.             $this->before[] = $closure;
  48.             return $this;
  49.         }
  50.         return $this->before[] = new ExprBuilder($this->node);
  51.     }
  52. }