[ErrorHandler] Fix rendered exception code highlighting on PHP 8.3

by @tscni

Some issues have been detected in this pull request

Issues that can be fixed by applying a patch

Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:

curl https://fabbot.io/patch/symfony/symfony/57355/2b46e2a6527bc1348d684a29335d6a75f0006eae/cs.diff | patch -p0
diff -ru src/Symfony/Bridge/Twig/Extension/CodeExtension.php src/Symfony/Bridge/Twig/Extension/CodeExtension.php
--- src/Symfony/Bridge/Twig/Extension/CodeExtension.php	2024-06-09 19:01:47.714460371 +0000
+++ src/Symfony/Bridge/Twig/Extension/CodeExtension.php	2024-06-09 19:01:51.151580615 +0000
@@ -36,9 +36,6 @@
         $this->charset = $charset;
     }
 
-    /**
-     * {@inheritdoc}
-     */
     public function getFilters(): array
     {
         return [
diff -ru src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php
--- src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php	2024-06-09 19:01:47.928467857 +0000
+++ src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php	2024-06-09 19:01:53.458661327 +0000
@@ -65,9 +65,6 @@
         $this->logger = $logger;
     }
 
-    /**
-     * {@inheritdoc}
-     */
     public function render(\Throwable $exception): FlattenException
     {
         $headers = ['Content-Type' => 'text/html; charset='.$this->charset];
@@ -207,7 +204,7 @@
     {
         $file = str_replace('\\', '/', $file);
 
-        if (null !== $this->projectDir && 0 === strpos($file, $this->projectDir)) {
+        if (null !== $this->projectDir && str_starts_with($file, $this->projectDir)) {
             return ltrim(substr($file, \strlen($this->projectDir)), '/');
         }
 
@@ -332,7 +329,7 @@
 
     private function formatLogMessage(string $message, array $context)
     {
-        if ($context && false !== strpos($message, '{')) {
+        if ($context && str_contains($message, '{')) {
             $replacements = [];
             foreach ($context as $key => $val) {
                 if (\is_scalar($val)) {

0
Common Typos

0
License Headers

0
Pull Request Contributor Headers

0
File Permissions

0
Merge Commits

0
Exception Messages Formatting

0
Usage of void in test files

0
Use ::class whenever possible

0
Deprecation Messages