Skip to content

Instantly share code, notes, and snippets.

View gsherwood's full-sized avatar
🤧
Code sniffing

Greg Sherwood gsherwood

🤧
Code sniffing
View GitHub Profile
@gsherwood
gsherwood / InlineControlStructureSniff.php
Created March 23, 2018 08:48
Generic/InlineControlStructure: fixer moves new PHPCS annotations #1932
<?php
/**
* Verifies that inline control statements are not present.
*
* @author Greg Sherwood <gsherwood@squiz.net>
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
*/
namespace PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures;
@gsherwood
gsherwood / 1. temp.php (before fixing)
Created November 4, 2014 00:09
PHPCS/PHPCBF PSR-2 auto-formatting example
<?php
namespace Vendor\Package;
use FooInterface; use BarClass as Bar; use OtherVendor\OtherPackage\BazClass;
class Foo extends Bar implements FooInterface {
public function sampleFunction($a,$b=null) {
if ($a === $b) { bar();
} else if ($a>$b) {
$foo->bar( $arg1 ); }
else {
BazClass::bar($arg2,$arg3 );
@gsherwood
gsherwood / CustomPHPCSRunner.php
Created September 8, 2016 02:21
A custom runner for PHP_CodeSniffer to process a single piece of content
<?php
namespace MyCustomProject;
use PHP_CodeSniffer\Runner;
use PHP_CodeSniffer\Config;
use PHP_CodeSniffer\Reporter;
use PHP_CodeSniffer\Files\DummyFile;
use PHP_CodeSniffer\Util\Timing;
// Include the PHPCS autoloader however you need.
@gsherwood
gsherwood / ruleset.xml
Created December 5, 2014 20:06
PSR2 with tabs instead of spaces
<?xml version="1.0"?>
<ruleset name="MyStandard">
<description>PSR2 with tabs instead of spaces.</description>
<arg name="tab-width" value="4"/>
<rule ref="PSR2">
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
</rule>
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>