Skip to content

Commit 8673f6a

Browse files
authored
Merge pull request #1234 from PHPCSStandards/feature/config-use-correct-type-for-basepath
Config: use correct type for $basepath
2 parents cb59397 + 5b52cc4 commit 8673f6a

File tree

2 files changed

+47
-45
lines changed

2 files changed

+47
-45
lines changed

src/Config.php

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,46 +23,46 @@
2323
/**
2424
* Stores the configuration used to run PHPCS and PHPCBF.
2525
*
26-
* @property string[] $files The files and directories to check.
27-
* @property string[] $standards The standards being used for checking.
28-
* @property int $verbosity How verbose the output should be.
29-
* 0: no unnecessary output
30-
* 1: basic output for files being checked
31-
* 2: ruleset and file parsing output
32-
* 3: sniff execution output
33-
* @property bool $interactive Enable interactive checking mode.
34-
* @property int $parallel Check files in parallel.
35-
* @property bool $cache Enable the use of the file cache.
36-
* @property string $cacheFile Path to the file where the cache data should be written
37-
* @property bool $colors Display colours in output.
38-
* @property bool $explain Explain the coding standards.
39-
* @property bool $local Process local files in directories only (no recursion).
40-
* @property bool $showSources Show sniff source codes in report output.
41-
* @property bool $showProgress Show basic progress information while running.
42-
* @property bool $quiet Quiet mode; disables progress and verbose output.
43-
* @property bool $annotations Process phpcs: annotations.
44-
* @property int $tabWidth How many spaces each tab is worth.
45-
* @property string $encoding The encoding of the files being checked.
46-
* @property string[] $sniffs The sniffs that should be used for checking.
47-
* If empty, all sniffs in the supplied standards will be used.
48-
* @property string[] $exclude The sniffs that should be excluded from checking.
49-
* If empty, all sniffs in the supplied standards will be used.
50-
* @property string[] $ignored Regular expressions used to ignore files and folders during checking.
51-
* @property string $reportFile A file where the report output should be written.
52-
* @property string $generator The documentation generator to use.
53-
* @property string $filter The filter to use for the run.
54-
* @property string[] $bootstrap One of more files to include before the run begins.
55-
* @property int|string $reportWidth The maximum number of columns that reports should use for output.
56-
* Set to "auto" for have this value changed to the width of the terminal.
57-
* @property int $errorSeverity The minimum severity an error must have to be displayed.
58-
* @property int $warningSeverity The minimum severity a warning must have to be displayed.
59-
* @property bool $recordErrors Record the content of error messages as well as error counts.
60-
* @property string $suffix A suffix to add to fixed files.
61-
* @property string $basepath A file system location to strip from the paths of files shown in reports.
62-
* @property bool $stdin Read content from STDIN instead of supplied files.
63-
* @property string $stdinContent Content passed directly to PHPCS on STDIN.
64-
* @property string $stdinPath The path to use for content passed on STDIN.
65-
* @property bool $trackTime Whether or not to track sniff run time.
26+
* @property string[] $files The files and directories to check.
27+
* @property string[] $standards The standards being used for checking.
28+
* @property int $verbosity How verbose the output should be.
29+
* 0: no unnecessary output
30+
* 1: basic output for files being checked
31+
* 2: ruleset and file parsing output
32+
* 3: sniff execution output
33+
* @property bool $interactive Enable interactive checking mode.
34+
* @property int $parallel Check files in parallel.
35+
* @property bool $cache Enable the use of the file cache.
36+
* @property string $cacheFile Path to the file where the cache data should be written
37+
* @property bool $colors Display colours in output.
38+
* @property bool $explain Explain the coding standards.
39+
* @property bool $local Process local files in directories only (no recursion).
40+
* @property bool $showSources Show sniff source codes in report output.
41+
* @property bool $showProgress Show basic progress information while running.
42+
* @property bool $quiet Quiet mode; disables progress and verbose output.
43+
* @property bool $annotations Process phpcs: annotations.
44+
* @property int $tabWidth How many spaces each tab is worth.
45+
* @property string $encoding The encoding of the files being checked.
46+
* @property string[] $sniffs The sniffs that should be used for checking.
47+
* If empty, all sniffs in the supplied standards will be used.
48+
* @property string[] $exclude The sniffs that should be excluded from checking.
49+
* If empty, all sniffs in the supplied standards will be used.
50+
* @property string[] $ignored Regular expressions used to ignore files and folders during checking.
51+
* @property string $reportFile A file where the report output should be written.
52+
* @property string $generator The documentation generator to use.
53+
* @property string $filter The filter to use for the run.
54+
* @property string[] $bootstrap One of more files to include before the run begins.
55+
* @property int|string $reportWidth The maximum number of columns that reports should use for output.
56+
* Set to "auto" for have this value changed to the width of the terminal.
57+
* @property int $errorSeverity The minimum severity an error must have to be displayed.
58+
* @property int $warningSeverity The minimum severity a warning must have to be displayed.
59+
* @property bool $recordErrors Record the content of error messages as well as error counts.
60+
* @property string $suffix A suffix to add to fixed files.
61+
* @property string|null $basepath A file system location to strip from the paths of files shown in reports.
62+
* @property bool $stdin Read content from STDIN instead of supplied files.
63+
* @property string $stdinContent Content passed directly to PHPCS on STDIN.
64+
* @property string $stdinPath The path to use for content passed on STDIN.
65+
* @property bool $trackTime Whether or not to track sniff run time.
6666
*
6767
* @property array<string, string> $extensions File extensions that should be checked, and what tokenizer to use.
6868
* E.g., array('inc' => 'PHP');
@@ -1057,11 +1057,13 @@ public function processLongArgument($arg, $pos)
10571057
break;
10581058
}
10591059

1060-
$this->basepath = Common::realpath(substr($arg, 9));
1060+
$basepath = Common::realpath(substr($arg, 9));
10611061

10621062
// It may not exist and return false instead.
1063-
if ($this->basepath === false) {
1063+
if ($basepath === false) {
10641064
$this->basepath = substr($arg, 9);
1065+
} else {
1066+
$this->basepath = $basepath;
10651067
}
10661068

10671069
if (is_dir($this->basepath) === false) {

src/Util/Common.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ public static function realpath($path)
135135
/**
136136
* Removes a base path from the front of a file path.
137137
*
138-
* @param string $path The path of the file.
139-
* @param string $basepath The base path to remove. This should not end
140-
* with a directory separator.
138+
* @param string $path The path of the file.
139+
* @param string|null $basepath The base path to remove. This should not end
140+
* with a directory separator.
141141
*
142142
* @return string
143143
*/

0 commit comments

Comments
 (0)