From 4b58a0427027a72003be96d56b70d9ec6ccf965b Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Fri, 1 Mar 2024 12:01:05 -0500 Subject: [PATCH] Add testing against PHP 8.3 (#497) * Adding testing against PHP 8.3 * Upgrading Nette PHP Generator * README * Testing CI --- .github/workflows/tests.yml | 2 +- README.md | 2 +- composer.json | 2 +- .../console/generators/class-printer.php | 40 +++++++++++-------- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 16dbb9067..402e66d0c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,7 +17,7 @@ jobs: matrix: dependencies: ["lowest", "highest"] multisite: [true, false] - php: [8.1, 8.2] + php: [8.1, 8.2, 8.3] wordpress: ["latest"] uses: alleyinteractive/.github/.github/workflows/php-tests.yml@main name: "P${{ matrix.php }} - ${{ matrix.wordpress }} ${{ matrix.multisite && 'Multisite' || '' }} - ${{ matrix.dependencies }}" diff --git a/README.md b/README.md index 94136ec45..a5f240474 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Mantle Framework ---------------- -![Unit Tests](https://github.com/alleyinteractive/mantle-framework/workflows/Unit%20Tests/badge.svg) +[![Testing Suite](https://github.com/alleyinteractive/mantle-framework/actions/workflows/tests.yml/badge.svg)](https://github.com/alleyinteractive/mantle-framework/actions/workflows/tests.yml) Mantle is a framework for building large, robust websites and applications with WordPress. Mantle extends WordPress Core and acts as a layer between WordPress and your custom code, aimed at helping you write more structured, testable, DRY, clean code, and doing so more quickly. diff --git a/composer.json b/composer.json index e08641419..651a34ac4 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "league/flysystem-cached-adapter": "^1.1", "monolog/monolog": "^2.9.1", "nesbot/carbon": "^2.68.1", - "nette/php-generator": "^3.6.9", + "nette/php-generator": "^4.1", "nunomaduro/collision": "^6.0 || ^7.0", "nunomaduro/termwind": "^1.15.1", "psr/container": "^1.1.1 || ^2.0.2", diff --git a/src/mantle/framework/console/generators/class-printer.php b/src/mantle/framework/console/generators/class-printer.php index 7af2c1dcf..82858aab7 100644 --- a/src/mantle/framework/console/generators/class-printer.php +++ b/src/mantle/framework/console/generators/class-printer.php @@ -3,6 +3,7 @@ * Printer class file. * * phpcs:disable Squiz.Commenting.FunctionComment.MissingParamTag + * phpcs:disable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase * * @package Mantle */ @@ -10,10 +11,15 @@ namespace Mantle\Framework\Console\Generators; use Nette\PhpGenerator\ClassType; +use Nette\PhpGenerator\EnumType; use Nette\PhpGenerator\GlobalFunction; +use Nette\PhpGenerator\InterfaceType; use Nette\PhpGenerator\Method; use Nette\PhpGenerator\PhpFile; use Nette\PhpGenerator\PhpNamespace; +use Nette\PhpGenerator\TraitType; + +use function Mantle\Support\Helpers\str; /** * Generates PHP code compatible with WordPress coding standards. @@ -25,19 +31,21 @@ class Printer extends \Nette\PhpGenerator\Printer { * @inheritDoc */ public function printFile( PhpFile $file ): string { - return str_replace( - [ - "rtrim( PHP_EOL )->append( PHP_EOL ); } /** @@ -45,7 +53,7 @@ public function printFile( PhpFile $file ): string { * * @inheritDoc */ - public function printClass( ClassType $class, PhpNamespace $namespace = null ): string { + public function printClass( ClassType|InterfaceType|TraitType|EnumType $class, PhpNamespace $namespace = null ): string { return trim( str_replace( "\n{\n", @@ -60,9 +68,9 @@ public function printClass( ClassType $class, PhpNamespace $namespace = null ): * * @inheritDoc */ - public function printMethod( Method $method, PhpNamespace $namespace = null ): string { + public function printMethod( Method $method, PhpNamespace $namespace = null, bool $isInterface = false ): string { $abstract = $method->isAbstract(); - $method = parent::printMethod( $method, $namespace ); + $method = parent::printMethod( $method, $namespace, $isInterface ); $lines = explode( "\n", $method ); foreach ( $lines as $i => $line ) {