Completed
Push — develop ( 8fa888...940939 )
by Zack
20:02
created
vendor/symfony/console/Input/InputOption.php 3 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -61,37 +61,37 @@  discard block
 block discarded – undo
61 61
      *
62 62
      * @throws InvalidArgumentException If option mode is invalid or incompatible
63 63
      */
64
-    public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
64
+    public function __construct( string $name, $shortcut = null, int $mode = null, string $description = '', $default = null )
65 65
     {
66
-        if (str_starts_with($name, '--')) {
67
-            $name = substr($name, 2);
66
+        if ( str_starts_with( $name, '--' ) ) {
67
+            $name = substr( $name, 2 );
68 68
         }
69 69
 
70
-        if (empty($name)) {
71
-            throw new InvalidArgumentException('An option name cannot be empty.');
70
+        if ( empty( $name ) ) {
71
+            throw new InvalidArgumentException( 'An option name cannot be empty.' );
72 72
         }
73 73
 
74
-        if (empty($shortcut)) {
74
+        if ( empty( $shortcut ) ) {
75 75
             $shortcut = null;
76 76
         }
77 77
 
78
-        if (null !== $shortcut) {
79
-            if (\is_array($shortcut)) {
80
-                $shortcut = implode('|', $shortcut);
78
+        if ( null !== $shortcut ) {
79
+            if ( \is_array( $shortcut ) ) {
80
+                $shortcut = implode( '|', $shortcut );
81 81
             }
82
-            $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
83
-            $shortcuts = array_filter($shortcuts);
84
-            $shortcut = implode('|', $shortcuts);
82
+            $shortcuts = preg_split( '{(\|)-?}', ltrim( $shortcut, '-' ) );
83
+            $shortcuts = array_filter( $shortcuts );
84
+            $shortcut = implode( '|', $shortcuts );
85 85
 
86
-            if (empty($shortcut)) {
87
-                throw new InvalidArgumentException('An option shortcut cannot be empty.');
86
+            if ( empty( $shortcut ) ) {
87
+                throw new InvalidArgumentException( 'An option shortcut cannot be empty.' );
88 88
             }
89 89
         }
90 90
 
91
-        if (null === $mode) {
91
+        if ( null === $mode ) {
92 92
             $mode = self::VALUE_NONE;
93
-        } elseif ($mode >= (self::VALUE_NEGATABLE << 1) || $mode < 1) {
94
-            throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
93
+        } elseif ( $mode >= ( self::VALUE_NEGATABLE << 1 ) || $mode < 1 ) {
94
+            throw new InvalidArgumentException( sprintf( 'Option mode "%s" is not valid.', $mode ) );
95 95
         }
96 96
 
97 97
         $this->name = $name;
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
         $this->mode = $mode;
100 100
         $this->description = $description;
101 101
 
102
-        if ($this->isArray() && !$this->acceptValue()) {
103
-            throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
102
+        if ( $this->isArray() && ! $this->acceptValue() ) {
103
+            throw new InvalidArgumentException( 'Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.' );
104 104
         }
105
-        if ($this->isNegatable() && $this->acceptValue()) {
106
-            throw new InvalidArgumentException('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.');
105
+        if ( $this->isNegatable() && $this->acceptValue() ) {
106
+            throw new InvalidArgumentException( 'Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.' );
107 107
         }
108 108
 
109
-        $this->setDefault($default);
109
+        $this->setDefault( $default );
110 110
     }
111 111
 
112 112
     /**
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     public function isValueRequired()
148 148
     {
149
-        return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
149
+        return self::VALUE_REQUIRED === ( self::VALUE_REQUIRED & $this->mode );
150 150
     }
151 151
 
152 152
     /**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public function isValueOptional()
158 158
     {
159
-        return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
159
+        return self::VALUE_OPTIONAL === ( self::VALUE_OPTIONAL & $this->mode );
160 160
     }
161 161
 
162 162
     /**
@@ -166,28 +166,28 @@  discard block
 block discarded – undo
166 166
      */
167 167
     public function isArray()
168 168
     {
169
-        return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
169
+        return self::VALUE_IS_ARRAY === ( self::VALUE_IS_ARRAY & $this->mode );
170 170
     }
171 171
 
172 172
     public function isNegatable(): bool
173 173
     {
174
-        return self::VALUE_NEGATABLE === (self::VALUE_NEGATABLE & $this->mode);
174
+        return self::VALUE_NEGATABLE === ( self::VALUE_NEGATABLE & $this->mode );
175 175
     }
176 176
 
177 177
     /**
178 178
      * @param string|bool|int|float|array|null $default
179 179
      */
180
-    public function setDefault($default = null)
180
+    public function setDefault( $default = null )
181 181
     {
182
-        if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
183
-            throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
182
+        if ( self::VALUE_NONE === ( self::VALUE_NONE & $this->mode ) && null !== $default ) {
183
+            throw new LogicException( 'Cannot set a default value when using InputOption::VALUE_NONE mode.' );
184 184
         }
185 185
 
186
-        if ($this->isArray()) {
187
-            if (null === $default) {
188
-                $default = [];
189
-            } elseif (!\is_array($default)) {
190
-                throw new LogicException('A default value for an array option must be an array.');
186
+        if ( $this->isArray() ) {
187
+            if ( null === $default ) {
188
+                $default = [ ];
189
+            } elseif ( ! \is_array( $default ) ) {
190
+                throw new LogicException( 'A default value for an array option must be an array.' );
191 191
             }
192 192
         }
193 193
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
      *
220 220
      * @return bool
221 221
      */
222
-    public function equals(self $option)
222
+    public function equals( self $option )
223 223
     {
224 224
         return $option->getName() === $this->getName()
225 225
             && $option->getShortcut() === $this->getShortcut()
Please login to merge, or discard this patch.
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -21,211 +21,211 @@
 block discarded – undo
21 21
  */
22 22
 class InputOption
23 23
 {
24
-    /**
25
-     * Do not accept input for the option (e.g. --yell). This is the default behavior of options.
26
-     */
27
-    public const VALUE_NONE = 1;
28
-
29
-    /**
30
-     * A value must be passed when the option is used (e.g. --iterations=5 or -i5).
31
-     */
32
-    public const VALUE_REQUIRED = 2;
33
-
34
-    /**
35
-     * The option may or may not have a value (e.g. --yell or --yell=loud).
36
-     */
37
-    public const VALUE_OPTIONAL = 4;
38
-
39
-    /**
40
-     * The option accepts multiple values (e.g. --dir=/foo --dir=/bar).
41
-     */
42
-    public const VALUE_IS_ARRAY = 8;
43
-
44
-    /**
45
-     * The option may have either positive or negative value (e.g. --ansi or --no-ansi).
46
-     */
47
-    public const VALUE_NEGATABLE = 16;
48
-
49
-    private $name;
50
-    private $shortcut;
51
-    private $mode;
52
-    private $default;
53
-    private $description;
54
-
55
-    /**
56
-     * @param string|array|null                $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
57
-     * @param int|null                         $mode     The option mode: One of the VALUE_* constants
58
-     * @param string|bool|int|float|array|null $default  The default value (must be null for self::VALUE_NONE)
59
-     *
60
-     * @throws InvalidArgumentException If option mode is invalid or incompatible
61
-     */
62
-    public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
63
-    {
64
-        if (str_starts_with($name, '--')) {
65
-            $name = substr($name, 2);
66
-        }
67
-
68
-        if (empty($name)) {
69
-            throw new InvalidArgumentException('An option name cannot be empty.');
70
-        }
71
-
72
-        if (empty($shortcut)) {
73
-            $shortcut = null;
74
-        }
75
-
76
-        if (null !== $shortcut) {
77
-            if (\is_array($shortcut)) {
78
-                $shortcut = implode('|', $shortcut);
79
-            }
80
-            $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
81
-            $shortcuts = array_filter($shortcuts);
82
-            $shortcut = implode('|', $shortcuts);
83
-
84
-            if (empty($shortcut)) {
85
-                throw new InvalidArgumentException('An option shortcut cannot be empty.');
86
-            }
87
-        }
88
-
89
-        if (null === $mode) {
90
-            $mode = self::VALUE_NONE;
91
-        } elseif ($mode >= (self::VALUE_NEGATABLE << 1) || $mode < 1) {
92
-            throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
93
-        }
94
-
95
-        $this->name = $name;
96
-        $this->shortcut = $shortcut;
97
-        $this->mode = $mode;
98
-        $this->description = $description;
99
-
100
-        if ($this->isArray() && !$this->acceptValue()) {
101
-            throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
102
-        }
103
-        if ($this->isNegatable() && $this->acceptValue()) {
104
-            throw new InvalidArgumentException('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.');
105
-        }
106
-
107
-        $this->setDefault($default);
108
-    }
109
-
110
-    /**
111
-     * Returns the option shortcut.
112
-     *
113
-     * @return string|null
114
-     */
115
-    public function getShortcut()
116
-    {
117
-        return $this->shortcut;
118
-    }
119
-
120
-    /**
121
-     * Returns the option name.
122
-     *
123
-     * @return string
124
-     */
125
-    public function getName()
126
-    {
127
-        return $this->name;
128
-    }
129
-
130
-    /**
131
-     * Returns true if the option accepts a value.
132
-     *
133
-     * @return bool true if value mode is not self::VALUE_NONE, false otherwise
134
-     */
135
-    public function acceptValue()
136
-    {
137
-        return $this->isValueRequired() || $this->isValueOptional();
138
-    }
139
-
140
-    /**
141
-     * Returns true if the option requires a value.
142
-     *
143
-     * @return bool true if value mode is self::VALUE_REQUIRED, false otherwise
144
-     */
145
-    public function isValueRequired()
146
-    {
147
-        return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
148
-    }
149
-
150
-    /**
151
-     * Returns true if the option takes an optional value.
152
-     *
153
-     * @return bool true if value mode is self::VALUE_OPTIONAL, false otherwise
154
-     */
155
-    public function isValueOptional()
156
-    {
157
-        return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
158
-    }
159
-
160
-    /**
161
-     * Returns true if the option can take multiple values.
162
-     *
163
-     * @return bool true if mode is self::VALUE_IS_ARRAY, false otherwise
164
-     */
165
-    public function isArray()
166
-    {
167
-        return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
168
-    }
169
-
170
-    public function isNegatable(): bool
171
-    {
172
-        return self::VALUE_NEGATABLE === (self::VALUE_NEGATABLE & $this->mode);
173
-    }
174
-
175
-    /**
176
-     * @param string|bool|int|float|array|null $default
177
-     */
178
-    public function setDefault($default = null)
179
-    {
180
-        if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
181
-            throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
182
-        }
183
-
184
-        if ($this->isArray()) {
185
-            if (null === $default) {
186
-                $default = [];
187
-            } elseif (!\is_array($default)) {
188
-                throw new LogicException('A default value for an array option must be an array.');
189
-            }
190
-        }
191
-
192
-        $this->default = $this->acceptValue() || $this->isNegatable() ? $default : false;
193
-    }
194
-
195
-    /**
196
-     * Returns the default value.
197
-     *
198
-     * @return string|bool|int|float|array|null
199
-     */
200
-    public function getDefault()
201
-    {
202
-        return $this->default;
203
-    }
204
-
205
-    /**
206
-     * Returns the description text.
207
-     *
208
-     * @return string
209
-     */
210
-    public function getDescription()
211
-    {
212
-        return $this->description;
213
-    }
214
-
215
-    /**
216
-     * Checks whether the given option equals this one.
217
-     *
218
-     * @return bool
219
-     */
220
-    public function equals(self $option)
221
-    {
222
-        return $option->getName() === $this->getName()
223
-            && $option->getShortcut() === $this->getShortcut()
224
-            && $option->getDefault() === $this->getDefault()
225
-            && $option->isNegatable() === $this->isNegatable()
226
-            && $option->isArray() === $this->isArray()
227
-            && $option->isValueRequired() === $this->isValueRequired()
228
-            && $option->isValueOptional() === $this->isValueOptional()
229
-        ;
230
-    }
24
+	/**
25
+	 * Do not accept input for the option (e.g. --yell). This is the default behavior of options.
26
+	 */
27
+	public const VALUE_NONE = 1;
28
+
29
+	/**
30
+	 * A value must be passed when the option is used (e.g. --iterations=5 or -i5).
31
+	 */
32
+	public const VALUE_REQUIRED = 2;
33
+
34
+	/**
35
+	 * The option may or may not have a value (e.g. --yell or --yell=loud).
36
+	 */
37
+	public const VALUE_OPTIONAL = 4;
38
+
39
+	/**
40
+	 * The option accepts multiple values (e.g. --dir=/foo --dir=/bar).
41
+	 */
42
+	public const VALUE_IS_ARRAY = 8;
43
+
44
+	/**
45
+	 * The option may have either positive or negative value (e.g. --ansi or --no-ansi).
46
+	 */
47
+	public const VALUE_NEGATABLE = 16;
48
+
49
+	private $name;
50
+	private $shortcut;
51
+	private $mode;
52
+	private $default;
53
+	private $description;
54
+
55
+	/**
56
+	 * @param string|array|null                $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
57
+	 * @param int|null                         $mode     The option mode: One of the VALUE_* constants
58
+	 * @param string|bool|int|float|array|null $default  The default value (must be null for self::VALUE_NONE)
59
+	 *
60
+	 * @throws InvalidArgumentException If option mode is invalid or incompatible
61
+	 */
62
+	public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
63
+	{
64
+		if (str_starts_with($name, '--')) {
65
+			$name = substr($name, 2);
66
+		}
67
+
68
+		if (empty($name)) {
69
+			throw new InvalidArgumentException('An option name cannot be empty.');
70
+		}
71
+
72
+		if (empty($shortcut)) {
73
+			$shortcut = null;
74
+		}
75
+
76
+		if (null !== $shortcut) {
77
+			if (\is_array($shortcut)) {
78
+				$shortcut = implode('|', $shortcut);
79
+			}
80
+			$shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
81
+			$shortcuts = array_filter($shortcuts);
82
+			$shortcut = implode('|', $shortcuts);
83
+
84
+			if (empty($shortcut)) {
85
+				throw new InvalidArgumentException('An option shortcut cannot be empty.');
86
+			}
87
+		}
88
+
89
+		if (null === $mode) {
90
+			$mode = self::VALUE_NONE;
91
+		} elseif ($mode >= (self::VALUE_NEGATABLE << 1) || $mode < 1) {
92
+			throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
93
+		}
94
+
95
+		$this->name = $name;
96
+		$this->shortcut = $shortcut;
97
+		$this->mode = $mode;
98
+		$this->description = $description;
99
+
100
+		if ($this->isArray() && !$this->acceptValue()) {
101
+			throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
102
+		}
103
+		if ($this->isNegatable() && $this->acceptValue()) {
104
+			throw new InvalidArgumentException('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.');
105
+		}
106
+
107
+		$this->setDefault($default);
108
+	}
109
+
110
+	/**
111
+	 * Returns the option shortcut.
112
+	 *
113
+	 * @return string|null
114
+	 */
115
+	public function getShortcut()
116
+	{
117
+		return $this->shortcut;
118
+	}
119
+
120
+	/**
121
+	 * Returns the option name.
122
+	 *
123
+	 * @return string
124
+	 */
125
+	public function getName()
126
+	{
127
+		return $this->name;
128
+	}
129
+
130
+	/**
131
+	 * Returns true if the option accepts a value.
132
+	 *
133
+	 * @return bool true if value mode is not self::VALUE_NONE, false otherwise
134
+	 */
135
+	public function acceptValue()
136
+	{
137
+		return $this->isValueRequired() || $this->isValueOptional();
138
+	}
139
+
140
+	/**
141
+	 * Returns true if the option requires a value.
142
+	 *
143
+	 * @return bool true if value mode is self::VALUE_REQUIRED, false otherwise
144
+	 */
145
+	public function isValueRequired()
146
+	{
147
+		return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
148
+	}
149
+
150
+	/**
151
+	 * Returns true if the option takes an optional value.
152
+	 *
153
+	 * @return bool true if value mode is self::VALUE_OPTIONAL, false otherwise
154
+	 */
155
+	public function isValueOptional()
156
+	{
157
+		return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
158
+	}
159
+
160
+	/**
161
+	 * Returns true if the option can take multiple values.
162
+	 *
163
+	 * @return bool true if mode is self::VALUE_IS_ARRAY, false otherwise
164
+	 */
165
+	public function isArray()
166
+	{
167
+		return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
168
+	}
169
+
170
+	public function isNegatable(): bool
171
+	{
172
+		return self::VALUE_NEGATABLE === (self::VALUE_NEGATABLE & $this->mode);
173
+	}
174
+
175
+	/**
176
+	 * @param string|bool|int|float|array|null $default
177
+	 */
178
+	public function setDefault($default = null)
179
+	{
180
+		if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
181
+			throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
182
+		}
183
+
184
+		if ($this->isArray()) {
185
+			if (null === $default) {
186
+				$default = [];
187
+			} elseif (!\is_array($default)) {
188
+				throw new LogicException('A default value for an array option must be an array.');
189
+			}
190
+		}
191
+
192
+		$this->default = $this->acceptValue() || $this->isNegatable() ? $default : false;
193
+	}
194
+
195
+	/**
196
+	 * Returns the default value.
197
+	 *
198
+	 * @return string|bool|int|float|array|null
199
+	 */
200
+	public function getDefault()
201
+	{
202
+		return $this->default;
203
+	}
204
+
205
+	/**
206
+	 * Returns the description text.
207
+	 *
208
+	 * @return string
209
+	 */
210
+	public function getDescription()
211
+	{
212
+		return $this->description;
213
+	}
214
+
215
+	/**
216
+	 * Checks whether the given option equals this one.
217
+	 *
218
+	 * @return bool
219
+	 */
220
+	public function equals(self $option)
221
+	{
222
+		return $option->getName() === $this->getName()
223
+			&& $option->getShortcut() === $this->getShortcut()
224
+			&& $option->getDefault() === $this->getDefault()
225
+			&& $option->isNegatable() === $this->isNegatable()
226
+			&& $option->isArray() === $this->isArray()
227
+			&& $option->isValueRequired() === $this->isValueRequired()
228
+			&& $option->isValueOptional() === $this->isValueOptional()
229
+		;
230
+	}
231 231
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@  discard block
 block discarded – undo
19 19
  *
20 20
  * @author Fabien Potencier <[email protected]>
21 21
  */
22
-class InputOption
23
-{
22
+class InputOption {
24 23
     /**
25 24
      * Do not accept input for the option (e.g. --yell). This is the default behavior of options.
26 25
      */
@@ -59,8 +58,7 @@  discard block
 block discarded – undo
59 58
      *
60 59
      * @throws InvalidArgumentException If option mode is invalid or incompatible
61 60
      */
62
-    public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
63
-    {
61
+    public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null) {
64 62
         if (str_starts_with($name, '--')) {
65 63
             $name = substr($name, 2);
66 64
         }
@@ -112,8 +110,7 @@  discard block
 block discarded – undo
112 110
      *
113 111
      * @return string|null
114 112
      */
115
-    public function getShortcut()
116
-    {
113
+    public function getShortcut() {
117 114
         return $this->shortcut;
118 115
     }
119 116
 
@@ -122,8 +119,7 @@  discard block
 block discarded – undo
122 119
      *
123 120
      * @return string
124 121
      */
125
-    public function getName()
126
-    {
122
+    public function getName() {
127 123
         return $this->name;
128 124
     }
129 125
 
@@ -132,8 +128,7 @@  discard block
 block discarded – undo
132 128
      *
133 129
      * @return bool true if value mode is not self::VALUE_NONE, false otherwise
134 130
      */
135
-    public function acceptValue()
136
-    {
131
+    public function acceptValue() {
137 132
         return $this->isValueRequired() || $this->isValueOptional();
138 133
     }
139 134
 
@@ -142,8 +137,7 @@  discard block
 block discarded – undo
142 137
      *
143 138
      * @return bool true if value mode is self::VALUE_REQUIRED, false otherwise
144 139
      */
145
-    public function isValueRequired()
146
-    {
140
+    public function isValueRequired() {
147 141
         return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
148 142
     }
149 143
 
@@ -152,8 +146,7 @@  discard block
 block discarded – undo
152 146
      *
153 147
      * @return bool true if value mode is self::VALUE_OPTIONAL, false otherwise
154 148
      */
155
-    public function isValueOptional()
156
-    {
149
+    public function isValueOptional() {
157 150
         return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
158 151
     }
159 152
 
@@ -162,8 +155,7 @@  discard block
 block discarded – undo
162 155
      *
163 156
      * @return bool true if mode is self::VALUE_IS_ARRAY, false otherwise
164 157
      */
165
-    public function isArray()
166
-    {
158
+    public function isArray() {
167 159
         return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
168 160
     }
169 161
 
@@ -175,8 +167,7 @@  discard block
 block discarded – undo
175 167
     /**
176 168
      * @param string|bool|int|float|array|null $default
177 169
      */
178
-    public function setDefault($default = null)
179
-    {
170
+    public function setDefault($default = null) {
180 171
         if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
181 172
             throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
182 173
         }
@@ -197,8 +188,7 @@  discard block
 block discarded – undo
197 188
      *
198 189
      * @return string|bool|int|float|array|null
199 190
      */
200
-    public function getDefault()
201
-    {
191
+    public function getDefault() {
202 192
         return $this->default;
203 193
     }
204 194
 
@@ -207,8 +197,7 @@  discard block
 block discarded – undo
207 197
      *
208 198
      * @return string
209 199
      */
210
-    public function getDescription()
211
-    {
200
+    public function getDescription() {
212 201
         return $this->description;
213 202
     }
214 203
 
@@ -217,8 +206,7 @@  discard block
 block discarded – undo
217 206
      *
218 207
      * @return bool
219 208
      */
220
-    public function equals(self $option)
221
-    {
209
+    public function equals(self $option) {
222 210
         return $option->getName() === $this->getName()
223 211
             && $option->getShortcut() === $this->getShortcut()
224 212
             && $option->getDefault() === $this->getDefault()
Please login to merge, or discard this patch.
vendor/symfony/console/Input/StringInput.php 3 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -24,45 +24,45 @@
 block discarded – undo
24 24
  */
25 25
 class StringInput extends ArgvInput
26 26
 {
27
-    public const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
28
-    public const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
27
+	public const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
28
+	public const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
29 29
 
30
-    /**
31
-     * @param string $input A string representing the parameters from the CLI
32
-     */
33
-    public function __construct(string $input)
34
-    {
35
-        parent::__construct([]);
30
+	/**
31
+	 * @param string $input A string representing the parameters from the CLI
32
+	 */
33
+	public function __construct(string $input)
34
+	{
35
+		parent::__construct([]);
36 36
 
37
-        $this->setTokens($this->tokenize($input));
38
-    }
37
+		$this->setTokens($this->tokenize($input));
38
+	}
39 39
 
40
-    /**
41
-     * Tokenizes a string.
42
-     *
43
-     * @throws InvalidArgumentException When unable to parse input (should never happen)
44
-     */
45
-    private function tokenize(string $input): array
46
-    {
47
-        $tokens = [];
48
-        $length = \strlen($input);
49
-        $cursor = 0;
50
-        while ($cursor < $length) {
51
-            if (preg_match('/\s+/A', $input, $match, 0, $cursor)) {
52
-            } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, 0, $cursor)) {
53
-                $tokens[] = $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, -1)));
54
-            } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
55
-                $tokens[] = stripcslashes(substr($match[0], 1, -1));
56
-            } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, 0, $cursor)) {
57
-                $tokens[] = stripcslashes($match[1]);
58
-            } else {
59
-                // should never happen
60
-                throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ...".', substr($input, $cursor, 10)));
61
-            }
40
+	/**
41
+	 * Tokenizes a string.
42
+	 *
43
+	 * @throws InvalidArgumentException When unable to parse input (should never happen)
44
+	 */
45
+	private function tokenize(string $input): array
46
+	{
47
+		$tokens = [];
48
+		$length = \strlen($input);
49
+		$cursor = 0;
50
+		while ($cursor < $length) {
51
+			if (preg_match('/\s+/A', $input, $match, 0, $cursor)) {
52
+			} elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, 0, $cursor)) {
53
+				$tokens[] = $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, -1)));
54
+			} elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
55
+				$tokens[] = stripcslashes(substr($match[0], 1, -1));
56
+			} elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, 0, $cursor)) {
57
+				$tokens[] = stripcslashes($match[1]);
58
+			} else {
59
+				// should never happen
60
+				throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ...".', substr($input, $cursor, 10)));
61
+			}
62 62
 
63
-            $cursor += \strlen($match[0]);
64
-        }
63
+			$cursor += \strlen($match[0]);
64
+		}
65 65
 
66
-        return $tokens;
67
-    }
66
+		return $tokens;
67
+	}
68 68
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
     /**
31 31
      * @param string $input A string representing the parameters from the CLI
32 32
      */
33
-    public function __construct(string $input)
33
+    public function __construct( string $input )
34 34
     {
35
-        parent::__construct([]);
35
+        parent::__construct( [ ] );
36 36
 
37
-        $this->setTokens($this->tokenize($input));
37
+        $this->setTokens( $this->tokenize( $input ) );
38 38
     }
39 39
 
40 40
     /**
@@ -42,25 +42,25 @@  discard block
 block discarded – undo
42 42
      *
43 43
      * @throws InvalidArgumentException When unable to parse input (should never happen)
44 44
      */
45
-    private function tokenize(string $input): array
45
+    private function tokenize( string $input ): array
46 46
     {
47
-        $tokens = [];
48
-        $length = \strlen($input);
47
+        $tokens = [ ];
48
+        $length = \strlen( $input );
49 49
         $cursor = 0;
50
-        while ($cursor < $length) {
51
-            if (preg_match('/\s+/A', $input, $match, 0, $cursor)) {
52
-            } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, 0, $cursor)) {
53
-                $tokens[] = $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, -1)));
54
-            } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
55
-                $tokens[] = stripcslashes(substr($match[0], 1, -1));
56
-            } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, 0, $cursor)) {
57
-                $tokens[] = stripcslashes($match[1]);
50
+        while ( $cursor < $length ) {
51
+            if ( preg_match( '/\s+/A', $input, $match, 0, $cursor ) ) {
52
+            } elseif ( preg_match( '/([^="\'\s]+?)(=?)(' . self::REGEX_QUOTED_STRING . '+)/A', $input, $match, 0, $cursor ) ) {
53
+                $tokens[ ] = $match[ 1 ] . $match[ 2 ] . stripcslashes( str_replace( [ '"\'', '\'"', '\'\'', '""' ], '', substr( $match[ 3 ], 1, -1 ) ) );
54
+            } elseif ( preg_match( '/' . self::REGEX_QUOTED_STRING . '/A', $input, $match, 0, $cursor ) ) {
55
+                $tokens[ ] = stripcslashes( substr( $match[ 0 ], 1, -1 ) );
56
+            } elseif ( preg_match( '/' . self::REGEX_STRING . '/A', $input, $match, 0, $cursor ) ) {
57
+                $tokens[ ] = stripcslashes( $match[ 1 ] );
58 58
             } else {
59 59
                 // should never happen
60
-                throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ...".', substr($input, $cursor, 10)));
60
+                throw new InvalidArgumentException( sprintf( 'Unable to parse input near "... %s ...".', substr( $input, $cursor, 10 ) ) );
61 61
             }
62 62
 
63
-            $cursor += \strlen($match[0]);
63
+            $cursor += \strlen( $match[ 0 ] );
64 64
         }
65 65
 
66 66
         return $tokens;
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,16 +22,14 @@
 block discarded – undo
22 22
  *
23 23
  * @author Fabien Potencier <[email protected]>
24 24
  */
25
-class StringInput extends ArgvInput
26
-{
25
+class StringInput extends ArgvInput {
27 26
     public const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
28 27
     public const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
29 28
 
30 29
     /**
31 30
      * @param string $input A string representing the parameters from the CLI
32 31
      */
33
-    public function __construct(string $input)
34
-    {
32
+    public function __construct(string $input) {
35 33
         parent::__construct([]);
36 34
 
37 35
         $this->setTokens($this->tokenize($input));
Please login to merge, or discard this patch.
vendor/symfony/console/Input/InputArgument.php 3 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
      *
39 39
      * @throws InvalidArgumentException When argument mode is not valid
40 40
      */
41
-    public function __construct(string $name, int $mode = null, string $description = '', $default = null)
41
+    public function __construct( string $name, int $mode = null, string $description = '', $default = null )
42 42
     {
43
-        if (null === $mode) {
43
+        if ( null === $mode ) {
44 44
             $mode = self::OPTIONAL;
45
-        } elseif ($mode > 7 || $mode < 1) {
46
-            throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
45
+        } elseif ( $mode > 7 || $mode < 1 ) {
46
+            throw new InvalidArgumentException( sprintf( 'Argument mode "%s" is not valid.', $mode ) );
47 47
         }
48 48
 
49 49
         $this->name = $name;
50 50
         $this->mode = $mode;
51 51
         $this->description = $description;
52 52
 
53
-        $this->setDefault($default);
53
+        $this->setDefault( $default );
54 54
     }
55 55
 
56 56
     /**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function isRequired()
72 72
     {
73
-        return self::REQUIRED === (self::REQUIRED & $this->mode);
73
+        return self::REQUIRED === ( self::REQUIRED & $this->mode );
74 74
     }
75 75
 
76 76
     /**
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function isArray()
82 82
     {
83
-        return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
83
+        return self::IS_ARRAY === ( self::IS_ARRAY & $this->mode );
84 84
     }
85 85
 
86 86
     /**
@@ -90,17 +90,17 @@  discard block
 block discarded – undo
90 90
      *
91 91
      * @throws LogicException When incorrect default value is given
92 92
      */
93
-    public function setDefault($default = null)
93
+    public function setDefault( $default = null )
94 94
     {
95
-        if (self::REQUIRED === $this->mode && null !== $default) {
96
-            throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
95
+        if ( self::REQUIRED === $this->mode && null !== $default ) {
96
+            throw new LogicException( 'Cannot set a default value except for InputArgument::OPTIONAL mode.' );
97 97
         }
98 98
 
99
-        if ($this->isArray()) {
100
-            if (null === $default) {
101
-                $default = [];
102
-            } elseif (!\is_array($default)) {
103
-                throw new LogicException('A default value for an array argument must be an array.');
99
+        if ( $this->isArray() ) {
100
+            if ( null === $default ) {
101
+                $default = [ ];
102
+            } elseif ( ! \is_array( $default ) ) {
103
+                throw new LogicException( 'A default value for an array argument must be an array.' );
104 104
             }
105 105
         }
106 106
 
Please login to merge, or discard this patch.
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -21,109 +21,109 @@
 block discarded – undo
21 21
  */
22 22
 class InputArgument
23 23
 {
24
-    public const REQUIRED = 1;
25
-    public const OPTIONAL = 2;
26
-    public const IS_ARRAY = 4;
27
-
28
-    private $name;
29
-    private $mode;
30
-    private $default;
31
-    private $description;
32
-
33
-    /**
34
-     * @param string                           $name        The argument name
35
-     * @param int|null                         $mode        The argument mode: self::REQUIRED or self::OPTIONAL
36
-     * @param string                           $description A description text
37
-     * @param string|bool|int|float|array|null $default     The default value (for self::OPTIONAL mode only)
38
-     *
39
-     * @throws InvalidArgumentException When argument mode is not valid
40
-     */
41
-    public function __construct(string $name, int $mode = null, string $description = '', $default = null)
42
-    {
43
-        if (null === $mode) {
44
-            $mode = self::OPTIONAL;
45
-        } elseif ($mode > 7 || $mode < 1) {
46
-            throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
47
-        }
48
-
49
-        $this->name = $name;
50
-        $this->mode = $mode;
51
-        $this->description = $description;
52
-
53
-        $this->setDefault($default);
54
-    }
55
-
56
-    /**
57
-     * Returns the argument name.
58
-     *
59
-     * @return string
60
-     */
61
-    public function getName()
62
-    {
63
-        return $this->name;
64
-    }
65
-
66
-    /**
67
-     * Returns true if the argument is required.
68
-     *
69
-     * @return bool true if parameter mode is self::REQUIRED, false otherwise
70
-     */
71
-    public function isRequired()
72
-    {
73
-        return self::REQUIRED === (self::REQUIRED & $this->mode);
74
-    }
75
-
76
-    /**
77
-     * Returns true if the argument can take multiple values.
78
-     *
79
-     * @return bool true if mode is self::IS_ARRAY, false otherwise
80
-     */
81
-    public function isArray()
82
-    {
83
-        return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
84
-    }
85
-
86
-    /**
87
-     * Sets the default value.
88
-     *
89
-     * @param string|bool|int|float|array|null $default
90
-     *
91
-     * @throws LogicException When incorrect default value is given
92
-     */
93
-    public function setDefault($default = null)
94
-    {
95
-        if (self::REQUIRED === $this->mode && null !== $default) {
96
-            throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
97
-        }
98
-
99
-        if ($this->isArray()) {
100
-            if (null === $default) {
101
-                $default = [];
102
-            } elseif (!\is_array($default)) {
103
-                throw new LogicException('A default value for an array argument must be an array.');
104
-            }
105
-        }
106
-
107
-        $this->default = $default;
108
-    }
109
-
110
-    /**
111
-     * Returns the default value.
112
-     *
113
-     * @return string|bool|int|float|array|null
114
-     */
115
-    public function getDefault()
116
-    {
117
-        return $this->default;
118
-    }
119
-
120
-    /**
121
-     * Returns the description text.
122
-     *
123
-     * @return string
124
-     */
125
-    public function getDescription()
126
-    {
127
-        return $this->description;
128
-    }
24
+	public const REQUIRED = 1;
25
+	public const OPTIONAL = 2;
26
+	public const IS_ARRAY = 4;
27
+
28
+	private $name;
29
+	private $mode;
30
+	private $default;
31
+	private $description;
32
+
33
+	/**
34
+	 * @param string                           $name        The argument name
35
+	 * @param int|null                         $mode        The argument mode: self::REQUIRED or self::OPTIONAL
36
+	 * @param string                           $description A description text
37
+	 * @param string|bool|int|float|array|null $default     The default value (for self::OPTIONAL mode only)
38
+	 *
39
+	 * @throws InvalidArgumentException When argument mode is not valid
40
+	 */
41
+	public function __construct(string $name, int $mode = null, string $description = '', $default = null)
42
+	{
43
+		if (null === $mode) {
44
+			$mode = self::OPTIONAL;
45
+		} elseif ($mode > 7 || $mode < 1) {
46
+			throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
47
+		}
48
+
49
+		$this->name = $name;
50
+		$this->mode = $mode;
51
+		$this->description = $description;
52
+
53
+		$this->setDefault($default);
54
+	}
55
+
56
+	/**
57
+	 * Returns the argument name.
58
+	 *
59
+	 * @return string
60
+	 */
61
+	public function getName()
62
+	{
63
+		return $this->name;
64
+	}
65
+
66
+	/**
67
+	 * Returns true if the argument is required.
68
+	 *
69
+	 * @return bool true if parameter mode is self::REQUIRED, false otherwise
70
+	 */
71
+	public function isRequired()
72
+	{
73
+		return self::REQUIRED === (self::REQUIRED & $this->mode);
74
+	}
75
+
76
+	/**
77
+	 * Returns true if the argument can take multiple values.
78
+	 *
79
+	 * @return bool true if mode is self::IS_ARRAY, false otherwise
80
+	 */
81
+	public function isArray()
82
+	{
83
+		return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
84
+	}
85
+
86
+	/**
87
+	 * Sets the default value.
88
+	 *
89
+	 * @param string|bool|int|float|array|null $default
90
+	 *
91
+	 * @throws LogicException When incorrect default value is given
92
+	 */
93
+	public function setDefault($default = null)
94
+	{
95
+		if (self::REQUIRED === $this->mode && null !== $default) {
96
+			throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
97
+		}
98
+
99
+		if ($this->isArray()) {
100
+			if (null === $default) {
101
+				$default = [];
102
+			} elseif (!\is_array($default)) {
103
+				throw new LogicException('A default value for an array argument must be an array.');
104
+			}
105
+		}
106
+
107
+		$this->default = $default;
108
+	}
109
+
110
+	/**
111
+	 * Returns the default value.
112
+	 *
113
+	 * @return string|bool|int|float|array|null
114
+	 */
115
+	public function getDefault()
116
+	{
117
+		return $this->default;
118
+	}
119
+
120
+	/**
121
+	 * Returns the description text.
122
+	 *
123
+	 * @return string
124
+	 */
125
+	public function getDescription()
126
+	{
127
+		return $this->description;
128
+	}
129 129
 }
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@  discard block
 block discarded – undo
19 19
  *
20 20
  * @author Fabien Potencier <[email protected]>
21 21
  */
22
-class InputArgument
23
-{
22
+class InputArgument {
24 23
     public const REQUIRED = 1;
25 24
     public const OPTIONAL = 2;
26 25
     public const IS_ARRAY = 4;
@@ -38,8 +37,7 @@  discard block
 block discarded – undo
38 37
      *
39 38
      * @throws InvalidArgumentException When argument mode is not valid
40 39
      */
41
-    public function __construct(string $name, int $mode = null, string $description = '', $default = null)
42
-    {
40
+    public function __construct(string $name, int $mode = null, string $description = '', $default = null) {
43 41
         if (null === $mode) {
44 42
             $mode = self::OPTIONAL;
45 43
         } elseif ($mode > 7 || $mode < 1) {
@@ -58,8 +56,7 @@  discard block
 block discarded – undo
58 56
      *
59 57
      * @return string
60 58
      */
61
-    public function getName()
62
-    {
59
+    public function getName() {
63 60
         return $this->name;
64 61
     }
65 62
 
@@ -68,8 +65,7 @@  discard block
 block discarded – undo
68 65
      *
69 66
      * @return bool true if parameter mode is self::REQUIRED, false otherwise
70 67
      */
71
-    public function isRequired()
72
-    {
68
+    public function isRequired() {
73 69
         return self::REQUIRED === (self::REQUIRED & $this->mode);
74 70
     }
75 71
 
@@ -78,8 +74,7 @@  discard block
 block discarded – undo
78 74
      *
79 75
      * @return bool true if mode is self::IS_ARRAY, false otherwise
80 76
      */
81
-    public function isArray()
82
-    {
77
+    public function isArray() {
83 78
         return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
84 79
     }
85 80
 
@@ -90,8 +85,7 @@  discard block
 block discarded – undo
90 85
      *
91 86
      * @throws LogicException When incorrect default value is given
92 87
      */
93
-    public function setDefault($default = null)
94
-    {
88
+    public function setDefault($default = null) {
95 89
         if (self::REQUIRED === $this->mode && null !== $default) {
96 90
             throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
97 91
         }
@@ -112,8 +106,7 @@  discard block
 block discarded – undo
112 106
      *
113 107
      * @return string|bool|int|float|array|null
114 108
      */
115
-    public function getDefault()
116
-    {
109
+    public function getDefault() {
117 110
         return $this->default;
118 111
     }
119 112
 
@@ -122,8 +115,7 @@  discard block
 block discarded – undo
122 115
      *
123 116
      * @return string
124 117
      */
125
-    public function getDescription()
126
-    {
118
+    public function getDescription() {
127 119
         return $this->description;
128 120
     }
129 121
 }
Please login to merge, or discard this patch.
vendor/symfony/console/Input/ArgvInput.php 3 patches
Braces   +14 added lines, -28 removed lines patch added patch discarded remove patch
@@ -38,13 +38,11 @@  discard block
 block discarded – undo
38 38
  * @see http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html
39 39
  * @see http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html#tag_12_02
40 40
  */
41
-class ArgvInput extends Input
42
-{
41
+class ArgvInput extends Input {
43 42
     private $tokens;
44 43
     private $parsed;
45 44
 
46
-    public function __construct(array $argv = null, InputDefinition $definition = null)
47
-    {
45
+    public function __construct(array $argv = null, InputDefinition $definition = null) {
48 46
         $argv = $argv ?? $_SERVER['argv'] ?? [];
49 47
 
50 48
         // strip the application name
@@ -55,16 +53,14 @@  discard block
 block discarded – undo
55 53
         parent::__construct($definition);
56 54
     }
57 55
 
58
-    protected function setTokens(array $tokens)
59
-    {
56
+    protected function setTokens(array $tokens) {
60 57
         $this->tokens = $tokens;
61 58
     }
62 59
 
63 60
     /**
64 61
      * {@inheritdoc}
65 62
      */
66
-    protected function parse()
67
-    {
63
+    protected function parse() {
68 64
         $parseOptions = true;
69 65
         $this->parsed = $this->tokens;
70 66
         while (null !== $token = array_shift($this->parsed)) {
@@ -85,8 +81,7 @@  discard block
 block discarded – undo
85 81
     /**
86 82
      * Parses a short option.
87 83
      */
88
-    private function parseShortOption(string $token)
89
-    {
84
+    private function parseShortOption(string $token) {
90 85
         $name = substr($token, 1);
91 86
 
92 87
         if (\strlen($name) > 1) {
@@ -106,8 +101,7 @@  discard block
 block discarded – undo
106 101
      *
107 102
      * @throws RuntimeException When option given doesn't exist
108 103
      */
109
-    private function parseShortOptionSet(string $name)
110
-    {
104
+    private function parseShortOptionSet(string $name) {
111 105
         $len = \strlen($name);
112 106
         for ($i = 0; $i < $len; ++$i) {
113 107
             if (!$this->definition->hasShortcut($name[$i])) {
@@ -129,8 +123,7 @@  discard block
 block discarded – undo
129 123
     /**
130 124
      * Parses a long option.
131 125
      */
132
-    private function parseLongOption(string $token)
133
-    {
126
+    private function parseLongOption(string $token) {
134 127
         $name = substr($token, 2);
135 128
 
136 129
         if (false !== $pos = strpos($name, '=')) {
@@ -148,8 +141,7 @@  discard block
 block discarded – undo
148 141
      *
149 142
      * @throws RuntimeException When too many arguments are given
150 143
      */
151
-    private function parseArgument(string $token)
152
-    {
144
+    private function parseArgument(string $token) {
153 145
         $c = \count($this->arguments);
154 146
 
155 147
         // if input is expecting another argument, add it
@@ -192,8 +184,7 @@  discard block
 block discarded – undo
192 184
      *
193 185
      * @throws RuntimeException When option given doesn't exist
194 186
      */
195
-    private function addShortOption(string $shortcut, $value)
196
-    {
187
+    private function addShortOption(string $shortcut, $value) {
197 188
         if (!$this->definition->hasShortcut($shortcut)) {
198 189
             throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
199 190
         }
@@ -206,8 +197,7 @@  discard block
 block discarded – undo
206 197
      *
207 198
      * @throws RuntimeException When option given doesn't exist
208 199
      */
209
-    private function addLongOption(string $name, $value)
210
-    {
200
+    private function addLongOption(string $name, $value) {
211 201
         if (!$this->definition->hasOption($name)) {
212 202
             if (!$this->definition->hasNegation($name)) {
213 203
                 throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
@@ -259,8 +249,7 @@  discard block
 block discarded – undo
259 249
     /**
260 250
      * {@inheritdoc}
261 251
      */
262
-    public function getFirstArgument()
263
-    {
252
+    public function getFirstArgument() {
264 253
         $isOption = false;
265 254
         foreach ($this->tokens as $i => $token) {
266 255
             if ($token && '-' === $token[0]) {
@@ -294,8 +283,7 @@  discard block
 block discarded – undo
294 283
     /**
295 284
      * {@inheritdoc}
296 285
      */
297
-    public function hasParameterOption($values, bool $onlyParams = false)
298
-    {
286
+    public function hasParameterOption($values, bool $onlyParams = false) {
299 287
         $values = (array) $values;
300 288
 
301 289
         foreach ($this->tokens as $token) {
@@ -319,8 +307,7 @@  discard block
 block discarded – undo
319 307
     /**
320 308
      * {@inheritdoc}
321 309
      */
322
-    public function getParameterOption($values, $default = false, bool $onlyParams = false)
323
-    {
310
+    public function getParameterOption($values, $default = false, bool $onlyParams = false) {
324 311
         $values = (array) $values;
325 312
         $tokens = $this->tokens;
326 313
 
@@ -352,8 +339,7 @@  discard block
 block discarded – undo
352 339
      *
353 340
      * @return string
354 341
      */
355
-    public function __toString()
356
-    {
342
+    public function __toString() {
357 343
         $tokens = array_map(function ($token) {
358 344
             if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
359 345
                 return $match[1].$this->escapeToken($match[2]);
Please login to merge, or discard this patch.
Indentation   +335 added lines, -335 removed lines patch added patch discarded remove patch
@@ -40,339 +40,339 @@
 block discarded – undo
40 40
  */
41 41
 class ArgvInput extends Input
42 42
 {
43
-    private $tokens;
44
-    private $parsed;
45
-
46
-    public function __construct(array $argv = null, InputDefinition $definition = null)
47
-    {
48
-        $argv = $argv ?? $_SERVER['argv'] ?? [];
49
-
50
-        // strip the application name
51
-        array_shift($argv);
52
-
53
-        $this->tokens = $argv;
54
-
55
-        parent::__construct($definition);
56
-    }
57
-
58
-    protected function setTokens(array $tokens)
59
-    {
60
-        $this->tokens = $tokens;
61
-    }
62
-
63
-    /**
64
-     * {@inheritdoc}
65
-     */
66
-    protected function parse()
67
-    {
68
-        $parseOptions = true;
69
-        $this->parsed = $this->tokens;
70
-        while (null !== $token = array_shift($this->parsed)) {
71
-            $parseOptions = $this->parseToken($token, $parseOptions);
72
-        }
73
-    }
74
-
75
-    protected function parseToken(string $token, bool $parseOptions): bool
76
-    {
77
-        if ($parseOptions && '' == $token) {
78
-            $this->parseArgument($token);
79
-        } elseif ($parseOptions && '--' == $token) {
80
-            return false;
81
-        } elseif ($parseOptions && str_starts_with($token, '--')) {
82
-            $this->parseLongOption($token);
83
-        } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
84
-            $this->parseShortOption($token);
85
-        } else {
86
-            $this->parseArgument($token);
87
-        }
88
-
89
-        return $parseOptions;
90
-    }
91
-
92
-    /**
93
-     * Parses a short option.
94
-     */
95
-    private function parseShortOption(string $token)
96
-    {
97
-        $name = substr($token, 1);
98
-
99
-        if (\strlen($name) > 1) {
100
-            if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
101
-                // an option with a value (with no space)
102
-                $this->addShortOption($name[0], substr($name, 1));
103
-            } else {
104
-                $this->parseShortOptionSet($name);
105
-            }
106
-        } else {
107
-            $this->addShortOption($name, null);
108
-        }
109
-    }
110
-
111
-    /**
112
-     * Parses a short option set.
113
-     *
114
-     * @throws RuntimeException When option given doesn't exist
115
-     */
116
-    private function parseShortOptionSet(string $name)
117
-    {
118
-        $len = \strlen($name);
119
-        for ($i = 0; $i < $len; ++$i) {
120
-            if (!$this->definition->hasShortcut($name[$i])) {
121
-                $encoding = mb_detect_encoding($name, null, true);
122
-                throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
123
-            }
124
-
125
-            $option = $this->definition->getOptionForShortcut($name[$i]);
126
-            if ($option->acceptValue()) {
127
-                $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
128
-
129
-                break;
130
-            } else {
131
-                $this->addLongOption($option->getName(), null);
132
-            }
133
-        }
134
-    }
135
-
136
-    /**
137
-     * Parses a long option.
138
-     */
139
-    private function parseLongOption(string $token)
140
-    {
141
-        $name = substr($token, 2);
142
-
143
-        if (false !== $pos = strpos($name, '=')) {
144
-            if ('' === $value = substr($name, $pos + 1)) {
145
-                array_unshift($this->parsed, $value);
146
-            }
147
-            $this->addLongOption(substr($name, 0, $pos), $value);
148
-        } else {
149
-            $this->addLongOption($name, null);
150
-        }
151
-    }
152
-
153
-    /**
154
-     * Parses an argument.
155
-     *
156
-     * @throws RuntimeException When too many arguments are given
157
-     */
158
-    private function parseArgument(string $token)
159
-    {
160
-        $c = \count($this->arguments);
161
-
162
-        // if input is expecting another argument, add it
163
-        if ($this->definition->hasArgument($c)) {
164
-            $arg = $this->definition->getArgument($c);
165
-            $this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token;
166
-
167
-        // if last argument isArray(), append token to last argument
168
-        } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
169
-            $arg = $this->definition->getArgument($c - 1);
170
-            $this->arguments[$arg->getName()][] = $token;
171
-
172
-        // unexpected argument
173
-        } else {
174
-            $all = $this->definition->getArguments();
175
-            $symfonyCommandName = null;
176
-            if (($inputArgument = $all[$key = array_key_first($all)] ?? null) && 'command' === $inputArgument->getName()) {
177
-                $symfonyCommandName = $this->arguments['command'] ?? null;
178
-                unset($all[$key]);
179
-            }
180
-
181
-            if (\count($all)) {
182
-                if ($symfonyCommandName) {
183
-                    $message = sprintf('Too many arguments to "%s" command, expected arguments "%s".', $symfonyCommandName, implode('" "', array_keys($all)));
184
-                } else {
185
-                    $message = sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all)));
186
-                }
187
-            } elseif ($symfonyCommandName) {
188
-                $message = sprintf('No arguments expected for "%s" command, got "%s".', $symfonyCommandName, $token);
189
-            } else {
190
-                $message = sprintf('No arguments expected, got "%s".', $token);
191
-            }
192
-
193
-            throw new RuntimeException($message);
194
-        }
195
-    }
196
-
197
-    /**
198
-     * Adds a short option value.
199
-     *
200
-     * @throws RuntimeException When option given doesn't exist
201
-     */
202
-    private function addShortOption(string $shortcut, $value)
203
-    {
204
-        if (!$this->definition->hasShortcut($shortcut)) {
205
-            throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
206
-        }
207
-
208
-        $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
209
-    }
210
-
211
-    /**
212
-     * Adds a long option value.
213
-     *
214
-     * @throws RuntimeException When option given doesn't exist
215
-     */
216
-    private function addLongOption(string $name, $value)
217
-    {
218
-        if (!$this->definition->hasOption($name)) {
219
-            if (!$this->definition->hasNegation($name)) {
220
-                throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
221
-            }
222
-
223
-            $optionName = $this->definition->negationToName($name);
224
-            if (null !== $value) {
225
-                throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
226
-            }
227
-            $this->options[$optionName] = false;
228
-
229
-            return;
230
-        }
231
-
232
-        $option = $this->definition->getOption($name);
233
-
234
-        if (null !== $value && !$option->acceptValue()) {
235
-            throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
236
-        }
237
-
238
-        if (\in_array($value, ['', null], true) && $option->acceptValue() && \count($this->parsed)) {
239
-            // if option accepts an optional or mandatory argument
240
-            // let's see if there is one provided
241
-            $next = array_shift($this->parsed);
242
-            if ((isset($next[0]) && '-' !== $next[0]) || \in_array($next, ['', null], true)) {
243
-                $value = $next;
244
-            } else {
245
-                array_unshift($this->parsed, $next);
246
-            }
247
-        }
248
-
249
-        if (null === $value) {
250
-            if ($option->isValueRequired()) {
251
-                throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
252
-            }
253
-
254
-            if (!$option->isArray() && !$option->isValueOptional()) {
255
-                $value = true;
256
-            }
257
-        }
258
-
259
-        if ($option->isArray()) {
260
-            $this->options[$name][] = $value;
261
-        } else {
262
-            $this->options[$name] = $value;
263
-        }
264
-    }
265
-
266
-    /**
267
-     * {@inheritdoc}
268
-     */
269
-    public function getFirstArgument()
270
-    {
271
-        $isOption = false;
272
-        foreach ($this->tokens as $i => $token) {
273
-            if ($token && '-' === $token[0]) {
274
-                if (str_contains($token, '=') || !isset($this->tokens[$i + 1])) {
275
-                    continue;
276
-                }
277
-
278
-                // If it's a long option, consider that everything after "--" is the option name.
279
-                // Otherwise, use the last char (if it's a short option set, only the last one can take a value with space separator)
280
-                $name = '-' === $token[1] ? substr($token, 2) : substr($token, -1);
281
-                if (!isset($this->options[$name]) && !$this->definition->hasShortcut($name)) {
282
-                    // noop
283
-                } elseif ((isset($this->options[$name]) || isset($this->options[$name = $this->definition->shortcutToName($name)])) && $this->tokens[$i + 1] === $this->options[$name]) {
284
-                    $isOption = true;
285
-                }
286
-
287
-                continue;
288
-            }
289
-
290
-            if ($isOption) {
291
-                $isOption = false;
292
-                continue;
293
-            }
294
-
295
-            return $token;
296
-        }
297
-
298
-        return null;
299
-    }
300
-
301
-    /**
302
-     * {@inheritdoc}
303
-     */
304
-    public function hasParameterOption($values, bool $onlyParams = false)
305
-    {
306
-        $values = (array) $values;
307
-
308
-        foreach ($this->tokens as $token) {
309
-            if ($onlyParams && '--' === $token) {
310
-                return false;
311
-            }
312
-            foreach ($values as $value) {
313
-                // Options with values:
314
-                //   For long options, test for '--option=' at beginning
315
-                //   For short options, test for '-o' at beginning
316
-                $leading = str_starts_with($value, '--') ? $value.'=' : $value;
317
-                if ($token === $value || '' !== $leading && str_starts_with($token, $leading)) {
318
-                    return true;
319
-                }
320
-            }
321
-        }
322
-
323
-        return false;
324
-    }
325
-
326
-    /**
327
-     * {@inheritdoc}
328
-     */
329
-    public function getParameterOption($values, $default = false, bool $onlyParams = false)
330
-    {
331
-        $values = (array) $values;
332
-        $tokens = $this->tokens;
333
-
334
-        while (0 < \count($tokens)) {
335
-            $token = array_shift($tokens);
336
-            if ($onlyParams && '--' === $token) {
337
-                return $default;
338
-            }
339
-
340
-            foreach ($values as $value) {
341
-                if ($token === $value) {
342
-                    return array_shift($tokens);
343
-                }
344
-                // Options with values:
345
-                //   For long options, test for '--option=' at beginning
346
-                //   For short options, test for '-o' at beginning
347
-                $leading = str_starts_with($value, '--') ? $value.'=' : $value;
348
-                if ('' !== $leading && str_starts_with($token, $leading)) {
349
-                    return substr($token, \strlen($leading));
350
-                }
351
-            }
352
-        }
353
-
354
-        return $default;
355
-    }
356
-
357
-    /**
358
-     * Returns a stringified representation of the args passed to the command.
359
-     *
360
-     * @return string
361
-     */
362
-    public function __toString()
363
-    {
364
-        $tokens = array_map(function ($token) {
365
-            if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
366
-                return $match[1].$this->escapeToken($match[2]);
367
-            }
368
-
369
-            if ($token && '-' !== $token[0]) {
370
-                return $this->escapeToken($token);
371
-            }
372
-
373
-            return $token;
374
-        }, $this->tokens);
375
-
376
-        return implode(' ', $tokens);
377
-    }
43
+	private $tokens;
44
+	private $parsed;
45
+
46
+	public function __construct(array $argv = null, InputDefinition $definition = null)
47
+	{
48
+		$argv = $argv ?? $_SERVER['argv'] ?? [];
49
+
50
+		// strip the application name
51
+		array_shift($argv);
52
+
53
+		$this->tokens = $argv;
54
+
55
+		parent::__construct($definition);
56
+	}
57
+
58
+	protected function setTokens(array $tokens)
59
+	{
60
+		$this->tokens = $tokens;
61
+	}
62
+
63
+	/**
64
+	 * {@inheritdoc}
65
+	 */
66
+	protected function parse()
67
+	{
68
+		$parseOptions = true;
69
+		$this->parsed = $this->tokens;
70
+		while (null !== $token = array_shift($this->parsed)) {
71
+			$parseOptions = $this->parseToken($token, $parseOptions);
72
+		}
73
+	}
74
+
75
+	protected function parseToken(string $token, bool $parseOptions): bool
76
+	{
77
+		if ($parseOptions && '' == $token) {
78
+			$this->parseArgument($token);
79
+		} elseif ($parseOptions && '--' == $token) {
80
+			return false;
81
+		} elseif ($parseOptions && str_starts_with($token, '--')) {
82
+			$this->parseLongOption($token);
83
+		} elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
84
+			$this->parseShortOption($token);
85
+		} else {
86
+			$this->parseArgument($token);
87
+		}
88
+
89
+		return $parseOptions;
90
+	}
91
+
92
+	/**
93
+	 * Parses a short option.
94
+	 */
95
+	private function parseShortOption(string $token)
96
+	{
97
+		$name = substr($token, 1);
98
+
99
+		if (\strlen($name) > 1) {
100
+			if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
101
+				// an option with a value (with no space)
102
+				$this->addShortOption($name[0], substr($name, 1));
103
+			} else {
104
+				$this->parseShortOptionSet($name);
105
+			}
106
+		} else {
107
+			$this->addShortOption($name, null);
108
+		}
109
+	}
110
+
111
+	/**
112
+	 * Parses a short option set.
113
+	 *
114
+	 * @throws RuntimeException When option given doesn't exist
115
+	 */
116
+	private function parseShortOptionSet(string $name)
117
+	{
118
+		$len = \strlen($name);
119
+		for ($i = 0; $i < $len; ++$i) {
120
+			if (!$this->definition->hasShortcut($name[$i])) {
121
+				$encoding = mb_detect_encoding($name, null, true);
122
+				throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
123
+			}
124
+
125
+			$option = $this->definition->getOptionForShortcut($name[$i]);
126
+			if ($option->acceptValue()) {
127
+				$this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
128
+
129
+				break;
130
+			} else {
131
+				$this->addLongOption($option->getName(), null);
132
+			}
133
+		}
134
+	}
135
+
136
+	/**
137
+	 * Parses a long option.
138
+	 */
139
+	private function parseLongOption(string $token)
140
+	{
141
+		$name = substr($token, 2);
142
+
143
+		if (false !== $pos = strpos($name, '=')) {
144
+			if ('' === $value = substr($name, $pos + 1)) {
145
+				array_unshift($this->parsed, $value);
146
+			}
147
+			$this->addLongOption(substr($name, 0, $pos), $value);
148
+		} else {
149
+			$this->addLongOption($name, null);
150
+		}
151
+	}
152
+
153
+	/**
154
+	 * Parses an argument.
155
+	 *
156
+	 * @throws RuntimeException When too many arguments are given
157
+	 */
158
+	private function parseArgument(string $token)
159
+	{
160
+		$c = \count($this->arguments);
161
+
162
+		// if input is expecting another argument, add it
163
+		if ($this->definition->hasArgument($c)) {
164
+			$arg = $this->definition->getArgument($c);
165
+			$this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token;
166
+
167
+		// if last argument isArray(), append token to last argument
168
+		} elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
169
+			$arg = $this->definition->getArgument($c - 1);
170
+			$this->arguments[$arg->getName()][] = $token;
171
+
172
+		// unexpected argument
173
+		} else {
174
+			$all = $this->definition->getArguments();
175
+			$symfonyCommandName = null;
176
+			if (($inputArgument = $all[$key = array_key_first($all)] ?? null) && 'command' === $inputArgument->getName()) {
177
+				$symfonyCommandName = $this->arguments['command'] ?? null;
178
+				unset($all[$key]);
179
+			}
180
+
181
+			if (\count($all)) {
182
+				if ($symfonyCommandName) {
183
+					$message = sprintf('Too many arguments to "%s" command, expected arguments "%s".', $symfonyCommandName, implode('" "', array_keys($all)));
184
+				} else {
185
+					$message = sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all)));
186
+				}
187
+			} elseif ($symfonyCommandName) {
188
+				$message = sprintf('No arguments expected for "%s" command, got "%s".', $symfonyCommandName, $token);
189
+			} else {
190
+				$message = sprintf('No arguments expected, got "%s".', $token);
191
+			}
192
+
193
+			throw new RuntimeException($message);
194
+		}
195
+	}
196
+
197
+	/**
198
+	 * Adds a short option value.
199
+	 *
200
+	 * @throws RuntimeException When option given doesn't exist
201
+	 */
202
+	private function addShortOption(string $shortcut, $value)
203
+	{
204
+		if (!$this->definition->hasShortcut($shortcut)) {
205
+			throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
206
+		}
207
+
208
+		$this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
209
+	}
210
+
211
+	/**
212
+	 * Adds a long option value.
213
+	 *
214
+	 * @throws RuntimeException When option given doesn't exist
215
+	 */
216
+	private function addLongOption(string $name, $value)
217
+	{
218
+		if (!$this->definition->hasOption($name)) {
219
+			if (!$this->definition->hasNegation($name)) {
220
+				throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
221
+			}
222
+
223
+			$optionName = $this->definition->negationToName($name);
224
+			if (null !== $value) {
225
+				throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
226
+			}
227
+			$this->options[$optionName] = false;
228
+
229
+			return;
230
+		}
231
+
232
+		$option = $this->definition->getOption($name);
233
+
234
+		if (null !== $value && !$option->acceptValue()) {
235
+			throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
236
+		}
237
+
238
+		if (\in_array($value, ['', null], true) && $option->acceptValue() && \count($this->parsed)) {
239
+			// if option accepts an optional or mandatory argument
240
+			// let's see if there is one provided
241
+			$next = array_shift($this->parsed);
242
+			if ((isset($next[0]) && '-' !== $next[0]) || \in_array($next, ['', null], true)) {
243
+				$value = $next;
244
+			} else {
245
+				array_unshift($this->parsed, $next);
246
+			}
247
+		}
248
+
249
+		if (null === $value) {
250
+			if ($option->isValueRequired()) {
251
+				throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
252
+			}
253
+
254
+			if (!$option->isArray() && !$option->isValueOptional()) {
255
+				$value = true;
256
+			}
257
+		}
258
+
259
+		if ($option->isArray()) {
260
+			$this->options[$name][] = $value;
261
+		} else {
262
+			$this->options[$name] = $value;
263
+		}
264
+	}
265
+
266
+	/**
267
+	 * {@inheritdoc}
268
+	 */
269
+	public function getFirstArgument()
270
+	{
271
+		$isOption = false;
272
+		foreach ($this->tokens as $i => $token) {
273
+			if ($token && '-' === $token[0]) {
274
+				if (str_contains($token, '=') || !isset($this->tokens[$i + 1])) {
275
+					continue;
276
+				}
277
+
278
+				// If it's a long option, consider that everything after "--" is the option name.
279
+				// Otherwise, use the last char (if it's a short option set, only the last one can take a value with space separator)
280
+				$name = '-' === $token[1] ? substr($token, 2) : substr($token, -1);
281
+				if (!isset($this->options[$name]) && !$this->definition->hasShortcut($name)) {
282
+					// noop
283
+				} elseif ((isset($this->options[$name]) || isset($this->options[$name = $this->definition->shortcutToName($name)])) && $this->tokens[$i + 1] === $this->options[$name]) {
284
+					$isOption = true;
285
+				}
286
+
287
+				continue;
288
+			}
289
+
290
+			if ($isOption) {
291
+				$isOption = false;
292
+				continue;
293
+			}
294
+
295
+			return $token;
296
+		}
297
+
298
+		return null;
299
+	}
300
+
301
+	/**
302
+	 * {@inheritdoc}
303
+	 */
304
+	public function hasParameterOption($values, bool $onlyParams = false)
305
+	{
306
+		$values = (array) $values;
307
+
308
+		foreach ($this->tokens as $token) {
309
+			if ($onlyParams && '--' === $token) {
310
+				return false;
311
+			}
312
+			foreach ($values as $value) {
313
+				// Options with values:
314
+				//   For long options, test for '--option=' at beginning
315
+				//   For short options, test for '-o' at beginning
316
+				$leading = str_starts_with($value, '--') ? $value.'=' : $value;
317
+				if ($token === $value || '' !== $leading && str_starts_with($token, $leading)) {
318
+					return true;
319
+				}
320
+			}
321
+		}
322
+
323
+		return false;
324
+	}
325
+
326
+	/**
327
+	 * {@inheritdoc}
328
+	 */
329
+	public function getParameterOption($values, $default = false, bool $onlyParams = false)
330
+	{
331
+		$values = (array) $values;
332
+		$tokens = $this->tokens;
333
+
334
+		while (0 < \count($tokens)) {
335
+			$token = array_shift($tokens);
336
+			if ($onlyParams && '--' === $token) {
337
+				return $default;
338
+			}
339
+
340
+			foreach ($values as $value) {
341
+				if ($token === $value) {
342
+					return array_shift($tokens);
343
+				}
344
+				// Options with values:
345
+				//   For long options, test for '--option=' at beginning
346
+				//   For short options, test for '-o' at beginning
347
+				$leading = str_starts_with($value, '--') ? $value.'=' : $value;
348
+				if ('' !== $leading && str_starts_with($token, $leading)) {
349
+					return substr($token, \strlen($leading));
350
+				}
351
+			}
352
+		}
353
+
354
+		return $default;
355
+	}
356
+
357
+	/**
358
+	 * Returns a stringified representation of the args passed to the command.
359
+	 *
360
+	 * @return string
361
+	 */
362
+	public function __toString()
363
+	{
364
+		$tokens = array_map(function ($token) {
365
+			if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
366
+				return $match[1].$this->escapeToken($match[2]);
367
+			}
368
+
369
+			if ($token && '-' !== $token[0]) {
370
+				return $this->escapeToken($token);
371
+			}
372
+
373
+			return $token;
374
+		}, $this->tokens);
375
+
376
+		return implode(' ', $tokens);
377
+	}
378 378
 }
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -43,19 +43,19 @@  discard block
 block discarded – undo
43 43
     private $tokens;
44 44
     private $parsed;
45 45
 
46
-    public function __construct(array $argv = null, InputDefinition $definition = null)
46
+    public function __construct( array $argv = null, InputDefinition $definition = null )
47 47
     {
48
-        $argv = $argv ?? $_SERVER['argv'] ?? [];
48
+        $argv = $argv ?? $_SERVER[ 'argv' ] ?? [ ];
49 49
 
50 50
         // strip the application name
51
-        array_shift($argv);
51
+        array_shift( $argv );
52 52
 
53 53
         $this->tokens = $argv;
54 54
 
55
-        parent::__construct($definition);
55
+        parent::__construct( $definition );
56 56
     }
57 57
 
58
-    protected function setTokens(array $tokens)
58
+    protected function setTokens( array $tokens )
59 59
     {
60 60
         $this->tokens = $tokens;
61 61
     }
@@ -67,23 +67,23 @@  discard block
 block discarded – undo
67 67
     {
68 68
         $parseOptions = true;
69 69
         $this->parsed = $this->tokens;
70
-        while (null !== $token = array_shift($this->parsed)) {
71
-            $parseOptions = $this->parseToken($token, $parseOptions);
70
+        while ( null !== $token = array_shift( $this->parsed ) ) {
71
+            $parseOptions = $this->parseToken( $token, $parseOptions );
72 72
         }
73 73
     }
74 74
 
75
-    protected function parseToken(string $token, bool $parseOptions): bool
75
+    protected function parseToken( string $token, bool $parseOptions ): bool
76 76
     {
77
-        if ($parseOptions && '' == $token) {
78
-            $this->parseArgument($token);
79
-        } elseif ($parseOptions && '--' == $token) {
77
+        if ( $parseOptions && '' == $token ) {
78
+            $this->parseArgument( $token );
79
+        } elseif ( $parseOptions && '--' == $token ) {
80 80
             return false;
81
-        } elseif ($parseOptions && str_starts_with($token, '--')) {
82
-            $this->parseLongOption($token);
83
-        } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
84
-            $this->parseShortOption($token);
81
+        } elseif ( $parseOptions && str_starts_with( $token, '--' ) ) {
82
+            $this->parseLongOption( $token );
83
+        } elseif ( $parseOptions && '-' === $token[ 0 ] && '-' !== $token ) {
84
+            $this->parseShortOption( $token );
85 85
         } else {
86
-            $this->parseArgument($token);
86
+            $this->parseArgument( $token );
87 87
         }
88 88
 
89 89
         return $parseOptions;
@@ -92,19 +92,19 @@  discard block
 block discarded – undo
92 92
     /**
93 93
      * Parses a short option.
94 94
      */
95
-    private function parseShortOption(string $token)
95
+    private function parseShortOption( string $token )
96 96
     {
97
-        $name = substr($token, 1);
97
+        $name = substr( $token, 1 );
98 98
 
99
-        if (\strlen($name) > 1) {
100
-            if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
99
+        if ( \strlen( $name ) > 1 ) {
100
+            if ( $this->definition->hasShortcut( $name[ 0 ] ) && $this->definition->getOptionForShortcut( $name[ 0 ] )->acceptValue() ) {
101 101
                 // an option with a value (with no space)
102
-                $this->addShortOption($name[0], substr($name, 1));
102
+                $this->addShortOption( $name[ 0 ], substr( $name, 1 ) );
103 103
             } else {
104
-                $this->parseShortOptionSet($name);
104
+                $this->parseShortOptionSet( $name );
105 105
             }
106 106
         } else {
107
-            $this->addShortOption($name, null);
107
+            $this->addShortOption( $name, null );
108 108
         }
109 109
     }
110 110
 
@@ -113,22 +113,22 @@  discard block
 block discarded – undo
113 113
      *
114 114
      * @throws RuntimeException When option given doesn't exist
115 115
      */
116
-    private function parseShortOptionSet(string $name)
116
+    private function parseShortOptionSet( string $name )
117 117
     {
118
-        $len = \strlen($name);
119
-        for ($i = 0; $i < $len; ++$i) {
120
-            if (!$this->definition->hasShortcut($name[$i])) {
121
-                $encoding = mb_detect_encoding($name, null, true);
122
-                throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
118
+        $len = \strlen( $name );
119
+        for ( $i = 0; $i < $len; ++$i ) {
120
+            if ( ! $this->definition->hasShortcut( $name[ $i ] ) ) {
121
+                $encoding = mb_detect_encoding( $name, null, true );
122
+                throw new RuntimeException( sprintf( 'The "-%s" option does not exist.', false === $encoding ? $name[ $i ] : mb_substr( $name, $i, 1, $encoding ) ) );
123 123
             }
124 124
 
125
-            $option = $this->definition->getOptionForShortcut($name[$i]);
126
-            if ($option->acceptValue()) {
127
-                $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
125
+            $option = $this->definition->getOptionForShortcut( $name[ $i ] );
126
+            if ( $option->acceptValue() ) {
127
+                $this->addLongOption( $option->getName(), $i === $len - 1 ? null : substr( $name, $i + 1 ) );
128 128
 
129 129
                 break;
130 130
             } else {
131
-                $this->addLongOption($option->getName(), null);
131
+                $this->addLongOption( $option->getName(), null );
132 132
             }
133 133
         }
134 134
     }
@@ -136,17 +136,17 @@  discard block
 block discarded – undo
136 136
     /**
137 137
      * Parses a long option.
138 138
      */
139
-    private function parseLongOption(string $token)
139
+    private function parseLongOption( string $token )
140 140
     {
141
-        $name = substr($token, 2);
141
+        $name = substr( $token, 2 );
142 142
 
143
-        if (false !== $pos = strpos($name, '=')) {
144
-            if ('' === $value = substr($name, $pos + 1)) {
145
-                array_unshift($this->parsed, $value);
143
+        if ( false !== $pos = strpos( $name, '=' ) ) {
144
+            if ( '' === $value = substr( $name, $pos + 1 ) ) {
145
+                array_unshift( $this->parsed, $value );
146 146
             }
147
-            $this->addLongOption(substr($name, 0, $pos), $value);
147
+            $this->addLongOption( substr( $name, 0, $pos ), $value );
148 148
         } else {
149
-            $this->addLongOption($name, null);
149
+            $this->addLongOption( $name, null );
150 150
         }
151 151
     }
152 152
 
@@ -155,42 +155,42 @@  discard block
 block discarded – undo
155 155
      *
156 156
      * @throws RuntimeException When too many arguments are given
157 157
      */
158
-    private function parseArgument(string $token)
158
+    private function parseArgument( string $token )
159 159
     {
160
-        $c = \count($this->arguments);
160
+        $c = \count( $this->arguments );
161 161
 
162 162
         // if input is expecting another argument, add it
163
-        if ($this->definition->hasArgument($c)) {
164
-            $arg = $this->definition->getArgument($c);
165
-            $this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token;
163
+        if ( $this->definition->hasArgument( $c ) ) {
164
+            $arg = $this->definition->getArgument( $c );
165
+            $this->arguments[ $arg->getName() ] = $arg->isArray() ? [ $token ] : $token;
166 166
 
167 167
         // if last argument isArray(), append token to last argument
168
-        } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
169
-            $arg = $this->definition->getArgument($c - 1);
170
-            $this->arguments[$arg->getName()][] = $token;
168
+        } elseif ( $this->definition->hasArgument( $c - 1 ) && $this->definition->getArgument( $c - 1 )->isArray() ) {
169
+            $arg = $this->definition->getArgument( $c - 1 );
170
+            $this->arguments[ $arg->getName() ][ ] = $token;
171 171
 
172 172
         // unexpected argument
173 173
         } else {
174 174
             $all = $this->definition->getArguments();
175 175
             $symfonyCommandName = null;
176
-            if (($inputArgument = $all[$key = array_key_first($all)] ?? null) && 'command' === $inputArgument->getName()) {
177
-                $symfonyCommandName = $this->arguments['command'] ?? null;
178
-                unset($all[$key]);
176
+            if ( ( $inputArgument = $all[ $key = array_key_first( $all ) ] ?? null ) && 'command' === $inputArgument->getName() ) {
177
+                $symfonyCommandName = $this->arguments[ 'command' ] ?? null;
178
+                unset( $all[ $key ] );
179 179
             }
180 180
 
181
-            if (\count($all)) {
182
-                if ($symfonyCommandName) {
183
-                    $message = sprintf('Too many arguments to "%s" command, expected arguments "%s".', $symfonyCommandName, implode('" "', array_keys($all)));
181
+            if ( \count( $all ) ) {
182
+                if ( $symfonyCommandName ) {
183
+                    $message = sprintf( 'Too many arguments to "%s" command, expected arguments "%s".', $symfonyCommandName, implode( '" "', array_keys( $all ) ) );
184 184
                 } else {
185
-                    $message = sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all)));
185
+                    $message = sprintf( 'Too many arguments, expected arguments "%s".', implode( '" "', array_keys( $all ) ) );
186 186
                 }
187
-            } elseif ($symfonyCommandName) {
188
-                $message = sprintf('No arguments expected for "%s" command, got "%s".', $symfonyCommandName, $token);
187
+            } elseif ( $symfonyCommandName ) {
188
+                $message = sprintf( 'No arguments expected for "%s" command, got "%s".', $symfonyCommandName, $token );
189 189
             } else {
190
-                $message = sprintf('No arguments expected, got "%s".', $token);
190
+                $message = sprintf( 'No arguments expected, got "%s".', $token );
191 191
             }
192 192
 
193
-            throw new RuntimeException($message);
193
+            throw new RuntimeException( $message );
194 194
         }
195 195
     }
196 196
 
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
      *
200 200
      * @throws RuntimeException When option given doesn't exist
201 201
      */
202
-    private function addShortOption(string $shortcut, $value)
202
+    private function addShortOption( string $shortcut, $value )
203 203
     {
204
-        if (!$this->definition->hasShortcut($shortcut)) {
205
-            throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
204
+        if ( ! $this->definition->hasShortcut( $shortcut ) ) {
205
+            throw new RuntimeException( sprintf( 'The "-%s" option does not exist.', $shortcut ) );
206 206
         }
207 207
 
208
-        $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
208
+        $this->addLongOption( $this->definition->getOptionForShortcut( $shortcut )->getName(), $value );
209 209
     }
210 210
 
211 211
     /**
@@ -213,53 +213,53 @@  discard block
 block discarded – undo
213 213
      *
214 214
      * @throws RuntimeException When option given doesn't exist
215 215
      */
216
-    private function addLongOption(string $name, $value)
216
+    private function addLongOption( string $name, $value )
217 217
     {
218
-        if (!$this->definition->hasOption($name)) {
219
-            if (!$this->definition->hasNegation($name)) {
220
-                throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
218
+        if ( ! $this->definition->hasOption( $name ) ) {
219
+            if ( ! $this->definition->hasNegation( $name ) ) {
220
+                throw new RuntimeException( sprintf( 'The "--%s" option does not exist.', $name ) );
221 221
             }
222 222
 
223
-            $optionName = $this->definition->negationToName($name);
224
-            if (null !== $value) {
225
-                throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
223
+            $optionName = $this->definition->negationToName( $name );
224
+            if ( null !== $value ) {
225
+                throw new RuntimeException( sprintf( 'The "--%s" option does not accept a value.', $name ) );
226 226
             }
227
-            $this->options[$optionName] = false;
227
+            $this->options[ $optionName ] = false;
228 228
 
229 229
             return;
230 230
         }
231 231
 
232
-        $option = $this->definition->getOption($name);
232
+        $option = $this->definition->getOption( $name );
233 233
 
234
-        if (null !== $value && !$option->acceptValue()) {
235
-            throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
234
+        if ( null !== $value && ! $option->acceptValue() ) {
235
+            throw new RuntimeException( sprintf( 'The "--%s" option does not accept a value.', $name ) );
236 236
         }
237 237
 
238
-        if (\in_array($value, ['', null], true) && $option->acceptValue() && \count($this->parsed)) {
238
+        if ( \in_array( $value, [ '', null ], true ) && $option->acceptValue() && \count( $this->parsed ) ) {
239 239
             // if option accepts an optional or mandatory argument
240 240
             // let's see if there is one provided
241
-            $next = array_shift($this->parsed);
242
-            if ((isset($next[0]) && '-' !== $next[0]) || \in_array($next, ['', null], true)) {
241
+            $next = array_shift( $this->parsed );
242
+            if ( ( isset( $next[ 0 ] ) && '-' !== $next[ 0 ] ) || \in_array( $next, [ '', null ], true ) ) {
243 243
                 $value = $next;
244 244
             } else {
245
-                array_unshift($this->parsed, $next);
245
+                array_unshift( $this->parsed, $next );
246 246
             }
247 247
         }
248 248
 
249
-        if (null === $value) {
250
-            if ($option->isValueRequired()) {
251
-                throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
249
+        if ( null === $value ) {
250
+            if ( $option->isValueRequired() ) {
251
+                throw new RuntimeException( sprintf( 'The "--%s" option requires a value.', $name ) );
252 252
             }
253 253
 
254
-            if (!$option->isArray() && !$option->isValueOptional()) {
254
+            if ( ! $option->isArray() && ! $option->isValueOptional() ) {
255 255
                 $value = true;
256 256
             }
257 257
         }
258 258
 
259
-        if ($option->isArray()) {
260
-            $this->options[$name][] = $value;
259
+        if ( $option->isArray() ) {
260
+            $this->options[ $name ][ ] = $value;
261 261
         } else {
262
-            $this->options[$name] = $value;
262
+            $this->options[ $name ] = $value;
263 263
         }
264 264
     }
265 265
 
@@ -269,25 +269,25 @@  discard block
 block discarded – undo
269 269
     public function getFirstArgument()
270 270
     {
271 271
         $isOption = false;
272
-        foreach ($this->tokens as $i => $token) {
273
-            if ($token && '-' === $token[0]) {
274
-                if (str_contains($token, '=') || !isset($this->tokens[$i + 1])) {
272
+        foreach ( $this->tokens as $i => $token ) {
273
+            if ( $token && '-' === $token[ 0 ] ) {
274
+                if ( str_contains( $token, '=' ) || ! isset( $this->tokens[ $i + 1 ] ) ) {
275 275
                     continue;
276 276
                 }
277 277
 
278 278
                 // If it's a long option, consider that everything after "--" is the option name.
279 279
                 // Otherwise, use the last char (if it's a short option set, only the last one can take a value with space separator)
280
-                $name = '-' === $token[1] ? substr($token, 2) : substr($token, -1);
281
-                if (!isset($this->options[$name]) && !$this->definition->hasShortcut($name)) {
280
+                $name = '-' === $token[ 1 ] ? substr( $token, 2 ) : substr( $token, -1 );
281
+                if ( ! isset( $this->options[ $name ] ) && ! $this->definition->hasShortcut( $name ) ) {
282 282
                     // noop
283
-                } elseif ((isset($this->options[$name]) || isset($this->options[$name = $this->definition->shortcutToName($name)])) && $this->tokens[$i + 1] === $this->options[$name]) {
283
+                } elseif ( ( isset( $this->options[ $name ] ) || isset( $this->options[ $name = $this->definition->shortcutToName( $name ) ] ) ) && $this->tokens[ $i + 1 ] === $this->options[ $name ] ) {
284 284
                     $isOption = true;
285 285
                 }
286 286
 
287 287
                 continue;
288 288
             }
289 289
 
290
-            if ($isOption) {
290
+            if ( $isOption ) {
291 291
                 $isOption = false;
292 292
                 continue;
293 293
             }
@@ -301,20 +301,20 @@  discard block
 block discarded – undo
301 301
     /**
302 302
      * {@inheritdoc}
303 303
      */
304
-    public function hasParameterOption($values, bool $onlyParams = false)
304
+    public function hasParameterOption( $values, bool $onlyParams = false )
305 305
     {
306
-        $values = (array) $values;
306
+        $values = (array)$values;
307 307
 
308
-        foreach ($this->tokens as $token) {
309
-            if ($onlyParams && '--' === $token) {
308
+        foreach ( $this->tokens as $token ) {
309
+            if ( $onlyParams && '--' === $token ) {
310 310
                 return false;
311 311
             }
312
-            foreach ($values as $value) {
312
+            foreach ( $values as $value ) {
313 313
                 // Options with values:
314 314
                 //   For long options, test for '--option=' at beginning
315 315
                 //   For short options, test for '-o' at beginning
316
-                $leading = str_starts_with($value, '--') ? $value.'=' : $value;
317
-                if ($token === $value || '' !== $leading && str_starts_with($token, $leading)) {
316
+                $leading = str_starts_with( $value, '--' ) ? $value . '=' : $value;
317
+                if ( $token === $value || '' !== $leading && str_starts_with( $token, $leading ) ) {
318 318
                     return true;
319 319
                 }
320 320
             }
@@ -326,27 +326,27 @@  discard block
 block discarded – undo
326 326
     /**
327 327
      * {@inheritdoc}
328 328
      */
329
-    public function getParameterOption($values, $default = false, bool $onlyParams = false)
329
+    public function getParameterOption( $values, $default = false, bool $onlyParams = false )
330 330
     {
331
-        $values = (array) $values;
331
+        $values = (array)$values;
332 332
         $tokens = $this->tokens;
333 333
 
334
-        while (0 < \count($tokens)) {
335
-            $token = array_shift($tokens);
336
-            if ($onlyParams && '--' === $token) {
334
+        while ( 0 < \count( $tokens ) ) {
335
+            $token = array_shift( $tokens );
336
+            if ( $onlyParams && '--' === $token ) {
337 337
                 return $default;
338 338
             }
339 339
 
340
-            foreach ($values as $value) {
341
-                if ($token === $value) {
342
-                    return array_shift($tokens);
340
+            foreach ( $values as $value ) {
341
+                if ( $token === $value ) {
342
+                    return array_shift( $tokens );
343 343
                 }
344 344
                 // Options with values:
345 345
                 //   For long options, test for '--option=' at beginning
346 346
                 //   For short options, test for '-o' at beginning
347
-                $leading = str_starts_with($value, '--') ? $value.'=' : $value;
348
-                if ('' !== $leading && str_starts_with($token, $leading)) {
349
-                    return substr($token, \strlen($leading));
347
+                $leading = str_starts_with( $value, '--' ) ? $value . '=' : $value;
348
+                if ( '' !== $leading && str_starts_with( $token, $leading ) ) {
349
+                    return substr( $token, \strlen( $leading ) );
350 350
                 }
351 351
             }
352 352
         }
@@ -361,18 +361,18 @@  discard block
 block discarded – undo
361 361
      */
362 362
     public function __toString()
363 363
     {
364
-        $tokens = array_map(function ($token) {
365
-            if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
366
-                return $match[1].$this->escapeToken($match[2]);
364
+        $tokens = array_map( function( $token ) {
365
+            if ( preg_match( '{^(-[^=]+=)(.+)}', $token, $match ) ) {
366
+                return $match[ 1 ] . $this->escapeToken( $match[ 2 ] );
367 367
             }
368 368
 
369
-            if ($token && '-' !== $token[0]) {
370
-                return $this->escapeToken($token);
369
+            if ( $token && '-' !== $token[ 0 ] ) {
370
+                return $this->escapeToken( $token );
371 371
             }
372 372
 
373 373
             return $token;
374
-        }, $this->tokens);
374
+        }, $this->tokens );
375 375
 
376
-        return implode(' ', $tokens);
376
+        return implode( ' ', $tokens );
377 377
     }
378 378
 }
Please login to merge, or discard this patch.
vendor/symfony/console/Input/StreamableInputInterface.php 3 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -19,19 +19,19 @@
 block discarded – undo
19 19
  */
20 20
 interface StreamableInputInterface extends InputInterface
21 21
 {
22
-    /**
23
-     * Sets the input stream to read from when interacting with the user.
24
-     *
25
-     * This is mainly useful for testing purpose.
26
-     *
27
-     * @param resource $stream The input stream
28
-     */
29
-    public function setStream($stream);
22
+	/**
23
+	 * Sets the input stream to read from when interacting with the user.
24
+	 *
25
+	 * This is mainly useful for testing purpose.
26
+	 *
27
+	 * @param resource $stream The input stream
28
+	 */
29
+	public function setStream($stream);
30 30
 
31
-    /**
32
-     * Returns the input stream.
33
-     *
34
-     * @return resource|null
35
-     */
36
-    public function getStream();
31
+	/**
32
+	 * Returns the input stream.
33
+	 *
34
+	 * @return resource|null
35
+	 */
36
+	public function getStream();
37 37
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
      *
27 27
      * @param resource $stream The input stream
28 28
      */
29
-    public function setStream($stream);
29
+    public function setStream( $stream );
30 30
 
31 31
     /**
32 32
      * Returns the input stream.
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@
 block discarded – undo
17 17
  *
18 18
  * @author Robin Chalas <[email protected]>
19 19
  */
20
-interface StreamableInputInterface extends InputInterface
21
-{
20
+interface StreamableInputInterface extends InputInterface {
22 21
     /**
23 22
      * Sets the input stream to read from when interacting with the user.
24 23
      *
Please login to merge, or discard this patch.
vendor/symfony/console/Input/InputInterface.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@
 block discarded – undo
19 19
  *
20 20
  * @author Fabien Potencier <[email protected]>
21 21
  */
22
-interface InputInterface
23
-{
22
+interface InputInterface {
24 23
     /**
25 24
      * Returns the first argument from the raw parameters (not parsed).
26 25
      *
Please login to merge, or discard this patch.
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -21,131 +21,131 @@
 block discarded – undo
21 21
  */
22 22
 interface InputInterface
23 23
 {
24
-    /**
25
-     * Returns the first argument from the raw parameters (not parsed).
26
-     *
27
-     * @return string|null
28
-     */
29
-    public function getFirstArgument();
30
-
31
-    /**
32
-     * Returns true if the raw parameters (not parsed) contain a value.
33
-     *
34
-     * This method is to be used to introspect the input parameters
35
-     * before they have been validated. It must be used carefully.
36
-     * Does not necessarily return the correct result for short options
37
-     * when multiple flags are combined in the same option.
38
-     *
39
-     * @param string|array $values     The values to look for in the raw parameters (can be an array)
40
-     * @param bool         $onlyParams Only check real parameters, skip those following an end of options (--) signal
41
-     *
42
-     * @return bool
43
-     */
44
-    public function hasParameterOption($values, bool $onlyParams = false);
45
-
46
-    /**
47
-     * Returns the value of a raw option (not parsed).
48
-     *
49
-     * This method is to be used to introspect the input parameters
50
-     * before they have been validated. It must be used carefully.
51
-     * Does not necessarily return the correct result for short options
52
-     * when multiple flags are combined in the same option.
53
-     *
54
-     * @param string|array                     $values     The value(s) to look for in the raw parameters (can be an array)
55
-     * @param string|bool|int|float|array|null $default    The default value to return if no result is found
56
-     * @param bool                             $onlyParams Only check real parameters, skip those following an end of options (--) signal
57
-     *
58
-     * @return mixed
59
-     */
60
-    public function getParameterOption($values, $default = false, bool $onlyParams = false);
61
-
62
-    /**
63
-     * Binds the current Input instance with the given arguments and options.
64
-     *
65
-     * @throws RuntimeException
66
-     */
67
-    public function bind(InputDefinition $definition);
68
-
69
-    /**
70
-     * Validates the input.
71
-     *
72
-     * @throws RuntimeException When not enough arguments are given
73
-     */
74
-    public function validate();
75
-
76
-    /**
77
-     * Returns all the given arguments merged with the default values.
78
-     *
79
-     * @return array<string|bool|int|float|array|null>
80
-     */
81
-    public function getArguments();
82
-
83
-    /**
84
-     * Returns the argument value for a given argument name.
85
-     *
86
-     * @return mixed
87
-     *
88
-     * @throws InvalidArgumentException When argument given doesn't exist
89
-     */
90
-    public function getArgument(string $name);
91
-
92
-    /**
93
-     * Sets an argument value by name.
94
-     *
95
-     * @param mixed $value The argument value
96
-     *
97
-     * @throws InvalidArgumentException When argument given doesn't exist
98
-     */
99
-    public function setArgument(string $name, $value);
100
-
101
-    /**
102
-     * Returns true if an InputArgument object exists by name or position.
103
-     *
104
-     * @return bool
105
-     */
106
-    public function hasArgument(string $name);
107
-
108
-    /**
109
-     * Returns all the given options merged with the default values.
110
-     *
111
-     * @return array<string|bool|int|float|array|null>
112
-     */
113
-    public function getOptions();
114
-
115
-    /**
116
-     * Returns the option value for a given option name.
117
-     *
118
-     * @return mixed
119
-     *
120
-     * @throws InvalidArgumentException When option given doesn't exist
121
-     */
122
-    public function getOption(string $name);
123
-
124
-    /**
125
-     * Sets an option value by name.
126
-     *
127
-     * @param mixed $value The option value
128
-     *
129
-     * @throws InvalidArgumentException When option given doesn't exist
130
-     */
131
-    public function setOption(string $name, $value);
132
-
133
-    /**
134
-     * Returns true if an InputOption object exists by name.
135
-     *
136
-     * @return bool
137
-     */
138
-    public function hasOption(string $name);
139
-
140
-    /**
141
-     * Is this input means interactive?
142
-     *
143
-     * @return bool
144
-     */
145
-    public function isInteractive();
146
-
147
-    /**
148
-     * Sets the input interactivity.
149
-     */
150
-    public function setInteractive(bool $interactive);
24
+	/**
25
+	 * Returns the first argument from the raw parameters (not parsed).
26
+	 *
27
+	 * @return string|null
28
+	 */
29
+	public function getFirstArgument();
30
+
31
+	/**
32
+	 * Returns true if the raw parameters (not parsed) contain a value.
33
+	 *
34
+	 * This method is to be used to introspect the input parameters
35
+	 * before they have been validated. It must be used carefully.
36
+	 * Does not necessarily return the correct result for short options
37
+	 * when multiple flags are combined in the same option.
38
+	 *
39
+	 * @param string|array $values     The values to look for in the raw parameters (can be an array)
40
+	 * @param bool         $onlyParams Only check real parameters, skip those following an end of options (--) signal
41
+	 *
42
+	 * @return bool
43
+	 */
44
+	public function hasParameterOption($values, bool $onlyParams = false);
45
+
46
+	/**
47
+	 * Returns the value of a raw option (not parsed).
48
+	 *
49
+	 * This method is to be used to introspect the input parameters
50
+	 * before they have been validated. It must be used carefully.
51
+	 * Does not necessarily return the correct result for short options
52
+	 * when multiple flags are combined in the same option.
53
+	 *
54
+	 * @param string|array                     $values     The value(s) to look for in the raw parameters (can be an array)
55
+	 * @param string|bool|int|float|array|null $default    The default value to return if no result is found
56
+	 * @param bool                             $onlyParams Only check real parameters, skip those following an end of options (--) signal
57
+	 *
58
+	 * @return mixed
59
+	 */
60
+	public function getParameterOption($values, $default = false, bool $onlyParams = false);
61
+
62
+	/**
63
+	 * Binds the current Input instance with the given arguments and options.
64
+	 *
65
+	 * @throws RuntimeException
66
+	 */
67
+	public function bind(InputDefinition $definition);
68
+
69
+	/**
70
+	 * Validates the input.
71
+	 *
72
+	 * @throws RuntimeException When not enough arguments are given
73
+	 */
74
+	public function validate();
75
+
76
+	/**
77
+	 * Returns all the given arguments merged with the default values.
78
+	 *
79
+	 * @return array<string|bool|int|float|array|null>
80
+	 */
81
+	public function getArguments();
82
+
83
+	/**
84
+	 * Returns the argument value for a given argument name.
85
+	 *
86
+	 * @return mixed
87
+	 *
88
+	 * @throws InvalidArgumentException When argument given doesn't exist
89
+	 */
90
+	public function getArgument(string $name);
91
+
92
+	/**
93
+	 * Sets an argument value by name.
94
+	 *
95
+	 * @param mixed $value The argument value
96
+	 *
97
+	 * @throws InvalidArgumentException When argument given doesn't exist
98
+	 */
99
+	public function setArgument(string $name, $value);
100
+
101
+	/**
102
+	 * Returns true if an InputArgument object exists by name or position.
103
+	 *
104
+	 * @return bool
105
+	 */
106
+	public function hasArgument(string $name);
107
+
108
+	/**
109
+	 * Returns all the given options merged with the default values.
110
+	 *
111
+	 * @return array<string|bool|int|float|array|null>
112
+	 */
113
+	public function getOptions();
114
+
115
+	/**
116
+	 * Returns the option value for a given option name.
117
+	 *
118
+	 * @return mixed
119
+	 *
120
+	 * @throws InvalidArgumentException When option given doesn't exist
121
+	 */
122
+	public function getOption(string $name);
123
+
124
+	/**
125
+	 * Sets an option value by name.
126
+	 *
127
+	 * @param mixed $value The option value
128
+	 *
129
+	 * @throws InvalidArgumentException When option given doesn't exist
130
+	 */
131
+	public function setOption(string $name, $value);
132
+
133
+	/**
134
+	 * Returns true if an InputOption object exists by name.
135
+	 *
136
+	 * @return bool
137
+	 */
138
+	public function hasOption(string $name);
139
+
140
+	/**
141
+	 * Is this input means interactive?
142
+	 *
143
+	 * @return bool
144
+	 */
145
+	public function isInteractive();
146
+
147
+	/**
148
+	 * Sets the input interactivity.
149
+	 */
150
+	public function setInteractive(bool $interactive);
151 151
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      *
42 42
      * @return bool
43 43
      */
44
-    public function hasParameterOption($values, bool $onlyParams = false);
44
+    public function hasParameterOption( $values, bool $onlyParams = false );
45 45
 
46 46
     /**
47 47
      * Returns the value of a raw option (not parsed).
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return mixed
59 59
      */
60
-    public function getParameterOption($values, $default = false, bool $onlyParams = false);
60
+    public function getParameterOption( $values, $default = false, bool $onlyParams = false );
61 61
 
62 62
     /**
63 63
      * Binds the current Input instance with the given arguments and options.
64 64
      *
65 65
      * @throws RuntimeException
66 66
      */
67
-    public function bind(InputDefinition $definition);
67
+    public function bind( InputDefinition $definition );
68 68
 
69 69
     /**
70 70
      * Validates the input.
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      *
88 88
      * @throws InvalidArgumentException When argument given doesn't exist
89 89
      */
90
-    public function getArgument(string $name);
90
+    public function getArgument( string $name );
91 91
 
92 92
     /**
93 93
      * Sets an argument value by name.
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
      *
97 97
      * @throws InvalidArgumentException When argument given doesn't exist
98 98
      */
99
-    public function setArgument(string $name, $value);
99
+    public function setArgument( string $name, $value );
100 100
 
101 101
     /**
102 102
      * Returns true if an InputArgument object exists by name or position.
103 103
      *
104 104
      * @return bool
105 105
      */
106
-    public function hasArgument(string $name);
106
+    public function hasArgument( string $name );
107 107
 
108 108
     /**
109 109
      * Returns all the given options merged with the default values.
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      *
120 120
      * @throws InvalidArgumentException When option given doesn't exist
121 121
      */
122
-    public function getOption(string $name);
122
+    public function getOption( string $name );
123 123
 
124 124
     /**
125 125
      * Sets an option value by name.
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
      *
129 129
      * @throws InvalidArgumentException When option given doesn't exist
130 130
      */
131
-    public function setOption(string $name, $value);
131
+    public function setOption( string $name, $value );
132 132
 
133 133
     /**
134 134
      * Returns true if an InputOption object exists by name.
135 135
      *
136 136
      * @return bool
137 137
      */
138
-    public function hasOption(string $name);
138
+    public function hasOption( string $name );
139 139
 
140 140
     /**
141 141
      * Is this input means interactive?
@@ -147,5 +147,5 @@  discard block
 block discarded – undo
147 147
     /**
148 148
      * Sets the input interactivity.
149 149
      */
150
-    public function setInteractive(bool $interactive);
150
+    public function setInteractive( bool $interactive );
151 151
 }
Please login to merge, or discard this patch.
vendor/symfony/console/Input/InputAwareInterface.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@
 block discarded – undo
19 19
  */
20 20
 interface InputAwareInterface
21 21
 {
22
-    /**
23
-     * Sets the Console Input.
24
-     */
25
-    public function setInput(InputInterface $input);
22
+	/**
23
+	 * Sets the Console Input.
24
+	 */
25
+	public function setInput(InputInterface $input);
26 26
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,5 +22,5 @@
 block discarded – undo
22 22
     /**
23 23
      * Sets the Console Input.
24 24
      */
25
-    public function setInput(InputInterface $input);
25
+    public function setInput( InputInterface $input );
26 26
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@
 block discarded – undo
17 17
  *
18 18
  * @author Wouter J <[email protected]>
19 19
  */
20
-interface InputAwareInterface
21
-{
20
+interface InputAwareInterface {
22 21
     /**
23 22
      * Sets the Console Input.
24 23
      */
Please login to merge, or discard this patch.
vendor/symfony/console/Input/Input.php 3 patches
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -27,187 +27,187 @@
 block discarded – undo
27 27
  */
28 28
 abstract class Input implements InputInterface, StreamableInputInterface
29 29
 {
30
-    protected $definition;
31
-    protected $stream;
32
-    protected $options = [];
33
-    protected $arguments = [];
34
-    protected $interactive = true;
35
-
36
-    public function __construct(InputDefinition $definition = null)
37
-    {
38
-        if (null === $definition) {
39
-            $this->definition = new InputDefinition();
40
-        } else {
41
-            $this->bind($definition);
42
-            $this->validate();
43
-        }
44
-    }
45
-
46
-    /**
47
-     * {@inheritdoc}
48
-     */
49
-    public function bind(InputDefinition $definition)
50
-    {
51
-        $this->arguments = [];
52
-        $this->options = [];
53
-        $this->definition = $definition;
54
-
55
-        $this->parse();
56
-    }
57
-
58
-    /**
59
-     * Processes command line arguments.
60
-     */
61
-    abstract protected function parse();
62
-
63
-    /**
64
-     * {@inheritdoc}
65
-     */
66
-    public function validate()
67
-    {
68
-        $definition = $this->definition;
69
-        $givenArguments = $this->arguments;
70
-
71
-        $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
72
-            return !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
73
-        });
74
-
75
-        if (\count($missingArguments) > 0) {
76
-            throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
77
-        }
78
-    }
79
-
80
-    /**
81
-     * {@inheritdoc}
82
-     */
83
-    public function isInteractive()
84
-    {
85
-        return $this->interactive;
86
-    }
87
-
88
-    /**
89
-     * {@inheritdoc}
90
-     */
91
-    public function setInteractive(bool $interactive)
92
-    {
93
-        $this->interactive = $interactive;
94
-    }
95
-
96
-    /**
97
-     * {@inheritdoc}
98
-     */
99
-    public function getArguments()
100
-    {
101
-        return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
102
-    }
103
-
104
-    /**
105
-     * {@inheritdoc}
106
-     */
107
-    public function getArgument(string $name)
108
-    {
109
-        if (!$this->definition->hasArgument($name)) {
110
-            throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
111
-        }
112
-
113
-        return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault();
114
-    }
115
-
116
-    /**
117
-     * {@inheritdoc}
118
-     */
119
-    public function setArgument(string $name, $value)
120
-    {
121
-        if (!$this->definition->hasArgument($name)) {
122
-            throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
123
-        }
124
-
125
-        $this->arguments[$name] = $value;
126
-    }
127
-
128
-    /**
129
-     * {@inheritdoc}
130
-     */
131
-    public function hasArgument(string $name)
132
-    {
133
-        return $this->definition->hasArgument($name);
134
-    }
135
-
136
-    /**
137
-     * {@inheritdoc}
138
-     */
139
-    public function getOptions()
140
-    {
141
-        return array_merge($this->definition->getOptionDefaults(), $this->options);
142
-    }
143
-
144
-    /**
145
-     * {@inheritdoc}
146
-     */
147
-    public function getOption(string $name)
148
-    {
149
-        if ($this->definition->hasNegation($name)) {
150
-            if (null === $value = $this->getOption($this->definition->negationToName($name))) {
151
-                return $value;
152
-            }
153
-
154
-            return !$value;
155
-        }
156
-
157
-        if (!$this->definition->hasOption($name)) {
158
-            throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
159
-        }
160
-
161
-        return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
162
-    }
163
-
164
-    /**
165
-     * {@inheritdoc}
166
-     */
167
-    public function setOption(string $name, $value)
168
-    {
169
-        if ($this->definition->hasNegation($name)) {
170
-            $this->options[$this->definition->negationToName($name)] = !$value;
171
-
172
-            return;
173
-        } elseif (!$this->definition->hasOption($name)) {
174
-            throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
175
-        }
176
-
177
-        $this->options[$name] = $value;
178
-    }
179
-
180
-    /**
181
-     * {@inheritdoc}
182
-     */
183
-    public function hasOption(string $name)
184
-    {
185
-        return $this->definition->hasOption($name) || $this->definition->hasNegation($name);
186
-    }
187
-
188
-    /**
189
-     * Escapes a token through escapeshellarg if it contains unsafe chars.
190
-     *
191
-     * @return string
192
-     */
193
-    public function escapeToken(string $token)
194
-    {
195
-        return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
196
-    }
197
-
198
-    /**
199
-     * {@inheritdoc}
200
-     */
201
-    public function setStream($stream)
202
-    {
203
-        $this->stream = $stream;
204
-    }
205
-
206
-    /**
207
-     * {@inheritdoc}
208
-     */
209
-    public function getStream()
210
-    {
211
-        return $this->stream;
212
-    }
30
+	protected $definition;
31
+	protected $stream;
32
+	protected $options = [];
33
+	protected $arguments = [];
34
+	protected $interactive = true;
35
+
36
+	public function __construct(InputDefinition $definition = null)
37
+	{
38
+		if (null === $definition) {
39
+			$this->definition = new InputDefinition();
40
+		} else {
41
+			$this->bind($definition);
42
+			$this->validate();
43
+		}
44
+	}
45
+
46
+	/**
47
+	 * {@inheritdoc}
48
+	 */
49
+	public function bind(InputDefinition $definition)
50
+	{
51
+		$this->arguments = [];
52
+		$this->options = [];
53
+		$this->definition = $definition;
54
+
55
+		$this->parse();
56
+	}
57
+
58
+	/**
59
+	 * Processes command line arguments.
60
+	 */
61
+	abstract protected function parse();
62
+
63
+	/**
64
+	 * {@inheritdoc}
65
+	 */
66
+	public function validate()
67
+	{
68
+		$definition = $this->definition;
69
+		$givenArguments = $this->arguments;
70
+
71
+		$missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
72
+			return !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
73
+		});
74
+
75
+		if (\count($missingArguments) > 0) {
76
+			throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
77
+		}
78
+	}
79
+
80
+	/**
81
+	 * {@inheritdoc}
82
+	 */
83
+	public function isInteractive()
84
+	{
85
+		return $this->interactive;
86
+	}
87
+
88
+	/**
89
+	 * {@inheritdoc}
90
+	 */
91
+	public function setInteractive(bool $interactive)
92
+	{
93
+		$this->interactive = $interactive;
94
+	}
95
+
96
+	/**
97
+	 * {@inheritdoc}
98
+	 */
99
+	public function getArguments()
100
+	{
101
+		return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
102
+	}
103
+
104
+	/**
105
+	 * {@inheritdoc}
106
+	 */
107
+	public function getArgument(string $name)
108
+	{
109
+		if (!$this->definition->hasArgument($name)) {
110
+			throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
111
+		}
112
+
113
+		return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault();
114
+	}
115
+
116
+	/**
117
+	 * {@inheritdoc}
118
+	 */
119
+	public function setArgument(string $name, $value)
120
+	{
121
+		if (!$this->definition->hasArgument($name)) {
122
+			throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
123
+		}
124
+
125
+		$this->arguments[$name] = $value;
126
+	}
127
+
128
+	/**
129
+	 * {@inheritdoc}
130
+	 */
131
+	public function hasArgument(string $name)
132
+	{
133
+		return $this->definition->hasArgument($name);
134
+	}
135
+
136
+	/**
137
+	 * {@inheritdoc}
138
+	 */
139
+	public function getOptions()
140
+	{
141
+		return array_merge($this->definition->getOptionDefaults(), $this->options);
142
+	}
143
+
144
+	/**
145
+	 * {@inheritdoc}
146
+	 */
147
+	public function getOption(string $name)
148
+	{
149
+		if ($this->definition->hasNegation($name)) {
150
+			if (null === $value = $this->getOption($this->definition->negationToName($name))) {
151
+				return $value;
152
+			}
153
+
154
+			return !$value;
155
+		}
156
+
157
+		if (!$this->definition->hasOption($name)) {
158
+			throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
159
+		}
160
+
161
+		return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
162
+	}
163
+
164
+	/**
165
+	 * {@inheritdoc}
166
+	 */
167
+	public function setOption(string $name, $value)
168
+	{
169
+		if ($this->definition->hasNegation($name)) {
170
+			$this->options[$this->definition->negationToName($name)] = !$value;
171
+
172
+			return;
173
+		} elseif (!$this->definition->hasOption($name)) {
174
+			throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
175
+		}
176
+
177
+		$this->options[$name] = $value;
178
+	}
179
+
180
+	/**
181
+	 * {@inheritdoc}
182
+	 */
183
+	public function hasOption(string $name)
184
+	{
185
+		return $this->definition->hasOption($name) || $this->definition->hasNegation($name);
186
+	}
187
+
188
+	/**
189
+	 * Escapes a token through escapeshellarg if it contains unsafe chars.
190
+	 *
191
+	 * @return string
192
+	 */
193
+	public function escapeToken(string $token)
194
+	{
195
+		return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
196
+	}
197
+
198
+	/**
199
+	 * {@inheritdoc}
200
+	 */
201
+	public function setStream($stream)
202
+	{
203
+		$this->stream = $stream;
204
+	}
205
+
206
+	/**
207
+	 * {@inheritdoc}
208
+	 */
209
+	public function getStream()
210
+	{
211
+		return $this->stream;
212
+	}
213 213
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
 {
30 30
     protected $definition;
31 31
     protected $stream;
32
-    protected $options = [];
33
-    protected $arguments = [];
32
+    protected $options = [ ];
33
+    protected $arguments = [ ];
34 34
     protected $interactive = true;
35 35
 
36
-    public function __construct(InputDefinition $definition = null)
36
+    public function __construct( InputDefinition $definition = null )
37 37
     {
38
-        if (null === $definition) {
38
+        if ( null === $definition ) {
39 39
             $this->definition = new InputDefinition();
40 40
         } else {
41
-            $this->bind($definition);
41
+            $this->bind( $definition );
42 42
             $this->validate();
43 43
         }
44 44
     }
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
     /**
47 47
      * {@inheritdoc}
48 48
      */
49
-    public function bind(InputDefinition $definition)
49
+    public function bind( InputDefinition $definition )
50 50
     {
51
-        $this->arguments = [];
52
-        $this->options = [];
51
+        $this->arguments = [ ];
52
+        $this->options = [ ];
53 53
         $this->definition = $definition;
54 54
 
55 55
         $this->parse();
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
         $definition = $this->definition;
69 69
         $givenArguments = $this->arguments;
70 70
 
71
-        $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
72
-            return !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
71
+        $missingArguments = array_filter( array_keys( $definition->getArguments() ), function( $argument ) use ( $definition, $givenArguments ) {
72
+            return ! \array_key_exists( $argument, $givenArguments ) && $definition->getArgument( $argument )->isRequired();
73 73
         });
74 74
 
75
-        if (\count($missingArguments) > 0) {
76
-            throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
75
+        if ( \count( $missingArguments ) > 0 ) {
76
+            throw new RuntimeException( sprintf( 'Not enough arguments (missing: "%s").', implode( ', ', $missingArguments ) ) );
77 77
         }
78 78
     }
79 79
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     /**
89 89
      * {@inheritdoc}
90 90
      */
91
-    public function setInteractive(bool $interactive)
91
+    public function setInteractive( bool $interactive )
92 92
     {
93 93
         $this->interactive = $interactive;
94 94
     }
@@ -98,39 +98,39 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function getArguments()
100 100
     {
101
-        return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
101
+        return array_merge( $this->definition->getArgumentDefaults(), $this->arguments );
102 102
     }
103 103
 
104 104
     /**
105 105
      * {@inheritdoc}
106 106
      */
107
-    public function getArgument(string $name)
107
+    public function getArgument( string $name )
108 108
     {
109
-        if (!$this->definition->hasArgument($name)) {
110
-            throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
109
+        if ( ! $this->definition->hasArgument( $name ) ) {
110
+            throw new InvalidArgumentException( sprintf( 'The "%s" argument does not exist.', $name ) );
111 111
         }
112 112
 
113
-        return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault();
113
+        return $this->arguments[ $name ] ?? $this->definition->getArgument( $name )->getDefault();
114 114
     }
115 115
 
116 116
     /**
117 117
      * {@inheritdoc}
118 118
      */
119
-    public function setArgument(string $name, $value)
119
+    public function setArgument( string $name, $value )
120 120
     {
121
-        if (!$this->definition->hasArgument($name)) {
122
-            throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
121
+        if ( ! $this->definition->hasArgument( $name ) ) {
122
+            throw new InvalidArgumentException( sprintf( 'The "%s" argument does not exist.', $name ) );
123 123
         }
124 124
 
125
-        $this->arguments[$name] = $value;
125
+        $this->arguments[ $name ] = $value;
126 126
     }
127 127
 
128 128
     /**
129 129
      * {@inheritdoc}
130 130
      */
131
-    public function hasArgument(string $name)
131
+    public function hasArgument( string $name )
132 132
     {
133
-        return $this->definition->hasArgument($name);
133
+        return $this->definition->hasArgument( $name );
134 134
     }
135 135
 
136 136
     /**
@@ -138,51 +138,51 @@  discard block
 block discarded – undo
138 138
      */
139 139
     public function getOptions()
140 140
     {
141
-        return array_merge($this->definition->getOptionDefaults(), $this->options);
141
+        return array_merge( $this->definition->getOptionDefaults(), $this->options );
142 142
     }
143 143
 
144 144
     /**
145 145
      * {@inheritdoc}
146 146
      */
147
-    public function getOption(string $name)
147
+    public function getOption( string $name )
148 148
     {
149
-        if ($this->definition->hasNegation($name)) {
150
-            if (null === $value = $this->getOption($this->definition->negationToName($name))) {
149
+        if ( $this->definition->hasNegation( $name ) ) {
150
+            if ( null === $value = $this->getOption( $this->definition->negationToName( $name ) ) ) {
151 151
                 return $value;
152 152
             }
153 153
 
154
-            return !$value;
154
+            return ! $value;
155 155
         }
156 156
 
157
-        if (!$this->definition->hasOption($name)) {
158
-            throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
157
+        if ( ! $this->definition->hasOption( $name ) ) {
158
+            throw new InvalidArgumentException( sprintf( 'The "%s" option does not exist.', $name ) );
159 159
         }
160 160
 
161
-        return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
161
+        return \array_key_exists( $name, $this->options ) ? $this->options[ $name ] : $this->definition->getOption( $name )->getDefault();
162 162
     }
163 163
 
164 164
     /**
165 165
      * {@inheritdoc}
166 166
      */
167
-    public function setOption(string $name, $value)
167
+    public function setOption( string $name, $value )
168 168
     {
169
-        if ($this->definition->hasNegation($name)) {
170
-            $this->options[$this->definition->negationToName($name)] = !$value;
169
+        if ( $this->definition->hasNegation( $name ) ) {
170
+            $this->options[ $this->definition->negationToName( $name ) ] = ! $value;
171 171
 
172 172
             return;
173
-        } elseif (!$this->definition->hasOption($name)) {
174
-            throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
173
+        } elseif ( ! $this->definition->hasOption( $name ) ) {
174
+            throw new InvalidArgumentException( sprintf( 'The "%s" option does not exist.', $name ) );
175 175
         }
176 176
 
177
-        $this->options[$name] = $value;
177
+        $this->options[ $name ] = $value;
178 178
     }
179 179
 
180 180
     /**
181 181
      * {@inheritdoc}
182 182
      */
183
-    public function hasOption(string $name)
183
+    public function hasOption( string $name )
184 184
     {
185
-        return $this->definition->hasOption($name) || $this->definition->hasNegation($name);
185
+        return $this->definition->hasOption( $name ) || $this->definition->hasNegation( $name );
186 186
     }
187 187
 
188 188
     /**
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
      *
191 191
      * @return string
192 192
      */
193
-    public function escapeToken(string $token)
193
+    public function escapeToken( string $token )
194 194
     {
195
-        return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
195
+        return preg_match( '{^[\w-]+$}', $token ) ? $token : escapeshellarg( $token );
196 196
     }
197 197
 
198 198
     /**
199 199
      * {@inheritdoc}
200 200
      */
201
-    public function setStream($stream)
201
+    public function setStream( $stream )
202 202
     {
203 203
         $this->stream = $stream;
204 204
     }
Please login to merge, or discard this patch.
Braces   +16 added lines, -32 removed lines patch added patch discarded remove patch
@@ -33,8 +33,7 @@  discard block
 block discarded – undo
33 33
     protected $arguments = [];
34 34
     protected $interactive = true;
35 35
 
36
-    public function __construct(InputDefinition $definition = null)
37
-    {
36
+    public function __construct(InputDefinition $definition = null) {
38 37
         if (null === $definition) {
39 38
             $this->definition = new InputDefinition();
40 39
         } else {
@@ -46,8 +45,7 @@  discard block
 block discarded – undo
46 45
     /**
47 46
      * {@inheritdoc}
48 47
      */
49
-    public function bind(InputDefinition $definition)
50
-    {
48
+    public function bind(InputDefinition $definition) {
51 49
         $this->arguments = [];
52 50
         $this->options = [];
53 51
         $this->definition = $definition;
@@ -63,8 +61,7 @@  discard block
 block discarded – undo
63 61
     /**
64 62
      * {@inheritdoc}
65 63
      */
66
-    public function validate()
67
-    {
64
+    public function validate() {
68 65
         $definition = $this->definition;
69 66
         $givenArguments = $this->arguments;
70 67
 
@@ -80,32 +77,28 @@  discard block
 block discarded – undo
80 77
     /**
81 78
      * {@inheritdoc}
82 79
      */
83
-    public function isInteractive()
84
-    {
80
+    public function isInteractive() {
85 81
         return $this->interactive;
86 82
     }
87 83
 
88 84
     /**
89 85
      * {@inheritdoc}
90 86
      */
91
-    public function setInteractive(bool $interactive)
92
-    {
87
+    public function setInteractive(bool $interactive) {
93 88
         $this->interactive = $interactive;
94 89
     }
95 90
 
96 91
     /**
97 92
      * {@inheritdoc}
98 93
      */
99
-    public function getArguments()
100
-    {
94
+    public function getArguments() {
101 95
         return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
102 96
     }
103 97
 
104 98
     /**
105 99
      * {@inheritdoc}
106 100
      */
107
-    public function getArgument(string $name)
108
-    {
101
+    public function getArgument(string $name) {
109 102
         if (!$this->definition->hasArgument($name)) {
110 103
             throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
111 104
         }
@@ -116,8 +109,7 @@  discard block
 block discarded – undo
116 109
     /**
117 110
      * {@inheritdoc}
118 111
      */
119
-    public function setArgument(string $name, $value)
120
-    {
112
+    public function setArgument(string $name, $value) {
121 113
         if (!$this->definition->hasArgument($name)) {
122 114
             throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
123 115
         }
@@ -128,24 +120,21 @@  discard block
 block discarded – undo
128 120
     /**
129 121
      * {@inheritdoc}
130 122
      */
131
-    public function hasArgument(string $name)
132
-    {
123
+    public function hasArgument(string $name) {
133 124
         return $this->definition->hasArgument($name);
134 125
     }
135 126
 
136 127
     /**
137 128
      * {@inheritdoc}
138 129
      */
139
-    public function getOptions()
140
-    {
130
+    public function getOptions() {
141 131
         return array_merge($this->definition->getOptionDefaults(), $this->options);
142 132
     }
143 133
 
144 134
     /**
145 135
      * {@inheritdoc}
146 136
      */
147
-    public function getOption(string $name)
148
-    {
137
+    public function getOption(string $name) {
149 138
         if ($this->definition->hasNegation($name)) {
150 139
             if (null === $value = $this->getOption($this->definition->negationToName($name))) {
151 140
                 return $value;
@@ -164,8 +153,7 @@  discard block
 block discarded – undo
164 153
     /**
165 154
      * {@inheritdoc}
166 155
      */
167
-    public function setOption(string $name, $value)
168
-    {
156
+    public function setOption(string $name, $value) {
169 157
         if ($this->definition->hasNegation($name)) {
170 158
             $this->options[$this->definition->negationToName($name)] = !$value;
171 159
 
@@ -180,8 +168,7 @@  discard block
 block discarded – undo
180 168
     /**
181 169
      * {@inheritdoc}
182 170
      */
183
-    public function hasOption(string $name)
184
-    {
171
+    public function hasOption(string $name) {
185 172
         return $this->definition->hasOption($name) || $this->definition->hasNegation($name);
186 173
     }
187 174
 
@@ -190,24 +177,21 @@  discard block
 block discarded – undo
190 177
      *
191 178
      * @return string
192 179
      */
193
-    public function escapeToken(string $token)
194
-    {
180
+    public function escapeToken(string $token) {
195 181
         return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
196 182
     }
197 183
 
198 184
     /**
199 185
      * {@inheritdoc}
200 186
      */
201
-    public function setStream($stream)
202
-    {
187
+    public function setStream($stream) {
203 188
         $this->stream = $stream;
204 189
     }
205 190
 
206 191
     /**
207 192
      * {@inheritdoc}
208 193
      */
209
-    public function getStream()
210
-    {
194
+    public function getStream() {
211 195
         return $this->stream;
212 196
     }
213 197
 }
Please login to merge, or discard this patch.
vendor/symfony/console/Input/ArrayInput.php 3 patches
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -25,186 +25,186 @@
 block discarded – undo
25 25
  */
26 26
 class ArrayInput extends Input
27 27
 {
28
-    private $parameters;
29
-
30
-    public function __construct(array $parameters, InputDefinition $definition = null)
31
-    {
32
-        $this->parameters = $parameters;
33
-
34
-        parent::__construct($definition);
35
-    }
36
-
37
-    /**
38
-     * {@inheritdoc}
39
-     */
40
-    public function getFirstArgument()
41
-    {
42
-        foreach ($this->parameters as $param => $value) {
43
-            if ($param && \is_string($param) && '-' === $param[0]) {
44
-                continue;
45
-            }
46
-
47
-            return $value;
48
-        }
49
-
50
-        return null;
51
-    }
52
-
53
-    /**
54
-     * {@inheritdoc}
55
-     */
56
-    public function hasParameterOption($values, bool $onlyParams = false)
57
-    {
58
-        $values = (array) $values;
59
-
60
-        foreach ($this->parameters as $k => $v) {
61
-            if (!\is_int($k)) {
62
-                $v = $k;
63
-            }
64
-
65
-            if ($onlyParams && '--' === $v) {
66
-                return false;
67
-            }
68
-
69
-            if (\in_array($v, $values)) {
70
-                return true;
71
-            }
72
-        }
73
-
74
-        return false;
75
-    }
76
-
77
-    /**
78
-     * {@inheritdoc}
79
-     */
80
-    public function getParameterOption($values, $default = false, bool $onlyParams = false)
81
-    {
82
-        $values = (array) $values;
83
-
84
-        foreach ($this->parameters as $k => $v) {
85
-            if ($onlyParams && ('--' === $k || (\is_int($k) && '--' === $v))) {
86
-                return $default;
87
-            }
88
-
89
-            if (\is_int($k)) {
90
-                if (\in_array($v, $values)) {
91
-                    return true;
92
-                }
93
-            } elseif (\in_array($k, $values)) {
94
-                return $v;
95
-            }
96
-        }
97
-
98
-        return $default;
99
-    }
100
-
101
-    /**
102
-     * Returns a stringified representation of the args passed to the command.
103
-     *
104
-     * @return string
105
-     */
106
-    public function __toString()
107
-    {
108
-        $params = [];
109
-        foreach ($this->parameters as $param => $val) {
110
-            if ($param && \is_string($param) && '-' === $param[0]) {
111
-                $glue = ('-' === $param[1]) ? '=' : ' ';
112
-                if (\is_array($val)) {
113
-                    foreach ($val as $v) {
114
-                        $params[] = $param.('' != $v ? $glue.$this->escapeToken($v) : '');
115
-                    }
116
-                } else {
117
-                    $params[] = $param.('' != $val ? $glue.$this->escapeToken($val) : '');
118
-                }
119
-            } else {
120
-                $params[] = \is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val);
121
-            }
122
-        }
123
-
124
-        return implode(' ', $params);
125
-    }
126
-
127
-    /**
128
-     * {@inheritdoc}
129
-     */
130
-    protected function parse()
131
-    {
132
-        foreach ($this->parameters as $key => $value) {
133
-            if ('--' === $key) {
134
-                return;
135
-            }
136
-            if (str_starts_with($key, '--')) {
137
-                $this->addLongOption(substr($key, 2), $value);
138
-            } elseif (str_starts_with($key, '-')) {
139
-                $this->addShortOption(substr($key, 1), $value);
140
-            } else {
141
-                $this->addArgument($key, $value);
142
-            }
143
-        }
144
-    }
145
-
146
-    /**
147
-     * Adds a short option value.
148
-     *
149
-     * @throws InvalidOptionException When option given doesn't exist
150
-     */
151
-    private function addShortOption(string $shortcut, $value)
152
-    {
153
-        if (!$this->definition->hasShortcut($shortcut)) {
154
-            throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
155
-        }
156
-
157
-        $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
158
-    }
159
-
160
-    /**
161
-     * Adds a long option value.
162
-     *
163
-     * @throws InvalidOptionException When option given doesn't exist
164
-     * @throws InvalidOptionException When a required value is missing
165
-     */
166
-    private function addLongOption(string $name, $value)
167
-    {
168
-        if (!$this->definition->hasOption($name)) {
169
-            if (!$this->definition->hasNegation($name)) {
170
-                throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
171
-            }
172
-
173
-            $optionName = $this->definition->negationToName($name);
174
-            $this->options[$optionName] = false;
175
-
176
-            return;
177
-        }
178
-
179
-        $option = $this->definition->getOption($name);
180
-
181
-        if (null === $value) {
182
-            if ($option->isValueRequired()) {
183
-                throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
184
-            }
185
-
186
-            if (!$option->isValueOptional()) {
187
-                $value = true;
188
-            }
189
-        }
190
-
191
-        $this->options[$name] = $value;
192
-    }
193
-
194
-    /**
195
-     * Adds an argument value.
196
-     *
197
-     * @param string|int $name  The argument name
198
-     * @param mixed      $value The value for the argument
199
-     *
200
-     * @throws InvalidArgumentException When argument given doesn't exist
201
-     */
202
-    private function addArgument($name, $value)
203
-    {
204
-        if (!$this->definition->hasArgument($name)) {
205
-            throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
206
-        }
207
-
208
-        $this->arguments[$name] = $value;
209
-    }
28
+	private $parameters;
29
+
30
+	public function __construct(array $parameters, InputDefinition $definition = null)
31
+	{
32
+		$this->parameters = $parameters;
33
+
34
+		parent::__construct($definition);
35
+	}
36
+
37
+	/**
38
+	 * {@inheritdoc}
39
+	 */
40
+	public function getFirstArgument()
41
+	{
42
+		foreach ($this->parameters as $param => $value) {
43
+			if ($param && \is_string($param) && '-' === $param[0]) {
44
+				continue;
45
+			}
46
+
47
+			return $value;
48
+		}
49
+
50
+		return null;
51
+	}
52
+
53
+	/**
54
+	 * {@inheritdoc}
55
+	 */
56
+	public function hasParameterOption($values, bool $onlyParams = false)
57
+	{
58
+		$values = (array) $values;
59
+
60
+		foreach ($this->parameters as $k => $v) {
61
+			if (!\is_int($k)) {
62
+				$v = $k;
63
+			}
64
+
65
+			if ($onlyParams && '--' === $v) {
66
+				return false;
67
+			}
68
+
69
+			if (\in_array($v, $values)) {
70
+				return true;
71
+			}
72
+		}
73
+
74
+		return false;
75
+	}
76
+
77
+	/**
78
+	 * {@inheritdoc}
79
+	 */
80
+	public function getParameterOption($values, $default = false, bool $onlyParams = false)
81
+	{
82
+		$values = (array) $values;
83
+
84
+		foreach ($this->parameters as $k => $v) {
85
+			if ($onlyParams && ('--' === $k || (\is_int($k) && '--' === $v))) {
86
+				return $default;
87
+			}
88
+
89
+			if (\is_int($k)) {
90
+				if (\in_array($v, $values)) {
91
+					return true;
92
+				}
93
+			} elseif (\in_array($k, $values)) {
94
+				return $v;
95
+			}
96
+		}
97
+
98
+		return $default;
99
+	}
100
+
101
+	/**
102
+	 * Returns a stringified representation of the args passed to the command.
103
+	 *
104
+	 * @return string
105
+	 */
106
+	public function __toString()
107
+	{
108
+		$params = [];
109
+		foreach ($this->parameters as $param => $val) {
110
+			if ($param && \is_string($param) && '-' === $param[0]) {
111
+				$glue = ('-' === $param[1]) ? '=' : ' ';
112
+				if (\is_array($val)) {
113
+					foreach ($val as $v) {
114
+						$params[] = $param.('' != $v ? $glue.$this->escapeToken($v) : '');
115
+					}
116
+				} else {
117
+					$params[] = $param.('' != $val ? $glue.$this->escapeToken($val) : '');
118
+				}
119
+			} else {
120
+				$params[] = \is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val);
121
+			}
122
+		}
123
+
124
+		return implode(' ', $params);
125
+	}
126
+
127
+	/**
128
+	 * {@inheritdoc}
129
+	 */
130
+	protected function parse()
131
+	{
132
+		foreach ($this->parameters as $key => $value) {
133
+			if ('--' === $key) {
134
+				return;
135
+			}
136
+			if (str_starts_with($key, '--')) {
137
+				$this->addLongOption(substr($key, 2), $value);
138
+			} elseif (str_starts_with($key, '-')) {
139
+				$this->addShortOption(substr($key, 1), $value);
140
+			} else {
141
+				$this->addArgument($key, $value);
142
+			}
143
+		}
144
+	}
145
+
146
+	/**
147
+	 * Adds a short option value.
148
+	 *
149
+	 * @throws InvalidOptionException When option given doesn't exist
150
+	 */
151
+	private function addShortOption(string $shortcut, $value)
152
+	{
153
+		if (!$this->definition->hasShortcut($shortcut)) {
154
+			throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
155
+		}
156
+
157
+		$this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
158
+	}
159
+
160
+	/**
161
+	 * Adds a long option value.
162
+	 *
163
+	 * @throws InvalidOptionException When option given doesn't exist
164
+	 * @throws InvalidOptionException When a required value is missing
165
+	 */
166
+	private function addLongOption(string $name, $value)
167
+	{
168
+		if (!$this->definition->hasOption($name)) {
169
+			if (!$this->definition->hasNegation($name)) {
170
+				throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
171
+			}
172
+
173
+			$optionName = $this->definition->negationToName($name);
174
+			$this->options[$optionName] = false;
175
+
176
+			return;
177
+		}
178
+
179
+		$option = $this->definition->getOption($name);
180
+
181
+		if (null === $value) {
182
+			if ($option->isValueRequired()) {
183
+				throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
184
+			}
185
+
186
+			if (!$option->isValueOptional()) {
187
+				$value = true;
188
+			}
189
+		}
190
+
191
+		$this->options[$name] = $value;
192
+	}
193
+
194
+	/**
195
+	 * Adds an argument value.
196
+	 *
197
+	 * @param string|int $name  The argument name
198
+	 * @param mixed      $value The value for the argument
199
+	 *
200
+	 * @throws InvalidArgumentException When argument given doesn't exist
201
+	 */
202
+	private function addArgument($name, $value)
203
+	{
204
+		if (!$this->definition->hasArgument($name)) {
205
+			throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
206
+		}
207
+
208
+		$this->arguments[$name] = $value;
209
+	}
210 210
 }
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 {
28 28
     private $parameters;
29 29
 
30
-    public function __construct(array $parameters, InputDefinition $definition = null)
30
+    public function __construct( array $parameters, InputDefinition $definition = null )
31 31
     {
32 32
         $this->parameters = $parameters;
33 33
 
34
-        parent::__construct($definition);
34
+        parent::__construct( $definition );
35 35
     }
36 36
 
37 37
     /**
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function getFirstArgument()
41 41
     {
42
-        foreach ($this->parameters as $param => $value) {
43
-            if ($param && \is_string($param) && '-' === $param[0]) {
42
+        foreach ( $this->parameters as $param => $value ) {
43
+            if ( $param && \is_string( $param ) && '-' === $param[ 0 ] ) {
44 44
                 continue;
45 45
             }
46 46
 
@@ -53,20 +53,20 @@  discard block
 block discarded – undo
53 53
     /**
54 54
      * {@inheritdoc}
55 55
      */
56
-    public function hasParameterOption($values, bool $onlyParams = false)
56
+    public function hasParameterOption( $values, bool $onlyParams = false )
57 57
     {
58
-        $values = (array) $values;
58
+        $values = (array)$values;
59 59
 
60
-        foreach ($this->parameters as $k => $v) {
61
-            if (!\is_int($k)) {
60
+        foreach ( $this->parameters as $k => $v ) {
61
+            if ( ! \is_int( $k ) ) {
62 62
                 $v = $k;
63 63
             }
64 64
 
65
-            if ($onlyParams && '--' === $v) {
65
+            if ( $onlyParams && '--' === $v ) {
66 66
                 return false;
67 67
             }
68 68
 
69
-            if (\in_array($v, $values)) {
69
+            if ( \in_array( $v, $values ) ) {
70 70
                 return true;
71 71
             }
72 72
         }
@@ -77,20 +77,20 @@  discard block
 block discarded – undo
77 77
     /**
78 78
      * {@inheritdoc}
79 79
      */
80
-    public function getParameterOption($values, $default = false, bool $onlyParams = false)
80
+    public function getParameterOption( $values, $default = false, bool $onlyParams = false )
81 81
     {
82
-        $values = (array) $values;
82
+        $values = (array)$values;
83 83
 
84
-        foreach ($this->parameters as $k => $v) {
85
-            if ($onlyParams && ('--' === $k || (\is_int($k) && '--' === $v))) {
84
+        foreach ( $this->parameters as $k => $v ) {
85
+            if ( $onlyParams && ( '--' === $k || ( \is_int( $k ) && '--' === $v ) ) ) {
86 86
                 return $default;
87 87
             }
88 88
 
89
-            if (\is_int($k)) {
90
-                if (\in_array($v, $values)) {
89
+            if ( \is_int( $k ) ) {
90
+                if ( \in_array( $v, $values ) ) {
91 91
                     return true;
92 92
                 }
93
-            } elseif (\in_array($k, $values)) {
93
+            } elseif ( \in_array( $k, $values ) ) {
94 94
                 return $v;
95 95
             }
96 96
         }
@@ -105,23 +105,23 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function __toString()
107 107
     {
108
-        $params = [];
109
-        foreach ($this->parameters as $param => $val) {
110
-            if ($param && \is_string($param) && '-' === $param[0]) {
111
-                $glue = ('-' === $param[1]) ? '=' : ' ';
112
-                if (\is_array($val)) {
113
-                    foreach ($val as $v) {
114
-                        $params[] = $param.('' != $v ? $glue.$this->escapeToken($v) : '');
108
+        $params = [ ];
109
+        foreach ( $this->parameters as $param => $val ) {
110
+            if ( $param && \is_string( $param ) && '-' === $param[ 0 ] ) {
111
+                $glue = ( '-' === $param[ 1 ] ) ? '=' : ' ';
112
+                if ( \is_array( $val ) ) {
113
+                    foreach ( $val as $v ) {
114
+                        $params[ ] = $param . ( '' != $v ? $glue . $this->escapeToken( $v ) : '' );
115 115
                     }
116 116
                 } else {
117
-                    $params[] = $param.('' != $val ? $glue.$this->escapeToken($val) : '');
117
+                    $params[ ] = $param . ( '' != $val ? $glue . $this->escapeToken( $val ) : '' );
118 118
                 }
119 119
             } else {
120
-                $params[] = \is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val);
120
+                $params[ ] = \is_array( $val ) ? implode( ' ', array_map( [ $this, 'escapeToken' ], $val ) ) : $this->escapeToken( $val );
121 121
             }
122 122
         }
123 123
 
124
-        return implode(' ', $params);
124
+        return implode( ' ', $params );
125 125
     }
126 126
 
127 127
     /**
@@ -129,16 +129,16 @@  discard block
 block discarded – undo
129 129
      */
130 130
     protected function parse()
131 131
     {
132
-        foreach ($this->parameters as $key => $value) {
133
-            if ('--' === $key) {
132
+        foreach ( $this->parameters as $key => $value ) {
133
+            if ( '--' === $key ) {
134 134
                 return;
135 135
             }
136
-            if (str_starts_with($key, '--')) {
137
-                $this->addLongOption(substr($key, 2), $value);
138
-            } elseif (str_starts_with($key, '-')) {
139
-                $this->addShortOption(substr($key, 1), $value);
136
+            if ( str_starts_with( $key, '--' ) ) {
137
+                $this->addLongOption( substr( $key, 2 ), $value );
138
+            } elseif ( str_starts_with( $key, '-' ) ) {
139
+                $this->addShortOption( substr( $key, 1 ), $value );
140 140
             } else {
141
-                $this->addArgument($key, $value);
141
+                $this->addArgument( $key, $value );
142 142
             }
143 143
         }
144 144
     }
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
      *
149 149
      * @throws InvalidOptionException When option given doesn't exist
150 150
      */
151
-    private function addShortOption(string $shortcut, $value)
151
+    private function addShortOption( string $shortcut, $value )
152 152
     {
153
-        if (!$this->definition->hasShortcut($shortcut)) {
154
-            throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
153
+        if ( ! $this->definition->hasShortcut( $shortcut ) ) {
154
+            throw new InvalidOptionException( sprintf( 'The "-%s" option does not exist.', $shortcut ) );
155 155
         }
156 156
 
157
-        $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
157
+        $this->addLongOption( $this->definition->getOptionForShortcut( $shortcut )->getName(), $value );
158 158
     }
159 159
 
160 160
     /**
@@ -163,32 +163,32 @@  discard block
 block discarded – undo
163 163
      * @throws InvalidOptionException When option given doesn't exist
164 164
      * @throws InvalidOptionException When a required value is missing
165 165
      */
166
-    private function addLongOption(string $name, $value)
166
+    private function addLongOption( string $name, $value )
167 167
     {
168
-        if (!$this->definition->hasOption($name)) {
169
-            if (!$this->definition->hasNegation($name)) {
170
-                throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
168
+        if ( ! $this->definition->hasOption( $name ) ) {
169
+            if ( ! $this->definition->hasNegation( $name ) ) {
170
+                throw new InvalidOptionException( sprintf( 'The "--%s" option does not exist.', $name ) );
171 171
             }
172 172
 
173
-            $optionName = $this->definition->negationToName($name);
174
-            $this->options[$optionName] = false;
173
+            $optionName = $this->definition->negationToName( $name );
174
+            $this->options[ $optionName ] = false;
175 175
 
176 176
             return;
177 177
         }
178 178
 
179
-        $option = $this->definition->getOption($name);
179
+        $option = $this->definition->getOption( $name );
180 180
 
181
-        if (null === $value) {
182
-            if ($option->isValueRequired()) {
183
-                throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
181
+        if ( null === $value ) {
182
+            if ( $option->isValueRequired() ) {
183
+                throw new InvalidOptionException( sprintf( 'The "--%s" option requires a value.', $name ) );
184 184
             }
185 185
 
186
-            if (!$option->isValueOptional()) {
186
+            if ( ! $option->isValueOptional() ) {
187 187
                 $value = true;
188 188
             }
189 189
         }
190 190
 
191
-        $this->options[$name] = $value;
191
+        $this->options[ $name ] = $value;
192 192
     }
193 193
 
194 194
     /**
@@ -199,12 +199,12 @@  discard block
 block discarded – undo
199 199
      *
200 200
      * @throws InvalidArgumentException When argument given doesn't exist
201 201
      */
202
-    private function addArgument($name, $value)
202
+    private function addArgument( $name, $value )
203 203
     {
204
-        if (!$this->definition->hasArgument($name)) {
205
-            throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
204
+        if ( ! $this->definition->hasArgument( $name ) ) {
205
+            throw new InvalidArgumentException( sprintf( 'The "%s" argument does not exist.', $name ) );
206 206
         }
207 207
 
208
-        $this->arguments[$name] = $value;
208
+        $this->arguments[ $name ] = $value;
209 209
     }
210 210
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,12 +23,10 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @author Fabien Potencier <[email protected]>
25 25
  */
26
-class ArrayInput extends Input
27
-{
26
+class ArrayInput extends Input {
28 27
     private $parameters;
29 28
 
30
-    public function __construct(array $parameters, InputDefinition $definition = null)
31
-    {
29
+    public function __construct(array $parameters, InputDefinition $definition = null) {
32 30
         $this->parameters = $parameters;
33 31
 
34 32
         parent::__construct($definition);
@@ -37,8 +35,7 @@  discard block
 block discarded – undo
37 35
     /**
38 36
      * {@inheritdoc}
39 37
      */
40
-    public function getFirstArgument()
41
-    {
38
+    public function getFirstArgument() {
42 39
         foreach ($this->parameters as $param => $value) {
43 40
             if ($param && \is_string($param) && '-' === $param[0]) {
44 41
                 continue;
@@ -53,8 +50,7 @@  discard block
 block discarded – undo
53 50
     /**
54 51
      * {@inheritdoc}
55 52
      */
56
-    public function hasParameterOption($values, bool $onlyParams = false)
57
-    {
53
+    public function hasParameterOption($values, bool $onlyParams = false) {
58 54
         $values = (array) $values;
59 55
 
60 56
         foreach ($this->parameters as $k => $v) {
@@ -77,8 +73,7 @@  discard block
 block discarded – undo
77 73
     /**
78 74
      * {@inheritdoc}
79 75
      */
80
-    public function getParameterOption($values, $default = false, bool $onlyParams = false)
81
-    {
76
+    public function getParameterOption($values, $default = false, bool $onlyParams = false) {
82 77
         $values = (array) $values;
83 78
 
84 79
         foreach ($this->parameters as $k => $v) {
@@ -103,8 +98,7 @@  discard block
 block discarded – undo
103 98
      *
104 99
      * @return string
105 100
      */
106
-    public function __toString()
107
-    {
101
+    public function __toString() {
108 102
         $params = [];
109 103
         foreach ($this->parameters as $param => $val) {
110 104
             if ($param && \is_string($param) && '-' === $param[0]) {
@@ -127,8 +121,7 @@  discard block
 block discarded – undo
127 121
     /**
128 122
      * {@inheritdoc}
129 123
      */
130
-    protected function parse()
131
-    {
124
+    protected function parse() {
132 125
         foreach ($this->parameters as $key => $value) {
133 126
             if ('--' === $key) {
134 127
                 return;
@@ -148,8 +141,7 @@  discard block
 block discarded – undo
148 141
      *
149 142
      * @throws InvalidOptionException When option given doesn't exist
150 143
      */
151
-    private function addShortOption(string $shortcut, $value)
152
-    {
144
+    private function addShortOption(string $shortcut, $value) {
153 145
         if (!$this->definition->hasShortcut($shortcut)) {
154 146
             throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
155 147
         }
@@ -163,8 +155,7 @@  discard block
 block discarded – undo
163 155
      * @throws InvalidOptionException When option given doesn't exist
164 156
      * @throws InvalidOptionException When a required value is missing
165 157
      */
166
-    private function addLongOption(string $name, $value)
167
-    {
158
+    private function addLongOption(string $name, $value) {
168 159
         if (!$this->definition->hasOption($name)) {
169 160
             if (!$this->definition->hasNegation($name)) {
170 161
                 throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
@@ -199,8 +190,7 @@  discard block
 block discarded – undo
199 190
      *
200 191
      * @throws InvalidArgumentException When argument given doesn't exist
201 192
      */
202
-    private function addArgument($name, $value)
203
-    {
193
+    private function addArgument($name, $value) {
204 194
         if (!$this->definition->hasArgument($name)) {
205 195
             throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
206 196
         }
Please login to merge, or discard this patch.