Fabien Potencier 346002452d bug #3186 Fix twig compare (dpinheiro)
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
2019-11-07 22:06:50 +01:00
2019-10-23 17:58:03 +02:00
2019-10-23 17:58:03 +02:00
2019-11-07 22:06:46 +01:00
2019-11-07 22:06:46 +01:00
2019-08-08 18:07:29 +02:00
2019-11-04 15:16:40 +01:00
2019-10-23 17:58:03 +02:00
2019-05-01 15:44:34 +02:00
2019-06-30 14:51:54 +02:00
2019-06-28 17:37:46 +02:00

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
Languages
PHP 99.9%