Skip to content

Commit f032387

Browse files
author
Sijun Zhu
committed
Merge branch 'master' into finer_forbidden_function_token
2 parents 31329f4 + 2cefc20 commit f032387

File tree

146 files changed

+2437
-417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+2437
-417
lines changed

.travis.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ matrix:
88
- php: 5.4
99
- php: 5.5
1010
- php: 5.5
11-
env: CUSTOM_INI=1
12-
- php: 5.6
13-
- php: 7.0
14-
- php: 7.0
1511
env: CUSTOM_INI=1 XMLLINT=1
1612
addons:
1713
apt:
1814
packages:
1915
- libxml2-utils
16+
- php: 5.6
17+
- php: 7.0
18+
- php: 7.0
19+
env: CUSTOM_INI=1 PEAR_VALIDATE=1
2020
- php: 7.1
2121
- php: 7.2
2222
- php: 7.3
2323
- php: nightly
24+
env: PHPSTAN=1
2425

2526
allow_failures:
2627
- php: nightly
@@ -39,6 +40,7 @@ script:
3940
- phpunit tests/AllTests.php
4041
- if [[ $CUSTOM_INI != "1" ]]; then php bin/phpcs --no-cache --parallel=1; fi
4142
- if [[ $CUSTOM_INI != "1" && $TRAVIS_PHP_VERSION != "nightly" ]]; then pear package-validate package.xml; fi
43+
- if [[ $PEAR_VALIDATE == "1" ]]; then php scripts/validate-pear-package.php; fi
4244
- if [[ $CUSTOM_INI != "1" ]]; then composer validate --no-check-all --strict; fi
4345
- if [[ $CUSTOM_INI != "1" ]]; then php scripts/build-phar.php; fi
4446
- if [[ $CUSTOM_INI != "1" ]]; then php phpcs.phar; fi
@@ -55,3 +57,5 @@ script:
5557
- if [[ $XMLLINT == "1" ]]; then diff -B ./src/Standards/PSR12/ruleset.xml <(xmllint --format "./src/Standards/PSR12/ruleset.xml"); fi
5658
- if [[ $XMLLINT == "1" ]]; then diff -B ./src/Standards/Squiz/ruleset.xml <(xmllint --format "./src/Standards/Squiz/ruleset.xml"); fi
5759
- if [[ $XMLLINT == "1" ]]; then diff -B ./src/Standards/Zend/ruleset.xml <(xmllint --format "./src/Standards/Zend/ruleset.xml"); fi
60+
# Run PHPStan
61+
- if [[ $PHPSTAN == "1" ]]; then composer require --dev phpstan/phpstan && php vendor/bin/phpstan analyse src --level=0 --configuration=phpstan.neon --autoload-file=tests/bootstrap.php; fi

package.xml

Lines changed: 113 additions & 11 deletions
Large diffs are not rendered by default.

phpstan.neon

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '~^Undefined variable: \$phpCodeSnifferConfig$~'
5+
path: %currentWorkingDirectory%/src/Config.php
6+
7+
dynamicConstantNames:
8+
- PHP_CODESNIFFER_IN_TESTS
9+
- PHP_CODESNIFFER_CBF
10+
- PHP_CODESNIFFER_VERBOSITY
11+
12+
excludes_analyse:
13+
- */Tests/*

scripts/ValidatePEAR/FileList.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
/**
3+
* Retrieve a filtered file list.
4+
*
5+
* PHP version 5
6+
*
7+
* @category PHP
8+
* @package PHP_CodeSniffer
9+
* @author Juliette Reinders Folmer <phpcs_nospam@adviesenzo.nl>
10+
* @copyright 2019 Juliette Reinders Folmer. All rights reserved.
11+
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12+
*/
13+
14+
/**
15+
* Class to create a file list with filtering.
16+
*/
17+
class FileList
18+
{
19+
20+
/**
21+
* The path to the project root directory.
22+
*
23+
* @var string
24+
*/
25+
protected $rootPath;
26+
27+
/**
28+
* Recursive directory iterator.
29+
*
30+
* @var \DirectoryIterator
31+
*/
32+
protected $fileIterator;
33+
34+
/**
35+
* Base regex to use if no filter regex is provided.
36+
*
37+
* Matches based on:
38+
* - File path starts with the project root (replacement done in constructor).
39+
* - Don't match .git/ files.
40+
* - Don't match dot files, i.e. "." or "..".
41+
* - Don't match backup files.
42+
* - Match everything else in a case-insensitive manner.
43+
*
44+
* @var string
45+
*/
46+
private $baseRegex = '`^%s(?!\.git/)(?!(.*/)?\.+$)(?!.*\.(bak|orig)).*$`Dix';
47+
48+
49+
/**
50+
* Constructor.
51+
*
52+
* @param string $directory The directory to examine.
53+
* @param string $rootPath Path to the project root.
54+
* @param string $filter PCRE regular expression to filter the file list with.
55+
*/
56+
public function __construct($directory, $rootPath='', $filter='')
57+
{
58+
$this->rootPath = $rootPath;
59+
60+
$directory = new \RecursiveDirectoryIterator(
61+
$directory,
62+
\RecursiveDirectoryIterator::UNIX_PATHS
63+
);
64+
$flattened = new \RecursiveIteratorIterator(
65+
$directory,
66+
\RecursiveIteratorIterator::LEAVES_ONLY,
67+
\RecursiveIteratorIterator::CATCH_GET_CHILD
68+
);
69+
70+
if ($filter === '') {
71+
$filter = sprintf($this->baseRegex, preg_quote($this->rootPath));
72+
}
73+
74+
$this->fileIterator = new \RegexIterator($flattened, $filter);
75+
76+
return $this;
77+
78+
}//end __construct()
79+
80+
81+
/**
82+
* Retrieve the filter file list as an array.
83+
*
84+
* @return array
85+
*/
86+
public function getList()
87+
{
88+
$fileList = [];
89+
90+
foreach ($this->fileIterator as $file) {
91+
$fileList[] = str_replace($this->rootPath, '', $file);
92+
}
93+
94+
return $fileList;
95+
96+
}//end getList()
97+
98+
99+
}//end class

0 commit comments

Comments
 (0)