Skip to content
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
9 changes: 3 additions & 6 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ jobs:
- '8.5'
symfony-version:
- '6.4.*'
- '7.3.*'
- '7.4.*@dev'
- '7.4.*'
include:
- php-version: '8.4'
symfony-version: '8.0.*@dev'
continue-on-error: true
symfony-version: '8.0.*'
- php-version: '8.5'
symfony-version: '8.0.*@dev'
continue-on-error: true
symfony-version: '8.0.*'

steps:
- name: Checkout code
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG-5.x.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
5.6.1
-----

* Fix deprecations

5.6.0
-----

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"twig/twig": "^3.0"
},
"require-dev": {
"doctrine/data-fixtures": "^1.6",
"doctrine/persistence": "^3.2",
"doctrine/data-fixtures": "^1.6 || ^2.2",
"doctrine/persistence": "^3.2 || ^4.0",
"easycorp/easyadmin-bundle": "^4.8.5",
"endroid/qr-code": "^4.8 || ^5.0 || ^6.0",
"fakerphp/faker": "^1.23",
Expand All @@ -52,7 +52,7 @@
"phpstan/phpstan-deprecation-rules": "^2.0.3",
"phpunit/phpunit": "^11.5.35",
"symfony/browser-kit": "^6.4 || ^7.0 || ^8.0",
"symplify/easy-coding-standard": "^12.5.24"
"symplify/easy-coding-standard": "^13.0.0"
},
"config": {
"sort-packages": true
Expand Down
82 changes: 50 additions & 32 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,157 +1,175 @@
parameters:
ignoreErrors:
-
message: '#^Property Leapt\\CoreBundle\\Datalist\\Datalist\:\:\$iterator \(Iterator\) does not accept Traversable\<mixed, mixed\>\.$#'
rawMessage: 'Property Leapt\CoreBundle\Datalist\Datalist::$initialized (bool) is never assigned true so the property type can be changed to false.'
identifier: property.tooWideBool
count: 1
path: src/Datalist/Datalist.php

-
rawMessage: 'Property Leapt\CoreBundle\Datalist\Datalist::$iterator (Iterator) does not accept Traversable<mixed, mixed>.'
identifier: assign.propertyType
count: 1
path: src/Datalist/Datalist.php

-
message: '#^Parameter \#1 \$value of function count expects array\|Countable, Iterator given\.$#'
rawMessage: 'Parameter #1 $value of function count expects array|Countable, Iterator given.'
identifier: argument.type
count: 1
path: src/Datalist/Datasource/AbstractDatasource.php

-
message: '#^Method Leapt\\CoreBundle\\Datalist\\Field\\DatalistField\:\:getType\(\) should return Leapt\\CoreBundle\\Datalist\\Field\\Type\\FieldTypeInterface but returns Leapt\\CoreBundle\\Datalist\\TypeInterface\.$#'
rawMessage: 'Method Leapt\CoreBundle\Datalist\Field\DatalistField::getType() should return Leapt\CoreBundle\Datalist\Field\Type\FieldTypeInterface but returns Leapt\CoreBundle\Datalist\TypeInterface.'
identifier: return.type
count: 1
path: src/Datalist/Field/DatalistField.php

-
message: '#^Method Leapt\\CoreBundle\\Datalist\\Filter\\DatalistFilter\:\:getType\(\) should return Leapt\\CoreBundle\\Datalist\\Filter\\Type\\FilterTypeInterface but returns Leapt\\CoreBundle\\Datalist\\TypeInterface\.$#'
rawMessage: 'Method Leapt\CoreBundle\Datalist\Filter\DatalistFilter::getType() should return Leapt\CoreBundle\Datalist\Filter\Type\FilterTypeInterface but returns Leapt\CoreBundle\Datalist\TypeInterface.'
identifier: return.type
count: 1
path: src/Datalist/Filter/DatalistFilter.php

-
message: '#^Method Leapt\\CoreBundle\\Paginator\\DoctrineORMPaginator\:\:getIterator\(\) should return ArrayIterator but returns Traversable\<\(int\|string\), mixed\>\.$#'
rawMessage: 'Method Leapt\CoreBundle\Paginator\DoctrineORMPaginator::getIterator() should return ArrayIterator but returns Traversable<(int|string), mixed>.'
identifier: return.type
count: 1
path: src/Paginator/DoctrineORMPaginator.php

-
message: '#^Call to method getParent\(\) of internal class Twig\\Template from outside its root namespace Twig\.$#'
rawMessage: 'Call to method getParent() of internal class Twig\Template from outside its root namespace Twig.'
identifier: method.internalClass
count: 1
path: src/Twig/Extension/DatalistExtension.php

-
message: '#^Call to method hasBlock\(\) of internal class Twig\\Template from outside its root namespace Twig\.$#'
rawMessage: 'Call to method hasBlock() of internal class Twig\Template from outside its root namespace Twig.'
identifier: method.internalClass
count: 1
path: src/Twig/Extension/DatalistExtension.php

-
message: '#^Call to method renderBlock\(\) of internal class Twig\\Template from outside its root namespace Twig\.$#'
rawMessage: 'Call to method renderBlock() of internal class Twig\Template from outside its root namespace Twig.'
identifier: method.internalClass
count: 1
path: src/Twig/Extension/DatalistExtension.php

-
message: '#^Instanceof references internal class Twig\\Template\.$#'
rawMessage: Instanceof references internal class Twig\Template.
identifier: instanceof.internalClass
count: 1
path: src/Twig/Extension/DatalistExtension.php

-
message: '#^Call to method getParent\(\) of internal class Twig\\Template from outside its root namespace Twig\.$#'
rawMessage: 'Call to method getParent() of internal class Twig\Template from outside its root namespace Twig.'
identifier: method.internalClass
count: 1
path: src/Twig/Extension/PaginatorExtension.php

-
message: '#^Call to method hasBlock\(\) of internal class Twig\\Template from outside its root namespace Twig\.$#'
rawMessage: 'Call to method hasBlock() of internal class Twig\Template from outside its root namespace Twig.'
identifier: method.internalClass
count: 1
path: src/Twig/Extension/PaginatorExtension.php

-
message: '#^Call to method renderBlock\(\) of internal class Twig\\Template from outside its root namespace Twig\.$#'
rawMessage: 'Call to method renderBlock() of internal class Twig\Template from outside its root namespace Twig.'
identifier: method.internalClass
count: 1
path: src/Twig/Extension/PaginatorExtension.php

-
message: '#^Instanceof references internal class Twig\\Template\.$#'
rawMessage: Instanceof references internal class Twig\Template.
identifier: instanceof.internalClass
count: 1
path: src/Twig/Extension/PaginatorExtension.php

-
message: '#^Call to function method_exists\(\) with ''Endroid\\\\QrCode\\\\Builder\\\\Builder'' and ''create'' will always evaluate to false\.$#'
rawMessage: 'Call to function method_exists() with ''Endroid\\QrCode\\Builder\\Builder'' and ''create'' will always evaluate to false.'
identifier: function.impossibleType
count: 1
path: src/Twig/Extension/QrCodeExtension.php

-
message: '''
#^Call to deprecated method getExpressionParser\(\) of class Twig\\Parser\:
since Twig 3\.21$#
rawMessage: '''
Call to deprecated method getExpressionParser() of class Twig\Parser:
since Twig 3.21
'''
identifier: method.deprecated
count: 3
path: src/Twig/TokenParser/DatalistThemeTokenParser.php

-
message: '#^Call to function method_exists\(\) with Twig\\Parser and ''parseExpression'' will always evaluate to true\.$#'
rawMessage: 'Call to function method_exists() with Twig\Parser and ''parseExpression'' will always evaluate to true.'
identifier: function.alreadyNarrowedType
count: 3
path: src/Twig/TokenParser/DatalistThemeTokenParser.php

-
message: '''
#^Call to method parseExpression\(\) of deprecated class Twig\\ExpressionParser\:
since Twig 3\.21$#
rawMessage: '''
Call to method parseExpression() of deprecated class Twig\ExpressionParser:
since Twig 3.21
'''
identifier: method.deprecatedClass
count: 3
path: src/Twig/TokenParser/DatalistThemeTokenParser.php

-
message: '''
#^Call to deprecated method getExpressionParser\(\) of class Twig\\Parser\:
since Twig 3\.21$#
rawMessage: '''
Call to deprecated method getExpressionParser() of class Twig\Parser:
since Twig 3.21
'''
identifier: method.deprecated
count: 3
path: src/Twig/TokenParser/PaginatorThemeTokenParser.php

-
message: '#^Call to function method_exists\(\) with Twig\\Parser and ''parseExpression'' will always evaluate to true\.$#'
rawMessage: 'Call to function method_exists() with Twig\Parser and ''parseExpression'' will always evaluate to true.'
identifier: function.alreadyNarrowedType
count: 3
path: src/Twig/TokenParser/PaginatorThemeTokenParser.php

-
message: '''
#^Call to method parseExpression\(\) of deprecated class Twig\\ExpressionParser\:
since Twig 3\.21$#
rawMessage: '''
Call to method parseExpression() of deprecated class Twig\ExpressionParser:
since Twig 3.21
'''
identifier: method.deprecatedClass
count: 3
path: src/Twig/TokenParser/PaginatorThemeTokenParser.php

-
message: '#^Method Leapt\\CoreBundle\\Tests\\LeaptCoreTestingKernel\:\:configureContainer\(\) is unused\.$#'
rawMessage: 'Method Symfony\Component\Validator\Constraints\Regex::__construct() invoked with 8 parameters, 1-7 required.'
identifier: arguments.count
count: 1
path: src/Validator/Constraints/Slug.php

-
rawMessage: 'Method Leapt\CoreBundle\Tests\LeaptCoreTestingKernel::configureContainer() is unused.'
identifier: method.unused
count: 1
path: tests/LeaptCoreTestingKernel.php

-
rawMessage: 'Method Leapt\CoreBundle\Tests\LeaptCoreTestingKernel::configureRoutes() is unused.'
identifier: method.unused
count: 1
path: tests/LeaptCoreTestingKernel.php

-
message: '#^Method Leapt\\CoreBundle\\Tests\\LeaptCoreTestingKernel\:\:configureRoutes\(\) is unused\.$#'
rawMessage: 'Method Leapt\CoreBundle\Tests\LeaptCoreTestingKernel::getConfigDir() is unused.'
identifier: method.unused
count: 1
path: tests/LeaptCoreTestingKernel.php

-
message: '#^Property Leapt\\CoreBundle\\Tests\\Listener\\Fixtures\\Entity\\User\:\:\$id is never written, only read\.$#'
rawMessage: 'Property Leapt\CoreBundle\Tests\Listener\Fixtures\Entity\User::$id is never written, only read.'
identifier: property.onlyRead
count: 1
path: tests/Listener/Fixtures/Entity/User.php

-
message: '#^Property Leapt\\CoreBundle\\Tests\\Paginator\\Entity\\Player\:\:\$id is never written, only read\.$#'
rawMessage: 'Property Leapt\CoreBundle\Tests\Paginator\Entity\Player::$id is never written, only read.'
identifier: property.onlyRead
count: 1
path: tests/Paginator/Entity/Player.php
3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="tests/bootstrap.php"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnPhpunitDeprecations="true"
displayDetailsOnAllIssues="true"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
>
<php>
Expand Down
1 change: 0 additions & 1 deletion src/Listener/FileSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ private function checkClassConfig($entity, EntityManagerInterface $entityManager
}
$attributes = $this->getAttributes($property);
foreach ($attributes as $attribute) {
$property->setAccessible(true);
$field = $property->getName();

if (null === $attribute->mappedBy) {
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Constraints/RecaptchaValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function validate(mixed $value, Constraint $constraint): void
// define variable for recaptcha check answer
$mainRequest = $this->requestStack->getMainRequest();
$remoteIp = $mainRequest->getClientIp();
$answer = $mainRequest->get('g-recaptcha-response');
$answer = $mainRequest->request->get('g-recaptcha-response');

// Verify user response with Google
$response = $this->checkAnswer($this->privateKey, $remoteIp, $answer);
Expand Down
9 changes: 7 additions & 2 deletions src/Validator/Constraints/Slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ public function __construct(
?callable $normalizer = null,
?array $groups = null,
mixed $payload = null,
array $options = [],
?array $options = null,
) {
parent::__construct($pattern, $message, $htmlPattern, $match, $normalizer, $groups, $payload, $options);
if (null !== $options) {
trigger_deprecation('leapt/core-bundle', '5.6.1', 'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.', static::class);
parent::__construct($pattern, $message, $htmlPattern, $match, $normalizer, $groups, $payload, $options);
} else {
parent::__construct($pattern, $message, $htmlPattern, $match, $normalizer, $groups, $payload);
}
}

public function getRequiredOptions(): array
Expand Down
2 changes: 1 addition & 1 deletion templates/Feed/index.atom.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ feed.title }}</title>
<link rel="alternate" href="{{ feed.link }}"/>
<link rel="self" href="{{ url('leapt_core_feed', {'feedName': feedName, '_format': app.request.get('_format')}) }}"/>
<link rel="self" href="{{ url('leapt_core_feed', {'feedName': feedName, '_format': app.request.query.get('_format')}) }}"/>
<updated>{{ feed.updatedAt|date(constant('DATE_ATOM')) }}</updated>
<id>{{ feed.id }}</id>
{% for item in items %}
Expand Down
5 changes: 5 additions & 0 deletions tests/LeaptCoreTestingKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ private function configureRoutes(RoutingConfigurator $routes): void
->prefix('/feed');
$routes->import(__DIR__ . '/../config/routing_sitemap.php');
}

