diff --git a/phpstan-baseline-7.4.neon b/phpstan-baseline-7.4.neon index 2ddba802a3..5e91304dbf 100644 --- a/phpstan-baseline-7.4.neon +++ b/phpstan-baseline-7.4.neon @@ -125,11 +125,6 @@ parameters: count: 1 path: src/bundle/Core/Imagine/PlaceholderProvider/RemoteProvider.php - - - message: "#^Parameter \\#1 \\$str of function trim expects string, string\\|false given\\.$#" - count: 1 - path: src/bundle/Debug/Twig/DebugTemplate.php - - message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|false given\\.$#" count: 1 diff --git a/phpstan-baseline-8.0.neon b/phpstan-baseline-8.0.neon index b6afeaa760..3f17ddcbc5 100644 --- a/phpstan-baseline-8.0.neon +++ b/phpstan-baseline-8.0.neon @@ -125,11 +125,6 @@ parameters: count: 2 path: src/bundle/Core/URLChecker/Handler/HTTPHandler.php - - - message: "#^Parameter \\#1 \\$string of function trim expects string, string\\|false given\\.$#" - count: 1 - path: src/bundle/Debug/Twig/DebugTemplate.php - - message: "#^Parameter \\#1 \\$stream of function fclose expects resource, resource\\|false given\\.$#" count: 1 diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8017126337..0032813488 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -4140,66 +4140,11 @@ parameters: count: 1 path: src/bundle/Debug/DependencyInjection/Compiler/DataCollectorPass.php - - - message: "#^Method Ibexa\\\\Bundle\\\\Debug\\\\DependencyInjection\\\\IbexaDebugExtension\\:\\:load\\(\\) has no return type specified\\.$#" - count: 1 - path: src/bundle/Debug/DependencyInjection/IbexaDebugExtension.php - - - - message: "#^Method Ibexa\\\\Bundle\\\\Debug\\\\DependencyInjection\\\\IbexaDebugExtension\\:\\:prepend\\(\\) has no return type specified\\.$#" - count: 1 - path: src/bundle/Debug/DependencyInjection/IbexaDebugExtension.php - - message: "#^Method Ibexa\\\\Bundle\\\\Debug\\\\IbexaDebugBundle\\:\\:build\\(\\) has no return type specified\\.$#" count: 1 path: src/bundle/Debug/IbexaDebugBundle.php - - - message: "#^Method Ibexa\\\\Bundle\\\\Debug\\\\Twig\\\\DebugTemplate\\:\\:display\\(\\) has parameter \\$blocks with no value type specified in iterable type array\\.$#" - count: 1 - path: src/bundle/Debug/Twig/DebugTemplate.php - - - - message: "#^Method Ibexa\\\\Bundle\\\\Debug\\\\Twig\\\\DebugTemplate\\:\\:display\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/bundle/Debug/Twig/DebugTemplate.php - - - - message: "#^Method Ibexa\\\\Bundle\\\\Debug\\\\Twig\\\\DebugTemplate\\:\\:doDisplay\\(\\) has parameter \\$blocks with no value type specified in iterable type array\\.$#" - count: 1 - path: src/bundle/Debug/Twig/DebugTemplate.php - - - - message: "#^Method Ibexa\\\\Bundle\\\\Debug\\\\Twig\\\\DebugTemplate\\:\\:doDisplay\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#" - count: 1 - path: src/bundle/Debug/Twig/DebugTemplate.php - - - - message: "#^Parameter \\#1 \\$haystack of function stripos expects string, string\\|false\\|null given\\.$#" - count: 1 - path: src/bundle/Debug/Twig/DebugTemplate.php - - - - message: "#^Parameter \\#1 \\$path of function dirname expects string, string\\|false given\\.$#" - count: 1 - path: src/bundle/Debug/Twig/DebugTemplate.php - - - - message: "#^Parameter \\#1 \\$string of function substr expects string, string\\|false\\|null given\\.$#" - count: 2 - path: src/bundle/Debug/Twig/DebugTemplate.php - - - - message: "#^Parameter \\#3 \\$subject of function preg_replace expects array\\|string, string\\|false given\\.$#" - count: 1 - path: src/bundle/Debug/Twig/DebugTemplate.php - - - - message: "#^Property Ibexa\\\\Bundle\\\\Debug\\\\Twig\\\\DebugTemplate\\:\\:\\$fileSystem has no type specified\\.$#" - count: 1 - path: src/bundle/Debug/Twig/DebugTemplate.php - - message: "#^Method Ibexa\\\\Bundle\\\\IO\\\\ApiLoader\\\\HandlerRegistry\\:\\:setHandlersMap\\(\\) has no return type specified\\.$#" count: 1 diff --git a/src/bundle/Debug/DependencyInjection/IbexaDebugExtension.php b/src/bundle/Debug/DependencyInjection/IbexaDebugExtension.php index 6e35f31bb0..418e4a6974 100644 --- a/src/bundle/Debug/DependencyInjection/IbexaDebugExtension.php +++ b/src/bundle/Debug/DependencyInjection/IbexaDebugExtension.php @@ -6,16 +6,21 @@ */ namespace Ibexa\Bundle\Debug\DependencyInjection; -use Ibexa\Bundle\Debug\Twig\DebugTemplate; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -class IbexaDebugExtension extends Extension implements PrependExtensionInterface +/** + * @internal + * @final + */ +class IbexaDebugExtension extends Extension { - public function load(array $configs, ContainerBuilder $container) + /** + * @throws \Exception + */ + public function load(array $configs, ContainerBuilder $container): void { $loader = new Loader\YamlFileLoader( $container, @@ -25,19 +30,6 @@ public function load(array $configs, ContainerBuilder $container) // Base services and services overrides $loader->load('services.yml'); } - - /** - * Sets the twig base template class to this bundle's in order to collect template infos. - */ - public function prepend(ContainerBuilder $container) - { - if ($container->getParameter('kernel.debug')) { - $container->prependExtensionConfig( - 'twig', - ['base_template_class' => DebugTemplate::class] - ); - } - } } class_alias(IbexaDebugExtension::class, 'eZ\Bundle\EzPublishDebugBundle\DependencyInjection\EzPublishDebugExtension'); diff --git a/src/bundle/Debug/Twig/DebugTemplate.php b/src/bundle/Debug/Twig/DebugTemplate.php deleted file mode 100644 index 958602d601..0000000000 --- a/src/bundle/Debug/Twig/DebugTemplate.php +++ /dev/null @@ -1,93 +0,0 @@ -fileSystem = $this->fileSystem ?: new Filesystem(); - - // Bufferize to be able to insert template name as HTML comments if applicable. - // Layout template name will only appear at the end, to avoid potential quirks with old browsers - // when comments appear before doctype declaration. - ob_start(); - parent::display($context, $blocks); - $templateResult = ob_get_clean(); - - $templateName = trim($this->fileSystem->makePathRelative($this->getSourceContext()->getPath(), dirname(getcwd())), '/'); - // Check if template name ends with "html.twig", indicating this is an HTML template. - $isHtmlTemplate = substr($templateName, -strlen('html.twig')) === 'html.twig'; - $templateName = $isHtmlTemplate ? $templateName . ' (' . $this->getSourceContext()->getName() . ')' : $templateName; - - // Display start template comment, if applicable. - if ($isHtmlTemplate) { - if (stripos(trim($templateResult), ']+>)#im', - "$1\n', - $templateResult - ); - } else { - echo "\n\n"; - } - } - - // Display stop template comment after result, if applicable. - if ($isHtmlTemplate) { - $bodyPos = stripos($templateResult, ''); - if ($bodyPos !== false) { - // Add layout template name before , to avoid display quirks in some browsers. - echo substr($templateResult, 0, $bodyPos) - . "\n\n" - . substr($templateResult, $bodyPos); - } else { - echo $templateResult; - echo "\n\n"; - } - } else { - echo $templateResult; - } - } - - public function getTemplateName(): string - { - return ''; - } - - public function getSourceContext(): Source - { - return new Source('', ''); - } - - protected function doDisplay(array $context, array $blocks = []): string - { - return ''; - } - - /** - * @return array - */ - public function getDebugInfo(): array - { - return []; - } -} - -class_alias(DebugTemplate::class, 'eZ\Bundle\EzPublishDebugBundle\Twig\DebugTemplate');