diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index a4b8dbb48..6c3133ef4 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -58,6 +58,11 @@ jobs:
allowed-to-fail: false
symfony-require: 6.4.*
variant: symfony/symfony:"6.4.*"
+ - php-version: '8.3'
+ dependencies: highest
+ allowed-to-fail: false
+ symfony-require: 7.0.*
+ variant: symfony/symfony:"7.0.*"
steps:
- name: Checkout
diff --git a/composer.json b/composer.json
index 2fbc4a270..27bd3ebd1 100644
--- a/composer.json
+++ b/composer.json
@@ -33,47 +33,47 @@
"sonata-project/seo-bundle": "^3.4",
"sonata-project/twig-extensions": "^1.3 || ^2.0",
"symfony-cmf/routing-bundle": "^2.1 || ^3.0",
- "symfony/config": "^5.4 || ^6.2",
- "symfony/console": "^5.4 || ^6.2",
- "symfony/dependency-injection": "^5.4 || ^6.2",
- "symfony/form": "^5.4 || ^6.2",
- "symfony/framework-bundle": "^5.4 || ^6.2",
- "symfony/http-foundation": "^5.4 || ^6.2",
- "symfony/http-kernel": "^5.4 || ^6.2",
- "symfony/intl": "^5.4 || ^6.2",
- "symfony/options-resolver": "^5.4 || ^6.2",
- "symfony/process": "^5.4 || ^6.2",
- "symfony/property-access": "^5.4 || ^6.2",
- "symfony/property-info": "^5.4 || ^6.2",
- "symfony/routing": "^5.4 || ^6.2",
- "symfony/runtime": "^5.4 || ^6.2",
- "symfony/security-core": "^5.4 || ^6.2",
- "symfony/security-http": "^5.4 || ^6.2",
- "symfony/serializer": "^5.4.24 || ^6.2.11",
- "symfony/validator": "^5.4 || ^6.2",
+ "symfony/config": "^5.4 || ^6.2 || ^7.0",
+ "symfony/console": "^5.4 || ^6.2 || ^7.0",
+ "symfony/dependency-injection": "^5.4 || ^6.2 || ^7.0",
+ "symfony/form": "^5.4 || ^6.2 || ^7.0",
+ "symfony/framework-bundle": "^5.4 || ^6.2 || ^7.0",
+ "symfony/http-foundation": "^5.4 || ^6.2 || ^7.0",
+ "symfony/http-kernel": "^5.4 || ^6.2 || ^7.0",
+ "symfony/intl": "^5.4 || ^6.2 || ^7.0",
+ "symfony/options-resolver": "^5.4 || ^6.2 || ^7.0",
+ "symfony/process": "^5.4 || ^6.2 || ^7.0",
+ "symfony/property-access": "^5.4 || ^6.2 || ^7.0",
+ "symfony/property-info": "^5.4 || ^6.2 || ^7.0",
+ "symfony/routing": "^5.4 || ^6.2 || ^7.0",
+ "symfony/runtime": "^5.4 || ^6.2 || ^7.0",
+ "symfony/security-core": "^5.4 || ^6.2 || ^7.0",
+ "symfony/security-http": "^5.4 || ^6.2 || ^7.0",
+ "symfony/serializer": "^5.4.24 || ^6.2.11 || ^7.0",
+ "symfony/validator": "^5.4 || ^6.2 || ^7.0",
"twig/string-extra": "^3.0",
"twig/twig": "^3.0"
},
"require-dev": {
- "dama/doctrine-test-bundle": "^7.0",
+ "dama/doctrine-test-bundle": "^8.0",
"friendsofphp/php-cs-fixer": "^3.4",
"masterminds/html5": "^2.7",
- "matthiasnoback/symfony-dependency-injection-test": "^4.1.1",
+ "matthiasnoback/symfony-dependency-injection-test": "^4.1.1 || ^5.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.3",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^9.5",
- "psalm/plugin-phpunit": "^0.18",
+ "psalm/plugin-phpunit": "^0.19",
"psalm/plugin-symfony": "^5.0",
"rector/rector": "^1.1",
- "symfony/browser-kit": "^5.4 || ^6.2",
- "symfony/css-selector": "^5.4 || ^6.2",
- "symfony/filesystem": "^5.4 || ^6.2",
+ "symfony/browser-kit": "^5.4 || ^6.2 || ^7.0",
+ "symfony/css-selector": "^5.4 || ^6.2 || ^7.0",
+ "symfony/filesystem": "^5.4 || ^6.2 || ^7.0",
"symfony/panther": "^2.0.1",
- "symfony/phpunit-bridge": "^6.2",
- "symfony/yaml": "^5.4 || ^6.2",
+ "symfony/phpunit-bridge": "^7.0",
+ "symfony/yaml": "^5.4 || ^6.2 || ^7.0",
"vimeo/psalm": "^5.0"
},
"conflict": {
diff --git a/src/Admin/BlockAdmin.php b/src/Admin/BlockAdmin.php
index 2afe73c54..cdcdbcae7 100644
--- a/src/Admin/BlockAdmin.php
+++ b/src/Admin/BlockAdmin.php
@@ -47,7 +47,7 @@ final class BlockAdmin extends BaseBlockAdmin
*/
public function __construct(
BlockServiceManagerInterface $blockManager,
- private array $blocks = []
+ private array $blocks = [],
) {
parent::__construct($blockManager);
}
@@ -206,7 +206,7 @@ private function configureBlockFields(FormMapper $form, BlockInterface $block):
$service = $this->blockManager->get($block);
if (!$service instanceof EditableBlockService) {
- throw new \RuntimeException(sprintf(
+ throw new \RuntimeException(\sprintf(
'The block "%s" must implement %s',
$blockType,
EditableBlockService::class
diff --git a/src/Admin/PageAdmin.php b/src/Admin/PageAdmin.php
index 582206f02..3adcbfd7b 100644
--- a/src/Admin/PageAdmin.php
+++ b/src/Admin/PageAdmin.php
@@ -48,7 +48,7 @@ final class PageAdmin extends AbstractAdmin
public function __construct(
private PageManagerInterface $pageManager,
- private SiteManagerInterface $siteManager
+ private SiteManagerInterface $siteManager,
) {
parent::__construct();
}
@@ -119,7 +119,7 @@ protected function alterNewInstance(object $object): void
protected function configurePersistentParameters(): array
{
$parameters = [];
- $key = sprintf('%s.current_site', $this->getCode());
+ $key = \sprintf('%s.current_site', $this->getCode());
if (!$this->hasRequest()) {
return $parameters;
@@ -192,7 +192,7 @@ protected function configureDatagridFilters(DatagridMapper $filter): void
$builder = $queryBuilder->getQueryBuilder();
if (\in_array($data->getValue(), ['hybrid', 'cms'], true)) {
- $builder->andWhere(sprintf('%s.routeName %s :routeName', $alias, 'cms' === $data->getValue() ? '=' : '!='));
+ $builder->andWhere(\sprintf('%s.routeName %s :routeName', $alias, 'cms' === $data->getValue() ? '=' : '!='));
$builder->setParameter('routeName', PageInterface::PAGE_ROUTE_CMS_NAME);
return true;
diff --git a/src/Admin/SharedBlockAdmin.php b/src/Admin/SharedBlockAdmin.php
index 80b2808eb..d5ccc1ed4 100644
--- a/src/Admin/SharedBlockAdmin.php
+++ b/src/Admin/SharedBlockAdmin.php
@@ -30,12 +30,12 @@ final class SharedBlockAdmin extends BaseBlockAdmin
protected function generateBaseRoutePattern(bool $isChildAdmin = false): string
{
- return sprintf('%s/%s', parent::generateBaseRoutePattern($isChildAdmin), 'shared');
+ return \sprintf('%s/%s', parent::generateBaseRoutePattern($isChildAdmin), 'shared');
}
protected function generateBaseRouteName(bool $isChildAdmin = false): string
{
- return sprintf('%s_%s', parent::generateBaseRouteName($isChildAdmin), 'shared');
+ return \sprintf('%s_%s', parent::generateBaseRouteName($isChildAdmin), 'shared');
}
/**
@@ -101,7 +101,7 @@ private function configureBlockFields(FormMapper $form, BlockInterface $block):
$service = $this->blockManager->get($block);
if (!$service instanceof EditableBlockService) {
- throw new \RuntimeException(sprintf(
+ throw new \RuntimeException(\sprintf(
'The block "%s" is not a valid %s',
$blockType,
EditableBlockService::class
diff --git a/src/Admin/SnapshotAdmin.php b/src/Admin/SnapshotAdmin.php
index 19a53bd06..907caa9e9 100644
--- a/src/Admin/SnapshotAdmin.php
+++ b/src/Admin/SnapshotAdmin.php
@@ -40,7 +40,7 @@ final class SnapshotAdmin extends AbstractAdmin
public function __construct(
private TransformerInterface $transformer,
private PageManagerInterface $pageManager,
- private SnapshotManagerInterface $snapshotManager
+ private SnapshotManagerInterface $snapshotManager,
) {
parent::__construct();
}
diff --git a/src/Block/BreadcrumbBlockService.php b/src/Block/BreadcrumbBlockService.php
index 152d24174..840faff4e 100644
--- a/src/Block/BreadcrumbBlockService.php
+++ b/src/Block/BreadcrumbBlockService.php
@@ -35,7 +35,7 @@ final class BreadcrumbBlockService extends BaseBreadcrumbMenuBlockService implem
public function __construct(
Environment $twig,
FactoryInterface $factory,
- private CmsManagerSelectorInterface $cmsSelector
+ private CmsManagerSelectorInterface $cmsSelector,
) {
parent::__construct($twig, $factory);
}
diff --git a/src/Block/ChildrenPagesBlockService.php b/src/Block/ChildrenPagesBlockService.php
index 5b70d12a1..261d1acdc 100755
--- a/src/Block/ChildrenPagesBlockService.php
+++ b/src/Block/ChildrenPagesBlockService.php
@@ -52,7 +52,7 @@ public function __construct(
Environment $twig,
private SiteSelectorInterface $siteSelector,
private CmsManagerSelectorInterface $cmsManagerSelector,
- private AdminInterface $pageAdmin
+ private AdminInterface $pageAdmin,
) {
parent::__construct($twig);
}
diff --git a/src/Block/PageListBlockService.php b/src/Block/PageListBlockService.php
index 84c421f98..6761f63b9 100755
--- a/src/Block/PageListBlockService.php
+++ b/src/Block/PageListBlockService.php
@@ -34,7 +34,7 @@ final class PageListBlockService extends AbstractBlockService implements Editabl
{
public function __construct(
Environment $twig,
- private PageManagerInterface $pageManager
+ private PageManagerInterface $pageManager,
) {
parent::__construct($twig);
}
diff --git a/src/Block/SharedBlockBlockService.php b/src/Block/SharedBlockBlockService.php
index b5543bc4c..4e7f8baf2 100755
--- a/src/Block/SharedBlockBlockService.php
+++ b/src/Block/SharedBlockBlockService.php
@@ -46,7 +46,7 @@ final class SharedBlockBlockService extends AbstractBlockService implements Edit
public function __construct(
Environment $twig,
private ManagerInterface $blockManager,
- private AdminInterface $sharedBlockAdmin
+ private AdminInterface $sharedBlockAdmin,
) {
parent::__construct($twig);
}
diff --git a/src/CmsManager/CmsManagerSelector.php b/src/CmsManager/CmsManagerSelector.php
index aa44e9ddc..b86a52411 100644
--- a/src/CmsManager/CmsManagerSelector.php
+++ b/src/CmsManager/CmsManagerSelector.php
@@ -41,7 +41,7 @@ public function __construct(
private CmsSnapshotManager $cmsSnapshotManager,
private AdminInterface $pageAdmin,
private TokenStorageInterface $tokenStorage,
- private RequestStack $requestStack
+ private RequestStack $requestStack,
) {
}
@@ -76,7 +76,7 @@ public function onLoginSuccess(LoginSuccessEvent $event): void
*/
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event): void
{
- @trigger_error(sprintf(
+ @trigger_error(\sprintf(
'The method "%s()" is deprecated since sonata-project/page-bundle 4.7.0 and will be removed in 5.0.'
.' Use "%s()" instead.',
__METHOD__,
diff --git a/src/CmsManager/CmsPageManager.php b/src/CmsManager/CmsPageManager.php
index c0319a5f5..4887be251 100644
--- a/src/CmsManager/CmsPageManager.php
+++ b/src/CmsManager/CmsPageManager.php
@@ -47,7 +47,7 @@ final class CmsPageManager extends BaseCmsPageManager
public function __construct(
private PageManagerInterface $pageManager,
- private BlockInteractorInterface $blockInteractor
+ private BlockInteractorInterface $blockInteractor,
) {
}
@@ -73,10 +73,10 @@ public function getPage(SiteInterface $site, $page): PageInterface
public function getInternalRoute(SiteInterface $site, string $routeName): PageInterface
{
if (str_starts_with($routeName, 'error')) {
- throw new \RuntimeException(sprintf('Illegal internal route name : %s, an internal page cannot start with `error`', $routeName));
+ throw new \RuntimeException(\sprintf('Illegal internal route name : %s, an internal page cannot start with `error`', $routeName));
}
- $routeName = sprintf('_page_internal_%s', $routeName);
+ $routeName = \sprintf('_page_internal_%s', $routeName);
try {
$page = $this->getPageByRouteName($site, $routeName);
@@ -84,7 +84,7 @@ public function getInternalRoute(SiteInterface $site, string $routeName): PageIn
$page = $this->pageManager->createWithDefaults([
'url' => null,
'routeName' => $routeName,
- 'name' => sprintf('Internal Page : %s', $routeName),
+ 'name' => \sprintf('Internal Page : %s', $routeName),
'decorate' => false,
]);
@@ -151,7 +151,7 @@ protected function getPageBy(?SiteInterface $site, string $fieldName, $value): P
$page = $this->pageManager->findOneBy($parameters);
if (null === $page) {
- throw new PageNotFoundException(sprintf('Unable to find the page : %s = %s', $fieldName, $value));
+ throw new PageNotFoundException(\sprintf('Unable to find the page : %s = %s', $fieldName, $value));
}
$this->loadBlocks($page);
diff --git a/src/CmsManager/CmsSnapshotManager.php b/src/CmsManager/CmsSnapshotManager.php
index 385e2242c..8c0c900ab 100644
--- a/src/CmsManager/CmsSnapshotManager.php
+++ b/src/CmsManager/CmsSnapshotManager.php
@@ -50,7 +50,7 @@ final class CmsSnapshotManager extends BaseCmsPageManager
public function __construct(
private SnapshotManagerInterface $snapshotManager,
- private TransformerInterface $transformer
+ private TransformerInterface $transformer,
) {
}
@@ -75,7 +75,7 @@ public function getPage(SiteInterface $site, $page): PageInterface
public function getInternalRoute(SiteInterface $site, string $routeName): PageInterface
{
- return $this->getPageByRouteName($site, sprintf('_page_internal_%s', $routeName));
+ return $this->getPageByRouteName($site, \sprintf('_page_internal_%s', $routeName));
}
public function findContainer(string $name, PageInterface $page, ?PageBlockInterface $parentContainer = null): ?PageBlockInterface
diff --git a/src/CmsManager/DecoratorStrategy.php b/src/CmsManager/DecoratorStrategy.php
index e7fb52e24..4830c6db2 100644
--- a/src/CmsManager/DecoratorStrategy.php
+++ b/src/CmsManager/DecoratorStrategy.php
@@ -30,7 +30,7 @@ final class DecoratorStrategy implements DecoratorStrategyInterface
public function __construct(
private array $ignoreRoutes,
private array $ignoreRoutePatterns,
- private array $ignoreUriPatterns
+ private array $ignoreUriPatterns,
) {
}
@@ -80,7 +80,7 @@ public function isRouteNameDecorable(string $routeName): bool
}
foreach ($this->ignoreRoutePatterns as $routePattern) {
- if (1 === preg_match(sprintf('#%s#', $routePattern), $routeName)) {
+ if (1 === preg_match(\sprintf('#%s#', $routePattern), $routeName)) {
return false;
}
}
@@ -91,7 +91,7 @@ public function isRouteNameDecorable(string $routeName): bool
public function isRouteUriDecorable(string $uri): bool
{
foreach ($this->ignoreUriPatterns as $uriPattern) {
- if (1 === preg_match(sprintf('#%s#', $uriPattern), $uri)) {
+ if (1 === preg_match(\sprintf('#%s#', $uriPattern), $uri)) {
return false;
}
}
diff --git a/src/Command/CleanupSnapshotsCommand.php b/src/Command/CleanupSnapshotsCommand.php
index 54d443944..c7a289d8a 100644
--- a/src/Command/CleanupSnapshotsCommand.php
+++ b/src/Command/CleanupSnapshotsCommand.php
@@ -27,7 +27,7 @@ final class CleanupSnapshotsCommand extends Command
{
public function __construct(
private CleanupSnapshotBySiteInterface $cleanupSnapshotBySite,
- private SiteManagerInterface $siteManager
+ private SiteManagerInterface $siteManager,
) {
parent::__construct();
}
@@ -52,7 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$keepSnapshots = $input->getOption('keep-snapshots');
foreach ($this->getSites($siteOption) as $site) {
- $output->write(sprintf('%s - Cleaning up snapshots ...', $site->getName() ?? ''));
+ $output->write(\sprintf('%s - Cleaning up snapshots ...', $site->getName() ?? ''));
$this->cleanupSnapshotBySite->cleanupBySite($site, (int) $keepSnapshots);
diff --git a/src/Command/CloneSiteCommand.php b/src/Command/CloneSiteCommand.php
index c191390af..bcfefcb08 100644
--- a/src/Command/CloneSiteCommand.php
+++ b/src/Command/CloneSiteCommand.php
@@ -34,7 +34,7 @@ final class CloneSiteCommand extends Command
public function __construct(
private SiteManagerInterface $siteManager,
private PageManagerInterface $pageManager,
- private BlockManagerInterface $blockManager
+ private BlockManagerInterface $blockManager,
) {
parent::__construct();
}
@@ -93,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$parent = $page->getParent();
- $output->writeln(sprintf(
+ $output->writeln(\sprintf(
' % 4s - % -70s - % 4s',
$pageId,
$page->getTitle() ?? '',
@@ -117,7 +117,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$blockId = $block->getId();
\assert(null !== $blockId);
- $output->writeln(sprintf(' cloning block % 4s ', $blockId));
+ $output->writeln(\sprintf(' cloning block % 4s ', $blockId));
$newBlock = clone $block;
$newBlock->setPage($newPage);
@@ -140,7 +140,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
\assert(null !== $parentId);
if (\array_key_exists($parentId, $pageClones)) {
- $output->writeln(sprintf(
+ $output->writeln(\sprintf(
'new parent: % 4s - % -70s - % 4s -> % 4s',
$page->getId() ?? '',
$page->getTitle() ?? '',
@@ -167,7 +167,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
\assert(null !== $parentBlockId);
if (\array_key_exists($parentBlockId, $blockClones)) {
- $output->writeln(sprintf(
+ $output->writeln(\sprintf(
'new block parent: % 4s - % 4s',
$block->getId() ?? '',
$blockClones[$parentBlockId]->getId() ?? ''
@@ -189,12 +189,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
*/
private function listAllSites(OutputInterface $output): void
{
- $output->writeln(sprintf(' % 5s - % -30s - %s', 'ID', 'Name', 'Url'));
+ $output->writeln(\sprintf(' % 5s - % -30s - %s', 'ID', 'Name', 'Url'));
$sites = $this->siteManager->findAll();
foreach ($sites as $site) {
- $output->writeln(sprintf(
+ $output->writeln(\sprintf(
' % 5s - % -30s - %s',
$site->getId() ?? '',
$site->getName() ?? '',
diff --git a/src/Command/CreateBlockContainerCommand.php b/src/Command/CreateBlockContainerCommand.php
index 0e16b4715..444bde717 100644
--- a/src/Command/CreateBlockContainerCommand.php
+++ b/src/Command/CreateBlockContainerCommand.php
@@ -31,7 +31,7 @@ final class CreateBlockContainerCommand extends Command
{
public function __construct(
private PageManagerInterface $pageManager,
- private BlockInteractorInterface $blockInteractor
+ private BlockInteractorInterface $blockInteractor,
) {
parent::__construct();
}
@@ -55,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
]);
foreach ($pages as $page) {
- $output->writeln(sprintf('Adding to page %s', $page->getName() ?? ''));
+ $output->writeln(\sprintf('Adding to page %s', $page->getName() ?? ''));
$block = $this->blockInteractor->createNewContainer([
'name' => $input->getArgument('blockName'),
@@ -69,7 +69,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$pageManager->save($page);
}
- $output->writeln(sprintf(
+ $output->writeln(\sprintf(
'Don\'t forget to add block %s into your sonata_page.yml',
$blockCode
));
diff --git a/src/Command/CreateSiteCommand.php b/src/Command/CreateSiteCommand.php
index d62189938..f397ecd25 100644
--- a/src/Command/CreateSiteCommand.php
+++ b/src/Command/CreateSiteCommand.php
@@ -71,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$values[$name] = $input->getOption($name);
while (null === $values[$name]) {
- $question = new Question(sprintf('Please define a value for Site.%s : ', $name));
+ $question = new Question(\sprintf('Please define a value for Site.%s : ', $name));
$values[$name] = $helper->ask($input, $output, $question);
}
}
@@ -120,8 +120,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'Site created!',
'',
'You can now create the related pages and snapshots by running the followings commands:',
- sprintf(' bin/console sonata:page:update-core-routes --site=%s', $site->getId() ?? ''),
- sprintf(' bin/console sonata:page:create-snapshots --site=%s', $site->getId() ?? ''),
+ \sprintf(' bin/console sonata:page:update-core-routes --site=%s', $site->getId() ?? ''),
+ \sprintf(' bin/console sonata:page:create-snapshots --site=%s', $site->getId() ?? ''),
]);
} else {
$output->writeln('Site creation cancelled!');
diff --git a/src/Command/CreateSnapshotsCommand.php b/src/Command/CreateSnapshotsCommand.php
index f6f993d5d..e049ff912 100644
--- a/src/Command/CreateSnapshotsCommand.php
+++ b/src/Command/CreateSnapshotsCommand.php
@@ -32,7 +32,7 @@ final class CreateSnapshotsCommand extends Command
{
public function __construct(
private CreateSnapshotBySiteInterface $createSnapshot,
- private SiteManagerInterface $siteManager
+ private SiteManagerInterface $siteManager,
) {
parent::__construct();
}
@@ -48,7 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$siteOption = $input->getOption('site');
foreach ($this->getSites($siteOption) as $site) {
- $output->write(sprintf('%s - Generating snapshots ...', $site->getName() ?? ''));
+ $output->write(\sprintf('%s - Generating snapshots ...', $site->getName() ?? ''));
$this->createSnapshot->createBySite($site);
$output->writeln(' done!');
diff --git a/src/Command/UpdateCoreRoutesCommand.php b/src/Command/UpdateCoreRoutesCommand.php
index 72954e392..a5e1340f6 100644
--- a/src/Command/UpdateCoreRoutesCommand.php
+++ b/src/Command/UpdateCoreRoutesCommand.php
@@ -32,7 +32,7 @@ final class UpdateCoreRoutesCommand extends Command
{
public function __construct(
private SiteManagerInterface $siteManager,
- private RoutePageGenerator $pageGenerator
+ private RoutePageGenerator $pageGenerator,
) {
parent::__construct();
}
diff --git a/src/Controller/BlockAdminController.php b/src/Controller/BlockAdminController.php
index 58eb904d9..b12dffe9d 100644
--- a/src/Controller/BlockAdminController.php
+++ b/src/Controller/BlockAdminController.php
@@ -127,13 +127,13 @@ public function switchParentAction(Request $request): Response
$block = $this->admin->getObject($blockId);
if (null === $block) {
- throw new BadRequestHttpException(sprintf('Unable to find block with id: "%s"', $blockId));
+ throw new BadRequestHttpException(\sprintf('Unable to find block with id: "%s"', $blockId));
}
$parent = $this->admin->getObject($parentId);
if (null === $parent) {
- throw new BadRequestHttpException(sprintf('Unable to find parent block with id: "%s"', $parentId));
+ throw new BadRequestHttpException(\sprintf('Unable to find parent block with id: "%s"', $parentId));
}
$this->admin->checkAccess('switchParent', $block);
diff --git a/src/Controller/PageAdminController.php b/src/Controller/PageAdminController.php
index 173613995..309205c23 100644
--- a/src/Controller/PageAdminController.php
+++ b/src/Controller/PageAdminController.php
@@ -183,11 +183,11 @@ public function composeAction(Request $request): Response
$id = $request->get($this->admin->getIdParameter());
$page = $this->admin->getObject($id);
if (null === $page) {
- throw new NotFoundHttpException(sprintf('Unable to find the page with id : %s', $id));
+ throw new NotFoundHttpException(\sprintf('Unable to find the page with id : %s', $id));
}
$templateCode = $page->getTemplateCode();
if (null === $templateCode) {
- throw new NotFoundHttpException(sprintf('The page with id "%s" has no template code', $id));
+ throw new NotFoundHttpException(\sprintf('The page with id "%s" has no template code', $id));
}
$containers = [];
@@ -198,7 +198,7 @@ public function composeAction(Request $request): Response
\assert($templateManager instanceof TemplateManagerInterface);
$template = $templateManager->get($templateCode);
if (null === $template) {
- throw new NotFoundHttpException(sprintf('Unable to find the template with code : %s', $templateCode));
+ throw new NotFoundHttpException(\sprintf('Unable to find the template with code : %s', $templateCode));
}
$templateContainers = $template->getContainers();
@@ -270,7 +270,7 @@ public function composeContainerShowAction(Request $request): Response
$id = $request->get($this->admin->getIdParameter());
$block = $blockAdmin->getObject($id);
if (!$block instanceof PageBlockInterface) {
- throw new NotFoundHttpException(sprintf('Unable to find the block with id : %s', $id));
+ throw new NotFoundHttpException(\sprintf('Unable to find the block with id : %s', $id));
}
$blockManager = $this->container->get('sonata.block.manager');
@@ -292,7 +292,7 @@ public function composeContainerShowAction(Request $request): Response
if (null !== $page && null !== $blockCode) {
$templateCode = $page->getTemplateCode();
if (null === $templateCode) {
- throw new NotFoundHttpException(sprintf('The page with id "%s" has no template code', $id));
+ throw new NotFoundHttpException(\sprintf('The page with id "%s" has no template code', $id));
}
$templateManager = $this->container->get('sonata.page.template_manager');
@@ -301,7 +301,7 @@ public function composeContainerShowAction(Request $request): Response
$template = $templateManager->get($templateCode);
if (null === $template) {
throw new NotFoundHttpException(
- sprintf('Unable to find the template with code : %s', $templateCode)
+ \sprintf('Unable to find the template with code : %s', $templateCode)
);
}
$container = $template->getContainer($blockCode);
diff --git a/src/Controller/PageController.php b/src/Controller/PageController.php
index a82b76b87..c18ffcb4e 100644
--- a/src/Controller/PageController.php
+++ b/src/Controller/PageController.php
@@ -31,7 +31,7 @@ final class PageController extends AbstractController
public function __construct(
private ExceptionListener $exceptionListener,
private PageServiceManagerInterface $pageServiceManager,
- private CmsManagerSelectorInterface $cmsSelector
+ private CmsManagerSelectorInterface $cmsSelector,
) {
}
@@ -57,7 +57,7 @@ public function exceptionEdit(Request $request, int $code): Response
$cms = $this->cmsSelector->retrieve();
if (!$this->exceptionListener->hasErrorCode($code)) {
- throw new InternalErrorException(sprintf('The error code "%s" is not set in the configuration', $code));
+ throw new InternalErrorException(\sprintf('The error code "%s" is not set in the configuration', $code));
}
try {
diff --git a/src/Controller/SiteAdminController.php b/src/Controller/SiteAdminController.php
index 7c52261c9..8adb3be39 100644
--- a/src/Controller/SiteAdminController.php
+++ b/src/Controller/SiteAdminController.php
@@ -57,7 +57,7 @@ public function snapshotsAction(Request $request): Response
$object = $this->admin->getObject($id);
if (null === $object) {
- throw new NotFoundHttpException(sprintf('Unable to find the object with id : %s', $id));
+ throw new NotFoundHttpException(\sprintf('Unable to find the object with id : %s', $id));
}
$this->admin->setSubject($object);
diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php
index 6b464bc93..db60afb6b 100644
--- a/src/DependencyInjection/Configuration.php
+++ b/src/DependencyInjection/Configuration.php
@@ -25,7 +25,7 @@
final class Configuration implements ConfigurationInterface
{
/**
- * @psalm-suppress PossiblyNullReference, UndefinedInterfaceMethod
+ * @psalm-suppress UndefinedInterfaceMethod
*
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
*/
@@ -188,7 +188,7 @@ public function getConfigTreeBuilder(): TreeBuilder
$inherits = $template['inherits_containers'];
if (!isset($templates[$inherits])) {
throw new InvalidConfigurationException(
- sprintf('Template "%s" cannot inherit containers from undefined template "%s"', $id, $inherits)
+ \sprintf('Template "%s" cannot inherit containers from undefined template "%s"', $id, $inherits)
);
}
$template['containers'] = array_merge($templates[$inherits]['containers'], $template['containers']);
@@ -197,7 +197,7 @@ public function getConfigTreeBuilder(): TreeBuilder
foreach ($template['containers'] as $containerKey => $container) {
if (!isset($template['matrix'][$containerKey])) {
throw new InvalidConfigurationException(
- sprintf('No area defined in matrix for template container "%s"', $containerKey)
+ \sprintf('No area defined in matrix for template container "%s"', $containerKey)
);
}
}
@@ -205,7 +205,7 @@ public function getConfigTreeBuilder(): TreeBuilder
foreach ($template['matrix'] as $containerKey => $config) {
if (!isset($template['containers'][$containerKey])) {
throw new InvalidConfigurationException(
- sprintf('No container defined for matrix area "%s"', $containerKey)
+ \sprintf('No container defined for matrix area "%s"', $containerKey)
);
}
$template['containers'][$containerKey]['placement'] = $config;
diff --git a/src/DependencyInjection/SonataPageExtension.php b/src/DependencyInjection/SonataPageExtension.php
index f5d58272c..dc5aee9e5 100644
--- a/src/DependencyInjection/SonataPageExtension.php
+++ b/src/DependencyInjection/SonataPageExtension.php
@@ -231,7 +231,7 @@ private function configureExceptions(ContainerBuilder $container, array $config)
$exceptions = [];
foreach ($config['catch_exceptions'] as $keyWord => $codes) {
foreach ($codes as $code) {
- $exceptions[$code] = sprintf('_page_internal_error_%s', $keyWord);
+ $exceptions[$code] = \sprintf('_page_internal_error_%s', $keyWord);
}
}
diff --git a/src/Entity/BlockInteractor.php b/src/Entity/BlockInteractor.php
index 8e3731b2c..033f6b49e 100644
--- a/src/Entity/BlockInteractor.php
+++ b/src/Entity/BlockInteractor.php
@@ -32,7 +32,7 @@ final class BlockInteractor implements BlockInteractorInterface
public function __construct(
private ManagerRegistry $registry,
- private BlockManagerInterface $blockManager
+ private BlockManagerInterface $blockManager,
) {
}
@@ -52,7 +52,7 @@ public function getBlock($id): ?PageBlockInterface
public function getBlocksById(PageInterface $page): array
{
$blocks = $this->getEntityManager()
- ->createQuery(sprintf('SELECT b FROM %s b INDEX BY b.id WHERE b.page = :page ORDER BY b.position ASC', $this->blockManager->getClass()))
+ ->createQuery(\sprintf('SELECT b FROM %s b INDEX BY b.id WHERE b.page = :page ORDER BY b.position ASC', $this->blockManager->getClass()))
->setParameter('page', $page->getId())
->execute();
diff --git a/src/Entity/BlockManager.php b/src/Entity/BlockManager.php
index 901046287..48a5776e3 100644
--- a/src/Entity/BlockManager.php
+++ b/src/Entity/BlockManager.php
@@ -29,7 +29,7 @@ public function updatePosition($id, int $position): PageBlockInterface
$block = $this->find($id);
if (null === $block) {
- throw new \RuntimeException(sprintf('Unable to update position to block with id %s', $id));
+ throw new \RuntimeException(\sprintf('Unable to update position to block with id %s', $id));
}
$block->setPosition($position);
diff --git a/src/Entity/PageManager.php b/src/Entity/PageManager.php
index ed4255345..5cb54b798 100644
--- a/src/Entity/PageManager.php
+++ b/src/Entity/PageManager.php
@@ -37,7 +37,7 @@ public function __construct(
ManagerRegistry $registry,
private SlugifyInterface $slugify,
private array $defaults = [],
- private array $pageDefaults = []
+ private array $pageDefaults = [],
) {
parent::__construct($class, $registry);
}
@@ -136,7 +136,7 @@ public function loadPages(SiteInterface $site): array
/** @var array */
$pages = $this->getEntityManager()
- ->createQuery(sprintf('SELECT p FROM %s p INDEX BY p.id WHERE p.site = %d ORDER BY p.position ASC', $this->class, $siteId))
+ ->createQuery(\sprintf('SELECT p FROM %s p INDEX BY p.id WHERE p.site = %d ORDER BY p.position ASC', $this->class, $siteId))
->execute();
foreach ($pages as $page) {
diff --git a/src/Entity/SnapshotManager.php b/src/Entity/SnapshotManager.php
index ce5756def..4eb3a6a2f 100644
--- a/src/Entity/SnapshotManager.php
+++ b/src/Entity/SnapshotManager.php
@@ -36,7 +36,7 @@ final class SnapshotManager extends BaseEntityManager implements SnapshotManager
public function __construct(
string $class,
ManagerRegistry $registry,
- private SnapshotPageProxyFactoryInterface $snapshotPageProxyFactory
+ private SnapshotPageProxyFactoryInterface $snapshotPageProxyFactory,
) {
parent::__construct($class, $registry);
}
@@ -124,7 +124,7 @@ public function cleanup(PageInterface $page, int $keep): int
$expr = $innerQb->expr();
// try a better Function expression for this?
- $ifNullExpr = sprintf(
+ $ifNullExpr = \sprintf(
'CASE WHEN %s THEN 1 ELSE 0 END',
$expr->isNull('i.publicationDateEnd')
);
diff --git a/src/Entity/Transformer.php b/src/Entity/Transformer.php
index 662d6a86d..cd46bffda 100644
--- a/src/Entity/Transformer.php
+++ b/src/Entity/Transformer.php
@@ -56,11 +56,11 @@ public function __construct(
private PageManagerInterface $pageManager,
private ManagerInterface $blockManager,
private ManagerRegistry $registry,
- private ?SerializerInterface $serializer = null
+ private ?SerializerInterface $serializer = null,
) {
// NEXT_MAJOR: Remove null support
if (null === $this->serializer) {
- @trigger_error(sprintf(
+ @trigger_error(\sprintf(
'Not passing an instance of %s as 5th parameter is deprecated since version 4.x and will be removed in 5.0.',
SerializerInterface::class
), \E_USER_DEPRECATED);
@@ -82,7 +82,7 @@ public function create(PageInterface $page, ?SnapshotInterface $snapshot = null)
$snapshot->setDecorate($page->getDecorate());
if (null === $page->getSite()) {
- throw new \RuntimeException(sprintf('No site linked to the page.id=%s', $page->getId() ?? ''));
+ throw new \RuntimeException(\sprintf('No site linked to the page.id=%s', $page->getId() ?? ''));
}
$snapshot->setSite($page->getSite());
diff --git a/src/Listener/ExceptionListener.php b/src/Listener/ExceptionListener.php
index 71775d78d..44ee80767 100644
--- a/src/Listener/ExceptionListener.php
+++ b/src/Listener/ExceptionListener.php
@@ -46,7 +46,7 @@ public function __construct(
private DecoratorStrategyInterface $decoratorStrategy,
private array $httpErrorCodes,
?LoggerInterface $logger = null,
- private bool $status = false
+ private bool $status = false,
) {
$this->logger = $logger ?? new NullLogger();
}
@@ -71,7 +71,7 @@ public function hasErrorCode(int $statusCode): bool
public function getErrorCodePage(int $statusCode): PageInterface
{
if (!$this->hasErrorCode($statusCode)) {
- throw new InternalErrorException(sprintf('There is not page configured to handle the status code %d', $statusCode));
+ throw new InternalErrorException(\sprintf('There is not page configured to handle the status code %d', $statusCode));
}
$cms = $this->cmsManagerSelector->retrieve();
@@ -162,7 +162,7 @@ private function handleNativeError(ExceptionEvent $event): void
return;
}
- $message = sprintf('%s: %s (uncaught exception) at %s line %s', $exception::class, $exception->getMessage(), $exception->getFile(), $exception->getLine());
+ $message = \sprintf('%s: %s (uncaught exception) at %s line %s', $exception::class, $exception->getMessage(), $exception->getFile(), $exception->getLine());
$this->logException($exception, $exception, $message);
@@ -201,7 +201,7 @@ private function handleNativeError(ExceptionEvent $event): void
private function logException(\Throwable $originalException, \Throwable $generatedException, ?string $message = null): void
{
if (null === $message) {
- $message = sprintf('Exception thrown when handling an exception (%s: %s)', $generatedException::class, $generatedException->getMessage());
+ $message = \sprintf('Exception thrown when handling an exception (%s: %s)', $generatedException::class, $generatedException->getMessage());
}
if (!$originalException instanceof HttpExceptionInterface || $originalException->getStatusCode() >= 500) {
diff --git a/src/Listener/RequestListener.php b/src/Listener/RequestListener.php
index 7f64550e0..7ec3ec3fb 100644
--- a/src/Listener/RequestListener.php
+++ b/src/Listener/RequestListener.php
@@ -32,7 +32,7 @@ final class RequestListener
public function __construct(
private CmsManagerSelectorInterface $cmsSelector,
private SiteSelectorInterface $siteSelector,
- private DecoratorStrategyInterface $decoratorStrategy
+ private DecoratorStrategyInterface $decoratorStrategy,
) {
}
@@ -63,14 +63,14 @@ public function onCoreRequest(RequestEvent $event): void
$locale = $site->getLocale();
if (null !== $locale && $locale !== $request->get('_locale')) {
- throw new PageNotFoundException(sprintf('Invalid locale - site.locale=%s - request._locale=%s', $locale, $request->get('_locale')));
+ throw new PageNotFoundException(\sprintf('Invalid locale - site.locale=%s - request._locale=%s', $locale, $request->get('_locale')));
}
try {
$page = $cms->getPageByRouteName($site, $request->get('_route'));
if (!$page->getEnabled() && !$this->cmsSelector->isEditor()) {
- throw new PageNotFoundException(sprintf('The page is not enabled : id=%s', $page->getId() ?? ''));
+ throw new PageNotFoundException(\sprintf('The page is not enabled : id=%s', $page->getId() ?? ''));
}
$cms->setCurrentPage($page);
diff --git a/src/Listener/ResponseListener.php b/src/Listener/ResponseListener.php
index 579991bdf..87ffab147 100644
--- a/src/Listener/ResponseListener.php
+++ b/src/Listener/ResponseListener.php
@@ -35,7 +35,7 @@ public function __construct(
private PageServiceManagerInterface $pageServiceManager,
private DecoratorStrategyInterface $decoratorStrategy,
private Environment $twig,
- private bool $skipRedirection
+ private bool $skipRedirection,
) {
}
diff --git a/src/Model/Page.php b/src/Model/Page.php
index dca62bbeb..2f58364d3 100755
--- a/src/Model/Page.php
+++ b/src/Model/Page.php
@@ -568,7 +568,7 @@ private function getHeadersAsString(array $headers): string
$rawHeaders = [];
foreach ($headers as $name => $header) {
- $rawHeaders[] = sprintf('%s: %s', trim($name), trim($header));
+ $rawHeaders[] = \sprintf('%s: %s', trim($name), trim($header));
}
$rawHeaders = implode("\r\n", $rawHeaders);
diff --git a/src/Model/Site.php b/src/Model/Site.php
index 6e2a9dbdc..c90adbba3 100644
--- a/src/Model/Site.php
+++ b/src/Model/Site.php
@@ -195,7 +195,7 @@ public function getUrl(): ?string
return $this->getRelativePath();
}
- return sprintf('//%s%s', $this->getHost() ?? '', $this->getRelativePath() ?? '');
+ return \sprintf('//%s%s', $this->getHost() ?? '', $this->getRelativePath() ?? '');
}
public function isEnabled(): bool
diff --git a/src/Model/SnapshotChildrenCollection.php b/src/Model/SnapshotChildrenCollection.php
index cba3aa96f..b54c33d54 100644
--- a/src/Model/SnapshotChildrenCollection.php
+++ b/src/Model/SnapshotChildrenCollection.php
@@ -28,7 +28,7 @@ final class SnapshotChildrenCollection extends AbstractLazyCollection
{
public function __construct(
private TransformerInterface $transformer,
- private PageInterface $page
+ private PageInterface $page,
) {
}
diff --git a/src/Model/SnapshotPageProxy.php b/src/Model/SnapshotPageProxy.php
index aaf7a4eef..a989fec7a 100644
--- a/src/Model/SnapshotPageProxy.php
+++ b/src/Model/SnapshotPageProxy.php
@@ -30,7 +30,7 @@ final class SnapshotPageProxy implements SnapshotPageProxyInterface
public function __construct(
private SnapshotManagerInterface $manager,
private TransformerInterface $transformer,
- private SnapshotInterface $snapshot
+ private SnapshotInterface $snapshot,
) {
}
diff --git a/src/Model/SnapshotPageProxyFactory.php b/src/Model/SnapshotPageProxyFactory.php
index 0da8b1cdd..5e9ab7881 100644
--- a/src/Model/SnapshotPageProxyFactory.php
+++ b/src/Model/SnapshotPageProxyFactory.php
@@ -25,7 +25,7 @@ public function __construct(private string $snapshotPageProxyClass)
public function create(
SnapshotManagerInterface $manager,
TransformerInterface $transformer,
- SnapshotInterface $snapshot
+ SnapshotInterface $snapshot,
): SnapshotPageProxyInterface {
return new $this->snapshotPageProxyClass($manager, $transformer, $snapshot);
}
diff --git a/src/Model/Template.php b/src/Model/Template.php
index 1eb1fdeda..4cbbbc9a3 100644
--- a/src/Model/Template.php
+++ b/src/Model/Template.php
@@ -52,7 +52,7 @@ final class Template
public function __construct(
private string $name,
private string $path,
- array $containers = []
+ array $containers = [],
) {
foreach ($containers as $code => $container) {
$this->containers[$code] = $this->normalize($container);
diff --git a/src/Page/PageServiceManager.php b/src/Page/PageServiceManager.php
index 13a057563..7487707b1 100644
--- a/src/Page/PageServiceManager.php
+++ b/src/Page/PageServiceManager.php
@@ -48,7 +48,7 @@ public function get($type): PageServiceInterface
if (!isset($this->services[$type])) {
if (null === $this->default) {
- throw new \RuntimeException(sprintf('unable to find a default service for type "%s"', $type ?? ''));
+ throw new \RuntimeException(\sprintf('unable to find a default service for type "%s"', $type ?? ''));
}
return $this->default;
diff --git a/src/Page/Service/DefaultPageService.php b/src/Page/Service/DefaultPageService.php
index 7d21b2a03..e4f5ae2e1 100644
--- a/src/Page/Service/DefaultPageService.php
+++ b/src/Page/Service/DefaultPageService.php
@@ -27,7 +27,7 @@ final class DefaultPageService extends BasePageService
public function __construct(
string $name,
private TemplateManagerInterface $templateManager,
- private ?SeoPageInterface $seoPage = null
+ private ?SeoPageInterface $seoPage = null,
) {
parent::__construct($name);
}
@@ -36,7 +36,7 @@ public function execute(
PageInterface $page,
Request $request,
array $parameters = [],
- ?Response $response = null
+ ?Response $response = null,
): Response {
$this->updateSeoPage($page);
diff --git a/src/Page/TemplateManager.php b/src/Page/TemplateManager.php
index eaaf61a04..8fffaa889 100644
--- a/src/Page/TemplateManager.php
+++ b/src/Page/TemplateManager.php
@@ -39,7 +39,7 @@ final class TemplateManager implements TemplateManagerInterface
*/
public function __construct(
private Environment $twig,
- private array $defaultParameters = []
+ private array $defaultParameters = [],
) {
}
diff --git a/src/Request/RequestFactory.php b/src/Request/RequestFactory.php
index 650a53e7e..33490d7d7 100644
--- a/src/Request/RequestFactory.php
+++ b/src/Request/RequestFactory.php
@@ -49,9 +49,9 @@ public static function create(
array $cookies = [],
array $files = [],
array $server = [],
- $content = null
+ $content = null,
): Request {
- @trigger_error(sprintf(
+ @trigger_error(\sprintf(
'The method "%s()" is deprecated since sonata-project/page-bundle 4.7.0 and will be removed in 5.0.'
.' Use "%s::%s()" instead.',
__METHOD__,
@@ -69,7 +69,7 @@ public static function create(
*/
public static function createFromGlobals(string $type): Request
{
- @trigger_error(sprintf(
+ @trigger_error(\sprintf(
'The method "%s()" is deprecated since sonata-project/page-bundle 4.7.0 and will be removed in 5.0.'
.' Use "%s::%s()" instead.',
__METHOD__,
@@ -99,7 +99,7 @@ private static function configureFactory(string $type): void
array $cookies = [],
array $files = [],
array $server = [],
- $content = null
+ $content = null,
) => new SiteRequest($query, $request, $attributes, $cookies, $files, $server, $content)
);
}
diff --git a/src/Request/SiteRequestContext.php b/src/Request/SiteRequestContext.php
index e4131a5d2..c0ad87c8e 100644
--- a/src/Request/SiteRequestContext.php
+++ b/src/Request/SiteRequestContext.php
@@ -31,7 +31,7 @@ public function __construct(
string $host = 'localhost',
string $scheme = 'http',
int $httpPort = 80,
- int $httpsPort = 443
+ int $httpsPort = 443,
) {
parent::__construct($baseUrl, $method, $host, $scheme, $httpPort, $httpsPort);
}
diff --git a/src/Route/CmsPageRouter.php b/src/Route/CmsPageRouter.php
index 120d789b3..7d7908b28 100644
--- a/src/Route/CmsPageRouter.php
+++ b/src/Route/CmsPageRouter.php
@@ -33,7 +33,7 @@ public function __construct(
private RequestContext $context,
private CmsManagerSelectorInterface $cmsSelector,
private SiteSelectorInterface $siteSelector,
- private RouterInterface $router
+ private RouterInterface $router,
) {
}
@@ -179,7 +179,7 @@ private function generateFromPage(PageInterface $page, array $parameters = [], i
$url = $page->getUrl();
if (null === $url) {
- throw new \RuntimeException(sprintf('Page "%d" has no url.', $page->getId() ?? ''));
+ throw new \RuntimeException(\sprintf('Page "%d" has no url.', $page->getId() ?? ''));
}
if (!$this->context instanceof SiteRequestContextInterface) {
@@ -226,23 +226,23 @@ private function decorateUrl(string $url, array $parameters = [], int $reference
if (self::ABSOLUTE_URL === $referenceType || self::NETWORK_PATH === $referenceType) {
$port = '';
if ('http' === $this->context->getScheme() && 80 !== $this->context->getHttpPort()) {
- $port = sprintf(':%s', $this->context->getHttpPort());
+ $port = \sprintf(':%s', $this->context->getHttpPort());
} elseif ('https' === $this->context->getScheme() && 443 !== $this->context->getHttpsPort()) {
- $port = sprintf(':%s', $this->context->getHttpsPort());
+ $port = \sprintf(':%s', $this->context->getHttpsPort());
}
- $schemeAuthority = self::NETWORK_PATH === $referenceType ? '//' : sprintf('%s://', $this->context->getScheme());
- $schemeAuthority = sprintf('%s%s%s', $schemeAuthority, $this->context->getHost(), $port);
+ $schemeAuthority = self::NETWORK_PATH === $referenceType ? '//' : \sprintf('%s://', $this->context->getScheme());
+ $schemeAuthority = \sprintf('%s%s%s', $schemeAuthority, $this->context->getHost(), $port);
}
if (self::RELATIVE_PATH === $referenceType) {
$url = $this->getRelativePath($this->context->getPathInfo(), $url);
} else {
- $url = sprintf('%s%s%s', $schemeAuthority, $this->context->getBaseUrl(), $url);
+ $url = \sprintf('%s%s%s', $schemeAuthority, $this->context->getBaseUrl(), $url);
}
if (\count($parameters) > 0) {
- return sprintf('%s?%s', $url, http_build_query($parameters, '', '&'));
+ return \sprintf('%s?%s', $url, http_build_query($parameters, '', '&'));
}
return $url;
diff --git a/src/Route/RoutePageGenerator.php b/src/Route/RoutePageGenerator.php
index fde520e6c..f39f6e6dc 100644
--- a/src/Route/RoutePageGenerator.php
+++ b/src/Route/RoutePageGenerator.php
@@ -30,13 +30,13 @@ public function __construct(
private RouterInterface $router,
private PageManagerInterface $pageManager,
private DecoratorStrategyInterface $decoratorStrategy,
- private ExceptionListener $exceptionListener
+ private ExceptionListener $exceptionListener,
) {
}
public function update(SiteInterface $site, ?OutputInterface $output = null, bool $clean = false): void
{
- $message = sprintf(
+ $message = \sprintf(
' > Updating core routes for site : %s - %s',
$site->getName() ?? '',
$site->getUrl() ?? ''
@@ -86,7 +86,7 @@ public function update(SiteInterface $site, ?OutputInterface $output = null, boo
if (null !== $page) {
$page->setEnabled(false);
- $this->writeln($output, sprintf(
+ $this->writeln($output, \sprintf(
' DISABLE % -50s %s',
$name,
$route->getPath()
@@ -121,7 +121,7 @@ public function update(SiteInterface $site, ?OutputInterface $output = null, boo
$this->pageManager->save($page);
- $this->writeln($output, sprintf(
+ $this->writeln($output, \sprintf(
' %s % -50s %s',
$update ? 'UPDATE ' : 'CREATE ',
$name,
@@ -149,7 +149,7 @@ public function update(SiteInterface $site, ?OutputInterface $output = null, boo
'site' => $site,
]);
- $this->writeln($output, sprintf(' %s % -50s %s', 'CREATE ', $name, ''));
+ $this->writeln($output, \sprintf(' %s % -50s %s', 'CREATE ', $name, ''));
}
// an internal page or an error page should not have any parent (no direct access)
@@ -174,9 +174,9 @@ public function update(SiteInterface $site, ?OutputInterface $output = null, boo
if ($clean) {
$this->pageManager->delete($page);
- $this->writeln($output, sprintf(' REMOVED %s', $page->getRouteName() ?? ''));
+ $this->writeln($output, \sprintf(' REMOVED %s', $page->getRouteName() ?? ''));
} else {
- $this->writeln($output, sprintf(' ERROR %s', $page->getRouteName() ?? ''));
+ $this->writeln($output, \sprintf(' ERROR %s', $page->getRouteName() ?? ''));
}
}
}
diff --git a/src/Runtime/SonataPagePathRuntime.php b/src/Runtime/SonataPagePathRuntime.php
index d73d05e81..530c2add1 100644
--- a/src/Runtime/SonataPagePathRuntime.php
+++ b/src/Runtime/SonataPagePathRuntime.php
@@ -39,7 +39,7 @@ public function getRunner(?object $application): RunnerInterface
array $cookies = [],
array $files = [],
array $server = [],
- $content = null
+ $content = null,
) => new SiteRequest($query, $request, $attributes, $cookies, $files, $server, $content)
);
diff --git a/src/Serializer/BlockTypeExtractor.php b/src/Serializer/BlockTypeExtractor.php
index 47f80a30c..99d250f36 100644
--- a/src/Serializer/BlockTypeExtractor.php
+++ b/src/Serializer/BlockTypeExtractor.php
@@ -15,7 +15,8 @@
use Sonata\BlockBundle\Model\BlockInterface;
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
-use Symfony\Component\PropertyInfo\Type;
+use Symfony\Component\PropertyInfo\Type as LegacyType;
+use Symfony\Component\TypeInfo\Type;
final class BlockTypeExtractor implements PropertyTypeExtractorInterface
{
@@ -28,14 +29,14 @@ final class BlockTypeExtractor implements PropertyTypeExtractorInterface
* @param class-string $blockClass
*/
public function __construct(
- private string $blockClass
+ private string $blockClass,
) {
}
/**
* @param array $context
*
- * @return Type[]|null
+ * @return LegacyType[]|null
*/
public function getTypes(string $class, string $property, array $context = []): ?array
{
@@ -44,19 +45,40 @@ public function getTypes(string $class, string $property, array $context = []):
}
if ('position' === $property) {
return [
- new Type(Type::BUILTIN_TYPE_INT, true),
- new Type(Type::BUILTIN_TYPE_STRING, true),
+ new LegacyType(LegacyType::BUILTIN_TYPE_INT, true),
+ new LegacyType(LegacyType::BUILTIN_TYPE_STRING, true),
];
}
if ('enabled' === $property) {
return [
- new Type(Type::BUILTIN_TYPE_BOOL, true),
- new Type(Type::BUILTIN_TYPE_INT, true),
- new Type(Type::BUILTIN_TYPE_STRING, true),
+ new LegacyType(LegacyType::BUILTIN_TYPE_BOOL, true),
+ new LegacyType(LegacyType::BUILTIN_TYPE_INT, true),
+ new LegacyType(LegacyType::BUILTIN_TYPE_STRING, true),
];
}
if (\in_array($property, self::NULLABLE_STRINGS, true)) {
- return [new Type(Type::BUILTIN_TYPE_STRING, true)];
+ return [new LegacyType(LegacyType::BUILTIN_TYPE_STRING, true)];
+ }
+
+ return null;
+ }
+
+ /**
+ * @param array $context
+ */
+ public function getType(string $class, string $property, array $context = []): ?Type
+ {
+ if ($class !== $this->blockClass) {
+ return null;
+ }
+ if ('position' === $property) {
+ return Type::nullable(Type::union(Type::int(), Type::string()));
+ }
+ if ('enabled' === $property) {
+ return Type::nullable(Type::union(Type::bool(), Type::int(), Type::string()));
+ }
+ if (\in_array($property, self::NULLABLE_STRINGS, true)) {
+ return Type::nullable(Type::string());
}
return null;
diff --git a/src/Serializer/InterfaceTypeExtractor.php b/src/Serializer/InterfaceTypeExtractor.php
index 40075d4b9..b7f64b6fd 100644
--- a/src/Serializer/InterfaceTypeExtractor.php
+++ b/src/Serializer/InterfaceTypeExtractor.php
@@ -16,7 +16,8 @@
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\PageBundle\Model\PageInterface;
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
-use Symfony\Component\PropertyInfo\Type;
+use Symfony\Component\PropertyInfo\Type as LegacyType;
+use Symfony\Component\TypeInfo\Type;
final class InterfaceTypeExtractor implements PropertyTypeExtractorInterface
{
@@ -26,21 +27,21 @@ final class InterfaceTypeExtractor implements PropertyTypeExtractorInterface
*/
public function __construct(
private string $pageClass,
- private string $blockClass
+ private string $blockClass,
) {
}
/**
* @param array $context
*
- * @return Type[]|null
+ * @return LegacyType[]|null
*/
public function getTypes(string $class, string $property, array $context = []): ?array
{
if ($this->pageClass === $class) {
if ('children' === $property) {
- return [new Type(
- Type::BUILTIN_TYPE_OBJECT,
+ return [new LegacyType(
+ LegacyType::BUILTIN_TYPE_OBJECT,
false,
null,
true,
@@ -49,8 +50,8 @@ public function getTypes(string $class, string $property, array $context = []):
)];
}
if ('blocks' === $property) {
- return [new Type(
- Type::BUILTIN_TYPE_OBJECT,
+ return [new LegacyType(
+ LegacyType::BUILTIN_TYPE_OBJECT,
false,
null,
true,
@@ -63,8 +64,8 @@ public function getTypes(string $class, string $property, array $context = []):
}
} elseif ($this->blockClass === $class) {
if ('children' === $property) {
- return [new Type(
- Type::BUILTIN_TYPE_OBJECT,
+ return [new LegacyType(
+ LegacyType::BUILTIN_TYPE_OBJECT,
false,
null,
true,
@@ -77,13 +78,37 @@ public function getTypes(string $class, string $property, array $context = []):
return null;
}
- private function getPageType(): Type
+ /**
+ * @param array $context
+ */
+ public function getType(string $class, string $property, array $context = []): ?Type
+ {
+ if ($this->pageClass === $class) {
+ if ('children' === $property) {
+ return Type::list(Type::object($this->pageClass));
+ }
+ if ('blocks' === $property) {
+ return Type::list(Type::object($this->blockClass));
+ }
+ if ('parent' === $property) {
+ return Type::object($this->pageClass);
+ }
+ } elseif ($this->blockClass === $class) {
+ if ('children' === $property) {
+ return Type::list(Type::object($this->blockClass));
+ }
+ }
+
+ return null;
+ }
+
+ private function getPageType(): LegacyType
{
- return new Type(Type::BUILTIN_TYPE_OBJECT, false, $this->pageClass);
+ return new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, $this->pageClass);
}
- private function getBlockType(): Type
+ private function getBlockType(): LegacyType
{
- return new Type(Type::BUILTIN_TYPE_OBJECT, false, $this->blockClass);
+ return new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, $this->blockClass);
}
}
diff --git a/src/Service/CleanupSnapshotService.php b/src/Service/CleanupSnapshotService.php
index adfd77cb5..fbacd23a7 100644
--- a/src/Service/CleanupSnapshotService.php
+++ b/src/Service/CleanupSnapshotService.php
@@ -23,7 +23,7 @@ final class CleanupSnapshotService implements CleanupSnapshotBySiteInterface
{
public function __construct(
private SnapshotManagerInterface $snapshotManager,
- private PageManagerInterface $pageManager
+ private PageManagerInterface $pageManager,
) {
}
diff --git a/src/Service/CreateSnapshotService.php b/src/Service/CreateSnapshotService.php
index 08f4c8379..d73a9e75f 100644
--- a/src/Service/CreateSnapshotService.php
+++ b/src/Service/CreateSnapshotService.php
@@ -28,7 +28,7 @@ final class CreateSnapshotService implements CreateSnapshotBySiteInterface, Crea
public function __construct(
private SnapshotManagerInterface $snapshotManager,
private PageManagerInterface $pageManager,
- private TransformerInterface $transformer
+ private TransformerInterface $transformer,
) {
}
diff --git a/src/Site/BaseSiteSelector.php b/src/Site/BaseSiteSelector.php
index a503a6104..accf84696 100644
--- a/src/Site/BaseSiteSelector.php
+++ b/src/Site/BaseSiteSelector.php
@@ -31,7 +31,7 @@ abstract class BaseSiteSelector implements SiteSelectorInterface
public function __construct(
protected SiteManagerInterface $siteManager,
protected DecoratorStrategyInterface $decoratorStrategy,
- protected SeoPageInterface $seoPage
+ protected SeoPageInterface $seoPage,
) {
}
@@ -102,7 +102,7 @@ protected function matchRequest(SiteInterface $site, Request $request)
$relativePath = $site->getRelativePath();
$regex = !\in_array($relativePath, [null, '/'], true) ?
- sprintf('@^(%s)(/.*|$)@', $relativePath) :
+ \sprintf('@^(%s)(/.*|$)@', $relativePath) :
'@^()(/.*|$)@';
if (0 === preg_match($regex, $requestPathInfo, $results)) {
diff --git a/src/Template/Matrix/Parser.php b/src/Template/Matrix/Parser.php
index 55c4b37cf..30a28ade7 100644
--- a/src/Template/Matrix/Parser.php
+++ b/src/Template/Matrix/Parser.php
@@ -56,13 +56,13 @@ public static function parse(string $matrix, array $mapping): array
foreach ($rows as $y => $row) {
if (\strlen($row) !== $colCount && $y > 0) {
- throw new \InvalidArgumentException(sprintf('Invalid template matrix, inconsistent row length, row "%d" should have a length of "%d"', $y, $colCount));
+ throw new \InvalidArgumentException(\sprintf('Invalid template matrix, inconsistent row length, row "%d" should have a length of "%d"', $y, $colCount));
}
$cells = str_split($row);
foreach ($cells as $x => $symbol) {
if (!\array_key_exists($symbol, $mapping)) {
- throw new \InvalidArgumentException(sprintf('Invalid template matrix, no mapping found for symbol "%s"', $symbol));
+ throw new \InvalidArgumentException(\sprintf('Invalid template matrix, no mapping found for symbol "%s"', $symbol));
}
if (!isset($areas[$symbol])) {
$areas[$symbol] = [
diff --git a/src/Twig/Extension/PageExtension.php b/src/Twig/Extension/PageExtension.php
index b91c970fe..96576f0b3 100644
--- a/src/Twig/Extension/PageExtension.php
+++ b/src/Twig/Extension/PageExtension.php
@@ -48,7 +48,7 @@ public function __construct(
RouterInterface $router,
BlockHelper $blockHelper,
RequestStack $requestStack,
- bool $hideDisabledBlocks = false
+ bool $hideDisabledBlocks = false,
) {
$this->pageRuntime = new PageRuntime(
$cmsManagerSelector,
@@ -83,7 +83,7 @@ public function getFunctions(): array
*/
public function breadcrumb(Environment $twig, ?PageInterface $page = null, array $options = []): string
{
- @trigger_error(sprintf(
+ @trigger_error(\sprintf(
'The method "%s()" is deprecated since sonata-project/page-bundle 4.7 and will be removed in 5.0.'
.' Use "%s::%s()" instead.',
__METHOD__,
@@ -99,7 +99,7 @@ public function breadcrumb(Environment $twig, ?PageInterface $page = null, array
*/
public function ajaxUrl(PageBlockInterface $block, array $parameters = [], int $absolute = UrlGeneratorInterface::ABSOLUTE_PATH): string
{
- @trigger_error(sprintf(
+ @trigger_error(\sprintf(
'The method "%s()" is deprecated since sonata-project/page-bundle 4.7 and will be removed in 5.0.'
.' Use "%s::%s()" instead.',
__METHOD__,
@@ -115,7 +115,7 @@ public function ajaxUrl(PageBlockInterface $block, array $parameters = [], int $
*/
public function renderContainer(string $name, string|PageInterface|null $page = null, array $options = []): string
{
- @trigger_error(sprintf(
+ @trigger_error(\sprintf(
'The method "%s()" is deprecated since sonata-project/page-bundle 4.7 and will be removed in 5.0.'
.' Use "%s::%s()" instead.',
__METHOD__,
@@ -131,7 +131,7 @@ public function renderContainer(string $name, string|PageInterface|null $page =
*/
public function renderBlock(PageBlockInterface $block, array $options = []): string
{
- @trigger_error(sprintf(
+ @trigger_error(\sprintf(
'The method "%s()" is deprecated since sonata-project/page-bundle 4.7 and will be removed in 5.0.'
.' Use "%s::%s()" instead.',
__METHOD__,
@@ -151,7 +151,7 @@ public function renderBlock(PageBlockInterface $block, array $options = []): str
*/
public function controller(string $controller, array $attributes = [], array $query = []): ControllerReference
{
- @trigger_error(sprintf(
+ @trigger_error(\sprintf(
'The method "%s()" is deprecated since sonata-project/page-bundle 4.7 and will be removed in 5.0.'
.' Use "%s::%s()" instead.',
__METHOD__,
diff --git a/src/Twig/GlobalVariables.php b/src/Twig/GlobalVariables.php
index 1f56c0881..52d1dbcd3 100644
--- a/src/Twig/GlobalVariables.php
+++ b/src/Twig/GlobalVariables.php
@@ -29,7 +29,7 @@ public function __construct(
private SiteManagerInterface $siteManager,
private CmsManagerSelectorInterface $cmsManagerSelector,
private SiteSelectorInterface $siteSelector,
- private TemplateManagerInterface $templateManager
+ private TemplateManagerInterface $templateManager,
) {
}
diff --git a/src/Twig/PageRuntime.php b/src/Twig/PageRuntime.php
index ed15c3e4e..186cd82ac 100644
--- a/src/Twig/PageRuntime.php
+++ b/src/Twig/PageRuntime.php
@@ -44,7 +44,7 @@ public function __construct(
private RequestStack $requestStack,
// NEXT_MAJOR: Stop supporting null for CmsPageRouter
private ?CmsPageRouter $cmsPageRouter = null,
- private bool $hideDisabledBlocks = false
+ private bool $hideDisabledBlocks = false,
) {
}
diff --git a/tests/App/config/doctrine.yaml b/tests/App/config/doctrine.yaml
index 80835b225..80b626929 100644
--- a/tests/App/config/doctrine.yaml
+++ b/tests/App/config/doctrine.yaml
@@ -1,6 +1,7 @@
doctrine:
dbal:
url: 'sqlite:///%app.base_dir%database.db'
+ use_savepoints: true
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
diff --git a/tests/Entity/SnapshotManagerTest.php b/tests/Entity/SnapshotManagerTest.php
index 8cf4e62c9..d3b96e568 100644
--- a/tests/Entity/SnapshotManagerTest.php
+++ b/tests/Entity/SnapshotManagerTest.php
@@ -182,9 +182,6 @@ public function testCreateSnapshotPageProxy(): void
public function testEnableSnapshotsWhenNoSnapshots(): void
{
- $connection = $this->createMock(Connection::class);
- $connection->expects(static::never())->method('query');
-
$this->entityManager->expects(static::never())->method('persist');
$this->entityManager->expects(static::never())->method('flush');
$this->entityManager->expects(static::never())->method('getConnection');
diff --git a/tests/Functional/Admin/BrowserTest.php b/tests/Functional/Admin/BrowserTest.php
index 4de5c35e2..56b1194d9 100644
--- a/tests/Functional/Admin/BrowserTest.php
+++ b/tests/Functional/Admin/BrowserTest.php
@@ -117,6 +117,6 @@ private function extractUniqId(Form $form): string
parse_str($queryString, $queryParameters);
\assert(\is_string($queryParameters['uniqid']));
- return $queryParameters['uniqid'] ?? '';
+ return $queryParameters['uniqid'];
}
}
diff --git a/tests/Functional/Admin/PageAdminTest.php b/tests/Functional/Admin/PageAdminTest.php
index c23f4fd5c..35a6b0a3c 100644
--- a/tests/Functional/Admin/PageAdminTest.php
+++ b/tests/Functional/Admin/PageAdminTest.php
@@ -274,7 +274,7 @@ private function prepareData(): void
$snapshot->setUrl('/');
$snapshot->setRouteName(PageInterface::PAGE_ROUTE_CMS_NAME);
$snapshot->setEnabled(true);
- $snapshot->setPublicationDateStart(new \DateTimeImmutable());
+ $snapshot->setPublicationDateStart(new \DateTime());
$snapshot->setPage($page);
$snapshot->setSite($site);
diff --git a/tests/Listener/ResponseListenerTest.php b/tests/Listener/ResponseListenerTest.php
index 39eb4814b..b3f6a214a 100644
--- a/tests/Listener/ResponseListenerTest.php
+++ b/tests/Listener/ResponseListenerTest.php
@@ -129,7 +129,7 @@ public function testPageIsDecorable(): void
->method('execute')
->with(static::equalTo($page), static::anything(), ['content' => $content])
->willReturnCallback(static function (PageInterface $page, Request $request, array $params, Response $response) {
- $response->setContent(sprintf('outer "%s" outer', $params['content']));
+ $response->setContent(\sprintf('outer "%s" outer', $params['content']));
return $response;
});
diff --git a/tests/Site/HostPathSiteSelectorTest.php b/tests/Site/HostPathSiteSelectorTest.php
index 33945169f..5c1257bb1 100644
--- a/tests/Site/HostPathSiteSelectorTest.php
+++ b/tests/Site/HostPathSiteSelectorTest.php
@@ -340,6 +340,6 @@ protected function _getFieldValue(object $object, string $fieldName): mixed
return $object->{$fieldName};
}
- throw new NoValueException(sprintf('Unable to retrieve the value of `%s`', $fieldName));
+ throw new NoValueException(\sprintf('Unable to retrieve the value of `%s`', $fieldName));
}
}
diff --git a/tests/Site/HostSiteSelectorTest.php b/tests/Site/HostSiteSelectorTest.php
index 221968b1b..cae6c882a 100644
--- a/tests/Site/HostSiteSelectorTest.php
+++ b/tests/Site/HostSiteSelectorTest.php
@@ -271,6 +271,6 @@ protected function _getFieldValue(object $object, string $fieldName): mixed
return $object->{$fieldName};
}
- throw new NoValueException(sprintf('Unable to retrieve the value of `%s`', $fieldName));
+ throw new NoValueException(\sprintf('Unable to retrieve the value of `%s`', $fieldName));
}
}