From 06634681903a8fe105de30abe81b7da6018f9d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20S=C3=B8derlind?= Date: Fri, 19 Jul 2024 12:48:53 +0200 Subject: [PATCH] Housekeeping --- .gitignore | 3 + CHANGELOG.md | 4 + a-faster-load-textdomain.php | 4 +- composer.json | 21 +- composer.lock | 365 +++++++++++++++++++++++++++ includes/class-afld-cachehandler.php | 3 + includes/class-translation-entry.php | 27 +- package-lock.json | 22 +- package.json | 2 +- phpstan.neon | 7 + readme.txt | 2 +- 11 files changed, 427 insertions(+), 33 deletions(-) create mode 100644 composer.lock create mode 100644 phpstan.neon diff --git a/.gitignore b/.gitignore index 3c3629e..a4b5bef 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ node_modules +vendor +vendor-bin +.phplint.cache diff --git a/CHANGELOG.md b/CHANGELOG.md index 66969bf..a608a8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Changelog +### 2.3.2 + +- Housekeeping + ### 2.3.1 - Catch errors in the cache handler. If the cache file is corrupt, update the file and return the .mo file. diff --git a/a-faster-load-textdomain.php b/a-faster-load-textdomain.php index ee9fb72..49b415d 100644 --- a/a-faster-load-textdomain.php +++ b/a-faster-load-textdomain.php @@ -1,7 +1,7 @@ =' ) ) { - // admin messages + // admin messages. \add_action( 'admin_notices', function () { diff --git a/composer.json b/composer.json index 7866702..9cc775f 100644 --- a/composer.json +++ b/composer.json @@ -3,5 +3,24 @@ "description": "A faster load_textdomain", "type": "wordpress-plugin", "homepage": "https://github.com/soderlind/a-faster-load-textdomain", - "license": "GPL-2.0-or-later" + "license": "GPL-2.0-or-later", + "require-dev": { + "szepeviktor/phpstan-wordpress": "^1.3", + "phpstan/extension-installer": "^1.4", + "bamarni/composer-bin-plugin": "^1.8" + }, + "config": { + "allow-plugins": { + "phpstan/extension-installer": true, + "bamarni/composer-bin-plugin": true + } + }, + "scripts": { + "test": [ + "composer phplint", + "composer phpstan" + ], + "phpstan": "phpstan analyse --configuration=phpstan.neon --memory-limit=1G", + "phplint": "phplint --no-cache --exclude=vendor ." + } } \ No newline at end of file diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..7e58a37 --- /dev/null +++ b/composer.lock @@ -0,0 +1,365 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "da795661eea3fe782f9474a049a917cb", + "packages": [], + "packages-dev": [ + { + "name": "bamarni/composer-bin-plugin", + "version": "1.8.2", + "source": { + "type": "git", + "url": "https://github.com/bamarni/composer-bin-plugin.git", + "reference": "92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880", + "reference": "92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "ext-json": "*", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpunit/phpunit": "^8.5 || ^9.5", + "symfony/console": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0", + "symfony/finder": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0", + "symfony/process": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Bamarni\\Composer\\Bin\\BamarniBinPlugin" + }, + "autoload": { + "psr-4": { + "Bamarni\\Composer\\Bin\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "No conflicts for your bin dependencies", + "keywords": [ + "composer", + "conflict", + "dependency", + "executable", + "isolation", + "tool" + ], + "support": { + "issues": "https://github.com/bamarni/composer-bin-plugin/issues", + "source": "https://github.com/bamarni/composer-bin-plugin/tree/1.8.2" + }, + "time": "2022-10-31T08:38:03+00:00" + }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v6.6.0", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "86e8753e89d59849276dcdd91b9a7dd78bb4abe2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/86e8753e89d59849276dcdd91b9a7dd78bb4abe2", + "reference": "86e8753e89d59849276dcdd91b9a7dd78bb4abe2", + "shasum": "" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "nikic/php-parser": "^4.13", + "php": "^7.4 || ^8.0", + "php-stubs/generator": "^0.8.3", + "phpdocumentor/reflection-docblock": "^5.4.1", + "phpstan/phpstan": "^1.10.49", + "phpunit/phpunit": "^9.5", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.0", + "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" + }, + "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.6.0" + }, + "time": "2024-07-17T08:50:38+00:00" + }, + { + "name": "phpstan/extension-installer", + "version": "1.4.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "f6b87faf9fc7978eab2f7919a8760bc9f58f9203" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f6b87faf9fc7978eab2f7919a8760bc9f58f9203", + "reference": "f6b87faf9fc7978eab2f7919a8760bc9f58f9203", + "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.4.1" + }, + "time": "2024-06-10T08:20:49+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.11.7", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "52d2bbfdcae7f895915629e4694e9497d0f8e28d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/52d2bbfdcae7f895915629e4694e9497d0f8e28d", + "reference": "52d2bbfdcae7f895915629e4694e9497d0f8e28d", + "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" + } + ], + "time": "2024-07-06T11:17:41+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.30.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/ec444d3f3f6505bb28d11afa41e75faadebc10a1", + "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "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.30.0" + }, + "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": "2024-05-31T15:07:36+00:00" + }, + { + "name": "szepeviktor/phpstan-wordpress", + "version": "v1.3.5", + "source": { + "type": "git", + "url": "https://github.com/szepeviktor/phpstan-wordpress.git", + "reference": "7f8cfe992faa96b6a33bbd75c7bace98864161e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/7f8cfe992faa96b6a33bbd75c7bace98864161e7", + "reference": "7f8cfe992faa96b6a33bbd75c7bace98864161e7", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0", + "phpstan/phpstan": "^1.10.31", + "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": "^1.0", + "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" + }, + "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.5" + }, + "time": "2024-06-28T22:27:19+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/includes/class-afld-cachehandler.php b/includes/class-afld-cachehandler.php index efb3835..567689a 100644 --- a/includes/class-afld-cachehandler.php +++ b/includes/class-afld-cachehandler.php @@ -53,6 +53,7 @@ public function __construct( $cache_path, $cache_file_prefix ) { * Set the cache path. * * @param string $cache_path Path to the cache directory. + * @return void */ private function set_cache_path( $cache_path ) { // Ensure cache directory exists. @@ -66,6 +67,7 @@ private function set_cache_path( $cache_path ) { * * @param string $cache_file_prefix Prefix for cache files. * @throws \InvalidArgumentException If an invalid cache file prefix is provided. + * @return void */ private function set_cache_file_prefix( $cache_file_prefix ) { if ( empty( $cache_file_prefix ) ) { @@ -112,6 +114,7 @@ public function get_cache_data( $file ) { * @param string $file Path to the file. * @param mixed $data Data to cache. * @param string $str_class Translation_Entry class name. + * @return void */ public function update_cache_data( $file, $data, $str_class = 'Translation_Entry' ) { // Construct cache file path. diff --git a/includes/class-translation-entry.php b/includes/class-translation-entry.php index da20b50..8c1354b 100644 --- a/includes/class-translation-entry.php +++ b/includes/class-translation-entry.php @@ -17,25 +17,14 @@ */ class Translation_Entry extends \Translation_Entry { - /** - * Constructor. - * - * @param array $args { - * Optional. Array of arguments for the translation entry. - * - * @type string $singular Singular form of the string. - * @type string $plural Plural form of the string. - * @type string $context Context information for the translators. - * @type string $domain Text domain. Unique identifier for retrieving translated strings. - * @type string $context Context information for the translators. - * @type string $translations { - * Optional. Array of translations for different plural forms. - * - * @type string $singular Singular form of the string. - * @type string $plural Plural form of the string. - * } - * } - */ + + /** + * Constructor for the Translation_Entry class. + * + * @param array $args Arguments array. + * + * @return \Translation_Entry + */ public static function __set_state( $args ) { return new \Translation_Entry( $args ); } diff --git a/package-lock.json b/package-lock.json index 1b3035d..ecb298e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "a-faster-load-textdomain", - "version": "2.2.4", + "version": "2.3.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "a-faster-load-textdomain", - "version": "2.2.4", + "version": "2.3.2", "license": "GPL-2.0-or-later", "dependencies": { "@soderlind/wp-project-version-sync": "^2.0.1" @@ -2166,11 +2166,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "license": "MIT", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -2372,9 +2373,10 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -2512,6 +2514,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -2948,6 +2951,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "license": "MIT", "dependencies": { "is-number": "^7.0.0" }, diff --git a/package.json b/package.json index 0694fc5..7006e2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "a-faster-load-textdomain", - "version": "2.3.1", + "version": "2.3.2", "description": "A faster load_textdomain", "author": "Per Søderlind ", "license": "GPL-2.0-or-later", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..fd4fb8f --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,7 @@ +parameters: + level: 6 + paths: + - ./a-faster-load-textdomain.php + - includes + scanDirectories: + - ../../../wp-includes \ No newline at end of file diff --git a/readme.txt b/readme.txt index 8a48f86..aa5b866 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: l10n, load_textdomain, cache, performance Requires at least: 5.9 Requires PHP: 7.4 Tested up to: 6.4 -Stable tag: 2.3.1 +Stable tag: 2.3.2 Donate link: https://paypal.me/PerSoderlind License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html