vscode-blade-formatter icon indicating copy to clipboard operation
vscode-blade-formatter copied to clipboard

[Formatting Bug]: Parse Error : syntax error, unexpected ')', expecting T_AS on line 1 > 1 | <?php foreach($errors->all) ?> | ^

Open itshahin111 opened this issue 1 year ago • 2 comments

Platform

Windows

Template before formatting

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    {{-- Bootstrap cdn --}}
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
    <div class="container d-flex justify-content-center pt-5">
        <div class="col-md-9">
            <h2 class="text-center pb-3 text-danger">
                Add & Remove Clients
            </h2>
            <form action="/post" method="POST">
                @csrf

                @if($errors->any())
                <div class="alert alert-danger">
                    <ul>
                        @foreach($errors->all) as $error)
                        <li>{{$errors}}</li>
                        @endforeach
                    </ul>
                </div>
                @endif

                @if(session()->has('success'))
                <div class="alert alert-success text-center">
                    <p>{{ $request->session()->get('success'); }}</p>
                </div>
                @endif

                <table class="table table-bordered" id="table">
                    <tr>
                        <th>FirstName</th>
                        <th>LastName</th>
                        <th>Email</th>
                        <th>Phone</th>
                        <th>Address</th>
                        <th>Action</th>
                    </tr>
                </table>

                <button type="submit" class="btn btn-primary col-md-2">Save</button>

            </form>
        </div>

    </div>


    {{-- ajax jquery --}}
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js">
        < /body>

        <
        /html>

Template after formatting

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    {{-- Bootstrap cdn --}}
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
    <div class="container d-flex justify-content-center pt-5">
        <div class="col-md-9">
            <h2 class="text-center pb-3 text-danger">
                Add & Remove Clients
            </h2>
            <form action="/post" method="POST">
                @csrf

                @if($errors->any())
                <div class="alert alert-danger">
                    <ul>
                        @foreach($errors->all) as $error)
                        <li>{{$errors}}</li>
                        @endforeach
                    </ul>
                </div>
                @endif

                @if(session()->has('success'))
                <div class="alert alert-success text-center">
                    <p>{{ $request->session()->get('success'); }}</p>
                </div>
                @endif

                <table class="table table-bordered" id="table">
                    <tr>
                        <th>FirstName</th>
                        <th>LastName</th>
                        <th>Email</th>
                        <th>Phone</th>
                        <th>Address</th>
                        <th>Action</th>
                    </tr>
                </table>

                <button type="submit" class="btn btn-primary col-md-2">Save</button>

            </form>
        </div>

    </div>


    {{-- ajax jquery --}}
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js">
        < /body>

        <
        /html>

Expected Behaviour

Document {{-- Bootstrap cdn --}}

Add & Remove Clients

@csrf
            @if($errors->any())
            <div class="alert alert-danger">
                <ul>
                    @foreach($errors->all) as $error)
                    <li>{{$errors}}</li>
                    @endforeach
                </ul>
            </div>
            @endif

            @if(session()->has('success'))
            <div class="alert alert-success text-center">
                <p>{{ $request->session()->get('success'); }}</p>
            </div>
            @endif

            <table class="table table-bordered" id="table">
                <tr>
                    <th>FirstName</th>
                    <th>LastName</th>
                    <th>Email</th>
                    <th>Phone</th>
                    <th>Address</th>
                    <th>Action</th>
                </tr>
            </table>

            <button type="submit" class="btn btn-primary col-md-2">Save</button>

        </form>
    </div>

</div>


{{-- ajax jquery --}}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js">
    < /body>

    <
    /html>

Relevant log output

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    {{-- Bootstrap cdn --}}
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
    <div class="container d-flex justify-content-center pt-5">
        <div class="col-md-9">
            <h2 class="text-center pb-3 text-danger">
                Add & Remove Clients
            </h2>
            <form action="/post" method="POST">
                @csrf

                @if($errors->any())
                <div class="alert alert-danger">
                    <ul>
                        @foreach($errors->all) as $error)
                        <li>{{$errors}}</li>
                        @endforeach
                    </ul>
                </div>
                @endif

                @if(session()->has('success'))
                <div class="alert alert-success text-center">
                    <p>{{ $request->session()->get('success'); }}</p>
                </div>
                @endif

                <table class="table table-bordered" id="table">
                    <tr>
                        <th>FirstName</th>
                        <th>LastName</th>
                        <th>Email</th>
                        <th>Phone</th>
                        <th>Address</th>
                        <th>Action</th>
                    </tr>
                </table>

                <button type="submit" class="btn btn-primary col-md-2">Save</button>

            </form>
        </div>

    </div>


    {{-- ajax jquery --}}
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js">
        < /body>

        <
        /html>

itshahin111 avatar Aug 12 '24 05:08 itshahin111

It seems this section has php syntax error. (unnecessary close parentheses exists)

@foreach($errors->all) as $error)
                        <li>{{$errors}}</li>
                        @endforeach

Expected syntax:

@foreach($errors->all as $error)
                        <li>{{$errors}}</li>
                        @endforeach

shufo avatar Sep 08 '24 13:09 shufo

@shufo I think you're right. I did a search for the syntax error. I've corrected it and it's fine. I think this issue should be closed.

Thank you

Bakugo90 avatar Sep 12 '24 16:09 Bakugo90

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] avatar Nov 12 '24 02:11 github-actions[bot]