Commit Graph

6955 Commits

Author SHA1 Message Date
Fabien Potencier fa1c9f0bf9 Merge branch '3.x' into 4.x
* 3.x:
  Remove obsolete code
  Deprecate Environment::mergeGlobals()
  Bump version
  Prepare the 3.13.0 release
  Fix wrong format of `Environment::VERSION_ID` constant
  Fix minor things
  Fix CS
  Fix isset in ForLoopNode
  Fix iterable return type
  Improve exception expectations reliability
2024-09-07 17:03:10 +02:00
Fabien Potencier 9117e9cc90 minor #4285 Remove obsolete code (fabpot)
This PR was merged into the 4.x branch.

Discussion
----------

Remove obsolete code

Commits
-------

8527821b Remove obsolete code
2024-09-07 16:45:29 +02:00
Fabien Potencier 6a76881e05 minor #4284 Remove obsolete code (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Remove obsolete code

Commits
-------

57f6119d Remove obsolete code
2024-09-07 16:45:14 +02:00
Fabien Potencier 7cd4352380 feature #4283 Deprecate Environment::mergeGlobals() (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate Environment::mergeGlobals()

Commits
-------

b86575cf Deprecate Environment::mergeGlobals()
2024-09-07 16:44:43 +02:00
Fabien Potencier 8527821ba3 Remove obsolete code 2024-09-07 14:40:56 +02:00
Fabien Potencier 57f6119d31 Remove obsolete code 2024-09-07 14:36:55 +02:00
Fabien Potencier b86575cfd6 Deprecate Environment::mergeGlobals() 2024-09-07 14:05:02 +02:00
Fabien Potencier e1b64b1937 Bump version 2024-09-07 12:53:18 +02:00
Fabien Potencier afc0eb63dc Prepare the 3.13.0 release v3.13.0 2024-09-07 10:01:12 +02:00
Fabien Potencier f5300784df bug #4281 Fix wrong format of Environment::VERSION_ID constant (emodric)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Fix wrong format of `Environment::VERSION_ID` constant

It seems that format of `Environment::VERSION_ID` constant was (erroneously?) changed with Twig 3.10.0.

Commits
-------

a219d9e7 Fix wrong format of `Environment::VERSION_ID` constant
2024-09-06 13:47:41 +02:00
Edi Modrić a219d9e77f Fix wrong format of Environment::VERSION_ID constant 2024-09-06 13:47:39 +02:00
Fabien Potencier 978f749b43 Fix minor things 2024-09-06 12:58:38 +02:00
Fabien Potencier a7e497af48 minor #4280 Fix isset in ForLoopNode (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Fix isset in ForLoopNode

Even though the code works perfectly fine, PHPStan doesn't understand it.

