Skip to content

Commit

Permalink
Add testing against PHP 8.3 (#497)
Browse files Browse the repository at this point in the history
* Adding testing against PHP 8.3

* Upgrading Nette PHP Generator

* README

* Testing CI
  • Loading branch information
srtfisher committed Mar 1, 2024
1 parent 7b6acc2 commit 4b58a04
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
40 changes: 24 additions & 16 deletions src/mantle/framework/console/generators/class-printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
* Printer class file.
*
* phpcs:disable Squiz.Commenting.FunctionComment.MissingParamTag
* phpcs:disable WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
*
* @package Mantle
*/

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.
Expand All @@ -25,27 +31,29 @@ class Printer extends \Nette\PhpGenerator\Printer {
* @inheritDoc
*/
public function printFile( PhpFile $file ): string {
return str_replace(
[
"<?php\n\n",
'( ) {',
'( ):',
],
[
"<?php\n",
'() {',
'():',
],
parent::printFile( $file ),
);
return str(
str_replace(
[
"<?php\n\n",
'( ) {',
'( ):',
],
[
"<?php\n",
'() {',
'():',
],
parent::printFile( $file ),
)
)->rtrim( PHP_EOL )->append( PHP_EOL );
}

/**
* Print the class.
*
* @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",
Expand All @@ -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 ) {
Expand Down

0 comments on commit 4b58a04

Please sign in to comment.