Skip to content

Commit

Permalink
feature #155 Add support for Symfony 6 (loic425)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.0-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | 
| License         | MIT


Commits
-------

e9557ba Add support for Symfony 6.0
1c530a5 Fix Phpstan and Psalm errors
597ef46 Fix another Psalm error
6107bd4 Remove Swiftmailer spec on Symfony 6
d6eb1af Fix spec removal
3c89f5a Copy bundles no swift config
15e8ab9 Trying to fix setDeprecated method on configuration
f63a48b Fix another setDeprecated method on configuration
ca0858d Fix bootstrap on test app
ecf4e8c Add tests for Symfony 6.1
7a114e8 Exclude Symfony 6.1 with PHP 8.0
c6ea7b3 Fix build
fb67acb Clean up and split static analysis
  • Loading branch information
Zales0123 authored Sep 6, 2022
2 parents bcf9343 + fb67acb commit 5a9a354
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 37 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ jobs:
fail-fast: false
matrix:
php: ["8.0", "8.1"]
symfony: ["5.4.*"]
symfony: ["5.4.*", "6.0.*", "6.1.*"]
twig: ["^2.12", "^3.3"]
exclude:
- php: "8.0"
symfony: "6.1.*"

steps:
-
Expand Down Expand Up @@ -47,14 +50,29 @@ jobs:
run: |
composer require "twig/twig:${{ matrix.twig }}" --no-update --no-scripts
-
name: Remove Swiftmailer on Symfony >= 6
if: matrix.symfony != '5.4.*'
run: |
composer remove --dev symfony/swiftmailer-bundle --no-update --no-scripts
rm src/Bundle/spec/Sender/Adapter/SwiftMailerAdapterSpec.php
-
name: Install dependencies
run: |
composer update ${{ matrix.composer-flags }} --no-scripts
(cd src/Component && composer update ${{ matrix.composer-flags }} --no-scripts)
-
name: Run analysis
name: Run analysis with Symfony 5
if: matrix.symfony == '5.4.*'
run: |
composer analyse-symfony5
(cd src/Component && composer validate --strict)
-
name: Run analysis with Symfony 6
if: matrix.symfony != '5.4.*'
run: |
composer analyse
(cd src/Component && composer validate --strict)
Expand All @@ -69,6 +87,7 @@ jobs:

