Skip to content

Standardize to PHP 8.2 and PSR-4 #217

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

Merged
merged 1 commit into from
Aug 9, 2025
Merged
Show file tree
Hide file tree
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
16 changes: 13 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jobs:
matrix:
php: [8.2, 8.3, 8.4]
symfony: ["5.4.*", "6.4.*", "6.4wApi", "7.3.*"]
env:
only_sf_latest: &only_sf_latest ${{ matrix.symfony == '7.3.*' }}

steps:
- name: Checkout code
Expand All @@ -17,7 +19,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2, phpstan
tools: composer:v2
extensions: ctype, iconv, intl, json, mbstring, pdo, pdo_sqlite
coverage: none

Expand Down Expand Up @@ -79,8 +81,16 @@ jobs:
composer update --prefer-dist --no-progress

- name: Run PHPStan (max)
if: ${{ matrix.symfony == '7.2.*' }}
run: phpstan analyse src --level=max --no-progress --error-format=github --memory-limit=1G
if: *only_sf_latest
run: composer phpstan

- name: Run PHP-CS-Fixer
if: *only_sf_latest
run: composer cs-check

- name: Run Composer Audit
if: *only_sf_latest
run: composer audit

- name: Validate Composer files
run: composer validate --strict
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.idea/
/vendor/
/composer.lock
/framework-tests
/framework-tests
/.php-cs-fixer.cache
14 changes: 11 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"codeception/module-asserts": "^3.0",
"codeception/module-doctrine": "^3.1",
"doctrine/orm": "^3.5",
"friendsofphp/php-cs-fixer": "^3.85",
"phpstan/phpstan": "^2.1",
"symfony/browser-kit": "^5.4 | ^6.4 | ^7.3",
"symfony/cache": "^5.4 | ^6.4 | ^7.3",
"symfony/config": "^5.4 | ^6.4 | ^7.3",
Expand Down Expand Up @@ -66,11 +68,17 @@
"symfony/web-profiler-bundle": "Tool that gives information about the execution of requests"
},
"autoload": {
"classmap": ["src/"]
"psr-4": {
"Codeception\\": "src/Codeception/"
}
},
"config": {
"classmap-authoritative": true,
"sort-packages": true
},
"minimum-stability": "RC"
"minimum-stability": "RC",
"scripts": {
"phpstan": "phpstan analyse src --level=max --memory-limit=1G",
"cs-check": "php-cs-fixer fix src --dry-run --diff --using-cache=no",
"cs-fix": "php-cs-fixer fix src --using-cache=no"
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A Codeception module for Symfony framework.
## Requirements

* `Symfony` `5.4.x`, `6.4.x`, `7.3.x` or higher, as per the [Symfony supported versions](https://symfony.com/releases).
* `PHP 8.1` or higher.
* `PHP 8.2` or higher.

## Installation

Expand Down
9 changes: 7 additions & 2 deletions src/Codeception/Module/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
use Symfony\Component\Mailer\DataCollector\MessageDataCollector;
use Symfony\Component\Translation\DataCollector\TranslationDataCollector;
use Symfony\Component\VarDumper\Cloner\Data;

use function array_keys;
use function array_map;
use function array_unique;
Expand All @@ -64,6 +65,7 @@
use function file_exists;
use function implode;
use function in_array;
use function extension_loaded;
use function ini_get;
use function ini_set;
use function is_object;
Expand Down Expand Up @@ -292,8 +294,7 @@ public function _getEntityManager(): EntityManagerInterface
$this->persistPermanentService($emService);
$container = $this->_getContainer();
foreach (
['doctrine', 'doctrine.orm.default_entity_manager', 'doctrine.dbal.default_connection']
as $service
['doctrine', 'doctrine.orm.default_entity_manager', 'doctrine.dbal.default_connection'] as $service
) {
if ($container->has($service)) {
$this->persistPermanentService($service);
Expand Down Expand Up @@ -495,6 +496,10 @@ protected function getInternalDomains(): array
*/
private function setXdebugMaxNestingLevel(int $max): void
{
if (!extension_loaded('xdebug')) {
return;
}

if ((int) ini_get('xdebug.max_nesting_level') < $max) {
ini_set('xdebug.max_nesting_level', (string) $max);
}
Expand Down
6 changes: 2 additions & 4 deletions src/Codeception/Module/Symfony/BrowserAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Symfony\Component\HttpFoundation\Test\Constraint\ResponseIsSuccessful;
use Symfony\Component\HttpFoundation\Test\Constraint\ResponseIsUnprocessable;
use Symfony\Component\HttpFoundation\Test\Constraint\ResponseStatusCodeSame;

use function sprintf;

trait BrowserAssertionsTrait
Expand Down Expand Up @@ -329,10 +330,7 @@ public function seePageRedirectsTo(string $page, string $redirectsTo): void
$client->followRedirects(false);
$this->amOnPage($page);

$this->assertTrue(
$client->getResponse()->isRedirection(),
'The response is not a redirection.'
);
$this->assertThatForResponse(new ResponseIsRedirected(), 'The response is not a redirection.');

$client->followRedirect();
$this->seeInCurrentUrl($redirectsTo);
Expand Down
14 changes: 7 additions & 7 deletions src/Codeception/Module/Symfony/ConsoleAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ private function configureOptions(array $parameters): array
$options['interactive'] = false;
}

if (in_array('-vvv', $parameters, true)
|| in_array('--verbose=3', $parameters, true)
if (in_array('-vvv', $parameters, true)
|| in_array('--verbose=3', $parameters, true)
|| (isset($parameters['--verbose']) && $parameters['--verbose'] === 3)
) {
$options['verbosity'] = OutputInterface::VERBOSITY_DEBUG;
} elseif (in_array('-vv', $parameters, true)
|| in_array('--verbose=2', $parameters, true)
} elseif (in_array('-vv', $parameters, true)
|| in_array('--verbose=2', $parameters, true)
|| (isset($parameters['--verbose']) && $parameters['--verbose'] === 2)
) {
$options['verbosity'] = OutputInterface::VERBOSITY_VERY_VERBOSE;
} elseif (in_array('-v', $parameters, true)
|| in_array('--verbose=1', $parameters, true)
|| in_array('--verbose', $parameters, true)
} elseif (in_array('-v', $parameters, true)
|| in_array('--verbose=1', $parameters, true)
|| in_array('--verbose', $parameters, true)
|| (isset($parameters['--verbose']) && $parameters['--verbose'] === 1)
) {
$options['verbosity'] = OutputInterface::VERBOSITY_VERBOSE;
Expand Down
6 changes: 4 additions & 2 deletions src/Codeception/Module/Symfony/DomCrawlerAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public function assertCheckboxNotChecked(string $fieldName, string $message = ''
$this->assertThatCrawler(
new LogicalNot(
new CrawlerSelectorExists("input[name=\"$fieldName\"]:checked")
), $message
),
$message
);
}

Expand All @@ -57,7 +58,8 @@ public function assertInputValueNotSame(string $fieldName, string $expectedValue
$this->assertThatCrawler(
new LogicalNot(
new CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'value', $expectedValue)
), $message
),
$message
);
}

Expand Down
1 change: 1 addition & 0 deletions src/Codeception/Module/Symfony/EventsAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PHPUnit\Framework\Assert;
use Symfony\Component\HttpKernel\DataCollector\EventDataCollector;

use function array_column;
use function array_merge;
use function count;
Expand Down
1 change: 1 addition & 0 deletions src/Codeception/Module/Symfony/FormAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Symfony\Component\Form\Extension\DataCollector\FormDataCollector;
use Symfony\Component\VarDumper\Cloner\Data;

use function is_array;
use function is_int;
use function is_string;
Expand Down
7 changes: 4 additions & 3 deletions src/Codeception/Module/Symfony/HttpClientAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Symfony\Component\HttpClient\DataCollector\HttpClientDataCollector;
use Symfony\Component\VarDumper\Cloner\Data;

use function array_change_key_case;
use function array_filter;
use function array_intersect_key;
Expand Down Expand Up @@ -56,10 +57,10 @@ function (array $trace) use ($expectedUrl, $expectedMethod, $expectedBody, $expe
$bodyMatches = $expectedBody === null || $expectedBody === $actualBody;

$headersMatch = $expectedHeaders === [] || (
is_array($headerValues = $this->extractValue($options['headers'] ?? []))
is_array($headerValues = $this->extractValue($options['headers'] ?? []))
&& ($normalizedExpected = array_change_key_case($expectedHeaders))
=== array_intersect_key(array_change_key_case($headerValues), $normalizedExpected)
);
);

return $bodyMatches && $headersMatch;
},
Expand Down Expand Up @@ -100,7 +101,7 @@ public function assertNotHttpClientRequest(
): void {
$matchingRequests = array_filter(
$this->getHttpClientTraces($httpClientId, __FUNCTION__),
fn(array $trace): bool => $this->matchesUrlAndMethod($trace, $unexpectedUrl, $unexpectedMethod)
fn (array $trace): bool => $this->matchesUrlAndMethod($trace, $unexpectedUrl, $unexpectedMethod)
);

$this->assertEmpty(
Expand Down
3 changes: 2 additions & 1 deletion src/Codeception/Module/Symfony/LoggerAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector;
use Symfony\Component\VarDumper\Cloner\Data;

use function sprintf;

trait LoggerAssertionsTrait
Expand Down Expand Up @@ -45,7 +46,7 @@ public function dontSeeDeprecations(string $message = ''): void
"Found %d deprecation message%s in the log:\n%s",
$count,
$count !== 1 ? 's' : '',
implode("\n", array_map(static fn(string $m): string => " - $m", $foundDeprecations)),
implode("\n", array_map(static fn (string $m): string => " - $m", $foundDeprecations)),
);
$this->assertEmpty($foundDeprecations, $errorMessage);
}
Expand Down
1 change: 1 addition & 0 deletions src/Codeception/Module/Symfony/SecurityAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;

use function sprintf;

trait SecurityAssertionsTrait
Expand Down
1 change: 1 addition & 0 deletions src/Codeception/Module/Symfony/SessionAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator;

use function class_exists;
use function in_array;
use function is_int;
Expand Down
1 change: 1 addition & 0 deletions src/Codeception/Module/Symfony/TimeAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Codeception\Module\Symfony;

use Symfony\Component\HttpKernel\DataCollector\TimeDataCollector;

use function round;
use function sprintf;

Expand Down
1 change: 1 addition & 0 deletions src/Codeception/Module/Symfony/TwigAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Codeception\Module\Symfony;

use Symfony\Bridge\Twig\DataCollector\TwigDataCollector;

use function array_key_first;

trait TwigAssertionsTrait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function getViolationsForSubject(object $subject, ?string $propertyPat
if ($constraint !== null) {
return (array)array_filter(
$violations,
static fn(ConstraintViolationInterface $violation): bool => get_class((object)$violation->getConstraint()) === $constraint &&
static fn (ConstraintViolationInterface $violation): bool => get_class((object)$violation->getConstraint()) === $constraint &&
($propertyPath === null || $violation->getPropertyPath() === $propertyPath)
);
}
Expand Down