diff --git a/composer.json b/composer.json index 63500b73..cc719245 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "phpmd/phpmd": "^2.7", "phan/phan": "^5.1", "skaut/wordpress-stubs": "^2.2.0", - "phpstan/phpstan": "^1.4", + "phpstan/phpstan": "^2.0", "dealerdirect/phpcodesniffer-composer-installer": "^1.0", "wp-cli/i18n-command": "^2.4" } diff --git a/composer.lock b/composer.lock index d1cdd6b7..ef2bdc75 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": "1f8c6d45dc238bbf50d83fd5b81980dc", + "content-hash": "eeba5bc9d88f38b2e3d36fb0febaf37c", "packages": [], "packages-dev": [ { @@ -1631,20 +1631,20 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.8", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "f6a60a4d66142b8156c9da923f1972657bc4748c" + "reference": "6c98c7600fc717b2c78c11ef60040d5b1e359c82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/f6a60a4d66142b8156c9da923f1972657bc4748c", - "reference": "f6a60a4d66142b8156c9da923f1972657bc4748c", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6c98c7600fc717b2c78c11ef60040d5b1e359c82", + "reference": "6c98c7600fc717b2c78c11ef60040d5b1e359c82", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -1685,7 +1685,7 @@ "type": "github" } ], - "time": "2024-11-06T19:06:49+00:00" + "time": "2024-11-17T14:17:00+00:00" }, { "name": "psr/container", diff --git a/src/languages/crdm-modern.pot b/src/languages/crdm-modern.pot index 3ec59060..7df8de53 100644 --- a/src/languages/crdm-modern.pot +++ b/src/languages/crdm-modern.pot @@ -213,18 +213,18 @@ msgstr "" msgid "A widget containing the site logo, title and tagline." msgstr "" -#: php/functions.php:163 +#: php/functions.php:165 msgid "CRDM - Modern theme requires at least WordPress 5.0" msgstr "" -#: php/functions.php:176 +#: php/functions.php:178 msgid "CRDM - Modern theme requires at least PHP 7.0" msgstr "" -#: php/functions.php:188 +#: php/functions.php:190 msgid "CRDM - Modern theme requires GeneratePress Premium" msgstr "" -#: php/functions.php:200 +#: php/functions.php:202 msgid "Failed to copy CRDM - Modern theme images to WordPress Media. The theme will work fine, but you won't be able to re-select the default images outside of the theme presets." msgstr "" diff --git a/src/languages/cs_CZ.po b/src/languages/cs_CZ.po index daf34909..0eb3f075 100644 --- a/src/languages/cs_CZ.po +++ b/src/languages/cs_CZ.po @@ -213,18 +213,18 @@ msgstr "Widget názvu webu" msgid "A widget containing the site logo, title and tagline." msgstr "Widget obsahující logo, název a popis webu." -#: php/functions.php:163 +#: php/functions.php:165 msgid "CRDM - Modern theme requires at least WordPress 5.0" msgstr "Šablona CRDM - Modern vyžaduje alespoň WordPress 5.0" -#: php/functions.php:176 +#: php/functions.php:178 msgid "CRDM - Modern theme requires at least PHP 7.0" msgstr "Šablona CRDM - Modern vyžaduje alespoň PHP 7.0" -#: php/functions.php:188 +#: php/functions.php:190 msgid "CRDM - Modern theme requires GeneratePress Premium" msgstr "Šablona CRDM - Modern vyžaduje premium verzi GeneratePress" -#: php/functions.php:200 +#: php/functions.php:202 msgid "Failed to copy CRDM - Modern theme images to WordPress Media. The theme will work fine, but you won't be able to re-select the default images outside of the theme presets." msgstr "Nepodařilo se zkopírovat obrázky šablony CRDM - Modern do WordPress Médií. Šablona bude fungovat v pořádku i tak, ale nebudete moct znovu použít její výchozí obrázky jinak, než použitím předvolby šablony." diff --git a/src/php/admin/class-wordpress-github-updater.php b/src/php/admin/class-wordpress-github-updater.php index 7c8edde6..41a1e9ce 100644 --- a/src/php/admin/class-wordpress-github-updater.php +++ b/src/php/admin/class-wordpress-github-updater.php @@ -181,7 +181,7 @@ public function update_theme( $transient ) { * * @return void * - * @SuppressWarnings(PHPMD.ExitExpression) + * @SuppressWarnings("PHPMD.ExitExpression") */ public function update_url() { if ( ! isset( $_GET['version'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended diff --git a/src/php/admin/customizer/class-preset-registry.php b/src/php/admin/customizer/class-preset-registry.php index 9ed69ba3..4ed106a9 100644 --- a/src/php/admin/customizer/class-preset-registry.php +++ b/src/php/admin/customizer/class-preset-registry.php @@ -73,7 +73,7 @@ public function default_preset() { * @return Preset_Registry The default registry. * * @suppress PhanPossiblyNullTypeReturn - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings("PHPMD.ExcessiveMethodLength") */ public static function get_instance() { if ( ! is_null( self::$instance ) ) { diff --git a/src/php/admin/customizer/class-preset.php b/src/php/admin/customizer/class-preset.php index 66e7f20e..c8caf244 100644 --- a/src/php/admin/customizer/class-preset.php +++ b/src/php/admin/customizer/class-preset.php @@ -14,7 +14,7 @@ * * Contains all the data about a preset. * - * @SuppressWarnings(PHPMD.ShortVariable) + * @SuppressWarnings("PHPMD.ShortVariable") */ class Preset { /** @@ -162,7 +162,7 @@ public function get_stylesheet_defaults( string $name ) { * * @return mixed The defautl values. * - * @SuppressWarnings(PHPMD.UnusedLocalVariable) + * @SuppressWarnings("PHPMD.UnusedLocalVariable") */ public function get_all_template_defaults() { $ret = array(); diff --git a/src/php/admin/customizer/controls/class-preset-customize-control.php b/src/php/admin/customizer/controls/class-preset-customize-control.php index 2cdfc059..24a79c4d 100644 --- a/src/php/admin/customizer/controls/class-preset-customize-control.php +++ b/src/php/admin/customizer/controls/class-preset-customize-control.php @@ -78,7 +78,7 @@ class Preset_Customize_Control extends \WP_Customize_Control { * * @inheritDoc * - * @SuppressWarnings(PHPMD.ShortVariable) + * @SuppressWarnings("PHPMD.ShortVariable") */ public function __construct( \WP_Customize_Manager $manager, string $id, array $args, $presets = null ) { parent::__construct( $manager, $id, $args ); diff --git a/src/php/admin/preset-on-activation.php b/src/php/admin/preset-on-activation.php index a99aff7c..05b717d6 100644 --- a/src/php/admin/preset-on-activation.php +++ b/src/php/admin/preset-on-activation.php @@ -121,6 +121,7 @@ function apply_preset( $preset ) { remove_theme_mod( $mod ); continue; } + // @phpstan-ignore function.alreadyNarrowedType (Should always be array, but check here for safety) if ( is_array( $value ) ) { $value = implode( ',', $value ); } diff --git a/src/php/frontend/class-title-widget.php b/src/php/frontend/class-title-widget.php index 5f647540..f4fce62c 100644 --- a/src/php/frontend/class-title-widget.php +++ b/src/php/frontend/class-title-widget.php @@ -80,8 +80,8 @@ public function __construct() { * * @return void * - * @SuppressWarnings(PHPMD.ShortVariable) - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings("PHPMD.ShortVariable") + * @SuppressWarnings("PHPMD.UnusedFormalParameter") */ public function widget( $args, $instance ) { $gp_settings = wp_parse_args( diff --git a/src/php/frontend/widget-icons.php b/src/php/frontend/widget-icons.php index 45fc278c..9ed2051c 100644 --- a/src/php/frontend/widget-icons.php +++ b/src/php/frontend/widget-icons.php @@ -37,8 +37,8 @@ function enqueue() { * * @return string The new title. * - * @SuppressWarnings(PHPMD.ShortVariable) - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings("PHPMD.ShortVariable") + * @SuppressWarnings("PHPMD.UnusedFormalParameter") */ function add_icon( string $title, array $instance = array(), string $id_base = '' ) { switch ( $id_base ) { diff --git a/src/php/functions.php b/src/php/functions.php index d4e98799..32e8dc1b 100644 --- a/src/php/functions.php +++ b/src/php/functions.php @@ -111,8 +111,9 @@ function copy_images() { * @return void */ function copy_image( $path, $title ) { - // Bail if image already exists. + // @phpstan-ignore requireOnce.fileNotFound (WordPress file) require_once ABSPATH . 'wp-admin/includes/post.php'; + // Bail if image already exists. if ( 0 !== post_exists( $title, '', '', 'attachment' ) ) { return; } @@ -134,6 +135,7 @@ function copy_image( $path, $title ) { if ( is_wp_error( $attachment_id ) ) { throw new \Exception(); } + // @phpstan-ignore requireOnce.fileNotFound (WordPress file) require_once ABSPATH . 'wp-admin/includes/image.php'; // @phpstan-ignore-next-line $attachment_metadata = wp_generate_attachment_metadata( $attachment_id, $file_contents['file'] );