Skip to content

Math operations with non-numeric strings in PHP8 causes fatal error #3454

@LoranRendel

Description

@LoranRendel

In PHP8 conversion of non-numeric string to number is considered fatal error.

Following example will throw a fatal error:

file.php

$twig = new Environment(new FilesystemLoader(__DIR__));
$twig->display('Page.twig', ['test_var' => 'string']);

template.html.twig

{{ test_var + 1 }}

Result:

Fatal error: Uncaught Error: Unsupported operand types: string + int
in /vendor/twig/twig/src/Environment.php(358) : eval()'d code on line 37

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions