Currently, the PHPDoc states that a string should be returned, but that's not correct.
It can be anything that is echo-able.
That means any scalar, Stringable and even null.
This PR was merged into the 3.x branch.
Discussion
----------
Improve exception expectations reliability
This PR moves exception expectations the closest possible to the line intended to throw. It improves reliability of tests ensuring that the right code is throwing the expected exception and not something else (resulting in false-positive). This has been done many times across Symfony code base.
Commits
-------
797e4903 Improve exception expectations reliability
This PR was merged into the 3.x branch.
Discussion
----------
Fix Xdebug detection
The ini setting `xdebug.overload_var_dump` has been removed in Xdebug 3. The `var_dump()` method is now always overloaded if the Xdebug runs in develop mode. I've adjusted our detection logic accordingly.
Since our minimum PHP version is 8.0 now, we can stop caring about Xdebug 2 which has never received a PHP 8 compatible release.
Commits
-------
1e87185d Fix Xdebug detection
This PR was merged into the 3.x branch.
Discussion
----------
Fix tests that don't perform assertions
The method `doesNotPerformAssertions()` is a getter that tells us if the current test is expected to perform assertions. I think the method that the author _wanted_ to call is `expectNotToPerformAssertions()` which tells PHPUnit not to complain if the current test does not perform any assertions.
Commits
-------
db22abfa Fix tests that don't perform assertions
This PR was merged into the 3.x branch.
Discussion
----------
Prepare IntegrationTestCase for static data providers
Data providers need to be static in PHPUnit 11. Because of this, I'd like to declare the two methods we use as data providers in `IntegrationTestCase` as static in 4.0. This PR prepares that change:
* The non-static `getFixturesDir()` method is replaced with a static `getFixturesDirectory()`.
* Both methods `getTests()` and `getLegacyTests()` are marked as final, so we can declare them static in the next major.
This however means that we're delaying PHPUnit 11 compatibility of integration tests to Twig 4.0. If that's too late for us, we could deprecate the whole `IntegrationTestCase` in favor of a compatible replacement. That's a bigger change, but I would work on it if you think it's worth it.
Commits
-------
18f42038 Prepare IntegrationTestCase for static data providers
This PR was merged into the 3.x branch.
Discussion
----------
Validate the input of CoreExtension::map()
Fixes https://github.com/twigphp/Twig/pull/4269#discussion_r1742182828
As discovered in #4269, we have a test that checks if the map filter fails if we pass a non-iterable value. However, this test relies on an active error handler that throws on PHP warnings.
This PR adds input validation the the `map()` function like we can already find it in similar functions.
Commits
-------
a035204a Validate the input of CoreExtension::map()
This PR was merged into the 3.x branch.
Discussion
----------
Make data providers static
Data providers must be static in PHPUnit 11. This PR fixes all the low hanging fruit.
Commits
-------
6ddb76bb Make data providers static
This PR was merged into the 3.x branch.
Discussion
----------
Rename AbstractTest to ProfilerTestCase
PHPUnit 11 doesn't allow abstract test classes to have the suffix "Test". This PR renames a class that violates that rule.
Commits
-------
fc20997c Rename AbstractTest to ProfilerTestCase
This PR was merged into the 3.x branch.
Discussion
----------
Migrate NodeTestCase to static data providers
PHPUnit 11 requires data providers to be static. This PR prepares our abstract `NodeTestCase` by deprecating the non-static `getTests()` and adding a static `provideTests()` as a replacement. I've also added PHPUnit attributes which newer PHPUnit releases prefer over PHPDoc annotations.
Commits
-------
f555a33c Migrate NodeTestCase to static data providers
This PR was merged into the 3.x branch.
Discussion
----------
Replace `return; yield` with `yield from []`
This has the same effect, but looks less hacky and makes PHPStan happy.
https://phpstan.org/r/df7fcc88-1df8-428e-b675-5dc6965c34d6
Previously this was needed to work properly with output capturing.
/cc `@fabpot` `@nicolas`-grekas
https://3v4l.org/KXste
Commits
-------
09a43a9f Replace `return; yield` with `yield from []`
This PR was merged into the 3.x branch.
Discussion
----------
Fix testExtensionsAreNotInitializedWhenRenderingACompiledTemplate
I stumbled over this test while checking for PHPUnit deprecations. In this case, we need to do something about the `setMethods()` call which has been removed in PHPUnit 11.
However, we add an expectation for a method `initExtensions()` which has been removed a long time ago. So, if that method was actually called, we'd get an error anyway. Expecting this method not to be called feels a little redundant. ~~This basically means, we can run this test against an unmocked `Environment`. But if we do so, the test does not really test what it's supposed to test which is why I decided to remove the whole test.~~
Update: Instead, I'm now registering an extension that throws if we try to initialize it.
Commits
-------
3a4d513f Fix testExtensionsAreNotInitializedWhenRenderingACompiledTemplate
This PR was merged into the 3.x branch.
Discussion
----------
Fix MacroTest
Because of a typo in a variable name, `MacroTest` was never executed. This PR fixes the typo and adjusts the expected compiled PHP code, assuming that the current behavior is correct.
Commits
-------
1e5dea44 Fix MacroTest
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Allow extra extensions to use Twig 4 (on 3.x)
Commits
-------
976cea04 Fix tests
031c7bda Allow extra extensions to use Twig 4
This PR was merged into the 3.x branch.
Discussion
----------
Only unset `_iterated` when there is an `else` node
Same as #4249
Even though PHP does not complain, PHPStan does.
> Cannot unset offset '_iterated' on array{ ... the context values ... }
Since this is compiled code, we can easily produce a bit more valid code in the eyes of PHPStan.
Commits
-------
a16910e1 Only unset `_iterated` when there is an `else` node
Same as #4249
Even though PHP does not complain, PHPStan does.
> Cannot unset offset '_iterated' on array{ ... the context values ... }
Since this is compiled code, we can easily produce a bit more valid code in the eyes of PHPStan.
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Adjust `cycle` implementation
Update code following [#4158](https://github.com/twigphp/Twig/issues/4158)
* return mixed
* trigger when non countable
* type the position argument
Add doc precisions
Commits
-------
7c3c1615 Adjust `cycle` implementation
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Add more types to Template class and compiled templates
Similar to https://github.com/twigphp/Twig/pull/4250.
Commits
-------
7e52a680 Add more types to Template class and compiled templates
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Document how to iterate over a string
Commits
-------
2f8c6218 Fix doc markup
a68804d6 Add an example on how to iterate over a string
This PR was merged into the 3.x branch.
Discussion
----------
Remove NodeCaptureInterface from TypesNode
This was accidentally copied from SetNode
Commits
-------
5e3f9d9f Remove NodeCaptureInterface from TypesNode
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Use CPP in full code base
Commits
-------
28923f42 Use CPP in full code base
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Add types tag
The is a draft implementation for #4165.
Commits
-------
67dabd81 Add types tag
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Add conditional return types to `ensureTraversable`
This way, static analyzers can understand what the output of this call will be.
Commits
-------
956d09bf Add conditional return types to `ensureTraversable`