diff vendor/symfony/dom-crawler/FormFieldRegistry.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 7a779792577d
children af1871eacc83
line wrap: on
line diff
--- a/vendor/symfony/dom-crawler/FormFieldRegistry.php	Tue Jul 10 15:07:59 2018 +0100
+++ b/vendor/symfony/dom-crawler/FormFieldRegistry.php	Thu Feb 28 13:21:36 2019 +0000
@@ -20,7 +20,7 @@
  */
 class FormFieldRegistry
 {
-    private $fields = array();
+    private $fields = [];
 
     private $base;
 
@@ -33,8 +33,8 @@
 
         $target = &$this->fields;
         while ($segments) {
-            if (!is_array($target)) {
-                $target = array();
+            if (!\is_array($target)) {
+                $target = [];
             }
             $path = array_shift($segments);
             if ('' === $path) {
@@ -55,7 +55,7 @@
     {
         $segments = $this->getSegments($name);
         $target = &$this->fields;
-        while (count($segments) > 1) {
+        while (\count($segments) > 1) {
             $path = array_shift($segments);
             if (!array_key_exists($path, $target)) {
                 return;
@@ -118,9 +118,9 @@
     public function set($name, $value)
     {
         $target = &$this->get($name);
-        if ((!is_array($value) && $target instanceof Field\FormField) || $target instanceof Field\ChoiceFormField) {
+        if ((!\is_array($value) && $target instanceof Field\FormField) || $target instanceof Field\ChoiceFormField) {
             $target->setValue($value);
-        } elseif (is_array($value)) {
+        } elseif (\is_array($value)) {
             $fields = self::create($name, $value);
             foreach ($fields->all() as $k => $v) {
                 $this->set($k, $v);
@@ -133,7 +133,7 @@
     /**
      * Returns the list of field with their value.
      *
-     * @return FormField[] The list of fields as array((string) Fully qualified name => (mixed) value)
+     * @return FormField[] The list of fields as [string] Fully qualified name => (mixed) value)
      */
     public function all()
     {
@@ -167,13 +167,13 @@
      * @param string $base   The name of the base field
      * @param array  $output The initial values
      *
-     * @return array The list of fields as array((string) Fully qualified name => (mixed) value)
+     * @return array The list of fields as [string] Fully qualified name => (mixed) value)
      */
-    private function walk(array $array, $base = '', array &$output = array())
+    private function walk(array $array, $base = '', array &$output = [])
     {
         foreach ($array as $k => $v) {
             $path = empty($base) ? $k : sprintf('%s[%s]', $base, $k);
-            if (is_array($v)) {
+            if (\is_array($v)) {
                 $this->walk($v, $path, $output);
             } else {
                 $output[$path] = $v;
@@ -186,9 +186,7 @@
     /**
      * Splits a field name into segments as a web browser would do.
      *
-     * <code>
-     *     getSegments('base[foo][3][]') = array('base', 'foo, '3', '');
-     * </code>
+     *     getSegments('base[foo][3][]') = ['base', 'foo, '3', ''];
      *
      * @param string $name The name of the field
      *
@@ -197,7 +195,7 @@
     private function getSegments($name)
     {
         if (preg_match('/^(?P<base>[^[]+)(?P<extra>(\[.*)|$)/', $name, $m)) {
-            $segments = array($m['base']);
+            $segments = [$m['base']];
             while (!empty($m['extra'])) {
                 $extra = $m['extra'];
                 if (preg_match('/^\[(?P<segment>.*?)\](?P<extra>.*)$/', $extra, $m)) {
@@ -210,6 +208,6 @@
             return $segments;
         }
 
-        return array($name);
+        return [$name];
     }
 }