Commit Graph

6819 Commits

Author SHA1 Message Date
Fabien Potencier 3f42d4e41f Merge branch '3.x' into 4.x
* 3.x:
  Fix tests
  Deprecate the spaceless filter
2024-08-26 17:43:29 +02:00
Fabien Potencier 303e3ea9d6 minor #4240 Fix tests (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Fix tests

Commits
-------

2511b658 Fix tests
2024-08-26 17:41:05 +02:00
Fabien Potencier 2511b658da Fix tests 2024-08-26 17:29:01 +02:00
Fabien Potencier 40bd341c29 minor #4234 Use proper node names when they are integers (fabpot)
This PR was merged into the 4.x branch.

Discussion
----------

Use proper node names when they are integers

Commits
-------

cde9e7dc Use proper node names when they are integers
2024-08-26 17:03:05 +02:00
Fabien Potencier 98a8210e25 feature #4236 Deprecate the spaceless filter (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate the spaceless filter

Closes #3576

Deprecate the `spaceless` filter for the following reasons:

* The performance is bad (as the work is done at runtime via a regexp)
* Optimizing the size of an HTML doc server side is "almost never" a good idea (compression is better and enough)
* There are some edge cases where you want to keep some spaces (see #3576)
* Controlling whitespace is possible and fine-grained via the dedicated Twig modifiers on `{{ }}`

If someone find it useful, re-creating it is trivial (`return trim(preg_replace('/>\s+</', '><', $content ?? ''));`),
but with so many caveats and not so many use cases, I think it does not belong to core.

Commits
-------

9fd4c487 Deprecate the spaceless filter
2024-08-26 17:00:09 +02:00
Fabien Potencier 9fd4c487e7 Deprecate the spaceless filter 2024-08-26 16:25:20 +02:00
Fabien Potencier cde9e7dcd4 Use proper node names when they are integers 2024-08-26 09:59:54 +02:00
Fabien Potencier 4696eeba1d Remove deprecated code 2024-08-26 09:30:21 +02:00
Fabien Potencier d1f9097c7b Merge branch '3.x' into 4.x
* 3.x:
  Deprecate some internal methods from Parser
  Move code from ExtendsTokenParser to Parser
  Update Node::__toString() to include the node tag if set
  Fix class name
  Fix error message
2024-08-26 09:28:17 +02:00
Fabien Potencier 727cbe9a39 feature #4232 Deprecate some internal methods from Parser (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate some internal methods from Parser

Commits
-------

9e6c4a6a Deprecate some internal methods from Parser
2024-08-26 09:27:11 +02:00
Fabien Potencier 9e6c4a6ac1 Deprecate some internal methods from Parser 2024-08-26 09:24:03 +02:00
Fabien Potencier a8c5100e45 minor #4230 Move code from ExtendsTokenParser to Parser (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Move code from ExtendsTokenParser to Parser

Commits
-------

cf472760 Move code from ExtendsTokenParser to Parser
2024-08-26 07:57:31 +02:00
Fabien Potencier cf4727606a Move code from ExtendsTokenParser to Parser 2024-08-26 07:56:37 +02:00
Fabien Potencier e2f3435c81 feature #4229 Update Node::__toString() to include the node tag if set (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Update Node::__toString() to include the node tag if set

Commits
-------

157d36ae Update Node::__toString() to include the node tag if set
2024-08-24 17:34:12 +02:00
Fabien Potencier 157d36ae43 Update Node::__toString() to include the node tag if set 2024-08-24 17:28:38 +02:00
Fabien Potencier 4b99692e2a Fix class name 2024-08-24 17:12:56 +02:00
Fabien Potencier 758be4dde3 Fix error message 2024-08-24 12:57:39 +02:00
Fabien Potencier a3e51e4243 Merge branch '3.x' into 4.x
* 3.x:
  Fix code
2024-08-24 10:56:02 +02:00
Fabien Potencier 7173182537 Fix code 2024-08-24 10:55:34 +02:00
Fabien Potencier fc9ec820bf Simplify code 2024-08-24 10:53:54 +02:00
Fabien Potencier 00a766f58e Merge branch '3.x' into 4.x
* 3.x:
  Deprecate returning null from TokenParserInterface::parse()
2024-08-24 10:53:41 +02:00
Fabien Potencier 3a90b86f0a feature #4227 Deprecate returning null from TokenParserInterface::parse() (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate returning null from TokenParserInterface::parse()

Commits
-------

0c751361 Deprecate returning null from TokenParserInterface::parse()
2024-08-24 10:52:38 +02:00
Fabien Potencier 0c75136162 Deprecate returning null from TokenParserInterface::parse() 2024-08-24 10:52:24 +02:00
Fabien Potencier dfd9d0faad Enforce more type hints 2024-08-24 10:51:35 +02:00
Fabien Potencier b858e61ddb Merge branch '3.x' into 4.x
* 3.x:
  Deprecate not passing a BodyNode instance as the body of a ModuleNode constructor
  Update a phpdoc (ModuleNode is final now)
2024-08-24 10:50:41 +02:00
Fabien Potencier 63105a6410 feature #4225 Deprecate not passing a BodyNode instance as the body of a ModuleNode or MacroNode constructor (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate not passing a `BodyNode` instance as the body of a `ModuleNode` or `MacroNode` constructor

Commits
-------

51e93aa1 Deprecate not passing a BodyNode instance as the body of a ModuleNode constructor
2024-08-24 10:50:09 +02:00
Fabien Potencier 51e93aa130 Deprecate not passing a BodyNode instance as the body of a ModuleNode constructor 2024-08-24 10:49:53 +02:00
Fabien Potencier fb46572f94 minor #4224 Update a phpdoc (ModuleNode is final now) (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Update a phpdoc (ModuleNode is final now)

Commits
-------

313303b3 Update a phpdoc (ModuleNode is final now)
2024-08-24 10:48:55 +02:00
Fabien Potencier bca2d993b0 Enforce string|int for Node names in Node 2024-08-24 10:48:28 +02:00
Fabien Potencier de634c0c68 Merge branch '3.x' into 4.x
* 3.x:
  Remove `Template::*_CALL` const optimisations
  Deprecate node names that are not strings or integers
2024-08-24 10:47:05 +02:00
Fabien Potencier 992f637297 feature #4223 Add support for integers in methods of Twig\Node\Node that take a Node name (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Add support for integers in methods of `Twig\Node\Node` that take a Node name

Closes #3811

Commits
-------

1ee4210b Deprecate node names that are not strings or integers
2024-08-24 10:45:55 +02:00
Fabien Potencier 75d888f2e0 minor #4226 Remove Template::*_CALL const optimisations (smnandre)
This PR was merged into the 3.x branch.

Discussion
----------

Remove `Template::*_CALL` const optimisations

* Template::ANY_CALL
* Template::ARRAY_CALL
* Template::METHOD_CALL

Commits
-------

094892aa Remove `Template::*_CALL` const optimisations
2024-08-24 10:11:23 +02:00
Simon André 094892aa3b Remove Template::*_CALL const optimisations
* Template::ANY_CALL
* Template::ARRAY_CALL
* Template::METHOD_CALL
2024-08-24 10:03:24 +02:00
Fabien Potencier 313303b366 Update a phpdoc (ModuleNode is final now) 2024-08-24 09:53:44 +02:00
Fabien Potencier 1ee4210ba9 Deprecate node names that are not strings or integers 2024-08-23 22:35:24 +02:00
Fabien Potencier 7e973202c9 Merge branch '3.x' into 4.x
* 3.x:
  Update docs
2024-08-23 09:26:25 +02:00
Fabien Potencier 86330fb9bc Update docs 2024-08-23 09:26:18 +02:00
Fabien Potencier e5f32d7a2f Fix bad merge 2024-08-23 09:26:00 +02:00
Fabien Potencier 7a4f6ea6ff Update docs 2024-08-23 09:25:12 +02:00
Fabien Potencier 34dce7cd9f Merge branch '3.x' into 4.x
* 3.x:
  Deprecate OptimizerNodeVisitor::OPTIMIZE_TEXT_NODES
2024-08-23 09:25:03 +02:00
Fabien Potencier 1fe2c00fa2 bug #4221 Deprecate OptimizerNodeVisitor::OPTIMIZE_TEXT_NODES (fabpot)
This PR was merged into the 3.x branch.

Discussion
----------

Deprecate OptimizerNodeVisitor::OPTIMIZE_TEXT_NODES

Refs #4146

While trying to debug #4146, I realized that this optimization is not possible as we don't know how nodes are going to be used.

See the script provided in #4146 to reproduce the problem.

`@brandonkelly` Can you confirm that this fixes your problem? Maybe there is also an issue with yield vs echo, but the script provided in the issue runs fine for me after this PR.

Commits
-------

7121673c Deprecate OptimizerNodeVisitor::OPTIMIZE_TEXT_NODES
2024-08-23 09:23:28 +02:00
Fabien Potencier 7121673c9c Deprecate OptimizerNodeVisitor::OPTIMIZE_TEXT_NODES 2024-08-23 09:22:06 +02:00
Fabien Potencier 96e5d65d42 minor #4218 Add private types on 4.x (smnandre)
This PR was squashed before being merged into the 4.x branch.

Discussion
----------

Add private types on 4.x

(WIP but i open to gather early feedback / comments)

Objective: add missing types

- [x] Private properties
- [x] Return type on private methods
- [ ] Argument types on private methods (?not sure)

Maybe "`@internal`" then

Commits
-------

72bbe489 Add private types on 4.x
2024-08-21 20:05:43 +02:00
Simon André 72bbe489e1 Add private types on 4.x 2024-08-21 20:05:41 +02:00
Fabien Potencier 8da936a2e0 feature #4199 Do not hide unnecessary escape characters (ruudk)
This PR was squashed before being merged into the 4.x branch.

Discussion
----------

Do not hide unnecessary escape characters

Follow up of #4176, #4123 and #2712.

Now that we have deprecated unnecessary escape in v3, we can change the behavior in v4.

With this change, unnecessary will no longer be ignored, but handled like any other character.

This allows for writing fully qualified class names like this:
```twig
{{ constant('App\Entity\User::SOME_CONSTANT') }}
```

Instead of having to escape the `\` in v3:
```twig
{{ constant('App\\Entity\\User::SOME_CONSTANT') }}
```

/cc `@fabpot` `@stof`

Commits
-------

53c24bfc Do not hide unnecessary escape characters
2024-08-21 19:42:34 +02:00
Ruud Kamphuis 53c24bfc33 Do not hide unnecessary escape characters 2024-08-21 19:42:26 +02:00
Fabien Potencier 878d2a200a Merge branch '3.x' into 4.x
* 3.x:
  Improve deprecation message
2024-08-21 19:39:57 +02:00
Fabien Potencier e0077a4a6c minor #4219 Improve deprecation message (ruudk)
This PR was merged into the 3.x branch.

Discussion
----------

Improve deprecation message

See https://github.com/twigphp/Twig/pull/4199#discussion_r1723456834

/cc `@stof` `@fabpot`

Commits
-------

90107929 Improve deprecation message
2024-08-21 19:39:46 +02:00
Ruud Kamphuis 90107929da Improve deprecation message
See https://github.com/twigphp/Twig/pull/4199#discussion_r1723456834
2024-08-21 19:36:27 +02:00
Fabien Potencier 2acd9e8d9f Remove obsolete code 2024-08-21 08:21:08 +02:00