gravityview /
GravityView
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 | namespace GV; |
||
| 3 | |||
| 4 | /** If this file is called directly, abort. */ |
||
| 5 | if ( ! defined( 'GRAVITYVIEW_DIR' ) ) |
||
|
0 ignored issues
–
show
|
|||
| 6 | die(); |
||
| 7 | |||
| 8 | /** |
||
| 9 | * The core GravityView API. |
||
| 10 | * |
||
| 11 | * Returned by the wrapper gravityview() global function, exposes |
||
| 12 | * all the required public functionality and classes, sets up global |
||
| 13 | * state depending on current request context, etc. |
||
| 14 | */ |
||
| 15 | final class Core { |
||
| 16 | /** |
||
| 17 | * @var \GV\Core The \GV\Core static instance. |
||
| 18 | */ |
||
| 19 | private static $__instance = null; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var \GV\Plugin The WordPress plugin context. |
||
| 23 | * |
||
| 24 | * @api |
||
| 25 | * @since future |
||
| 26 | */ |
||
| 27 | public $plugin; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var \GV\Request The current request. |
||
| 31 | * |
||
| 32 | * @api |
||
| 33 | * @since future |
||
| 34 | */ |
||
| 35 | public $request; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var \GV\CoreSettings core GravityView settings |
||
| 39 | */ |
||
| 40 | public $settings; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Get the global instance of \GV\Core. |
||
| 44 | * |
||
| 45 | * @return \GV\Core The global instance of GravityView Core. |
||
| 46 | */ |
||
| 47 | public static function get() { |
||
| 48 | if ( ! self::$__instance instanceof self ) |
||
|
0 ignored issues
–
show
|
|||
| 49 | self::$__instance = new self; |
||
| 50 | return self::$__instance; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Bootstrap. |
||
| 55 | * |
||
| 56 | * @return void |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Adding a
@return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.
Adding a Please refer to the PHP core documentation on constructors. Loading history...
|
|||
| 57 | */ |
||
| 58 | private function __construct() { |
||
| 59 | $this->init(); |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Early initialization. |
||
| 64 | * |
||
| 65 | * Loads dependencies, sets up the object, adds hooks, etc. |
||
| 66 | * |
||
| 67 | * @return void |
||
| 68 | */ |
||
| 69 | private function init() { |
||
| 70 | require_once dirname( __FILE__ ) . '/class-gv-plugin.php'; |
||
| 71 | $this->plugin = \GV\Plugin::get(); |
||
| 72 | } |
||
| 73 | |||
| 74 | private function __clone() { } |
||
| 75 | |||
| 76 | private function __wakeup() { } |
||
| 77 | } |
||
| 78 |
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.