phpstan-blade-rule icon indicating copy to clipboard operation
phpstan-blade-rule copied to clipboard

Syntax error, unexpected T_ENDIF on line X

Open micc83 opened this issue 2 years ago • 6 comments

Hi, first of all thank you. I've been waiting to be able to run static analysis on my blade templates since a long time.

Unfortunately on my first try I get only a bunch of syntax errors such as:

 ------ ---------------------------------------------------------------
  Line   Domain/Schedulers/Http/Controllers/SchedulePlanController.php 
 ------ ---------------------------------------------------------------
  217    Syntax error, unexpected T_ENDIF on line 217
 ------ ---------------------------------------------------------------

or

 ------ --------------------------------------------------------------
  Line   Domain/Statistics/Http/Controllers/StatsController.php       
 ------ --------------------------------------------------------------
  6      Syntax error, unexpected T_VARIABLE, expecting ';' on line 6
 ------ --------------------------------------------------------------

What I can tell you is that, for example, SchedulePlanController doesn't even have 217 lines so, I guess, its referring to some issue in some of the blade templates rendered by the controller?

My composer.json is something like:

{
    "require": {
        "php": ">=8.0",
        "laravel/framework": "^8.0",
        "laravel/helpers": "^1.2",
        "laravel/legacy-factories": "^1.1",
        "laravel/ui": "^3.0",
    },
    "require-dev": {
        "canvural/phpstan-blade-rule": "^0.1.0",
        "nunomaduro/larastan": "^1.0",
    },
    "autoload": {
        "classmap": [
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/",
            "Domain\\": "app/Domain/",
            "Common\\": "app/Common/",
            "Database\\Seeders\\": "database/seeders/"
        },
        "files": [
            "app/Common/helpers.php"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    }
}

My phpstan.neon file:

includes:
    - ./vendor/nunomaduro/larastan/extension.neon
    - ./vendor/canvural/phpstan-blade-rule/config/extension.neon
    - ./vendor/symplify/template-phpstan-compiler/config/services.neon
    - ./vendor/symplify/astral/config/services.neon

parameters:

    paths:
        - app/Domain
        - app/Common

    templatePaths:
        - resources/views

    # The level 8 is the highest level
    level: 8

    #ignoreErrors:
    #    - '#Unsafe usage of new static#'

    excludePaths:
        - ./*/*/FileToBeExcluded.php

    checkMissingIterableValueType: false

I've also tried to comment larastan extension but nothing.

micc83 avatar Feb 04 '22 17:02 micc83