phpffcms /
ffcms
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 | // check if loader is initialized |
||
| 4 | if (!defined('root')) { |
||
| 5 | die('Hack attempt'); |
||
| 6 | } |
||
| 7 | |||
| 8 | // global environment |
||
| 9 | define('env_name', 'Api'); |
||
| 10 | define('type', 'web'); |
||
| 11 | define('env_no_layout', true); |
||
| 12 | |||
| 13 | require_once(root . '/Loader/Autoload.php'); |
||
| 14 | |||
| 15 | // make fast-access alias \App::$Object |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
37% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 16 | // class_alias('Ffcms\Core\App', 'App'); |
||
| 17 | class App extends Ffcms\Core\App {} |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
The type
App has been defined more than once; this definition is ignored, only the first definition in Loader/Admin/index.php (L17-17) is considered.
This check looks for classes that have been defined more than once. If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface. This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP. Loading history...
|
|||
| 18 | /** |
||
| 19 | * Alias for translate function for fast usage. Example: __('Welcome my friend') |
||
| 20 | * @param string $text |
||
| 21 | * @param array $params |
||
| 22 | * @return string |
||
| 23 | */ |
||
| 24 | function __($text, array $params = []) { |
||
|
0 ignored issues
–
show
The function
__() has been defined more than once; this definition is ignored, only the first definition in Loader/Admin/index.php (L24-26) is considered.
This check looks for functions that have already been defined in other files. Some Codebases, like WordPress, make a practice of defining functions multiple times. This
may lead to problems with the detection of function parameters and types. If you really
need to do this, you can mark the duplicate definition with the /**
* @ignore
*/
function getUser() {
}
function getUser($id, $realm) {
}
See also the PhpDoc documentation for @ignore. Loading history...
|
|||
| 25 | return \App::$Translate->translate($text, $params); |
||
| 26 | } |
||
| 27 | |||
| 28 | try { |
||
| 29 | // prepare to run |
||
| 30 | \App::init([ |
||
| 31 | 'Database' => true, |
||
| 32 | 'Session' => true, |
||
| 33 | 'Debug' => false, |
||
| 34 | 'User' => true, |
||
| 35 | 'Mailer' => true, |
||
| 36 | 'Captcha' => true, |
||
| 37 | 'Cache' => true |
||
| 38 | ]); |
||
| 39 | // display output |
||
| 40 | \App::run(); |
||
| 41 | } catch (Exception $e) { |
||
| 42 | (new \Ffcms\Core\Exception\NativeException($e->getMessage()))->display(); |
||
| 43 | } |
||
| 44 |
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.