From c680f872c125caaf2d1e2f8da007e73de6b58ed7 Mon Sep 17 00:00:00 2001 From: YvesCesar Date: Mon, 28 Sep 2026 10:15:31 -0400 Subject: [PATCH 1/4] chore: add composer setup with phpcs and phpstan Signed-off-by: YvesCesar --- .gitignore | 2 + composer.json | 37 ++ composer.lock | 81 ++++ phpcs.xml.dist | 47 +++ phpstan.neon.dist | 12 + readme.txt | 9 + vendor-bin/lint/composer.json | 11 + vendor-bin/lint/composer.lock | 83 ++++ vendor-bin/phpcs/composer.json | 17 + vendor-bin/phpcs/composer.lock | 651 +++++++++++++++++++++++++++++++ vendor-bin/phpstan/composer.json | 13 + vendor-bin/phpstan/composer.lock | 245 ++++++++++++ 12 files changed, 1208 insertions(+) create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 phpcs.xml.dist create mode 100644 phpstan.neon.dist create mode 100644 vendor-bin/lint/composer.json create mode 100644 vendor-bin/lint/composer.lock create mode 100644 vendor-bin/phpcs/composer.json create mode 100644 vendor-bin/phpcs/composer.lock create mode 100644 vendor-bin/phpstan/composer.json create mode 100644 vendor-bin/phpstan/composer.lock diff --git a/.gitignore b/.gitignore index be3e02d..6a4497a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ # Compiled translation binaries — generated from .po files by the workflow languages/*.mo +/vendor/ +/vendor-bin/*/vendor/ diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..78612b8 --- /dev/null +++ b/composer.json @@ -0,0 +1,37 @@ +{ + "name": "libresign/wordpress-theme", + "description": "WordPress theme for the LibreSign SaaS", + "type": "wordpress-theme", + "license": "GPL-2.0-or-later", + "require": { + "php": ">=8.3 <8.6" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8" + }, + "config": { + "platform": { + "php": "8.3" + }, + "allow-plugins": { + "bamarni/composer-bin-plugin": true + } + }, + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": true + } + }, + "scripts": { + "lint": "parallel-lint --exclude vendor --exclude vendor-bin .", + "cs": "phpcs", + "cs:fix": "phpcbf", + "stan": "phpstan analyse --memory-limit=2G", + "ci": [ + "@lint", + "@cs", + "@stan" + ] + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..8a4e2b4 --- /dev/null +++ b/composer.lock @@ -0,0 +1,81 @@ +{ + "_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": "b7e5f17d904a4977efb85dde5d48edf0", + "packages": [], + "packages-dev": [ + { + "name": "bamarni/composer-bin-plugin", + "version": "1.9.1", + "source": { + "type": "git", + "url": "https://github.com/bamarni/composer-bin-plugin.git", + "reference": "641d0663f5ac270b1aeec4337b7856f76204df47" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/641d0663f5ac270b1aeec4337b7856f76204df47", + "reference": "641d0663f5ac270b1aeec4337b7856f76204df47", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "composer/composer": "^2.2.26", + "ext-json": "*", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8 || ^2.0", + "phpstan/phpstan-phpunit": "^1.1 || ^2.0", + "phpunit/phpunit": "^8.5 || ^9.6 || ^10.0", + "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.9.1" + }, + "time": "2026-02-04T10:18:12+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=8.3 <8.6" + }, + "platform-dev": {}, + "platform-overrides": { + "php": "8.3" + }, + "plugin-api-version": "2.9.0" +} diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..0bfeb29 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,47 @@ + + + Lean ruleset: security, compatibility and global-scope hygiene. + + . + /vendor/* + /vendor-bin/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /woocommerce/* + + + + + + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..87a4e76 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,12 @@ +includes: + - vendor-bin/phpstan/vendor/szepeviktor/phpstan-wordpress/extension.neon + +parameters: + level: 5 + paths: + - functions.php + - inc + - patterns + - woocommerce + bootstrapFiles: + - vendor-bin/phpstan/vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php diff --git a/readme.txt b/readme.txt index e2721f4..6eb2a70 100644 --- a/readme.txt +++ b/readme.txt @@ -49,6 +49,15 @@ Recommended repository webhook configuration on `LibreSign/site`: - `bash tests/github-site-webhook-smoke.sh` +== Development == + +Every check is a Composer script: + +- `composer lint`: php -l on every file +- `composer cs`: PHPCS +- `composer stan`: PHPStan +- `composer ci`: all of the above, in this order + == Development notes == - Site fragment sync/render bootstrap: `inc/footer-fragment.php` diff --git a/vendor-bin/lint/composer.json b/vendor-bin/lint/composer.json new file mode 100644 index 0000000..b699202 --- /dev/null +++ b/vendor-bin/lint/composer.json @@ -0,0 +1,11 @@ +{ + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.4" + }, + "config": { + "platform": { + "php": "8.3" + }, + "sort-packages": true + } +} diff --git a/vendor-bin/lint/composer.lock b/vendor-bin/lint/composer.lock new file mode 100644 index 0000000..e042d85 --- /dev/null +++ b/vendor-bin/lint/composer.lock @@ -0,0 +1,83 @@ +{ + "_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": "e029a2fc75e122e06d5e0893f9a5dac9", + "packages": [], + "packages-dev": [ + { + "name": "php-parallel-lint/php-parallel-lint", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", + "reference": "6db563514f27e19595a19f45a4bf757b6401194e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6db563514f27e19595a19f45a4bf757b6401194e", + "reference": "6db563514f27e19595a19f45a4bf757b6401194e", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=5.3.0" + }, + "replace": { + "grogy/php-parallel-lint": "*", + "jakub-onderka/php-parallel-lint": "*" + }, + "require-dev": { + "nette/tester": "^1.3 || ^2.0", + "php-parallel-lint/php-console-highlighter": "0.* || ^1.0", + "squizlabs/php_codesniffer": "^3.6" + }, + "suggest": { + "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" + }, + "bin": [ + "parallel-lint" + ], + "type": "library", + "autoload": { + "classmap": [ + "./src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Jakub Onderka", + "email": "ahoj@jakubonderka.cz" + } + ], + "description": "This tool checks the syntax of PHP files about 20x faster than serial check.", + "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", + "keywords": [ + "lint", + "static analysis" + ], + "support": { + "issues": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/issues", + "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v1.4.0" + }, + "time": "2024-03-27T12:14:49+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": {}, + "platform-dev": {}, + "platform-overrides": { + "php": "8.3" + }, + "plugin-api-version": "2.9.0" +} diff --git a/vendor-bin/phpcs/composer.json b/vendor-bin/phpcs/composer.json new file mode 100644 index 0000000..b34fac6 --- /dev/null +++ b/vendor-bin/phpcs/composer.json @@ -0,0 +1,17 @@ +{ + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "phpcompatibility/phpcompatibility-wp": "^2.1", + "squizlabs/php_codesniffer": "^3.13", + "wp-coding-standards/wpcs": "^3.2" + }, + "config": { + "platform": { + "php": "8.3" + }, + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + } +} diff --git a/vendor-bin/phpcs/composer.lock b/vendor-bin/phpcs/composer.lock new file mode 100644 index 0000000..8b1f7d9 --- /dev/null +++ b/vendor-bin/phpcs/composer.lock @@ -0,0 +1,651 @@ +{ + "_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": "7a5d629e67c2817ee2a280c32aa7431e", + "packages": [], + "packages-dev": [ + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v1.2.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "963f0c67bffde0eac41b56be71ac0e8ba132f0bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/963f0c67bffde0eac41b56be71ac0e8ba132f0bd", + "reference": "963f0c67bffde0eac41b56be71ac0e8ba132f0bd", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.2", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "^2.2", + "ext-json": "*", + "ext-zip": "*", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcompatibility/php-compatibility": "^9.0 || ^10.0.0@dev", + "yoast/phpunit-polyfills": "^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "opensource@frenck.dev", + "homepage": "https://frenck.dev", + "role": "Open source developer" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "security": "https://github.com/PHPCSStandards/composer-installer/security/policy", + "source": "https://github.com/PHPCSStandards/composer-installer" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2026-05-06T08:26:05+00:00" + }, + { + "name": "phpcompatibility/php-compatibility", + "version": "9.3.5", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibility" + }, + "time": "2019-12-27T09:44:58+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-paragonie", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", + "reference": "244d7b04fc4bc2117c15f5abe23eb933b5f02bbf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/244d7b04fc4bc2117c15f5abe23eb933b5f02bbf", + "reference": "244d7b04fc4bc2117c15f5abe23eb933b5f02bbf", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "paragonie/random_compat": "dev-master", + "paragonie/sodium_compat": "dev-master" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "paragonie", + "phpcs", + "polyfill", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", + "security": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/security/policy", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" + }, + "funding": [ + { + "url": "https://github.com/PHPCompatibility", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcompatibility", + "type": "thanks_dev" + } + ], + "time": "2025-09-19T17:43:28+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-wp", + "version": "2.1.8", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", + "reference": "7c8d18b4d90dac9e86b0869a608fa09158e168fa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/7c8d18b4d90dac9e86b0869a608fa09158e168fa", + "reference": "7c8d18b4d90dac9e86b0869a608fa09158e168fa", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0", + "phpcompatibility/phpcompatibility-paragonie": "^1.0", + "squizlabs/php_codesniffer": "^3.3" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "phpcs", + "standards", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", + "security": "https://github.com/PHPCompatibility/PHPCompatibilityWP/security/policy", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" + }, + "funding": [ + { + "url": "https://github.com/PHPCompatibility", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcompatibility", + "type": "thanks_dev" + } + ], + "time": "2025-10-18T00:05:59+00:00" + }, + { + "name": "phpcsstandards/phpcsextra", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", + "reference": "39467533fdb742446d68c1d10ac33d625ee0311c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/39467533fdb742446d68c1d10ac33d625ee0311c", + "reference": "39467533fdb742446d68c1d10ac33d625ee0311c", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.2.3", + "squizlabs/php_codesniffer": "^3.13.5 || ^4.0.1" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", + "phpcsstandards/phpcsdevtools": "^1.2.1", + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" + } + ], + "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", + "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSExtra" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2026-07-27T11:13:17+00:00" + }, + { + "name": "phpcsstandards/phpcsutils", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "5f35d9408c54d7b529501f3c688b6eae562aea1f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/5f35d9408c54d7b529501f3c688b6eae562aea1f", + "reference": "5f35d9408c54d7b529501f3c688b6eae562aea1f", + "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.13.5 || ^4.0.1" + }, + "require-dev": { + "ext-filter": "*", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0 || ^3.0.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPCSUtils/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" + } + ], + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "phpcs3", + "phpcs4", + "standards", + "static analysis", + "tokens", + "utility" + ], + "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" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2026-07-27T10:28:41+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.13.6", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "4c378e1a528ea066890fc2397cbdd2f94eb2fc91" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/4c378e1a528ea066890fc2397cbdd2f94eb2fc91", + "reference": "4c378e1a528ea066890fc2397cbdd2f94eb2fc91", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + }, + "bin": [ + "bin/phpcbf", + "bin/phpcs" + ], + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "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/PHPCSStandards/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards", + "static analysis" + ], + "support": { + "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" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2026-08-06T00:17:32+00:00" + }, + { + "name": "wp-coding-standards/wpcs", + "version": "3.4.1", + "source": { + "type": "git", + "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", + "reference": "ec2ff942335f33683a5957a85d138753876a05cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/ec2ff942335f33683a5957a85d138753876a05cf", + "reference": "ec2ff942335f33683a5957a85d138753876a05cf", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "ext-libxml": "*", + "ext-tokenizer": "*", + "ext-xmlreader": "*", + "php": ">=7.2", + "phpcsstandards/phpcsextra": "^1.5.1", + "phpcsstandards/phpcsutils": "^1.2.3", + "squizlabs/php_codesniffer": "^3.13.5" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcompatibility/php-compatibility": "^10.0.0@dev", + "phpcsstandards/phpcsdevtools": "^1.2.0", + "phpunit/phpunit": "^8.0 || ^9.0" + }, + "suggest": { + "ext-iconv": "For improved results", + "ext-mbstring": "For improved results" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", + "keywords": [ + "phpcs", + "standards", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", + "source": "https://github.com/WordPress/WordPress-Coding-Standards", + "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" + }, + "funding": [ + { + "url": "https://opencollective.com/php_codesniffer", + "type": "custom" + } + ], + "time": "2026-07-27T11:53:23+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": {}, + "platform-dev": {}, + "platform-overrides": { + "php": "8.3" + }, + "plugin-api-version": "2.9.0" +} diff --git a/vendor-bin/phpstan/composer.json b/vendor-bin/phpstan/composer.json new file mode 100644 index 0000000..02fea08 --- /dev/null +++ b/vendor-bin/phpstan/composer.json @@ -0,0 +1,13 @@ +{ + "require-dev": { + "php-stubs/woocommerce-stubs": "^11.1", + "phpstan/phpstan": "^2.1", + "szepeviktor/phpstan-wordpress": "^2.0" + }, + "config": { + "platform": { + "php": "8.3" + }, + "sort-packages": true + } +} diff --git a/vendor-bin/phpstan/composer.lock b/vendor-bin/phpstan/composer.lock new file mode 100644 index 0000000..b95eaf8 --- /dev/null +++ b/vendor-bin/phpstan/composer.lock @@ -0,0 +1,245 @@ +{ + "_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": "a3479c2b5b3a0fc3ce103f1766b67945", + "packages": [], + "packages-dev": [ + { + "name": "php-stubs/woocommerce-stubs", + "version": "v11.1.2", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/woocommerce-stubs.git", + "reference": "06dfedfe33a46a12db99fd343b80f1f2f11e64f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/woocommerce-stubs/zipball/06dfedfe33a46a12db99fd343b80f1f2f11e64f6", + "reference": "06dfedfe33a46a12db99fd343b80f1f2f11e64f6", + "shasum": "" + }, + "require": { + "php-stubs/wordpress-stubs": "^5.3 || ^6.0 || ^7.0" + }, + "require-dev": { + "php": "~7.1 || ~8.0", + "php-stubs/generator": "^0.9.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": "WooCommerce function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/woocommerce-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "woocommerce", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/woocommerce-stubs/issues", + "source": "https://github.com/php-stubs/woocommerce-stubs/tree/v11.1.2" + }, + "time": "2026-09-22T23:29:58+00:00" + }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v7.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "394570301894799e69a4aa117c9c995427e3ba04" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/394570301894799e69a4aa117c9c995427e3ba04", + "reference": "394570301894799e69a4aa117c9c995427e3ba04", + "shasum": "" + }, + "conflict": { + "phpdocumentor/reflection-docblock": "5.6.1" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "nikic/php-parser": "^5.5", + "php": "^7.4 || ^8.0", + "php-stubs/generator": "^0.9", + "phpdocumentor/reflection-docblock": "^6.0", + "phpstan/phpstan": "^2.2", + "phpunit/phpunit": "^9.5", + "symfony/polyfill-php80": "*", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.2", + "wp-coding-standards/wpcs": "3.4.1 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/v7.1.0" + }, + "time": "2026-08-28T00:32:06+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "2.2.16", + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/46a6d9060e5a7763adfcc21ebcb8b504ebdbcb92", + "reference": "46a6d9060e5a7763adfcc21ebcb8b504ebdbcb92", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ondřej Mirtes" + }, + { + "name": "Markus Staab" + }, + { + "name": "Vincent Langlet" + } + ], + "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": "2026-09-25T09:31:51+00:00" + }, + { + "name": "szepeviktor/phpstan-wordpress", + "version": "v2.0.4", + "source": { + "type": "git", + "url": "https://github.com/szepeviktor/phpstan-wordpress.git", + "reference": "84577e2ea1e4c2a95537fe5ea2ac8e18f4ceab1a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/84577e2ea1e4c2a95537fe5ea2ac8e18f4ceab1a", + "reference": "84577e2ea1e4c2a95537fe5ea2ac8e18f4ceab1a", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "php-stubs/wordpress-stubs": ">=6.6.2", + "phpstan/phpstan": "^2.0" + }, + "require-dev": { + "composer/composer": "^2.1.14", + "composer/semver": "^3.4", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^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/v2.0.4" + }, + "time": "2026-05-22T16:22:09+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": {}, + "platform-dev": {}, + "platform-overrides": { + "php": "8.3" + }, + "plugin-api-version": "2.9.0" +} From 3a9be349454c857b187884520d133ca2a1505ae4 Mon Sep 17 00:00:00 2001 From: YvesCesar Date: Mon, 28 Sep 2026 10:15:31 -0400 Subject: [PATCH 2/4] chore: clear the phpcs findings and declare the supported wordpress and php versions Signed-off-by: YvesCesar --- inc/account.php | 42 +++++++++++----------- inc/checkout.php | 10 +++--- inc/cpf-cnpj.php | 14 ++++---- inc/logo.php | 14 ++++---- inc/plans.php | 2 +- inc/registration.php | 24 ++++++------- patterns/text-centered-statement-small.php | 13 +++---- readme.txt | 6 ++-- style.css | 6 ++-- woocommerce/myaccount/form-login.php | 14 ++++---- 10 files changed, 73 insertions(+), 72 deletions(-) diff --git a/inc/account.php b/inc/account.php index b4829c8..d4c06b9 100644 --- a/inc/account.php +++ b/inc/account.php @@ -15,7 +15,7 @@ /** * Resolve the canonical WooCommerce My Account URL. */ -function libresign_get_account_url() { +function libresign_theme_get_account_url() { if ( function_exists( 'wc_get_page_permalink' ) ) { $account_url = wc_get_page_permalink( 'myaccount' ); if ( ! empty( $account_url ) ) { @@ -31,11 +31,11 @@ function libresign_get_account_url() { * `redirect_to`, then checkout while a purchase is in progress, then the * account dashboard. */ -function libresign_get_purchase_redirect_target() { +function libresign_theme_get_purchase_redirect_target() { $redirect_to = ''; if ( isset( $_REQUEST['redirect_to'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended - $redirect_to = wp_unslash( $_REQUEST['redirect_to'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended + $redirect_to = wp_sanitize_redirect( wp_unslash( $_REQUEST['redirect_to'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended } $redirect_to = wp_validate_redirect( $redirect_to, '' ); @@ -44,11 +44,11 @@ function libresign_get_purchase_redirect_target() { return $redirect_to; } - if ( function_exists( 'libresign_cart_has_items' ) && libresign_cart_has_items() && function_exists( 'wc_get_checkout_url' ) ) { + if ( function_exists( 'libresign_theme_cart_has_items' ) && libresign_theme_cart_has_items() && function_exists( 'wc_get_checkout_url' ) ) { return wc_get_checkout_url(); } - return libresign_get_account_url(); + return libresign_theme_get_account_url(); } // --------------------------------------------------------------------------- @@ -58,7 +58,7 @@ function libresign_get_purchase_redirect_target() { /** * Detect if the current request targets the WooCommerce lost-password endpoint. */ -function libresign_is_lost_password_request() { +function libresign_theme_is_lost_password_request() { if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'lost-password' ) ) { return true; } @@ -73,8 +73,8 @@ function libresign_is_lost_password_request() { /** * Detect the direct /lost-password/ route used outside the WooCommerce account page. */ -function libresign_is_direct_lost_password_route() { - $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : ''; +function libresign_theme_is_direct_lost_password_route() { + $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; $path = wp_parse_url( $request_uri, PHP_URL_PATH ); return '/lost-password/' === $path || '/lost-password' === $path; @@ -84,7 +84,7 @@ function libresign_is_direct_lost_password_route() { * Detect a WooCommerce password-reset confirmation request (reset link, * set-new-password or link-sent step). */ -function libresign_is_password_reset_confirmation() { +function libresign_theme_is_password_reset_confirmation() { if ( isset( $_GET['key'] ) && ( isset( $_GET['id'] ) || isset( $_GET['login'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return true; } @@ -99,8 +99,8 @@ function libresign_is_password_reset_confirmation() { /** * Render the lost-password form. */ -function libresign_render_lost_password_form() { - $account_url = libresign_get_account_url(); +function libresign_theme_render_lost_password_form() { + $account_url = libresign_theme_get_account_url(); $button_class = function_exists( 'wc_wp_theme_get_element_class_name' ) && wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : ''; @@ -150,7 +150,7 @@ function libresign_render_lost_password_form() { * and the standard dashboard for logged-in users). * - Shop / checkout → prepend the SaaS onboarding block pattern. */ -function libresign_prepend_saas_onboarding_to_content( $content ) { +function libresign_theme_prepend_saas_onboarding_to_content( $content ) { if ( is_admin() || ! in_the_loop() || ! is_main_query() ) { return $content; } @@ -162,13 +162,13 @@ function libresign_prepend_saas_onboarding_to_content( $content ) { remove_filter( 'the_content', 'shortcode_unautop' ); } - if ( function_exists( 'is_account_page' ) && is_account_page() && libresign_is_lost_password_request() ) { - if ( libresign_is_password_reset_confirmation() ) { + if ( function_exists( 'is_account_page' ) && is_account_page() && libresign_theme_is_lost_password_request() ) { + if ( libresign_theme_is_password_reset_confirmation() ) { return function_exists( 'do_shortcode' ) ? do_shortcode( '[woocommerce_my_account]' ) : $content; } ob_start(); - libresign_render_lost_password_form(); + libresign_theme_render_lost_password_form(); return ob_get_clean(); } @@ -194,7 +194,7 @@ function libresign_prepend_saas_onboarding_to_content( $content ) { return $content; } -add_filter( 'the_content', 'libresign_prepend_saas_onboarding_to_content', 5 ); +add_filter( 'the_content', 'libresign_theme_prepend_saas_onboarding_to_content', 5 ); // --------------------------------------------------------------------------- // Direct /lost-password/ route handler @@ -204,14 +204,14 @@ function libresign_prepend_saas_onboarding_to_content( $content ) { * Render the lost-password page when the route is visited outside the * WooCommerce account page (e.g. /lost-password/ directly). */ -function libresign_render_direct_lost_password_route() { - if ( is_admin() || wp_doing_ajax() || ! libresign_is_direct_lost_password_route() ) { +function libresign_theme_render_direct_lost_password_route() { + if ( is_admin() || wp_doing_ajax() || ! libresign_theme_is_direct_lost_password_route() ) { return; } // Let WooCommerce's redirect_reset_password_link() (priority 10) handle // confirmation links. - if ( libresign_is_password_reset_confirmation() ) { + if ( libresign_theme_is_password_reset_confirmation() ) { return; } @@ -239,7 +239,7 @@ function libresign_render_direct_lost_password_route() {

