diff --git a/composer.json b/composer.json index 813c5bb..a97cfc4 100644 --- a/composer.json +++ b/composer.json @@ -43,9 +43,7 @@ "10up/phpcs-composer": "^3.0", "phpcompatibility/php-compatibility": "dev-develop as 9.99.99", "phpunit/php-code-coverage": "^9.2", - "slevomat/coding-standard": "^8.15", - "rector/rector": "^2.0", - "tomasvotruba/type-coverage": "^2.0" + "slevomat/coding-standard": "^8.15" }, "scripts": { "test": "XDEBUG_MODE=coverage ./vendor/bin/phpunit", @@ -54,10 +52,6 @@ "static": [ "Composer\\Config::disableProcessTimeout", "phpstan --memory-limit=1G" - ], - "rector": [ - "./vendor/bin/rector", - "composer run lint-fix" ] }, "config": { diff --git a/composer.lock b/composer.lock index f386d5f..7f69bb0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "88da233f8a52d5119878cc443defdcdd", + "content-hash": "5c674b2bd34e9e2105a937d69259c184", "packages": [ { "name": "amphp/amp", @@ -2329,95 +2329,6 @@ ], "time": "2025-02-12T12:17:51+00:00" }, - { - "name": "nette/utils", - "version": "v4.0.8", - "source": { - "type": "git", - "url": "https://github.com/nette/utils.git", - "reference": "c930ca4e3cf4f17dcfb03037703679d2396d2ede" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/c930ca4e3cf4f17dcfb03037703679d2396d2ede", - "reference": "c930ca4e3cf4f17dcfb03037703679d2396d2ede", - "shasum": "" - }, - "require": { - "php": "8.0 - 8.5" - }, - "conflict": { - "nette/finder": "<3", - "nette/schema": "<1.2.2" - }, - "require-dev": { - "jetbrains/phpstorm-attributes": "^1.2", - "nette/tester": "^2.5", - "phpstan/phpstan-nette": "^2.0@stable", - "tracy/tracy": "^2.9" - }, - "suggest": { - "ext-gd": "to use Image", - "ext-iconv": "to use Strings::webalize(), toAscii(), chr() and reverse()", - "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", - "ext-json": "to use Nette\\Utils\\Json", - "ext-mbstring": "to use Strings::lower() etc...", - "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "psr-4": { - "Nette\\": "src" - }, - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause", - "GPL-2.0-only", - "GPL-3.0-only" - ], - "authors": [ - { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" - } - ], - "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", - "homepage": "https://nette.org", - "keywords": [ - "array", - "core", - "datetime", - "images", - "json", - "nette", - "paginator", - "password", - "slugify", - "string", - "unicode", - "utf-8", - "utility", - "validation" - ], - "support": { - "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v4.0.8" - }, - "time": "2025-08-06T21:43:34+00:00" - }, { "name": "nikic/php-parser", "version": "v5.4.0", @@ -3662,65 +3573,6 @@ ], "time": "2024-12-05T13:48:26+00:00" }, - { - "name": "rector/rector", - "version": "2.0.10", - "source": { - "type": "git", - "url": "https://github.com/rectorphp/rector.git", - "reference": "5844a718acb40f40afcd110394270afa55509fd0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/5844a718acb40f40afcd110394270afa55509fd0", - "reference": "5844a718acb40f40afcd110394270afa55509fd0", - "shasum": "" - }, - "require": { - "php": "^7.4|^8.0", - "phpstan/phpstan": "^2.1.6" - }, - "conflict": { - "rector/rector-doctrine": "*", - "rector/rector-downgrade-php": "*", - "rector/rector-phpunit": "*", - "rector/rector-symfony": "*" - }, - "suggest": { - "ext-dom": "To manipulate phpunit.xml via the custom-rule command" - }, - "bin": [ - "bin/rector" - ], - "type": "library", - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Instant Upgrade and Automated Refactoring of any PHP code", - "keywords": [ - "automation", - "dev", - "migration", - "refactoring" - ], - "support": { - "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/2.0.10" - }, - "funding": [ - { - "url": "https://github.com/tomasvotruba", - "type": "github" - } - ], - "time": "2025-03-03T17:35:18+00:00" - }, { "name": "sebastian/cli-parser", "version": "1.0.2", @@ -5002,63 +4854,6 @@ ], "time": "2024-03-03T12:36:25+00:00" }, - { - "name": "tomasvotruba/type-coverage", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/TomasVotruba/type-coverage.git", - "reference": "d033429580f2c18bda538fa44f2939236a990e0c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/TomasVotruba/type-coverage/zipball/d033429580f2c18bda538fa44f2939236a990e0c", - "reference": "d033429580f2c18bda538fa44f2939236a990e0c", - "shasum": "" - }, - "require": { - "nette/utils": "^3.2 || ^4.0", - "php": "^7.4 || ^8.0", - "phpstan/phpstan": "^2.0" - }, - "type": "phpstan-extension", - "extra": { - "phpstan": { - "includes": [ - "config/extension.neon" - ] - } - }, - "autoload": { - "psr-4": { - "TomasVotruba\\TypeCoverage\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Measure type coverage of your project", - "keywords": [ - "phpstan-extension", - "static analysis" - ], - "support": { - "issues": "https://github.com/TomasVotruba/type-coverage/issues", - "source": "https://github.com/TomasVotruba/type-coverage/tree/2.0.2" - }, - "funding": [ - { - "url": "https://www.paypal.me/rectorphp", - "type": "custom" - }, - { - "url": "https://github.com/tomasvotruba", - "type": "github" - } - ], - "time": "2025-01-07T00:10:26+00:00" - }, { "name": "wp-coding-standards/wpcs", "version": "3.1.0", diff --git a/fixtures/classes/PostTypes/Demo.php b/fixtures/classes/PostTypes/Demo.php index 8e5c515..410cf46 100644 --- a/fixtures/classes/PostTypes/Demo.php +++ b/fixtures/classes/PostTypes/Demo.php @@ -21,7 +21,7 @@ class Demo extends AbstractPostType { * * @return string */ - public function get_name(): string { + public function get_name() { return 'tenup-demo'; } @@ -30,7 +30,7 @@ public function get_name(): string { * * @return string */ - public function get_singular_label(): string { + public function get_singular_label() { return esc_html__( 'Demo', 'tenup-plugin' ); } @@ -39,7 +39,7 @@ public function get_singular_label(): string { * * @return string */ - public function get_plural_label(): string { + public function get_plural_label() { return esc_html__( 'Demos', 'tenup-plugin' ); } @@ -52,7 +52,7 @@ public function get_plural_label(): string { * * @return string */ - public function get_menu_icon(): string { + public function get_menu_icon() { return 'dashicons-chart-pie'; } @@ -61,7 +61,7 @@ public function get_menu_icon(): string { * * @return bool */ - public function can_register(): bool { + public function can_register() { return true; } @@ -71,7 +71,7 @@ public function can_register(): bool { * * @return array */ - public function get_supported_taxonomies(): array { + public function get_supported_taxonomies() { return [ 'tenup-tax-demo', ]; @@ -82,7 +82,7 @@ public function get_supported_taxonomies(): array { * * @return void */ - public function after_register(): void { + public function after_register() { // Register any hooks/filters you need. } } diff --git a/fixtures/classes/PostTypes/Page.php b/fixtures/classes/PostTypes/Page.php index 7815534..fa360d4 100644 --- a/fixtures/classes/PostTypes/Page.php +++ b/fixtures/classes/PostTypes/Page.php @@ -24,7 +24,7 @@ class Page extends AbstractCorePostType { * * @return string */ - public function get_name(): string { + public function get_name() { return 'page'; } @@ -34,7 +34,7 @@ public function get_name(): string { * * @return array */ - public function get_supported_taxonomies(): array { + public function get_supported_taxonomies() { return []; } @@ -43,7 +43,7 @@ public function get_supported_taxonomies(): array { * * @return void */ - public function after_register(): void { + public function after_register() { // Do nothing. } } diff --git a/fixtures/classes/PostTypes/Post.php b/fixtures/classes/PostTypes/Post.php index 21c93ab..ce4a28c 100644 --- a/fixtures/classes/PostTypes/Post.php +++ b/fixtures/classes/PostTypes/Post.php @@ -24,7 +24,7 @@ class Post extends AbstractCorePostType { * * @return string */ - public function get_name(): string { + public function get_name() { return 'post'; } @@ -36,7 +36,7 @@ public function get_name(): string { * * @return array */ - public function get_supported_taxonomies(): array { + public function get_supported_taxonomies() { return []; } @@ -45,7 +45,7 @@ public function get_supported_taxonomies(): array { * * @return void */ - public function after_register(): void { + public function after_register() { // Do nothing. } } diff --git a/fixtures/classes/Standalone/Standalone.php b/fixtures/classes/Standalone/Standalone.php index 94bfdb7..d52c2b8 100644 --- a/fixtures/classes/Standalone/Standalone.php +++ b/fixtures/classes/Standalone/Standalone.php @@ -27,7 +27,7 @@ public function __construct() { * * @return void */ - public function init(): void { + public function init() { echo 'Hello from the Standalone class!'; } } diff --git a/fixtures/classes/Taxonomies/Demo.php b/fixtures/classes/Taxonomies/Demo.php index 281dc6b..de86cc6 100644 --- a/fixtures/classes/Taxonomies/Demo.php +++ b/fixtures/classes/Taxonomies/Demo.php @@ -21,7 +21,7 @@ class Demo extends AbstractTaxonomy { * * @return string */ - public function get_name(): string { + public function get_name() { return 'tenup-tax-demo'; } @@ -30,7 +30,7 @@ public function get_name(): string { * * @return string */ - public function get_singular_label(): string { + public function get_singular_label() { return esc_html__( 'Demo Term', 'tenup-plugin' ); } @@ -39,7 +39,7 @@ public function get_singular_label(): string { * * @return string */ - public function get_plural_label(): string { + public function get_plural_label() { return esc_html__( 'Demo Terms', 'tenup-plugin' ); } @@ -48,7 +48,7 @@ public function get_plural_label(): string { * * @return bool */ - public function can_register(): bool { + public function can_register() { return true; } } diff --git a/phpstan.neon b/phpstan.neon index b6c7924..4d9795d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,6 @@ includes: - vendor/szepeviktor/phpstan-wordpress/extension.neon - vendor/phpstan/phpstan-deprecation-rules/rules.neon - - vendor/tomasvotruba/type-coverage/config/extension.neon parameters: paths: @@ -17,8 +16,3 @@ parameters: - '#^Function remove_filter invoked with [34567] parameters, 2-3 required\.$#' # Remove issues that come from using array as a type rather than string[] or array etc. - '#no value type specified in iterable type array#' - type_coverage: - return: 99 - param: 99 - property: 99 - constant: 99 diff --git a/rector.php b/rector.php deleted file mode 100644 index fac46ff..0000000 --- a/rector.php +++ /dev/null @@ -1,27 +0,0 @@ -withPaths([ - __DIR__ . '/src', - __DIR__ . '/fixtures', - ]) - ->withSkip([ - __DIR__ . '/**/node_modules/**', - __DIR__ . '/**/vendor/**', - __DIR__ . '/**/dist/**', - - ]) - ->withPhpSets(php83: true) - ->withTypeCoverageLevel(49) - ->withSkip([ - Rector\Php81\Rector\Array_\FirstClassCallableRector::class, - Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector::class, - Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector::class, - Rector\Php53\Rector\Ternary\TernaryToElvisRector::class, - Rector\Php81\Rector\Property\ReadOnlyPropertyRector::class, - ]); diff --git a/src/Assets/GetAssetInfo.php b/src/Assets/GetAssetInfo.php index f2d13a3..5241f31 100644 --- a/src/Assets/GetAssetInfo.php +++ b/src/Assets/GetAssetInfo.php @@ -23,22 +23,24 @@ trait GetAssetInfo { * * @var ?string */ - public ?string $dist_path = null; + public $dist_path = null; /** * Fallback version to use if asset file is not found * * @var ?string */ - public ?string $fallback_version = null; + public $fallback_version = null; /** * Setup asset variables * * @param string $dist_path Path to the dist directory * @param string $fallback_version Fallback version to use if asset file is not found + * + * @return void */ - public function setup_asset_vars( string $dist_path, string $fallback_version ): void { + public function setup_asset_vars( string $dist_path, string $fallback_version ) { $this->dist_path = trailingslashit( $dist_path ); $this->fallback_version = $fallback_version; } @@ -53,7 +55,7 @@ public function setup_asset_vars( string $dist_path, string $fallback_version ): * * @return string|($attribute is null ? array{version: string, dependencies: array} : $attribute is'dependencies' ? array : string) */ - public function get_asset_info( string $slug, ?string $attribute = null ): string|array { + public function get_asset_info( string $slug, ?string $attribute = null ) { if ( is_null( $this->dist_path ) || is_null( $this->fallback_version ) ) { throw new RuntimeException( 'Asset variables not set. Please run setup_asset_vars() before calling get_asset_info().' ); diff --git a/src/Module.php b/src/Module.php index a4fc4c7..fc67ebf 100644 --- a/src/Module.php +++ b/src/Module.php @@ -20,18 +20,24 @@ trait Module { * Lower number will be initialized first. * * @note This has no correlation to the `init` priority. It's just a way to allow certain classes to be initialized before others. + * + * @return int The priority of the module. */ - public function load_order(): int { + public function load_order() { return 10; } /** * Checks whether the Module should run within the current context. + * + * @return bool */ - abstract public function can_register(): bool; + abstract public function can_register(); /** * Connects the Module with WordPress using Hooks and/or Filters. + * + * @return void */ - abstract public function register(): void; + abstract public function register(); } diff --git a/src/ModuleInitialization.php b/src/ModuleInitialization.php index 01271cd..5c53d4b 100644 --- a/src/ModuleInitialization.php +++ b/src/ModuleInitialization.php @@ -24,14 +24,16 @@ class ModuleInitialization { /** * The class instance. * - * @var ?\TenupFramework\ModuleInitialization + * @var null|ModuleInitialization */ - private static ?\TenupFramework\ModuleInitialization $instance = null; + private static $instance = null; /** * Get the instance of the class. + * + * @return ModuleInitialization */ - public static function instance(): \TenupFramework\ModuleInitialization { + public static function instance() { if ( null === self::$instance ) { self::$instance = new self(); } @@ -50,7 +52,7 @@ private function __construct() { * * @var array */ - protected array $classes = []; + protected $classes = []; /** * Get all the TenupFramework plugin classes. @@ -59,7 +61,7 @@ private function __construct() { * * @return array */ - public function get_classes( string $dir ): array { + public function get_classes( $dir ) { $this->directory_check( $dir ); // Get all classes from this directory and its subdirectories. @@ -75,8 +77,7 @@ public function get_classes( string $dir ): array { ); } - // @phpstan-ignore-next-line typeCoverage.paramTypeCoverage - $classes = array_filter( $class_finder->get(), fn( $cl ): bool => is_string( $cl ) ); + $classes = array_filter( $class_finder->get(), fn( $cl ) => is_string( $cl ) ); // Return the classes return $classes; @@ -88,8 +89,10 @@ public function get_classes( string $dir ): array { * @param string $dir The directory to check. * * @throws \RuntimeException If the directory does not exist. + * + * @return bool */ - protected function directory_check( ?string $dir ): bool { + protected function directory_check( $dir ): bool { if ( empty( $dir ) ) { throw new \RuntimeException( 'Directory is required to initialize classes.' ); } @@ -106,12 +109,13 @@ protected function directory_check( ?string $dir ): bool { * Initialize all the TenupFramework plugin classes. * * @param string $dir The directory to search for classes. + * + * @return void */ - public function init_classes( ?string $dir = '' ): void { + public function init_classes( $dir = '' ) { $this->directory_check( $dir ); $load_class_order = []; - // @phpstan-ignore-next-line argument.type foreach ( $this->get_classes( $dir ) as $class ) { // Create a slug for the class name. $slug = $this->slugify_class_name( $class ); @@ -134,7 +138,7 @@ public function init_classes( ?string $dir = '' ): void { } // Check if the class implements ModuleInterface before instantiating it - if ( ! $reflection_class->implementsInterface( \TenupFramework\ModuleInterface::class ) ) { + if ( ! $reflection_class->implementsInterface( 'TenupFramework\ModuleInterface' ) ) { continue; } @@ -177,6 +181,8 @@ public function init_classes( ?string $dir = '' ): void { * * @param string $class_name The name of the class to load. * + * @return false|ReflectionClass Returns a ReflectionClass instance if the class is loadable, or false if it is not. + * * @phpstan-ignore missingType.generics */ public function get_fully_loadable_class( string $class_name ): false|ReflectionClass { @@ -184,7 +190,7 @@ public function get_fully_loadable_class( string $class_name ): false|Reflection // Create a new reflection of the class. // @phpstan-ignore argument.type return new ReflectionClass( $class_name ); - } catch ( \Throwable ) { + } catch ( \Throwable $e ) { // This includes ReflectionException, Error due to missing parent, etc. return false; } @@ -194,8 +200,10 @@ public function get_fully_loadable_class( string $class_name ): false|Reflection * Slugify a class name. * * @param string $class_name The class name. + * + * @return string */ - protected function slugify_class_name( string $class_name ): string { + protected function slugify_class_name( $class_name ) { return sanitize_title( str_replace( '\\', '-', $class_name ) ); } @@ -203,8 +211,10 @@ protected function slugify_class_name( string $class_name ): string { * Get a class by its full class name, including namespace. * * @param string $class_name The class name & namespace. + * + * @return false|ModuleInterface */ - public function get_class( string $class_name ): false|ModuleInterface { + public function get_class( $class_name ) { $class_name = $this->slugify_class_name( $class_name ); if ( isset( $this->classes[ $class_name ] ) ) { @@ -219,7 +229,7 @@ public function get_class( string $class_name ): false|ModuleInterface { * * @return array */ - public function get_all_classes(): array { + public function get_all_classes() { return $this->classes; } @@ -227,8 +237,10 @@ public function get_all_classes(): array { * Get an initialized class by its full class name, including namespace. * * @param string $class_name The class name including the namespace. + * + * @return false|ModuleInterface */ - public static function get_module( string $class_name ): false|ModuleInterface { + public static function get_module( $class_name ) { return self::instance()->get_class( $class_name ); } } diff --git a/src/ModuleInterface.php b/src/ModuleInterface.php index b03b7e1..960ec7b 100644 --- a/src/ModuleInterface.php +++ b/src/ModuleInterface.php @@ -20,16 +20,22 @@ interface ModuleInterface { * Lower number will be initialized first. * * @note This has no correlation to the `init` priority. It's just a way to allow certain classes to be initialized before others. + * + * @return int The priority of the module. */ - public function load_order(): int; + public function load_order(); /** * Checks whether the Module should run within the current context. + * + * @return bool */ - public function can_register(): bool; + public function can_register(); /** * Connects the Module with WordPress using Hooks and/or Filters. + * + * @return void */ - public function register(): void; + public function register(); } diff --git a/src/PostTypes/AbstractCorePostType.php b/src/PostTypes/AbstractCorePostType.php index 4a92884..1823423 100644 --- a/src/PostTypes/AbstractCorePostType.php +++ b/src/PostTypes/AbstractCorePostType.php @@ -22,8 +22,10 @@ abstract class AbstractCorePostType extends AbstractPostType { * Get the singular post type label. * * No-op for core post types since they are already registered by WordPress. + * + * @return string */ - public function get_singular_label(): string { + public function get_singular_label() { return ''; } @@ -31,8 +33,10 @@ public function get_singular_label(): string { * Get the plural post type label. * * No-op for core post types since they are already registered by WordPress. + * + * @return string */ - public function get_plural_label(): string { + public function get_plural_label() { return ''; } @@ -40,8 +44,10 @@ public function get_plural_label(): string { * Get the menu icon for the post type. * * No-op for core post types since they are already registered by WordPress. + * + * @return string */ - public function get_menu_icon(): string { + public function get_menu_icon() { return ''; } @@ -49,16 +55,23 @@ public function get_menu_icon(): string { * Checks whether the Module should run within the current context. * * True for core post types since they are already registered by WordPress. + * + * @return bool */ - public function can_register(): bool { + public function can_register() { return true; } /** * Registers a post type and associates its taxonomies. + * + * @uses $this->get_name() to get the post's type name. + * @return Bool Whether this theme has supports for this post type. */ - public function register(): void { + public function register() { $this->register_taxonomies(); $this->after_register(); + + return true; } } diff --git a/src/PostTypes/AbstractPostType.php b/src/PostTypes/AbstractPostType.php index 855ae95..d945df3 100644 --- a/src/PostTypes/AbstractPostType.php +++ b/src/PostTypes/AbstractPostType.php @@ -46,18 +46,24 @@ abstract class AbstractPostType implements ModuleInterface { /** * Get the post type name. + * + * @return string */ - abstract public function get_name(): string; + abstract public function get_name(); /** * Get the singular post type label. + * + * @return string */ - abstract public function get_singular_label(): string; + abstract public function get_singular_label(); /** * Get the plural post type label. + * + * @return string */ - abstract public function get_plural_label(): string; + abstract public function get_plural_label(); /** * Get the menu icon for the post type. @@ -65,20 +71,26 @@ abstract public function get_plural_label(): string; * This can be a base64 encoded SVG, a dashicons class or 'none' to leave it empty so it can be filled with CSS. * * @see https://developer.wordpress.org/resource/dashicons/ + * + * @return string */ - abstract public function get_menu_icon(): string; + abstract public function get_menu_icon(); /** * Get the menu position for the post type. + * + * @return int|null */ - public function get_menu_position(): int|null { + public function get_menu_position() { return null; } /** * Is the post type hierarchical? + * + * @return bool */ - public function is_hierarchical(): bool { + public function is_hierarchical() { return false; } @@ -87,7 +99,7 @@ public function is_hierarchical(): bool { * * @return array */ - public function get_editor_supports(): array { + public function get_editor_supports() { $supports = [ 'title', 'editor', @@ -142,7 +154,7 @@ public function get_editor_supports(): array { * template_lock?: string|false, * } */ - public function get_options(): array { + public function get_options() { $options = [ 'labels' => $this->get_labels(), 'public' => true, @@ -170,7 +182,7 @@ public function get_options(): array { * * @return array */ - public function get_labels(): array { + public function get_labels() { $plural_label = $this->get_plural_label(); $singular_label = $this->get_singular_label(); @@ -213,18 +225,25 @@ public function get_labels(): array { /** * Registers a post type and associates its taxonomies. + * + * @uses $this->get_name() to get the post's type name. + * @return Bool Whether this theme has supports for this post type. */ - public function register(): void { + public function register() { $this->register_post_type(); $this->register_taxonomies(); $this->after_register(); + + return true; } /** * Registers the current post type with WordPress. + * + * @return void */ - public function register_post_type(): void { + public function register_post_type() { register_post_type( $this->get_name(), $this->get_options() @@ -233,8 +252,10 @@ public function register_post_type(): void { /** * Registers the taxonomies declared with the current post type. + * + * @return void */ - public function register_taxonomies(): void { + public function register_taxonomies() { $taxonomies = $this->get_supported_taxonomies(); $object_type = $this->get_name(); @@ -255,14 +276,16 @@ public function register_taxonomies(): void { * * @return array */ - public function get_supported_taxonomies(): array { + public function get_supported_taxonomies() { return []; } /** * Run any code after the post type has been registered. + * + * @return void */ - public function after_register(): void { + public function after_register() { // Do nothing. } } diff --git a/src/Taxonomies/AbstractTaxonomy.php b/src/Taxonomies/AbstractTaxonomy.php index 328b0a2..c3dfdf3 100644 --- a/src/Taxonomies/AbstractTaxonomy.php +++ b/src/Taxonomies/AbstractTaxonomy.php @@ -44,30 +44,40 @@ abstract class AbstractTaxonomy implements ModuleInterface { * Used to alter the order in which classes are initialized. * * Lower number will be initialized first. + * + * @return int */ - public function load_order(): int { + public function load_order() { return 9; } /** * Get the taxonomy name. + * + * @return string */ - abstract public function get_name(): string; + abstract public function get_name(); /** * Get the singular taxonomy label. + * + * @return string */ - abstract public function get_singular_label(): string; + abstract public function get_singular_label(); /** * Get the plural taxonomy label. + * + * @return string */ - abstract public function get_plural_label(): string; + abstract public function get_plural_label(); /** * Is the taxonomy hierarchical? + * + * @return bool */ - public function is_hierarchical(): bool { + public function is_hierarchical() { return false; } @@ -75,8 +85,9 @@ public function is_hierarchical(): bool { * Register hooks and actions. * * @uses $this->get_name() to get the taxonomy's slug. + * @return bool */ - public function register(): void { + public function register() { \register_taxonomy( $this->get_name(), $this->get_post_types(), @@ -84,6 +95,8 @@ public function register(): void { ); $this->after_register(); + + return true; } /** @@ -124,7 +137,7 @@ public function register(): void { * _builtin?: bool, * } */ - public function get_options(): array { + public function get_options() { return [ 'labels' => $this->get_labels(), 'hierarchical' => $this->is_hierarchical(), @@ -141,7 +154,7 @@ public function get_options(): array { * * @return array */ - public function get_labels(): array { + public function get_labels() { $plural_label = $this->get_plural_label(); $singular_label = $this->get_singular_label(); @@ -174,14 +187,16 @@ public function get_labels(): array { * * @return array */ - public function get_post_types(): array { + public function get_post_types() { return []; } /** * Run any code after the taxonomy has been registered. + * + * @return void */ - public function after_register(): void { + public function after_register() { // Do nothing. } }