@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | private $command; |
26 | 26 | private $isEnabled; |
27 | 27 | |
28 | - public function __construct(string $name, array $aliases, string $description, bool $isHidden, \Closure $commandFactory, ?bool $isEnabled = true) |
|
28 | + public function __construct( string $name, array $aliases, string $description, bool $isHidden, \Closure $commandFactory, ?bool $isEnabled = true ) |
|
29 | 29 | { |
30 | - $this->setName($name) |
|
31 | - ->setAliases($aliases) |
|
32 | - ->setHidden($isHidden) |
|
33 | - ->setDescription($description); |
|
30 | + $this->setName( $name ) |
|
31 | + ->setAliases( $aliases ) |
|
32 | + ->setHidden( $isHidden ) |
|
33 | + ->setDescription( $description ); |
|
34 | 34 | |
35 | 35 | $this->command = $commandFactory; |
36 | 36 | $this->isEnabled = $isEnabled; |
@@ -41,22 +41,22 @@ discard block |
||
41 | 41 | $this->getCommand()->ignoreValidationErrors(); |
42 | 42 | } |
43 | 43 | |
44 | - public function setApplication(Application $application = null): void |
|
44 | + public function setApplication( Application $application = null ): void |
|
45 | 45 | { |
46 | - if ($this->command instanceof parent) { |
|
47 | - $this->command->setApplication($application); |
|
46 | + if ( $this->command instanceof parent ) { |
|
47 | + $this->command->setApplication( $application ); |
|
48 | 48 | } |
49 | 49 | |
50 | - parent::setApplication($application); |
|
50 | + parent::setApplication( $application ); |
|
51 | 51 | } |
52 | 52 | |
53 | - public function setHelperSet(HelperSet $helperSet): void |
|
53 | + public function setHelperSet( HelperSet $helperSet ): void |
|
54 | 54 | { |
55 | - if ($this->command instanceof parent) { |
|
56 | - $this->command->setHelperSet($helperSet); |
|
55 | + if ( $this->command instanceof parent ) { |
|
56 | + $this->command->setHelperSet( $helperSet ); |
|
57 | 57 | } |
58 | 58 | |
59 | - parent::setHelperSet($helperSet); |
|
59 | + parent::setHelperSet( $helperSet ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | public function isEnabled(): bool |
@@ -64,17 +64,17 @@ discard block |
||
64 | 64 | return $this->isEnabled ?? $this->getCommand()->isEnabled(); |
65 | 65 | } |
66 | 66 | |
67 | - public function run(InputInterface $input, OutputInterface $output): int |
|
67 | + public function run( InputInterface $input, OutputInterface $output ): int |
|
68 | 68 | { |
69 | - return $this->getCommand()->run($input, $output); |
|
69 | + return $this->getCommand()->run( $input, $output ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * @return $this |
74 | 74 | */ |
75 | - public function setCode(callable $code): self |
|
75 | + public function setCode( callable $code ): self |
|
76 | 76 | { |
77 | - $this->getCommand()->setCode($code); |
|
77 | + $this->getCommand()->setCode( $code ); |
|
78 | 78 | |
79 | 79 | return $this; |
80 | 80 | } |
@@ -82,17 +82,17 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * @internal |
84 | 84 | */ |
85 | - public function mergeApplicationDefinition(bool $mergeArgs = true): void |
|
85 | + public function mergeApplicationDefinition( bool $mergeArgs = true ): void |
|
86 | 86 | { |
87 | - $this->getCommand()->mergeApplicationDefinition($mergeArgs); |
|
87 | + $this->getCommand()->mergeApplicationDefinition( $mergeArgs ); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @return $this |
92 | 92 | */ |
93 | - public function setDefinition($definition): self |
|
93 | + public function setDefinition( $definition ): self |
|
94 | 94 | { |
95 | - $this->getCommand()->setDefinition($definition); |
|
95 | + $this->getCommand()->setDefinition( $definition ); |
|
96 | 96 | |
97 | 97 | return $this; |
98 | 98 | } |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | /** |
111 | 111 | * @return $this |
112 | 112 | */ |
113 | - public function addArgument(string $name, int $mode = null, string $description = '', $default = null): self |
|
113 | + public function addArgument( string $name, int $mode = null, string $description = '', $default = null ): self |
|
114 | 114 | { |
115 | - $this->getCommand()->addArgument($name, $mode, $description, $default); |
|
115 | + $this->getCommand()->addArgument( $name, $mode, $description, $default ); |
|
116 | 116 | |
117 | 117 | return $this; |
118 | 118 | } |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * @return $this |
122 | 122 | */ |
123 | - public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null): self |
|
123 | + public function addOption( string $name, $shortcut = null, int $mode = null, string $description = '', $default = null ): self |
|
124 | 124 | { |
125 | - $this->getCommand()->addOption($name, $shortcut, $mode, $description, $default); |
|
125 | + $this->getCommand()->addOption( $name, $shortcut, $mode, $description, $default ); |
|
126 | 126 | |
127 | 127 | return $this; |
128 | 128 | } |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | /** |
131 | 131 | * @return $this |
132 | 132 | */ |
133 | - public function setProcessTitle(string $title): self |
|
133 | + public function setProcessTitle( string $title ): self |
|
134 | 134 | { |
135 | - $this->getCommand()->setProcessTitle($title); |
|
135 | + $this->getCommand()->setProcessTitle( $title ); |
|
136 | 136 | |
137 | 137 | return $this; |
138 | 138 | } |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * @return $this |
142 | 142 | */ |
143 | - public function setHelp(string $help): self |
|
143 | + public function setHelp( string $help ): self |
|
144 | 144 | { |
145 | - $this->getCommand()->setHelp($help); |
|
145 | + $this->getCommand()->setHelp( $help ); |
|
146 | 146 | |
147 | 147 | return $this; |
148 | 148 | } |
@@ -157,17 +157,17 @@ discard block |
||
157 | 157 | return $this->getCommand()->getProcessedHelp(); |
158 | 158 | } |
159 | 159 | |
160 | - public function getSynopsis(bool $short = false): string |
|
160 | + public function getSynopsis( bool $short = false ): string |
|
161 | 161 | { |
162 | - return $this->getCommand()->getSynopsis($short); |
|
162 | + return $this->getCommand()->getSynopsis( $short ); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | 166 | * @return $this |
167 | 167 | */ |
168 | - public function addUsage(string $usage): self |
|
168 | + public function addUsage( string $usage ): self |
|
169 | 169 | { |
170 | - $this->getCommand()->addUsage($usage); |
|
170 | + $this->getCommand()->addUsage( $usage ); |
|
171 | 171 | |
172 | 172 | return $this; |
173 | 173 | } |
@@ -180,28 +180,28 @@ discard block |
||
180 | 180 | /** |
181 | 181 | * @return mixed |
182 | 182 | */ |
183 | - public function getHelper(string $name) |
|
183 | + public function getHelper( string $name ) |
|
184 | 184 | { |
185 | - return $this->getCommand()->getHelper($name); |
|
185 | + return $this->getCommand()->getHelper( $name ); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | public function getCommand(): parent |
189 | 189 | { |
190 | - if (!$this->command instanceof \Closure) { |
|
190 | + if ( ! $this->command instanceof \Closure ) { |
|
191 | 191 | return $this->command; |
192 | 192 | } |
193 | 193 | |
194 | - $command = $this->command = ($this->command)(); |
|
195 | - $command->setApplication($this->getApplication()); |
|
194 | + $command = $this->command = ( $this->command )(); |
|
195 | + $command->setApplication( $this->getApplication() ); |
|
196 | 196 | |
197 | - if (null !== $this->getHelperSet()) { |
|
198 | - $command->setHelperSet($this->getHelperSet()); |
|
197 | + if ( null !== $this->getHelperSet() ) { |
|
198 | + $command->setHelperSet( $this->getHelperSet() ); |
|
199 | 199 | } |
200 | 200 | |
201 | - $command->setName($this->getName()) |
|
202 | - ->setAliases($this->getAliases()) |
|
203 | - ->setHidden($this->isHidden()) |
|
204 | - ->setDescription($this->getDescription()); |
|
201 | + $command->setName( $this->getName() ) |
|
202 | + ->setAliases( $this->getAliases() ) |
|
203 | + ->setHidden( $this->isHidden() ) |
|
204 | + ->setDescription( $this->getDescription() ); |
|
205 | 205 | |
206 | 206 | // Will throw if the command is not correctly initialized. |
207 | 207 | $command->getDefinition(); |
@@ -30,24 +30,24 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Locks a command. |
32 | 32 | */ |
33 | - private function lock(string $name = null, bool $blocking = false): bool |
|
33 | + private function lock( string $name = null, bool $blocking = false ): bool |
|
34 | 34 | { |
35 | - if (!class_exists(SemaphoreStore::class)) { |
|
36 | - throw new LogicException('To enable the locking feature you must install the symfony/lock component.'); |
|
35 | + if ( ! class_exists( SemaphoreStore::class ) ) { |
|
36 | + throw new LogicException( 'To enable the locking feature you must install the symfony/lock component.' ); |
|
37 | 37 | } |
38 | 38 | |
39 | - if (null !== $this->lock) { |
|
40 | - throw new LogicException('A lock is already in place.'); |
|
39 | + if ( null !== $this->lock ) { |
|
40 | + throw new LogicException( 'A lock is already in place.' ); |
|
41 | 41 | } |
42 | 42 | |
43 | - if (SemaphoreStore::isSupported()) { |
|
43 | + if ( SemaphoreStore::isSupported() ) { |
|
44 | 44 | $store = new SemaphoreStore(); |
45 | 45 | } else { |
46 | 46 | $store = new FlockStore(); |
47 | 47 | } |
48 | 48 | |
49 | - $this->lock = (new LockFactory($store))->createLock($name ?: $this->getName()); |
|
50 | - if (!$this->lock->acquire($blocking)) { |
|
49 | + $this->lock = ( new LockFactory( $store ) )->createLock( $name ?: $this->getName() ); |
|
50 | + if ( ! $this->lock->acquire( $blocking ) ) { |
|
51 | 51 | $this->lock = null; |
52 | 52 | |
53 | 53 | return false; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | private function release() |
63 | 63 | { |
64 | - if ($this->lock) { |
|
64 | + if ( $this->lock ) { |
|
65 | 65 | $this->lock->release(); |
66 | 66 | $this->lock = null; |
67 | 67 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | private $application; |
49 | 49 | private $name; |
50 | 50 | private $processTitle; |
51 | - private $aliases = []; |
|
51 | + private $aliases = [ ]; |
|
52 | 52 | private $definition; |
53 | 53 | private $hidden = false; |
54 | 54 | private $help = ''; |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | private $fullDefinition; |
57 | 57 | private $ignoreValidationErrors = false; |
58 | 58 | private $code; |
59 | - private $synopsis = []; |
|
60 | - private $usages = []; |
|
59 | + private $synopsis = [ ]; |
|
60 | + private $usages = [ ]; |
|
61 | 61 | private $helperSet; |
62 | 62 | |
63 | 63 | /** |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | { |
68 | 68 | $class = static::class; |
69 | 69 | |
70 | - if (\PHP_VERSION_ID >= 80000 && $attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) { |
|
71 | - return $attribute[0]->newInstance()->name; |
|
70 | + if ( \PHP_VERSION_ID >= 80000 && $attribute = ( new \ReflectionClass( $class ) )->getAttributes( AsCommand::class ) ) { |
|
71 | + return $attribute[ 0 ]->newInstance()->name; |
|
72 | 72 | } |
73 | 73 | |
74 | - $r = new \ReflectionProperty($class, 'defaultName'); |
|
74 | + $r = new \ReflectionProperty( $class, 'defaultName' ); |
|
75 | 75 | |
76 | 76 | return $class === $r->class ? static::$defaultName : null; |
77 | 77 | } |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | { |
84 | 84 | $class = static::class; |
85 | 85 | |
86 | - if (\PHP_VERSION_ID >= 80000 && $attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) { |
|
87 | - return $attribute[0]->newInstance()->description; |
|
86 | + if ( \PHP_VERSION_ID >= 80000 && $attribute = ( new \ReflectionClass( $class ) )->getAttributes( AsCommand::class ) ) { |
|
87 | + return $attribute[ 0 ]->newInstance()->description; |
|
88 | 88 | } |
89 | 89 | |
90 | - $r = new \ReflectionProperty($class, 'defaultDescription'); |
|
90 | + $r = new \ReflectionProperty( $class, 'defaultDescription' ); |
|
91 | 91 | |
92 | 92 | return $class === $r->class ? static::$defaultDescription : null; |
93 | 93 | } |
@@ -97,27 +97,27 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @throws LogicException When the command name is empty |
99 | 99 | */ |
100 | - public function __construct(string $name = null) |
|
100 | + public function __construct( string $name = null ) |
|
101 | 101 | { |
102 | 102 | $this->definition = new InputDefinition(); |
103 | 103 | |
104 | - if (null === $name && null !== $name = static::getDefaultName()) { |
|
105 | - $aliases = explode('|', $name); |
|
104 | + if ( null === $name && null !== $name = static::getDefaultName() ) { |
|
105 | + $aliases = explode( '|', $name ); |
|
106 | 106 | |
107 | - if ('' === $name = array_shift($aliases)) { |
|
108 | - $this->setHidden(true); |
|
109 | - $name = array_shift($aliases); |
|
107 | + if ( '' === $name = array_shift( $aliases ) ) { |
|
108 | + $this->setHidden( true ); |
|
109 | + $name = array_shift( $aliases ); |
|
110 | 110 | } |
111 | 111 | |
112 | - $this->setAliases($aliases); |
|
112 | + $this->setAliases( $aliases ); |
|
113 | 113 | } |
114 | 114 | |
115 | - if (null !== $name) { |
|
116 | - $this->setName($name); |
|
115 | + if ( null !== $name ) { |
|
116 | + $this->setName( $name ); |
|
117 | 117 | } |
118 | 118 | |
119 | - if ('' === $this->description) { |
|
120 | - $this->setDescription(static::getDefaultDescription() ?? ''); |
|
119 | + if ( '' === $this->description ) { |
|
120 | + $this->setDescription( static::getDefaultDescription() ?? '' ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | $this->configure(); |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | $this->ignoreValidationErrors = true; |
134 | 134 | } |
135 | 135 | |
136 | - public function setApplication(Application $application = null) |
|
136 | + public function setApplication( Application $application = null ) |
|
137 | 137 | { |
138 | 138 | $this->application = $application; |
139 | - if ($application) { |
|
140 | - $this->setHelperSet($application->getHelperSet()); |
|
139 | + if ( $application ) { |
|
140 | + $this->setHelperSet( $application->getHelperSet() ); |
|
141 | 141 | } else { |
142 | 142 | $this->helperSet = null; |
143 | 143 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $this->fullDefinition = null; |
146 | 146 | } |
147 | 147 | |
148 | - public function setHelperSet(HelperSet $helperSet) |
|
148 | + public function setHelperSet( HelperSet $helperSet ) |
|
149 | 149 | { |
150 | 150 | $this->helperSet = $helperSet; |
151 | 151 | } |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @see setCode() |
206 | 206 | */ |
207 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
207 | + protected function execute( InputInterface $input, OutputInterface $output ) |
|
208 | 208 | { |
209 | - throw new LogicException('You must override the execute() method in the concrete command class.'); |
|
209 | + throw new LogicException( 'You must override the execute() method in the concrete command class.' ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * This means that this is the only place where the command can |
217 | 217 | * interactively ask for values of missing required arguments. |
218 | 218 | */ |
219 | - protected function interact(InputInterface $input, OutputInterface $output) |
|
219 | + protected function interact( InputInterface $input, OutputInterface $output ) |
|
220 | 220 | { |
221 | 221 | } |
222 | 222 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @see InputInterface::bind() |
231 | 231 | * @see InputInterface::validate() |
232 | 232 | */ |
233 | - protected function initialize(InputInterface $input, OutputInterface $output) |
|
233 | + protected function initialize( InputInterface $input, OutputInterface $output ) |
|
234 | 234 | { |
235 | 235 | } |
236 | 236 | |
@@ -248,62 +248,62 @@ discard block |
||
248 | 248 | * @see setCode() |
249 | 249 | * @see execute() |
250 | 250 | */ |
251 | - public function run(InputInterface $input, OutputInterface $output) |
|
251 | + public function run( InputInterface $input, OutputInterface $output ) |
|
252 | 252 | { |
253 | 253 | // add the application arguments and options |
254 | 254 | $this->mergeApplicationDefinition(); |
255 | 255 | |
256 | 256 | // bind the input against the command specific arguments/options |
257 | 257 | try { |
258 | - $input->bind($this->getDefinition()); |
|
259 | - } catch (ExceptionInterface $e) { |
|
260 | - if (!$this->ignoreValidationErrors) { |
|
258 | + $input->bind( $this->getDefinition() ); |
|
259 | + } catch ( ExceptionInterface $e ) { |
|
260 | + if ( ! $this->ignoreValidationErrors ) { |
|
261 | 261 | throw $e; |
262 | 262 | } |
263 | 263 | } |
264 | 264 | |
265 | - $this->initialize($input, $output); |
|
265 | + $this->initialize( $input, $output ); |
|
266 | 266 | |
267 | - if (null !== $this->processTitle) { |
|
268 | - if (\function_exists('cli_set_process_title')) { |
|
269 | - if (!@cli_set_process_title($this->processTitle)) { |
|
270 | - if ('Darwin' === \PHP_OS) { |
|
271 | - $output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
267 | + if ( null !== $this->processTitle ) { |
|
268 | + if ( \function_exists( 'cli_set_process_title' ) ) { |
|
269 | + if ( ! @cli_set_process_title( $this->processTitle ) ) { |
|
270 | + if ( 'Darwin' === \PHP_OS ) { |
|
271 | + $output->writeln( '<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE ); |
|
272 | 272 | } else { |
273 | - cli_set_process_title($this->processTitle); |
|
273 | + cli_set_process_title( $this->processTitle ); |
|
274 | 274 | } |
275 | 275 | } |
276 | - } elseif (\function_exists('setproctitle')) { |
|
277 | - setproctitle($this->processTitle); |
|
278 | - } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) { |
|
279 | - $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>'); |
|
276 | + } elseif ( \function_exists( 'setproctitle' ) ) { |
|
277 | + setproctitle( $this->processTitle ); |
|
278 | + } elseif ( OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity() ) { |
|
279 | + $output->writeln( '<comment>Install the proctitle PECL to be able to change the process title.</comment>' ); |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | - if ($input->isInteractive()) { |
|
284 | - $this->interact($input, $output); |
|
283 | + if ( $input->isInteractive() ) { |
|
284 | + $this->interact( $input, $output ); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // The command name argument is often omitted when a command is executed directly with its run() method. |
288 | 288 | // It would fail the validation if we didn't make sure the command argument is present, |
289 | 289 | // since it's required by the application. |
290 | - if ($input->hasArgument('command') && null === $input->getArgument('command')) { |
|
291 | - $input->setArgument('command', $this->getName()); |
|
290 | + if ( $input->hasArgument( 'command' ) && null === $input->getArgument( 'command' ) ) { |
|
291 | + $input->setArgument( 'command', $this->getName() ); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | $input->validate(); |
295 | 295 | |
296 | - if ($this->code) { |
|
297 | - $statusCode = ($this->code)($input, $output); |
|
296 | + if ( $this->code ) { |
|
297 | + $statusCode = ( $this->code )( $input, $output ); |
|
298 | 298 | } else { |
299 | - $statusCode = $this->execute($input, $output); |
|
299 | + $statusCode = $this->execute( $input, $output ); |
|
300 | 300 | |
301 | - if (!\is_int($statusCode)) { |
|
302 | - throw new \TypeError(sprintf('Return value of "%s::execute()" must be of the type int, "%s" returned.', static::class, get_debug_type($statusCode))); |
|
301 | + if ( ! \is_int( $statusCode ) ) { |
|
302 | + throw new \TypeError( sprintf( 'Return value of "%s::execute()" must be of the type int, "%s" returned.', static::class, get_debug_type( $statusCode ) ) ); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
306 | - return is_numeric($statusCode) ? (int) $statusCode : 0; |
|
306 | + return is_numeric( $statusCode ) ? (int)$statusCode : 0; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -320,14 +320,14 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @see execute() |
322 | 322 | */ |
323 | - public function setCode(callable $code) |
|
323 | + public function setCode( callable $code ) |
|
324 | 324 | { |
325 | - if ($code instanceof \Closure) { |
|
326 | - $r = new \ReflectionFunction($code); |
|
327 | - if (null === $r->getClosureThis()) { |
|
328 | - set_error_handler(static function () {}); |
|
325 | + if ( $code instanceof \Closure ) { |
|
326 | + $r = new \ReflectionFunction( $code ); |
|
327 | + if ( null === $r->getClosureThis() ) { |
|
328 | + set_error_handler( static function() {}); |
|
329 | 329 | try { |
330 | - if ($c = \Closure::bind($code, $this)) { |
|
330 | + if ( $c = \Closure::bind( $code, $this ) ) { |
|
331 | 331 | $code = $c; |
332 | 332 | } |
333 | 333 | } finally { |
@@ -350,21 +350,21 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @internal |
352 | 352 | */ |
353 | - public function mergeApplicationDefinition(bool $mergeArgs = true) |
|
353 | + public function mergeApplicationDefinition( bool $mergeArgs = true ) |
|
354 | 354 | { |
355 | - if (null === $this->application) { |
|
355 | + if ( null === $this->application ) { |
|
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | 359 | $this->fullDefinition = new InputDefinition(); |
360 | - $this->fullDefinition->setOptions($this->definition->getOptions()); |
|
361 | - $this->fullDefinition->addOptions($this->application->getDefinition()->getOptions()); |
|
360 | + $this->fullDefinition->setOptions( $this->definition->getOptions() ); |
|
361 | + $this->fullDefinition->addOptions( $this->application->getDefinition()->getOptions() ); |
|
362 | 362 | |
363 | - if ($mergeArgs) { |
|
364 | - $this->fullDefinition->setArguments($this->application->getDefinition()->getArguments()); |
|
365 | - $this->fullDefinition->addArguments($this->definition->getArguments()); |
|
363 | + if ( $mergeArgs ) { |
|
364 | + $this->fullDefinition->setArguments( $this->application->getDefinition()->getArguments() ); |
|
365 | + $this->fullDefinition->addArguments( $this->definition->getArguments() ); |
|
366 | 366 | } else { |
367 | - $this->fullDefinition->setArguments($this->definition->getArguments()); |
|
367 | + $this->fullDefinition->setArguments( $this->definition->getArguments() ); |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | * |
376 | 376 | * @return $this |
377 | 377 | */ |
378 | - public function setDefinition($definition) |
|
378 | + public function setDefinition( $definition ) |
|
379 | 379 | { |
380 | - if ($definition instanceof InputDefinition) { |
|
380 | + if ( $definition instanceof InputDefinition ) { |
|
381 | 381 | $this->definition = $definition; |
382 | 382 | } else { |
383 | - $this->definition->setDefinition($definition); |
|
383 | + $this->definition->setDefinition( $definition ); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | $this->fullDefinition = null; |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | */ |
411 | 411 | public function getNativeDefinition() |
412 | 412 | { |
413 | - if (null === $this->definition) { |
|
414 | - throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', static::class)); |
|
413 | + if ( null === $this->definition ) { |
|
414 | + throw new LogicException( sprintf( 'Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', static::class ) ); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | return $this->definition; |
@@ -427,11 +427,11 @@ discard block |
||
427 | 427 | * |
428 | 428 | * @return $this |
429 | 429 | */ |
430 | - public function addArgument(string $name, int $mode = null, string $description = '', $default = null) |
|
430 | + public function addArgument( string $name, int $mode = null, string $description = '', $default = null ) |
|
431 | 431 | { |
432 | - $this->definition->addArgument(new InputArgument($name, $mode, $description, $default)); |
|
433 | - if (null !== $this->fullDefinition) { |
|
434 | - $this->fullDefinition->addArgument(new InputArgument($name, $mode, $description, $default)); |
|
432 | + $this->definition->addArgument( new InputArgument( $name, $mode, $description, $default ) ); |
|
433 | + if ( null !== $this->fullDefinition ) { |
|
434 | + $this->fullDefinition->addArgument( new InputArgument( $name, $mode, $description, $default ) ); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | return $this; |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return $this |
450 | 450 | */ |
451 | - public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null) |
|
451 | + public function addOption( string $name, $shortcut = null, int $mode = null, string $description = '', $default = null ) |
|
452 | 452 | { |
453 | - $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default)); |
|
454 | - if (null !== $this->fullDefinition) { |
|
455 | - $this->fullDefinition->addOption(new InputOption($name, $shortcut, $mode, $description, $default)); |
|
453 | + $this->definition->addOption( new InputOption( $name, $shortcut, $mode, $description, $default ) ); |
|
454 | + if ( null !== $this->fullDefinition ) { |
|
455 | + $this->fullDefinition->addOption( new InputOption( $name, $shortcut, $mode, $description, $default ) ); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | return $this; |
@@ -470,9 +470,9 @@ discard block |
||
470 | 470 | * |
471 | 471 | * @throws InvalidArgumentException When the name is invalid |
472 | 472 | */ |
473 | - public function setName(string $name) |
|
473 | + public function setName( string $name ) |
|
474 | 474 | { |
475 | - $this->validateName($name); |
|
475 | + $this->validateName( $name ); |
|
476 | 476 | |
477 | 477 | $this->name = $name; |
478 | 478 | |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | * |
488 | 488 | * @return $this |
489 | 489 | */ |
490 | - public function setProcessTitle(string $title) |
|
490 | + public function setProcessTitle( string $title ) |
|
491 | 491 | { |
492 | 492 | $this->processTitle = $title; |
493 | 493 | |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | * |
513 | 513 | * @final since Symfony 5.1 |
514 | 514 | */ |
515 | - public function setHidden(bool $hidden /*= true*/) |
|
515 | + public function setHidden( bool $hidden /*= true*/ ) |
|
516 | 516 | { |
517 | 517 | $this->hidden = $hidden; |
518 | 518 | |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return $this |
534 | 534 | */ |
535 | - public function setDescription(string $description) |
|
535 | + public function setDescription( string $description ) |
|
536 | 536 | { |
537 | 537 | $this->description = $description; |
538 | 538 | |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | * |
555 | 555 | * @return $this |
556 | 556 | */ |
557 | - public function setHelp(string $help) |
|
557 | + public function setHelp( string $help ) |
|
558 | 558 | { |
559 | 559 | $this->help = $help; |
560 | 560 | |
@@ -588,10 +588,10 @@ discard block |
||
588 | 588 | ]; |
589 | 589 | $replacements = [ |
590 | 590 | $name, |
591 | - $isSingleCommand ? $_SERVER['PHP_SELF'] : $_SERVER['PHP_SELF'].' '.$name, |
|
591 | + $isSingleCommand ? $_SERVER[ 'PHP_SELF' ] : $_SERVER[ 'PHP_SELF' ] . ' ' . $name, |
|
592 | 592 | ]; |
593 | 593 | |
594 | - return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription()); |
|
594 | + return str_replace( $placeholders, $replacements, $this->getHelp() ?: $this->getDescription() ); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -603,16 +603,16 @@ discard block |
||
603 | 603 | * |
604 | 604 | * @throws InvalidArgumentException When an alias is invalid |
605 | 605 | */ |
606 | - public function setAliases(iterable $aliases) |
|
606 | + public function setAliases( iterable $aliases ) |
|
607 | 607 | { |
608 | - $list = []; |
|
608 | + $list = [ ]; |
|
609 | 609 | |
610 | - foreach ($aliases as $alias) { |
|
611 | - $this->validateName($alias); |
|
612 | - $list[] = $alias; |
|
610 | + foreach ( $aliases as $alias ) { |
|
611 | + $this->validateName( $alias ); |
|
612 | + $list[ ] = $alias; |
|
613 | 613 | } |
614 | 614 | |
615 | - $this->aliases = \is_array($aliases) ? $aliases : $list; |
|
615 | + $this->aliases = \is_array( $aliases ) ? $aliases : $list; |
|
616 | 616 | |
617 | 617 | return $this; |
618 | 618 | } |
@@ -634,15 +634,15 @@ discard block |
||
634 | 634 | * |
635 | 635 | * @return string The synopsis |
636 | 636 | */ |
637 | - public function getSynopsis(bool $short = false) |
|
637 | + public function getSynopsis( bool $short = false ) |
|
638 | 638 | { |
639 | 639 | $key = $short ? 'short' : 'long'; |
640 | 640 | |
641 | - if (!isset($this->synopsis[$key])) { |
|
642 | - $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short))); |
|
641 | + if ( ! isset( $this->synopsis[ $key ] ) ) { |
|
642 | + $this->synopsis[ $key ] = trim( sprintf( '%s %s', $this->name, $this->definition->getSynopsis( $short ) ) ); |
|
643 | 643 | } |
644 | 644 | |
645 | - return $this->synopsis[$key]; |
|
645 | + return $this->synopsis[ $key ]; |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | /** |
@@ -650,13 +650,13 @@ discard block |
||
650 | 650 | * |
651 | 651 | * @return $this |
652 | 652 | */ |
653 | - public function addUsage(string $usage) |
|
653 | + public function addUsage( string $usage ) |
|
654 | 654 | { |
655 | - if (!str_starts_with($usage, $this->name)) { |
|
656 | - $usage = sprintf('%s %s', $this->name, $usage); |
|
655 | + if ( ! str_starts_with( $usage, $this->name ) ) { |
|
656 | + $usage = sprintf( '%s %s', $this->name, $usage ); |
|
657 | 657 | } |
658 | 658 | |
659 | - $this->usages[] = $usage; |
|
659 | + $this->usages[ ] = $usage; |
|
660 | 660 | |
661 | 661 | return $this; |
662 | 662 | } |
@@ -679,13 +679,13 @@ discard block |
||
679 | 679 | * @throws LogicException if no HelperSet is defined |
680 | 680 | * @throws InvalidArgumentException if the helper is not defined |
681 | 681 | */ |
682 | - public function getHelper(string $name) |
|
682 | + public function getHelper( string $name ) |
|
683 | 683 | { |
684 | - if (null === $this->helperSet) { |
|
685 | - throw new LogicException(sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name)); |
|
684 | + if ( null === $this->helperSet ) { |
|
685 | + throw new LogicException( sprintf( 'Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name ) ); |
|
686 | 686 | } |
687 | 687 | |
688 | - return $this->helperSet->get($name); |
|
688 | + return $this->helperSet->get( $name ); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -695,10 +695,10 @@ discard block |
||
695 | 695 | * |
696 | 696 | * @throws InvalidArgumentException When the name is invalid |
697 | 697 | */ |
698 | - private function validateName(string $name) |
|
698 | + private function validateName( string $name ) |
|
699 | 699 | { |
700 | - if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) { |
|
701 | - throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name)); |
|
700 | + if ( ! preg_match( '/^[^\:]++(\:[^\:]++)*$/', $name ) ) { |
|
701 | + throw new InvalidArgumentException( sprintf( 'Command name "%s" is invalid.', $name ) ); |
|
702 | 702 | } |
703 | 703 | } |
704 | 704 | } |
@@ -34,11 +34,11 @@ |
||
34 | 34 | /** |
35 | 35 | * {@inheritdoc} |
36 | 36 | */ |
37 | - protected function doWrite(string $message, bool $newline) |
|
37 | + protected function doWrite( string $message, bool $newline ) |
|
38 | 38 | { |
39 | 39 | $this->buffer .= $message; |
40 | 40 | |
41 | - if ($newline) { |
|
41 | + if ( $newline ) { |
|
42 | 42 | $this->buffer .= \PHP_EOL; |
43 | 43 | } |
44 | 44 | } |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | * @param bool $decorated Whether to decorate messages |
38 | 38 | * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) |
39 | 39 | */ |
40 | - public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null) |
|
40 | + public function __construct( ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null ) |
|
41 | 41 | { |
42 | 42 | $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity; |
43 | 43 | $this->formatter = $formatter ?? new OutputFormatter(); |
44 | - $this->formatter->setDecorated($decorated); |
|
44 | + $this->formatter->setDecorated( $decorated ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * {@inheritdoc} |
49 | 49 | */ |
50 | - public function setFormatter(OutputFormatterInterface $formatter) |
|
50 | + public function setFormatter( OutputFormatterInterface $formatter ) |
|
51 | 51 | { |
52 | 52 | $this->formatter = $formatter; |
53 | 53 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * {@inheritdoc} |
65 | 65 | */ |
66 | - public function setDecorated(bool $decorated) |
|
66 | + public function setDecorated( bool $decorated ) |
|
67 | 67 | { |
68 | - $this->formatter->setDecorated($decorated); |
|
68 | + $this->formatter->setDecorated( $decorated ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * {@inheritdoc} |
81 | 81 | */ |
82 | - public function setVerbosity(int $level) |
|
82 | + public function setVerbosity( int $level ) |
|
83 | 83 | { |
84 | 84 | $this->verbosity = $level; |
85 | 85 | } |
@@ -127,18 +127,18 @@ discard block |
||
127 | 127 | /** |
128 | 128 | * {@inheritdoc} |
129 | 129 | */ |
130 | - public function writeln($messages, int $options = self::OUTPUT_NORMAL) |
|
130 | + public function writeln( $messages, int $options = self::OUTPUT_NORMAL ) |
|
131 | 131 | { |
132 | - $this->write($messages, true, $options); |
|
132 | + $this->write( $messages, true, $options ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | 136 | * {@inheritdoc} |
137 | 137 | */ |
138 | - public function write($messages, bool $newline = false, int $options = self::OUTPUT_NORMAL) |
|
138 | + public function write( $messages, bool $newline = false, int $options = self::OUTPUT_NORMAL ) |
|
139 | 139 | { |
140 | - if (!is_iterable($messages)) { |
|
141 | - $messages = [$messages]; |
|
140 | + if ( ! is_iterable( $messages ) ) { |
|
141 | + $messages = [ $messages ]; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN; |
@@ -147,28 +147,28 @@ discard block |
||
147 | 147 | $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG; |
148 | 148 | $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL; |
149 | 149 | |
150 | - if ($verbosity > $this->getVerbosity()) { |
|
150 | + if ( $verbosity > $this->getVerbosity() ) { |
|
151 | 151 | return; |
152 | 152 | } |
153 | 153 | |
154 | - foreach ($messages as $message) { |
|
155 | - switch ($type) { |
|
154 | + foreach ( $messages as $message ) { |
|
155 | + switch ( $type ) { |
|
156 | 156 | case OutputInterface::OUTPUT_NORMAL: |
157 | - $message = $this->formatter->format($message); |
|
157 | + $message = $this->formatter->format( $message ); |
|
158 | 158 | break; |
159 | 159 | case OutputInterface::OUTPUT_RAW: |
160 | 160 | break; |
161 | 161 | case OutputInterface::OUTPUT_PLAIN: |
162 | - $message = strip_tags($this->formatter->format($message)); |
|
162 | + $message = strip_tags( $this->formatter->format( $message ) ); |
|
163 | 163 | break; |
164 | 164 | } |
165 | 165 | |
166 | - $this->doWrite($message ?? '', $newline); |
|
166 | + $this->doWrite( $message ?? '', $newline ); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
171 | 171 | * Writes a message to the output. |
172 | 172 | */ |
173 | - abstract protected function doWrite(string $message, bool $newline); |
|
173 | + abstract protected function doWrite( string $message, bool $newline ); |
|
174 | 174 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | */ |
27 | 27 | public function getErrorOutput(); |
28 | 28 | |
29 | - public function setErrorOutput(OutputInterface $error); |
|
29 | + public function setErrorOutput( OutputInterface $error ); |
|
30 | 30 | |
31 | 31 | public function section(): ConsoleSectionOutput; |
32 | 32 | } |
@@ -30,29 +30,29 @@ discard block |
||
30 | 30 | class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface |
31 | 31 | { |
32 | 32 | private $stderr; |
33 | - private $consoleSectionOutputs = []; |
|
33 | + private $consoleSectionOutputs = [ ]; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) |
37 | 37 | * @param bool|null $decorated Whether to decorate messages (null for auto-guessing) |
38 | 38 | * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) |
39 | 39 | */ |
40 | - public function __construct(int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null) |
|
40 | + public function __construct( int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null ) |
|
41 | 41 | { |
42 | - parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter); |
|
42 | + parent::__construct( $this->openOutputStream(), $verbosity, $decorated, $formatter ); |
|
43 | 43 | |
44 | - if (null === $formatter) { |
|
44 | + if ( null === $formatter ) { |
|
45 | 45 | // for BC reasons, stdErr has it own Formatter only when user don't inject a specific formatter. |
46 | - $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated); |
|
46 | + $this->stderr = new StreamOutput( $this->openErrorStream(), $verbosity, $decorated ); |
|
47 | 47 | |
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | 51 | $actualDecorated = $this->isDecorated(); |
52 | - $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter()); |
|
52 | + $this->stderr = new StreamOutput( $this->openErrorStream(), $verbosity, $decorated, $this->getFormatter() ); |
|
53 | 53 | |
54 | - if (null === $decorated) { |
|
55 | - $this->setDecorated($actualDecorated && $this->stderr->isDecorated()); |
|
54 | + if ( null === $decorated ) { |
|
55 | + $this->setDecorated( $actualDecorated && $this->stderr->isDecorated() ); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -61,34 +61,34 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function section(): ConsoleSectionOutput |
63 | 63 | { |
64 | - return new ConsoleSectionOutput($this->getStream(), $this->consoleSectionOutputs, $this->getVerbosity(), $this->isDecorated(), $this->getFormatter()); |
|
64 | + return new ConsoleSectionOutput( $this->getStream(), $this->consoleSectionOutputs, $this->getVerbosity(), $this->isDecorated(), $this->getFormatter() ); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | 68 | * {@inheritdoc} |
69 | 69 | */ |
70 | - public function setDecorated(bool $decorated) |
|
70 | + public function setDecorated( bool $decorated ) |
|
71 | 71 | { |
72 | - parent::setDecorated($decorated); |
|
73 | - $this->stderr->setDecorated($decorated); |
|
72 | + parent::setDecorated( $decorated ); |
|
73 | + $this->stderr->setDecorated( $decorated ); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | 77 | * {@inheritdoc} |
78 | 78 | */ |
79 | - public function setFormatter(OutputFormatterInterface $formatter) |
|
79 | + public function setFormatter( OutputFormatterInterface $formatter ) |
|
80 | 80 | { |
81 | - parent::setFormatter($formatter); |
|
82 | - $this->stderr->setFormatter($formatter); |
|
81 | + parent::setFormatter( $formatter ); |
|
82 | + $this->stderr->setFormatter( $formatter ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | 86 | * {@inheritdoc} |
87 | 87 | */ |
88 | - public function setVerbosity(int $level) |
|
88 | + public function setVerbosity( int $level ) |
|
89 | 89 | { |
90 | - parent::setVerbosity($level); |
|
91 | - $this->stderr->setVerbosity($level); |
|
90 | + parent::setVerbosity( $level ); |
|
91 | + $this->stderr->setVerbosity( $level ); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | /** |
103 | 103 | * {@inheritdoc} |
104 | 104 | */ |
105 | - public function setErrorOutput(OutputInterface $error) |
|
105 | + public function setErrorOutput( OutputInterface $error ) |
|
106 | 106 | { |
107 | 107 | $this->stderr = $error; |
108 | 108 | } |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | private function isRunningOS400(): bool |
137 | 137 | { |
138 | 138 | $checks = [ |
139 | - \function_exists('php_uname') ? php_uname('s') : '', |
|
140 | - getenv('OSTYPE'), |
|
139 | + \function_exists( 'php_uname' ) ? php_uname( 's' ) : '', |
|
140 | + getenv( 'OSTYPE' ), |
|
141 | 141 | \PHP_OS, |
142 | 142 | ]; |
143 | 143 | |
144 | - return false !== stripos(implode(';', $checks), 'OS400'); |
|
144 | + return false !== stripos( implode( ';', $checks ), 'OS400' ); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | */ |
150 | 150 | private function openOutputStream() |
151 | 151 | { |
152 | - if (!$this->hasStdoutSupport()) { |
|
153 | - return fopen('php://output', 'w'); |
|
152 | + if ( ! $this->hasStdoutSupport() ) { |
|
153 | + return fopen( 'php://output', 'w' ); |
|
154 | 154 | } |
155 | 155 | |
156 | - return @fopen('php://stdout', 'w') ?: fopen('php://output', 'w'); |
|
156 | + return @fopen( 'php://stdout', 'w' ) ?: fopen( 'php://output', 'w' ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -161,6 +161,6 @@ discard block |
||
161 | 161 | */ |
162 | 162 | private function openErrorStream() |
163 | 163 | { |
164 | - return fopen($this->hasStderrSupport() ? 'php://stderr' : 'php://output', 'w'); |
|
164 | + return fopen( $this->hasStderrSupport() ? 'php://stderr' : 'php://output', 'w' ); |
|
165 | 165 | } |
166 | 166 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param bool $newline Whether to add a newline |
38 | 38 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
39 | 39 | */ |
40 | - public function write($messages, bool $newline = false, int $options = 0); |
|
40 | + public function write( $messages, bool $newline = false, int $options = 0 ); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Writes a message to the output and adds a newline at the end. |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | * @param string|iterable $messages The message as an iterable of strings or a single string |
46 | 46 | * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL |
47 | 47 | */ |
48 | - public function writeln($messages, int $options = 0); |
|
48 | + public function writeln( $messages, int $options = 0 ); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Sets the verbosity of the output. |
52 | 52 | */ |
53 | - public function setVerbosity(int $level); |
|
53 | + public function setVerbosity( int $level ); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Gets the current verbosity of the output. |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | /** |
91 | 91 | * Sets the decorated flag. |
92 | 92 | */ |
93 | - public function setDecorated(bool $decorated); |
|
93 | + public function setDecorated( bool $decorated ); |
|
94 | 94 | |
95 | 95 | /** |
96 | 96 | * Gets the decorated flag. |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function isDecorated(); |
101 | 101 | |
102 | - public function setFormatter(OutputFormatterInterface $formatter); |
|
102 | + public function setFormatter( OutputFormatterInterface $formatter ); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Returns current output formatter instance. |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @throws InvalidArgumentException When first argument is not a real stream |
41 | 41 | */ |
42 | - public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null) |
|
42 | + public function __construct( $stream, int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null ) |
|
43 | 43 | { |
44 | - if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) { |
|
45 | - throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.'); |
|
44 | + if ( ! \is_resource( $stream ) || 'stream' !== get_resource_type( $stream ) ) { |
|
45 | + throw new InvalidArgumentException( 'The StreamOutput class needs a stream as its first argument.' ); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | $this->stream = $stream; |
49 | 49 | |
50 | - if (null === $decorated) { |
|
50 | + if ( null === $decorated ) { |
|
51 | 51 | $decorated = $this->hasColorSupport(); |
52 | 52 | } |
53 | 53 | |
54 | - parent::__construct($verbosity, $decorated, $formatter); |
|
54 | + parent::__construct( $verbosity, $decorated, $formatter ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | /** |
68 | 68 | * {@inheritdoc} |
69 | 69 | */ |
70 | - protected function doWrite(string $message, bool $newline) |
|
70 | + protected function doWrite( string $message, bool $newline ) |
|
71 | 71 | { |
72 | - if ($newline) { |
|
72 | + if ( $newline ) { |
|
73 | 73 | $message .= \PHP_EOL; |
74 | 74 | } |
75 | 75 | |
76 | - @fwrite($this->stream, $message); |
|
76 | + @fwrite( $this->stream, $message ); |
|
77 | 77 | |
78 | - fflush($this->stream); |
|
78 | + fflush( $this->stream ); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -94,22 +94,22 @@ discard block |
||
94 | 94 | protected function hasColorSupport() |
95 | 95 | { |
96 | 96 | // Follow https://no-color.org/ |
97 | - if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) { |
|
97 | + if ( isset( $_SERVER[ 'NO_COLOR' ] ) || false !== getenv( 'NO_COLOR' ) ) { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | |
101 | - if ('Hyper' === getenv('TERM_PROGRAM')) { |
|
101 | + if ( 'Hyper' === getenv( 'TERM_PROGRAM' ) ) { |
|
102 | 102 | return true; |
103 | 103 | } |
104 | 104 | |
105 | - if (\DIRECTORY_SEPARATOR === '\\') { |
|
106 | - return (\function_exists('sapi_windows_vt100_support') |
|
107 | - && @sapi_windows_vt100_support($this->stream)) |
|
108 | - || false !== getenv('ANSICON') |
|
109 | - || 'ON' === getenv('ConEmuANSI') |
|
110 | - || 'xterm' === getenv('TERM'); |
|
105 | + if ( \DIRECTORY_SEPARATOR === '\\' ) { |
|
106 | + return ( \function_exists( 'sapi_windows_vt100_support' ) |
|
107 | + && @sapi_windows_vt100_support( $this->stream ) ) |
|
108 | + || false !== getenv( 'ANSICON' ) |
|
109 | + || 'ON' === getenv( 'ConEmuANSI' ) |
|
110 | + || 'xterm' === getenv( 'TERM' ); |
|
111 | 111 | } |
112 | 112 | |
113 | - return stream_isatty($this->stream); |
|
113 | + return stream_isatty( $this->stream ); |
|
114 | 114 | } |
115 | 115 | } |