mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 18:36:53 +00:00
ba5875b57596967e0236a1cf47bf3a48c4b85867
This PR was merged into the 3.x branch.
Discussion
----------
Add more precise types for the registration of safe classes
Safe classes only impact the auto-escaping of the string casting of instance of those classes.
By defining that this method only expects names of stringable classes, it allows static analysis tools to report non-working configurations (for instance for people thinking this would impact the auto-escaping for values returned by getters of a safe class, as in https://github.com/twigphp/Twig/issues/4113 for instance).
The method technically support prefixing the class name with a `\`. Static analyzers would reject such string when checking for `class-string`. However, I think this is fine. Projects wanting to use a SA tool are probably already using the `::class` constant anyway to refer to class names (and otherwise, removing the leading `\` in their string literal is easy)
Commits
-------
8330936415 Add more precise types for the registration of safe classes
…
Twig, the flexible, fast, and secure template language for PHP
==============================================================
Twig is a template language for PHP.
Twig uses a syntax similar to the Django and Jinja template languages which
inspired the Twig runtime environment.
Sponsors
--------
.. raw:: html
<a href="https://docs.blackfire.io/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%