@@ -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 |
@@ -44,19 +44,19 @@ discard block |
||
44 | 44 | * @param string $compiled_path If null then it uses (caller_folder)/compiles |
45 | 45 | * @param int $mode =[BladeOne::MODE_AUTO,BladeOne::MODE_DEBUG,BladeOne::MODE_FAST,BladeOne::MODE_SLOW][$i] |
46 | 46 | */ |
47 | - public function __construct( $template_path = null, $compiled_path = null, $mode = 0 ) { |
|
48 | - parent::__construct( $template_path, $compiled_path, $mode ); |
|
47 | + public function __construct($template_path = null, $compiled_path = null, $mode = 0) { |
|
48 | + parent::__construct($template_path, $compiled_path, $mode); |
|
49 | 49 | |
50 | 50 | // Add the viewModel directive. |
51 | - $this->directiveRT( 'viewModel', fn( $expression ) => $this->view_model( $expression, true ) ); |
|
51 | + $this->directiveRT('viewModel', fn($expression) => $this->view_model($expression, true)); |
|
52 | 52 | |
53 | 53 | // Add the component directive. |
54 | - $this->directiveRT( 'viewComponent', fn( $expression ) => $this->component( $expression, true ) ); |
|
54 | + $this->directiveRT('viewComponent', fn($expression) => $this->component($expression, true)); |
|
55 | 55 | |
56 | 56 | // Add the WP_Nonce directive. |
57 | 57 | $this->directiveRT( |
58 | 58 | 'nonce', |
59 | - function( string $action, ?string $field = null, bool $inc_referer = true ): void { |
|
59 | + function(string $action, ?string $field = null, bool $inc_referer = true): void { |
|
60 | 60 | \wp_nonce_field( |
61 | 61 | $action, |
62 | 62 | $field ?? '_pcnonce', |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | * @param string $esc_function |
89 | 89 | * @return void |
90 | 90 | */ |
91 | - public function set_esc_function( string $esc_function ): void { |
|
91 | + public function set_esc_function(string $esc_function): void { |
|
92 | 92 | // Throw exception if not a valid callable. |
93 | - if ( ! \is_callable( $esc_function ) ) { |
|
94 | - throw new \InvalidArgumentException( 'Invalid esc function provided.' ); |
|
93 | + if ( ! \is_callable($esc_function)) { |
|
94 | + throw new \InvalidArgumentException('Invalid esc function provided.'); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | static::$esc_function = $esc_function; |
98 | - $this->echoFormat = sprintf( '\\%s(%%s)', $esc_function ); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
98 | + $this->echoFormat = sprintf('\\%s(%%s)', $esc_function); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | * @param int|float|string|null|mixed[]|object $value |
114 | 114 | * @return string |
115 | 115 | */ |
116 | - public static function e( $value ): string { |
|
117 | - if ( \is_null( $value ) ) { |
|
116 | + public static function e($value): string { |
|
117 | + if (\is_null($value)) { |
|
118 | 118 | return ''; |
119 | 119 | } |
120 | - if ( \is_array( $value ) || \is_object( $value ) ) { |
|
121 | - return \call_user_func( static::$esc_function, \print_r( $value, true ) );//phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r |
|
120 | + if (\is_array($value) || \is_object($value)) { |
|
121 | + return \call_user_func(static::$esc_function, \print_r($value, true)); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r |
|
122 | 122 | } |
123 | - if ( \is_numeric( $value ) ) { |
|
123 | + if (\is_numeric($value)) { |
|
124 | 124 | $value = (string) $value; |
125 | 125 | } |
126 | - return \call_user_func( static::$esc_function, $value ); |
|
126 | + return \call_user_func(static::$esc_function, $value); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | * @param bool $print |
134 | 134 | * @return string|void |
135 | 135 | */ |
136 | - public function component( Component $component, bool $print = true ) { |
|
136 | + public function component(Component $component, bool $print = true) { |
|
137 | 137 | /** @var View */ |
138 | 138 | $view = App::view(); |
139 | 139 | |
140 | - return $view->component( $component, $print ); |
|
140 | + return $view->component($component, $print); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | * @param bool $print Print or Return the HTML |
148 | 148 | * @return string|void |
149 | 149 | */ |
150 | - public function view_model( View_Model $view_model, bool $print = true ) { |
|
150 | + public function view_model(View_Model $view_model, bool $print = true) { |
|
151 | 151 | /** @var View */ |
152 | 152 | $view = App::view(); |
153 | 153 | |
154 | - return $view->view_model( $view_model, $print ); |
|
154 | + return $view->view_model($view_model, $print); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | * @param string $expression |
161 | 161 | * @return string |
162 | 162 | */ |
163 | - protected function compileAuth( $expression = '' ): string { |
|
164 | - $role = $this->stripParentheses( $expression ); |
|
165 | - if ( $role === '' ) { |
|
166 | - return $this->phpTag . 'if(!PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
163 | + protected function compileAuth($expression = ''): string { |
|
164 | + $role = $this->stripParentheses($expression); |
|
165 | + if ($role === '') { |
|
166 | + return $this->phpTag.'if(!PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
167 | 167 | } |
168 | 168 | |
169 | - return $this->phpTag . "if(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; |
|
169 | + return $this->phpTag."if(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | * @param string $expression |
176 | 176 | * @return string |
177 | 177 | */ |
178 | - protected function compileElseAuth( $expression = '' ): string { |
|
179 | - $role = $this->stripParentheses( $expression ); |
|
180 | - if ( $role === '' ) { |
|
181 | - return $this->phpTag . 'else: ?>'; |
|
178 | + protected function compileElseAuth($expression = ''): string { |
|
179 | + $role = $this->stripParentheses($expression); |
|
180 | + if ($role === '') { |
|
181 | + return $this->phpTag.'else: ?>'; |
|
182 | 182 | } |
183 | 183 | |
184 | - return $this->phpTag . "elseif(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; |
|
184 | + return $this->phpTag."elseif(!PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) && \$this->currentRole==$role): ?>"; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -190,18 +190,18 @@ discard block |
||
190 | 190 | * @param string|null $expression |
191 | 191 | * @return string |
192 | 192 | */ |
193 | - protected function compileGuest( $expression = null ): string { |
|
193 | + protected function compileGuest($expression = null): string { |
|
194 | 194 | |
195 | - if ( $expression === null ) { |
|
196 | - return $this->phpTag . 'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
195 | + if ($expression === null) { |
|
196 | + return $this->phpTag.'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
197 | 197 | } |
198 | 198 | |
199 | - $role = $this->stripParentheses( $expression ); |
|
200 | - if ( $role === '' ) { |
|
201 | - return $this->phpTag . 'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
199 | + $role = $this->stripParentheses($expression); |
|
200 | + if ($role === '') { |
|
201 | + return $this->phpTag.'if(PinkCrab\FunctionConstructors\Strings\isBlank($this->currentUser)): ?>'; |
|
202 | 202 | } |
203 | 203 | |
204 | - return $this->phpTag . "if(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; |
|
204 | + return $this->phpTag."if(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -210,13 +210,13 @@ discard block |
||
210 | 210 | * @param string|null $expression |
211 | 211 | * @return string |
212 | 212 | */ |
213 | - protected function compileElseGuest( $expression ): string { |
|
214 | - $role = $this->stripParentheses( $expression ); |
|
215 | - if ( $role === '' ) { |
|
216 | - return $this->phpTag . 'else: ?>'; |
|
213 | + protected function compileElseGuest($expression): string { |
|
214 | + $role = $this->stripParentheses($expression); |
|
215 | + if ($role === '') { |
|
216 | + return $this->phpTag.'else: ?>'; |
|
217 | 217 | } |
218 | 218 | |
219 | - return $this->phpTag . "elseif(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; |
|
219 | + return $this->phpTag."elseif(PinkCrab\FunctionConstructors\Strings\isBlank(\$this->currentUser) || \$this->currentRole!=$role): ?>"; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | } |