antonioribeiro / laravelcs Goto Github PK
View Code? Open in Web Editor NEWLaravel PHP_CodeSniffer
License: BSD 3-Clause "New" or "Revised" License
Laravel PHP_CodeSniffer
License: BSD 3-Clause "New" or "Revised" License
I am using the standard installed globally, but for some reason, it is expecting tabs to indent code instead of the 4 spaces defined in the https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md that is followed by Laravel.
This is the command I am using
phpcs --standard=$HOME/.composer/vendor/pragmarx/laravelcs/Standards/Laravel/ app/Http/Controllers/ParentController.php
See output
Time: 39ms; Memory: 4Mb`
Please improve documentation.
Already install the package but dont know how to use it, when not in global require.
Hi, when I tried to install I got this error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for pragmarx/laravelcs ^0.1.0 -> satisfiable by pragmarx/laravelcs[v0.1.0].
- pragmarx/laravelcs v0.1.0 requires squizlabs/php_codesniffer ~2.0 -> satisfiable by squizlabs/php_codesniffer[2.0.0, 2.0.0RC1, 2.0.0RC2, 2.0.0RC3, 2.0.0RC4, 2.0.0a1, 2.0.0a2, 2.1.0, 2.2.0, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.4.0, 2.5.0, 2.5.1, 2.6.0, 2.6.1, 2.6.2, 2.7.0, 2.7.1, 2.8.0, 2.8.1, 2.9.0, 2.9.1, 2.9.2, 2.9.x-dev] but these conflict with your requirements or minimum-stability.
Installation failed, reverting ./composer.json to its original content.
Now, what do I do?
Hi there:
I am getting a fatal error when attempting to use your standard while running phpcs
from the command line.
Here is the command I'm using:
$ phpcs --standard=Laravel /Users/govinda/Sites/mysite/app/Models/Blog.php
PHP Fatal error: Interface 'PHP_CodeSniffer_Sniff' not found in /Users/govinda/.composer/vendor/pragmarx/laravelcs/Standards/Laravel/Sniffs/ControlStructures/ControlSignatureSniff.php on line 12
PHP Stack trace:
PHP 1. {main}() /Users/govinda/pear/bin/phpcs:0
PHP 2. PHP_CodeSniffer\Runner->runPHPCS() /Users/govinda/pear/bin/phpcs:18
PHP 3. PHP_CodeSniffer\Runner->init() /Users/govinda/pear/share/pear/PHP/CodeSniffer/src/Runner.php:70
PHP 4. PHP_CodeSniffer\Ruleset->__construct($config = *uninitialized*) /Users/govinda/pear/share/pear/PHP/CodeSniffer/src/Runner.php:294
PHP 5. PHP_CodeSniffer\Ruleset->registerSniffs($files = *uninitialized*, $restrictions = *uninitialized*, $exclusions = *uninitialized*) /Users/govinda/pear/share/pear/PHP/CodeSniffer/src/Ruleset.php:215
PHP 6. PHP_CodeSniffer\Autoload::loadFile($path = *uninitialized*) /Users/govinda/pear/share/pear/PHP/CodeSniffer/src/Ruleset.php:1103
PHP 7. include() /Users/govinda/pear/share/pear/PHP/CodeSniffer/autoload.php:167
Fatal error: Interface 'PHP_CodeSniffer_Sniff' not found in /Users/govinda/.composer/vendor/pragmarx/laravelcs/Standards/Laravel/Sniffs/ControlStructures/ControlSignatureSniff.php on line 12
Call Stack:
0.0328 364632 1. {main}() /Users/govinda/pear/bin/phpcs:0
0.0669 519088 2. PHP_CodeSniffer\Runner->runPHPCS() /Users/govinda/pear/bin/phpcs:18
0.1921 872736 3. PHP_CodeSniffer\Runner->init() /Users/govinda/pear/share/pear/PHP/CodeSniffer/src/Runner.php:70
0.2551 1094504 4. PHP_CodeSniffer\Ruleset->__construct(???) /Users/govinda/pear/share/pear/PHP/CodeSniffer/src/Runner.php:294
0.2847 1111192 5. PHP_CodeSniffer\Ruleset->registerSniffs(???, ???, ???) /Users/govinda/pear/share/pear/PHP/CodeSniffer/src/Ruleset.php:215
0.2847 1111192 6. PHP_CodeSniffer\Autoload::loadFile(???) /Users/govinda/pear/share/pear/PHP/CodeSniffer/src/Ruleset.php:1103
0.3235 1150880 7. include('/Users/govinda/.composer/vendor/pragmarx/laravelcs/Standards/Laravel/Sniffs/ControlStructures/ControlSignatureSniff.php') /Users/govinda/pear/share/pear/PHP/CodeSniffer/autoload.php:167
In contrast, phpcs
seems to work fine with PSR2. For example, the following command outputs normally:
$ phpcs --standard=PSR2 /Users/govinda/Sites/mysite/app/Models/Blog.php
FILE: /Users/govinda/Sites/mysite/app/Models/Blog.php
--------------------------------------------------------------------------------------------------------------------------
FOUND 209 ERRORS AND 6 WARNINGS AFFECTING 175 LINES
--------------------------------------------------------------------------------------------------------------------------
14 | ERROR | [x] Opening brace of a class must be on the line after the definition
16 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
...
Some of my system info:
PHP_CodeSniffer version 3.1.1 (stable) by Squiz (http://www.squiz.net)
PEAR Version: 1.10.5
PHP Version: 7.1.8
Zend Engine Version: 3.1.0
Running on: Darwin Govindas-iMac.local 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64
Is this is a namespace issue?
Hello,
Looks like this package is not being maintained. I've found documentation pointing to Laravael 4.2 which uses and old coding standard in comparison con current version 6.0.
It'd be nice to reference this repository for an up to date version of this coding standard ruleset.
https://github.com/emielmolenaar/phpcs-laravel
Regards
As Laravel 5 using PSR-2 , this package is out-of-date.
Is it correct that the following is not correct? (To mungle grammar at this early hour!)
/**
* Comment about a thing.
*/
There is a single space at the beginning of the second two lines, before the asterisks.
When trying to use this standard with PHPCS 3.5.4 and PHP 8.1.5 installed globally on my system, the following error occurs - this error doesn't get triggered when using any other standards:
phpcs: Uncaught Error: Interface "PHP_CodeSniffer_Sniff" not found in .../Standards/Laravel/Sniffs/Tabs/DisallowWhitespaceIndentSniff.php:12
if (true) {
// some code
}
throws an error
53 | ERROR | [x] Expected 1 new line after closing parenthesis; | | found " "
The most recent PHPCS is not supported in this repo, also there are PSR2 clashes with the repo. The current repo does not support PHP 7 return type Hinting, which was fixed in the last year in PHPCS >=3.0.1.
Code example of type hinting.
protected static function buildSeleniumProcess() : Process { //some code here }
Also when using routes file Squiz does not like function closures.
`Route::get('/', function () {
return view('welcome');
<- error here disallow whitespace indent
[tab]});`
<- squiz.whitespace and laravel.tabs disallow whitespace clash.
I installed globally via composer
Getting the error below when I try to run with Laravel Standard
ERROR: the "~/.composer/vendor/pragmarx/laravelcs/Standards/Laravel" coding standard is not installed. The installed coding standards are MySource, PEAR, PHPCS, PSR1, PSR2, Squiz and Zend
Just running phpcs
works fine.
Use of undefined constant T_DOC_XXXXXXXXXX - assumed 'T_DOC_XXXXXX'
I am getting a lot of these errors when running the command. They come from different files located under /vendor/pragmarx/laravelcs/Standards/Laravel/Sniffs/
I am unable to install this globally using composer, because I need to deploy it at build time on a continuous integration server. So, I have added it to the composer.json file for the laravel project.
I call it like this
phpcs --standard=./vendor/pragmarx/laravelcs/Standards/Laravel /path/to/laravel
I am running
PHP 5.5.22-1+deb.sury.org~precise+1 (cli) (built: Feb 20 2015 11:25:27)
Thanks!
Nice! Please add the following to README.md to make Laravel the default standard.
Link (or copy) Laravel into the global CodeSniffer directory.
Mac OSX Homebrew example:
ln -s LaravelCodeSniffer/Standards/Laravel/ /usr/local/etc/php-code-sniffer/Standards/
Set Laravel as default:
phpcs --config-set default_standard Laravel
Details at https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options
AFAIK, this also applies, and simplifies https://github.com/FriendsOfPHP/PHP-CS-Fixer
Just wondering how you can tweak the set of rules to custom them as you want? I found the rules used, but would like to avoid to modify this file, and maybe use a simpler format for your rules (javascript linting or pep8 style)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.