-
name: Test bundle (with all services)
if: matrix.symfony == '5.4.*'
run: |
rm -rf src/Bundle/test/var/cache
composer require symfony/mailer --no-interaction --no-scripts
Expand All @@ -77,9 +96,11 @@ jobs:
-
name: Test bundle (with Swift Mailer)
if: matrix.symfony == '5.4.*'
run: |
rm -rf src/Bundle/test/var/cache
composer remove symfony/mailer --no-scripts
composer require symfony/swiftmailer-bundle --no-interaction --no-scripts
(cd src/Bundle/test && APP_ENV=test_with_swiftmailer bin/console lint:container)
vendor/bin/phpunit src/Bundle/tests/Functional/SwiftmailerSenderTest.php
Expand All @@ -97,4 +118,5 @@ jobs:
run: |
rm -rf src/Bundle/test/var/cache
composer remove symfony/mailer --no-scripts
composer remove symfony/swiftmailer-bundle --no-scripts
(cd src/Bundle/test && APP_ENV=test_no_mailers bin/console lint:container)
30 changes: 18 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
"require": {
"php": "^8.0",
"sylius-labs/polyfill-symfony-event-dispatcher": "^1.0",
"symfony/config": "^5.4",
"symfony/config": "^5.4 || ^6.0",
"symfony/deprecation-contracts": "^2.1 || ^3.0",
"symfony/dependency-injection": "^5.4",
"symfony/framework-bundle": "^5.4",
"symfony/http-kernel": "^5.4",
"symfony/dependency-injection": "^5.4 || ^6.0",
"symfony/framework-bundle": "^5.4 || ^6.0",
"symfony/http-kernel": "^5.4 || ^6.0",
"twig/twig": "^2.12 || ^3.3",
"webmozart/assert": "^1.9"
},
Expand All @@ -44,15 +44,15 @@
"phpstan/phpstan-phpunit": "1.1.1",
"phpstan/phpstan-webmozart-assert": "1.2.0",
"phpunit/phpunit": "^9.4",
"rector/rector": "^0.13.6",
"sylius-labs/coding-standard": "^4.0",
"symfony/console": "^5.4",
"symfony/dotenv": "^5.4",
"symfony/event-dispatcher": "^5.4",
"symfony/mailer": "^5.4",
"symfony/swiftmailer-bundle": "^3.1",
"symfony/twig-bundle": "^5.4",
"vimeo/psalm": "^4.22",
"rector/rector": "^0.13.6"
"symfony/console": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/event-dispatcher": "^5.4 || ^6.0",
"symfony/mailer": "^5.4 || ^6.0",
"symfony/twig-bundle": "^5.4 || ^6.0",
"vimeo/psalm": "^4.22"
},
"extra": {
"branch-alias": {
Expand Down Expand Up @@ -87,7 +87,13 @@
"@composer validate --strict",
"vendor/bin/ecs check src",
"vendor/bin/phpstan analyse --ansi -c phpstan.neon -l max src",
"vendor/bin/psalm"
"vendor/bin/psalm src"
],
"analyse-symfony5": [
"@composer validate --strict",
"vendor/bin/ecs check src",
"vendor/bin/phpstan analyse --ansi -c phpstan.symfony5.neon -l max src",
"vendor/bin/psalm -c psalm.symfony5.xml src"
],
"fix": [
"vendor/bin/ecs check src --fix"
Expand Down
11 changes: 2 additions & 9 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,18 @@ includes:

parameters:
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false

excludePaths:
- %currentWorkingDirectory%/src/Bundle/DependencyInjection/Configuration.php
- %currentWorkingDirectory%/src/Bundle/DependencyInjection/SyliusMailerExtension.php
- %currentWorkingDirectory%/src/Bundle/Sender/Adapter/SwiftMailerAdapter.php
- %currentWorkingDirectory%/src/Bundle/spec/*
- %currentWorkingDirectory%/src/Bundle/test/*
- %currentWorkingDirectory%/src/Bundle/tests/*
- %currentWorkingDirectory%/src/Component/spec/*
- %currentWorkingDirectory%/src/Component/vendor/*

ignoreErrors:
# Symfony 3.4 compatibility
- '/Call to function method_exists\(\) with .Symfony\\\\Component…. and .getRootNode. will always evaluate to false/'
- '/Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder::getRootNode\(\)/'
- '/Class Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder does not have a constructor and must be instantiated without any parameters/'

- '/Parameter \#1 \$event of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects object, string given\./'
- '/Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required\./'
- '/Cannot call method has\(\) on object\|null/'
- '/Property Sylius\\Component\\Mailer\\Model\\Email\:\:\$id is never written\, only read\./'
- '/PHPDoc tag \@param references unknown parameter\: \$bccRecipients/'
- '/PHPDoc tag \@param references unknown parameter\: \$ccRecipients/'
21 changes: 21 additions & 0 deletions phpstan.symfony5.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
includes:
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
- vendor/phpstan/phpstan-phpunit/extension.neon

- vendor/phpstan/phpstan-phpunit/rules.neon

parameters:
checkMissingIterableValueType: false

excludePaths:
- %currentWorkingDirectory%/src/Bundle/DependencyInjection/Configuration.php
- %currentWorkingDirectory%/src/Bundle/spec/*
- %currentWorkingDirectory%/src/Bundle/test/*
- %currentWorkingDirectory%/src/Bundle/tests/*
- %currentWorkingDirectory%/src/Component/spec/*
- %currentWorkingDirectory%/src/Component/vendor/*

ignoreErrors:
- '/Property Sylius\\Component\\Mailer\\Model\\Email\:\:\$id is never written\, only read\./'
- '/PHPDoc tag \@param references unknown parameter\: \$bccRecipients/'
- '/PHPDoc tag \@param references unknown parameter\: \$ccRecipients/'
52 changes: 52 additions & 0 deletions psalm.symfony5.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0"?>
<psalm
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
<directory name="src/Bundle/spec" />
<directory name="src/Bundle/test" />
<directory name="src/Bundle/tests" />
<directory name="src/Component/spec" />
<directory name="src/Component/vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<InvalidDocblockParamName>
<errorLevel type="suppress">
<file name="src/Component/Sender/SenderInterface.php" />
</errorLevel>
</InvalidDocblockParamName>

<PossiblyNullReference>
<errorLevel type="suppress">
<file name="src/Bundle/DependencyInjection/Configuration.php" />
</errorLevel>
</PossiblyNullReference>

<PossiblyUndefinedMethod>
<errorLevel type="suppress">
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeDefinition::scalarNode" />
</errorLevel>
</PossiblyUndefinedMethod>

<TooManyArguments>
<errorLevel type="suppress">
<referencedFunction name="Symfony\Component\Config\Definition\Builder\TreeBuilder::__construct" />
<referencedFunction name="Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch" />
</errorLevel>
</TooManyArguments>

<NonInvariantDocblockPropertyType>
<errorLevel type="suppress">
<file name="src/Bundle/Renderer/Adapter/EmailDefaultAdapter.php" />
<file name="src/Bundle/Sender/Adapter/DefaultAdapter.php" />
</errorLevel>
</NonInvariantDocblockPropertyType>
</issueHandlers>
</psalm>
14 changes: 3 additions & 11 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<directory name="src/Bundle/spec" />
<directory name="src/Bundle/test" />
<directory name="src/Bundle/tests" />
<file name="src/Bundle/DependencyInjection/SyliusMailerExtension.php" />
<file name="src/Bundle/Sender/Adapter/SwiftMailerAdapter.php" />
<directory name="src/Component/spec" />
<directory name="src/Component/vendor" />
</ignoreFiles>
Expand All @@ -31,20 +33,10 @@

<PossiblyUndefinedMethod>
<errorLevel type="suppress">
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeDefinition::arrayNode" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeDefinition::scalarNode" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeDefinition::variableNode" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\NodeParentInterface::end" />
<referencedMethod name="Symfony\Component\Config\Definition\Builder\VariableNodeDefinition::scalarNode" />
</errorLevel>
</PossiblyUndefinedMethod>

<TooManyArguments>
<errorLevel type="suppress">
<referencedFunction name="Symfony\Component\Config\Definition\Builder\TreeBuilder::__construct" />
<referencedFunction name="Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch" />
</errorLevel>
</TooManyArguments>

<NonInvariantDocblockPropertyType>
<errorLevel type="suppress">
<file name="src/Bundle/Renderer/Adapter/EmailDefaultAdapter.php" />
Expand Down
4 changes: 2 additions & 2 deletions src/Bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private function addEmailsSection(ArrayNodeDefinition $node): void
->arrayPrototype()
->children()
->scalarNode('subject')
->setDeprecated('The "subject" option is deprecated since SyliusMailerBundle 1.5')
->setDeprecated('sylius/mailer-bundle', '1.5', 'The "subject" option is deprecated since SyliusMailerBundle 1.5')
->end()
->scalarNode('template')->cannotBeEmpty()->end()
->booleanNode('enabled')->defaultTrue()->end()
Expand All @@ -70,7 +70,7 @@ private function addEmailsSection(ArrayNodeDefinition $node): void
->end()
->end()
->arrayNode('templates')
->setDeprecated('The "templates" option is deprecated')
->setDeprecated('sylius/mailer-bundle', '1.6', 'The "templates" option is deprecated')
->useAttributeAsKey('name')
->scalarPrototype()->end()
->end()
Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/test/config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
} else {
// load all the .env files
(new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env');
(new Dotenv())->loadEnv(dirname(__DIR__) . '/.env');
}

$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'test';
Expand Down

0 comments on commit 5a9a354

Please sign in to comment.