Passed
Pull Request — master (#198)
by Daniel
05:55
created
Classes/Setup.php 1 patch
Spacing   +64 added lines, -64 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,29 +128,29 @@  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 = \Aimeos\Aimeos\Base::getExtConfig('siteCode', 'default');
141
-        $template = \Aimeos\Aimeos\Base::getExtConfig('siteTpl', 'default');
140
+        $site = \Aimeos\Aimeos\Base::getExtConfig( 'siteCode', 'default' );
141
+        $template = \Aimeos\Aimeos\Base::getExtConfig( 'siteTpl', 'default' );
142 142
 
143 143
         $boostrap = \Aimeos\Aimeos\Base::aimeos();
144
-        $ctx = self::context(['setup' => ['default' => ['demo' => (string) $demo]]])->setEditor('setup');
144
+        $ctx = self::context( ['setup' => ['default' => ['demo' => (string) $demo]]] )->setEditor( 'setup' );
145 145
 
146
-        \Aimeos\Setup::use($boostrap)->verbose('vvv')
147
-            ->context($ctx->setEditor('aimeos:setup'))
148
-            ->up($site, $template);
146
+        \Aimeos\Setup::use( $boostrap )->verbose( 'vvv' )
147
+            ->context( $ctx->setEditor( 'aimeos:setup' ) )
148
+            ->up( $site, $template );
149 149
 
150
-        if (defined('TYPO3_version') && version_compare(constant('TYPO3_version'), '11.0.0', '<')) {
151
-            $extconf->set('aimeos', 'useDemoData', '');
150
+        if( defined( 'TYPO3_version' ) && version_compare( constant( 'TYPO3_version' ), '11.0.0', '<' ) ) {
151
+            $extconf->set( 'aimeos', 'useDemoData', '' );
152 152
         } else {
153
-            $extconf->set('aimeos', ['useDemoData' => '']);
153
+            $extconf->set( 'aimeos', ['useDemoData' => ''] );
154 154
         }
155 155
     }
156 156
 
@@ -161,34 +161,34 @@  discard block
 block discarded – undo
161 161
      * @param array $sql List of SQL statements
162 162
      * @return array SQL statements required for the install tool
163 163
      */
164
-    public static function schema(array $sql) : array
164
+    public static function schema( array $sql ) : array
165 165
     {
166 166
         $ctx = self::getContext();
167
-        $connectionNames = array_keys($ctx->getConfig()->get( 'resource'));
168
-        $connectionNames = array_filter($connectionNames, fn (string $key): bool => str_starts_with($key, 'db'));
167
+        $connectionNames = array_keys( $ctx->getConfig()->get( 'resource' ) );
168
+        $connectionNames = array_filter( $connectionNames, fn ( string $key ): bool => str_starts_with( $key, 'db' ) );
169 169
 
170
-        foreach ($connectionNames as $connectionName) {
171
-            $conn = $ctx->db($connectionName);
170
+        foreach( $connectionNames as $connectionName ) {
171
+            $conn = $ctx->db( $connectionName );
172 172
 
173 173
             $tables = [];
174
-            foreach(['fe_users_', 'madmin_', 'mshop_'] as $prefix) {
175
-                $result = $conn->create('SHOW TABLES like \'' . $prefix . '%\'')->execute();
174
+            foreach( ['fe_users_', 'madmin_', 'mshop_'] as $prefix ) {
175
+                $result = $conn->create( 'SHOW TABLES like \'' . $prefix . '%\'' )->execute();
176 176
 
177
-                while(($row = $result->fetch(\Aimeos\Base\DB\Result\Base::FETCH_NUM)) !== null) {
177
+                while( ( $row = $result->fetch( \Aimeos\Base\DB\Result\Base::FETCH_NUM ) ) !== null ) {
178 178
                     $tables[] = $row[0];
179 179
                 }
180 180
             }
181 181
 
182
-            foreach($tables as $table) {
183
-                $result = $conn->create('SHOW CREATE TABLE `' . $table . '`')->execute();
182
+            foreach( $tables as $table ) {
183
+                $result = $conn->create( 'SHOW CREATE TABLE `' . $table . '`' )->execute();
184 184
 
185
-                while(($row = $result->fetch(\Aimeos\Base\DB\Result\Base::FETCH_NUM)) !== null) {
185
+                while( ( $row = $result->fetch( \Aimeos\Base\DB\Result\Base::FETCH_NUM ) ) !== null ) {
186 186
                     $str = $row[1];
187 187
 
188
-                    $str = str_replace('"', '`', $str);
189
-                    $str = preg_replace('/CONSTRAINT `[a-zA-Z0-9_-]+` /', '', $str);
190
-                    $str = preg_replace('/ DEFAULT CHARSET=[^ ;]+/', '', $str);
191
-                    $str = preg_replace('/ COLLATE=[^ ;]+/', '', $str);
188
+                    $str = str_replace( '"', '`', $str );
189
+                    $str = preg_replace( '/CONSTRAINT `[a-zA-Z0-9_-]+` /', '', $str );
190
+                    $str = preg_replace( '/ DEFAULT CHARSET=[^ ;]+/', '', $str );
191
+                    $str = preg_replace( '/ COLLATE=[^ ;]+/', '', $str );
192 192
 
193 193
                     $sql[] = $str . ";\n";
194 194
                 }
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
      *
205 205
      * @param string|null $extname Installed extension name
206 206
      */
207
-    public static function executeOnSignal(string $extname = null)
207
+    public static function executeOnSignal( string $extname = null )
208 208
     {
209
-        self::signal($extname);
209
+        self::signal( $extname );
210 210
     }
211 211
 
212 212
 
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
      *
216 216
      * @param string|null $extname Installed extension name
217 217
      */
218
-    public static function signal(string $extname = null)
218
+    public static function signal( string $extname = null )
219 219
     {
220
-        if ($extname === 'aimeos' && \Aimeos\Aimeos\Base::getExtConfig('autoSetup', true)) {
220
+        if( $extname === 'aimeos' && \Aimeos\Aimeos\Base::getExtConfig( 'autoSetup', true ) ) {
221 221
             self::execute();
222 222
         }
223 223
     }
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
      *
229 229
      * @param AlterTableDefinitionStatementsEvent $event Event object
230 230
      */
231
-    public function schemaEvent(AlterTableDefinitionStatementsEvent $event)
231
+    public function schemaEvent( AlterTableDefinitionStatementsEvent $event )
232 232
     {
233
-        $list = self::schema([]);
233
+        $list = self::schema( [] );
234 234
 
235
-        foreach ($list['sqlString'] ?? [] as $sql) {
236
-            $event->addSqlData($sql);
235
+        foreach( $list['sqlString'] ?? [] as $sql ) {
236
+            $event->addSqlData( $sql );
237 237
         }
238 238
     }
239 239
 
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
      *
244 244
      * @param AfterPackageActivationEvent $event Event object
245 245
      */
246
-    public function setupEvent(AfterPackageActivationEvent $event)
246
+    public function setupEvent( AfterPackageActivationEvent $event )
247 247
     {
248
-        if ($event->getPackageKey() === 'aimeos' && \Aimeos\Aimeos\Base::getExtConfig('autoSetup', true)) {
248
+        if( $event->getPackageKey() === 'aimeos' && \Aimeos\Aimeos\Base::getExtConfig( 'autoSetup', true ) ) {
249 249
             self::execute();
250 250
         }
251 251
     }
@@ -257,34 +257,34 @@  discard block
 block discarded – undo
257 257
      * @param array $config Nested array of configuration settings
258 258
      * @return \Aimeos\MShop\ContextIface Context object
259 259
      */
260
-    protected static function context(array $config = []) : \Aimeos\MShop\ContextIface
260
+    protected static function context( array $config = [] ) : \Aimeos\MShop\ContextIface
261 261
     {
262
-        $aimeosExtPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('aimeos');
262
+        $aimeosExtPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath( 'aimeos' );
263 263
 
264
-        if (file_exists($aimeosExtPath . '/Resources/Libraries/autoload.php') === true) {
264
+        if( file_exists( $aimeosExtPath . '/Resources/Libraries/autoload.php' ) === true ) {
265 265
             require_once $aimeosExtPath . '/Resources/Libraries/autoload.php';
266 266
         }
267 267
 
268 268
         $ctx = new \Aimeos\MShop\Context();
269
-        $conf = \Aimeos\Aimeos\Base::config($config);
269
+        $conf = \Aimeos\Aimeos\Base::config( $config );
270 270
 
271
-        $ctx->setConfig($conf);
272
-        $ctx->setDatabaseManager(new \Aimeos\Base\DB\Manager\Standard($conf->get('resource', []), 'DBAL'));
273
-        $ctx->setFilesystemManager(new \Aimeos\Base\Filesystem\Manager\Standard($conf->get('resource', [])));
274
-        $ctx->setLogger(new \Aimeos\Base\Logger\Errorlog(\Aimeos\Base\Logger\Iface::INFO));
275
-        $ctx->setSession(new \Aimeos\Base\Session\None());
276
-        $ctx->setCache(new \Aimeos\Base\Cache\None());
271
+        $ctx->setConfig( $conf );
272
+        $ctx->setDatabaseManager( new \Aimeos\Base\DB\Manager\Standard( $conf->get( 'resource', [] ), 'DBAL' ) );
273
+        $ctx->setFilesystemManager( new \Aimeos\Base\Filesystem\Manager\Standard( $conf->get( 'resource', [] ) ) );
274
+        $ctx->setLogger( new \Aimeos\Base\Logger\Errorlog( \Aimeos\Base\Logger\Iface::INFO ) );
275
+        $ctx->setSession( new \Aimeos\Base\Session\None() );
276
+        $ctx->setCache( new \Aimeos\Base\Cache\None() );
277 277
 
278 278
         // Reset before child processes are spawned to avoid lost DB connections afterwards (TYPO3 9.4 and above)
279
-        if (php_sapi_name() === 'cli' && class_exists('\TYPO3\CMS\Core\Database\ConnectionPool')
280
-            && method_exists('\TYPO3\CMS\Core\Database\ConnectionPool', 'resetConnections')
279
+        if( php_sapi_name() === 'cli' && class_exists( '\TYPO3\CMS\Core\Database\ConnectionPool' )
280
+            && method_exists( '\TYPO3\CMS\Core\Database\ConnectionPool', 'resetConnections' )
281 281
         ) {
282
-            $ctx->setProcess(new \Aimeos\Base\Process\Pcntl(\Aimeos\Aimeos\Base::getExtConfig('pcntlMax', 4)));
282
+            $ctx->setProcess( new \Aimeos\Base\Process\Pcntl( \Aimeos\Aimeos\Base::getExtConfig( 'pcntlMax', 4 ) ) );
283 283
         } else {
284
-            $ctx->setProcess(new \Aimeos\Base\Process\None());
284
+            $ctx->setProcess( new \Aimeos\Base\Process\None() );
285 285
         }
286 286
 
287
-        $factory = GeneralUtility::makeInstance('TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory');
288
-        return $ctx->setPassword(new \Aimeos\Base\Password\Typo3($factory->getDefaultHashInstance('FE')));
287
+        $factory = GeneralUtility::makeInstance( 'TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory' );
288
+        return $ctx->setPassword( new \Aimeos\Base\Password\Typo3( $factory->getDefaultHashInstance( 'FE' ) ) );
289 289
     }
290 290
 }
Please login to merge, or discard this patch.