@@ -33,7 +33,7 @@ |
||
33 | 33 | * @param object $class |
34 | 34 | * @return object |
35 | 35 | */ |
36 | - public function process( $class ); |
|
36 | + public function process($class); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Used to for any middleware setup before process is called |
@@ -31,5 +31,5 @@ |
||
31 | 31 | * @param Hook_Loader $loader |
32 | 32 | * @return void |
33 | 33 | */ |
34 | - public function register( Hook_Loader $loader ): void; |
|
34 | + public function register(Hook_Loader $loader): void; |
|
35 | 35 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | * @param DI_Container $container |
42 | 42 | * @return void |
43 | 43 | */ |
44 | - public function set_di_container( DI_Container $container ): void { |
|
44 | + public function set_di_container(DI_Container $container): void { |
|
45 | 45 | $this->di_container = $container; |
46 | 46 | } |
47 | 47 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | * @param App_Config $app_config |
42 | 42 | * @return void |
43 | 43 | */ |
44 | - public function set_app_config( App_Config $app_config ): void { |
|
44 | + public function set_app_config(App_Config $app_config): void { |
|
45 | 45 | $this->app_config = $app_config; |
46 | 46 | } |
47 | 47 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | * @param Hook_Loader $container |
42 | 42 | * @return void |
43 | 43 | */ |
44 | - public function set_hook_loader( Hook_Loader $hook_loader ): void { |
|
44 | + public function set_hook_loader(Hook_Loader $hook_loader): void { |
|
45 | 45 | $this->loader = $hook_loader; |
46 | 46 | } |
47 | 47 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @param Dice $dice |
45 | 45 | */ |
46 | - public function __construct( Dice $dice ) { |
|
46 | + public function __construct(Dice $dice) { |
|
47 | 47 | $this->dice = $dice; |
48 | 48 | } |
49 | 49 | |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | * @param Dice $dice |
54 | 54 | * @return self |
55 | 55 | */ |
56 | - public static function withDice( Dice $dice ): self { // phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid |
|
57 | - return new PinkCrab_Dice( $dice ); |
|
56 | + public static function withDice(Dice $dice): self { // phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid |
|
57 | + return new PinkCrab_Dice($dice); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | * @param string $id Class name (fully namespaced.) |
65 | 65 | * @return object|null |
66 | 66 | */ |
67 | - public function get( $id ) { |
|
68 | - if ( ! $this->has( $id ) ) { |
|
69 | - throw new DI_Container_Exception( "{$id} not defined in container", 1 ); |
|
67 | + public function get($id) { |
|
68 | + if ( ! $this->has($id)) { |
|
69 | + throw new DI_Container_Exception("{$id} not defined in container", 1); |
|
70 | 70 | } |
71 | - return $this->create( $id ); |
|
71 | + return $this->create($id); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -78,21 +78,21 @@ discard block |
||
78 | 78 | * @param string $id Class name (fully namespaced.) |
79 | 79 | * @return bool |
80 | 80 | */ |
81 | - public function has( $id ) { |
|
82 | - $from_dice = $this->dice->getRule( $id ); |
|
81 | + public function has($id) { |
|
82 | + $from_dice = $this->dice->getRule($id); |
|
83 | 83 | // If set in global rules. |
84 | - if ( array_key_exists( 'substitutions', $from_dice ) |
|
85 | - && array_key_exists( $id, $from_dice['substitutions'] ) ) { |
|
84 | + if (array_key_exists('substitutions', $from_dice) |
|
85 | + && array_key_exists($id, $from_dice['substitutions'])) { |
|
86 | 86 | return true; |
87 | 87 | } |
88 | 88 | |
89 | 89 | // If set with a replacement instance. |
90 | - if ( array_key_exists( 'instanceOf', $from_dice ) ) { |
|
90 | + if (array_key_exists('instanceOf', $from_dice)) { |
|
91 | 91 | return true; |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Checks if the class exists |
95 | - return class_exists( $id ); |
|
95 | + return class_exists($id); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * @param array<string, string|object|mixed[]> $rule |
103 | 103 | * @return PinkCrab_Dice |
104 | 104 | */ |
105 | - public function addRule( string $name, array $rule ): DI_Container { // phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid |
|
106 | - $this->dice = $this->dice->addRule( $name, $rule ); |
|
105 | + public function addRule(string $name, array $rule): DI_Container { // phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid |
|
106 | + $this->dice = $this->dice->addRule($name, $rule); |
|
107 | 107 | return $this; |
108 | 108 | } |
109 | 109 | |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | * @param array<string, mixed[]> $rules |
114 | 114 | * @return PinkCrab_Dice |
115 | 115 | */ |
116 | - public function addRules( array $rules ): DI_Container { // phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid |
|
117 | - $this->dice = $this->dice->addRules( apply_filters( Hooks::APP_INIT_SET_DI_RULES, $rules ) ); |
|
116 | + public function addRules(array $rules): DI_Container { // phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid |
|
117 | + $this->dice = $this->dice->addRules(apply_filters(Hooks::APP_INIT_SET_DI_RULES, $rules)); |
|
118 | 118 | return $this; |
119 | 119 | } |
120 | 120 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param array<mixed> $args |
126 | 126 | * @return object|null |
127 | 127 | */ |
128 | - public function create( string $name, array $args = array() ) { |
|
129 | - return $this->dice->create( $name, $args ); |
|
128 | + public function create(string $name, array $args = array()) { |
|
129 | + return $this->dice->create($name, $args); |
|
130 | 130 | } |
131 | 131 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param Hook_Loader $loader |
42 | 42 | * @return void |
43 | 43 | */ |
44 | - public function set_hook_loader( Hook_Loader $loader ):void { |
|
44 | + public function set_hook_loader(Hook_Loader $loader):void { |
|
45 | 45 | $this->loader = $loader; |
46 | 46 | } |
47 | 47 | |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | * @param object $class |
52 | 52 | * @return object |
53 | 53 | */ |
54 | - public function process( $class ) { |
|
55 | - if ( in_array( Hookable::class, class_implements( $class ) ?: array(), true ) ) { |
|
54 | + public function process($class) { |
|
55 | + if (in_array(Hookable::class, class_implements($class) ?: array(), true)) { |
|
56 | 56 | /** @phpstan-ignore-next-line class must implement register for interface*/ |
57 | - $class->register( $this->loader ); |
|
57 | + $class->register($this->loader); |
|
58 | 58 | } |
59 | 59 | return $class; |
60 | 60 | } |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | */ |
41 | 41 | protected $base_path; |
42 | 42 | |
43 | - public function __construct( ?string $base_path = null ) { |
|
43 | + public function __construct(?string $base_path = null) { |
|
44 | 44 | $this->app = new App(); |
45 | 45 | |
46 | - if ( null === $base_path ) { |
|
46 | + if (null === $base_path) { |
|
47 | 47 | $trace = debug_backtrace(); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace |
48 | - $this->base_path = isset( $trace[0]['file'] ) ? \trailingslashit( dirname( $trace[0]['file'] ) ) : __DIR__; |
|
48 | + $this->base_path = isset($trace[0]['file']) ? \trailingslashit(dirname($trace[0]['file'])) : __DIR__; |
|
49 | 49 | } else { |
50 | - $this->base_path = \trailingslashit( $base_path ); |
|
50 | + $this->base_path = \trailingslashit($base_path); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -61,25 +61,25 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return self |
63 | 63 | */ |
64 | - public function with_wp_dice( bool $include_default_rules = false ): self { |
|
64 | + public function with_wp_dice(bool $include_default_rules = false): self { |
|
65 | 65 | $loader = new Hook_Loader(); |
66 | 66 | |
67 | 67 | // Setup DI Container |
68 | - $container = PinkCrab_Dice::withDice( new Dice() ); |
|
68 | + $container = PinkCrab_Dice::withDice(new Dice()); |
|
69 | 69 | |
70 | - if ( $include_default_rules === true ) { |
|
71 | - $container->addRules( $this->default_di_rules() ); |
|
70 | + if ($include_default_rules === true) { |
|
71 | + $container->addRules($this->default_di_rules()); |
|
72 | 72 | } |
73 | 73 | |
74 | - $this->app->set_container( $container ); |
|
74 | + $this->app->set_container($container); |
|
75 | 75 | |
76 | 76 | // Set registration middleware |
77 | - $this->app->set_registration_services( new Registration_Service() ); |
|
77 | + $this->app->set_registration_services(new Registration_Service()); |
|
78 | 78 | |
79 | - $this->app->set_loader( $loader ); |
|
79 | + $this->app->set_loader($loader); |
|
80 | 80 | |
81 | 81 | // Include Hookable. |
82 | - $this->app->registration_middleware( new Hookable_Middleware() ); |
|
82 | + $this->app->registration_middleware(new Hookable_Middleware()); |
|
83 | 83 | |
84 | 84 | return $this; |
85 | 85 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | return array( |
95 | 95 | '*' => array( |
96 | 96 | 'substitutions' => array( |
97 | - Renderable::class => new PHP_Engine( $this->base_path ), |
|
97 | + Renderable::class => new PHP_Engine($this->base_path), |
|
98 | 98 | ), |
99 | 99 | ), |
100 | 100 | ); |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | * @param array<string,array<string,string|object|callable|null|false|\Closure>> $rules |
107 | 107 | * @return self |
108 | 108 | */ |
109 | - public function di_rules( array $rules ): self { |
|
109 | + public function di_rules(array $rules): self { |
|
110 | 110 | $this->app->container_config( |
111 | - function( DI_Container $container ) use ( $rules ): void { |
|
112 | - $container->addRules( $rules ); |
|
111 | + function(DI_Container $container) use ($rules): void { |
|
112 | + $container->addRules($rules); |
|
113 | 113 | } |
114 | 114 | ); |
115 | 115 | return $this; |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @param array<int, string> $class_list Array of fully namespaced class names. |
122 | 122 | * @return self |
123 | 123 | */ |
124 | - public function registration_classes( array $class_list ): self { |
|
125 | - $this->app->registration_classes( $class_list ); |
|
124 | + public function registration_classes(array $class_list): self { |
|
125 | + $this->app->registration_classes($class_list); |
|
126 | 126 | return $this; |
127 | 127 | } |
128 | 128 | |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * @param array<string, mixed> $app_config |
133 | 133 | * @return self |
134 | 134 | */ |
135 | - public function app_config( array $app_config ): self { |
|
136 | - $this->app->set_app_config( array_merge( $this->default_config_paths(), $app_config ) ); |
|
135 | + public function app_config(array $app_config): self { |
|
136 | + $this->app->set_app_config(array_merge($this->default_config_paths(), $app_config)); |
|
137 | 137 | return $this; |
138 | 138 | } |
139 | 139 | |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function boot(): App { |
155 | 155 | // Sets default settings if not already set. |
156 | - if ( ! $this->app->has_app_config() ) { |
|
157 | - $this->app_config( $this->default_config_paths() ); |
|
156 | + if ( ! $this->app->has_app_config()) { |
|
157 | + $this->app_config($this->default_config_paths()); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | return $this->app->boot(); |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | |
186 | 186 | return array( |
187 | 187 | 'path' => array( |
188 | - 'plugin' => rtrim( $this->base_path, \DIRECTORY_SEPARATOR ), |
|
189 | - 'view' => rtrim( $this->base_path, \DIRECTORY_SEPARATOR ) . '/views', |
|
190 | - 'assets' => rtrim( $this->base_path, \DIRECTORY_SEPARATOR ) . '/assets', |
|
188 | + 'plugin' => rtrim($this->base_path, \DIRECTORY_SEPARATOR), |
|
189 | + 'view' => rtrim($this->base_path, \DIRECTORY_SEPARATOR) . '/views', |
|
190 | + 'assets' => rtrim($this->base_path, \DIRECTORY_SEPARATOR) . '/assets', |
|
191 | 191 | 'upload_root' => $wp_uploads['basedir'], |
192 | 192 | 'upload_current' => $wp_uploads['path'], |
193 | 193 | ), |
194 | 194 | 'url' => array( |
195 | - 'plugin' => rtrim( plugins_url( basename( $this->base_path ) ), \DIRECTORY_SEPARATOR ), |
|
196 | - 'view' => rtrim( plugins_url( basename( $this->base_path ) ), \DIRECTORY_SEPARATOR ) . '/views', |
|
197 | - 'assets' => rtrim( plugins_url( basename( $this->base_path ) ), \DIRECTORY_SEPARATOR ) . '/assets', |
|
195 | + 'plugin' => rtrim(plugins_url(basename($this->base_path)), \DIRECTORY_SEPARATOR), |
|
196 | + 'view' => rtrim(plugins_url(basename($this->base_path)), \DIRECTORY_SEPARATOR) . '/views', |
|
197 | + 'assets' => rtrim(plugins_url(basename($this->base_path)), \DIRECTORY_SEPARATOR) . '/assets', |
|
198 | 198 | 'upload_root' => $wp_uploads['baseurl'], |
199 | 199 | 'upload_current' => $wp_uploads['url'], |
200 | 200 | ), |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | * @return self |
209 | 209 | * @throws App_Initialization_Exception Code 3 |
210 | 210 | */ |
211 | - public function registration_middleware( Registration_Middleware $middleware ): self { |
|
212 | - $this->app->registration_middleware( $middleware ); |
|
211 | + public function registration_middleware(Registration_Middleware $middleware): self { |
|
212 | + $this->app->registration_middleware($middleware); |
|
213 | 213 | return $this; |
214 | 214 | } |
215 | 215 | |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | * @throws App_Initialization_Exception Code 1 If DI container not registered |
223 | 223 | * @throws App_Initialization_Exception Code 9 If class doesn't create as middleware. |
224 | 224 | */ |
225 | - public function construct_registration_middleware( string $class_name ): self { |
|
226 | - $this->app->construct_registration_middleware( $class_name ); |
|
225 | + public function construct_registration_middleware(string $class_name): self { |
|
226 | + $this->app->construct_registration_middleware($class_name); |
|
227 | 227 | return $this; |
228 | 228 | } |
229 | 229 | } |
@@ -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,5 +59,5 @@ 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 | } |