> Offset 'revindex0' does not exist on array{parent: array{index0: int<1, max>, index: int<2, max>, first: false, revindex0?: int, revindex?: int, length: int<0, max>, last?: bool}.
> Offset 'revindex' does not exist on array{parent: array{index0: int<1, max>, index: int<2, max>, first: false, revindex0: int, revindex?: int, length: int<0, max>, last?: bool}.

Since we want to work with `revindex` and `revindex0`, we can better check for their existence, instead of `length`.

/cc `@stof` `@fabpot`

Commits
-------

2b887e64 Fix isset in ForLoopNode
2024-09-06 12:33:51 +02:00
Fabien Potencier 2ae0c0d38c Fix CS 2024-09-06 12:33:38 +02:00
Ruud Kamphuis 2b887e64d5 Fix isset in ForLoopNode
Even though the code works perfectly fine, PHPStan doesn't understand it.

Since we want to work with `revindex` and `revindex0`, we can better check for their
existence, instead of `length`.
2024-09-06 09:42:11 +02:00
Fabien Potencier b1cdda25c6 minor #4279 Fix iterable return type (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Fix iterable return type

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.

/cc `@stof` `@fabpot`

Commits
-------

4cd8955f Fix iterable return type
2024-09-05 14:08:39 +02:00
Ruud Kamphuis 4cd8955f74 Fix iterable return type
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.
2024-09-05 09:24:38 +02:00
Fabien Potencier 83c5415da5 minor #4277 Improve exception expectations reliability (alexandre-daubois)
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
2024-09-04 16:46:09 +02:00
Alexandre Daubois 797e490356 Improve exception expectations reliability 2024-09-04 15:22:48 +02:00
Fabien Potencier 2a8cf65d25 minor #4269 PHPUnit 11 (derrabus)
This PR was squashed before being merged into the 4.x branch.

Discussion
----------

PHPUnit 11

This PR switches our CI to PHPUnit 11.

TODO:

- [x] #4262
- [x] #4263
- [x] #4264
- [x] #4265
- [x] #4268
- [x] #4266
- [x] #4270
- [x] #4271
- [x] #4272
- [x] #4274

Commits
-------

f2053bbe PHPUnit 11
2024-09-04 12:11:53 +02:00
Alexander M. Turek f2053bbea0 PHPUnit 11 2024-09-04 12:11:51 +02:00
Fabien Potencier 1383c09982 bug #4275 Fix method visibility (derrabus)
This PR was merged into the 4.x branch.

Discussion
----------

Fix method visibility

The method's visibility was accidentally changed to private in 6f885353f3. Since it's a utility function for child classes, it should remain protected.

Commits
-------

6172a42e Fix method visibility
2024-09-04 10:29:33 +02:00
Alexander M. Turek 6172a42e9e Fix method visibility 2024-09-04 10:04:33 +02:00
Fabien Potencier b02a8b5eb5 Merge branch '3.x' into 4.x
* 3.x:
  Fix Xdebug detection
2024-09-04 07:58:13 +02:00
Fabien Potencier fb2663eb69 bug #4267 Fix Xdebug detection (derrabus)
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
2024-09-04 07:57:05 +02:00
Fabien Potencier 6f885353f3 Make NodeTestCase::getEnvironment() final 2024-09-04 07:56:08 +02:00
Fabien Potencier 09d2b155d2 minor #4274 Switch to static data provides for integration tests (derrabus)
This PR was merged into the 4.x branch.

Discussion
----------

Switch to static data provides for integration tests

This change should make our integration test case compatible with PHPUnit 10 and 11. Merging the PR will hopefully give us a green build on #4269. 🤞🏻

Commits
-------

9282dbcc Switch to static data provides for integration tests
2024-09-04 07:55:01 +02:00
Alexander M. Turek 9282dbcc42 Switch to static data provides for integration tests 2024-09-03 23:24:35 +02:00
Fabien Potencier 6f9f7e2d29 Merge branch '3.x' into 4.x
* 3.x:
  Fix tests that don't perform assertions
2024-09-03 22:59:28 +02:00
Fabien Potencier b80ce5eceb minor #4273 Fix tests that don't perform assertions (derrabus)
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
2024-09-03 22:58:49 +02:00
Alexander M. Turek db22abfadf Fix tests that don't perform assertions 2024-09-03 22:51:23 +02:00
Fabien Potencier 65fc44bce5 Remove deprecated code 2024-09-03 22:22:04 +02:00
Fabien Potencier a789eca738 Merge branch '3.x' into 4.x
* 3.x:
  Validate the input of CoreExtension::map()
  Rename AbstractTest to ProfilerTestCase
  Make data providers static
  Prepare IntegrationTestCase for static data providers
2024-09-03 22:20:28 +02:00
Fabien Potencier 722a5fb027 feature #4266 Prepare IntegrationTestCase for static data providers (derrabus)
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
2024-09-03 22:17:35 +02:00
Fabien Potencier e829b26dc8 minor #4272 Validate the input of CoreExtension::map() (derrabus)
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()
2024-09-03 22:14:48 +02:00
Alexander M. Turek a035204afb Validate the input of CoreExtension::map() 2024-09-03 17:18:47 +02:00
Fabien Potencier 3349175e72 minor #4270 Make data providers static (derrabus)
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
2024-09-03 16:53:53 +02:00
Fabien Potencier 3371d6e2b1 minor #4271 Rename AbstractTest to ProfilerTestCase (derrabus)
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
2024-09-03 16:53:09 +02:00
Alexander M. Turek fc20997c9e Rename AbstractTest to ProfilerTestCase 2024-09-03 16:34:13 +02:00
Alexander M. Turek 6ddb76bb76 Make data providers static 2024-09-03 16:32:00 +02:00
Alexander M. Turek 18f4203827 Prepare IntegrationTestCase for static data providers 2024-09-03 15:08:40 +02:00
Fabien Potencier 2f757a3616 Remove deprecated clode 2024-09-03 14:55:56 +02:00
Fabien Potencier fe7bac8989 Merge branch '3.x' into 4.x
* 3.x:
  Migrate NodeTestCase to static data providers
2024-09-03 14:51:02 +02:00
Fabien Potencier dd9af8ec25 feature #4265 Migrate NodeTestCase to static data providers (derrabus)
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
2024-09-03 14:03:04 +02:00
Fabien Potencier b47b03d237 minor #4268 Remove obsolete "requires PHP" annotation (derrabus)
This PR was merged into the 4.x branch.

Discussion
----------

Remove obsolete "requires PHP" annotation

Commits
-------

fe2803d2 Remove obsolete "requires PHP" annotation
2024-09-03 14:00:43 +02:00
Fabien Potencier 50f8b13adf Fix tests 2024-09-03 13:58:52 +02:00
Alexander M. Turek fe2803d245 Remove obsolete "requires PHP" annotation 2024-09-03 13:58:34 +02:00
Fabien Potencier cc1045e4e4 Merge branch '3.x' into 4.x
* 3.x:
  Replace `return; yield` with `yield from []`
  Fix testExtensionsAreNotInitializedWhenRenderingACompiledTemplate
  Fix MacroTest
2024-09-03 13:55:51 +02:00
Alexander M. Turek f555a33caf Migrate NodeTestCase to static data providers 2024-09-03 13:51:42 +02:00
Fabien Potencier f0c337690f minor #4259 Replace return; yield with yield from [] (ruudk)
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 []`
2024-09-03 13:17:04 +02:00