Repository: twigphp/Twig (php)

Issue:
The `autoescape` tag escapes already escaped value by the escape filter
According to the [documentation of the autoescape tag](https://twig.symfony.com/doc/3.x/tags/autoescape.html):

> Twig is smart enough to not escape an already escaped value by the [escape](https://twig.symfony.com/doc/3.x/filters/escape.html) filter.

But, when testing TwigPHP, it seems like the `autoescape` tag actually _do_ escape already escaped value by the escape filter:

```twig
{% set br = "<br/>" %}
{% autoescape "css" %}
{{ br|escape('html') }}
{% endautoescape %}
```

> \26 lt\3B br\2F \26 gt\3B 

https://twigfiddle.com/qtyoxi

So, which one is correct: TwigPHP implementation or the documentation?


Pull request:
Be more precise about double-escaping
Closes #3918

Patch:
diff --git a/CHANGELOG b/CHANGELOG
index 2fc4b934..4d0616ce 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,5 @@
 # 3.15.0 (2024-XX-XX)
 
- * Add `Profile::getStartTime()` and `Profile::getEndTime()`
  * Fix "ignore missing" when used on an "embed" tag
  * Fix the possibility to override an aliased block (via use)
  * Add template cache hot reload
diff --git a/doc/tags/autoescape.rst b/doc/tags/autoescape.rst
index 8c621d3a..2708009c 100644
--- a/doc/tags/autoescape.rst
+++ b/doc/tags/autoescape.rst
@@ -41,7 +41,8 @@ Functions returning template data (like :doc:`macros<macro>` and
 .. note::
 
     Twig is smart enough to not escape an already escaped value by the
-    :doc:`escape<../filters/escape>` filter.
+    :doc:`escape<../filters/escape>` filter when the automatic escaping
+    strategy is the same as the one applied by the escape filter.
 
 .. note::
 
diff --git a/src/Profiler/Profile.php b/src/Profiler/Profile.php
index a3c6ee02..2928e164 100644
--- a/src/Profiler/Profile.php
+++ b/src/Profiler/Profile.php
@@ -99,22 +99,6 @@ final class Profile implements \IteratorAggregate, \Serializable
         return isset($this->ends['wt']) && isset($this->starts['wt']) ? $this->ends['wt'] - $this->starts['wt'] : 0;
     }
 
-    /**
-     * Returns the start time in microseconds.
-     */
-    public function getStartTime(): float
-    {
-        return $this->starts['wt'] ?? 0.0;
-    }
-
-    /**
-     * Returns the end time in microseconds.
-     */
-    public function getEndTime(): float
-    {
-        return $this->ends['wt'] ?? 0.0;
-    }
-
     /**
      * Returns the memory usage in bytes.
      */


Test patch:
diff --git a/tests/Profiler/ProfileTest.php b/tests/Profiler/ProfileTest.php
index 8c00e65b..5f41fc9c 100644
--- a/tests/Profiler/ProfileTest.php
+++ b/tests/Profiler/ProfileTest.php
@@ -80,15 +80,6 @@ class ProfileTest extends TestCase
         $this->assertTrue($profile->getDuration() > 0, \sprintf('Expected duration > 0, got: %f', $profile->getDuration()));
     }
 
-    public function testTimeAccessors()
-    {
-        $current = microtime(true);
-        $profile = new Profile();
-
-        $this->assertEqualsWithDelta($current, $profile->getStartTime(), 1);
-        $this->assertSame(0.0, $profile->getEndTime());
-    }
-
     public function testSerialize()
     {
         $profile = new Profile('template', 'type', 'name');