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
$ cat temp.php
<?php
class Client extends GuzzleClient implements ClientInterface {
/**
* {@inheritdoc}
*/
public function authenticatedRequest($method = 'GET', $url = null, UserInterface $user, $options = []) {
$duration = isset($options['timeout']) ? $options['timeout'] : NULL;
$options['query']['token'] = $user->acquireToken($duration);
@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 / JSTokenizer.php
Created November 21, 2016 22:02
Using PHP_CodeSniffer to tokenize a JS file
<?php
namespace MyCustomProject;
use PHP_CodeSniffer\Runner;
use PHP_CodeSniffer\Config;
use PHP_CodeSniffer\Files\DummyFile;
// Include the PHPCS autoloader, however you need to.
require_once __DIR__.'/autoload.php';
@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;