Skip to content

Commit

Permalink
Bump minimum requirements & supports SF 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
odolbeau committed Nov 29, 2023
1 parent d08880d commit 85f6393
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: PHPStan
uses: docker://jakzal/phpqa:php8.0
uses: docker://jakzal/phpqa:php8.2
with:
args: phpstan analyze --no-progress

Expand All @@ -17,6 +17,6 @@ jobs:
steps:
- uses: actions/checkout@master
- name: PHP-CS-Fixer
uses: docker://jakzal/phpqa:php8.0
uses: docker://jakzal/phpqa:php8.2
with:
args: php-cs-fixer fix --config=.php_cs.dist.php --dry-run --diff
19 changes: 11 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: PHPUnit

on:
push:
pull_request:

jobs:
Expand All @@ -13,14 +12,18 @@ jobs:
strategy:
matrix:
include:
- php: '7.4'
symfony-require: 4.4.*
- php: '8.0'
symfony-require: 5.3.*
- php: '8.0'
symfony-require: 6.0.*
stability: dev
- php: '8.1'
symfony-require: 5.4.*
- php: '8.1'
symfony-require: 6.3.*
- php: '8.2'
symfony-require: 7.0.*
- php: '8.2'
symfony-require: 7.0.*
stability: dev
continue-on-error: true
- php: '8.3'
continue-on-error: true
fail-fast: false

steps:
Expand Down
23 changes: 10 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
"sort-packages": true
},
"require": {
"php": ">=7.4",
"php": ">=8.1",
"giggsey/libphonenumber-for-php": "^8.0",
"symfony/framework-bundle": "^4.4|^5.3|^6.0",
"symfony/intl": "^4.4|^5.3|^6.0",
"symfony/framework-bundle": "^5.4|^6.3|^7.0",
"symfony/intl": "^5.4|^6.3|^7.0",
"symfony/polyfill-mbstring": "^1.28"
},
"require-dev": {
"doctrine/doctrine-bundle": "^1.12|^2.0",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5",
"symfony/form": "^4.4|^5.3|^6.0",
"symfony/phpunit-bridge": "^6.2",
"symfony/property-access": "^4.4|^5.3|^6.0",
"symfony/serializer": "^4.4|^5.3|^6.0.1",
"symfony/twig-bundle": "^4.4|^5.3|^6.0",
"symfony/validator": "^4.4|^5.3|^6.0"
"symfony/form": "^5.4|^6.3|^7.0",
"symfony/phpunit-bridge": "^7.0",
"symfony/property-access": "^5.4|^6.3|^7.0",
"symfony/serializer": "^5.4|^6.3|^7.0",
"symfony/twig-bundle": "^5.4|^6.3|^7.0",
"symfony/validator": "^5.4|^6.3|^7.0"
},
"suggest": {
"doctrine/doctrine-bundle": "Add a DBAL mapping type",
Expand All @@ -52,10 +52,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.6.x-dev"
"dev-master": "3.10.x-dev"
}
},
"conflict": {
"symfony/serializer": "6.0.0"
}
}
5 changes: 0 additions & 5 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,3 @@ parameters:
- src
- tests
inferPrivatePropertyTypeFromConstructor: true
ignoreErrors:
-
message: "#^Attribute class Symfony\\\\Component\\\\Validator\\\\Attribute\\\\HasNamedArguments does not exist\\.$#"
count: 1
path: src/Validator/Constraints/PhoneNumber.php
1 change: 0 additions & 1 deletion src/Validator/Constraints/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* Phone number constraint.
*
* @Annotation
*
* @NamedArgumentConstructor
*/
#[\Attribute(\Attribute::TARGET_PROPERTY)]
Expand Down
5 changes: 1 addition & 4 deletions tests/Form/Type/PhoneNumberTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
*/
class PhoneNumberTypeTest extends TestCase
{
/**
* @var FormFactoryInterface
*/
protected $factory;
protected FormFactoryInterface $factory;

protected function setUp(): void
{
Expand Down
8 changes: 4 additions & 4 deletions tests/Validator/Constraints/PhoneNumberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public function testProperties()
{
$phoneNumber = new PhoneNumber();

$this->assertObjectHasAttribute('message', $phoneNumber);
$this->assertObjectHasAttribute('type', $phoneNumber);
$this->assertObjectHasAttribute('defaultRegion', $phoneNumber);
$this->assertObjectHasAttribute('regionPath', $phoneNumber);
$this->assertObjectHasProperty('message', $phoneNumber);
$this->assertObjectHasProperty('type', $phoneNumber);
$this->assertObjectHasProperty('defaultRegion', $phoneNumber);
$this->assertObjectHasProperty('regionPath', $phoneNumber);
}

/**
Expand Down
12 changes: 9 additions & 3 deletions tests/Validator/Constraints/PhoneNumberValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
use Symfony\Component\Validator\Mapping\Loader\AttributeLoader;
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;

/**
Expand Down Expand Up @@ -68,8 +69,7 @@ public function testValidate($value, $violates, $type = null, $defaultRegion = n
->with($this->isType('string'))
->willReturn($constraintViolationBuilder);
$constraintViolationBuilder
->method('addViolation')
->willReturn($constraintViolationBuilder);
->method('addViolation');

$this->context
->expects($this->once())
Expand All @@ -89,7 +89,13 @@ public function testValidate($value, $violates, $type = null, $defaultRegion = n
public function testValidateFromAttribute()
{
$classMetadata = new ClassMetadata(PhoneNumberDummy::class);
(new AnnotationLoader())->loadClassMetadata($classMetadata);
if (class_exists(AttributeLoader::class)) {
(new AttributeLoader())->loadClassMetadata($classMetadata);
} else {
// AnnotationLoader have been removed in favor of AttributeLoader in 7.0
/* @phpstan-ignore-next-line */
(new AnnotationLoader())->loadClassMetadata($classMetadata);
}

[$constraint1] = $classMetadata->properties['phoneNumber1']->constraints;
[$constraint2] = $classMetadata->properties['phoneNumber2']->constraints;
Expand Down

0 comments on commit 85f6393

Please sign in to comment.