diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index da6179a..284d3af 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [master] + branches: [main] pull_request: - branches: [master] + branches: [main] jobs: @@ -16,16 +16,18 @@ jobs: fail-fast: false matrix: operating-system: [ ubuntu-latest, windows-latest ] - php: [ '7.4', '8.0', '8.1' ] - symfony: [ '4.4.*', '5.4.*', '6.0.*', '6.1.*' ] + php: [ '7.4', '8.0', '8.1', '8.2' ] + symfony: [ '4.4.*', '5.4.*', '6.4.*', '7.0.*' ] exclude: - - { php: '7.4', symfony: '6.0.*' } - - { php: '7.4', symfony: '6.1.*' } - - { php: '8.0', symfony: '6.1.*' } + - { php: '7.4', symfony: '6.4.*' } + - { php: '8.0', symfony: '6.4.*' } + - { php: '7.4', symfony: '7.0.*' } + - { php: '8.0', symfony: '7.0.*' } + - { php: '8.1', symfony: '7.0.*' } steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP ${{ matrix.php }} uses: shivammathur/setup-php@v2 @@ -35,7 +37,7 @@ jobs: coverage: none - name: Install composer dependencies - uses: ramsey/composer-install@v2 + uses: ramsey/composer-install@v3 env: SYMFONY_REQUIRE: ${{ matrix.symfony }} @@ -46,14 +48,14 @@ jobs: name: Easy Coding Standard runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: ramsey/composer-install@v2 + - uses: actions/checkout@v4 + - uses: ramsey/composer-install@v3 - run: vendor/bin/ecs phpstan: name: PHPStan runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: ramsey/composer-install@v2 + - uses: actions/checkout@v4 + - uses: ramsey/composer-install@v3 - run: vendor/bin/phpstan diff --git a/composer.json b/composer.json index 242482f..0329d97 100644 --- a/composer.json +++ b/composer.json @@ -11,16 +11,16 @@ "require": { "php": ">=7.4", "moneyphp/money": "^3.3 || ^4.0", - "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0" + "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0" }, "require-dev": { "doctrine/doctrine-bundle": "^1.0 || ^2.0", "phpstan/phpstan": "^1.8", "phpunit/phpunit": "^8.0 || ^9.0", - "symfony/form": "^4.4 || ^5.0 || ^6.0", - "symfony/serializer": "^4.4 || ^5.0 || ^6.0", - "symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0", - "symfony/validator": "^4.4 || ^5.0 || ^6.0", + "symfony/form": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/serializer": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/validator": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symplify/easy-coding-standard": "^11" }, "suggest": { @@ -30,6 +30,9 @@ "symfony/twig-bundle": "Format and manipulate Money in Twig templates", "symfony/validator": "Use custom validation constraints on Money objects" }, + "conflict": { + "doctrine/dbal": ">=4.0.0" + }, "autoload": { "psr-4": { "Headsnet\\MoneyBundle\\": "src/", diff --git a/phpstan.neon b/phpstan.neon index 906d323..b799c40 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,4 +9,6 @@ parameters: bootstrapFiles: - vendor/autoload.php - checkGenericClassInNonGenericObjectType: false + ignoreErrors: + - + identifier: missingType.generics diff --git a/src/HeadsnetMoneyBundle.php b/src/HeadsnetMoneyBundle.php index d2cb1df..735f801 100644 --- a/src/HeadsnetMoneyBundle.php +++ b/src/HeadsnetMoneyBundle.php @@ -17,6 +17,7 @@ use Doctrine\Persistence\ManagerRegistry; use Headsnet\MoneyBundle\Doctrine\DBAL\Types\CurrencyType; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; class HeadsnetMoneyBundle extends Bundle @@ -28,6 +29,9 @@ public function build(ContainerBuilder $container): void $this->addDoctrineMapping($container); } + /** + * @throws Exception + */ public function boot(): void { $this->addCurrencyColumnType(); @@ -60,8 +64,10 @@ private function addCurrencyColumnType(): void Type::addType('currency', CurrencyType::class); } + /** @var ContainerInterface $container Keep PHPStan happy */ + $container = $this->container; /** @var ManagerRegistry $registry */ - $registry = $this->container->get('doctrine'); + $registry = $container->get('doctrine'); /** @var Connection $connection */ foreach ($registry->getConnections() as $connection) { diff --git a/src/Serializer/Normalizer/MoneyAsDecimalNormalizer.php b/src/Serializer/Normalizer/MoneyAsDecimalNormalizer.php index 4779a9c..512c239 100644 --- a/src/Serializer/Normalizer/MoneyAsDecimalNormalizer.php +++ b/src/Serializer/Normalizer/MoneyAsDecimalNormalizer.php @@ -29,13 +29,16 @@ public function __construct() /** * @param Money $object - * @param string[] $context + * @param array $context */ public function normalize($object, string $format = null, array $context = []): string { return $this->moneyFormatter->format($object); } + /** + * @param array $context + */ public function supportsNormalization($data, string $format = null, array $context = []): bool { return $data instanceof Money; diff --git a/src/Serializer/Normalizer/MoneyNormalizer.php b/src/Serializer/Normalizer/MoneyNormalizer.php index be7df32..fd79396 100644 --- a/src/Serializer/Normalizer/MoneyNormalizer.php +++ b/src/Serializer/Normalizer/MoneyNormalizer.php @@ -19,7 +19,7 @@ class MoneyNormalizer implements NormalizerInterface, DenormalizerInterface { /** * @param Money $object - * @param string[] $context + * @param array $context * * @return array{amount: string, currency: Currency} */ @@ -31,6 +31,9 @@ public function normalize($object, string $format = null, array $context = []): ]; } + /** + * @param array $context + */ public function supportsNormalization($data, string $format = null, array $context = []): bool { return $data instanceof Money; @@ -38,13 +41,16 @@ public function supportsNormalization($data, string $format = null, array $conte /** * @param array{amount: numeric-string, currency: non-empty-string} $data - * @param string[] $context + * @param array $context */ public function denormalize($data, string $type, string $format = null, array $context = []): Money { return new Money($data['amount'], new Currency($data['currency'])); } + /** + * @param array $context + */ public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool { if ($type !== Money::class) {