Skip to content

Commit

Permalink
Merge 3.x into 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI committed Sep 4, 2022
2 parents 17f6d41 + 0030610 commit 1e8c973
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 29 deletions.
7 changes: 6 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@
'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true],
'ordered_class_elements' => true,
'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['class', 'function', 'const']],
'phpdoc_order' => ['order' => ['var', 'param', 'throws', 'return', 'phpstan-var', 'psalm-var', 'phpstan-param', 'psalm-param', 'phpstan-return', 'psalm-return']],
'phpdoc_separation' => ['groups' => [
['phpstan-template', 'phpstan-template-covariant', 'phpstan-extends', 'phpstan-implements', 'phpstan-var', 'psalm-var', 'phpstan-param', 'psalm-param', 'phpstan-return', 'psalm-return'],
['psalm-suppress', 'phpstan-ignore-next-line'],
]],
'php_unit_strict' => true,
'php_unit_test_case_static_method_calls' => true,
'phpdoc_to_comment' => ['ignored_tags' => ['psalm-suppress']],
'phpdoc_to_comment' => ['ignored_tags' => ['psalm-suppress', 'phpstan-var']],
'single_line_throw' => false,
'static_lambda' => true,
'strict_comparison' => true,
Expand Down
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ set_time_limit(0);

require dirname(__DIR__) . '/vendor/autoload.php';

$kernel = new AppKernel();
$kernel = new AppKernel('test', false);
$application = new Application($kernel);
$application->run(new ArgvInput());
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"twig/twig": "^2.12 || ^3.0"
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.1",
"doctrine/doctrine-bundle": "^2.4",
"doctrine/doctrine-fixtures-bundle": "^3.4",
"doctrine/orm": "^2.5",
"doctrine/orm": "^2.8",
"doctrine/persistence": "^2.0 || ^3.0",
"friendsofphp/php-cs-fixer": "^3.4",
"gedmo/doctrine-extensions": "^3.0",
Expand All @@ -56,6 +56,7 @@
"sonata-project/doctrine-orm-admin-bundle": "^4.0",
"symfony/browser-kit": "^4.4 || ^5.4 || ^6.0",
"symfony/css-selector": "^4.4 || ^5.4 || ^6.0",
"symfony/filesystem": "^4.4 || ^5.4 || ^6.0",
"symfony/phpunit-bridge": "^6.1",
"vimeo/psalm": "^4.3.2",
"weirdan/doctrine-psalm-plugin": "^2.0"
Expand Down
2 changes: 1 addition & 1 deletion phpstan-object-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

require __DIR__.'/vendor/autoload.php';

$kernel = new AppKernel();
$kernel = new AppKernel('test', false);
$kernel->boot();

return $kernel->getContainer()->get('doctrine')->getManager();
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@ It's auto-generated by sonata-project/dev-kit package.
<php>
<ini name="precision" value="8" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
<env name="KERNEL_CLASS" value="\Sonata\TranslationBundle\Tests\App\AppKernel" />
<server name="APP_ENV" value="test" force="true" />
<server name="APP_DEBUG" value="false" />
</php>
</phpunit>
1 change: 1 addition & 0 deletions src/Checker/TranslatableChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function getSupportedInterfaces(): array

/**
* @param string[] $supportedModels
*
* @phpstan-param class-string[] $supportedModels
*/
public function setSupportedModels(array $supportedModels): void
Expand Down
6 changes: 6 additions & 0 deletions src/Filter/TranslationFieldFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ protected function association(ProxyQueryInterface $query, FilterData $data): ar
return [$alias, $fieldName];
}

/**
* @phpstan-param ProxyQueryInterface<object> $query
*/
private function applyGedmoFilters(ProxyQueryInterface $query, string $joinAlias, string $alias, string $field, string $value): void
{
$this->applyWhere($query, $query->getQueryBuilder()->expr()->orX(
Expand All @@ -129,6 +132,9 @@ private function applyGedmoFilters(ProxyQueryInterface $query, string $joinAlias
));
}

/**
* @phpstan-param ProxyQueryInterface<object> $query
*/
private function applyKnplabsFilters(ProxyQueryInterface $query, string $joinAlias, string $field, string $value): void
{
$this->applyWhere(
Expand Down
11 changes: 2 additions & 9 deletions tests/App/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,10 @@
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

/**
* @psalm-suppress PropertyNotSetInConstructor https://github.com/vimeo/psalm/issues/2319 comming from
* https://github.com/psalm/psalm-plugin-symfony/blob/65586604237c9062c15adc92faee5f84d1698af6/src/Stubs/common/Component/HttpKernel/Kernel.stubphp
*/
final class AppKernel extends Kernel
{
use MicroKernelTrait;

public function __construct()
{
parent::__construct('test', true);
}

public function registerBundles(): iterable
{
return [
Expand Down Expand Up @@ -94,6 +85,8 @@ protected function configureRoutes($routes): void

protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
$container->setParameter('app.base_dir', $this->getBaseDir());

if (interface_exists(AuthenticatorFactoryInterface::class)) {
$loader->load(__DIR__.'/config/config_v5.yml');
$loader->load(__DIR__.'/config/security_v5.yml');
Expand Down
2 changes: 1 addition & 1 deletion tests/App/config/config_v4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ twig:
strict_variables: true

parameters:
env(DATABASE_URL): 'sqlite:////%kernel.cache_dir%/test_database.db'
env(DATABASE_URL): 'sqlite:////%app.base_dir%database.db'
locale: 'en'

sonata_block:
Expand Down
2 changes: 1 addition & 1 deletion tests/App/config/config_v5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ twig:
strict_variables: true

parameters:
env(DATABASE_URL): 'sqlite:////%kernel.cache_dir%/test_database.db'
env(DATABASE_URL): 'sqlite:////%app.base_dir%database.db'
locale: 'en'

sonata_block:
Expand Down
6 changes: 0 additions & 6 deletions tests/Functional/GedmoCRUDTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Sonata\TranslationBundle\Tests\Functional;

use Sonata\TranslationBundle\Tests\App\AppKernel;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -137,11 +136,6 @@ public function provideLocalesToEdit(): iterable
yield 'french' => ['fr', 'Roman édité'];
}

protected static function getKernelClass(): string
{
return AppKernel::class;
}

private function generateUrlWithLocale(string $url, string $locale): string
{
if ('' === $locale) {
Expand Down
6 changes: 0 additions & 6 deletions tests/Functional/KnpCRUDTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Sonata\TranslationBundle\Tests\Functional;

use Sonata\TranslationBundle\Tests\App\AppKernel;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -137,11 +136,6 @@ public function provideLocalesToEdit(): iterable
yield 'french' => ['fr', 'Roman édité'];
}

protected static function getKernelClass(): string
{
return AppKernel::class;
}

private function generateUrlWithLocale(string $url, string $locale): string
{
if ('' === $locale) {
Expand Down
6 changes: 5 additions & 1 deletion tests/custom_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Filesystem\Filesystem;

$application = new Application(new AppKernel());
$kernel = new AppKernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->setAutoExit(false);

$input = new ArrayInput([
Expand All @@ -41,3 +43,5 @@
'--no-interaction' => false,
]);
$application->run($input, new NullOutput());

(new Filesystem())->remove([$kernel->getCacheDir()]);

0 comments on commit 1e8c973

Please sign in to comment.