Skip to content

@instanceof throws fatal error due to documentation example #37

@codepuncher

Description

@codepuncher

This code:

@instanceof($latest_posts_query, 'WP_Query')
  {!! \App\pagination($latest_posts_query) !!}
@endinstanceof

Renders this code:

<?php if ($latest_posts_query instanceof 'WP_Query') : ?>
  <?php echo \App\pagination($latest_posts_query); ?>

<?php endif; ?>

With the error of Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: syntax error, unexpected ''WP_Query'' (T_CONSTANT_ENCAPSED_STRING).

The documentation of this directive suggests passing the class name as a string but in fact, should be the actual instance object.

Simply removing the quotes around the second argument will fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions