@@ -33,13 +33,13 @@ abstract class AbstractCommand extends Command
3333 * Additional Phing args to add in specialized commands.
3434 * @var array
3535 */
36- protected $additionalPhingArgs = array() ;
36+ protected $additionalPhingArgs = [] ;
3737
3838 /**
3939 * Temporary XML schemas used on command execution.
4040 * @var array
4141 */
42- protected $tempSchemas = array() ;
42+ protected $tempSchemas = [] ;
4343
4444 /**
4545 * @var string
@@ -74,12 +74,8 @@ abstract class AbstractCommand extends Command
7474 */
7575 protected $output;
7676
77- private ContainerInterface $container;
78-
79- public function __construct(ContainerInterface $container, $name = null)
77+ public function __construct(private ContainerInterface $container, $name = null)
8078 {
81- $this->container = $container;
82-
8379 parent::__construct($name);
8480 }
8581
@@ -153,7 +149,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
153149
154150 if ($input->hasArgument('bundle') && $input->getArgument('bundle')) {
155151 $bundleName = $input->getArgument('bundle');
156- if (0 === strpos ($bundleName, '@')) {
152+ if (str_starts_with ($bundleName, '@')) {
157153 $bundleName = substr($bundleName, 1);
158154 }
159155
@@ -167,7 +163,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
167163 * @param string $taskName A Propel task name.
168164 * @param array $properties An array of properties to pass to Phing.
169165 */
170- protected function callPhing($taskName, $properties = array() )
166+ protected function callPhing($taskName, $properties = [] )
171167 {
172168 $kernel = $this->getApplication()->getKernel();
173169
@@ -197,7 +193,7 @@ protected function callPhing($taskName, $properties = array())
197193
198194 // Add any arbitrary arguments last
199195 foreach ($this->additionalPhingArgs as $arg) {
200- if (in_array($arg, array( 'verbose', 'debug') )) {
196+ if (in_array($arg, [ 'verbose', 'debug'] )) {
201197 $bufferPhingOutput = false;
202198 }
203199
@@ -229,7 +225,7 @@ protected function callPhing($taskName, $properties = array())
229225 strstr($this->buffer, 'failed for the following reason:')) {
230226 $returnStatus = false;
231227 }
232- } catch (\Exception $e ) {
228+ } catch (\Exception) {
233229 $returnStatus = false;
234230 }
235231
@@ -254,7 +250,7 @@ protected function copySchemas(KernelInterface $kernel, $cacheDir)
254250 /** @var array<string, array{?BundleInterface, \SplFileInfo}> $finalSchemas */
255251 $finalSchemas = $this->getFinalSchemas($kernel, $this->bundle);
256252 foreach ($finalSchemas as $schema) {
257- list( $bundle, $finalSchema) = $schema;
253+ [ $bundle, $finalSchema] = $schema;
258254
259255 if ($bundle) {
260256 $file = $cacheDir.DIRECTORY_SEPARATOR.'bundle-'.$bundle->getName().'-'.$finalSchema->getBaseName();
@@ -383,7 +379,7 @@ protected function createBuildTimeFile($file)
383379 <datasources default="%default_connection%">
384380
385381EOT
386- , array( '%default_connection%' => $container->getParameter('propel.dbal.default_connection')) );
382+ , [ '%default_connection%' => $container->getParameter('propel.dbal.default_connection')] );
387383
388384 $propelConfiguration = $container->get('propel.configuration');
389385 foreach ($propelConfiguration['datasources'] as $name => $datasource) {
@@ -403,14 +399,14 @@ protected function createBuildTimeFile($file)
403399 </datasource>
404400
405401EOT
406- , array(
402+ , [
407403 '%name%' => $name,
408404 '%adapter%' => $datasource['adapter'],
409405 '%classname%'=> $datasource['connection']['classname'],
410406 '%dsn%' => $datasource['connection']['dsn'],
411407 '%username%' => $datasource['connection']['user'],
412- '%password%' => isset( $datasource['connection']['password']) ? $datasource['connection']['password'] : '',
413- ) );
408+ '%password%' => $datasource['connection']['password'] ?? '',
409+ ] );
414410 }
415411
416412 $xml .= <<<EOT
@@ -430,7 +426,7 @@ protected function createBuildTimeFile($file)
430426 */
431427 protected function getProperties($file)
432428 {
433- $properties = array() ;
429+ $properties = [] ;
434430
435431 if (false === $lines = @file($file)) {
436432 throw new \Exception(sprintf('Unable to parse contents of "%s".', $file));
@@ -439,7 +435,7 @@ protected function getProperties($file)
439435 foreach ($lines as $line) {
440436 $line = trim($line);
441437
442- if ('' == $line || in_array($line[0], array( '#', ';') )) {
438+ if ('' == $line || in_array($line[0], [ '#', ';'] )) {
443439 continue;
444440 }
445441
@@ -538,7 +534,7 @@ protected function getConnection(InputInterface $input, OutputInterface $output)
538534 $defaultConfig['connection']['password'] = null;
539535 }
540536
541- return array( $name, $defaultConfig) ;
537+ return [ $name, $defaultConfig] ;
542538 }
543539
544540 /**
@@ -551,12 +547,8 @@ protected function parseDbName($dsn)
551547 {
552548 preg_match('#dbname=([a-zA-Z0-9\_]+)#', $dsn, $matches);
553549
554- if (isset($matches[1])) {
555- return $matches[1];
556- }
557-
558550 // e.g. SQLite
559- return null;
551+ return $matches[1] ?? null;
560552 }
561553
562554 /**
@@ -580,7 +572,7 @@ protected function checkConfiguration()
580572 protected function writeSummary(OutputInterface $output, $taskname)
581573 {
582574 foreach (explode("\n", $this->buffer) as $line) {
583- if (false !== strpos ($line, '[' . $taskname . ']')) {
575+ if (str_contains ($line, '[' . $taskname . ']')) {
584576 $arr = preg_split('#\[' . $taskname . '\] #', $line);
585577 $info = $arr[1];
586578
@@ -603,11 +595,11 @@ protected function writeSummary(OutputInterface $output, $taskname)
603595 */
604596 protected function writeSection(OutputInterface $output, $text, $style = 'bg=blue;fg=white')
605597 {
606- $output->writeln(array(
598+ $output->writeln([
607599 '',
608600 $this->getHelperSet()->get('formatter')->formatBlock($text, $style, true),
609601 '',
610- ) );
602+ ] );
611603 }
612604
613605 /**
@@ -621,11 +613,11 @@ protected function writeTaskError($output, $taskName, $more = true)
621613 {
622614 $moreText = $more ? ' To get more details, run the command with the "--verbose" option.' : '';
623615
624- return $this->writeSection($output, array(
616+ return $this->writeSection($output, [
625617 '[Propel] Error',
626618 '',
627619 'An error has occured during the "' . $taskName . '" task process.' . $moreText
628- ) , 'fg=white;bg=red');
620+ ] , 'fg=white;bg=red');
629621 }
630622
631623 /**
@@ -680,10 +672,10 @@ protected function transformToLogicalName(\SplFileInfo $schema, BundleInterface
680672 */
681673 private function getPhingArguments(KernelInterface $kernel, $workingDirectory, $properties)
682674 {
683- $args = array() ;
675+ $args = [] ;
684676
685677 // Default properties
686- $properties = array_merge(array(
678+ $properties = array_merge([
687679 'propel.database' => 'mysql',
688680 'project.dir' => $workingDirectory,
689681 'propel.output.dir' => $kernel->getProjectDir().'/app/propel',
@@ -696,7 +688,7 @@ private function getPhingArguments(KernelInterface $kernel, $workingDirectory, $
696688 'propel.addClassLevelComment' => false,
697689 'propel.defaultTimeStampFormat' => '',
698690 'propel.builder.pluralizer.class' => 'builder.util.StandardEnglishPluralizer',
699- ) , $properties);
691+ ] , $properties);
700692
701693 // Adding user defined properties from the configuration
702694 $properties = array_merge(
0 commit comments