From aac408ad5b7613755508d2af9ee492450698a989 Mon Sep 17 00:00:00 2001 From: James Morrison Date: Wed, 17 Sep 2025 17:50:21 +0100 Subject: [PATCH 1/2] Add explicit return type declarations to PHP methods for WP Framework compatibility. --- mu-plugins/10up-plugin/src/Assets.php | 8 ++++---- mu-plugins/10up-plugin/src/PostTypes/Demo.php | 14 +++++++------- mu-plugins/10up-plugin/src/PostTypes/Page.php | 6 +++--- mu-plugins/10up-plugin/src/PostTypes/Post.php | 6 +++--- mu-plugins/10up-plugin/src/Taxonomies/Demo.php | 8 ++++---- themes/10up-block-theme/src/Assets.php | 12 ++++++------ themes/10up-block-theme/src/Blocks.php | 8 ++++---- themes/10up-block-theme/src/TemplateTags.php | 6 +++--- themes/10up-theme/src/Assets.php | 10 +++++----- themes/10up-theme/src/Blocks.php | 12 ++++++------ 10 files changed, 45 insertions(+), 45 deletions(-) diff --git a/mu-plugins/10up-plugin/src/Assets.php b/mu-plugins/10up-plugin/src/Assets.php index c9a6607c..4dca15b8 100644 --- a/mu-plugins/10up-plugin/src/Assets.php +++ b/mu-plugins/10up-plugin/src/Assets.php @@ -26,7 +26,7 @@ class Assets implements ModuleInterface { * * @return bool */ - public function can_register() { + public function can_register(): bool { return true; } @@ -35,7 +35,7 @@ public function can_register() { * * @return void */ - public function register() { + public function register(): void { $this->setup_asset_vars( dist_path: TENUP_PLUGIN_PATH . 'dist/', fallback_version: TENUP_PLUGIN_VERSION @@ -50,7 +50,7 @@ public function register() { * * @return void */ - public function admin_scripts() { + public function admin_scripts(): void { wp_enqueue_script( 'tenup_plugin_admin', TENUP_PLUGIN_URL . 'dist/js/admin.js', @@ -65,7 +65,7 @@ public function admin_scripts() { * * @return void */ - public function admin_styles() { + public function admin_styles(): void { wp_enqueue_style( 'tenup_plugin_admin', TENUP_PLUGIN_URL . 'dist/css/admin.css', diff --git a/mu-plugins/10up-plugin/src/PostTypes/Demo.php b/mu-plugins/10up-plugin/src/PostTypes/Demo.php index c22f2ad5..c3fe4f41 100644 --- a/mu-plugins/10up-plugin/src/PostTypes/Demo.php +++ b/mu-plugins/10up-plugin/src/PostTypes/Demo.php @@ -19,7 +19,7 @@ class Demo extends AbstractPostType { * * @return string */ - public function get_name() { + public function get_name(): string { return 'tenup-demo'; } @@ -28,7 +28,7 @@ public function get_name() { * * @return string */ - public function get_singular_label() { + public function get_singular_label(): string { return esc_html__( 'Demo', 'tenup-plugin' ); } @@ -37,7 +37,7 @@ public function get_singular_label() { * * @return string */ - public function get_plural_label() { + public function get_plural_label(): string { return esc_html__( 'Demos', 'tenup-plugin' ); } @@ -50,7 +50,7 @@ public function get_plural_label() { * * @return string */ - public function get_menu_icon() { + public function get_menu_icon(): string { return 'dashicons-chart-pie'; } @@ -59,7 +59,7 @@ public function get_menu_icon() { * * @return bool */ - public function can_register() { + public function can_register(): bool { return false; } @@ -69,7 +69,7 @@ public function can_register() { * * @return array */ - public function get_supported_taxonomies() { + public function get_supported_taxonomies(): array { return [ 'tenup-tax-demo', ]; @@ -80,7 +80,7 @@ public function get_supported_taxonomies() { * * @return void */ - public function after_register() { + public function after_register(): void { // Register any hooks/filters you need. } } diff --git a/mu-plugins/10up-plugin/src/PostTypes/Page.php b/mu-plugins/10up-plugin/src/PostTypes/Page.php index 98bdeb8c..ce29d39d 100644 --- a/mu-plugins/10up-plugin/src/PostTypes/Page.php +++ b/mu-plugins/10up-plugin/src/PostTypes/Page.php @@ -22,7 +22,7 @@ class Page extends AbstractCorePostType { * * @return string */ - public function get_name() { + public function get_name(): string { return 'page'; } @@ -32,7 +32,7 @@ public function get_name() { * * @return array */ - public function get_supported_taxonomies() { + public function get_supported_taxonomies(): array { return []; } @@ -41,7 +41,7 @@ public function get_supported_taxonomies() { * * @return void */ - public function after_register() { + public function after_register(): void { // Do nothing. } } diff --git a/mu-plugins/10up-plugin/src/PostTypes/Post.php b/mu-plugins/10up-plugin/src/PostTypes/Post.php index a84fe7d8..2583f9da 100644 --- a/mu-plugins/10up-plugin/src/PostTypes/Post.php +++ b/mu-plugins/10up-plugin/src/PostTypes/Post.php @@ -22,7 +22,7 @@ class Post extends AbstractCorePostType { * * @return string */ - public function get_name() { + public function get_name(): string { return 'post'; } @@ -34,7 +34,7 @@ public function get_name() { * * @return array */ - public function get_supported_taxonomies() { + public function get_supported_taxonomies(): array { return []; } @@ -43,7 +43,7 @@ public function get_supported_taxonomies() { * * @return void */ - public function after_register() { + public function after_register(): void { // Do nothing. } } diff --git a/mu-plugins/10up-plugin/src/Taxonomies/Demo.php b/mu-plugins/10up-plugin/src/Taxonomies/Demo.php index ad89ce24..e8405624 100644 --- a/mu-plugins/10up-plugin/src/Taxonomies/Demo.php +++ b/mu-plugins/10up-plugin/src/Taxonomies/Demo.php @@ -19,7 +19,7 @@ class Demo extends AbstractTaxonomy { * * @return string */ - public function get_name() { + public function get_name(): string { return 'tenup-tax-demo'; } @@ -28,7 +28,7 @@ public function get_name() { * * @return string */ - public function get_singular_label() { + public function get_singular_label(): string { return esc_html__( 'Demo Term', 'tenup-plugin' ); } @@ -37,7 +37,7 @@ public function get_singular_label() { * * @return string */ - public function get_plural_label() { + public function get_plural_label(): string { return esc_html__( 'Demo Terms', 'tenup-plugin' ); } @@ -46,7 +46,7 @@ public function get_plural_label() { * * @return bool */ - public function can_register() { + public function can_register(): bool { return false; } } diff --git a/themes/10up-block-theme/src/Assets.php b/themes/10up-block-theme/src/Assets.php index d2bc60e7..063e7abc 100644 --- a/themes/10up-block-theme/src/Assets.php +++ b/themes/10up-block-theme/src/Assets.php @@ -26,7 +26,7 @@ class Assets implements ModuleInterface { * * @return bool */ - public function can_register() { + public function can_register(): bool { return true; } @@ -35,7 +35,7 @@ public function can_register() { * * @return void */ - public function register() { + public function register(): void { $this->setup_asset_vars( dist_path: TENUP_BLOCK_THEME_DIST_PATH, fallback_version: TENUP_BLOCK_THEME_VERSION @@ -51,7 +51,7 @@ public function register() { * * @return void */ - public function enqueue_frontend_assets() { + public function enqueue_frontend_assets(): void { wp_enqueue_style( 'tenup-theme-styles', TENUP_BLOCK_THEME_TEMPLATE_URL . '/dist/css/frontend.css', @@ -77,7 +77,7 @@ public function enqueue_frontend_assets() { * * @return void */ - public function enqueue_block_editor_assets() { + public function enqueue_block_editor_assets(): void { wp_enqueue_style( 'tenup-theme-editor-frame-style-overrides', TENUP_BLOCK_THEME_TEMPLATE_URL . '/dist/css/editor-frame-style-overrides.css', @@ -99,7 +99,7 @@ public function enqueue_block_editor_assets() { * * @return void */ - public function enqueue_block_editor_iframe_assets() { + public function enqueue_block_editor_iframe_assets(): void { // The `enqueue_block_assets` action is triggered both on the front-end and in the editor iframe. // We only want to enqueue these styles inside the editor iframe. @@ -120,7 +120,7 @@ public function enqueue_block_editor_iframe_assets() { * * @return void */ - public function register_all_icons() { + public function register_all_icons(): void { if ( ! function_exists( '\UIKitCore\Helpers\register_icons' ) ) { return; } diff --git a/themes/10up-block-theme/src/Blocks.php b/themes/10up-block-theme/src/Blocks.php index f689eec3..342815ca 100644 --- a/themes/10up-block-theme/src/Blocks.php +++ b/themes/10up-block-theme/src/Blocks.php @@ -26,7 +26,7 @@ class Blocks implements ModuleInterface { * * @return bool */ - public function can_register() { + public function can_register(): bool { return true; } @@ -35,7 +35,7 @@ public function can_register() { * * @return void */ - public function register() { + public function register(): void { $this->setup_asset_vars( dist_path: TENUP_BLOCK_THEME_DIST_PATH, fallback_version: TENUP_BLOCK_THEME_VERSION @@ -53,7 +53,7 @@ public function register() { * * @return void */ - public function register_theme_blocks() { + public function register_theme_blocks(): void { // Register all the blocks in the theme. if ( file_exists( TENUP_BLOCK_THEME_BLOCK_DIST_DIR ) ) { $block_json_files = glob( TENUP_BLOCK_THEME_BLOCK_DIST_DIR . '*/block.json' ); @@ -91,7 +91,7 @@ function ( array|bool $allowed_blocks ) use ( $block_names ): array|bool { * * @return void */ - public function enqueue_theme_block_styles() { + public function enqueue_theme_block_styles(): void { $stylesheets = glob( TENUP_BLOCK_THEME_DIST_PATH . '/blocks/autoenqueue/**/*.css' ); if ( empty( $stylesheets ) ) { diff --git a/themes/10up-block-theme/src/TemplateTags.php b/themes/10up-block-theme/src/TemplateTags.php index 95e77e5f..36d1b45a 100644 --- a/themes/10up-block-theme/src/TemplateTags.php +++ b/themes/10up-block-theme/src/TemplateTags.php @@ -24,7 +24,7 @@ class TemplateTags implements ModuleInterface { * * @return bool */ - public function can_register() { + public function can_register(): bool { return true; } @@ -33,7 +33,7 @@ public function can_register() { * * @return void */ - public function register() { + public function register(): void { add_action( 'wp_head', [ $this, 'add_viewport_meta_tag' ], 10, 0 ); } @@ -42,7 +42,7 @@ public function register() { * * @return void */ - public function add_viewport_meta_tag() { + public function add_viewport_meta_tag(): void { ?> setup_asset_vars( dist_path: TENUP_THEME_DIST_PATH, fallback_version: TENUP_THEME_VERSION @@ -51,7 +51,7 @@ public function register() { * * @return void */ - public function scripts() { + public function scripts(): void { /** * Enqueuing frontend.js is required to get css hot reloading working in the frontend * If you're not shipping any front-end js wrap this enqueue in a SCRIPT_DEBUG check. @@ -70,7 +70,7 @@ public function scripts() { * * @return void */ - public function enqueue_block_editor_scripts() { + public function enqueue_block_editor_scripts(): void { wp_enqueue_script( 'block-editor-script', TENUP_THEME_DIST_URL . 'js/block-editor-script.js', @@ -85,7 +85,7 @@ public function enqueue_block_editor_scripts() { * * @return void */ - public function styles() { + public function styles(): void { wp_enqueue_style( 'styles', TENUP_THEME_TEMPLATE_URL . '/dist/css/frontend.css', diff --git a/themes/10up-theme/src/Blocks.php b/themes/10up-theme/src/Blocks.php index 306bdd7a..f618eb21 100644 --- a/themes/10up-theme/src/Blocks.php +++ b/themes/10up-theme/src/Blocks.php @@ -26,7 +26,7 @@ class Blocks implements ModuleInterface { * * @return bool */ - public function can_register() { + public function can_register(): bool { return true; } @@ -35,7 +35,7 @@ public function can_register() { * * @return void */ - public function register() { + public function register(): void { $this->setup_asset_vars( dist_path: TENUP_THEME_DIST_PATH, fallback_version: TENUP_THEME_VERSION @@ -55,7 +55,7 @@ public function register() { * * @return void */ - public function register_theme_blocks() { + public function register_theme_blocks(): void { // Register all the blocks in the theme if ( file_exists( TENUP_THEME_BLOCK_DIST_DIR ) ) { $block_json_files = glob( TENUP_THEME_BLOCK_DIST_DIR . '*/block.json' ); @@ -97,7 +97,7 @@ public function register_theme_blocks() { * * @return void */ - public function blocks_editor_styles() { + public function blocks_editor_styles(): void { wp_enqueue_style( 'editor-style-overrides', TENUP_THEME_TEMPLATE_URL . '/dist/css/editor-style-overrides.css', @@ -132,7 +132,7 @@ public function blocks_editor_styles() { * * @return void */ - public function enqueue_block_specific_styles() { + public function enqueue_block_specific_styles(): void { $stylesheets = glob( TENUP_THEME_DIST_PATH . 'blocks/autoenqueue/**/*.css' ); if ( empty( $stylesheets ) ) { @@ -179,7 +179,7 @@ public function enqueue_block_specific_styles() { * * @return void */ - public function register_block_pattern_categories() { + public function register_block_pattern_categories(): void { // Register a block pattern category register_block_pattern_category( '10up-theme', From babfd4beaef7028b424321475c01c910abf221cd Mon Sep 17 00:00:00 2001 From: James Morrison Date: Wed, 17 Sep 2025 18:24:00 +0100 Subject: [PATCH 2/2] Added strict types. --- mu-plugins/10up-plugin/plugin.php | 2 ++ mu-plugins/10up-plugin/src/Assets.php | 2 ++ mu-plugins/10up-plugin/src/Core/Emoji.php | 2 ++ mu-plugins/10up-plugin/src/Core/HeadOverrides.php | 2 ++ mu-plugins/10up-plugin/src/PluginCore.php | 2 ++ mu-plugins/10up-plugin/src/PostTypes/Demo.php | 2 ++ mu-plugins/10up-plugin/src/PostTypes/Page.php | 2 ++ mu-plugins/10up-plugin/src/PostTypes/Post.php | 2 ++ mu-plugins/10up-plugin/src/Taxonomies/Demo.php | 2 ++ themes/10up-block-theme/src/Assets.php | 2 ++ themes/10up-block-theme/src/Blocks.php | 2 ++ themes/10up-block-theme/src/TemplateTags.php | 2 ++ themes/10up-block-theme/src/ThemeCore.php | 2 ++ themes/10up-theme/src/Assets.php | 2 ++ themes/10up-theme/src/Blocks.php | 2 ++ themes/10up-theme/src/ThemeCore.php | 2 ++ 16 files changed, 32 insertions(+) diff --git a/mu-plugins/10up-plugin/plugin.php b/mu-plugins/10up-plugin/plugin.php index ccc77f74..f7cc9628 100755 --- a/mu-plugins/10up-plugin/plugin.php +++ b/mu-plugins/10up-plugin/plugin.php @@ -16,6 +16,8 @@ * @package TenUpPlugin */ +declare( strict_types = 1 ); + // Useful global constants. define( 'TENUP_PLUGIN_VERSION', '0.1.0' ); define( 'TENUP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); diff --git a/mu-plugins/10up-plugin/src/Assets.php b/mu-plugins/10up-plugin/src/Assets.php index 4dca15b8..7deb5967 100644 --- a/mu-plugins/10up-plugin/src/Assets.php +++ b/mu-plugins/10up-plugin/src/Assets.php @@ -5,6 +5,8 @@ * @package TenUpPlugin */ +declare( strict_types = 1 ); + namespace TenUpPlugin; use TenupFramework\Assets\GetAssetInfo; diff --git a/mu-plugins/10up-plugin/src/Core/Emoji.php b/mu-plugins/10up-plugin/src/Core/Emoji.php index b3d58357..4a4885f4 100644 --- a/mu-plugins/10up-plugin/src/Core/Emoji.php +++ b/mu-plugins/10up-plugin/src/Core/Emoji.php @@ -5,6 +5,8 @@ * @package TenUpPlugin/Core */ +declare( strict_types = 1 ); + namespace TenUpPlugin\Core; use TenupFramework\Module; diff --git a/mu-plugins/10up-plugin/src/Core/HeadOverrides.php b/mu-plugins/10up-plugin/src/Core/HeadOverrides.php index f2b926ef..94063d3e 100644 --- a/mu-plugins/10up-plugin/src/Core/HeadOverrides.php +++ b/mu-plugins/10up-plugin/src/Core/HeadOverrides.php @@ -5,6 +5,8 @@ * @package TenUpPlugin/Core */ +declare( strict_types = 1 ); + namespace TenUpPlugin\Core; use TenupFramework\Module; diff --git a/mu-plugins/10up-plugin/src/PluginCore.php b/mu-plugins/10up-plugin/src/PluginCore.php index f30e9f69..b92f2554 100644 --- a/mu-plugins/10up-plugin/src/PluginCore.php +++ b/mu-plugins/10up-plugin/src/PluginCore.php @@ -5,6 +5,8 @@ * @package TenUpPlugin */ +declare( strict_types = 1 ); + namespace TenUpPlugin; use TenupFramework\ModuleInitialization; diff --git a/mu-plugins/10up-plugin/src/PostTypes/Demo.php b/mu-plugins/10up-plugin/src/PostTypes/Demo.php index c3fe4f41..a4cd1ecf 100644 --- a/mu-plugins/10up-plugin/src/PostTypes/Demo.php +++ b/mu-plugins/10up-plugin/src/PostTypes/Demo.php @@ -5,6 +5,8 @@ * @package TenUpPlugin */ +declare( strict_types = 1 ); + namespace TenUpPlugin\PostTypes; use TenupFramework\PostTypes\AbstractPostType; diff --git a/mu-plugins/10up-plugin/src/PostTypes/Page.php b/mu-plugins/10up-plugin/src/PostTypes/Page.php index ce29d39d..0fe48df4 100644 --- a/mu-plugins/10up-plugin/src/PostTypes/Page.php +++ b/mu-plugins/10up-plugin/src/PostTypes/Page.php @@ -5,6 +5,8 @@ * @package TenUpPlugin */ +declare( strict_types = 1 ); + namespace TenUpPlugin\PostTypes; use TenupFramework\PostTypes\AbstractCorePostType; diff --git a/mu-plugins/10up-plugin/src/PostTypes/Post.php b/mu-plugins/10up-plugin/src/PostTypes/Post.php index 2583f9da..0a919e5e 100644 --- a/mu-plugins/10up-plugin/src/PostTypes/Post.php +++ b/mu-plugins/10up-plugin/src/PostTypes/Post.php @@ -5,6 +5,8 @@ * @package TenUpPlugin */ +declare( strict_types = 1 ); + namespace TenUpPlugin\PostTypes; use TenupFramework\PostTypes\AbstractCorePostType; diff --git a/mu-plugins/10up-plugin/src/Taxonomies/Demo.php b/mu-plugins/10up-plugin/src/Taxonomies/Demo.php index e8405624..098281dc 100644 --- a/mu-plugins/10up-plugin/src/Taxonomies/Demo.php +++ b/mu-plugins/10up-plugin/src/Taxonomies/Demo.php @@ -5,6 +5,8 @@ * @package TenUpPlugin */ +declare( strict_types = 1 ); + namespace TenUpPlugin\Taxonomies; use TenupFramework\Taxonomies\AbstractTaxonomy; diff --git a/themes/10up-block-theme/src/Assets.php b/themes/10up-block-theme/src/Assets.php index 063e7abc..d8ee273b 100644 --- a/themes/10up-block-theme/src/Assets.php +++ b/themes/10up-block-theme/src/Assets.php @@ -5,6 +5,8 @@ * @package TenupBlockTheme */ +declare( strict_types = 1 ); + namespace TenupBlockTheme; use TenupFramework\Assets\GetAssetInfo; diff --git a/themes/10up-block-theme/src/Blocks.php b/themes/10up-block-theme/src/Blocks.php index 342815ca..186dde0f 100644 --- a/themes/10up-block-theme/src/Blocks.php +++ b/themes/10up-block-theme/src/Blocks.php @@ -5,6 +5,8 @@ * @package TenupBlockTheme */ +declare( strict_types = 1 ); + namespace TenupBlockTheme; use TenupFramework\Assets\GetAssetInfo; diff --git a/themes/10up-block-theme/src/TemplateTags.php b/themes/10up-block-theme/src/TemplateTags.php index 36d1b45a..59661e04 100644 --- a/themes/10up-block-theme/src/TemplateTags.php +++ b/themes/10up-block-theme/src/TemplateTags.php @@ -5,6 +5,8 @@ * @package TenupBlockTheme */ +declare( strict_types = 1 ); + namespace TenupBlockTheme; use TenupFramework\Module; diff --git a/themes/10up-block-theme/src/ThemeCore.php b/themes/10up-block-theme/src/ThemeCore.php index 20deae07..424b6754 100644 --- a/themes/10up-block-theme/src/ThemeCore.php +++ b/themes/10up-block-theme/src/ThemeCore.php @@ -5,6 +5,8 @@ * @package TenupBlockTheme */ +declare( strict_types = 1 ); + namespace TenupBlockTheme; use TenupFramework\ModuleInitialization; diff --git a/themes/10up-theme/src/Assets.php b/themes/10up-theme/src/Assets.php index 6f663725..d6a0c997 100644 --- a/themes/10up-theme/src/Assets.php +++ b/themes/10up-theme/src/Assets.php @@ -5,6 +5,8 @@ * @package TenUpTheme */ +declare( strict_types = 1 ); + namespace TenUpTheme; use TenupFramework\Assets\GetAssetInfo; diff --git a/themes/10up-theme/src/Blocks.php b/themes/10up-theme/src/Blocks.php index f618eb21..e734551b 100644 --- a/themes/10up-theme/src/Blocks.php +++ b/themes/10up-theme/src/Blocks.php @@ -5,6 +5,8 @@ * @package TenUpTheme */ +declare( strict_types = 1 ); + namespace TenUpTheme; use TenupFramework\Assets\GetAssetInfo; diff --git a/themes/10up-theme/src/ThemeCore.php b/themes/10up-theme/src/ThemeCore.php index b42b8d2d..1958ea19 100644 --- a/themes/10up-theme/src/ThemeCore.php +++ b/themes/10up-theme/src/ThemeCore.php @@ -5,6 +5,8 @@ * @package TenUpTheme */ +declare( strict_types = 1 ); + namespace TenUpTheme; use TenupFramework\ModuleInitialization;