Skip to content

Possible bug with @includeWhen #18231

@kevinkhill

Description

@kevinkhill
  • Laravel Version: 5.4.15
  • PHP Version: 7.1.1 with Xdebug 2.5.1
  • Database Driver & Version: N/A

Description:

Parse error: syntax error, unexpected ','

Steps To Reproduce:

I added this statement to my view:

@includeWhen($product->isCategorized, 'shared.panels.footer-category-crumbs', ['product' => $product])

which compiles to:

<?php if ($product->isCategorized, 'shared.panels.footer-category-crumbs') echo $__env->make(['product' => $product], array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

I can see that the expression is being split at the wrong comma.

Desired output

<?php if ($product->isCategorized) echo $__env->make('shared.panels.footer-category-crumbs', ['product' => $product], array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

When I put the above corrected line in the compiled view, it works.

To wrap up my findings...

Would this be a better regex to use? (probably not, I hack away at them until they work)

/^([^,]+)\s?,\s?(.*)$/is

This way the expression is split at the first comma, and the correct line of compiled output is produced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions