Skip to content

Commit

Permalink
Bumps phpcs to 3.6.2
Browse files Browse the repository at this point in the history
(see readme_moodle.txt for complete instructions)
  • Loading branch information
stronk7 committed Dec 30, 2021
1 parent e43d72c commit 5458d48
Show file tree
Hide file tree
Showing 303 changed files with 7,897 additions and 870 deletions.
9 changes: 6 additions & 3 deletions phpcs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

PHP_CodeSniffer is a set of two PHP scripts; the main `phpcs` script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second `phpcbf` script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent.

[![Build Status](https://travis-ci.org/squizlabs/PHP_CodeSniffer.svg?branch=phpcs-fixer)](https://travis-ci.org/squizlabs/PHP_CodeSniffer) [![Code consistency](http://squizlabs.github.io/PHP_CodeSniffer/analysis/squizlabs/PHP_CodeSniffer/grade.svg)](http://squizlabs.github.io/PHP_CodeSniffer/analysis/squizlabs/PHP_CodeSniffer) [![Join the chat at https://gitter.im/squizlabs/PHP_CodeSniffer](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/squizlabs/PHP_CodeSniffer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://github.com/squizlabs/PHP_CodeSniffer/workflows/Validate/badge.svg?branch=master)](https://github.com/squizlabs/PHP_CodeSniffer/actions)
[![Build Status](https://github.com/squizlabs/PHP_CodeSniffer/workflows/Test/badge.svg?branch=master)](https://github.com/squizlabs/PHP_CodeSniffer/actions)
[![Code consistency](http://squizlabs.github.io/PHP_CodeSniffer/analysis/squizlabs/PHP_CodeSniffer/grade.svg)](http://squizlabs.github.io/PHP_CodeSniffer/analysis/squizlabs/PHP_CodeSniffer)
[![Join the chat at https://gitter.im/squizlabs/PHP_CodeSniffer](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/squizlabs/PHP_CodeSniffer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## Requirements

Expand Down Expand Up @@ -84,9 +87,9 @@ Or if you wish to check an entire directory you can specify the directory locati

$ phpcs /path/to/code-directory

If you wish to check your code against the PSR-2 coding standard, use the `--standard` command line argument:
If you wish to check your code against the PSR-12 coding standard, use the `--standard` command line argument:

$ phpcs --standard=PSR2 /path/to/code-directory
$ phpcs --standard=PSR12 /path/to/code-directory

If PHP_CodeSniffer finds any coding standard errors, a report will be shown after running the command.

Expand Down
3 changes: 3 additions & 0 deletions phpcs/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ public static function determineLoadedClass($classesBeforeLoad, $classesAfterLoa
$className = null;

$newClasses = array_diff($classesAfterLoad['classes'], $classesBeforeLoad['classes']);
if (PHP_VERSION_ID < 70400) {
$newClasses = array_reverse($newClasses);
}

// Since PHP 7.4 get_declared_classes() does not guarantee any order, making
// it impossible to use order to determine which is the parent an which is the child.
Expand Down
2 changes: 1 addition & 1 deletion phpcs/licence.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ modification, are permitted provided that the following conditions are met:
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Squiz Pty Ltd nor the
* Neither the name of the copyright holder nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

Expand Down
445 changes: 429 additions & 16 deletions phpcs/package.xml

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions phpcs/src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use PHP_CodeSniffer\Exceptions\DeepExitException;
use PHP_CodeSniffer\Exceptions\RuntimeException;
use PHP_CodeSniffer\Util\Common;

/**
* Stores the configuration used to run PHPCS and PHPCBF.
Expand Down Expand Up @@ -79,7 +80,7 @@ class Config
*
* @var string
*/
const VERSION = '3.5.8';
const VERSION = '3.6.2';

/**
* Package stability; either stable, beta or alpha.
Expand Down Expand Up @@ -363,7 +364,7 @@ public function __construct(array $cliArgs=[], $dieOnUnknownArg=true)

$lastDir = $currentDir;
$currentDir = dirname($currentDir);
} while ($currentDir !== '.' && $currentDir !== $lastDir && @is_readable($currentDir) === true);
} while ($currentDir !== '.' && $currentDir !== $lastDir && Common::isReadable($currentDir) === true);
}//end if

if (defined('STDIN') === false
Expand Down Expand Up @@ -459,7 +460,7 @@ public function setCommandLineValues($args)
/**
* Restore default values for all possible command line arguments.
*
* @return array
* @return void
*/
public function restoreDefaults()
{
Expand Down Expand Up @@ -1656,7 +1657,7 @@ public static function getAllConfigData()
return [];
}

if (is_readable($configFile) === false) {
if (Common::isReadable($configFile) === false) {
$error = 'ERROR: Config file '.$configFile.' is not readable'.PHP_EOL.PHP_EOL;
throw new DeepExitException($error, 3);
}
Expand Down
2 changes: 1 addition & 1 deletion phpcs/src/Files/DummyFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct($content, Ruleset $ruleset, Config $config)
// This is done by including: phpcs_input_file: [file path]
// as the first line of content.
$path = 'STDIN';
if ($content !== null) {
if ($content !== '') {
if (substr($content, 0, 17) === 'phpcs_input_file:') {
$eolPos = strpos($content, $this->eolChar);
$filename = trim(substr($content, 17, ($eolPos - 17)));
Expand Down
Loading

0 comments on commit 5458d48

Please sign in to comment.