- +
@@ -250,4 +250,4 @@ function libresign_render_direct_lost_password_route() { add( 'libresign_policy_consent', @@ -36,4 +36,4 @@ function libresign_validate_checkout_policy_consent( $data, $errors ) { ); } } -add_action( 'woocommerce_after_checkout_validation', 'libresign_validate_checkout_policy_consent', 10, 2 ); +add_action( 'woocommerce_after_checkout_validation', 'libresign_theme_validate_checkout_policy_consent', 10, 2 ); diff --git a/inc/cpf-cnpj.php b/inc/cpf-cnpj.php index 30bf92e..23353f6 100644 --- a/inc/cpf-cnpj.php +++ b/inc/cpf-cnpj.php @@ -43,7 +43,7 @@ * @param string $cpf Raw or formatted CPF (dots and dash are stripped). * @return bool */ -function libresign_validate_cpf( string $cpf ): bool { +function libresign_theme_validate_cpf( string $cpf ): bool { $cpf = preg_replace( '/[^0-9]/', '', $cpf ); if ( strlen( $cpf ) !== 11 ) { return false; @@ -86,7 +86,7 @@ function libresign_validate_cpf( string $cpf ): bool { * @param string $cnpj Raw or formatted CNPJ (dots, slash, dash are stripped). * @return bool */ -function libresign_validate_cnpj( string $cnpj ): bool { +function libresign_theme_validate_cnpj( string $cnpj ): bool { $cnpj = strtoupper( preg_replace( '/[\.\-\/]/', '', $cnpj ) ); if ( strlen( $cnpj ) !== 14 ) { return false; @@ -145,11 +145,11 @@ function libresign_validate_cnpj( string $cnpj ): bool { $stripped = strtoupper( preg_replace( '/[\.\-\/]/', '', $value ) ); if ( 14 === strlen( $stripped ) ) { - if ( ! libresign_validate_cnpj( $value ) ) { + if ( ! libresign_theme_validate_cnpj( $value ) ) { $errors->add( 'invalid_cnpj', __( 'Please enter a valid CNPJ.', 'libresign' ) ); } } elseif ( 11 === strlen( $digits_only ) ) { - if ( ! libresign_validate_cpf( $value ) ) { + if ( ! libresign_theme_validate_cpf( $value ) ) { $errors->add( 'invalid_cpf', __( 'Please enter a valid CPF.', 'libresign' ) ); } } else { @@ -163,7 +163,7 @@ function libresign_validate_cnpj( string $cnpj ): bool { * Store API update hooks, which fire after the value is set on the object but * before it is saved. */ -function libresign_strip_irrelevant_cpf_cnpj( $wc_object ) { +function libresign_theme_strip_irrelevant_cpf_cnpj( $wc_object ) { if ( ! is_object( $wc_object ) || ! method_exists( $wc_object, 'delete_meta_data' ) ) { return; } @@ -176,11 +176,11 @@ function libresign_strip_irrelevant_cpf_cnpj( $wc_object ) { } add_action( 'woocommerce_store_api_checkout_update_order_from_request', function ( $order ) { - libresign_strip_irrelevant_cpf_cnpj( $order ); + libresign_theme_strip_irrelevant_cpf_cnpj( $order ); }, 100, 1 ); add_action( 'woocommerce_store_api_checkout_update_customer_from_request', function ( $customer ) { - libresign_strip_irrelevant_cpf_cnpj( $customer ); + libresign_theme_strip_irrelevant_cpf_cnpj( $customer ); }, 100, 1 ); /** diff --git a/inc/logo.php b/inc/logo.php index aaeff64..91a1775 100644 --- a/inc/logo.php +++ b/inc/logo.php @@ -25,7 +25,7 @@ * @param string $variant 'light' for light backgrounds (default), 'dark' for dark. * @return string */ -function libresign_get_theme_logo_url( string $variant = 'light' ): string { +function libresign_theme_get_theme_logo_url( string $variant = 'light' ): string { $base = 'https://github.com/LibreSign/site/raw/refs/heads/main/source/assets/images/logo/'; return 'dark' === $variant ? $base . 'logo-2.svg' // pale logo — legible on dark backgrounds @@ -40,7 +40,7 @@ function libresign_get_theme_logo_url( string $variant = 'light' ): string { * the browser may select any of the srcset candidates based on viewport and * device pixel ratio. */ -function libresign_custom_logo_needs_fallback( $custom_logo_html ) { +function libresign_theme_custom_logo_needs_fallback( $custom_logo_html ) { if ( '' === trim( (string) $custom_logo_html ) ) { return true; } @@ -112,13 +112,13 @@ function libresign_custom_logo_needs_fallback( $custom_logo_html ) { * 3. Wraps the in a element so the browser picks the correct * variant from the system color-scheme preference without JavaScript. */ -function libresign_filter_custom_logo( $custom_logo_html, $blog_id ) { - if ( ! libresign_custom_logo_needs_fallback( $custom_logo_html ) ) { +function libresign_theme_filter_custom_logo( $custom_logo_html, $blog_id ) { + if ( ! libresign_theme_custom_logo_needs_fallback( $custom_logo_html ) ) { return $custom_logo_html; } - $logo_light = esc_url( libresign_get_theme_logo_url( 'light' ) ); - $logo_dark = esc_url( libresign_get_theme_logo_url( 'dark' ) ); + $logo_light = esc_url( libresign_theme_get_theme_logo_url( 'light' ) ); + $logo_dark = esc_url( libresign_theme_get_theme_logo_url( 'dark' ) ); // Remove srcset/sizes and set src to the light-background logo. $patched = preg_replace( '/\ssrcset=["\'][^"\']*["\']/', '', $custom_logo_html ); @@ -142,4 +142,4 @@ function libresign_filter_custom_logo( $custom_logo_html, $blog_id ) { return $patched ?: $custom_logo_html; } -add_filter( 'get_custom_logo', 'libresign_filter_custom_logo', 10, 2 ); +add_filter( 'get_custom_logo', 'libresign_theme_filter_custom_logo', 10, 2 ); diff --git a/inc/plans.php b/inc/plans.php index 8197bca..e156ce5 100644 --- a/inc/plans.php +++ b/inc/plans.php @@ -10,7 +10,7 @@ /** * URL of the plans listing, falling back to the WooCommerce shop. */ -function libresign_get_plans_url() { +function libresign_theme_get_plans_url() { $page = get_page_by_path( 'plans' ); if ( $page instanceof WP_Post && 'publish' === $page->post_status ) { return (string) get_permalink( $page ); diff --git a/inc/registration.php b/inc/registration.php index f3d1bf4..ca3c794 100644 --- a/inc/registration.php +++ b/inc/registration.php @@ -12,7 +12,7 @@ /** * Return the site policy / privacy page URL. */ -function libresign_get_policy_url() { +function libresign_theme_get_policy_url() { $policy_page_id = 3; $policy_url = get_permalink( $policy_page_id ); @@ -27,7 +27,7 @@ function libresign_get_policy_url() { * Whether a purchase is in progress, which decides what the account page offers * and where authentication leads. */ -function libresign_cart_has_items() { +function libresign_theme_cart_has_items() { if ( ! function_exists( 'WC' ) ) { return false; } @@ -45,7 +45,7 @@ function libresign_cart_has_items() { * wc_create_new_customer(), which checkout also uses, and would reject every * account created there since the consent field only exists on this form. */ -function libresign_validate_workspace_terms( $errors ) { +function libresign_theme_validate_workspace_terms( $errors ) { if ( empty( $_POST['libresign_workspace_terms'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing $errors->add( 'libresign_workspace_terms', @@ -55,12 +55,12 @@ function libresign_validate_workspace_terms( $errors ) { return $errors; } -add_filter( 'woocommerce_process_registration_errors', 'libresign_validate_workspace_terms', 10, 1 ); +add_filter( 'woocommerce_process_registration_errors', 'libresign_theme_validate_workspace_terms', 10, 1 ); /** * Persist the terms consent so the approval is auditable. */ -function libresign_persist_workspace_consent( $customer_id ) { +function libresign_theme_persist_workspace_consent( $customer_id ) { if ( empty( $_POST['libresign_workspace_terms'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing return; } @@ -68,20 +68,20 @@ function libresign_persist_workspace_consent( $customer_id ) { update_user_meta( $customer_id, 'libresign_workspace_terms', 'yes' ); update_user_meta( $customer_id, 'libresign_workspace_terms_date', current_time( 'mysql' ) ); } -add_action( 'woocommerce_created_customer', 'libresign_persist_workspace_consent', 10, 1 ); +add_action( 'woocommerce_created_customer', 'libresign_theme_persist_workspace_consent', 10, 1 ); /** * Send users to their destination after logging in. */ -function libresign_login_redirect( $redirect, $user ) { - return libresign_get_purchase_redirect_target(); +function libresign_theme_login_redirect( $redirect, $user ) { + return libresign_theme_get_purchase_redirect_target(); } -add_filter( 'woocommerce_login_redirect', 'libresign_login_redirect', 10, 2 ); +add_filter( 'woocommerce_login_redirect', 'libresign_theme_login_redirect', 10, 2 ); /** * Send users to their destination after registering. */ -function libresign_registration_redirect( $redirect ) { - return libresign_get_purchase_redirect_target(); +function libresign_theme_registration_redirect( $redirect ) { + return libresign_theme_get_purchase_redirect_target(); } -add_filter( 'woocommerce_registration_redirect', 'libresign_registration_redirect', 10, 1 ); +add_filter( 'woocommerce_registration_redirect', 'libresign_theme_registration_redirect', 10, 1 ); diff --git a/patterns/text-centered-statement-small.php b/patterns/text-centered-statement-small.php index c9fcaca..8014e23 100644 --- a/patterns/text-centered-statement-small.php +++ b/patterns/text-centered-statement-small.php @@ -16,14 +16,15 @@

' . esc_html__( 'Money Studies', 'libresign' ) . ''; - echo sprintf( + echo wp_kses_post( + sprintf( /* Translators: About text placeholder */ esc_html__( 'I write about finance, management and economy, my book “%1$s” is out now.', 'libresign' ), - $about_link - ); - ?> + /* Translators: About link placeholder */ + '' . esc_html__( 'Money Studies', 'libresign' ) . '' + ) + ); + ?>

diff --git a/readme.txt b/readme.txt index 6eb2a70..486e55a 100644 --- a/readme.txt +++ b/readme.txt @@ -1,9 +1,9 @@ == libresign == Contributors: LibreCode -Requires at least: 6.0 -Tested up to: 6.6 -Requires PHP: 5.7 +Requires at least: 7.0 +Tested up to: 7.0 +Requires PHP: 8.3 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/style.css b/style.css index 4b13d8b..c04f6ca 100644 --- a/style.css +++ b/style.css @@ -4,9 +4,9 @@ Theme URI: Author: LibreCode Author URI: Description: Nosso tema -Requires at least: 6.4 -Tested up to: 6.6 -Requires PHP: 7.0 +Requires at least: 7.0 +Tested up to: 7.0 +Requires PHP: 8.3 Version: 1.0 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/woocommerce/myaccount/form-login.php b/woocommerce/myaccount/form-login.php index 094136c..8f559b6 100644 --- a/woocommerce/myaccount/form-login.php +++ b/woocommerce/myaccount/form-login.php @@ -22,12 +22,12 @@ do_action( 'woocommerce_before_customer_login_form' ); -$purchase_in_progress = function_exists( 'libresign_cart_has_items' ) && libresign_cart_has_items(); +$purchase_in_progress = function_exists( 'libresign_theme_cart_has_items' ) && libresign_theme_cart_has_items(); $show_registration = $purchase_in_progress && 'yes' === get_option( 'woocommerce_enable_myaccount_registration' ); -$redirect_to = function_exists( 'libresign_get_purchase_redirect_target' ) ? libresign_get_purchase_redirect_target() : ''; -$policy_url = function_exists( 'libresign_get_policy_url' ) ? libresign_get_policy_url() : home_url( '/privacy-policy/' ); +$redirect_to = function_exists( 'libresign_theme_get_purchase_redirect_target' ) ? libresign_theme_get_purchase_redirect_target() : ''; +$policy_url = function_exists( 'libresign_theme_get_policy_url' ) ? libresign_theme_get_policy_url() : home_url( '/privacy-policy/' ); $lost_password_url = function_exists( 'wc_lostpassword_url' ) ? wc_lostpassword_url() : wp_lostpassword_url(); -$plans_url = function_exists( 'libresign_get_plans_url' ) ? libresign_get_plans_url() : ''; +$plans_url = function_exists( 'libresign_theme_get_plans_url' ) ? libresign_theme_get_plans_url() : ''; $show_plans_cta = ! $purchase_in_progress && '' !== $plans_url; $two_columns = $show_registration || $show_plans_cta; ?> @@ -47,7 +47,7 @@ - +

@@ -110,7 +110,7 @@ - +

@@ -119,7 +119,7 @@ - +

From 19ce58fbfb40173d6f80eddf2a19dee675099953 Mon Sep 17 00:00:00 2001 From: YvesCesar Date: Mon, 28 Sep 2026 10:15:31 -0400 Subject: [PATCH 3/4] chore: clear the phpstan findings Signed-off-by: YvesCesar --- inc/footer-fragment.php | 13 +++---------- phpstan.neon.dist | 11 +++++++++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/inc/footer-fragment.php b/inc/footer-fragment.php index aa32ffc..749f217 100644 --- a/inc/footer-fragment.php +++ b/inc/footer-fragment.php @@ -53,7 +53,7 @@ function libresign_theme_site_fragment_normalize_locale_tag( $locale ) { return ''; } - $parts = array_values( array_filter( explode( '-', $locale ), 'strlen' ) ); + $parts = array_values( array_filter( explode( '-', $locale ), static fn ( $part ) => '' !== $part ) ); if ( empty( $parts ) ) { return ''; } @@ -193,10 +193,6 @@ function libresign_theme_site_fragment_fetch_url( $url ) { * @return bool */ function libresign_theme_site_fragment_is_optional_http_error( $error ) { - if ( ! is_wp_error( $error ) ) { - return false; - } - $data = $error->get_error_data(); return is_array( $data ) && isset( $data['status'] ) && 404 === (int) $data['status']; @@ -309,7 +305,7 @@ static function ( $matches ) use ( $site_origin ) { $content = preg_replace_callback( '~url\(\s*(?:("|\')\s*)?(\/(?!\/)[^)"\']+)(?:\s*\1)?\s*\)~i', static function ( $matches ) use ( $site_origin ) { - $quote = isset( $matches[1] ) ? (string) $matches[1] : ''; + $quote = $matches[1]; return 'url(' . $quote . $site_origin . $matches[2] . $quote . ')'; }, @@ -550,10 +546,7 @@ function libresign_theme_site_fragment_locale_lookup_keys() { } $keys[] = $normalized; - $language_only = strtok( $normalized, '-' ); - if ( is_string( $language_only ) && '' !== $language_only ) { - $keys[] = strtolower( $language_only ); - } + $keys[] = strtolower( strtok( $normalized, '-' ) ); } $keys[] = LIBRESIGN_THEME_SITE_FRAGMENT_DEFAULT_LOCALE_KEY; diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 87a4e76..cfa98c4 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -10,3 +10,14 @@ parameters: - woocommerce bootstrapFiles: - vendor-bin/phpstan/vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php + ignoreErrors: + - + identifier: constant.notFound + message: '#^Constant (AUTH_KEY|SECURE_AUTH_SALT|NONCE_SALT) not found\.$#' + path: inc/github-site-webhook.php + - + identifier: isset.property + path: inc/registration.php + - + identifier: booleanAnd.rightAlwaysTrue + path: inc/registration.php From 850619e96875977f05a2d66cdd03f867ab3e0bf8 Mon Sep 17 00:00:00 2001 From: YvesCesar Date: Mon, 28 Sep 2026 10:15:31 -0400 Subject: [PATCH 4/4] ci: run php lint, phpcs and phpstan on every pull request Signed-off-by: YvesCesar --- .github/workflows/php-lint.yml | 43 ++++++++++++++++++++++++++++++++++ .github/workflows/phpcs.yml | 43 ++++++++++++++++++++++++++++++++++ .github/workflows/phpstan.yml | 43 ++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 .github/workflows/php-lint.yml create mode 100644 .github/workflows/phpcs.yml create mode 100644 .github/workflows/phpstan.yml diff --git a/.github/workflows/php-lint.yml b/.github/workflows/php-lint.yml new file mode 100644 index 0000000..e1016c9 --- /dev/null +++ b/.github/workflows/php-lint.yml @@ -0,0 +1,43 @@ +name: PHP Lint + +on: + push: + branches: + - main + pull_request: + +permissions: + contents: read + +jobs: + php-matrix: + name: PHP matrix + runs-on: ubuntu-latest + outputs: + versions: ${{ steps.php-matrix.outputs.versions }} + steps: + - uses: actions/checkout@v5 + + - uses: typisttech/php-matrix-action@0545a7d54db2c7be158b615b1e7f458ae6e99ad3 # v3.0.2 + id: php-matrix + + php-lint: + name: PHP Lint (PHP ${{ matrix.php }}) + needs: php-matrix + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ${{ fromJSON(needs.php-matrix.outputs.versions) }} + steps: + - uses: actions/checkout@v5 + + - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 + with: + php-version: ${{ matrix.php }} + coverage: none + tools: composer + + - uses: ramsey/composer-install@a8d0d959dab41457692a5e2041bd9b757a119e3f # 3.2.1 + + - run: composer lint diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml new file mode 100644 index 0000000..ac2ab98 --- /dev/null +++ b/.github/workflows/phpcs.yml @@ -0,0 +1,43 @@ +name: PHPCS + +on: + push: + branches: + - main + pull_request: + +permissions: + contents: read + +jobs: + php-matrix: + name: PHP matrix + runs-on: ubuntu-latest + outputs: + versions: ${{ steps.php-matrix.outputs.versions }} + steps: + - uses: actions/checkout@v5 + + - uses: typisttech/php-matrix-action@0545a7d54db2c7be158b615b1e7f458ae6e99ad3 # v3.0.2 + id: php-matrix + + phpcs: + name: PHPCS (PHP ${{ matrix.php }}) + needs: php-matrix + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ${{ fromJSON(needs.php-matrix.outputs.versions) }} + steps: + - uses: actions/checkout@v5 + + - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 + with: + php-version: ${{ matrix.php }} + coverage: none + tools: composer + + - uses: ramsey/composer-install@a8d0d959dab41457692a5e2041bd9b757a119e3f # 3.2.1 + + - run: composer cs diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..bd37985 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,43 @@ +name: PHPStan + +on: + push: + branches: + - main + pull_request: + +permissions: + contents: read + +jobs: + php-matrix: + name: PHP matrix + runs-on: ubuntu-latest + outputs: + versions: ${{ steps.php-matrix.outputs.versions }} + steps: + - uses: actions/checkout@v5 + + - uses: typisttech/php-matrix-action@0545a7d54db2c7be158b615b1e7f458ae6e99ad3 # v3.0.2 + id: php-matrix + + phpstan: + name: PHPStan (PHP ${{ matrix.php }}) + needs: php-matrix + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ${{ fromJSON(needs.php-matrix.outputs.versions) }} + steps: + - uses: actions/checkout@v5 + + - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 + with: + php-version: ${{ matrix.php }} + coverage: none + tools: composer + + - uses: ramsey/composer-install@a8d0d959dab41457692a5e2041bd9b757a119e3f # 3.2.1 + + - run: composer stan