@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @param Renderable $engine |
63 | 63 | */ |
64 | - public function __construct( Renderable $engine, Component_Compiler $component_compiler ) { |
|
64 | + public function __construct(Renderable $engine, Component_Compiler $component_compiler) { |
|
65 | 65 | $this->engine = $engine; |
66 | 66 | $this->component_compiler = $component_compiler; |
67 | 67 | |
68 | 68 | // Populate engine with compiler. |
69 | - $this->engine->set_component_compiler( $component_compiler ); |
|
69 | + $this->engine->set_component_compiler($component_compiler); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * @param bool $print Print or Return the HTML |
78 | 78 | * @return string|void |
79 | 79 | */ |
80 | - public function render( string $view, iterable $view_data = array(), bool $print = self::PRINT_VIEW ) { |
|
81 | - return $this->engine->render( $view, $view_data, $print ); |
|
80 | + public function render(string $view, iterable $view_data = array(), bool $print = self::PRINT_VIEW) { |
|
81 | + return $this->engine->render($view, $view_data, $print); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | * @param bool $print Print or Return the HTML |
89 | 89 | * @return string|void |
90 | 90 | */ |
91 | - public function component( Component $component, bool $print = self::PRINT_VIEW ) { |
|
92 | - return $this->engine->component( $component, $print ); |
|
91 | + public function component(Component $component, bool $print = self::PRINT_VIEW) { |
|
92 | + return $this->engine->component($component, $print); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | * @param bool $print Print or Return the HTML |
100 | 100 | * @return string|void |
101 | 101 | */ |
102 | - public function view_model( View_Model $view_model, bool $print = self::PRINT_VIEW ) { |
|
103 | - return $this->engine->view_model( $view_model, $print ); |
|
102 | + public function view_model(View_Model $view_model, bool $print = self::PRINT_VIEW) { |
|
103 | + return $this->engine->view_model($view_model, $print); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param callable $to_buffer |
110 | 110 | * @return string |
111 | 111 | */ |
112 | - public static function print_buffer( callable $to_buffer ): string { |
|
112 | + public static function print_buffer(callable $to_buffer): string { |
|
113 | 113 | ob_start(); |
114 | 114 | $to_buffer(); |
115 | 115 | $output = ob_get_contents(); |
@@ -61,11 +61,11 @@ |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | - * Gets the defined base path. |
|
65 | - * |
|
66 | - * @return string |
|
67 | - * @since 1.4.0 |
|
68 | - */ |
|
64 | + * Gets the defined base path. |
|
65 | + * |
|
66 | + * @return string |
|
67 | + * @since 1.4.0 |
|
68 | + */ |
|
69 | 69 | public function get_base_path(): string { |
70 | 70 | return $this->base_path; |
71 | 71 | } |
@@ -62,17 +62,17 @@ discard block |
||
62 | 62 | */ |
63 | 63 | protected array $modules = array(); |
64 | 64 | |
65 | - public function __construct( ?string $base_path = null ) { |
|
65 | + public function __construct(?string $base_path = null) { |
|
66 | 66 | |
67 | - if ( null === $base_path ) { |
|
67 | + if (null === $base_path) { |
|
68 | 68 | $file_index = 0; |
69 | 69 | $trace = debug_backtrace(); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace |
70 | - $this->base_path = isset( $trace[ $file_index ]['file'] ) ? \trailingslashit( dirname( $trace[ $file_index ]['file'] ) ) : __DIR__; |
|
70 | + $this->base_path = isset($trace[$file_index]['file']) ? \trailingslashit(dirname($trace[$file_index]['file'])) : __DIR__; |
|
71 | 71 | } else { |
72 | - $this->base_path = \trailingslashit( $base_path ); |
|
72 | + $this->base_path = \trailingslashit($base_path); |
|
73 | 73 | } |
74 | 74 | |
75 | - $this->app = new App( $this->base_path ); |
|
75 | + $this->app = new App($this->base_path); |
|
76 | 76 | |
77 | 77 | } |
78 | 78 | |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | * @param string $base_view_path |
94 | 94 | * @return self |
95 | 95 | */ |
96 | - public function set_base_view_path( string $base_view_path ): self { |
|
97 | - $this->base_view_path = \trailingslashit( $base_view_path ); |
|
96 | + public function set_base_view_path(string $base_view_path): self { |
|
97 | + $this->base_view_path = \trailingslashit($base_view_path); |
|
98 | 98 | |
99 | 99 | // Set the view base path on the app. |
100 | - $this->app->set_view_path( $this->base_view_path ); |
|
100 | + $this->app->set_view_path($this->base_view_path); |
|
101 | 101 | |
102 | 102 | return $this; |
103 | 103 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | public function get_base_view_path(): string { |
112 | 112 | return null !== $this->base_view_path |
113 | 113 | ? $this->base_view_path |
114 | - : \trailingslashit( $this->default_config_paths()['path']['view'] ); |
|
114 | + : \trailingslashit($this->default_config_paths()['path']['view']); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | * @infection-ignore-all |
124 | 124 | * @return self |
125 | 125 | */ |
126 | - public function with_wp_dice( bool $include_default_rules = false ): self { |
|
126 | + public function with_wp_dice(bool $include_default_rules = false): self { |
|
127 | 127 | // If the view path is not set, set it to the same as base path. |
128 | - if ( null === $this->base_view_path ) { |
|
128 | + if (null === $this->base_view_path) { |
|
129 | 129 | $this->base_view_path = $this->base_path; |
130 | 130 | } |
131 | - return $this->default_setup( $include_default_rules ); |
|
131 | + return $this->default_setup($include_default_rules); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -143,29 +143,29 @@ discard block |
||
143 | 143 | * @param bool $include_default_rules |
144 | 144 | * @return self |
145 | 145 | */ |
146 | - public function default_setup( bool $include_default_rules = true ): self { |
|
146 | + public function default_setup(bool $include_default_rules = true): self { |
|
147 | 147 | $loader = new Hook_Loader(); |
148 | 148 | |
149 | 149 | // Setup DI Container |
150 | - $container = PinkCrab_Dice::withDice( new Dice() ); |
|
150 | + $container = PinkCrab_Dice::withDice(new Dice()); |
|
151 | 151 | |
152 | - if ( $include_default_rules === true ) { |
|
153 | - $container->addRules( $this->default_di_rules() ); |
|
152 | + if ($include_default_rules === true) { |
|
153 | + $container->addRules($this->default_di_rules()); |
|
154 | 154 | } |
155 | 155 | |
156 | - $this->app->set_container( $container ); |
|
157 | - $this->app->set_loader( $loader ); |
|
156 | + $this->app->set_container($container); |
|
157 | + $this->app->set_loader($loader); |
|
158 | 158 | |
159 | 159 | // Set registration middleware |
160 | - $module_manager = new Module_Manager( $container, new Registration_Service( $container ) ); |
|
161 | - $module_manager->push_module( Hookable_Module::class ); |
|
160 | + $module_manager = new Module_Manager($container, new Registration_Service($container)); |
|
161 | + $module_manager->push_module(Hookable_Module::class); |
|
162 | 162 | |
163 | 163 | // Push any modules that have been added before the module manager was set. |
164 | - foreach ( $this->modules as $module ) { |
|
165 | - $module_manager->push_module( $module[0], $module[1] ); |
|
164 | + foreach ($this->modules as $module) { |
|
165 | + $module_manager->push_module($module[0], $module[1]); |
|
166 | 166 | } |
167 | 167 | |
168 | - $this->app->set_module_manager( $module_manager ); |
|
168 | + $this->app->set_module_manager($module_manager); |
|
169 | 169 | |
170 | 170 | return $this; |
171 | 171 | } |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | * @param ?callable(Module, ?Registration_Middleware):Module $callback |
179 | 179 | * @return self |
180 | 180 | */ |
181 | - public function module( string $module, ?callable $callback = null ): self { |
|
181 | + public function module(string $module, ?callable $callback = null): self { |
|
182 | 182 | |
183 | 183 | // If the Module_Manager has been set in app, add the module to app. |
184 | - if ( $this->app->has_module_manager() ) { |
|
185 | - $this->app->module( $module, $callback ); |
|
184 | + if ($this->app->has_module_manager()) { |
|
185 | + $this->app->module($module, $callback); |
|
186 | 186 | return $this; |
187 | 187 | } |
188 | 188 | |
189 | - $this->modules[] = array( $module, $callback ); |
|
189 | + $this->modules[] = array($module, $callback); |
|
190 | 190 | return $this; |
191 | 191 | } |
192 | 192 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | 'shared' => true, |
209 | 209 | ), |
210 | 210 | Component_Compiler::class => array( |
211 | - 'constructParams' => array( 'components' ), |
|
211 | + 'constructParams' => array('components'), |
|
212 | 212 | ), |
213 | 213 | ); |
214 | 214 | } |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | * @param array<string,array<string,string|object|callable|null|false|\Closure>> $rules |
220 | 220 | * @return self |
221 | 221 | */ |
222 | - public function di_rules( array $rules ): self { |
|
222 | + public function di_rules(array $rules): self { |
|
223 | 223 | $this->app->container_config( |
224 | - function( DI_Container $container ) use ( $rules ): void { |
|
225 | - $container->addRules( $rules ); |
|
224 | + function(DI_Container $container) use ($rules): void { |
|
225 | + $container->addRules($rules); |
|
226 | 226 | } |
227 | 227 | ); |
228 | 228 | return $this; |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | * @param array<class-string> $class_list Array of fully namespaced class names. |
235 | 235 | * @return self |
236 | 236 | */ |
237 | - public function registration_classes( array $class_list ): self { |
|
238 | - $this->app->registration_classes( $class_list ); |
|
237 | + public function registration_classes(array $class_list): self { |
|
238 | + $this->app->registration_classes($class_list); |
|
239 | 239 | return $this; |
240 | 240 | } |
241 | 241 | |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | * @param array<string, mixed> $app_config |
246 | 246 | * @return self |
247 | 247 | */ |
248 | - public function app_config( array $app_config ): self { |
|
249 | - $this->app->set_app_config( \array_replace_recursive( $this->default_config_paths(), $app_config ) ); |
|
248 | + public function app_config(array $app_config): self { |
|
249 | + $this->app->set_app_config(\array_replace_recursive($this->default_config_paths(), $app_config)); |
|
250 | 250 | return $this; |
251 | 251 | } |
252 | 252 | |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function boot(): App { |
268 | 268 | // Sets default settings if not already set. |
269 | - if ( ! $this->app->has_app_config() ) { |
|
270 | - $this->app_config( $this->default_config_paths() ); |
|
269 | + if ( ! $this->app->has_app_config()) { |
|
270 | + $this->app_config($this->default_config_paths()); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | return $this->app->boot(); |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | private function default_config_paths(): array { |
297 | 297 | $wp_uploads = \wp_upload_dir(); |
298 | 298 | |
299 | - $base_path = App_Config_Path_Helper::normalise_path( $this->base_path ); |
|
300 | - $view_path = $this->base_view_path ?? App_Config_Path_Helper::assume_view_path( $base_path ); |
|
299 | + $base_path = App_Config_Path_Helper::normalise_path($this->base_path); |
|
300 | + $view_path = $this->base_view_path ?? App_Config_Path_Helper::assume_view_path($base_path); |
|
301 | 301 | |
302 | 302 | return array( |
303 | 303 | 'path' => array( |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | 'upload_current' => $wp_uploads['path'], |
309 | 309 | ), |
310 | 310 | 'url' => array( |
311 | - 'plugin' => App_Config_Path_Helper::assume_base_url( $base_path ), |
|
312 | - 'view' => App_Config_Path_Helper::assume_view_url( $base_path, $view_path ), |
|
313 | - 'assets' => App_Config_Path_Helper::assume_base_url( $base_path ) . '/assets', |
|
311 | + 'plugin' => App_Config_Path_Helper::assume_base_url($base_path), |
|
312 | + 'view' => App_Config_Path_Helper::assume_view_url($base_path, $view_path), |
|
313 | + 'assets' => App_Config_Path_Helper::assume_base_url($base_path) . '/assets', |
|
314 | 314 | 'upload_root' => $wp_uploads['baseurl'], |
315 | 315 | 'upload_current' => $wp_uploads['url'], |
316 | 316 | ), |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param bool $print |
36 | 36 | * @return void|string |
37 | 37 | */ |
38 | - public function render( string $view, iterable $data, bool $print = true ); |
|
38 | + public function render(string $view, iterable $data, bool $print = true); |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Renders a component. |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param Component $component |
44 | 44 | * @return string|void |
45 | 45 | */ |
46 | - public function component( Component $component, bool $print = true ); |
|
46 | + public function component(Component $component, bool $print = true); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Renders a view Model |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param View_Model $view_model |
52 | 52 | * @return string|void |
53 | 53 | */ |
54 | - public function view_model( View_Model $view_model, bool $print = true ); |
|
54 | + public function view_model(View_Model $view_model, bool $print = true); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Sets the component compiler. |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param Component_Compiler $compiler |
60 | 60 | * @return void |
61 | 61 | */ |
62 | - public function set_component_compiler( Component_Compiler $compiler ): void; |
|
62 | + public function set_component_compiler(Component_Compiler $compiler): void; |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * Returns the base view path. |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @param string $path |
35 | 35 | * @return string |
36 | 36 | */ |
37 | - public static function normalise_path( string $path ): string { |
|
38 | - return rtrim( $path, '/\\' ); |
|
37 | + public static function normalise_path(string $path): string { |
|
38 | + return rtrim($path, '/\\'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * @param string $base_path |
45 | 45 | * @return string |
46 | 46 | */ |
47 | - public static function assume_view_path( string $base_path ): string { |
|
47 | + public static function assume_view_path(string $base_path): string { |
|
48 | 48 | // Remove any trailing slash. |
49 | - $base_path = self::normalise_path( $base_path ); |
|
49 | + $base_path = self::normalise_path($base_path); |
|
50 | 50 | return $base_path . \DIRECTORY_SEPARATOR . 'views'; |
51 | 51 | } |
52 | 52 | |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | * @param string $base_path |
57 | 57 | * @return string |
58 | 58 | */ |
59 | - public static function assume_base_url( string $base_path ): string { |
|
59 | + public static function assume_base_url(string $base_path): string { |
|
60 | 60 | // Remove any trailing slash. |
61 | - $base_path = self::normalise_path( $base_path ); |
|
62 | - return plugins_url( basename( $base_path ) ); |
|
61 | + $base_path = self::normalise_path($base_path); |
|
62 | + return plugins_url(basename($base_path)); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | * @param string $view_path |
70 | 70 | * @return string |
71 | 71 | */ |
72 | - public static function assume_view_url( string $base_path, string $view_path ): string { |
|
72 | + public static function assume_view_url(string $base_path, string $view_path): string { |
|
73 | 73 | |
74 | - $base_path = self::normalise_path( $base_path ); |
|
75 | - $view_path = self::normalise_path( $view_path ); |
|
74 | + $base_path = self::normalise_path($base_path); |
|
75 | + $view_path = self::normalise_path($view_path); |
|
76 | 76 | |
77 | 77 | // Remove any trailing slash. |
78 | - $diff = ltrim( str_replace( $base_path, '', $view_path ), '/\\' ); |
|
78 | + $diff = ltrim(str_replace($base_path, '', $view_path), '/\\'); |
|
79 | 79 | |
80 | 80 | // Return the base url with the diff. |
81 | - return self::assume_base_url( $base_path ) . '/' . $diff; |
|
81 | + return self::assume_base_url($base_path) . '/' . $diff; |
|
82 | 82 | } |
83 | 83 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * @param string $class |
34 | 34 | * @return bool |
35 | 35 | */ |
36 | - public static function is_a( $value, string $class ): bool { |
|
37 | - return is_object( $value ) && is_a( $value, $class ); |
|
36 | + public static function is_a($value, string $class): bool { |
|
37 | + return is_object($value) && is_a($value, $class); |
|
38 | 38 | } |
39 | 39 | } |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param string $base_path |
108 | 108 | */ |
109 | - public function __construct( string $base_path ) { |
|
109 | + public function __construct(string $base_path) { |
|
110 | 110 | $this->base_path = $base_path; |
111 | 111 | |
112 | 112 | // Assume the view path. |
113 | - $this->view_path = rtrim( $this->base_path, '/\\' ) . \DIRECTORY_SEPARATOR . 'views'; |
|
113 | + $this->view_path = rtrim($this->base_path, '/\\') . \DIRECTORY_SEPARATOR . 'views'; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param string $view_path |
120 | 120 | * @return self |
121 | 121 | */ |
122 | - public function set_view_path( string $view_path ): self { |
|
122 | + public function set_view_path(string $view_path): self { |
|
123 | 123 | $this->view_path = $view_path; |
124 | 124 | return $this; |
125 | 125 | } |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @return self |
132 | 132 | * @throws App_Initialization_Exception Code 2 |
133 | 133 | */ |
134 | - public function set_container( DI_Container $container ): self { |
|
135 | - if ( self::$container !== null ) { |
|
134 | + public function set_container(DI_Container $container): self { |
|
135 | + if (self::$container !== null) { |
|
136 | 136 | throw App_Initialization_Exception::di_container_exists(); |
137 | 137 | } |
138 | 138 | |
@@ -157,28 +157,28 @@ discard block |
||
157 | 157 | * @return self |
158 | 158 | * @throws App_Initialization_Exception Code 5 |
159 | 159 | */ |
160 | - public function set_app_config( array $settings ): self { |
|
161 | - if ( self::$app_config !== null ) { |
|
160 | + public function set_app_config(array $settings): self { |
|
161 | + if (self::$app_config !== null) { |
|
162 | 162 | throw App_Initialization_Exception::app_config_exists(); |
163 | 163 | } |
164 | 164 | |
165 | 165 | // Run through the filter to allow for config changes. |
166 | - $settings = apply_filters( Hooks::APP_INIT_CONFIG_VALUES, $settings ); |
|
166 | + $settings = apply_filters(Hooks::APP_INIT_CONFIG_VALUES, $settings); |
|
167 | 167 | |
168 | 168 | // Ensure the base path and url are defined from app. |
169 | 169 | $settings['path'] = $settings['path'] ?? array(); |
170 | 170 | $settings['path']['plugin'] = $this->base_path; |
171 | - $settings['path']['view'] = $this->view_path ?? App_Config_Path_Helper::assume_view_path( $this->base_path ); |
|
171 | + $settings['path']['view'] = $this->view_path ?? App_Config_Path_Helper::assume_view_path($this->base_path); |
|
172 | 172 | |
173 | 173 | // Get the url from the base path. |
174 | 174 | $settings['url'] = $settings['url'] ?? array(); |
175 | - $settings['url']['plugin'] = App_Config_Path_Helper::assume_base_url( $this->base_path ); |
|
175 | + $settings['url']['plugin'] = App_Config_Path_Helper::assume_base_url($this->base_path); |
|
176 | 176 | $settings['url']['view'] = App_Config_Path_Helper::assume_view_url( |
177 | 177 | $this->base_path, |
178 | - $this->view_path ?? App_Config_Path_Helper::assume_view_path( $this->base_path ) |
|
178 | + $this->view_path ?? App_Config_Path_Helper::assume_view_path($this->base_path) |
|
179 | 179 | ); |
180 | 180 | |
181 | - self::$app_config = new App_Config( $settings ); |
|
181 | + self::$app_config = new App_Config($settings); |
|
182 | 182 | return $this; |
183 | 183 | } |
184 | 184 | |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * @return self |
190 | 190 | * @throws App_Initialization_Exception Code 10 |
191 | 191 | */ |
192 | - public function set_module_manager( Module_Manager $module_manager ): self { |
|
193 | - if ( $this->module_manager !== null ) { |
|
192 | + public function set_module_manager(Module_Manager $module_manager): self { |
|
193 | + if ($this->module_manager !== null) { |
|
194 | 194 | throw App_Initialization_Exception::module_manager_exists(); |
195 | 195 | } |
196 | 196 | |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | * @param \PinkCrab\Loader\Hook_Loader $loader |
205 | 205 | * @return self |
206 | 206 | */ |
207 | - public function set_loader( Hook_Loader $loader ): self { |
|
208 | - if ( $this->loader !== null ) { |
|
207 | + public function set_loader(Hook_Loader $loader): self { |
|
208 | + if ($this->loader !== null) { |
|
209 | 209 | throw App_Initialization_Exception::loader_exists(); |
210 | 210 | } |
211 | 211 | $this->loader = $loader; |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | * @return self |
221 | 221 | * @throws App_Initialization_Exception Code 1 |
222 | 222 | */ |
223 | - public function container_config( callable $callback ): self { |
|
224 | - if ( self::$container === null ) { |
|
223 | + public function container_config(callable $callback): self { |
|
224 | + if (self::$container === null) { |
|
225 | 225 | throw App_Initialization_Exception::requires_di_container(); |
226 | 226 | } |
227 | - $callback( self::$container ); |
|
227 | + $callback(self::$container); |
|
228 | 228 | return $this; |
229 | 229 | } |
230 | 230 | |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | * @return self |
236 | 236 | * @throws App_Initialization_Exception Code 3 |
237 | 237 | */ |
238 | - public function registration_classes( array $class_list ): self { |
|
239 | - if ( $this->module_manager === null ) { |
|
238 | + public function registration_classes(array $class_list): self { |
|
239 | + if ($this->module_manager === null) { |
|
240 | 240 | throw App_Initialization_Exception::requires_module_manager(); |
241 | 241 | } |
242 | 242 | |
243 | - foreach ( $class_list as $class ) { |
|
244 | - $this->module_manager->register_class( $class ); |
|
243 | + foreach ($class_list as $class) { |
|
244 | + $this->module_manager->register_class($class); |
|
245 | 245 | } |
246 | 246 | return $this; |
247 | 247 | } |
@@ -256,17 +256,17 @@ discard block |
||
256 | 256 | * @throws App_Initialization_Exception Code 1 If DI container not registered |
257 | 257 | * @throws App_Initialization_Exception Code 3 If module manager not defined. |
258 | 258 | */ |
259 | - public function module( string $module, ?callable $callback = null ): self { |
|
259 | + public function module(string $module, ?callable $callback = null): self { |
|
260 | 260 | // Check if module manager exists. |
261 | - if ( $this->module_manager === null ) { |
|
261 | + if ($this->module_manager === null) { |
|
262 | 262 | throw App_Initialization_Exception::requires_module_manager(); |
263 | 263 | } |
264 | 264 | |
265 | - if ( self::$container === null ) { |
|
265 | + if (self::$container === null) { |
|
266 | 266 | throw App_Initialization_Exception::requires_di_container(); |
267 | 267 | } |
268 | 268 | |
269 | - $this->module_manager->push_module( $module, $callback ); |
|
269 | + $this->module_manager->push_module($module, $callback); |
|
270 | 270 | |
271 | 271 | return $this; |
272 | 272 | } |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | public function boot(): self { |
281 | 281 | |
282 | 282 | // Validate. |
283 | - $validate = new App_Validation( $this ); |
|
284 | - if ( $validate->validate() === false ) { |
|
283 | + $validate = new App_Validation($this); |
|
284 | + if ($validate->validate() === false) { |
|
285 | 285 | throw App_Initialization_Exception::failed_boot_validation( |
286 | 286 | $validate->errors |
287 | 287 | ); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | Inject_Hook_Loader::class, |
334 | 334 | array( |
335 | 335 | 'call' => array( |
336 | - array( 'set_hook_loader', array( $this->loader ) ), |
|
336 | + array('set_hook_loader', array($this->loader)), |
|
337 | 337 | ), |
338 | 338 | ) |
339 | 339 | ); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | Inject_App_Config::class, |
344 | 344 | array( |
345 | 345 | 'call' => array( |
346 | - array( 'set_app_config', array( self::$app_config ) ), |
|
346 | + array('set_app_config', array(self::$app_config)), |
|
347 | 347 | ), |
348 | 348 | ) |
349 | 349 | ); |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | Inject_DI_Container::class, |
354 | 354 | array( |
355 | 355 | 'call' => array( |
356 | - array( 'set_di_container', array( self::$container ) ), |
|
356 | + array('set_di_container', array(self::$container)), |
|
357 | 357 | ), |
358 | 358 | ) |
359 | 359 | ); |
@@ -362,15 +362,15 @@ discard block |
||
362 | 362 | $this->module_manager->register_modules(); // @phpstan-ignore-line, already verified if not null |
363 | 363 | |
364 | 364 | /** @hook{string, App_Config, Loader, DI_Container} */ |
365 | - do_action( Hooks::APP_INIT_PRE_BOOT, self::$app_config, $this->loader, self::$container ); // phpcs:disable WordPress.NamingConventions.ValidHookName.* |
|
365 | + do_action(Hooks::APP_INIT_PRE_BOOT, self::$app_config, $this->loader, self::$container); // phpcs:disable WordPress.NamingConventions.ValidHookName.* |
|
366 | 366 | |
367 | 367 | // Initialise on init |
368 | 368 | add_action( |
369 | 369 | 'init', |
370 | - function () { |
|
371 | - do_action( Hooks::APP_INIT_PRE_REGISTRATION, self::$app_config, $this->loader, self::$container ); |
|
370 | + function() { |
|
371 | + do_action(Hooks::APP_INIT_PRE_REGISTRATION, self::$app_config, $this->loader, self::$container); |
|
372 | 372 | $this->module_manager->process_middleware(); // @phpstan-ignore-line, already verified if not null |
373 | - do_action( Hooks::APP_INIT_POST_REGISTRATION, self::$app_config, $this->loader, self::$container ); |
|
373 | + do_action(Hooks::APP_INIT_POST_REGISTRATION, self::$app_config, $this->loader, self::$container); |
|
374 | 374 | $this->loader->register_hooks(); // @phpstan-ignore-line, if loader is not defined, exception will be thrown above |
375 | 375 | }, |
376 | 376 | 1 |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | * @return object|null |
390 | 390 | * @throws App_Initialization_Exception Code 4 |
391 | 391 | */ |
392 | - public static function make( string $class, array $args = array() ): ?object { |
|
393 | - if ( self::$booted === false ) { |
|
394 | - throw App_Initialization_Exception::app_not_initialized( DI_Container::class ); |
|
392 | + public static function make(string $class, array $args = array()): ?object { |
|
393 | + if (self::$booted === false) { |
|
394 | + throw App_Initialization_Exception::app_not_initialized(DI_Container::class); |
|
395 | 395 | } |
396 | - return self::$container->create( $class, $args ); // @phpstan-ignore-line, already verified if not null |
|
396 | + return self::$container->create($class, $args); // @phpstan-ignore-line, already verified if not null |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | * @return mixed |
405 | 405 | * @throws App_Initialization_Exception Code 4 |
406 | 406 | */ |
407 | - public static function config( string $key, string ...$child ) { |
|
408 | - if ( self::$booted === false ) { |
|
409 | - throw App_Initialization_Exception::app_not_initialized( App_Config::class ); |
|
407 | + public static function config(string $key, string ...$child) { |
|
408 | + if (self::$booted === false) { |
|
409 | + throw App_Initialization_Exception::app_not_initialized(App_Config::class); |
|
410 | 410 | } |
411 | - return self::$app_config->{$key}( ...$child ); |
|
411 | + return self::$app_config->{$key}(...$child); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | /** |
@@ -418,11 +418,11 @@ discard block |
||
418 | 418 | * @throws App_Initialization_Exception Code 4 |
419 | 419 | */ |
420 | 420 | public static function view(): ?View { |
421 | - if ( self::$booted === false ) { |
|
422 | - throw App_Initialization_Exception::app_not_initialized( View::class ); |
|
421 | + if (self::$booted === false) { |
|
422 | + throw App_Initialization_Exception::app_not_initialized(View::class); |
|
423 | 423 | } |
424 | 424 | /** @var ?View */ |
425 | - return self::$container->create( View::class ); // @phpstan-ignore-line, already verified if not null |
|
425 | + return self::$container->create(View::class); // @phpstan-ignore-line, already verified if not null |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** @return array{ |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * @return bool |
451 | 451 | */ |
452 | 452 | public function has_app_config(): bool { |
453 | - return Object_Helper::is_a( self::$app_config, App_Config::class ); |
|
453 | + return Object_Helper::is_a(self::$app_config, App_Config::class); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @throws App_Initialization_Exception (Code 1) |
461 | 461 | */ |
462 | 462 | public function get_container(): DI_Container { |
463 | - if ( self::$container === null ) { |
|
463 | + if (self::$container === null) { |
|
464 | 464 | // Throw container not set. |
465 | 465 | throw App_Initialization_Exception::requires_di_container(); |
466 | 466 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | /** @var App */ |
44 | 44 | private App $app; |
45 | 45 | |
46 | - public function __construct( App $app ) { |
|
46 | + public function __construct(App $app) { |
|
47 | 47 | $this->app = $app; |
48 | 48 | } |
49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | public function validate(): bool { |
56 | 56 | $this->already_booted(); |
57 | 57 | $this->validate_properties_set(); |
58 | - return count( $this->errors ) === 0; |
|
58 | + return count($this->errors) === 0; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | * @return void |
66 | 66 | */ |
67 | 67 | private function validate_properties_set(): void { |
68 | - foreach ( $this->required_properties as $property => $is_static ) { |
|
69 | - $property_reflection = new ReflectionProperty( $this->app, $property ); |
|
70 | - $property_reflection->setAccessible( true ); |
|
71 | - if ( empty( $property_reflection->getValue( $this->app ) ) ) { |
|
72 | - $this->errors[] = \sprintf( self::ERROR_MESSAGE_TEMPLATE, $property ); |
|
68 | + foreach ($this->required_properties as $property => $is_static) { |
|
69 | + $property_reflection = new ReflectionProperty($this->app, $property); |
|
70 | + $property_reflection->setAccessible(true); |
|
71 | + if (empty($property_reflection->getValue($this->app))) { |
|
72 | + $this->errors[] = \sprintf(self::ERROR_MESSAGE_TEMPLATE, $property); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @return void |
81 | 81 | */ |
82 | 82 | private function already_booted(): void { |
83 | - if ( $this->app->is_booted() === true ) { |
|
83 | + if ($this->app->is_booted() === true) { |
|
84 | 84 | $this->errors[] = self::ERROR_MESSAGE_APP_BOOTED; |
85 | 85 | } |
86 | 86 | } |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | /** |
90 | 90 | * @param array<string, mixed> $settings |
91 | 91 | */ |
92 | - public function __construct( array $settings = array() ) { |
|
93 | - $settings = $this->set_defaults( $settings ); |
|
94 | - $this->set_props( $settings ); |
|
92 | + public function __construct(array $settings = array()) { |
|
93 | + $settings = $this->set_defaults($settings); |
|
94 | + $this->set_props($settings); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | * @param array<string, mixed> $settings |
101 | 101 | * @return array<string, mixed> |
102 | 102 | */ |
103 | - private function set_defaults( array $settings ): array { |
|
104 | - return array_replace_recursive( $this->settings_defaults(), $settings ); |
|
103 | + private function set_defaults(array $settings): array { |
|
104 | + return array_replace_recursive($this->settings_defaults(), $settings); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | * @param array<string, mixed> $settings |
111 | 111 | * @return void |
112 | 112 | */ |
113 | - private function set_props( array $settings ): void { |
|
113 | + private function set_props(array $settings): void { |
|
114 | 114 | $this->paths['url'] = $settings['url']; |
115 | 115 | $this->paths['path'] = $settings['path']; |
116 | - $this->namespaces = $this->filter_key_value_pair( $settings['namespaces'] ); |
|
116 | + $this->namespaces = $this->filter_key_value_pair($settings['namespaces']); |
|
117 | 117 | $this->plugin = $settings['plugin']; |
118 | 118 | $this->additional = $settings['additional']; |
119 | - $this->db_tables = $this->filter_key_value_pair( $settings['db_tables'] ); |
|
120 | - $this->post_types = $this->filter_key_value_pair( $settings['post_types'] ); |
|
121 | - $this->taxonomies = $this->filter_key_value_pair( $settings['taxonomies'] ); |
|
119 | + $this->db_tables = $this->filter_key_value_pair($settings['db_tables']); |
|
120 | + $this->post_types = $this->filter_key_value_pair($settings['post_types']); |
|
121 | + $this->taxonomies = $this->filter_key_value_pair($settings['taxonomies']); |
|
122 | 122 | |
123 | - $this->set_meta( $settings['meta'] ); |
|
123 | + $this->set_meta($settings['meta']); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | * @param string|null $default The default value to return if not set. |
131 | 131 | * @return array<string, mixed>|string|null |
132 | 132 | */ |
133 | - public function path( ?string $path = null, ?string $default = null ) { |
|
133 | + public function path(?string $path = null, ?string $default = null) { |
|
134 | 134 | |
135 | - if ( is_null( $path ) ) { |
|
135 | + if (is_null($path)) { |
|
136 | 136 | return $this->paths['path']; |
137 | 137 | } |
138 | 138 | |
139 | - return \array_key_exists( $path, $this->paths['path'] ) |
|
140 | - ? trailingslashit( $this->paths['path'][ $path ] ) |
|
139 | + return \array_key_exists($path, $this->paths['path']) |
|
140 | + ? trailingslashit($this->paths['path'][$path]) |
|
141 | 141 | : $default; |
142 | 142 | } |
143 | 143 | |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | * @param string|null $default The default value to return if not set. |
149 | 149 | * @return array<string, mixed>|string|null |
150 | 150 | */ |
151 | - public function url( ?string $url = null, ?string $default = null ) { |
|
151 | + public function url(?string $url = null, ?string $default = null) { |
|
152 | 152 | |
153 | - if ( is_null( $url ) ) { |
|
153 | + if (is_null($url)) { |
|
154 | 154 | return $this->paths['url']; |
155 | 155 | } |
156 | 156 | |
157 | - return \array_key_exists( $url, $this->paths['url'] ) |
|
158 | - ? trailingslashit( $this->paths['url'][ $url ] ) |
|
157 | + return \array_key_exists($url, $this->paths['url']) |
|
158 | + ? trailingslashit($this->paths['url'][$url]) |
|
159 | 159 | : $default; |
160 | 160 | } |
161 | 161 | |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | * @param string|null $default The default value to return if not set. |
185 | 185 | * @return string|null |
186 | 186 | */ |
187 | - public function namespace( string $key, ?string $default = null ): ?string { |
|
188 | - return array_key_exists( $key, $this->namespaces ) |
|
189 | - ? $this->namespaces[ $key ] : $default; |
|
187 | + public function namespace(string $key, ?string $default = null) : ?string { |
|
188 | + return array_key_exists($key, $this->namespaces) |
|
189 | + ? $this->namespaces[$key] : $default; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | * @param string|null $default The default value to return if not set. |
197 | 197 | * @return mixed |
198 | 198 | */ |
199 | - public function additional( string $key, ?string $default = null ) { |
|
200 | - return array_key_exists( $key, $this->additional ) |
|
201 | - ? $this->additional[ $key ] : $default; |
|
199 | + public function additional(string $key, ?string $default = null) { |
|
200 | + return array_key_exists($key, $this->additional) |
|
201 | + ? $this->additional[$key] : $default; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | * @return string |
227 | 227 | * @throws OutOfBoundsException |
228 | 228 | */ |
229 | - public function post_types( string $key ) { |
|
230 | - if ( ! array_key_exists( $key, $this->post_types ) ) { |
|
231 | - throw new OutOfBoundsException( "App Config :: \"{$key}\" is not a defined post type" ); |
|
229 | + public function post_types(string $key) { |
|
230 | + if ( ! array_key_exists($key, $this->post_types)) { |
|
231 | + throw new OutOfBoundsException("App Config :: \"{$key}\" is not a defined post type"); |
|
232 | 232 | } |
233 | 233 | |
234 | - return $this->post_types[ $key ]; |
|
234 | + return $this->post_types[$key]; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -242,17 +242,17 @@ discard block |
||
242 | 242 | * @return string |
243 | 243 | * @throws OutOfBoundsException |
244 | 244 | */ |
245 | - public function meta( string $key, string $type = self::POST_META ): string { |
|
245 | + public function meta(string $key, string $type = self::POST_META): string { |
|
246 | 246 | // Check meta type. |
247 | - if ( ! array_key_exists( $type, $this->meta ) ) { |
|
248 | - throw new OutOfBoundsException( "App Config :: \"{$type}\" is not a valid meta type and cant be fetched" ); |
|
247 | + if ( ! array_key_exists($type, $this->meta)) { |
|
248 | + throw new OutOfBoundsException("App Config :: \"{$type}\" is not a valid meta type and cant be fetched"); |
|
249 | 249 | } |
250 | 250 | // Check key. |
251 | - if ( ! array_key_exists( $key, $this->meta[ $type ] ) ) { |
|
252 | - throw new OutOfBoundsException( "App Config :: \"{$key}\" is not a defined {$type} meta key" ); |
|
251 | + if ( ! array_key_exists($key, $this->meta[$type])) { |
|
252 | + throw new OutOfBoundsException("App Config :: \"{$key}\" is not a defined {$type} meta key"); |
|
253 | 253 | } |
254 | 254 | |
255 | - return $this->meta[ $type ][ $key ]; |
|
255 | + return $this->meta[$type][$key]; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | * @param string $key |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public function post_meta( string $key ): string { |
|
266 | - return $this->meta( $key, self::POST_META ); |
|
265 | + public function post_meta(string $key): string { |
|
266 | + return $this->meta($key, self::POST_META); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | * @param string $key |
274 | 274 | * @return string |
275 | 275 | */ |
276 | - public function user_meta( string $key ): string { |
|
277 | - return $this->meta( $key, self::USER_META ); |
|
276 | + public function user_meta(string $key): string { |
|
277 | + return $this->meta($key, self::USER_META); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | * @param string $key |
285 | 285 | * @return string |
286 | 286 | */ |
287 | - public function term_meta( string $key ): string { |
|
288 | - return $this->meta( $key, self::TERM_META ); |
|
287 | + public function term_meta(string $key): string { |
|
288 | + return $this->meta($key, self::TERM_META); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -294,15 +294,15 @@ discard block |
||
294 | 294 | * @param array<string, array<string,string>> $meta |
295 | 295 | * @return void |
296 | 296 | */ |
297 | - public function set_meta( array $meta ): void { |
|
298 | - $valid_meta_types = array( self::POST_META, self::USER_META, self::TERM_META ); |
|
299 | - foreach ( $meta as $meta_type => $pairs ) { |
|
300 | - if ( ! in_array( $meta_type, $valid_meta_types, true ) ) { |
|
301 | - throw new OutOfBoundsException( "App Config :: \"{$meta_type}\" is not a valid meta type and cant be defined" ); |
|
297 | + public function set_meta(array $meta): void { |
|
298 | + $valid_meta_types = array(self::POST_META, self::USER_META, self::TERM_META); |
|
299 | + foreach ($meta as $meta_type => $pairs) { |
|
300 | + if ( ! in_array($meta_type, $valid_meta_types, true)) { |
|
301 | + throw new OutOfBoundsException("App Config :: \"{$meta_type}\" is not a valid meta type and cant be defined"); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | // Set all pairs which have both valid key and values. |
305 | - $this->meta[ $meta_type ] = $this->filter_key_value_pair( $pairs ); |
|
305 | + $this->meta[$meta_type] = $this->filter_key_value_pair($pairs); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
@@ -313,12 +313,12 @@ discard block |
||
313 | 313 | * @return string |
314 | 314 | * @throws OutOfBoundsException |
315 | 315 | */ |
316 | - public function taxonomies( string $key ): string { |
|
317 | - if ( ! array_key_exists( $key, $this->taxonomies ) ) { |
|
318 | - throw new OutOfBoundsException( "App Config :: \"{$key}\" is not a defined taxonomy" ); |
|
316 | + public function taxonomies(string $key): string { |
|
317 | + if ( ! array_key_exists($key, $this->taxonomies)) { |
|
318 | + throw new OutOfBoundsException("App Config :: \"{$key}\" is not a defined taxonomy"); |
|
319 | 319 | } |
320 | 320 | |
321 | - return $this->taxonomies[ $key ]; |
|
321 | + return $this->taxonomies[$key]; |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | |
@@ -329,11 +329,11 @@ discard block |
||
329 | 329 | * @return string |
330 | 330 | * @throws OutOfBoundsException |
331 | 331 | */ |
332 | - public function db_tables( string $name ): string { |
|
333 | - if ( ! array_key_exists( $name, $this->db_tables ) ) { |
|
334 | - throw new OutOfBoundsException( "App Config :: \"{$name}\" is not a defined DB table" ); |
|
332 | + public function db_tables(string $name): string { |
|
333 | + if ( ! array_key_exists($name, $this->db_tables)) { |
|
334 | + throw new OutOfBoundsException("App Config :: \"{$name}\" is not a defined DB table"); |
|
335 | 335 | } |
336 | - return $this->db_tables[ $name ]; |
|
336 | + return $this->db_tables[$name]; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | * @param string $name |
343 | 343 | * @return mixed |
344 | 344 | */ |
345 | - public function __get( $name ) { |
|
346 | - return $this->additional( $name ); |
|
345 | + public function __get($name) { |
|
346 | + return $this->additional($name); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
@@ -352,11 +352,11 @@ discard block |
||
352 | 352 | * @return array<string, mixed> |
353 | 353 | */ |
354 | 354 | private function settings_defaults(): array { |
355 | - $base_path = \dirname( __DIR__, 2 ); |
|
355 | + $base_path = \dirname(__DIR__, 2); |
|
356 | 356 | $wp_uploads = \wp_upload_dir(); |
357 | 357 | |
358 | - $base_path = App_Config_Path_Helper::normalise_path( $base_path ); |
|
359 | - $view_path = App_Config_Path_Helper::assume_view_path( $base_path ); |
|
358 | + $base_path = App_Config_Path_Helper::normalise_path($base_path); |
|
359 | + $view_path = App_Config_Path_Helper::assume_view_path($base_path); |
|
360 | 360 | |
361 | 361 | global $wpdb; |
362 | 362 | |
@@ -373,9 +373,9 @@ discard block |
||
373 | 373 | 'upload_current' => $wp_uploads['path'], |
374 | 374 | ), |
375 | 375 | 'url' => array( |
376 | - 'plugin' => App_Config_Path_Helper::assume_base_url( $base_path ), |
|
377 | - 'view' => App_Config_Path_Helper::assume_view_url( $base_path, $view_path ), |
|
378 | - 'assets' => App_Config_Path_Helper::assume_base_url( $base_path ) . '/assets', |
|
376 | + 'plugin' => App_Config_Path_Helper::assume_base_url($base_path), |
|
377 | + 'view' => App_Config_Path_Helper::assume_view_url($base_path, $view_path), |
|
378 | + 'assets' => App_Config_Path_Helper::assume_base_url($base_path) . '/assets', |
|
379 | 379 | 'upload_root' => $wp_uploads['baseurl'], |
380 | 380 | 'upload_current' => $wp_uploads['url'], |
381 | 381 | ), |
@@ -397,15 +397,15 @@ discard block |
||
397 | 397 | * @param array<int|string, mixed> $pairs |
398 | 398 | * @return array<string, string> |
399 | 399 | */ |
400 | - private function filter_key_value_pair( array $pairs ): array { |
|
400 | + private function filter_key_value_pair(array $pairs): array { |
|
401 | 401 | /** @var array<string, string> (as per filter function)*/ |
402 | 402 | return array_filter( |
403 | 403 | $pairs, |
404 | - function ( $value, $key ): bool { |
|
405 | - return is_string( $value ) |
|
406 | - && \strlen( $value ) > 0 |
|
407 | - && is_string( $key ) |
|
408 | - && \strlen( $key ) > 0; |
|
404 | + function($value, $key): bool { |
|
405 | + return is_string($value) |
|
406 | + && \strlen($value) > 0 |
|
407 | + && is_string($key) |
|
408 | + && \strlen($key) > 0; |
|
409 | 409 | }, |
410 | 410 | ARRAY_FILTER_USE_BOTH |
411 | 411 | ); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public static function requires_di_container(): App_Initialization_Exception { |
38 | 38 | $message = 'The Application must be populated with a DI_Container before booting.'; |
39 | - return new App_Initialization_Exception( $message, 1 ); |
|
39 | + return new App_Initialization_Exception($message, 1); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public static function di_container_exists(): App_Initialization_Exception { |
48 | 48 | $message = 'App already contains a DI Container, can not redeclare.'; |
49 | - return new App_Initialization_Exception( $message, 2 ); |
|
49 | + return new App_Initialization_Exception($message, 2); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public static function requires_module_manager(): App_Initialization_Exception { |
58 | 58 | $message = 'App has not defined Registration Service, this must be set before use.'; |
59 | - return new App_Initialization_Exception( $message, 3 ); |
|
59 | + return new App_Initialization_Exception($message, 3); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * @param string $service The service which has been called without initialising the app. |
66 | 66 | * @return App_Initialization_Exception |
67 | 67 | */ |
68 | - public static function app_not_initialized( string $service ): App_Initialization_Exception { |
|
68 | + public static function app_not_initialized(string $service): App_Initialization_Exception { |
|
69 | 69 | $message = "App must be initialised before calling {$service}"; |
70 | - return new App_Initialization_Exception( $message, 4 ); |
|
70 | + return new App_Initialization_Exception($message, 4); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public static function app_config_exists(): App_Initialization_Exception { |
79 | 79 | $message = 'Can not redeclare App_Config as its already set to the application'; |
80 | - return new App_Initialization_Exception( $message, 5 ); |
|
80 | + return new App_Initialization_Exception($message, 5); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public static function registration_exists(): App_Initialization_Exception { |
89 | 89 | $message = 'Can not redeclare Registration_Service as its already set to the application'; |
90 | - return new App_Initialization_Exception( $message, 7 ); |
|
90 | + return new App_Initialization_Exception($message, 7); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | * @param array<int,string> $errors |
97 | 97 | * @return App_Initialization_Exception |
98 | 98 | */ |
99 | - public static function failed_boot_validation( array $errors ): App_Initialization_Exception { |
|
99 | + public static function failed_boot_validation(array $errors): App_Initialization_Exception { |
|
100 | 100 | $message = sprintf( |
101 | 101 | 'App failed boot validation : %s', |
102 | - join( ', ', $errors ) |
|
102 | + join(', ', $errors) |
|
103 | 103 | ); |
104 | - return new App_Initialization_Exception( $message, 6 ); |
|
104 | + return new App_Initialization_Exception($message, 6); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public static function loader_exists(): App_Initialization_Exception { |
113 | 113 | $message = 'Can not redeclare Loader as its already set to the application'; |
114 | - return new App_Initialization_Exception( $message, 8 ); |
|
114 | + return new App_Initialization_Exception($message, 8); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public static function module_manager_exists(): App_Initialization_Exception { |
123 | 123 | $message = 'Can not redeclare Module_Manager as its already set to the application'; |
124 | - return new App_Initialization_Exception( $message, 10 ); |
|
124 | + return new App_Initialization_Exception($message, 10); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | } |