From de5a4b1d692bebf9580021d1bb21bbb598c2581b Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Wed, 10 Jan 2024 21:13:21 -0800 Subject: [PATCH 01/10] Remove unnecessary `wlwmanifest_link` removal This was removed in core in WP 6.3. Thanks @Soean! Fixes #41 --- mu-plugins/wp/head.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/mu-plugins/wp/head.php b/mu-plugins/wp/head.php index 0349ffa0..b1ba06f9 100644 --- a/mu-plugins/wp/head.php +++ b/mu-plugins/wp/head.php @@ -16,9 +16,6 @@ */ function remove_default_actions() { - // There is a very close to zero chance I will ever use Windows Live Writer. - remove_action( 'wp_head', 'wlwmanifest_link' ); - // Remove EditURI link for XML-RPC hinting. remove_action( 'wp_head', 'rsd_link' ); From b5d63a8d8dffd63e5674b867a1e6628109df28c5 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Wed, 10 Jan 2024 21:20:24 -0800 Subject: [PATCH 02/10] Redirect author archives to home page Fixes #39 --- mu-plugins/index.php | 1 + mu-plugins/wp/urls.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 mu-plugins/wp/urls.php diff --git a/mu-plugins/index.php b/mu-plugins/index.php index c38525e4..0795553a 100644 --- a/mu-plugins/index.php +++ b/mu-plugins/index.php @@ -6,6 +6,7 @@ require_once __DIR__ . '/wp/emoji.php'; require_once __DIR__ . '/wp/head.php'; require_once __DIR__ . '/wp/styles.php'; +require_once __DIR__ . '/wp/urls.php'; require_once __DIR__ . '/plugins/content-visibility.php'; require_once __DIR__ . '/plugins/indieweb.php'; diff --git a/mu-plugins/wp/urls.php b/mu-plugins/wp/urls.php new file mode 100644 index 00000000..0ffdd14c --- /dev/null +++ b/mu-plugins/wp/urls.php @@ -0,0 +1,20 @@ + Date: Wed, 10 Jan 2024 21:28:13 -0800 Subject: [PATCH 03/10] Improve PHPCS configuration --- composer.json | 22 +- composer.lock | 547 +++++++++++++++++++++++++++++++++++++--- mu-plugins/wp/emoji.php | 2 +- 3 files changed, 534 insertions(+), 37 deletions(-) diff --git a/composer.json b/composer.json index e40494ca..7792be72 100644 --- a/composer.json +++ b/composer.json @@ -3,19 +3,31 @@ "type": "project", "minimum-stability": "stable", "require-dev": { - "wp-coding-standards/wpcs": "*", "dealerdirect/phpcodesniffer-composer-installer": "*", - "phpcompatibility/php-compatibility": "dev-develop as 9.99.99", - "phpcompatibility/phpcompatibility-wp": "*" + "phpcompatibility/phpcompatibility-wp": "*", + "phpcompatibility/php-compatibility": "dev-develop as 9.99.9", + "sirbrillig/phpcs-variable-analysis": "*", + "squizlabs/php_codesniffer": "3.*", + "wp-coding-standards/wpcs": "*", + "phpstan/phpstan": "^1.10", + "szepeviktor/phpstan-wordpress": "^1.3", + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan-phpunit": "^1.3", + "php-stubs/wordpress-tests-stubs": "^6.2" }, "scripts": { "phpcs": "vendor/bin/phpcs", - "phpcbf": "vendor/bin/phpcbf" + "phpcbf": "vendor/bin/phpcbf", + "phpstan": "vendor/bin/phpstan analyse --memory-limit=2048M" }, "config": { "allow-plugins": { "composer/installers": true, - "dealerdirect/phpcodesniffer-composer-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "phpstan/extension-installer": true + }, + "platform": { + "php": "8.0" } } } diff --git a/composer.lock b/composer.lock index a8fbc6b7..13e29a7b 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": "93935df048d221a1ddd1f7ebb18a38f0", + "content-hash": "c425eb286c184843c27c55ccaf3b2368", "packages": [], "packages-dev": [ { @@ -85,6 +85,93 @@ }, "time": "2023-01-05T11:28:13+00:00" }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v6.4.1", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "6d6063cf9464a306ca2a0529705d41312b08500b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/6d6063cf9464a306ca2a0529705d41312b08500b", + "reference": "6d6063cf9464a306ca2a0529705d41312b08500b", + "shasum": "" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "nikic/php-parser": "^4.13", + "php": "^7.4 || ~8.0.0", + "php-stubs/generator": "^0.8.3", + "phpdocumentor/reflection-docblock": "^5.3", + "phpstan/phpstan": "^1.10.12", + "phpunit/phpunit": "^9.5", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8" + }, + "suggest": { + "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "symfony/polyfill-php80": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.4.1" + }, + "time": "2023-11-10T00:33:47+00:00" + }, + { + "name": "php-stubs/wordpress-tests-stubs", + "version": "v6.3.0", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-tests-stubs.git", + "reference": "c603908a8e70895ba3d5b5050ed791511cabc60f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-tests-stubs/zipball/c603908a8e70895ba3d5b5050ed791511cabc60f", + "reference": "c603908a8e70895ba3d5b5050ed791511cabc60f", + "shasum": "" + }, + "require-dev": { + "php": "~7.3 || ~8.0", + "php-stubs/generator": "^0.8.0" + }, + "suggest": { + "symfony/polyfill-php73": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress Tests function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-tests-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-tests-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-tests-stubs/tree/v6.3.0" + }, + "time": "2023-08-10T16:09:20+00:00" + }, { "name": "phpcompatibility/php-compatibility", "version": "dev-develop", @@ -275,29 +362,29 @@ }, { "name": "phpcsstandards/phpcsextra", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", - "reference": "78b2cae1e9de1c05f0416de6f9a658cbb83ac324" + "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/78b2cae1e9de1c05f0416de6f9a658cbb83ac324", - "reference": "78b2cae1e9de1c05f0416de6f9a658cbb83ac324", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", + "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", "shasum": "" }, "require": { "php": ">=5.4", - "phpcsstandards/phpcsutils": "^1.0.8", - "squizlabs/php_codesniffer": "^3.7.1" + "phpcsstandards/phpcsutils": "^1.0.9", + "squizlabs/php_codesniffer": "^3.8.0" }, "require-dev": { "php-parallel-lint/php-console-highlighter": "^1.0", "php-parallel-lint/php-parallel-lint": "^1.3.2", "phpcsstandards/phpcsdevcs": "^1.1.6", "phpcsstandards/phpcsdevtools": "^1.2.1", - "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" }, "type": "phpcodesniffer-standard", "extra": { @@ -349,33 +436,33 @@ "type": "open_collective" } ], - "time": "2023-12-02T14:30:12+00:00" + "time": "2023-12-08T16:49:07+00:00" }, { "name": "phpcsstandards/phpcsutils", - "version": "1.0.8", + "version": "1.0.9", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "69465cab9d12454e5e7767b9041af0cd8cd13be7" + "reference": "908247bc65010c7b7541a9551e002db12e9dae70" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/69465cab9d12454e5e7767b9041af0cd8cd13be7", - "reference": "69465cab9d12454e5e7767b9041af0cd8cd13be7", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/908247bc65010c7b7541a9551e002db12e9dae70", + "reference": "908247bc65010c7b7541a9551e002db12e9dae70", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.7.1 || 4.0.x-dev@dev" + "squizlabs/php_codesniffer": "^3.8.0 || 4.0.x-dev@dev" }, "require-dev": { "ext-filter": "*", "php-parallel-lint/php-console-highlighter": "^1.0", "php-parallel-lint/php-parallel-lint": "^1.3.2", "phpcsstandards/phpcsdevcs": "^1.1.6", - "yoast/phpunit-polyfills": "^1.0.5 || ^2.0.0" + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" }, "type": "phpcodesniffer-standard", "extra": { @@ -420,22 +507,253 @@ "support": { "docs": "https://phpcsutils.com/", "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", + "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", "source": "https://github.com/PHPCSStandards/PHPCSUtils" }, - "time": "2023-07-16T21:39:41+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2023-12-08T14:50:00+00:00" + }, + { + "name": "phpstan/extension-installer", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "f45734bfb9984c6c56c4486b71230355f066a58a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f45734bfb9984c6c56c4486b71230355f066a58a", + "reference": "f45734bfb9984c6c56c4486b71230355f066a58a", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.3.1" + }, + "time": "2023-05-24T08:59:17+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.10.55", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "9a88f9d18ddf4cf54c922fbeac16c4cb164c5949" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9a88f9d18ddf4cf54c922fbeac16c4cb164c5949", + "reference": "9a88f9d18ddf4cf54c922fbeac16c4cb164c5949", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2024-01-08T12:32:40+00:00" + }, + { + "name": "phpstan/phpstan-phpunit", + "version": "1.3.15", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-phpunit.git", + "reference": "70ecacc64fe8090d8d2a33db5a51fe8e88acd93a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/70ecacc64fe8090d8d2a33db5a51fe8e88acd93a", + "reference": "70ecacc64fe8090d8d2a33db5a51fe8e88acd93a", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.10" + }, + "conflict": { + "phpunit/phpunit": "<7.0" + }, + "require-dev": { + "nikic/php-parser": "^4.13.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-strict-rules": "^1.5.1", + "phpunit/phpunit": "^9.5" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon", + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPUnit extensions and rules for PHPStan", + "support": { + "issues": "https://github.com/phpstan/phpstan-phpunit/issues", + "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.3.15" + }, + "time": "2023-10-09T18:58:39+00:00" + }, + { + "name": "sirbrillig/phpcs-variable-analysis", + "version": "v2.11.17", + "source": { + "type": "git", + "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", + "reference": "3b71162a6bf0cde2bff1752e40a1788d8273d049" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/3b71162a6bf0cde2bff1752e40a1788d8273d049", + "reference": "3b71162a6bf0cde2bff1752e40a1788d8273d049", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "squizlabs/php_codesniffer": "^3.5.6" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0", + "phpcsstandards/phpcsdevcs": "^1.1", + "phpstan/phpstan": "^1.7", + "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.5 || ^7.0 || ^8.0 || ^9.0", + "sirbrillig/phpcs-import-detection": "^1.1", + "vimeo/psalm": "^0.2 || ^0.3 || ^1.1 || ^4.24 || ^5.0@beta" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "VariableAnalysis\\": "VariableAnalysis/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Sam Graham", + "email": "php-codesniffer-variableanalysis@illusori.co.uk" + }, + { + "name": "Payton Swick", + "email": "payton@foolord.com" + } + ], + "description": "A PHPCS sniff to detect problems with variables.", + "keywords": [ + "phpcs", + "static analysis" + ], + "support": { + "issues": "https://github.com/sirbrillig/phpcs-variable-analysis/issues", + "source": "https://github.com/sirbrillig/phpcs-variable-analysis", + "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki" + }, + "time": "2023-08-05T23:46:11+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.2", + "version": "3.8.0", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5805f7a4e4958dbb5e944ef1e6edae0a303765e7", + "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7", "shasum": "" }, "require": { @@ -445,7 +763,7 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" }, "bin": [ "bin/phpcs", @@ -464,22 +782,186 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", "standards", "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2023-12-08T12:32:31+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.28.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fe2f306d1d9d346a7fee353d0d5012e401e984b5", + "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.28-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.28.0" }, - "time": "2023-02-22T23:07:41+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-26T09:26:14+00:00" + }, + { + "name": "szepeviktor/phpstan-wordpress", + "version": "v1.3.2", + "source": { + "type": "git", + "url": "https://github.com/szepeviktor/phpstan-wordpress.git", + "reference": "b8516ed6bab7ec50aae981698ce3f67f1be2e45a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/b8516ed6bab7ec50aae981698ce3f67f1be2e45a", + "reference": "b8516ed6bab7ec50aae981698ce3f67f1be2e45a", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0", + "phpstan/phpstan": "^1.10.30", + "symfony/polyfill-php73": "^1.12.0" + }, + "require-dev": { + "composer/composer": "^2.1.14", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpstan/phpstan-strict-rules": "^1.2", + "phpunit/phpunit": "^8.0 || ^9.0", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^0.8" + }, + "suggest": { + "swissspidy/phpstan-no-private": "Detect usage of internal core functions, classes and methods" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "SzepeViktor\\PHPStan\\WordPress\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress extensions for PHPStan", + "keywords": [ + "PHPStan", + "code analyse", + "code analysis", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", + "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.3.2" + }, + "time": "2023-10-16T17:23:56+00:00" }, { "name": "wp-coding-standards/wpcs", @@ -552,8 +1034,8 @@ { "package": "phpcompatibility/php-compatibility", "version": "dev-develop", - "alias": "9.99.99", - "alias_normalized": "9.99.99.0" + "alias": "9.99.9", + "alias_normalized": "9.99.9.0" } ], "minimum-stability": "stable", @@ -564,5 +1046,8 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.3.0" + "platform-overrides": { + "php": "8.0" + }, + "plugin-api-version": "2.6.0" } diff --git a/mu-plugins/wp/emoji.php b/mu-plugins/wp/emoji.php index b944d107..37e6eaaa 100644 --- a/mu-plugins/wp/emoji.php +++ b/mu-plugins/wp/emoji.php @@ -39,7 +39,7 @@ function remove_extra_emoji_handling() { * @param array A list of URLs. * @return array A modified list of URLs. */ -function remove_wp_org_cdn_prefetch( array $urls ) : array { +function remove_wp_org_cdn_prefetch( array $urls ): array { foreach ( $urls as $key => $url ) { From 53065b77d67bff000018cf6d5823bc34ba411a48 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Wed, 10 Jan 2024 21:29:48 -0800 Subject: [PATCH 04/10] Add actual phpcs configuration --- phpcs.xml | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 phpcs.xml diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 00000000..0286c39e --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,63 @@ + + + + . + + /plugins/ + /themes/ + /vendor/ + /uploads/ + /upgrade/ + advanced-cache.php + db.php + object-cache.php + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 9f4978218e91fe575a9778a863fc1085be2882c6 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Wed, 10 Jan 2024 21:29:57 -0800 Subject: [PATCH 05/10] Add phpstan configuration --- phpstan.neon.dist | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 phpstan.neon.dist diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..29bf7d90 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,18 @@ +parameters: + level: 5 + paths: + - ./ + scanFiles: + - %rootDir%/../../php-stubs/wordpress-stubs/wordpress-stubs.php + - %rootDir%/../../php-stubs/wordpress-tests-stubs/wordpress-tests-stubs.php + excludePaths: + - vendor + - node_modules + - plugins + - themes + - uploads + - upgrade + - advanced-cache.php + - db.php + - object-cache.php + ignoreErrors: From d720f179c4837b492d50247079ae329cd2795b55 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Wed, 10 Jan 2024 21:33:40 -0800 Subject: [PATCH 06/10] Remove extraneous argument from remove_action I always do this --- mu-plugins/wp/head.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mu-plugins/wp/head.php b/mu-plugins/wp/head.php index b1ba06f9..cec50712 100644 --- a/mu-plugins/wp/head.php +++ b/mu-plugins/wp/head.php @@ -24,8 +24,8 @@ function remove_default_actions() { // I can't ever imagine wanting a shortlink in today's internet, but that may // just be me. - remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); - remove_action( 'template_redirect', 'wp_shortlink_header', 11, 0 ); + remove_action( 'wp_head', 'wp_shortlink_wp_head', 10 ); + remove_action( 'template_redirect', 'wp_shortlink_header', 11 ); // No need to advertise the REST API, it's still there. remove_action( 'wp_head', 'rest_output_link_wp_head' ); From 56960eb858ffc73af6e31ca0b37c146389369123 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Wed, 10 Jan 2024 21:34:46 -0800 Subject: [PATCH 07/10] Fix parameter documentation --- mu-plugins/wp/emoji.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mu-plugins/wp/emoji.php b/mu-plugins/wp/emoji.php index 37e6eaaa..0fce3f9d 100644 --- a/mu-plugins/wp/emoji.php +++ b/mu-plugins/wp/emoji.php @@ -36,7 +36,7 @@ function remove_extra_emoji_handling() { /** * Remove unnecessary DNS prefetch for s.w.org. * - * @param array A list of URLs. + * @param array $urls A list of URLs. * @return array A modified list of URLs. */ function remove_wp_org_cdn_prefetch( array $urls ): array { From 5c845b584996842d7d4e31a601f36cd81e5b8bb0 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Wed, 10 Jan 2024 21:35:25 -0800 Subject: [PATCH 08/10] Remove another extra parameter on remove_filter --- mu-plugins/plugins/micropub.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mu-plugins/plugins/micropub.php b/mu-plugins/plugins/micropub.php index 276c8a5f..9879b23e 100644 --- a/mu-plugins/plugins/micropub.php +++ b/mu-plugins/plugins/micropub.php @@ -82,7 +82,7 @@ function filter_micropub_post_content( $content, $input ) { // Remove content filtering if this is a reply. if ( isset( $props['in-reply-to'] ) ) { - remove_filter( 'micropub_post_content', array( 'Micropub_Render', 'generate_post_content' ), 1, 2 ); + remove_filter( 'micropub_post_content', array( 'Micropub_Render', 'generate_post_content' ), 1 ); } return $content; From 4923bc4f63b7ec4029eaeff152a47480b2f60816 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Wed, 10 Jan 2024 21:36:45 -0800 Subject: [PATCH 09/10] Improve return documentation --- mu-plugins/plugins/micropub.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mu-plugins/plugins/micropub.php b/mu-plugins/plugins/micropub.php index 9879b23e..7b1ee8f7 100644 --- a/mu-plugins/plugins/micropub.php +++ b/mu-plugins/plugins/micropub.php @@ -96,7 +96,7 @@ function filter_micropub_post_content( $content, $input ) { * @param int $post_id The post ID. * @param string $meta_key The meta key. * @param bool $single Whether a single value was requested. - * @return string The reply-to URL. + * @return null|string The reply-to URL. */ function filter_reply_to_metadata( $value, $post_id, $meta_key, $single ) { if ( 'shortnotes_reply_to_url' !== $meta_key ) { From 8761325ee80528074aeadbb8e1a3aa05da14a017 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Wed, 10 Jan 2024 21:40:02 -0800 Subject: [PATCH 10/10] Clean up more documentation --- mu-plugins/plugins/indieweb.php | 7 +++++-- mu-plugins/wp/emoji.php | 2 +- mu-plugins/wp/head.php | 2 +- mu-plugins/wp/styles.php | 2 +- mu-plugins/wp/urls.php | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/mu-plugins/plugins/indieweb.php b/mu-plugins/plugins/indieweb.php index 8f3640b0..475d9e2b 100644 --- a/mu-plugins/plugins/indieweb.php +++ b/mu-plugins/plugins/indieweb.php @@ -12,12 +12,15 @@ * * In these cases, the site/theme has taken care of the display layer. */ -function remove_indieweb_styles() { +function remove_indieweb_styles(): void { remove_action( 'wp_enqueue_scripts', array( 'IndieWeb_Plugin', 'enqueue_style' ) ); remove_action( 'wp_enqueue_scripts', array( 'Semantic_Linkbacks_Plugin', 'enqueue_scripts' ) ); } -function remove_indieweb_added_on_init() { +/** + * Remove unneeded filters added by the IndieWeb plugin(s). + */ +function remove_indieweb_added_on_init(): void { // Remove the injection of the Semantic_Linkbacks_Walker_Comment walker when displaying // comments. This is added on the init action by the Semantic Linkbacks plugin. diff --git a/mu-plugins/wp/emoji.php b/mu-plugins/wp/emoji.php index 0fce3f9d..5302e2d6 100644 --- a/mu-plugins/wp/emoji.php +++ b/mu-plugins/wp/emoji.php @@ -15,7 +15,7 @@ * current support for emoji on devices that will actually be reading this * content is high. ❤️ */ -function remove_extra_emoji_handling() { +function remove_extra_emoji_handling(): void { // Don't output the inline JavaScript used to convert emoji characters // into Twemoji images. diff --git a/mu-plugins/wp/head.php b/mu-plugins/wp/head.php index cec50712..21937fb8 100644 --- a/mu-plugins/wp/head.php +++ b/mu-plugins/wp/head.php @@ -14,7 +14,7 @@ * Remove other default actions that output unnecessary elements or do * unnecessary things. */ -function remove_default_actions() { +function remove_default_actions(): void { // Remove EditURI link for XML-RPC hinting. remove_action( 'wp_head', 'rsd_link' ); diff --git a/mu-plugins/wp/styles.php b/mu-plugins/wp/styles.php index 2d515b13..ff364aea 100644 --- a/mu-plugins/wp/styles.php +++ b/mu-plugins/wp/styles.php @@ -13,7 +13,7 @@ * Remove the global styles generated by WordPress and Gutenberg on * the front end for the block editor. */ -function remove_global_styles() { +function remove_global_styles(): void { remove_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' ); remove_action( 'wp_body_open', 'gutenberg_global_styles_render_svg_filters' ); diff --git a/mu-plugins/wp/urls.php b/mu-plugins/wp/urls.php index 0ffdd14c..1f8754be 100644 --- a/mu-plugins/wp/urls.php +++ b/mu-plugins/wp/urls.php @@ -12,7 +12,7 @@ /** * Redirect author archives to the homepage. */ -function redirect_author_archives() { +function redirect_author_archives(): void { if ( is_author() ) { wp_safe_redirect( home_url(), 301 ); exit;