Skip to content

Unused variable in compiled Twig templates #4021

Description

@javiereguiluz

In many compiled templates I see this instruction:

$context = array_intersect_key($context, $_parent) + $_parent;

Problem is that many times that variable at the very end of some method and it's never used:

image

Two quick questions:

  • Is setting this variable needed ... or is this indeed a case of "unused variable" that we should optimize?
  • If it's a truly unused variable ... should we care about it or will PHP itself remove this variable (and avoid computing its value) when optimizing code to generate the bytecode?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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