Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for PHP 8.4, Upgrade to Laminas Coding Standard 3.0 and Fix Compatibility with Symfony Console 7.1 #131

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow php 8.4 + composer bump --dev-only + laminas/laminas-coding-sta…
…ndard:^3

Signed-off-by: fezfez <[email protected]>
fezfez committed Nov 21, 2024
commit a2940f6574a77947fdd2159b9dd16b5ba690b612
2 changes: 1 addition & 1 deletion .laminas-ci.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ignore_php_platform_requirements": {
"8.3": true
"8.4": true
}
}
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -27,21 +27,21 @@
}
},
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"composer-runtime-api": "^2.0.0",
"psr/container": "^1.0 || ^2.0",
"symfony/console": "^6.0 || ^7.0",
"symfony/event-dispatcher": "^6.0 || ^7.0",
"webmozart/assert": "^1.10"
},
"require-dev": {
"laminas/laminas-coding-standard": "~2.5.0",
"laminas/laminas-mvc": "^3.7.0",
"laminas/laminas-servicemanager": "^3.22.1",
"laminas/laminas-coding-standard": "^3.0.1",
"laminas/laminas-mvc": "^3.8.0",
"laminas/laminas-servicemanager": "^3.23.0",
"mikey179/vfsstream": "2.0.x-dev",
"phpunit/phpunit": "^10.5.5",
"phpunit/phpunit": "^10.5.38",
"psalm/plugin-phpunit": "^0.19.0",
"vimeo/psalm": "^5.18"
"vimeo/psalm": "^5.26.1"
},
"autoload": {
"psr-4": {
@@ -68,5 +68,8 @@
"static-analysis": "psalm --shepherd --stats",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml"
},
"conflict": {
"amphp/amp":"<2.6.4"
}
}
1,095 changes: 583 additions & 512 deletions composer.lock

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.0.0@4e177bf0c9f03c17d2fbfd83b7cc9c47605274d8">
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<file src="src/Input/ChoiceParam.php">
<PossiblyInvalidArgument>
<code><![CDATA[$defaultValue]]></code>
</PossiblyInvalidArgument>
</file>
</files>
4 changes: 2 additions & 2 deletions src/Input/AbstractParamAwareInput.php
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ final public function getParam(string $name)
$value = $this->askQuestion($question, $valueIsArray, $inputParam->isRequired());

// Reset the validator if we prepended it earlier.
if ($originalValidator) {
if ($originalValidator !== null) {
$question->setValidator($originalValidator);
}

@@ -211,7 +211,7 @@ private function validateValue(
string $paramName
): void {
// No validator: nothing to do
if (! $validator) {
if ($validator === null) {
return;
}

4 changes: 2 additions & 2 deletions src/Input/StringParam.php
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
use function restore_error_handler;
use function set_error_handler;
use function sprintf;
use function strstr;
use function str_contains;

use const E_WARNING;

@@ -70,7 +70,7 @@ private function validatePattern(string $pattern): bool
{
// phpcs:ignore WebimpressCodingStandard.NamingConventions.ValidVariableName.NotCamelCaps
set_error_handler(static function (int $_, string $errstr): bool {
if (! strstr($errstr, 'preg_match')) {
if (! str_contains($errstr, 'preg_match')) {
return false;
}

12 changes: 10 additions & 2 deletions src/Listener/TerminateListener.php
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\StreamableInputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Webmozart\Assert\Assert;

@@ -117,8 +118,15 @@ public function __invoke(ConsoleTerminateEvent $event): void

$inputMapper = $this->createInputMapper($inputMapperSpec, $nextCommandClass);

$params = ['command' => $nextCommandName] + $inputMapper($input);
$exitCode = $application->run(new ArrayInput($params), $output);
$params = ['command' => $nextCommandName] + $inputMapper($input);
$inputForNextCommand = new ArrayInput($params);
if ($input instanceof StreamableInputInterface) {
$stream = $input->getStream();
if ($stream !== null) {
$inputForNextCommand->setStream($stream);
}
}
$exitCode = $application->run($inputForNextCommand, $output);
/** @psalm-suppress TypeDoesNotContainType */
if (! is_int($exitCode)) {
$exitCode = 0;
5 changes: 4 additions & 1 deletion test/ApplicationTest.php
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@

use function array_filter;
use function current;
use function is_int;

/** @psalm-suppress PropertyNotSetInConstructor */
class ApplicationTest extends TestCase
@@ -270,7 +271,9 @@ public function testChainCommand(
]
);

self::assertSame(current(array_filter($exitCodes)) ?: 0, $statusCode);
$currentExitCode = current(array_filter($exitCodes));

self::assertSame(is_int($currentExitCode) ? $currentExitCode : 0, $statusCode);
$display = $applicationTester->getDisplay();
foreach ($contains as $str) {
self::assertStringContainsString($str, $display, 'Output does not contain ' . $str . "\n" . $display);
12 changes: 6 additions & 6 deletions test/ContainerResolverTest.php
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ final class ContainerResolverTest extends TestCase
{
public function testWillLoadContainerFromInputOption(): void
{
$containerFileContents = <<<EOT
$containerFileContents = <<<'EOT'
<?php return new \Laminas\ServiceManager\ServiceManager();
EOT;

@@ -67,10 +67,10 @@ public function testWillLoadContainerFromApplicationConfig(): void

public function testWillLoadContainerFromMezzioContainerPath(): void
{
$containerFileContents = <<<EOT
<?php \$container = new \Laminas\ServiceManager\ServiceManager();
\$container->setService('foo', 'bar');
return \$container;
$containerFileContents = <<<'EOT'
<?php $container = new \Laminas\ServiceManager\ServiceManager();
$container->setService('foo', 'bar');
return $container;
EOT;

$directory = vfsStream::setup('root', null, [
@@ -91,7 +91,7 @@ public function testWillLoadContainerFromMezzioContainerPath(): void

public function testCanHandleAbsolutePathForContainerOption(): void
{
$containerFileContents = <<<EOT
$containerFileContents = <<<'EOT'
<?php return new \Laminas\ServiceManager\ServiceManager();
EOT;