@@ -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. |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param string $template_path |
| 57 | 57 | * @return self |
| 58 | 58 | */ |
| 59 | - public function template_path( string $template_path ): self { |
|
| 59 | + public function template_path(string $template_path): self { |
|
| 60 | 60 | $this->template_path = $template_path; |
| 61 | 61 | return $this; |
| 62 | 62 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param string $compiled_path |
| 68 | 68 | * @return self |
| 69 | 69 | */ |
| 70 | - public function compiled_path( string $compiled_path ): self { |
|
| 70 | + public function compiled_path(string $compiled_path): self { |
|
| 71 | 71 | $this->compiled_path = $compiled_path; |
| 72 | 72 | return $this; |
| 73 | 73 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param integer $mode |
| 79 | 79 | * @return self |
| 80 | 80 | */ |
| 81 | - public function mode( int $mode ): self { |
|
| 81 | + public function mode(int $mode): self { |
|
| 82 | 82 | $this->mode = $mode; |
| 83 | 83 | return $this; |
| 84 | 84 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @param \Closure(BladeOne_Engine):BladeOne_Engine $config |
| 90 | 90 | * @return self |
| 91 | 91 | */ |
| 92 | - public function config( \Closure $config ): self { |
|
| 92 | + public function config(\Closure $config): self { |
|
| 93 | 93 | $this->config = $config; |
| 94 | 94 | return $this; |
| 95 | 95 | } |
@@ -103,38 +103,38 @@ discard block |
||
| 103 | 103 | * @pram DI_Container $di_container |
| 104 | 104 | * @return void |
| 105 | 105 | */ |
| 106 | - public function pre_boot( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 106 | + public function pre_boot(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 107 | 107 | // @codeCoverageIgnoreStart |
| 108 | - if ( ! function_exists( 'WP_Filesystem' ) ) { |
|
| 108 | + if ( ! function_exists('WP_Filesystem')) { |
|
| 109 | 109 | // @phpstan-ignore-next-line |
| 110 | - require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
| 110 | + require_once ABSPATH.'wp-admin/includes/file.php'; |
|
| 111 | 111 | } |
| 112 | 112 | // @codeCoverageIgnoreEnd |
| 113 | 113 | \WP_Filesystem(); |
| 114 | 114 | global $wp_filesystem; |
| 115 | 115 | |
| 116 | 116 | // If we dont have an instance of the WP_Filesystem, throw an exception. |
| 117 | - if ( ! $wp_filesystem instanceof \WP_Filesystem_Base ) { |
|
| 117 | + if ( ! $wp_filesystem instanceof \WP_Filesystem_Base) { |
|
| 118 | 118 | // @codeCoverageIgnoreStart |
| 119 | - throw new \RuntimeException( 'Unable to create WP_Filesystem instance' ); |
|
| 119 | + throw new \RuntimeException('Unable to create WP_Filesystem instance'); |
|
| 120 | 120 | // @codeCoverageIgnoreEnd |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $wp_upload_dir = wp_upload_dir(); |
| 124 | - $compiled_path = $this->compiled_path ?? sprintf( '%1$s%2$sblade-cache', $wp_upload_dir['basedir'], \DIRECTORY_SEPARATOR ); // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 124 | + $compiled_path = $this->compiled_path ?? sprintf('%1$s%2$sblade-cache', $wp_upload_dir['basedir'], \DIRECTORY_SEPARATOR); // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 125 | 125 | $instance = new PinkCrab_BladeOne( |
| 126 | - $this->template_path ?? $config->path( 'view' ), |
|
| 126 | + $this->template_path ?? $config->path('view'), |
|
| 127 | 127 | $compiled_path, |
| 128 | 128 | $this->mode |
| 129 | 129 | ); |
| 130 | 130 | |
| 131 | - $instance->setAuth( ...$this->get_auth_data() ); |
|
| 131 | + $instance->setAuth(...$this->get_auth_data()); |
|
| 132 | 132 | |
| 133 | 133 | // Create the compiled path if it does not exist. |
| 134 | - if ( ! $wp_filesystem->exists( $compiled_path ) ) { |
|
| 134 | + if ( ! $wp_filesystem->exists($compiled_path)) { |
|
| 135 | 135 | |
| 136 | 136 | // Create the directory. |
| 137 | - $wp_filesystem->mkdir( $compiled_path ); // phpcs:ignore WordPress.VIP.MkdirPermissions |
|
| 137 | + $wp_filesystem->mkdir($compiled_path); // phpcs:ignore WordPress.VIP.MkdirPermissions |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | $di_container->addRule( |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $instance, |
| 145 | 145 | ), |
| 146 | 146 | 'call' => array( |
| 147 | - array( 'allow_pipe', array() ), |
|
| 147 | + array('allow_pipe', array()), |
|
| 148 | 148 | ), |
| 149 | 149 | 'shared' => true, |
| 150 | 150 | ) |
@@ -177,9 +177,9 @@ discard block |
||
| 177 | 177 | private function get_auth_data(): array { |
| 178 | 178 | |
| 179 | 179 | // @codeCoverageIgnoreStart |
| 180 | - if ( ! function_exists( 'wp_get_current_user' ) ) { |
|
| 180 | + if ( ! function_exists('wp_get_current_user')) { |
|
| 181 | 181 | // @phpstan-ignore-next-line |
| 182 | - require_once ABSPATH . 'wp-includes/pluggable.php'; |
|
| 182 | + require_once ABSPATH.'wp-includes/pluggable.php'; |
|
| 183 | 183 | } |
| 184 | 184 | // @codeCoverageIgnoreEnd |
| 185 | 185 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | return array( |
| 188 | 188 | 0 !== $user->ID ? $user->user_login : '', |
| 189 | 189 | 0 !== $user->ID ? $user->roles[0] : '', |
| 190 | - 0 !== $user->ID ? array_keys( array_filter( $user->allcaps ) ) : array(), |
|
| 190 | + 0 !== $user->ID ? array_keys(array_filter($user->allcaps)) : array(), |
|
| 191 | 191 | ); |
| 192 | 192 | } |
| 193 | 193 | |
@@ -199,18 +199,18 @@ discard block |
||
| 199 | 199 | * @pram DI_Container $di_container |
| 200 | 200 | * @return void |
| 201 | 201 | */ |
| 202 | - public function pre_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 202 | + public function pre_register(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 203 | 203 | |
| 204 | - $provider = $di_container->create( BladeOne_Engine::class ); |
|
| 204 | + $provider = $di_container->create(BladeOne_Engine::class); |
|
| 205 | 205 | |
| 206 | 206 | // If dont have an instance of BladeOne_Engine, return. |
| 207 | - if ( ! $provider instanceof BladeOne_Engine ) { |
|
| 208 | - throw new \RuntimeException( 'Unable to create BladeOne_Engine instance to configure instance' ); |
|
| 207 | + if ( ! $provider instanceof BladeOne_Engine) { |
|
| 208 | + throw new \RuntimeException('Unable to create BladeOne_Engine instance to configure instance'); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | // Pass the config to the provider, if set. |
| 212 | - if ( ! is_null( $this->config ) ) { |
|
| 213 | - \call_user_func( $this->config, $provider ); |
|
| 212 | + if ( ! is_null($this->config)) { |
|
| 213 | + \call_user_func($this->config, $provider); |
|
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @return void |
| 228 | 228 | */ |
| 229 | - public function post_register( App_Config $config, Hook_Loader $loader, DI_Container $di_container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 229 | + public function post_register(App_Config $config, Hook_Loader $loader, DI_Container $di_container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * 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 |
@@ -49,19 +49,19 @@ discard block |
||
| 49 | 49 | * @param string $compiled_path If null then it uses (caller_folder)/compiles |
| 50 | 50 | * @param integer $mode =[BladeOne::MODE_AUTO,BladeOne::MODE_DEBUG,BladeOne::MODE_FAST,BladeOne::MODE_SLOW][$i] |
| 51 | 51 | */ |
| 52 | - public function __construct( $template_path = null, $compiled_path = null, $mode = 0 ) { |
|
| 53 | - parent::__construct( $template_path, $compiled_path, $mode ); |
|
| 52 | + public function __construct($template_path = null, $compiled_path = null, $mode = 0) { |
|
| 53 | + parent::__construct($template_path, $compiled_path, $mode); |
|
| 54 | 54 | |
| 55 | 55 | // Add the viewModel directive. |
| 56 | - $this->directiveRT( 'viewModel', fn( $expression ) => $this->view_model( $expression, true ) ); |
|
| 56 | + $this->directiveRT('viewModel', fn($expression) => $this->view_model($expression, true)); |
|
| 57 | 57 | |
| 58 | 58 | // Add the component directive. |
| 59 | - $this->directiveRT( 'viewComponent', fn( $expression ) => $this->component( $expression, true ) ); |
|
| 59 | + $this->directiveRT('viewComponent', fn($expression) => $this->component($expression, true)); |
|
| 60 | 60 | |
| 61 | 61 | // Add the WP_Nonce directive. |
| 62 | 62 | $this->directiveRT( |
| 63 | 63 | 'nonce', |
| 64 | - function ( string $action, ?string $field = null, bool $inc_referer = true ): void { |
|
| 64 | + function(string $action, ?string $field = null, bool $inc_referer = true): void { |
|
| 65 | 65 | \wp_nonce_field( |
| 66 | 66 | $action, |
| 67 | 67 | $field ?? '_pcnonce', |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | 74 | // Allow other plugins to add their own directives. |
| 75 | - \do_action( self::SETUP_CONFIG, $this ); |
|
| 75 | + \do_action(self::SETUP_CONFIG, $this); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | * @param string $esc_function |
| 97 | 97 | * @return void |
| 98 | 98 | */ |
| 99 | - public function set_esc_function( string $esc_function ): void { |
|
| 99 | + public function set_esc_function(string $esc_function): void { |
|
| 100 | 100 | // Throw exception if not a valid callable. |
| 101 | - if ( ! \is_callable( $esc_function ) ) { |
|
| 102 | - throw new \InvalidArgumentException( 'Invalid esc function provided.' ); |
|
| 101 | + if ( ! \is_callable($esc_function)) { |
|
| 102 | + throw new \InvalidArgumentException('Invalid esc function provided.'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | static::$esc_function = $esc_function; |
| 106 | - $this->echoFormat = sprintf( '\\%s(%%s)', $esc_function ); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 106 | + $this->echoFormat = sprintf('\\%s(%%s)', $esc_function); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -121,17 +121,17 @@ discard block |
||
| 121 | 121 | * @param integer|float|string|null|mixed[]|object $value |
| 122 | 122 | * @return string |
| 123 | 123 | */ |
| 124 | - public static function e( $value ): string { |
|
| 125 | - if ( \is_null( $value ) ) { |
|
| 124 | + public static function e($value): string { |
|
| 125 | + if (\is_null($value)) { |
|
| 126 | 126 | return ''; |
| 127 | 127 | } |
| 128 | - if ( \is_array( $value ) || \is_object( $value ) ) { |
|
| 129 | - return \call_user_func( static::$esc_function, \print_r( $value, true ) );//phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r |
|
| 128 | + if (\is_array($value) || \is_object($value)) { |
|
| 129 | + return \call_user_func(static::$esc_function, \print_r($value, true)); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r |
|
| 130 | 130 | } |
| 131 | - if ( \is_numeric( $value ) ) { |
|
| 131 | + if (\is_numeric($value)) { |
|
| 132 | 132 | $value = (string) $value; |
| 133 | 133 | } |
| 134 | - return \call_user_func( static::$esc_function, $value ); |
|
| 134 | + return \call_user_func(static::$esc_function, $value); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * @return string|void |
| 144 | 144 | */ |
| 145 | - public function component( Component $component, bool $print_mode = true ) { |
|
| 145 | + public function component(Component $component, bool $print_mode = true) { |
|
| 146 | 146 | /** |
| 147 | 147 | * Creates a new instance of the view. |
| 148 | 148 | * |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | $view = App::view(); |
| 152 | 152 | |
| 153 | - return $view->component( $component, $print_mode ); |
|
| 153 | + return $view->component($component, $print_mode); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * |
| 162 | 162 | * @return string|void |
| 163 | 163 | */ |
| 164 | - public function view_model( View_Model $view_model, bool $print_mode = true ) { |
|
| 164 | + public function view_model(View_Model $view_model, bool $print_mode = true) { |
|
| 165 | 165 | /** |
| 166 | 166 | * Creates a new instance of the view. |
| 167 | 167 | * |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | $view = App::view(); |
| 171 | 171 | |
| 172 | - return $view->view_model( $view_model, $print_mode ); |
|
| 172 | + return $view->view_model($view_model, $print_mode); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -178,13 +178,13 @@ discard block |
||
| 178 | 178 | * @param string $expression |
| 179 | 179 | * @return string |
| 180 | 180 | */ |
| 181 | - protected function compileAuth( $expression = '' ): string { |
|
| 182 | - $role = $this->stripParentheses( $expression ); |
|
| 183 | - if ( $role === '' ) { |
|
| 184 | - return $this->phpTag . 'if(!PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
| 181 | + protected function compileAuth($expression = ''): string { |
|
| 182 | + $role = $this->stripParentheses($expression); |
|
| 183 | + if ($role === '') { |
|
| 184 | + return $this->phpTag.'if(!PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - return $this->phpTag . "if(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; |
|
| 187 | + return $this->phpTag."if(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -193,13 +193,13 @@ discard block |
||
| 193 | 193 | * @param string $expression |
| 194 | 194 | * @return string |
| 195 | 195 | */ |
| 196 | - protected function compileElseAuth( $expression = '' ): string { |
|
| 197 | - $role = $this->stripParentheses( $expression ); |
|
| 198 | - if ( $role === '' ) { |
|
| 199 | - return $this->phpTag . 'else: ?>'; |
|
| 196 | + protected function compileElseAuth($expression = ''): string { |
|
| 197 | + $role = $this->stripParentheses($expression); |
|
| 198 | + if ($role === '') { |
|
| 199 | + return $this->phpTag.'else: ?>'; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - return $this->phpTag . "elseif(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; |
|
| 202 | + return $this->phpTag."elseif(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -208,18 +208,18 @@ discard block |
||
| 208 | 208 | * @param string|null $expression |
| 209 | 209 | * @return string |
| 210 | 210 | */ |
| 211 | - protected function compileGuest( $expression = null ): string { |
|
| 211 | + protected function compileGuest($expression = null): string { |
|
| 212 | 212 | |
| 213 | - if ( $expression === null ) { |
|
| 214 | - return $this->phpTag . 'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
| 213 | + if ($expression === null) { |
|
| 214 | + return $this->phpTag.'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - $role = $this->stripParentheses( $expression ); |
|
| 218 | - if ( $role === '' ) { |
|
| 219 | - return $this->phpTag . 'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
| 217 | + $role = $this->stripParentheses($expression); |
|
| 218 | + if ($role === '') { |
|
| 219 | + return $this->phpTag.'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - return $this->phpTag . "if(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; |
|
| 222 | + return $this->phpTag."if(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -228,12 +228,12 @@ discard block |
||
| 228 | 228 | * @param string|null $expression |
| 229 | 229 | * @return string |
| 230 | 230 | */ |
| 231 | - protected function compileElseGuest( $expression ): string { |
|
| 232 | - $role = $this->stripParentheses( $expression ); |
|
| 233 | - if ( $role === '' ) { |
|
| 234 | - return $this->phpTag . 'else: ?>'; |
|
| 231 | + protected function compileElseGuest($expression): string { |
|
| 232 | + $role = $this->stripParentheses($expression); |
|
| 233 | + if ($role === '') { |
|
| 234 | + return $this->phpTag.'else: ?>'; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - return $this->phpTag . "elseif(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; |
|
| 237 | + return $this->phpTag."elseif(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; |
|
| 238 | 238 | } |
| 239 | 239 | } |
@@ -150,13 +150,13 @@ |
||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | - * Renders a component. |
|
| 154 | - * |
|
| 155 | - * @param Component $component |
|
| 156 | - * @param boolean $print_mode If true it will print the view, if false it will return the view as a string. |
|
| 157 | - * |
|
| 158 | - * @return string|void |
|
| 159 | - */ |
|
| 153 | + * Renders a component. |
|
| 154 | + * |
|
| 155 | + * @param Component $component |
|
| 156 | + * @param boolean $print_mode If true it will print the view, if false it will return the view as a string. |
|
| 157 | + * |
|
| 158 | + * @return string|void |
|
| 159 | + */ |
|
| 160 | 160 | public function component( Component $component, bool $print_mode = true ) { |
| 161 | 161 | |
| 162 | 162 | // Throw exception of no compiler passed. |
@@ -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 | * Implementation of BladeOne for the PinkCrab Perique frameworks Renderable interface |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @param PinkCrab_BladeOne $blade |
| 61 | 61 | */ |
| 62 | - final public function __construct( PinkCrab_BladeOne $blade ) { |
|
| 62 | + final public function __construct(PinkCrab_BladeOne $blade) { |
|
| 63 | 63 | static::$blade = $blade; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | ?string $compiled_path = null, |
| 77 | 77 | int $mode = 0 |
| 78 | 78 | ): self { |
| 79 | - return new static( new PinkCrab_BladeOne( $template_path, $compiled_path, $mode ) ); |
|
| 79 | + return new static(new PinkCrab_BladeOne($template_path, $compiled_path, $mode)); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function base_view_path(): string { |
| 98 | 98 | $paths = static::$blade->get_template_paths(); |
| 99 | - return ! empty( $paths ) ? reset( $paths ) : ''; |
|
| 99 | + return ! empty($paths) ? reset($paths) : ''; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | * @param string $esc |
| 106 | 106 | * @return self |
| 107 | 107 | */ |
| 108 | - public function set_esc_function( string $esc ): self { |
|
| 109 | - static::$blade->set_esc_function( $esc ); |
|
| 108 | + public function set_esc_function(string $esc): self { |
|
| 109 | + static::$blade->set_esc_function($esc); |
|
| 110 | 110 | return $this; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @param Component_Compiler $compiler |
| 117 | 117 | * @return void |
| 118 | 118 | */ |
| 119 | - public function set_component_compiler( Component_Compiler $compiler ): void { |
|
| 119 | + public function set_component_compiler(Component_Compiler $compiler): void { |
|
| 120 | 120 | $this->component_compiler = $compiler; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return void|string |
| 131 | 131 | */ |
| 132 | - public function render( string $view, iterable $data, bool $print_mode = true ) { |
|
| 133 | - if ( $print_mode ) { |
|
| 134 | - print static::$blade->run( $view, (array) $data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 132 | + public function render(string $view, iterable $data, bool $print_mode = true) { |
|
| 133 | + if ($print_mode) { |
|
| 134 | + print static::$blade->run($view, (array) $data); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 135 | 135 | } else { |
| 136 | - return static::$blade->run( $view, (array) $data ); |
|
| 136 | + return static::$blade->run($view, (array) $data); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @return string|void |
| 147 | 147 | */ |
| 148 | - public function view_model( View_Model $view_model, bool $print_mode = true ) { |
|
| 149 | - return $this->render( str_replace( array( '/', '\\' ), '.', $view_model->template() ), $view_model->data(), $print_mode ); |
|
| 148 | + public function view_model(View_Model $view_model, bool $print_mode = true) { |
|
| 149 | + return $this->render(str_replace(array('/', '\\'), '.', $view_model->template()), $view_model->data(), $print_mode); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -157,16 +157,16 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @return string|void |
| 159 | 159 | */ |
| 160 | - public function component( Component $component, bool $print_mode = true ) { |
|
| 160 | + public function component(Component $component, bool $print_mode = true) { |
|
| 161 | 161 | |
| 162 | 162 | // Throw exception of no compiler passed. |
| 163 | - if ( null === $this->component_compiler ) { |
|
| 164 | - throw new Exception( 'No component compiler passed to BladeOne' ); |
|
| 163 | + if (null === $this->component_compiler) { |
|
| 164 | + throw new Exception('No component compiler passed to BladeOne'); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // Compile the component. |
| 168 | - $compiled = $this->component_compiler->compile( $component ); |
|
| 169 | - return $this->render( str_replace( array( '/', '\\' ), '.', $compiled->template() ), $compiled->data(), $print_mode ); |
|
| 168 | + $compiled = $this->component_compiler->compile($component); |
|
| 169 | + return $this->render(str_replace(array('/', '\\'), '.', $compiled->template()), $compiled->data(), $print_mode); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -177,12 +177,12 @@ discard block |
||
| 177 | 177 | * @return mixed |
| 178 | 178 | * @throws BadMethodCallException |
| 179 | 179 | */ |
| 180 | - public function __call( string $method, array $args = array() ) { |
|
| 181 | - if ( ! $this->is_method( $method ) ) { |
|
| 182 | - throw new BadMethodCallException( esc_attr( "{$method} is not a valid method on the BladeOne instance." ) ); |
|
| 180 | + public function __call(string $method, array $args = array()) { |
|
| 181 | + if ( ! $this->is_method($method)) { |
|
| 182 | + throw new BadMethodCallException(esc_attr("{$method} is not a valid method on the BladeOne instance.")); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - return static::$blade->{$method}( ...$args ); |
|
| 185 | + return static::$blade->{$method}(...$args); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | * @return mixed |
| 194 | 194 | * @throws BadMethodCallException |
| 195 | 195 | */ |
| 196 | - public static function __callStatic( string $method, array $args = array() ) { |
|
| 197 | - if ( ! static::is_static_method( $method ) ) { |
|
| 198 | - throw new BadMethodCallException( esc_attr( "{$method} is not a valid method on the BladeOne instance." ) ); |
|
| 196 | + public static function __callStatic(string $method, array $args = array()) { |
|
| 197 | + if ( ! static::is_static_method($method)) { |
|
| 198 | + throw new BadMethodCallException(esc_attr("{$method} is not a valid method on the BladeOne instance.")); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - return static::$blade::{$method}( ...$args ); |
|
| 201 | + return static::$blade::{$method}(...$args); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -207,15 +207,15 @@ discard block |
||
| 207 | 207 | * @param string $method |
| 208 | 208 | * @return boolean |
| 209 | 209 | */ |
| 210 | - protected function is_method( string $method ): bool { |
|
| 211 | - $class_reflection = new ReflectionClass( static::$blade ); |
|
| 210 | + protected function is_method(string $method): bool { |
|
| 211 | + $class_reflection = new ReflectionClass(static::$blade); |
|
| 212 | 212 | |
| 213 | 213 | // Check method exists. |
| 214 | - if ( ! $class_reflection->hasMethod( $method ) ) { |
|
| 214 | + if ( ! $class_reflection->hasMethod($method)) { |
|
| 215 | 215 | return false; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - $method_reflection = $class_reflection->getMethod( $method ); |
|
| 218 | + $method_reflection = $class_reflection->getMethod($method); |
|
| 219 | 219 | |
| 220 | 220 | return $method_reflection->isPublic() && ! $method_reflection->isStatic(); |
| 221 | 221 | } |
@@ -226,15 +226,15 @@ discard block |
||
| 226 | 226 | * @param string $method |
| 227 | 227 | * @return boolean |
| 228 | 228 | */ |
| 229 | - protected static function is_static_method( string $method ): bool { |
|
| 230 | - $class_reflection = new ReflectionClass( static::$blade ); |
|
| 229 | + protected static function is_static_method(string $method): bool { |
|
| 230 | + $class_reflection = new ReflectionClass(static::$blade); |
|
| 231 | 231 | |
| 232 | 232 | // Check method exists. |
| 233 | - if ( ! $class_reflection->hasMethod( $method ) ) { |
|
| 233 | + if ( ! $class_reflection->hasMethod($method)) { |
|
| 234 | 234 | return false; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $method_reflection = $class_reflection->getMethod( $method ); |
|
| 237 | + $method_reflection = $class_reflection->getMethod($method); |
|
| 238 | 238 | return $method_reflection->isPublic() && $method_reflection->isStatic(); |
| 239 | 239 | } |
| 240 | 240 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * @param boolean $allow_pipe |
| 245 | 245 | * @return self |
| 246 | 246 | */ |
| 247 | - public function allow_pipe( bool $allow_pipe = true ): self { |
|
| 247 | + public function allow_pipe(bool $allow_pipe = true): self { |
|
| 248 | 248 | static::$blade->pipeEnable = $allow_pipe; //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
| 249 | 249 | return $this; |
| 250 | 250 | } |
@@ -256,8 +256,8 @@ discard block |
||
| 256 | 256 | * @param callable $handler |
| 257 | 257 | * @return self |
| 258 | 258 | */ |
| 259 | - public function directive( string $name, callable $handler ): self { |
|
| 260 | - static::$blade->directive( $name, $handler ); |
|
| 259 | + public function directive(string $name, callable $handler): self { |
|
| 260 | + static::$blade->directive($name, $handler); |
|
| 261 | 261 | return $this; |
| 262 | 262 | } |
| 263 | 263 | |
@@ -268,8 +268,8 @@ discard block |
||
| 268 | 268 | * @param callable $handler |
| 269 | 269 | * @return self |
| 270 | 270 | */ |
| 271 | - public function directive_rt( $name, callable $handler ): self { |
|
| 272 | - static::$blade->directiveRT( $name, $handler ); |
|
| 271 | + public function directive_rt($name, callable $handler): self { |
|
| 272 | + static::$blade->directiveRT($name, $handler); |
|
| 273 | 273 | return $this; |
| 274 | 274 | } |
| 275 | 275 | |
@@ -280,8 +280,8 @@ discard block |
||
| 280 | 280 | * @param string|null $alias example "mynewop". If null then it uses the name of the template. |
| 281 | 281 | * @return self |
| 282 | 282 | */ |
| 283 | - public function add_include( $view, $alias = null ): self { |
|
| 284 | - static::$blade->addInclude( $view, $alias ); |
|
| 283 | + public function add_include($view, $alias = null): self { |
|
| 284 | + static::$blade->addInclude($view, $alias); |
|
| 285 | 285 | return $this; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -292,8 +292,8 @@ discard block |
||
| 292 | 292 | * @param string $class_with_namespace |
| 293 | 293 | * @return self |
| 294 | 294 | */ |
| 295 | - public function add_alias_classes( $alias_name, $class_with_namespace ): self { |
|
| 296 | - static::$blade->addAliasClasses( $alias_name, $class_with_namespace ); |
|
| 295 | + public function add_alias_classes($alias_name, $class_with_namespace): self { |
|
| 296 | + static::$blade->addAliasClasses($alias_name, $class_with_namespace); |
|
| 297 | 297 | return $this; |
| 298 | 298 | } |
| 299 | 299 | |
@@ -303,8 +303,8 @@ discard block |
||
| 303 | 303 | * @param integer $mode BladeOne::MODE_AUTO, BladeOne::MODE_DEBUG, BladeOne::MODE_FAST, BladeOne::MODE_SLOW |
| 304 | 304 | * @return self |
| 305 | 305 | */ |
| 306 | - public function set_mode( int $mode ): self { |
|
| 307 | - static::$blade->setMode( $mode ); |
|
| 306 | + public function set_mode(int $mode): self { |
|
| 307 | + static::$blade->setMode($mode); |
|
| 308 | 308 | return $this; |
| 309 | 309 | } |
| 310 | 310 | |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | * @param mixed $value |
| 323 | 323 | * @return $this |
| 324 | 324 | */ |
| 325 | - public function share( $var_name, $value = null ): self { |
|
| 326 | - static::$blade->share( $var_name, $value ); |
|
| 325 | + public function share($var_name, $value = null): self { |
|
| 326 | + static::$blade->share($var_name, $value); |
|
| 327 | 327 | return $this; |
| 328 | 328 | } |
| 329 | 329 | |
@@ -333,8 +333,8 @@ discard block |
||
| 333 | 333 | * @param callable $resolver |
| 334 | 334 | * @return $this |
| 335 | 335 | */ |
| 336 | - public function set_inject_resolver( callable $resolver ): self { |
|
| 337 | - static::$blade->setInjectResolver( $resolver ); |
|
| 336 | + public function set_inject_resolver(callable $resolver): self { |
|
| 337 | + static::$blade->setInjectResolver($resolver); |
|
| 338 | 338 | return $this; |
| 339 | 339 | } |
| 340 | 340 | |
@@ -345,8 +345,8 @@ discard block |
||
| 345 | 345 | * @param string $file_extension Example: .prefix.ext |
| 346 | 346 | * @return $this |
| 347 | 347 | */ |
| 348 | - public function set_file_extension( string $file_extension ): self { |
|
| 349 | - static::$blade->setFileExtension( $file_extension ); |
|
| 348 | + public function set_file_extension(string $file_extension): self { |
|
| 349 | + static::$blade->setFileExtension($file_extension); |
|
| 350 | 350 | return $this; |
| 351 | 351 | } |
| 352 | 352 | |
@@ -357,8 +357,8 @@ discard block |
||
| 357 | 357 | * @param string $file_extension |
| 358 | 358 | * @return $this |
| 359 | 359 | */ |
| 360 | - public function set_compiled_extension( string $file_extension ): self { |
|
| 361 | - static::$blade->setCompiledExtension( $file_extension ); |
|
| 360 | + public function set_compiled_extension(string $file_extension): self { |
|
| 361 | + static::$blade->setCompiledExtension($file_extension); |
|
| 362 | 362 | return $this; |
| 363 | 363 | } |
| 364 | 364 | } |