mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-17 21:07:18 +00:00
346002452d261aaea09b150c8628b58502ac3673
This PR was squashed before being merged into the 3.x branch (closes #3186).
Discussion
----------
Fix twig compare
On twig 2.x the comparison between two variables was being done using the php operators (<, >, <=..), although on 3.x the function `twig_compare` was introduced and it had some issues
As an example
`'200' > 399` was returning `false` on twig 2.x, but on 3.x it was returning `true`.
Digging into the code I found out the comparison binaries (`GreaterBinary`, `LessBinary`, etc) were doing the wrong comparison, and the function `twig_compare` was also returning an wrong value if both variables had the same type
Now it's following the convention `-1` if first var is less, 0 if they are equal, or 1 if first var is greater
This is my first PR, so please comment if anything is wrong
Commits
-------
0d81c6e5 Fix twig compare
…
Twig, the flexible, fast, and secure template language for PHP
==============================================================
Twig is a template language for PHP, released under the new BSD license (code
and documentation).
Twig uses a syntax similar to the Django and Jinja template languages which
inspired the Twig runtime environment.
Sponsors
--------
.. raw:: html
<a href="https://blackfire.io/docs/introduction?utm_source=twig&utm_medium=github_readme&utm_campaign=logo">
<img src="https://static.blackfire.io/assets/intemporals/logo/png/blackfire-io_secondary_horizontal_transparent.png?1" width="255px" alt="Blackfire.io">
</a>
More Information
----------------
Read the `documentation`_ for more information.
.. _documentation: https://twig.symfony.com/documentation
Description
Languages
PHP
99.9%