diff --git a/.harness.json b/.harness.json index a7ee1c5..26e5084 100644 --- a/.harness.json +++ b/.harness.json @@ -5,10 +5,10 @@ "framework" ], "ratchet": { - "type_coverage": 89.1, - "phpstan_level": 5, + "phpstan_level": 8, "phpstan_baseline": 2, - "coverage": 98.0, + "coverage": 98, + "type_coverage": 89.1, "msi": 95 } } diff --git a/composer.json b/composer.json index a8aac2f..2889e2e 100644 --- a/composer.json +++ b/composer.json @@ -46,8 +46,8 @@ "test:coverage": "pest --coverage", "test:unit": "pest --testsuite=Unit", "test:feature": "pest --testsuite=Feature", - "phpstan": "phpstan analyse src tests --level=5", - "phpstan:ci": "phpstan analyse src tests --level=5 --no-progress", + "phpstan": "phpstan analyse src tests --level=8", + "phpstan:ci": "phpstan analyse src tests --level=8 --no-progress", "lint": "pint", "lint:check": "pint --test", "qa": "@php vendor/bin/pollora-qa check", diff --git a/phpstan.neon b/phpstan.neon index d0ce587..d74c0c8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,7 +3,7 @@ includes: - vendor/pollora/harness/presets/phpstan/base.neon parameters: - level: 5 + level: 8 paths: - src excludePaths: diff --git a/src/Adapter/Out/WordPress/PostTypeRegistryAdapter.php b/src/Adapter/Out/WordPress/PostTypeRegistryAdapter.php index 14cd8f9..2aae307 100755 --- a/src/Adapter/Out/WordPress/PostTypeRegistryAdapter.php +++ b/src/Adapter/Out/WordPress/PostTypeRegistryAdapter.php @@ -20,8 +20,8 @@ class PostTypeRegistryAdapter implements PostTypeRegistryPort * This is a generic method that delegates to the specific post type registration method. * * @param string $slug The entity slug - * @param array $args Registration arguments - * @param array $names Entity names (singular, plural) + * @param array $args Registration arguments + * @param array $names Entity names (singular, plural) */ public function register(string $slug, array $args, array $names): void { @@ -34,8 +34,8 @@ public function register(string $slug, array $args, array $names): void * Uses register_extended_post_type if available, or falls back to register_post_type. * * @param string $slug The post type slug - * @param array $args Registration arguments - * @param array $names Post type names (singular, plural) + * @param array $args Registration arguments + * @param array $names Post type names (singular, plural) */ public function registerPostType(string $slug, array $args, array $names): void { @@ -56,8 +56,8 @@ public function registerPostType(string $slug, array $args, array $names): void * Fallback to standard WordPress post type registration if extended registration fails * * @param string $slug Post type slug - * @param array $args Arguments for post type - * @param array $names Names for post type + * @param array $args Arguments for post type + * @param array $names Names for post type */ protected function fallbackToStandardPostTypeRegistration(string $slug, array $args, array $names): void { diff --git a/src/Adapter/Out/WordPress/TaxonomyRegistryAdapter.php b/src/Adapter/Out/WordPress/TaxonomyRegistryAdapter.php index 61021b1..d76a922 100755 --- a/src/Adapter/Out/WordPress/TaxonomyRegistryAdapter.php +++ b/src/Adapter/Out/WordPress/TaxonomyRegistryAdapter.php @@ -20,8 +20,8 @@ class TaxonomyRegistryAdapter implements TaxonomyRegistryPort * This is a generic method that delegates to the specific taxonomy registration method. * * @param string $slug The entity slug - * @param array $args Registration arguments - * @param array $names Entity names (singular, plural) + * @param array $args Registration arguments + * @param array $names Entity names (singular, plural) */ public function register(string $slug, array $args, array $names): void { @@ -40,9 +40,9 @@ public function register(string $slug, array $args, array $names): void * Uses register_extended_taxonomy if available, or falls back to register_taxonomy. * * @param string $slug The taxonomy slug - * @param string|array $objectType The post type(s) the taxonomy is associated with - * @param array $args Registration arguments - * @param array $names Taxonomy names (singular, plural) + * @param string|array $objectType The post type(s) the taxonomy is associated with + * @param array $args Registration arguments + * @param array $names Taxonomy names (singular, plural) */ public function registerTaxonomy(string $slug, string|array $objectType, array $args, array $names): void { @@ -58,9 +58,9 @@ public function registerTaxonomy(string $slug, string|array $objectType, array $ * Fallback to standard WordPress taxonomy registration if extended registration fails * * @param string $slug Taxonomy slug - * @param string|array $objectType Post type(s) to register the taxonomy for - * @param array $args Arguments for taxonomy - * @param array $names Names for taxonomy + * @param string|array $objectType Post type(s) to register the taxonomy for + * @param array $args Arguments for taxonomy + * @param array $names Names for taxonomy */ protected function fallbackToStandardTaxonomyRegistration(string $slug, string|array $objectType, array $args, array $names): void { diff --git a/src/Application/Service/EntityRegistrationService.php b/src/Application/Service/EntityRegistrationService.php index 7b3d029..472467c 100755 --- a/src/Application/Service/EntityRegistrationService.php +++ b/src/Application/Service/EntityRegistrationService.php @@ -44,6 +44,6 @@ public function registerEntity(Entity $entity): void $this->entityRegistry->register($entity->getSlug(), $args, $names); - }, $entity->getPriority()); + }, $entity->getPriority() ?? $entity->priority); } } diff --git a/src/Application/Service/TaxonomyService.php b/src/Application/Service/TaxonomyService.php index f915c43..e6d0842 100755 --- a/src/Application/Service/TaxonomyService.php +++ b/src/Application/Service/TaxonomyService.php @@ -40,7 +40,7 @@ public function register(Taxonomy $taxonomy): void * This method creates a new taxonomy and registers it with WordPress. * * @param string $slug The taxonomy slug - * @param string|array $objectType The post type(s) the taxonomy is associated with + * @param string|array $objectType The post type(s) the taxonomy is associated with * @param string|null $singular The singular label for the taxonomy * @param string|null $plural The plural label for the taxonomy * @return Taxonomy The created taxonomy diff --git a/src/Domain/Model/Entity.php b/src/Domain/Model/Entity.php index 0d5f2aa..5d1f25c 100755 --- a/src/Domain/Model/Entity.php +++ b/src/Domain/Model/Entity.php @@ -31,7 +31,7 @@ abstract class Entity /** * Labels array for this post type or taxonomy. * - * @var array + * @var array */ public $labels; @@ -55,7 +55,7 @@ abstract class Entity /** * Whether queries can be performed on the front end for the post type as part of `parse_request()` for post types or whether a taxonomy is intended for use publicly either via the admin interface or by front-end users * - * @var bool + * @var bool|null */ public $publiclyQueryable; @@ -69,7 +69,7 @@ abstract class Entity /** * Rewrites information for this post type or taxonomy. * - * @var array|false + * @var bool|array */ public $rewrite; @@ -78,7 +78,7 @@ abstract class Entity * * Default is the value of $public. * - * @var bool + * @var bool|null */ public $showUi; @@ -94,7 +94,7 @@ abstract class Entity * * Default is the value $public. * - * @var bool + * @var bool|null */ public $showInNavMenus; @@ -146,12 +146,14 @@ abstract class Entity /** * Post type or Taxonomy capabilities. * - * @var array + * @var array */ public $capabilities; /** * Whether to show this post type or taxonomy on the 'At a Glance' section of the admin dashboard. + * + * @var bool|null */ public $dashboardGlance; @@ -165,7 +167,7 @@ abstract class Entity /** * Names of the post type or taxonomy. * - * @var array + * @var array */ public $names; @@ -238,9 +240,9 @@ public function setLabel(string $label): self /** * Retrieves the labels associated with the entity. * - * @return array|null Returns an object containing the labels associated with the entity. - * If labels are available, an array is returned with the label properties. - * If labels are not available, null is returned. + * @return array|null Returns an object containing the labels associated with the entity. + * If labels are available, an array is returned with the label properties. + * If labels are not available, null is returned. */ public function getLabels(): ?array { @@ -250,7 +252,7 @@ public function getLabels(): ?array /** * Sets the labels for the entity. * - * @param array $labels The labels array containing the labels for the entity. + * @param array $labels The labels array containing the labels for the entity. * @return static Returns an instance of the class. */ public function labels(array $labels): self @@ -265,7 +267,7 @@ public function labels(array $labels): self * * @deprecated Use labels() instead * - * @param array $labels The labels array containing the labels for the entity. + * @param array $labels The labels array containing the labels for the entity. * @return static Returns an instance of the class. */ public function setLabels(array $labels): self @@ -748,7 +750,7 @@ public function setQueryVar(bool|string $queryVar): self /** * Retrieves the value of the rewrite property. * - * @return bool|array|null The value of the rewrite property. + * @return bool|array|null The value of the rewrite property. */ public function getRewrite(): bool|array|null { @@ -758,7 +760,7 @@ public function getRewrite(): bool|array|null /** * Sets the value of the rewrite property. * - * @param bool|array $rewrite The new value for the rewrite property. + * @param bool|array $rewrite The new value for the rewrite property. * @return static Returns an instance of the current object. */ public function rewrite(bool|array $rewrite): self @@ -773,7 +775,7 @@ public function rewrite(bool|array $rewrite): self * * @deprecated Use withRewrite() instead * - * @param bool|array $rewrite The new value for the rewrite property. + * @param bool|array $rewrite The new value for the rewrite property. * @return static Returns an instance of the current object. */ public function withRewrite(bool|array $rewrite): self @@ -786,7 +788,7 @@ public function withRewrite(bool|array $rewrite): self * * @deprecated Use rewrite() instead * - * @param bool|array $rewrite The new value for the rewrite property. + * @param bool|array $rewrite The new value for the rewrite property. * @return static Returns an instance of the current object. */ public function setRewrite(bool|array $rewrite): self @@ -1004,7 +1006,7 @@ public function setRestControllerClass(bool|string $restControllerClass): self /** * Retrieves the capabilities. * - * @return array|null The capabilities array, or null if it is not set. + * @return array|null The capabilities array, or null if it is not set. */ public function getCapabilities(): ?array { @@ -1014,7 +1016,7 @@ public function getCapabilities(): ?array /** * Sets the capability for the object. * - * @param array $capabilities The capability to set. + * @param array $capabilities The capability to set. * @return static Returns a reference to the object. */ public function capabilities(array $capabilities): self @@ -1029,7 +1031,7 @@ public function capabilities(array $capabilities): self * * @deprecated Use withCapabilities() instead * - * @param array $capabilities The capability to set. + * @param array $capabilities The capability to set. * @return static Returns a reference to the object. */ public function withCapabilities(array $capabilities): self @@ -1042,7 +1044,7 @@ public function withCapabilities(array $capabilities): self * * @deprecated Use capabilities() instead * - * @param array $capabilities The capability to set. + * @param array $capabilities The capability to set. * @return static Returns a reference to the object. */ public function setCapabilities(array $capabilities): self @@ -1179,7 +1181,7 @@ public function setSlug(?string $slug): self /** * Sets the names property with the given array. * - * @param array $names The names to be set. + * @param array $names The names to be set. * @return $this The current instance of the class. */ public function names(array $names): self @@ -1194,7 +1196,7 @@ public function names(array $names): self * * @deprecated Use withNames() instead * - * @param array $names The names to be set. + * @param array $names The names to be set. * @return $this The current instance of the class. */ public function withNames(array $names): self @@ -1207,7 +1209,7 @@ public function withNames(array $names): self * * @deprecated Use names() instead * - * @param array $names The names to be set. + * @param array $names The names to be set. * @return $this The current instance of the class. */ public function setNames(array $names): self @@ -1218,7 +1220,7 @@ public function setNames(array $names): self /** * Retrieves the value of the names property. * - * @return array The value of the names property. + * @return array The value of the names property. */ public function getNames(): array { @@ -1288,7 +1290,7 @@ public function setDashboardGlance(bool $dashboardGlance): self /** * Returns the admin columns for the current object. * - * @return array|null The admin columns array or null if no admin columns are defined. + * @return array|null The admin columns array or null if no admin columns are defined. */ public function getAdminCols(): ?array { @@ -1298,7 +1300,7 @@ public function getAdminCols(): ?array /** * Sets the value of the adminCols property. * - * @param array $adminCols The value to set for the adminCols property. + * @param array $adminCols The value to set for the adminCols property. * @return static Returns this object instance. */ public function adminCols(array $adminCols): self @@ -1313,7 +1315,7 @@ public function adminCols(array $adminCols): self * * @deprecated Use withAdminCols() instead * - * @param array $adminCols The value to set for the adminCols property. + * @param array $adminCols The value to set for the adminCols property. * @return static Returns this object instance. */ public function withAdminCols(array $adminCols): self @@ -1326,7 +1328,7 @@ public function withAdminCols(array $adminCols): self * * @deprecated Use adminCols() instead * - * @param array $adminCols The value to set for the adminCols property. + * @param array $adminCols The value to set for the adminCols property. * @return static Returns this object instance. */ public function setAdminCols(array $adminCols): self @@ -1392,7 +1394,7 @@ abstract public function init(); /** * Get the arguments for the entity. * - * @return array|null The arguments for the entity. + * @return array|null The arguments for the entity. */ public function getArgs(): ?array { diff --git a/src/Domain/Model/PostType.php b/src/Domain/Model/PostType.php index 5f2236d..a9f1dbf 100755 --- a/src/Domain/Model/PostType.php +++ b/src/Domain/Model/PostType.php @@ -19,7 +19,7 @@ class PostType extends Entity * * @since 4.6.0 * - * @var bool + * @var bool|null */ public $excludeFromSearch; @@ -30,7 +30,7 @@ class PostType extends Entity * * @since 4.6.0 * - * @var int + * @var int|null */ public $menuPosition; @@ -46,7 +46,7 @@ class PostType extends Entity * * @since 4.6.0 * - * @var string + * @var string|null */ public $menuIcon; @@ -57,7 +57,7 @@ class PostType extends Entity * * @since 4.6.0 * - * @var bool + * @var bool|null */ public $showInAdminBar; @@ -92,7 +92,7 @@ class PostType extends Entity * * @since 4.6.0 * - * @var callable + * @var callable|null */ public $registerMetaBoxCb; @@ -143,7 +143,7 @@ class PostType extends Entity * * @since 4.6.0 * - * @var bool + * @var bool|null */ public $deleteWithUser; @@ -168,7 +168,7 @@ class PostType extends Entity * @link https://developer.wordpress.org/block-editor/developers/block-api/block-templates/ * @since 5.0.0 * - * @var array[] + * @var array */ public $template; @@ -185,7 +185,7 @@ class PostType extends Entity * @link https://developer.wordpress.org/block-editor/developers/block-api/block-templates/ * @since 5.0.0 * - * @var string|false + * @var bool|string */ public $templateLock; @@ -194,7 +194,7 @@ class PostType extends Entity * * @since 4.6.0 * - * @var array|bool + * @var array|bool */ public $supports; @@ -217,16 +217,22 @@ class PostType extends Entity * admin dashboard. * * Default true. + * + * @var bool|null */ public $dashboardActivity; /** * Placeholder text which appears in the title field for this post type. + * + * @var string|null */ public $enterTitleHere; /** * Text which replaces the 'Featured Image' phrase for this post type. + * + * @var string|null */ public $featuredImage; @@ -234,6 +240,8 @@ class PostType extends Entity * Whether to show Quick Edit links for this post type. * * Default true. + * + * @var bool|null */ public $quickEdit; @@ -241,6 +249,8 @@ class PostType extends Entity * Whether to include this post type in the site's main feed. * * Default false. + * + * @var bool|null */ public $showInFeed; @@ -719,7 +729,7 @@ public function setRegisterMetaBoxCb(?callable $registerMetaBoxCb): self * * This method returns the taxonomies stored in the current instance. * - * @return array|null The taxonomies or null if not set. + * @return array|null The taxonomies or null if not set. */ public function getTaxonomies(): ?array { @@ -729,7 +739,7 @@ public function getTaxonomies(): ?array /** * Set the taxonomies for this object. * - * @param array $taxonomies An array of taxonomies to set. + * @param array $taxonomies An array of taxonomies to set. * @return self Returns itself after setting the taxonomies. */ public function taxonomies(array $taxonomies): self @@ -744,7 +754,7 @@ public function taxonomies(array $taxonomies): self * * @deprecated Use taxonomies() instead * - * @param array $taxonomies An array of taxonomies to set. + * @param array $taxonomies An array of taxonomies to set. * @return self Returns itself after setting the taxonomies. */ public function setTaxonomies(array $taxonomies): self @@ -951,7 +961,7 @@ public function setRestController(\WP_REST_Controller $restController): self /** * Retrieves the template for the site. * - * @return array|null The template for the site, or null if none is set. + * @return array|null The template for the site, or null if none is set. */ public function getTemplate(): ?array { @@ -961,7 +971,7 @@ public function getTemplate(): ?array /** * Sets the template for the object. * - * @param array $template The template to set. + * @param array $template The template to set. * @return self Returns the object itself for method chaining. */ public function template(array $template): self @@ -976,7 +986,7 @@ public function template(array $template): self * * @deprecated Use template() instead * - * @param array $template The template to set. + * @param array $template The template to set. * @return self Returns the object itself for method chaining. */ public function setTemplate(array $template): self @@ -1026,8 +1036,8 @@ public function setTemplateLock(bool|string $templateLock): self /** * Retrieves the supports for the current object. * - * @return bool|array|null The supports for the current object. This will either be a boolean value, an array, - * or null if no supports are set. + * @return bool|array|null The supports for the current object. This will either be a boolean value, an array, + * or null if no supports are set. */ public function getSupports(): bool|array|null { @@ -1037,7 +1047,7 @@ public function getSupports(): bool|array|null /** * Sets the support options for the site. * - * @param bool|array $supports The support options, can be a boolean value or an array of options. + * @param bool|array $supports The support options, can be a boolean value or an array of options. * @return self The updated instance of the class. */ public function supports(bool|array $supports): self @@ -1052,7 +1062,7 @@ public function supports(bool|array $supports): self * * @deprecated Use supports() instead * - * @param bool|array $supports The support options, can be a boolean value or an array of options. + * @param bool|array $supports The support options, can be a boolean value or an array of options. * @return self The updated instance of the class. */ public function setSupports(bool|array $supports): self @@ -1063,7 +1073,7 @@ public function setSupports(bool|array $supports): self /** * Retrieves the admin filters for the site. * - * @return array|null The admin filters for the site, or null if none are set. + * @return array|null The admin filters for the site, or null if none are set. */ public function getAdminFilters(): ?array { @@ -1073,7 +1083,7 @@ public function getAdminFilters(): ?array /** * Sets the admin filters for the site. * - * @param array $adminFilters The admin filters to be set. + * @param array $adminFilters The admin filters to be set. * @return self Returns the current object instance. */ public function adminFilters(array $adminFilters): self @@ -1086,7 +1096,7 @@ public function adminFilters(array $adminFilters): self /** * Retrieves the archive for the site. * - * @return array|null The archive for the site, or null if none is set. + * @return array|null The archive for the site, or null if none is set. */ public function getArchive(): ?array { @@ -1096,7 +1106,7 @@ public function getArchive(): ?array /** * Sets the archive for the site. * - * @param array $archive The archive to set. + * @param array $archive The archive to set. * @return self The updated instance of the class. */ public function archive(array $archive): self @@ -1111,7 +1121,7 @@ public function archive(array $archive): self * * @deprecated Use archive() instead * - * @param array $archive The archive to set. + * @param array $archive The archive to set. * @return self The updated instance of the class. */ public function setArchive(array $archive): self @@ -1458,7 +1468,7 @@ public function setShowInFeed(bool $showInFeed): self /** * Retrieves the site filters. * - * @return array|null The site filters, if available; otherwise null. + * @return array|null The site filters, if available; otherwise null. */ public function getSiteFilters(): ?array { @@ -1468,7 +1478,7 @@ public function getSiteFilters(): ?array /** * Set the site filters. * - * @param array $siteFilters The array containing site filters. + * @param array $siteFilters The array containing site filters. * @return self The current object with the updated site filters. */ public function siteFilters(array $siteFilters): self @@ -1481,7 +1491,7 @@ public function siteFilters(array $siteFilters): self /** * Retrieves the sortables for the site. * - * @return array|null The sortables for the site, or null if none are set. + * @return array|null The sortables for the site, or null if none are set. */ public function getSiteSortables(): ?array { @@ -1491,7 +1501,7 @@ public function getSiteSortables(): ?array /** * Set the site sortables. * - * @param array $siteSortables The array of site sortables. + * @param array $siteSortables The array of site sortables. * @return self The current instance of the object. */ public function siteSortables(array $siteSortables): self diff --git a/src/Domain/Model/Taxonomy.php b/src/Domain/Model/Taxonomy.php index 9d73a5d..555d7dd 100755 --- a/src/Domain/Model/Taxonomy.php +++ b/src/Domain/Model/Taxonomy.php @@ -43,7 +43,7 @@ class Taxonomy extends Entity * * @since 4.7.0 * - * @var bool|callable + * @var bool|callable|null */ public $metaBoxCb; @@ -52,7 +52,7 @@ class Taxonomy extends Entity * * @since 5.1.0 * - * @var callable + * @var callable|null */ public $metaBoxSanitizeCb; @@ -71,7 +71,7 @@ class Taxonomy extends Entity * * @since 5.5.0 * - * @var array|string + * @var array|string */ public $defaultTerm; @@ -91,7 +91,7 @@ class Taxonomy extends Entity * * @since 2.6.0 * - * @var array|null + * @var array|null */ public $args; @@ -99,6 +99,8 @@ class Taxonomy extends Entity * This allows you to override WordPress' default behaviour if necessary. * * Default false if you're using a custom meta box (see the `$meta_box` argument), default true otherwise. + * + * @var bool|null */ public $checkedOntop; @@ -111,6 +113,8 @@ class Taxonomy extends Entity * post, but rather each post can exclusively have only one term. It's not feature * complete because you can edit a post in Quick Edit and give it more than one term * from the taxonomy. + * + * @var bool|null */ public $exclusive; @@ -118,6 +122,8 @@ class Taxonomy extends Entity * All this does currently is disable hierarchy in the taxonomy's rewrite rules. * * Default false. + * + * @var bool|null */ public $allowHierarchy; @@ -130,7 +136,7 @@ class Taxonomy extends Entity * Taxonomy constructor. * * @param string $slug The slug of the taxonomy. - * @param string|array $objectType The post type(s) to associate with this taxonomy. + * @param string|array $objectType The post type(s) to associate with this taxonomy. * @param string|null $singular The singular label for the taxonomy. * @param string|null $plural The plural label for the taxonomy. */ @@ -149,7 +155,7 @@ public function __construct( * Factory method to create a new taxonomy. * * @param string $slug The slug to set. - * @param string|array $objectType The post type(s) to be associated. + * @param string|array $objectType The post type(s) to be associated. * @param string|null $singular (Optional) The singular label. * @param string|null $plural (Optional) The plural form of the label. * @return self Returns a new instance of the class. @@ -192,7 +198,7 @@ public function getSlug(): string /** * Gets the object type(s) associated with this taxonomy. * - * @return string|array The object type(s) + * @return string|array The object type(s) */ public function getObjectType(): string|array { @@ -492,8 +498,8 @@ public function setUpdateCountCallback(callable $updateCountCallback): self /** * Retrieves the default term value. * - * @return array|string|null The default term value. If a default term is set, it will be returned as an array, - * otherwise it can be null or a string. + * @return array|string|null The default term value. If a default term is set, it will be returned as an array, + * otherwise it can be null or a string. */ public function getDefaultTerm(): array|string|null { @@ -503,7 +509,7 @@ public function getDefaultTerm(): array|string|null /** * Sets the default term for the taxonomy. * - * @param array|string $defaultTerm The default term for the taxonomy. Can be either an array or a string. + * @param array|string $defaultTerm The default term for the taxonomy. Can be either an array or a string. * @return self The current instance of the Taxonomy object. */ public function defaultTerm(array|string $defaultTerm): self @@ -518,7 +524,7 @@ public function defaultTerm(array|string $defaultTerm): self * * @deprecated Use defaultTerm() instead * - * @param array|string $defaultTerm The default term for the taxonomy. Can be either an array or a string. + * @param array|string $defaultTerm The default term for the taxonomy. Can be either an array or a string. * @return self The current instance of the Taxonomy object. */ public function setDefaultTerm(array|string $defaultTerm): self @@ -591,7 +597,7 @@ public function setSort(?bool $sort): self /** * Set the arguments for the taxonomy. * - * @param array|null $args The arguments for the taxonomy. + * @param array|null $args The arguments for the taxonomy. * @return self Returns the updated Taxonomy object. */ public function args(?array $args): self @@ -606,7 +612,7 @@ public function args(?array $args): self * * @deprecated Use args() instead * - * @param array|null $args The arguments for the taxonomy. + * @param array|null $args The arguments for the taxonomy. * @return self Returns the updated Taxonomy object. */ public function setArgs(?array $args): self diff --git a/src/Port/Out/EntityRegistryPort.php b/src/Port/Out/EntityRegistryPort.php index 45f0554..5f85a3e 100755 --- a/src/Port/Out/EntityRegistryPort.php +++ b/src/Port/Out/EntityRegistryPort.php @@ -16,8 +16,8 @@ interface EntityRegistryPort * Registers an entity with WordPress. * * @param string $slug The entity slug - * @param array $args Registration arguments - * @param array $names Entity names (singular, plural) + * @param array $args Registration arguments + * @param array $names Entity names (singular, plural) */ public function register(string $slug, array $args, array $names): void; } diff --git a/src/Port/Out/PostTypeRegistryPort.php b/src/Port/Out/PostTypeRegistryPort.php index a9e094c..b6c7336 100755 --- a/src/Port/Out/PostTypeRegistryPort.php +++ b/src/Port/Out/PostTypeRegistryPort.php @@ -13,8 +13,8 @@ interface PostTypeRegistryPort extends EntityRegistryPort * Registers a post type with WordPress. * * @param string $slug The post type slug - * @param array $args Registration arguments - * @param array $names Post type names (singular, plural) + * @param array $args Registration arguments + * @param array $names Post type names (singular, plural) */ public function registerPostType(string $slug, array $args, array $names): void; } diff --git a/src/Port/Out/TaxonomyRegistryPort.php b/src/Port/Out/TaxonomyRegistryPort.php index 33ea82c..c0939f4 100755 --- a/src/Port/Out/TaxonomyRegistryPort.php +++ b/src/Port/Out/TaxonomyRegistryPort.php @@ -13,9 +13,9 @@ interface TaxonomyRegistryPort extends EntityRegistryPort * Registers a taxonomy with WordPress. * * @param string $slug The taxonomy slug - * @param string|array $objectType The post type(s) the taxonomy is associated with - * @param array $args Registration arguments - * @param array $names Taxonomy names (singular, plural) + * @param string|array $objectType The post type(s) the taxonomy is associated with + * @param array $args Registration arguments + * @param array $names Taxonomy names (singular, plural) */ public function registerTaxonomy(string $slug, string|array $objectType, array $args, array $names): void; } diff --git a/src/Taxonomy.php b/src/Taxonomy.php index 2fb897e..7fc1b18 100755 --- a/src/Taxonomy.php +++ b/src/Taxonomy.php @@ -21,7 +21,7 @@ class Taxonomy * Create a new taxonomy. * * @param string $slug The slug of the taxonomy. - * @param string|array $objectType The post type(s) to associate with this taxonomy. + * @param string|array $objectType The post type(s) to associate with this taxonomy. * @param string|null $singular The singular label for the taxonomy. * @param string|null $plural The plural label for the taxonomy. * @return TaxonomyDomain The created taxonomy domain model. diff --git a/tests/Helpers/helpers.php b/tests/Helpers/helpers.php index 878bfdd..95bfcca 100755 --- a/tests/Helpers/helpers.php +++ b/tests/Helpers/helpers.php @@ -8,6 +8,9 @@ if (! function_exists('add_action')) { function add_action($hook, $callback, $priority = 10, $accepted_args = 1) { + // Kept for the tests that look at the priority a hook is registered with + $GLOBALS['entity_test_hook_priorities'][$hook] = $priority; + // Execute the callback immediately to simulate WordPress hook if ($hook === 'init') { $callback(); diff --git a/tests/Unit/MutationRegistrationTest.php b/tests/Unit/MutationRegistrationTest.php index 97e1bd0..66dbdd8 100644 --- a/tests/Unit/MutationRegistrationTest.php +++ b/tests/Unit/MutationRegistrationTest.php @@ -45,6 +45,7 @@ test('the registration service passes args without names and names separately', function () { $registry = new class implements EntityRegistryPort { + /** @var list> */ public array $calls = []; public function register(string $slug, array $args, array $names): void @@ -59,7 +60,7 @@ public function register(string $slug, array $args, array $names): void public function init(): void {} - public function getArgs(): ?array + public function getArgs(): array { return ['label' => 'Thing']; } @@ -83,6 +84,7 @@ public function getSlug(): string test('the registration service passes empty names when the translated args drop them', function () { $registry = new class implements EntityRegistryPort { + /** @var list> */ public array $calls = []; public function register(string $slug, array $args, array $names): void @@ -97,7 +99,7 @@ public function register(string $slug, array $args, array $names): void public function init(): void {} - public function getArgs(): ?array + public function getArgs(): array { return ['label' => 'Thing']; } @@ -136,3 +138,21 @@ public function init(): void {} expect($entity->getSlug())->toBe(''); }); + +test('a null declaration priority falls back to the declared priority', function (): void { + $registry = new class implements EntityRegistryPort + { + public function register(string $slug, array $args, array $names): void {} + }; + $entity = new class('movie', 'Movie', 'Movies') extends PostTypeDomain + { + public function getPriority(): ?int + { + return null; + } + }; + + (new EntityRegistrationService($registry))->registerEntity($entity); + + expect($GLOBALS['entity_test_hook_priorities']['init'])->toBe($entity->priority); +});