Skip to content

Commit 4bc0fd5

Browse files
jrfnlgrogy
authored andcommitted
CS/QA: always import all used classes
1 parent 5208338 commit 4bc0fd5

19 files changed

+77
-46
lines changed

src/Application.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PHP_Parallel_Lint\PhpParallelLint;
44

5+
use Exception;
56
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\InvalidArgumentException;
67
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\ParallelLintException;
78

@@ -65,7 +66,7 @@ public function run()
6566
}
6667
return self::FAILED;
6768

68-
} catch (\Exception $e) {
69+
} catch (Exception $e) {
6970
echo $e->getMessage(), PHP_EOL;
7071
return self::FAILED;
7172
}

src/Blame.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace PHP_Parallel_Lint\PhpParallelLint;
44

5+
use JsonSerializable;
56
use ReturnTypeWillChange;
67

7-
class Blame implements \JsonSerializable
8+
class Blame implements JsonSerializable
89
{
910
public $name;
1011

src/Errors/ParallelLintError.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace PHP_Parallel_Lint\PhpParallelLint\Errors;
44

5+
use JsonSerializable;
56
use ReturnTypeWillChange;
67

7-
class ParallelLintError implements \JsonSerializable
8+
class ParallelLintError implements JsonSerializable
89
{
910
/** @var string */
1011
protected $filePath;

src/Exceptions/ParallelLintException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace PHP_Parallel_Lint\PhpParallelLint\Exceptions;
44

5+
use Exception;
6+
use JsonSerializable;
57
use ReturnTypeWillChange;
68

7-
class ParallelLintException extends \Exception implements \JsonSerializable
9+
class ParallelLintException extends Exception implements JsonSerializable
810
{
911
#[ReturnTypeWillChange]
1012
public function jsonSerialize()

src/Iterators/ArrayIterator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace PHP_Parallel_Lint\PhpParallelLint\Iterators;
44

5-
class ArrayIterator extends \ArrayIterator
5+
use ArrayIterator as PHPArrayIterator;
6+
7+
class ArrayIterator extends PHPArrayIterator
68
{
79
public function getNext()
810
{

src/Iterators/RecursiveDirectoryFilterIterator.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22

33
namespace PHP_Parallel_Lint\PhpParallelLint\Iterators;
44

5+
use RecursiveDirectoryIterator;
6+
use RecursiveFilterIterator;
57
use ReturnTypeWillChange;
8+
use SplFileInfo;
69

7-
class RecursiveDirectoryFilterIterator extends \RecursiveFilterIterator
10+
class RecursiveDirectoryFilterIterator extends RecursiveFilterIterator
811
{
9-
/** @var \RecursiveDirectoryIterator */
12+
/** @var RecursiveDirectoryIterator */
1013
private $iterator;
1114

1215
/** @var array */
1316
private $excluded = array();
1417

1518
/**
16-
* @param \RecursiveDirectoryIterator $iterator
19+
* @param RecursiveDirectoryIterator $iterator
1720
* @param array $excluded
1821
*/
19-
public function __construct(\RecursiveDirectoryIterator $iterator, array $excluded)
22+
public function __construct(RecursiveDirectoryIterator $iterator, array $excluded)
2023
{
2124
parent::__construct($iterator);
2225
$this->iterator = $iterator;
@@ -61,7 +64,7 @@ public function hasChildren()
6164
* Return the inner iterator's children contained in a RecursiveFilterIterator
6265
*
6366
* @link http://php.net/manual/en/recursivefilteriterator.getchildren.php
64-
* @return \RecursiveFilterIterator containing the inner iterator's children.
67+
* @return RecursiveFilterIterator containing the inner iterator's children.
6568
*/
6669
#[ReturnTypeWillChange]
6770
public function getChildren()
@@ -81,7 +84,7 @@ private function getPathname($file)
8184
$file = '.' . DIRECTORY_SEPARATOR . $file;
8285
}
8386

84-
$directoryFile = new \SplFileInfo($file);
87+
$directoryFile = new SplFileInfo($file);
8588
return $directoryFile->getPathname();
8689
}
8790

src/Manager.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
namespace PHP_Parallel_Lint\PhpParallelLint;
44

5+
use FilesystemIterator;
56
use PHP_Parallel_Lint\PhpParallelLint\Contracts\SyntaxErrorCallback;
67
use PHP_Parallel_Lint\PhpParallelLint\Errors\SyntaxError;
7-
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\ClassNotFoundException;
8-
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\PathNotFoundException;
98
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\CallbackNotImplementedException;
9+
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\ClassNotFoundException;
1010
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\ParallelLintException;
11+
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\PathNotFoundException;
1112
use PHP_Parallel_Lint\PhpParallelLint\Iterators\RecursiveDirectoryFilterIterator;
1213
use PHP_Parallel_Lint\PhpParallelLint\Outputs\CheckstyleOutput;
1314
use PHP_Parallel_Lint\PhpParallelLint\Outputs\GitLabOutput;
@@ -18,6 +19,9 @@
1819
use PHP_Parallel_Lint\PhpParallelLint\Process\GitBlameProcess;
1920
use PHP_Parallel_Lint\PhpParallelLint\Process\PhpExecutable;
2021
use PHP_Parallel_Lint\PhpParallelLint\Writers\ConsoleWriter;
22+
use RecursiveDirectoryIterator;
23+
use RecursiveIteratorIterator;
24+
use RegexIterator;
2125

2226
class Manager
2327
{
@@ -159,17 +163,17 @@ protected function getFilesFromPaths(array $paths, array $extensions, array $exc
159163
if (is_file($path)) {
160164
$files[] = $path;
161165
} elseif (is_dir($path)) {
162-
$iterator = new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS);
166+
$iterator = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
163167
if (!empty($excluded)) {
164168
$iterator = new RecursiveDirectoryFilterIterator($iterator, $excluded);
165169
}
166-
$iterator = new \RecursiveIteratorIterator(
170+
$iterator = new RecursiveIteratorIterator(
167171
$iterator,
168-
\RecursiveIteratorIterator::LEAVES_ONLY,
169-
\RecursiveIteratorIterator::CATCH_GET_CHILD
172+
RecursiveIteratorIterator::LEAVES_ONLY,
173+
RecursiveIteratorIterator::CATCH_GET_CHILD
170174
);
171175

172-
$iterator = new \RegexIterator($iterator, $regex);
176+
$iterator = new RegexIterator($iterator, $regex);
173177

174178
/** @var \SplFileInfo[] $iterator */
175179
foreach ($iterator as $directoryFile) {

src/Outputs/GitLabOutput.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace PHP_Parallel_Lint\PhpParallelLint\Outputs;
44

5-
use PHP_Parallel_Lint\PhpParallelLint\Outputs\OutputInterface;
65
use PHP_Parallel_Lint\PhpParallelLint\ErrorFormatter;
76
use PHP_Parallel_Lint\PhpParallelLint\Errors\SyntaxError;
87
use PHP_Parallel_Lint\PhpParallelLint\Result;

src/Outputs/TextOutputColored.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@
22

33
namespace PHP_Parallel_Lint\PhpParallelLint\Outputs;
44

5+
use JakubOnderka\PhpConsoleColor\ConsoleColor as OldConsoleColor;
6+
use PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor;
57
use PHP_Parallel_Lint\PhpParallelLint\Settings;
68
use PHP_Parallel_Lint\PhpParallelLint\Writers\WriterInterface;
79

810
class TextOutputColored extends TextOutput
911
{
10-
/** @var \PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor|\JakubOnderka\PhpConsoleColor\ConsoleColor */
12+
/** @var ConsoleColor|OldConsoleColor */
1113
private $colors;
1214

1315
public function __construct(WriterInterface $writer, $colors = Settings::AUTODETECT)
1416
{
1517
parent::__construct($writer);
1618

1719
if (class_exists('\PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor')) {
18-
$this->colors = new \PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor();
20+
$this->colors = new ConsoleColor();
1921
$this->colors->setForceStyle($colors === Settings::FORCED);
2022
} elseif (class_exists('\JakubOnderka\PhpConsoleColor\ConsoleColor')) {
21-
$this->colors = new \JakubOnderka\PhpConsoleColor\ConsoleColor();
23+
$this->colors = new OldConsoleColor();
2224
$this->colors->setForceStyle($colors === Settings::FORCED);
2325
}
2426
}
@@ -31,8 +33,8 @@ public function __construct(WriterInterface $writer, $colors = Settings::AUTODET
3133
public function write($string, $type = self::TYPE_DEFAULT)
3234
{
3335
if (
34-
!$this->colors instanceof \PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor
35-
&& !$this->colors instanceof \JakubOnderka\PhpConsoleColor\ConsoleColor
36+
!$this->colors instanceof ConsoleColor
37+
&& !$this->colors instanceof OldConsoleColor
3638
) {
3739
parent::write($string, $type);
3840
} else {

src/ParallelLint.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PHP_Parallel_Lint\PhpParallelLint;
44

5+
use Exception;
56
use PHP_Parallel_Lint\PhpParallelLint\Contracts\SyntaxErrorCallback;
67
use PHP_Parallel_Lint\PhpParallelLint\Errors\ParallelLintError;
78
use PHP_Parallel_Lint\PhpParallelLint\Errors\SyntaxError;
@@ -46,7 +47,7 @@ public function __construct(PhpExecutable $phpExecutable, $parallelJobs = 10)
4647
/**
4748
* @param array $files
4849
* @return Result
49-
* @throws \Exception
50+
* @throws Exception
5051
*/
5152
public function lint(array $files)
5253
{
@@ -120,13 +121,13 @@ public function lint(array $files)
120121

121122
if ($skipLintProcess->isFail()) {
122123
$message = "Error in skip-linting.php process\nError output: {$skipLintProcess->getErrorOutput()}";
123-
throw new \Exception($message);
124+
throw new Exception($message);
124125
}
125126

126127
foreach ($waiting as $file => $process) {
127128
$skipStatus = $skipLintProcess->isSkipped($file);
128129
if ($skipStatus === null) {
129-
throw new \Exception("File $file has empty skip status. Please contact the author of PHP Parallel Lint.");
130+
throw new Exception("File $file has empty skip status. Please contact the author of PHP Parallel Lint.");
130131

131132
} elseif ($skipStatus === true) {
132133
$skippedFiles[] = $file;

src/Process/GitBlameProcess.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace PHP_Parallel_Lint\PhpParallelLint\Process;
44

5+
use DateInterval;
6+
use DateTime;
7+
use DateTimeZone;
58
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\RuntimeException;
69

710
class GitBlameProcess extends Process
@@ -58,7 +61,7 @@ public function getAuthorEmail()
5861
}
5962

6063
/**
61-
* @return \DateTime
64+
* @return DateTime
6265
* @throws RuntimeException
6366
*/
6467
public function getAuthorTime()
@@ -123,26 +126,26 @@ public static function gitExists($gitExecutable)
123126
*
124127
* @param int $time
125128
* @param string $zone
126-
* @return \DateTime
129+
* @return DateTime
127130
* @throws \Exception
128131
*/
129132
protected function getDateTime($time, $zone)
130133
{
131-
$utcTimeZone = new \DateTimeZone('UTC');
132-
$datetime = \DateTime::createFromFormat('U', $time, $utcTimeZone);
134+
$utcTimeZone = new DateTimeZone('UTC');
135+
$datetime = DateTime::createFromFormat('U', $time, $utcTimeZone);
133136

134137
$way = substr($zone, 0, 1);
135138
$hours = (int) substr($zone, 1, 2);
136139
$minutes = (int) substr($zone, 3, 2);
137140

138-
$interval = new \DateInterval("PT{$hours}H{$minutes}M");
141+
$interval = new DateInterval("PT{$hours}H{$minutes}M");
139142

140143
if ($way === '+') {
141144
$datetime->add($interval);
142145
} else {
143146
$datetime->sub($interval);
144147
}
145148

146-
return new \DateTime($datetime->format('Y-m-d\TH:i:s') . $zone, $utcTimeZone);
149+
return new DateTime($datetime->format('Y-m-d\TH:i:s') . $zone, $utcTimeZone);
147150
}
148151
}

src/Process/LintProcess.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PHP_Parallel_Lint\PhpParallelLint\Process;
44

5+
use InvalidArgumentException;
56
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\ParallelLintException;
67
use PHP_Parallel_Lint\PhpParallelLint\Exceptions\RuntimeException;
78

@@ -27,7 +28,7 @@ class LintProcess extends PhpProcess
2728
public function __construct(PhpExecutable $phpExecutable, $fileToCheck, $aspTags = false, $shortTag = false, $deprecated = false)
2829
{
2930
if (empty($fileToCheck)) {
30-
throw new \InvalidArgumentException("File to check must be set.");
31+
throw new InvalidArgumentException("File to check must be set.");
3132
}
3233

3334
$parameters = array(

src/Result.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
namespace PHP_Parallel_Lint\PhpParallelLint;
44

5+
use JsonSerializable;
56
use PHP_Parallel_Lint\PhpParallelLint\Errors\ParallelLintError;
67
use PHP_Parallel_Lint\PhpParallelLint\Errors\SyntaxError;
78
use ReturnTypeWillChange;
89

9-
class Result implements \JsonSerializable
10+
class Result implements JsonSerializable
1011
{
1112
/** @var ParallelLintError[] */
1213
private $errors;

tests/Manager.run.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ use PHP_Parallel_Lint\PhpParallelLint\Outputs\TextOutput;
1212
use PHP_Parallel_Lint\PhpParallelLint\Settings;
1313
use PHP_Parallel_Lint\PhpParallelLint\Writers\NullWriter;
1414
use Tester\Assert;
15+
use Tester\TestCase;
1516

16-
class ManagerRunTest extends Tester\TestCase
17+
class ManagerRunTest extends TestCase
1718
{
1819
public function testBadPath()
1920
{
@@ -118,7 +119,7 @@ class ManagerRunTest extends Tester\TestCase
118119
}
119120

120121
/**
121-
* @return PHP_Parallel_Lint\PhpParallelLint\Settings
122+
* @return Settings
122123
*/
123124
private function prepareSettings()
124125
{

tests/Output.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ use PHP_Parallel_Lint\PhpParallelLint\Outputs\GitLabOutput;
1515
use PHP_Parallel_Lint\PhpParallelLint\Result;
1616
use PHP_Parallel_Lint\PhpParallelLint\Writers\WriterInterface;
1717
use Tester\Assert;
18+
use Tester\TestCase;
1819

19-
class OutputTest extends Tester\TestCase
20+
class OutputTest extends TestCase
2021
{
2122
/**
2223
* @dataProvider getGitLabOutputData

tests/ParallelLint.lint.phpt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ require_once __DIR__ . '/../src/polyfill.php';
88
require __DIR__ . '/../vendor/autoload.php';
99

1010
use PHP_Parallel_Lint\PhpParallelLint\ParallelLint;
11+
use PHP_Parallel_Lint\PhpParallelLint\Process\PhpExecutable;
1112
use Tester\Assert;
13+
use Tester\Environment;
14+
use Tester\TestCase;
1215

13-
class ParallelLintLintTest extends Tester\TestCase
16+
class ParallelLintLintTest extends TestCase
1417
{
1518
public function testSettersAndGetters()
1619
{
@@ -103,7 +106,7 @@ class ParallelLintLintTest extends Tester\TestCase
103106
Assert::equal(0, count($result->getErrors()));
104107

105108
if (PHP_VERSION_ID < 70000 || PHP_VERSION_ID >= 80000) {
106-
Tester\Environment::skip('test for php version 7.0-7.4');
109+
Environment::skip('test for php version 7.0-7.4');
107110
}
108111

109112
$parallelLint = new ParallelLint($this->getPhpExecutable());
@@ -131,7 +134,7 @@ class ParallelLintLintTest extends Tester\TestCase
131134

132135
private function getPhpExecutable()
133136
{
134-
return \PHP_Parallel_Lint\PhpParallelLint\Process\PhpExecutable::getPhpExecutable('php');
137+
return PhpExecutable::getPhpExecutable('php');
135138
}
136139
}
137140

tests/Settings.parseArguments.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ require __DIR__ . '/../vendor/autoload.php';
99

1010
use PHP_Parallel_Lint\PhpParallelLint\Settings;
1111
use Tester\Assert;
12+
use Tester\TestCase;
1213

13-
class SettingsParseArgumentsTest extends Tester\TestCase
14+
class SettingsParseArgumentsTest extends TestCase
1415
{
1516
public function testNoneArguments()
1617
{

0 commit comments

Comments
 (0)