private function getConfigDir(): string
{
return __DIR__ . '/../var/config';
}
}
6 changes: 5 additions & 1 deletion tests/Listener/FileSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ private function buildEntityManager(): EntityManagerInterface
{
$config = ORMSetup::createConfiguration(true, sys_get_temp_dir());
$config->setMetadataDriverImpl(new AttributeDriver([__DIR__ . '/Fixtures']));
$config->setAutoGenerateProxyClasses(true);
if (\PHP_VERSION_ID < 80400) {
$config->setAutoGenerateProxyClasses(true);
} else {
$config->enableNativeLazyObjects(true);
}

$params = [
'driver' => 'pdo_sqlite',
Expand Down
6 changes: 5 additions & 1 deletion tests/Paginator/DoctrineORMPaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ public static function setUpBeforeClass(): void
$proxiesIdentifier = uniqid('Proxies', true);
$config->setProxyDir(sys_get_temp_dir() . '/' . $proxiesIdentifier);
$config->setProxyNamespace('MyProject\Proxies\\' . $proxiesIdentifier);
$config->setAutoGenerateProxyClasses(true);
if (\PHP_VERSION_ID < 80400) {
$config->setAutoGenerateProxyClasses(true);
} else {
$config->enableNativeLazyObjects(true);
}

$em = new EntityManager(DriverManager::getConnection($dbParams), $config);

Expand Down
27 changes: 12 additions & 15 deletions tests/Validator/PasswordStrengthValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testEmptyStringIsValid(): void
#[DataProvider('getValidPasswords')]
public function testValidPassword(string $password): void
{
$this->validator->validate($password, new PasswordStrength(['score' => 50, 'min' => 5, 'max' => 255]));
$this->validator->validate($password, new PasswordStrength(min: 5, max: 255, score: 50));
$this->assertNoViolation();
}

Expand All @@ -48,10 +48,7 @@ public static function getValidPasswords(): iterable
#[DataProvider('getInvalidPasswords')]
public function testInvalidPasswords(string $password): void
{
$constraint = new PasswordStrength([
'scoreMessage' => 'scoreMessage',
'score' => 50,
]);
$constraint = new PasswordStrength(score: 50, scoreMessage: 'scoreMessage');

$this->validator->validate($password, $constraint);

Expand All @@ -68,11 +65,11 @@ public static function getInvalidPasswords(): iterable

public function testMinPasswords(): void
{
$constraint = new PasswordStrength([
'minMessage' => 'minMessage',
'score' => 50,
'min' => 5,
]);
$constraint = new PasswordStrength(
min: 5,
minMessage: 'minMessage',
score: 50,
);
$this->validator->validate('abc', $constraint);

$this->buildViolation('minMessage')
Expand All @@ -82,11 +79,11 @@ public function testMinPasswords(): void

public function testMaxPasswords(): void
{
$constraint = new PasswordStrength([
'maxMessage' => 'maxMessage',
'score' => 50,
'max' => 5,
]);
$constraint = new PasswordStrength(
max: 5,
maxMessage: 'maxMessage',
score: 50,
);
$this->validator->validate('abcdefgh', $constraint);

$this->buildViolation('maxMessage')
Expand Down