Resolve this error for Laravel migration file: Each class must be in a namespace of at least one level
Asked Answered
W

1

9

How to resolve this phpcs error? It shows up for the class Keyword in all Laravel migrations files. The error message is:

Each class must be in a namespace of at least one level (a top-level vendor name) phpcs

enter image description here

What answered 25/12, 2018 at 3:54 Comment(0)
S
14

You can do it several different ways:

First, you can put this at the top of your file:

// phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace

Second, you can use:

// @codingStandardsIgnoreLine

Just before your class declaration.

Hope any one of these will work for you. If the problem still persists please let me know about this.

Silberman answered 25/12, 2018 at 4:7 Comment(2)
Added to phpcs.xml as below and worked <rule ref="PSR1"><exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" /></rule>Sosthena
is there a way by not disable it? the actual wayKeddah

© 2022 - 2024 — McMap. All rights reserved.