@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * @param array<string, mixed> $labels |
| 272 | 272 | * @return array<string, mixed> |
| 273 | 273 | */ |
| 274 | - public function filter_labels( array $labels ): array { |
|
| 274 | + public function filter_labels(array $labels): array { |
|
| 275 | 275 | return $labels; |
| 276 | 276 | } |
| 277 | 277 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | * @param array<string, mixed> $args |
| 282 | 282 | * @return array<string, mixed> |
| 283 | 283 | */ |
| 284 | - public function filter_args( array $args ): array { |
|
| 284 | + public function filter_args(array $args): array { |
|
| 285 | 285 | return $args; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * @param Meta_Data[] $collection |
| 292 | 292 | * @return Meta_Data[] |
| 293 | 293 | */ |
| 294 | - public function meta_data( array $collection ): array { |
|
| 294 | + public function meta_data(array $collection): array { |
|
| 295 | 295 | return $collection; |
| 296 | 296 | } |
| 297 | 297 | |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @param Meta_Box[] $collection |
| 302 | 302 | * @return Meta_Box[] |
| 303 | 303 | */ |
| 304 | - public function meta_boxes( array $collection ): array { |
|
| 304 | + public function meta_boxes(array $collection): array { |
|
| 305 | 305 | return $collection; |
| 306 | 306 | } |
| 307 | 307 | } |
@@ -25,4 +25,4 @@ |
||
| 25 | 25 | |
| 26 | 26 | namespace PinkCrab\Registerables\Registration_Middleware; |
| 27 | 27 | |
| 28 | -interface Registerable{} |
|
| 28 | +interface Registerable {} |
|
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param \PinkCrab\Loader\Hook_Loader $loader |
| 47 | 47 | * @return void |
| 48 | 48 | */ |
| 49 | - public function set_hook_loader( Hook_Loader $loader ) { |
|
| 49 | + public function set_hook_loader(Hook_Loader $loader) { |
|
| 50 | 50 | $this->loader = $loader; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param \PinkCrab\Perique\Interfaces\DI_Container $container |
| 57 | 57 | * @return void |
| 58 | 58 | */ |
| 59 | - public function set_di_container( DI_Container $container ): void { |
|
| 59 | + public function set_di_container(DI_Container $container): void { |
|
| 60 | 60 | $this->container = $container; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -66,27 +66,27 @@ discard block |
||
| 66 | 66 | * @param object|Registerable $class |
| 67 | 67 | * @return object |
| 68 | 68 | */ |
| 69 | - public function process( $class ) { |
|
| 69 | + public function process($class) { |
|
| 70 | 70 | |
| 71 | - if ( ! is_a( $class, Registerable::class ) ) { |
|
| 71 | + if ( ! is_a($class, Registerable::class)) { |
|
| 72 | 72 | return $class; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // Register registerable. |
| 76 | 76 | $this->loader->action( |
| 77 | 77 | 'init', |
| 78 | - static function() use ( $class ) { |
|
| 78 | + static function() use ($class) { |
|
| 79 | 79 | Registrar_Factory::new() |
| 80 | - ->create_from_registerable( $class ) |
|
| 81 | - ->register( $class ); |
|
| 80 | + ->create_from_registerable($class) |
|
| 81 | + ->register($class); |
|
| 82 | 82 | } |
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | 85 | // Disable gutenberg if post type decides. |
| 86 | - if ( is_a( $class, Post_Type::class ) ) { |
|
| 86 | + if (is_a($class, Post_Type::class)) { |
|
| 87 | 87 | $this->loader->filter( |
| 88 | 88 | 'use_block_editor_for_post_type', |
| 89 | - static function( bool $state, string $post_type ) use ( $class ): bool { |
|
| 89 | + static function(bool $state, string $post_type) use ($class): bool { |
|
| 90 | 90 | return $post_type === $class->key |
| 91 | 91 | ? (bool) $class->gutenberg |
| 92 | 92 | : $state; |
@@ -96,16 +96,16 @@ discard block |
||
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | 98 | // Register meta boxes. |
| 99 | - $meta_boxes = $class->meta_boxes( array() ); |
|
| 99 | + $meta_boxes = $class->meta_boxes(array()); |
|
| 100 | 100 | |
| 101 | - if ( ! empty( $meta_boxes ) ) { |
|
| 101 | + if ( ! empty($meta_boxes)) { |
|
| 102 | 102 | // Create the registrat |
| 103 | 103 | $meta_box_registrar = Registrar_Factory::new() |
| 104 | - ->meta_box_registrar( $this->container, $this->loader ); |
|
| 104 | + ->meta_box_registrar($this->container, $this->loader); |
|
| 105 | 105 | |
| 106 | 106 | // Register each meta box. |
| 107 | - foreach ( $meta_boxes as $meta_box ) { |
|
| 108 | - $meta_box_registrar->register( $meta_box ); |
|
| 107 | + foreach ($meta_boxes as $meta_box) { |
|
| 108 | + $meta_box_registrar->register($meta_box); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -35,5 +35,5 @@ |
||
| 35 | 35 | * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $registerable |
| 36 | 36 | * @return void |
| 37 | 37 | */ |
| 38 | - public function register( Registerable $registerable ): void; |
|
| 38 | + public function register(Registerable $registerable): void; |
|
| 39 | 39 | } |
@@ -55,16 +55,16 @@ discard block |
||
| 55 | 55 | * @return Registrar |
| 56 | 56 | * @throws Exception If not valid registerable type passed. |
| 57 | 57 | */ |
| 58 | - public function create_from_registerable( Registerable $registerable ): Registrar { |
|
| 59 | - switch ( true ) { |
|
| 60 | - case is_a( $registerable, Post_Type::class ): |
|
| 61 | - return new Post_Type_Registrar( new Post_Type_Validator() ); |
|
| 58 | + public function create_from_registerable(Registerable $registerable): Registrar { |
|
| 59 | + switch (true) { |
|
| 60 | + case is_a($registerable, Post_Type::class): |
|
| 61 | + return new Post_Type_Registrar(new Post_Type_Validator()); |
|
| 62 | 62 | |
| 63 | - case is_a( $registerable, Taxonomy::class ): |
|
| 64 | - return new Taxonomy_Registrar( new Taxonomy_Validator() ); |
|
| 63 | + case is_a($registerable, Taxonomy::class): |
|
| 64 | + return new Taxonomy_Registrar(new Taxonomy_Validator()); |
|
| 65 | 65 | |
| 66 | 66 | default: |
| 67 | - throw new Exception( 'Invalid registerable type (no dispatcher exists)' ); |
|
| 67 | + throw new Exception('Invalid registerable type (no dispatcher exists)'); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | * @param \PinkCrab\Loader\Hook_Loader $loader |
| 76 | 76 | * @return Meta_Box_Registrar |
| 77 | 77 | */ |
| 78 | - public function meta_box_registrar( DI_Container $container, Hook_Loader $loader ): Meta_Box_Registrar { |
|
| 79 | - return new Meta_Box_Registrar( new Meta_Box_Validator(), $container, $loader ); |
|
| 78 | + public function meta_box_registrar(DI_Container $container, Hook_Loader $loader): Meta_Box_Registrar { |
|
| 79 | + return new Meta_Box_Registrar(new Meta_Box_Validator(), $container, $loader); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | class Meta_Box_Validator extends Abstract_Validator { |
| 34 | 34 | |
| 35 | - protected const REQUIRED_FIELDS = array( 'key', 'label' ); |
|
| 35 | + protected const REQUIRED_FIELDS = array('key', 'label'); |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * Validates the class passed. |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $object |
| 41 | 41 | * @return bool |
| 42 | 42 | */ |
| 43 | - public function validate( Registerable $object ): bool { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass |
|
| 43 | + public function validate(Registerable $object): bool { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass |
|
| 44 | 44 | return false; //no op |
| 45 | 45 | } |
| 46 | 46 | |
@@ -50,20 +50,20 @@ discard block |
||
| 50 | 50 | * @param mixed $meta_box |
| 51 | 51 | * @return bool |
| 52 | 52 | */ |
| 53 | - public function verify_meta_box( $meta_box ): bool { |
|
| 53 | + public function verify_meta_box($meta_box): bool { |
|
| 54 | 54 | // If this is not a valid post type, just bail here. |
| 55 | - if ( ! is_object( $meta_box ) || ! is_a( $meta_box, Meta_Box::class ) ) { |
|
| 56 | - $this->add_error( sprintf( '%s is not a valid Meta Box Model', is_object( $meta_box ) ? get_class( $meta_box ) : \gettype( $meta_box ) ) ); |
|
| 55 | + if ( ! is_object($meta_box) || ! is_a($meta_box, Meta_Box::class)) { |
|
| 56 | + $this->add_error(sprintf('%s is not a valid Meta Box Model', is_object($meta_box) ? get_class($meta_box) : \gettype($meta_box))); |
|
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /* @var Meta_Box $object, already confirmed as a post type */ |
| 61 | 61 | |
| 62 | 62 | // Ensure all required fields are set. |
| 63 | - $this->has_required_fields( $meta_box ); |
|
| 63 | + $this->has_required_fields($meta_box); |
|
| 64 | 64 | |
| 65 | 65 | // Ensure can render view. |
| 66 | - $this->has_valid_view( $meta_box ); |
|
| 66 | + $this->has_valid_view($meta_box); |
|
| 67 | 67 | |
| 68 | 68 | // Check if the passed object has any errors. |
| 69 | 69 | return ! $this->has_errors(); |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | * @param Meta_Box $meta_box |
| 76 | 76 | * @return void |
| 77 | 77 | */ |
| 78 | - protected function has_required_fields( Meta_Box $meta_box ): void { |
|
| 79 | - foreach ( self::REQUIRED_FIELDS as $field ) { |
|
| 80 | - if ( ! is_string( $meta_box->{$field} ) |
|
| 81 | - || \mb_strlen( $meta_box->{$field} ) === 0 |
|
| 78 | + protected function has_required_fields(Meta_Box $meta_box): void { |
|
| 79 | + foreach (self::REQUIRED_FIELDS as $field) { |
|
| 80 | + if ( ! is_string($meta_box->{$field} ) |
|
| 81 | + || \mb_strlen($meta_box->{$field} ) === 0 |
|
| 82 | 82 | ) { |
| 83 | - $this->add_error( sprintf( '%s is not set on %s Meta Box Model', $field, get_class( $meta_box ) ) ); |
|
| 83 | + $this->add_error(sprintf('%s is not set on %s Meta Box Model', $field, get_class($meta_box))); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -92,13 +92,13 @@ discard block |
||
| 92 | 92 | * @param \PinkCrab\Registerables\Meta_Box $meta_box |
| 93 | 93 | * @return void |
| 94 | 94 | */ |
| 95 | - protected function has_valid_view( Meta_Box $meta_box ): void { |
|
| 96 | - if ( ! \is_callable( $meta_box->view ) |
|
| 97 | - && ( ! is_string( $meta_box->view_template ) |
|
| 98 | - || ( is_string( $meta_box->view_template ) && \mb_strlen( $meta_box->view_template ) === 0 ) |
|
| 95 | + protected function has_valid_view(Meta_Box $meta_box): void { |
|
| 96 | + if ( ! \is_callable($meta_box->view) |
|
| 97 | + && ( ! is_string($meta_box->view_template) |
|
| 98 | + || (is_string($meta_box->view_template) && \mb_strlen($meta_box->view_template) === 0) |
|
| 99 | 99 | ) |
| 100 | 100 | ) { |
| 101 | - $this->add_error( sprintf( '%s doesn\'t have a valid view defined.', get_class( $meta_box ) ) ); |
|
| 101 | + $this->add_error(sprintf('%s doesn\'t have a valid view defined.', get_class($meta_box))); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | class Post_Type_Validator extends Abstract_Validator { |
| 33 | 33 | |
| 34 | - protected const REQUIRED_FIELDS = array( 'key', 'singular', 'plural' ); |
|
| 34 | + protected const REQUIRED_FIELDS = array('key', 'singular', 'plural'); |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Validates the class passed. |
@@ -39,17 +39,17 @@ discard block |
||
| 39 | 39 | * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $object |
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | - public function validate( Registerable $object ): bool { |
|
| 42 | + public function validate(Registerable $object): bool { |
|
| 43 | 43 | // If this is not a valid post type, just bail here. |
| 44 | - if ( ! is_a( $object, Post_Type::class ) ) { |
|
| 45 | - $this->add_error( sprintf( '%s is not a valid Post Type Model', get_class( $object ) ) ); |
|
| 44 | + if ( ! is_a($object, Post_Type::class)) { |
|
| 45 | + $this->add_error(sprintf('%s is not a valid Post Type Model', get_class($object))); |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /* @var Post_Type $object, already confirmed as a post type */ |
| 50 | 50 | |
| 51 | 51 | // Ensure all required fields are set. |
| 52 | - $this->has_required_fields( $object ); |
|
| 52 | + $this->has_required_fields($object); |
|
| 53 | 53 | |
| 54 | 54 | // Check if the passed object has any errors. |
| 55 | 55 | return ! $this->has_errors(); |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | * @param Post_Type $post_type |
| 62 | 62 | * @return void |
| 63 | 63 | */ |
| 64 | - protected function has_required_fields( Post_Type $post_type ): void { |
|
| 65 | - foreach ( self::REQUIRED_FIELDS as $field ) { |
|
| 66 | - if ( ! is_string( $post_type->{$field} ) |
|
| 67 | - || \mb_strlen( $post_type->{$field} ) === 0 |
|
| 64 | + protected function has_required_fields(Post_Type $post_type): void { |
|
| 65 | + foreach (self::REQUIRED_FIELDS as $field) { |
|
| 66 | + if ( ! is_string($post_type->{$field} ) |
|
| 67 | + || \mb_strlen($post_type->{$field} ) === 0 |
|
| 68 | 68 | ) { |
| 69 | - $this->add_error( sprintf( '%s is not set on %s Post Type Model', $field, get_class( $post_type ) ) ); |
|
| 69 | + $this->add_error(sprintf('%s is not set on %s Post Type Model', $field, get_class($post_type))); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | class Taxonomy_Validator extends Abstract_Validator { |
| 33 | 33 | |
| 34 | - protected const REQUIRED_FIELDS = array( 'slug', 'singular', 'plural' ); |
|
| 34 | + protected const REQUIRED_FIELDS = array('slug', 'singular', 'plural'); |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Validates the class passed. |
@@ -39,17 +39,17 @@ discard block |
||
| 39 | 39 | * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $object |
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | - public function validate( Registerable $object ): bool { |
|
| 42 | + public function validate(Registerable $object): bool { |
|
| 43 | 43 | // If this is not a valid taxonomy, just bail here. |
| 44 | - if ( ! is_a( $object, Taxonomy::class ) ) { |
|
| 45 | - $this->add_error( sprintf( '%s is not a valid Taxonomy Model', get_class( $object ) ) ); |
|
| 44 | + if ( ! is_a($object, Taxonomy::class)) { |
|
| 45 | + $this->add_error(sprintf('%s is not a valid Taxonomy Model', get_class($object))); |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /* @var Taxonomy $object, already confirmed as a Taxonomy */ |
| 50 | 50 | |
| 51 | 51 | // Ensure all required fields are set. |
| 52 | - $this->has_required_fields( $object ); |
|
| 52 | + $this->has_required_fields($object); |
|
| 53 | 53 | |
| 54 | 54 | // Check if the passed object has any errors. |
| 55 | 55 | return ! $this->has_errors(); |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | * @param Taxonomy $taxonomy |
| 62 | 62 | * @return void |
| 63 | 63 | */ |
| 64 | - protected function has_required_fields( Taxonomy $taxonomy ): void { |
|
| 65 | - foreach ( self::REQUIRED_FIELDS as $field ) { |
|
| 66 | - if ( ! is_string( $taxonomy->{$field} ) |
|
| 67 | - || \mb_strlen( $taxonomy->{$field} ) === 0 |
|
| 64 | + protected function has_required_fields(Taxonomy $taxonomy): void { |
|
| 65 | + foreach (self::REQUIRED_FIELDS as $field) { |
|
| 66 | + if ( ! is_string($taxonomy->{$field} ) |
|
| 67 | + || \mb_strlen($taxonomy->{$field} ) === 0 |
|
| 68 | 68 | ) { |
| 69 | - $this->add_error( sprintf( '%s is not set on %s Taxonomy Model', $field, get_class( $taxonomy ) ) ); |
|
| 69 | + $this->add_error(sprintf('%s is not set on %s Taxonomy Model', $field, get_class($taxonomy))); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @return bool |
| 42 | 42 | */ |
| 43 | 43 | public function has_errors(): bool { |
| 44 | - return count( $this->errors ) >= 1; |
|
| 44 | + return count($this->errors) >= 1; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param string $error |
| 60 | 60 | * @return self |
| 61 | 61 | */ |
| 62 | - public function add_error( string $error ): self { |
|
| 62 | + public function add_error(string $error): self { |
|
| 63 | 63 | $this->errors[] = $error; |
| 64 | 64 | return $this; |
| 65 | 65 | } |
@@ -80,5 +80,5 @@ discard block |
||
| 80 | 80 | * @param \PinkCrab\Registerables\Registration_Middleware\Registerable $object |
| 81 | 81 | * @return bool |
| 82 | 82 | */ |
| 83 | - abstract public function validate( Registerable $object ): bool; |
|
| 83 | + abstract public function validate(Registerable $object): bool; |
|
| 84 | 84 | } |