| @@ -107,7 +107,7 @@ discard block | ||
| 107 | 107 | * | 
| 108 | 108 | * @param string $key | 
| 109 | 109 | */ | 
| 110 | -	final public function __construct( string $key ) { | |
| 110 | +	final public function __construct(string $key) { | |
| 111 | 111 | $this->key = $key; | 
| 112 | 112 | } | 
| 113 | 113 | |
| @@ -117,8 +117,8 @@ discard block | ||
| 117 | 117 | * @param string $key | 
| 118 | 118 | * @return self | 
| 119 | 119 | */ | 
| 120 | -	public static function normal( string $key ): self { | |
| 121 | - $meta_box = new static( $key ); | |
| 120 | +	public static function normal(string $key): self { | |
| 121 | + $meta_box = new static($key); | |
| 122 | 122 | $meta_box->context = 'normal'; | 
| 123 | 123 | return $meta_box; | 
| 124 | 124 | } | 
| @@ -129,8 +129,8 @@ discard block | ||
| 129 | 129 | * @param string $key | 
| 130 | 130 | * @return self | 
| 131 | 131 | */ | 
| 132 | -	public static function side( string $key ): self { | |
| 133 | - $meta_box = new static( $key ); | |
| 132 | +	public static function side(string $key): self { | |
| 133 | + $meta_box = new static($key); | |
| 134 | 134 | $meta_box->context = 'side'; | 
| 135 | 135 | return $meta_box; | 
| 136 | 136 | } | 
| @@ -141,7 +141,7 @@ discard block | ||
| 141 | 141 | * @param string $label | 
| 142 | 142 | * @return self | 
| 143 | 143 | */ | 
| 144 | -	public function label( string $label ): self { | |
| 144 | +	public function label(string $label): self { | |
| 145 | 145 | $this->label = $label; | 
| 146 | 146 | return $this; | 
| 147 | 147 | } | 
| @@ -152,8 +152,8 @@ discard block | ||
| 152 | 152 | * @param string|array<mixed>|\WP_Screen $screen | 
| 153 | 153 | * @return self | 
| 154 | 154 | */ | 
| 155 | -	public function screen( $screen ): self { | |
| 156 | - array_push( $this->screen, $screen ); | |
| 155 | +	public function screen($screen): self { | |
| 156 | + array_push($this->screen, $screen); | |
| 157 | 157 | return $this; | 
| 158 | 158 | } | 
| 159 | 159 | |
| @@ -163,7 +163,7 @@ discard block | ||
| 163 | 163 | * @param array<string, mixed> $view_vars | 
| 164 | 164 | * @return self | 
| 165 | 165 | */ | 
| 166 | -	public function view_vars( array $view_vars ): self { | |
| 166 | +	public function view_vars(array $view_vars): self { | |
| 167 | 167 | $this->view_vars = $view_vars; | 
| 168 | 168 | return $this; | 
| 169 | 169 | } | 
| @@ -175,7 +175,7 @@ discard block | ||
| 175 | 175 | * @param string $view_template | 
| 176 | 176 | * @return self | 
| 177 | 177 | */ | 
| 178 | -	public function view_template( string $view_template ): self { | |
| 178 | +	public function view_template(string $view_template): self { | |
| 179 | 179 | $this->view_template = $view_template; | 
| 180 | 180 | return $this; | 
| 181 | 181 | } | 
| @@ -187,7 +187,7 @@ discard block | ||
| 187 | 187 | * @param callable $callable | 
| 188 | 188 | * @return self | 
| 189 | 189 | */ | 
| 190 | -	public function view( $callable ): self { | |
| 190 | +	public function view($callable): self { | |
| 191 | 191 | $this->view = $callable; | 
| 192 | 192 | return $this; | 
| 193 | 193 | } | 
| @@ -201,8 +201,8 @@ discard block | ||
| 201 | 201 | * @param int $params | 
| 202 | 202 | * @return self | 
| 203 | 203 | */ | 
| 204 | -	public function add_action( string $hook, callable $callable, int $priority = 10, int $params = 1 ): self { | |
| 205 | - $this->actions[ $hook ] = | |
| 204 | +	public function add_action(string $hook, callable $callable, int $priority = 10, int $params = 1): self { | |
| 205 | + $this->actions[$hook] = | |
| 206 | 206 | array( | 
| 207 | 207 | 'callback' => $callable, | 
| 208 | 208 | 'priority' => $priority, | 
| @@ -218,7 +218,7 @@ discard block | ||
| 218 | 218 | * @param callable(\WP_Post $post,array<string, mixed> $args):array<string, mixed> $view_data_filter | 
| 219 | 219 | * @return self | 
| 220 | 220 | */ | 
| 221 | -	public function view_data_filter( callable $view_data_filter ): self { | |
| 221 | +	public function view_data_filter(callable $view_data_filter): self { | |
| 222 | 222 | $this->view_data_filter = $view_data_filter; | 
| 223 | 223 | return $this; | 
| 224 | 224 | } | 
| @@ -64,30 +64,30 @@ discard block | ||
| 64 | 64 | * @param Meta_Box $meta_box | 
| 65 | 65 | * @return void | 
| 66 | 66 | */ | 
| 67 | -	public function register( Meta_Box $meta_box ): void { | |
| 67 | +	public function register(Meta_Box $meta_box): void { | |
| 68 | 68 | |
| 69 | -		if ( ! $this->validator->verify_meta_box( $meta_box ) ) { | |
| 69 | +		if ( ! $this->validator->verify_meta_box($meta_box)) { | |
| 70 | 70 | throw new Exception( | 
| 71 | 71 | sprintf( | 
| 72 | 72 | 'Failed validating meta box model(%s) with errors: %s', | 
| 73 | - get_class( $meta_box ), | |
| 74 | - join( ', ', $this->validator->get_errors() ) | |
| 73 | + get_class($meta_box), | |
| 74 | +					join(', ', $this->validator->get_errors()) | |
| 75 | 75 | ) | 
| 76 | 76 | ); | 
| 77 | 77 | } | 
| 78 | 78 | |
| 79 | 79 | // Set the view using View, if not traditional callback supplied and a defined template. | 
| 80 | -		if ( ! \is_callable( $meta_box->view ) && is_string( $meta_box->view_template ) ) { | |
| 81 | - $meta_box = $this->set_view_callback_from_renderable( $meta_box ); | |
| 80 | +		if ( ! \is_callable($meta_box->view) && is_string($meta_box->view_template)) { | |
| 81 | + $meta_box = $this->set_view_callback_from_renderable($meta_box); | |
| 82 | 82 | } | 
| 83 | -		if ( \is_callable( $meta_box->view ) ) { | |
| 84 | - $meta_box = $this->set_view_callback_from_callable( $meta_box ); | |
| 83 | +		if (\is_callable($meta_box->view)) { | |
| 84 | + $meta_box = $this->set_view_callback_from_callable($meta_box); | |
| 85 | 85 | } | 
| 86 | 86 | |
| 87 | 87 | // Add meta_box to loader. | 
| 88 | 88 | $this->loader->action( | 
| 89 | 89 | 'add_meta_boxes', | 
| 90 | -			function() use ( $meta_box ) : void { | |
| 90 | +			function() use ($meta_box) : void { | |
| 91 | 91 | \add_meta_box( | 
| 92 | 92 | $meta_box->key, | 
| 93 | 93 | $meta_box->label, | 
| @@ -100,9 +100,9 @@ discard block | ||
| 100 | 100 | } | 
| 101 | 101 | ); | 
| 102 | 102 | // If we have any hook calls, add them to the loader. | 
| 103 | -		if ( $this->is_active( $meta_box ) && ! empty( $meta_box->actions ) ) { | |
| 104 | -			foreach ( $meta_box->actions as $handle => $hook ) { | |
| 105 | - $this->loader->action( (string) $handle, $hook['callback'], $hook['priority'], $hook['params'] ); | |
| 103 | +		if ($this->is_active($meta_box) && ! empty($meta_box->actions)) { | |
| 104 | +			foreach ($meta_box->actions as $handle => $hook) { | |
| 105 | + $this->loader->action((string) $handle, $hook['callback'], $hook['priority'], $hook['params']); | |
| 106 | 106 | } | 
| 107 | 107 | } | 
| 108 | 108 | |
| @@ -114,21 +114,21 @@ discard block | ||
| 114 | 114 | * @param \PinkCrab\Registerables\Meta_Box $meta_box | 
| 115 | 115 | * @return \PinkCrab\Registerables\Meta_Box | 
| 116 | 116 | */ | 
| 117 | -	protected function set_view_callback_from_callable( Meta_Box $meta_box ): Meta_Box { | |
| 117 | +	protected function set_view_callback_from_callable(Meta_Box $meta_box): Meta_Box { | |
| 118 | 118 | |
| 119 | 119 | // Get the current view callback. | 
| 120 | 120 | $current_callback = $meta_box->view; | 
| 121 | 121 | |
| 122 | 122 | $meta_box->view( | 
| 123 | -			function ( \WP_Post $post, array $args ) use ( $meta_box, $current_callback ) { | |
| 123 | +			function(\WP_Post $post, array $args) use ($meta_box, $current_callback) { | |
| 124 | 124 | |
| 125 | 125 | // Set the view args | 
| 126 | 126 | $args['args']['post'] = $post; | 
| 127 | - $args['args'] = $this->filter_view_args( $meta_box, $post, $args['args'] ); | |
| 127 | + $args['args'] = $this->filter_view_args($meta_box, $post, $args['args']); | |
| 128 | 128 | |
| 129 | 129 | // Render the callback. | 
| 130 | -				if ( \is_callable( $current_callback ) ) { | |
| 131 | - call_user_func( $current_callback, $post, $args ); | |
| 130 | +				if (\is_callable($current_callback)) { | |
| 131 | + call_user_func($current_callback, $post, $args); | |
| 132 | 132 | } | 
| 133 | 133 | } | 
| 134 | 134 | ); | 
| @@ -142,22 +142,22 @@ discard block | ||
| 142 | 142 | * @param \PinkCrab\Registerables\Meta_Box $meta_box | 
| 143 | 143 | * @return \PinkCrab\Registerables\Meta_Box | 
| 144 | 144 | */ | 
| 145 | -	protected function set_view_callback_from_renderable( Meta_Box $meta_box ): Meta_Box { | |
| 145 | +	protected function set_view_callback_from_renderable(Meta_Box $meta_box): Meta_Box { | |
| 146 | 146 | |
| 147 | 147 | // Create View(View) | 
| 148 | - $view = $this->container->create( View::class ); | |
| 149 | -		if ( is_null( $view ) || ! is_a( $view, View::class ) ) { | |
| 150 | - throw new Exception( 'View not defined' ); | |
| 148 | + $view = $this->container->create(View::class); | |
| 149 | +		if (is_null($view) || ! is_a($view, View::class)) { | |
| 150 | +			throw new Exception('View not defined'); | |
| 151 | 151 | } | 
| 152 | 152 | |
| 153 | 153 | $meta_box->view( | 
| 154 | -			function ( \WP_Post $post, array $args ) use ( $meta_box, $view ) { | |
| 154 | +			function(\WP_Post $post, array $args) use ($meta_box, $view) { | |
| 155 | 155 | |
| 156 | 156 | $args['args']['post'] = $post; | 
| 157 | - $args['args'] = $this->filter_view_args( $meta_box, $post, $args['args'] ); | |
| 157 | + $args['args'] = $this->filter_view_args($meta_box, $post, $args['args']); | |
| 158 | 158 | |
| 159 | 159 | // @phpstan-ignore-next-line, template should already be checked for valid template path in register() method (which calls this) | 
| 160 | - $view->render( $meta_box->view_template, $args['args'] ); | |
| 160 | + $view->render($meta_box->view_template, $args['args']); | |
| 161 | 161 | } | 
| 162 | 162 | ); | 
| 163 | 163 | |
| @@ -169,12 +169,12 @@ discard block | ||
| 169 | 169 | * | 
| 170 | 170 | * @return boolean | 
| 171 | 171 | */ | 
| 172 | -	protected function is_active( Meta_Box $meta_box ): bool { | |
| 172 | +	protected function is_active(Meta_Box $meta_box): bool { | |
| 173 | 173 | global $current_screen; | 
| 174 | 174 | |
| 175 | - return ! is_null( $current_screen ) | |
| 176 | - && ! empty( $current_screen->post_type ) | |
| 177 | - && in_array( $current_screen->post_type, $meta_box->screen, true ); | |
| 175 | + return ! is_null($current_screen) | |
| 176 | + && ! empty($current_screen->post_type) | |
| 177 | + && in_array($current_screen->post_type, $meta_box->screen, true); | |
| 178 | 178 | } | 
| 179 | 179 | |
| 180 | 180 | /** | 
| @@ -185,9 +185,9 @@ discard block | ||
| 185 | 185 | * @param array<string, mixed> $view_args | 
| 186 | 186 | * @return array<string, mixed> | 
| 187 | 187 | */ | 
| 188 | -	public function filter_view_args( Meta_Box $meta_box, \WP_Post $post, array $view_args ): array { | |
| 189 | -		if ( is_callable( $meta_box->view_data_filter ) ) { | |
| 190 | - $view_args = ( $meta_box->view_data_filter )( $post, $view_args ); | |
| 188 | +	public function filter_view_args(Meta_Box $meta_box, \WP_Post $post, array $view_args): array { | |
| 189 | +		if (is_callable($meta_box->view_data_filter)) { | |
| 190 | + $view_args = ($meta_box->view_data_filter)($post, $view_args); | |
| 191 | 191 | } | 
| 192 | 192 | return $view_args; | 
| 193 | 193 | } |