Passed
Push — master ( 60a1fa...68970e )
by Aimeos
03:23 queued 12s
created
Classes/Setup.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
     {
73 73
         try {
74 74
             ob_start();
75
-            $exectimeStart = microtime(true);
75
+            $exectimeStart = microtime( true );
76 76
 
77 77
             self::execute();
78 78
 
79
-            $this->output->writeln(ob_get_clean());
80
-            $this->output->writeln(sprintf('Setup process lasted %1$f sec', (microtime(true) - $exectimeStart)));
81
-        } catch(\Throwable $t) {
82
-            $this->output->writeln(ob_get_clean());
83
-            $this->output->writeln($t->getMessage());
84
-            $this->output->writeln($t->getTraceAsString());
79
+            $this->output->writeln( ob_get_clean() );
80
+            $this->output->writeln( sprintf( 'Setup process lasted %1$f sec', ( microtime( true ) - $exectimeStart ) ) );
81
+        } catch( \Throwable $t ) {
82
+            $this->output->writeln( ob_get_clean() );
83
+            $this->output->writeln( $t->getMessage() );
84
+            $this->output->writeln( $t->getTraceAsString() );
85 85
 
86 86
             return false;
87 87
         }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      *
107 107
      * @param OutputInterface $output
108 108
      */
109
-    public function setOutput(OutputInterface $output) : void
109
+    public function setOutput( OutputInterface $output ) : void
110 110
     {
111 111
         $this->output = $output;
112 112
     }
@@ -128,30 +128,30 @@  discard block
 block discarded – undo
128 128
      */
129 129
     public static function execute()
130 130
     {
131
-        ini_set('max_execution_time', 0);
131
+        ini_set( 'max_execution_time', 0 );
132 132
 
133
-        $objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
134
-        $extconf = $objectManager->get('TYPO3\CMS\Core\Configuration\ExtensionConfiguration');
135
-        $demo = $extconf->get('aimeos', 'useDemoData');
133
+        $objectManager = GeneralUtility::makeInstance( \TYPO3\CMS\Extbase\Object\ObjectManager::class );
134
+        $extconf = $objectManager->get( 'TYPO3\CMS\Core\Configuration\ExtensionConfiguration' );
135
+        $demo = $extconf->get( 'aimeos', 'useDemoData' );
136 136
 
137
-        \Aimeos\MShop::cache(false);
138
-        \Aimeos\MAdmin::cache(false);
137
+        \Aimeos\MShop::cache( false );
138
+        \Aimeos\MAdmin::cache( false );
139 139
 
140
-        $site = $extconf->get('siteCode', 'default');
141
-        $template = $extconf->get('siteTpl', 'default');
142
-        $codelen = $extconf->get('codeLength', 64);
140
+        $site = $extconf->get( 'siteCode', 'default' );
141
+        $template = $extconf->get( 'siteTpl', 'default' );
142
+        $codelen = $extconf->get( 'codeLength', 64 );
143 143
 
144 144
         $boostrap = \Aimeos\Aimeos\Base::aimeos();
145
-        $ctx = self::context(['setup' => ['default' => ['demo' => (string) $demo]]])->setEditor('setup');
145
+        $ctx = self::context( ['setup' => ['default' => ['demo' => (string) $demo]]] )->setEditor( 'setup' );
146 146
 
147
-        \Aimeos\Setup::use($boostrap, ['codelength' => $codelen])->verbose('vvv')
148
-            ->context($ctx->setEditor('aimeos:setup'))
149
-            ->up($site, $template);
147
+        \Aimeos\Setup::use( $boostrap, ['codelength' => $codelen] )->verbose( 'vvv' )
148
+            ->context( $ctx->setEditor( 'aimeos:setup' ) )
149
+            ->up( $site, $template );
150 150
 
151
-        if (defined('TYPO3_version') && version_compare(constant('TYPO3_version'), '11.0.0', '<')) {
152
-            $extconf->set('aimeos', 'useDemoData', '');
151
+        if( defined( 'TYPO3_version' ) && version_compare( constant( 'TYPO3_version' ), '11.0.0', '<' ) ) {
152
+            $extconf->set( 'aimeos', 'useDemoData', '' );
153 153
         } else {
154
-            $extconf->set('aimeos', ['useDemoData' => '']);
154
+            $extconf->set( 'aimeos', ['useDemoData' => ''] );
155 155
         }
156 156
     }
157 157
 
@@ -162,34 +162,34 @@  discard block
 block discarded – undo
162 162
      * @param array $sql List of SQL statements
163 163
      * @return array SQL statements required for the install tool
164 164
      */
165
-    public static function schema(array $sql) : array
165
+    public static function schema( array $sql ) : array
166 166
     {
167 167
         $ctx = self::getContext();
168
-        $connectionNames = array_keys($ctx->getConfig()->get( 'resource'));
169
-        $connectionNames = array_filter($connectionNames, fn (string $key): bool => str_starts_with($key, 'db'));
168
+        $connectionNames = array_keys( $ctx->getConfig()->get( 'resource' ) );
169
+        $connectionNames = array_filter( $connectionNames, fn ( string $key ): bool => str_starts_with( $key, 'db' ) );
170 170
 
171
-        foreach ($connectionNames as $connectionName) {
172
-            $conn = $ctx->db($connectionName);
171
+        foreach( $connectionNames as $connectionName ) {
172
+            $conn = $ctx->db( $connectionName );
173 173
 
174 174
             $tables = [];
175
-            foreach(['fe_users_', 'madmin_', 'mshop_'] as $prefix) {
176
-                $result = $conn->create('SHOW TABLES like \'' . $prefix . '%\'')->execute();
175
+            foreach( ['fe_users_', 'madmin_', 'mshop_'] as $prefix ) {
176
+                $result = $conn->create( 'SHOW TABLES like \'' . $prefix . '%\'' )->execute();
177 177
 
178
-                while(($row = $result->fetch(\Aimeos\Base\DB\Result\Base::FETCH_NUM)) !== null) {
178
+                while( ( $row = $result->fetch( \Aimeos\Base\DB\Result\Base::FETCH_NUM ) ) !== null ) {
179 179
                     $tables[] = $row[0];
180 180
                 }
181 181
             }
182 182
 
183
-            foreach($tables as $table) {
184
-                $result = $conn->create('SHOW CREATE TABLE `' . $table . '`')->execute();
183
+            foreach( $tables as $table ) {
184
+                $result = $conn->create( 'SHOW CREATE TABLE `' . $table . '`' )->execute();
185 185
 
186
-                while(($row = $result->fetch(\Aimeos\Base\DB\Result\Base::FETCH_NUM)) !== null) {
186
+                while( ( $row = $result->fetch( \Aimeos\Base\DB\Result\Base::FETCH_NUM ) ) !== null ) {
187 187
                     $str = $row[1];
188 188
 
189
-                    $str = str_replace('"', '`', $str);
190
-                    $str = preg_replace('/CONSTRAINT `[a-zA-Z0-9_-]+` /', '', $str);
191
-                    $str = preg_replace('/ DEFAULT CHARSET=[^ ;]+/', '', $str);
192
-                    $str = preg_replace('/ COLLATE=[^ ;]+/', '', $str);
189
+                    $str = str_replace( '"', '`', $str );
190
+                    $str = preg_replace( '/CONSTRAINT `[a-zA-Z0-9_-]+` /', '', $str );
191
+                    $str = preg_replace( '/ DEFAULT CHARSET=[^ ;]+/', '', $str );
192
+                    $str = preg_replace( '/ COLLATE=[^ ;]+/', '', $str );
193 193
 
194 194
                     $sql[] = $str . ";\n";
195 195
                 }
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
      *
206 206
      * @param string|null $extname Installed extension name
207 207
      */
208
-    public static function executeOnSignal(string $extname = null)
208
+    public static function executeOnSignal( string $extname = null )
209 209
     {
210
-        self::signal($extname);
210
+        self::signal( $extname );
211 211
     }
212 212
 
213 213
 
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
      *
217 217
      * @param string|null $extname Installed extension name
218 218
      */
219
-    public static function signal(string $extname = null)
219
+    public static function signal( string $extname = null )
220 220
     {
221
-        if ($extname === 'aimeos' && \Aimeos\Aimeos\Base::getExtConfig('autoSetup', true)) {
221
+        if( $extname === 'aimeos' && \Aimeos\Aimeos\Base::getExtConfig( 'autoSetup', true ) ) {
222 222
             self::execute();
223 223
         }
224 224
     }
@@ -229,12 +229,12 @@  discard block
 block discarded – undo
229 229
      *
230 230
      * @param AlterTableDefinitionStatementsEvent $event Event object
231 231
      */
232
-    public function schemaEvent(AlterTableDefinitionStatementsEvent $event)
232
+    public function schemaEvent( AlterTableDefinitionStatementsEvent $event )
233 233
     {
234
-        $list = self::schema([]);
234
+        $list = self::schema( [] );
235 235
 
236
-        foreach ($list['sqlString'] ?? [] as $sql) {
237
-            $event->addSqlData($sql);
236
+        foreach( $list['sqlString'] ?? [] as $sql ) {
237
+            $event->addSqlData( $sql );
238 238
         }
239 239
     }
240 240
 
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
      *
245 245
      * @param AfterPackageActivationEvent $event Event object
246 246
      */
247
-    public function setupEvent(AfterPackageActivationEvent $event)
247
+    public function setupEvent( AfterPackageActivationEvent $event )
248 248
     {
249
-        if ($event->getPackageKey() === 'aimeos' && \Aimeos\Aimeos\Base::getExtConfig('autoSetup', true)) {
249
+        if( $event->getPackageKey() === 'aimeos' && \Aimeos\Aimeos\Base::getExtConfig( 'autoSetup', true ) ) {
250 250
             self::execute();
251 251
         }
252 252
     }
@@ -258,34 +258,34 @@  discard block
 block discarded – undo
258 258
      * @param array $config Nested array of configuration settings
259 259
      * @return \Aimeos\MShop\ContextIface Context object
260 260
      */
261
-    protected static function context(array $config = []) : \Aimeos\MShop\ContextIface
261
+    protected static function context( array $config = [] ) : \Aimeos\MShop\ContextIface
262 262
     {
263
-        $aimeosExtPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('aimeos');
263
+        $aimeosExtPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath( 'aimeos' );
264 264
 
265
-        if (file_exists($aimeosExtPath . '/Resources/Libraries/autoload.php') === true) {
265
+        if( file_exists( $aimeosExtPath . '/Resources/Libraries/autoload.php' ) === true ) {
266 266
             require_once $aimeosExtPath . '/Resources/Libraries/autoload.php';
267 267
         }
268 268
 
269 269
         $ctx = new \Aimeos\MShop\Context();
270
-        $conf = \Aimeos\Aimeos\Base::config($config);
270
+        $conf = \Aimeos\Aimeos\Base::config( $config );
271 271
 
272
-        $ctx->setConfig($conf);
273
-        $ctx->setDatabaseManager(new \Aimeos\Base\DB\Manager\Standard($conf->get('resource', []), 'DBAL'));
274
-        $ctx->setFilesystemManager(new \Aimeos\Base\Filesystem\Manager\Standard($conf->get('resource', [])));
275
-        $ctx->setLogger(new \Aimeos\Base\Logger\Errorlog(\Aimeos\Base\Logger\Iface::INFO));
276
-        $ctx->setSession(new \Aimeos\Base\Session\None());
277
-        $ctx->setCache(new \Aimeos\Base\Cache\None());
272
+        $ctx->setConfig( $conf );
273
+        $ctx->setDatabaseManager( new \Aimeos\Base\DB\Manager\Standard( $conf->get( 'resource', [] ), 'DBAL' ) );
274
+        $ctx->setFilesystemManager( new \Aimeos\Base\Filesystem\Manager\Standard( $conf->get( 'resource', [] ) ) );
275
+        $ctx->setLogger( new \Aimeos\Base\Logger\Errorlog( \Aimeos\Base\Logger\Iface::INFO ) );
276
+        $ctx->setSession( new \Aimeos\Base\Session\None() );
277
+        $ctx->setCache( new \Aimeos\Base\Cache\None() );
278 278
 
279 279
         // Reset before child processes are spawned to avoid lost DB connections afterwards (TYPO3 9.4 and above)
280
-        if (php_sapi_name() === 'cli' && class_exists('\TYPO3\CMS\Core\Database\ConnectionPool')
281
-            && method_exists('\TYPO3\CMS\Core\Database\ConnectionPool', 'resetConnections')
280
+        if( php_sapi_name() === 'cli' && class_exists( '\TYPO3\CMS\Core\Database\ConnectionPool' )
281
+            && method_exists( '\TYPO3\CMS\Core\Database\ConnectionPool', 'resetConnections' )
282 282
         ) {
283
-            $ctx->setProcess(new \Aimeos\Base\Process\Pcntl(\Aimeos\Aimeos\Base::getExtConfig('pcntlMax', 4)));
283
+            $ctx->setProcess( new \Aimeos\Base\Process\Pcntl( \Aimeos\Aimeos\Base::getExtConfig( 'pcntlMax', 4 ) ) );
284 284
         } else {
285
-            $ctx->setProcess(new \Aimeos\Base\Process\None());
285
+            $ctx->setProcess( new \Aimeos\Base\Process\None() );
286 286
         }
287 287
 
288
-        $factory = GeneralUtility::makeInstance('TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory');
289
-        return $ctx->setPassword(new \Aimeos\Base\Password\Typo3($factory->getDefaultHashInstance('FE')));
288
+        $factory = GeneralUtility::makeInstance( 'TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory' );
289
+        return $ctx->setPassword( new \Aimeos\Base\Password\Typo3( $factory->getDefaultHashInstance( 'FE' ) ) );
290 290
     }
291 291
 }
Please login to merge, or discard this patch.