netz98 /
n98-magerun2
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
|
0 ignored issues
–
show
|
|||
| 2 | |||
| 3 | if (!class_exists('N98_Magerun_Bootstrap')) { |
||
| 4 | class N98_Magerun_Bootstrap |
||
| 5 | { |
||
| 6 | public static function includeIfExists($file) |
||
| 7 | { |
||
| 8 | if (file_exists($file)) { |
||
| 9 | return include $file; |
||
| 10 | } |
||
| 11 | } |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @throws ErrorException |
||
| 15 | * @return \Composer\Autoload\ClassLoader |
||
| 16 | */ |
||
| 17 | public static function getLoader() |
||
| 18 | { |
||
| 19 | if ((!$loader = \N98_Magerun_Bootstrap::includeIfExists(__DIR__.'/../vendor/autoload.php')) |
||
| 20 | && (!$loader = \N98_Magerun_Bootstrap::includeIfExists(__DIR__.'/../../../autoload.php'))) { |
||
| 21 | throw new \ErrorException('You must set up the project dependencies, run the following commands:'.PHP_EOL. |
||
|
0 ignored issues
–
show
|
|||
| 22 | 'curl -s http://getcomposer.org/installer | php'.PHP_EOL. |
||
| 23 | 'php composer.phar install'.PHP_EOL); |
||
| 24 | } |
||
| 25 | |||
| 26 | return $loader; |
||
| 27 | } |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | try { |
||
| 32 | if (version_compare(PHP_VERSION, '5.4.11', '<')) { |
||
| 33 | throw new \ErrorException('PHP Version is lower than 5.4.11. Please upgrade your runtime.'); |
||
| 34 | } |
||
| 35 | |||
| 36 | $loader = \N98_Magerun_Bootstrap::getLoader(); |
||
| 37 | $application = new \N98\Magento\Application($loader); |
||
| 38 | |||
| 39 | return $application; |
||
| 40 | |||
| 41 | } catch (\Exception $e) { |
||
| 42 | echo $e->getMessage(); |
||
| 43 | exit(1); |
||
| 44 | } |
||
| 45 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.