@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types=1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * The BladeOne Module for Perique. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param string $template_path |
58 | 58 | * @return self |
59 | 59 | */ |
60 | - public function template_path( string $template_path ): self { |
|
60 | + public function template_path(string $template_path): self { |
|
61 | 61 | $this->template_path = $template_path; |
62 | 62 | return $this; |
63 | 63 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param string $compiled_path |
69 | 69 | * @return self |
70 | 70 | */ |
71 | - public function compiled_path( string $compiled_path ): self { |
|
71 | + public function compiled_path(string $compiled_path): self { |
|
72 | 72 | $this->compiled_path = $compiled_path; |
73 | 73 | return $this; |
74 | 74 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param integer $mode |
80 | 80 | * @return self |
81 | 81 | */ |
82 | - public function mode( int $mode ): self { |
|
82 | + public function mode(int $mode): self { |
|
83 | 83 | $this->mode = $mode; |
84 | 84 | return $this; |
85 | 85 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param integer $comment_mode |
91 | 91 | * @return self |
92 | 92 | */ |
93 | - public function comment_mode( int $comment_mode ): self { |
|
93 | + public function comment_mode(int $comment_mode): self { |
|
94 | 94 | $this->comment_mode = $comment_mode; |
95 | 95 | return $this; |
96 | 96 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param \Closure(BladeOne_Engine):BladeOne_Engine $config |
102 | 102 | * @return self |
103 | 103 | */ |
104 | - public function config( \Closure $config ): self { |
|
104 | + public function config(\Closure $config): self { |
|
105 | 105 | $this->config = $config; |
106 | 106 | return $this; |
107 | 107 | } |
@@ -115,25 +115,25 @@ discard block |
||
115 | 115 | * @pram DI_Container $di_container |
116 | 116 | * @return void |
117 | 117 | */ |
118 | - public function pre_boot( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
118 | + public function pre_boot(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
119 | 119 | // @codeCoverageIgnoreStart |
120 | - if ( ! function_exists( 'WP_Filesystem' ) ) { |
|
120 | + if ( ! function_exists('WP_Filesystem')) { |
|
121 | 121 | // @phpstan-ignore-next-line |
122 | - require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
122 | + require_once ABSPATH.'wp-admin/includes/file.php'; |
|
123 | 123 | } |
124 | 124 | // @codeCoverageIgnoreEnd |
125 | 125 | \WP_Filesystem(); |
126 | 126 | global $wp_filesystem; |
127 | 127 | |
128 | 128 | // If we dont have an instance of the WP_Filesystem, throw an exception. |
129 | - if ( ! $wp_filesystem instanceof \WP_Filesystem_Base ) { |
|
129 | + if ( ! $wp_filesystem instanceof \WP_Filesystem_Base) { |
|
130 | 130 | // @codeCoverageIgnoreStart |
131 | - throw new \RuntimeException( 'Unable to create WP_Filesystem instance' ); |
|
131 | + throw new \RuntimeException('Unable to create WP_Filesystem instance'); |
|
132 | 132 | // @codeCoverageIgnoreEnd |
133 | 133 | } |
134 | 134 | |
135 | 135 | $wp_upload_dir = wp_upload_dir(); |
136 | - $compiled_path = $this->compiled_path ?? sprintf( '%1$s%2$sblade-cache', $wp_upload_dir['basedir'], \DIRECTORY_SEPARATOR ); // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
136 | + $compiled_path = $this->compiled_path ?? sprintf('%1$s%2$sblade-cache', $wp_upload_dir['basedir'], \DIRECTORY_SEPARATOR); // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
137 | 137 | $instance = new PinkCrab_BladeOne( |
138 | 138 | $this->template_path ?? $config->view_path(), |
139 | 139 | $compiled_path, |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | $this->comment_mode |
142 | 142 | ); |
143 | 143 | |
144 | - $instance->setAuth( ...$this->get_auth_data() ); |
|
144 | + $instance->setAuth(...$this->get_auth_data()); |
|
145 | 145 | |
146 | 146 | // Create the compiled path if it does not exist. |
147 | - if ( ! $wp_filesystem->exists( $compiled_path ) ) { |
|
147 | + if ( ! $wp_filesystem->exists($compiled_path)) { |
|
148 | 148 | |
149 | 149 | // Create the directory. |
150 | - $wp_filesystem->mkdir( $compiled_path ); // phpcs:ignore WordPress.VIP.MkdirPermissions |
|
150 | + $wp_filesystem->mkdir($compiled_path); // phpcs:ignore WordPress.VIP.MkdirPermissions |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $di_container->addRule( |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $instance, |
158 | 158 | ), |
159 | 159 | 'call' => array( |
160 | - array( 'allow_pipe', array() ), |
|
160 | + array('allow_pipe', array()), |
|
161 | 161 | ), |
162 | 162 | 'shared' => true, |
163 | 163 | ) |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | private function get_auth_data(): array { |
191 | 191 | |
192 | 192 | // @codeCoverageIgnoreStart |
193 | - if ( ! function_exists( 'wp_get_current_user' ) ) { |
|
193 | + if ( ! function_exists('wp_get_current_user')) { |
|
194 | 194 | // @phpstan-ignore-next-line |
195 | - require_once ABSPATH . 'wp-includes/pluggable.php'; |
|
195 | + require_once ABSPATH.'wp-includes/pluggable.php'; |
|
196 | 196 | } |
197 | 197 | // @codeCoverageIgnoreEnd |
198 | 198 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | return array( |
201 | 201 | 0 !== $user->ID ? $user->user_login : '', |
202 | 202 | 0 !== $user->ID ? $user->roles[0] : '', |
203 | - 0 !== $user->ID ? array_keys( array_filter( $user->allcaps ) ) : array(), |
|
203 | + 0 !== $user->ID ? array_keys(array_filter($user->allcaps)) : array(), |
|
204 | 204 | ); |
205 | 205 | } |
206 | 206 | |
@@ -212,18 +212,18 @@ discard block |
||
212 | 212 | * @pram DI_Container $di_container |
213 | 213 | * @return void |
214 | 214 | */ |
215 | - public function pre_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
215 | + public function pre_register(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
216 | 216 | |
217 | - $provider = $di_container->create( BladeOne_Engine::class ); |
|
217 | + $provider = $di_container->create(BladeOne_Engine::class); |
|
218 | 218 | |
219 | 219 | // If dont have an instance of BladeOne_Engine, return. |
220 | - if ( ! $provider instanceof BladeOne_Engine ) { |
|
221 | - throw new \RuntimeException( 'Unable to create BladeOne_Engine instance to configure instance' ); |
|
220 | + if ( ! $provider instanceof BladeOne_Engine) { |
|
221 | + throw new \RuntimeException('Unable to create BladeOne_Engine instance to configure instance'); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | // Pass the config to the provider, if set. |
225 | - if ( ! is_null( $this->config ) ) { |
|
226 | - \call_user_func( $this->config, $provider ); |
|
225 | + if ( ! is_null($this->config)) { |
|
226 | + \call_user_func($this->config, $provider); |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @return void |
241 | 241 | */ |
242 | - public function post_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
242 | + public function post_register(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
243 | 243 | |
244 | 244 | /** |
245 | 245 | * Unused method. |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types=1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Wrapper for BladeOne with HTML enabled |
@@ -55,19 +55,19 @@ discard block |
||
55 | 55 | * @param integer $mode =[BladeOne::MODE_AUTO,BladeOne::MODE_DEBUG,BladeOne::MODE_FAST,BladeOne::MODE_SLOW][$i] |
56 | 56 | * @param integer $comment_mode =[BladeOne::COMMENT_PHP,BladeOne::COMMENT_RAW,BladeOne::COMMENT_NONE][$i] |
57 | 57 | */ |
58 | - public function __construct( $template_path = null, $compiled_path = null, $mode = 0, $comment_mode = 0 ) { |
|
59 | - parent::__construct( $template_path, $compiled_path, $mode, $comment_mode ); |
|
58 | + public function __construct($template_path = null, $compiled_path = null, $mode = 0, $comment_mode = 0) { |
|
59 | + parent::__construct($template_path, $compiled_path, $mode, $comment_mode); |
|
60 | 60 | |
61 | 61 | // Add the viewModel directive. |
62 | - $this->directiveRT( 'viewModel', fn( $expression ) => $this->view_model( $expression, true ) ); |
|
62 | + $this->directiveRT('viewModel', fn($expression) => $this->view_model($expression, true)); |
|
63 | 63 | |
64 | 64 | // Add the component directive. |
65 | - $this->directiveRT( 'viewComponent', fn( $expression ) => $this->component( $expression, true ) ); |
|
65 | + $this->directiveRT('viewComponent', fn($expression) => $this->component($expression, true)); |
|
66 | 66 | |
67 | 67 | // Add the WP_Nonce directive. |
68 | 68 | $this->directiveRT( |
69 | 69 | 'nonce', |
70 | - function ( string $action, ?string $field = null, bool $inc_referer = true ): void { |
|
70 | + function(string $action, ?string $field = null, bool $inc_referer = true): void { |
|
71 | 71 | \wp_nonce_field( |
72 | 72 | $action, |
73 | 73 | $field ?? '_pcnonce', |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | ); |
79 | 79 | |
80 | 80 | // Allow other plugins to add their own directives. |
81 | - \do_action( self::SETUP_CONFIG, $this ); |
|
81 | + \do_action(self::SETUP_CONFIG, $this); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | * @param string $esc_function |
103 | 103 | * @return void |
104 | 104 | */ |
105 | - public function set_esc_function( string $esc_function ): void { |
|
105 | + public function set_esc_function(string $esc_function): void { |
|
106 | 106 | // Throw exception if not a valid callable. |
107 | - if ( ! \is_callable( $esc_function ) ) { |
|
108 | - throw new \InvalidArgumentException( 'Invalid esc function provided.' ); |
|
107 | + if ( ! \is_callable($esc_function)) { |
|
108 | + throw new \InvalidArgumentException('Invalid esc function provided.'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | static::$esc_function = $esc_function; |
112 | - $this->echoFormat = sprintf( '\\%s(%%s)', $esc_function ); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
112 | + $this->echoFormat = sprintf('\\%s(%%s)', $esc_function); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | * @param integer|float|string|null|mixed[]|object $value |
128 | 128 | * @return string |
129 | 129 | */ |
130 | - public static function e( $value ): string { |
|
131 | - if ( \is_null( $value ) ) { |
|
130 | + public static function e($value): string { |
|
131 | + if (\is_null($value)) { |
|
132 | 132 | return ''; |
133 | 133 | } |
134 | - if ( \is_array( $value ) || \is_object( $value ) ) { |
|
135 | - return \call_user_func( static::$esc_function, \print_r( $value, true ) );//phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r |
|
134 | + if (\is_array($value) || \is_object($value)) { |
|
135 | + return \call_user_func(static::$esc_function, \print_r($value, true)); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r |
|
136 | 136 | } |
137 | - if ( \is_numeric( $value ) ) { |
|
137 | + if (\is_numeric($value)) { |
|
138 | 138 | $value = (string) $value; |
139 | 139 | } |
140 | - return \call_user_func( static::$esc_function, $value ); |
|
140 | + return \call_user_func(static::$esc_function, $value); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return string|void |
150 | 150 | */ |
151 | - public function component( Component $component, bool $print_mode = true ) { |
|
151 | + public function component(Component $component, bool $print_mode = true) { |
|
152 | 152 | /** |
153 | 153 | * Creates a new instance of the view. |
154 | 154 | * |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | $view = App::view(); |
158 | 158 | |
159 | - return $view->component( $component, $print_mode ); |
|
159 | + return $view->component($component, $print_mode); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return string|void |
169 | 169 | */ |
170 | - public function view_model( View_Model $view_model, bool $print_mode = true ) { |
|
170 | + public function view_model(View_Model $view_model, bool $print_mode = true) { |
|
171 | 171 | /** |
172 | 172 | * Creates a new instance of the view. |
173 | 173 | * |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | $view = App::view(); |
177 | 177 | |
178 | - return $view->view_model( $view_model, $print_mode ); |
|
178 | + return $view->view_model($view_model, $print_mode); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | * @param string $expression |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - protected function compileAuth( $expression = '' ): string { |
|
188 | - $role = $this->stripParentheses( $expression ); |
|
189 | - if ( $role === '' ) { |
|
190 | - return $this->phpTag . 'if(!PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
187 | + protected function compileAuth($expression = ''): string { |
|
188 | + $role = $this->stripParentheses($expression); |
|
189 | + if ($role === '') { |
|
190 | + return $this->phpTag.'if(!PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
191 | 191 | } |
192 | 192 | |
193 | - return $this->phpTag . "if(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; |
|
193 | + return $this->phpTag."if(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | * @param string $expression |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - protected function compileElseAuth( $expression = '' ): string { |
|
203 | - $role = $this->stripParentheses( $expression ); |
|
204 | - if ( $role === '' ) { |
|
205 | - return $this->phpTag . 'else: ?>'; |
|
202 | + protected function compileElseAuth($expression = ''): string { |
|
203 | + $role = $this->stripParentheses($expression); |
|
204 | + if ($role === '') { |
|
205 | + return $this->phpTag.'else: ?>'; |
|
206 | 206 | } |
207 | 207 | |
208 | - return $this->phpTag . "elseif(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; |
|
208 | + return $this->phpTag."elseif(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -214,18 +214,18 @@ discard block |
||
214 | 214 | * @param string|null $expression |
215 | 215 | * @return string |
216 | 216 | */ |
217 | - protected function compileGuest( $expression = null ): string { |
|
217 | + protected function compileGuest($expression = null): string { |
|
218 | 218 | |
219 | - if ( $expression === null ) { |
|
220 | - return $this->phpTag . 'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
219 | + if ($expression === null) { |
|
220 | + return $this->phpTag.'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
221 | 221 | } |
222 | 222 | |
223 | - $role = $this->stripParentheses( $expression ); |
|
224 | - if ( $role === '' ) { |
|
225 | - return $this->phpTag . 'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
223 | + $role = $this->stripParentheses($expression); |
|
224 | + if ($role === '') { |
|
225 | + return $this->phpTag.'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
226 | 226 | } |
227 | 227 | |
228 | - return $this->phpTag . "if(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; |
|
228 | + return $this->phpTag."if(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -234,13 +234,13 @@ discard block |
||
234 | 234 | * @param string|null $expression |
235 | 235 | * @return string |
236 | 236 | */ |
237 | - protected function compileElseGuest( $expression ): string { |
|
238 | - $role = $this->stripParentheses( $expression ); |
|
239 | - if ( $role === '' ) { |
|
240 | - return $this->phpTag . 'else: ?>'; |
|
237 | + protected function compileElseGuest($expression): string { |
|
238 | + $role = $this->stripParentheses($expression); |
|
239 | + if ($role === '') { |
|
240 | + return $this->phpTag.'else: ?>'; |
|
241 | 241 | } |
242 | 242 | |
243 | - return $this->phpTag . "elseif(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; |
|
243 | + return $this->phpTag."elseif(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |