Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Symfony 5.1 🎉🎊 #1546

Merged
merged 4 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,32 @@
"sensiolabs/security-checker": "^6.0",
"siriusphp/upload": "^3.0.1",
"squirrelphp/twig-php-syntax": "^1.5",
"symfony/asset": "^4.4",
"symfony/console": "^4.4",
"symfony/debug-bundle": "^4.4",
"symfony/dependency-injection": "^4.4",
"symfony/dotenv": "^4.4",
"symfony/expression-language": "^4.4",
"symfony/asset": "^5.1",
"symfony/console": "^5.1",
"symfony/debug-bundle": "^5.1",
"symfony/dependency-injection": "^5.1",
"symfony/dotenv": "^5.1",
"symfony/expression-language": "^5.1",
"symfony/flex": "^1.6",
"symfony/form": "^4.4",
"symfony/framework-bundle": "^4.4",
"symfony/http-client": "^4.4",
"symfony/mailer": "^4.4",
"symfony/form": "^5.1",
"symfony/framework-bundle": "^5.1",
"symfony/http-client": "^5.1",
"symfony/mailer": "^5.1",
"symfony/maker-bundle": "^1.14",
"symfony/monolog-bridge": "^4.4",
"symfony/monolog-bridge": "^5.1",
"symfony/monolog-bundle": "^3.5",
"symfony/polyfill-php72": "^1.13",
"symfony/security-bundle": "^4.4",
"symfony/serializer": "^4.4",
"symfony/stopwatch": "^4.4",
"symfony/translation": "^4.4",
"symfony/twig-bundle": "^4.4",
"symfony/validator": "^4.4",
"symfony/var-dumper": "^4.4",
"symfony/web-profiler-bundle": "^4.4",
"symfony/security-bundle": "^5.1",
"symfony/serializer": "^5.1",
"symfony/stopwatch": "^5.1",
"symfony/translation": "^5.1",
"symfony/twig-bundle": "^5.1",
"symfony/validator": "^5.1",
"symfony/var-dumper": "^5.1",
"symfony/web-profiler-bundle": "^5.1",
"symfony/web-server-bundle": "^4.4",
"symfony/webpack-encore-bundle": "^1.7",
"symfony/yaml": "^4.4",
"symfony/yaml": "^5.1",
"tightenco/collect": "^7.4",
"twig/twig": "^3.0",
"ua-parser/uap-php": "^3.9",
Expand Down Expand Up @@ -101,8 +101,8 @@
"phpunit/phpunit": "^7.5",
"roave/security-advisories": "dev-master@dev",
"se/selenium-server-standalone": "^3.141",
"symfony/browser-kit": "^4.4",
"symfony/css-selector": "^4.4",
"symfony/browser-kit": "^5.1",
"symfony/css-selector": "^5.1",
"symplify/easy-coding-standard": "^8.0",
"vaimo/binary-chromedriver": "^5.0"
},
Expand All @@ -115,7 +115,7 @@
"extra": {
"symfony": {
"allow-contrib": true,
"require": "^4.4"
"require": "^5.1"
}
},
"autoload": {
Expand Down
10 changes: 5 additions & 5 deletions config/bolt/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ thumbnails:
# user that PHP (and/or your webserver) is running as, and the user who owns the
# actual folders/files.
#
# - If they are the same user, use `0755` for folders and `0644` for files.
# - If they're in the same group, use use `0775` for folders and `0664` for files.
# - If you don't know, or you can't make it work otherwise, then use `0777` for folders and `0666` for files.
# - If they are the same user, use `0o755` for folders and `0o644` for files.
# - If they're in the same group, use use `0o775` for folders and `0o664` for files.
# - If you don't know, or you can't make it work otherwise, then use `0o777` for folders and `0o666` for files.
filepermissions:
folders: 0775
files: 0664
folders: 0o775
files: 0o664

# Define the HTML tags and attributes that are allowed in cleaned HTML. This
# is used for sanitizing HTML, to make sure there are no undesirable elements
Expand Down
1 change: 0 additions & 1 deletion config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true, 'test' => true, 'local' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
Symplify\ConsoleColorDiff\ConsoleColorDiffBundle::class => ['dev' => true, 'test' => true],
Symplify\ConsoleColorDiff\ConsoleColorDiffBundle::class => ['dev' => true, 'test' => true],
Translation\Bundle\TranslationBundle::class => ['all' => true],
Translation\PlatformAdapter\Loco\Bridge\Symfony\TranslationAdapterLocoBundle::class => ['dev' => true, 'local' => true],
];
8 changes: 1 addition & 7 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ parameters:
tmpDir: var/cache/ecs
level: 5
symfony:
container_xml_path: '%rootDir%/../../../var/cache/dev/srcBolt_KernelDevDebugContainer.xml'
container_xml_path: '%rootDir%/../../../var/cache/dev/Bolt_KernelDevDebugContainer.xml'

ignoreErrors:
# false positive: `Unreachable statement - code above always terminates.`
Expand All @@ -16,12 +16,6 @@ parameters:
message: '#Call to an undefined method Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslationInterface#'
path: %currentWorkingDirectory%/src/*

# false positive: `Method Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch() invoked with 2 parameters, 1 required.`
# We skip this error, because it's still what the docs recommend: https://symfony.com/doc/current/components/event_dispatcher.html#dispatch-the-event
-
message: '#EventDispatcherInterface::dispatch\(\) invoked with 2 parameters#'
path: %currentWorkingDirectory%/src/*

includes:
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/phpstan/phpstan-doctrine/extension.neon
Expand Down
1 change: 1 addition & 0 deletions phpunit.bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
$application->run(new \Symfony\Component\Console\Input\StringInput('doctrine:database:drop --force --quiet'));
$application->run(new \Symfony\Component\Console\Input\StringInput('doctrine:database:create --quiet'));
$application->run(new \Symfony\Component\Console\Input\StringInput('doctrine:schema:create --quiet'));
$application->run(new \Symfony\Component\Console\Input\StringInput('doctrine:fixtures:load --no-interaction --group=without-images'));

$kernel->shutdown();
9 changes: 4 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@
</testsuite>
</testsuites>

<listeners>
<!-- it begins a database transaction before every testcase and rolls it back after
the test finished, so tests can manipulate the database without affecting other tests -->
<listener class="\DAMA\DoctrineTestBundle\PHPUnit\PHPUnitListener" />
</listeners>
<extensions>
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
</extensions>

</phpunit>
6 changes: 3 additions & 3 deletions src/Canonical.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(Config $config, UrlGeneratorInterface $urlGenerator,
{
$this->config = $config;
$this->urlGenerator = $urlGenerator;
$this->request = $requestStack->getCurrentRequest();
$this->request = $requestStack->getCurrentRequest() ?? Request::createFromGlobals();
$this->defaultLocale = $defaultLocale;

$this->init();
Expand All @@ -51,7 +51,7 @@ public function __construct(Config $config, UrlGeneratorInterface $urlGenerator,
public function init(): void
{
// Ensure in request cycle (even for override).
if ($this->request === null) {
if ($this->request === null || $this->request->getHost() === '') {
return;
}

Expand Down Expand Up @@ -182,7 +182,7 @@ public function generateLink(?string $route, ?array $params, $canonical = false)
$params,
$canonical ? UrlGeneratorInterface::ABSOLUTE_URL : UrlGeneratorInterface::ABSOLUTE_PATH
);
} catch (InvalidParameterException | MissingMandatoryParametersException | RouteNotFoundException $e) {
} catch (InvalidParameterException | MissingMandatoryParametersException | RouteNotFoundException | \TypeError $e) {
// Just use the current URL /shrug
return$this->request->getUri();
}
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/TwigAwareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Bolt\Storage\Query;
use Bolt\Utils\Sanitiser;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\TwigBundle\Loader\NativeFilesystemLoader;
use Symfony\Component\Asset\Packages;
use Symfony\Component\Asset\PathPackage;
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
Expand Down Expand Up @@ -101,7 +100,7 @@ protected function renderTemplate($template, array $parameters = [], ?Response $

private function setTwigLoader(): void
{
/** @var NativeFilesystemLoader $twigLoaders */
/** @var FilesystemLoader $twigLoaders */
$twigLoaders = $this->twig->getLoader();

$path = $this->config->getPath('theme');
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Field/FileExtrasTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private function getPath(): string
{
$filesPackage = new PathPackage('/files/', new EmptyVersionStrategy());

return $filesPackage->getUrl($this->get('filename'));
return $filesPackage->getUrl((string) $this->get('filename'));
}

private function getUrl(): string
Expand Down
3 changes: 1 addition & 2 deletions src/Extension/BaseExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Composer\Package\CompletePackage;
use Composer\Package\PackageInterface;
use ComposerPackages\Packages;
use Symfony\Bundle\TwigBundle\Loader\NativeFilesystemLoader;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Twig\Environment;
use Twig\Extension\ExtensionInterface as TwigExtensionInterface;
Expand Down Expand Up @@ -94,7 +93,7 @@ public function addTwigNamespace(string $namespace = '', string $foldername = ''
return;
}

/** @var NativeFilesystemLoader $twigLoaders */
/** @var FilesystemLoader $twigLoaders */
$twigLoaders = $this->getTwig()->getLoader();

if ($twigLoaders instanceof FilesystemLoader) {
Expand Down
2 changes: 1 addition & 1 deletion src/Twig/ContentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function __construct(
$this->contentRepository = $contentRepository;
$this->csrfTokenManager = $csrfTokenManager;
$this->security = $security;
$this->request = $requestStack->getCurrentRequest();
$this->request = $requestStack->getCurrentRequest() ?? Request::createFromGlobals();
$this->config = $config;
$this->query = $query;
$this->taxonomyRepository = $taxonomyRepository;
Expand Down
5 changes: 3 additions & 2 deletions src/Utils/ContentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
use Bolt\Configuration\Config;
use Bolt\Entity\Content;
use Bolt\Entity\Field\Excerptable;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

class ContentHelper
{
/** @var Canonical */
private $canonical;

/** @var \Symfony\Component\HttpFoundation\Request|null */
/** @var Request */
private $request;

/** @var Config */
Expand All @@ -24,7 +25,7 @@ class ContentHelper
public function __construct(Canonical $canonical, RequestStack $requestStack, Config $config)
{
$this->canonical = $canonical;
$this->request = $requestStack->getCurrentRequest();
$this->request = $requestStack->getCurrentRequest() ?? Request::createFromGlobals();
$this->config = $config;
}

Expand Down
3 changes: 0 additions & 3 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,6 @@
"symfony/css-selector": {
"version": "v4.4.4"
},
"symfony/debug": {
"version": "v4.4.4"
},
"symfony/debug-bundle": {
"version": "4.1",
"recipe": {
Expand Down
10 changes: 1 addition & 9 deletions tests/php/Repository/TaxonomyRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,10 @@
use Bolt\Tests\DbAwareTestCase;

/**
* @todo Add represenative tests here, when methods are implemented in TaxonomyRepository
* @todo Add representative tests here, when methods are implemented in TaxonomyRepository
*/
class TaxonomyRepositoryTest extends DbAwareTestCase
{
protected function setUp(): void
{
parent::setUp();

// fixtures loading takes a lot of time, it would be better to load database dump for tests
self::runCommand('doctrine:fixtures:load --no-interaction --group=without-images');
}

public function testSearchByType(): void
{
$taxonomies = $this->getEm()
Expand Down
8 changes: 0 additions & 8 deletions tests/php/Repository/UserRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@

class UserRepositoryTest extends DbAwareTestCase
{
protected function setUp(): void
{
parent::setUp();

// fixtures loading takes a lot of time, it would be better to load database dump for tests
self::runCommand('doctrine:fixtures:load --no-interaction --group=without-images');
}

public function testFindOneByUsername(): void
{
$admin = $this->getEm()->getRepository(User::class)->findOneByUsername('admin');
Expand Down