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 7d75f23 commit c0c9ce2
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 281 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ 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: 6.3.*
- php: '8.2'
symfony-require: 7.0.*
stability: dev
- php: '8.3'
fail-fast: false

steps:
Expand Down
244 changes: 1 addition & 243 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,243 +1 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [3.7.0] - 2022-07-04

### Added

- Maintenance: added return types on methods, avoid deprecation trigger, make the bundle future-proof

### Fixed

- Name of the catalan translation file is now accurate #116
- Remove deprecation notice when using annotations

## [3.6.3] - 2022-06-14

### Added

- Add catalan translation

### Changed

- Deprecate `PhoneNumber::$errorNames` in favour of `PhoneNumber::ERROR_NAMES`.

### Fixed

- Deprecation notice on Symfony >= 6.1

## [3.6.2] - 2022-02-24

### Fixed

- Fix option format while using the validation constraint as attribute

## [3.6.1] - 2021-12-29

- Added return types

## [3.6.0] - 2021-12-07

- Added support for Symfony ^6.0
- Improve README documentation

## [3.5.0] - 2021-10-23

- Added support PHP8 attribute
- Drop support for PHP < 7.4
- Drop support for Symfony < 4.4

## [3.4.2] - 2021-06-28

### Added
- New twig template for Bootstrap 5
- Add `symfony/intl` as a required dependency

## [3.4.1] - 2021-04-12

### Added
- New twig template for Bootstrap 4

## [3.4.0] - 2021-04-06

### Added
- New twig filter `phone_number_format_out_of_country_calling_number`

## [3.3.3] - 2021-02-04

### Added
- Can now define a property path for the region on `PhoneNumber` constraint
- New option to specify default region for serialization
- New option to specify the format of the serialization

## [3.3.2] - 2021-01-22

### Changed
- Revert "Improve `PhoneNumber` constraint"

## [3.3.1] - 2021-01-22

### Changed
- Improve `PhoneNumber` constraint

## [3.3.0] - 2021-01-05

### Added
- Add PHP 8 support

### Changed
- Improve `PhoneNumberNormalizer`

## [3.2.1] - 2020-10-28

### Fixed
- Fix PhoneNumberValidator

## [3.2.0] - 2020-10-23

- Improve bundle configuration
- Can now define default region from config

## [3.1.1] - 2020-06-19

- Use replace keyword instead of conflict in composer.json

## [3.1.0] - 2020-04-27

### Added
- Add support of null values in phone number deserializer
- Add the ability to pass options down to country and number fields
- Refactor `PhoneNumber` constraints & validator to accept more than 1 type.
- Clarify LICENSE & add copyright back
- Update README
- Revamped folder

## [3.0.0] - 2019-11-26

### Removed
- Remove symfony/templating
- Remove deprecated DIC paremeters & aliases

## [2.0.2] - 2019-11-25

### Added
- Add Czech translations
- Add Turkish translations
- Add Ukrainian translations

## [2.0.1] - 2019-11-25

### Fixed
- Fix PhoneNumberBundle class

## [2.0.0] - 2019-11-25

### Added
- Add services only if relevant (optional) dependencies are available

### Changed
- Rename `tel_widget` to `phone_number_widget`

### Removed
- Drop support for Symfony < 3.4
- Drop support for PHP < 7.2
- Drop support for JMS Serializer
- Drop support for PHP templates


## [1.3.1] - 2018-01-17

### Changed
- Undo minor breaking change by reinstating and deprecating `se` code for Swedish translations.
- Validator uses `buildViolation` instead of `addViolation` for Symfony >= 2.5.

## [1.3.0] - 2018-01-15

### Added
- Symfony 4 support.
- Add `phone_number_of_type` Twig test and `isType` test to `PhoneNumberHelper`.
- Swedish translation improvements. Rename country code `se`->`sv`.
- Add `country_placeholder` option.
- Regard `"0"` as an invalid phone number.

### Changed
- Deprecate `PhoneNumberFormatHelper` in favour of `PhoneNumberHelper` and `PhoneNumberFormatExtension` in favour of `PhoneNumberHelperExtension`.

## [1.2.0] - 2016-01-17

### Added
- Add Symfony Serializer support.
- Confirm libphonenumber 8.0 compatibility.
- Avoid `choices_as_values` deprecation notice in Symfony 3.1.

### Changed
- Deprecate `phone_number_format` Twig function in favour of a filter.

## [1.1.3] - 2016-09-07

- Add basic Danish, Swedish and Finnish translations.

## [1.1.2] - 2016-03-31

### Added
- Allow the country choice form widget to not be required.
- Add difference between form type in Symfony 2 and 3 to the documentation.

## [1.1.1] - 2016-03-12

### Fixed
- Correct the block prefix for PhoneNumberType in Symfony 3.

## [1.1.0] - 2016-01-25

### Added
- Add translations for the validation constraint (BC break).
- Add validation of the phone number type.
- Throw an exception if Doctrine can't convert a database value to/from a `PhoneNumber`.
- Add country choice form widget.
- Add `libphonenumber.phone_number_offline_geocoder` service.
- Add `libphonenumber.short_number_info` service.
- Add `libphonenumber.phone_number_to_carrier_mapper` service.
- Add `libphonenumber.phone_number_to_time_zones_mapper` service.
- Deprecate `.class` parameters.

## [1.0.6] - 2015-01-22

- Confirm Symfony 3.0 compatibility.

## [1.0.5] - 2015-04-15

### Added
- Cater for Symfony's deprecation notices.
- Throw a `ConversionException` in the Doctrine type when the value is not a `PhoneNumber`.

## [1.0.4] - 2014-11-03

### Added
- Confirm libphonenumber 7.0 compatibility.

## [1.0.3] - 2014-10-20

### Added
- Handle international numbers correctly when using the national format and a default region.
- Throw a `TransformationFailedException` when required in the form data transformer.

## [1.0.2] - 2014-02-27

### Added
- Confirm libphonenumber 6.0 compatibility.

## [1.0.1] - 2014-01-30

### Changed
- Changed libphonenumber port to giggsey/libphonenumber-for-php.

## [1.0.0] - 2013-10-10

### Added
- Initial release.
See: https://github.com/odolbeau/phone-number-bundle/releases
21 changes: 9 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
"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"
},
"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/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/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 @@ -50,10 +50,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.6.x-dev"
"dev-master": "3.10.x-dev"
}
},
"conflict": {
"symfony/serializer": "6.0.0"
}
}
23 changes: 11 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="./vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="MisdPhoneNumberBundle Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="MisdPhoneNumberBundle Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
7 changes: 7 additions & 0 deletions src/Serializer/Normalizer/PhoneNumberNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,11 @@ public function supportsDenormalization($data, $type, $format = null, array $con
{
return 'libphonenumber\PhoneNumber' === $type && \is_string($data);
}

public function getSupportedTypes(?string $format): array
{
return [
PhoneNumber::class => true,
];
}
}
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
11 changes: 8 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,12 @@ 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
(new AnnotationLoader())->loadClassMetadata($classMetadata);
}

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

0 comments on commit c0c9ce2

Please sign in to comment.