Skip to content

Commit 188ff49

Browse files
authored
Apply CodeSniffer (#273)
1 parent ec1541a commit 188ff49

31 files changed

+123
-113
lines changed

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
/vendor/
1313
/vendor-bin/*/vendor/
1414
/vendor-bin/*/bin/
15-
/.travis/
16-
!/.travis/.gitkeep
17-
!/.travis/secrets.tar.enc
15+
/.phpcs-cache
16+
/phpcs.xml

.travis/.gitkeep

Whitespace-only changes.

.travis/secrets.tar.enc

-5.02 KB
Binary file not shown.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CODE_SNIFFER_FIX=vendor-bin/code-sniffer/vendor/bin/phpcbf
2323
cs: ## Fixes CS
2424
cs: $(CODE_SNIFFER) $(CODE_SNIFFER_FIX)
2525
$(PHPNOGC) $(CODE_SNIFFER_FIX) || true
26-
$(PHPNOGC) $(PHP_CS_FIXER) fix
26+
$(PHPNOGC) $(CODE_SNIFFER)
2727

2828
.PHONY: build
2929
build: ## Build the PHAR

phpcs.xml.dist

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
<arg name="colors"/>
1111
<arg value="ps"/>
1212

13-
<file>fixtures</file>
14-
<exclude-pattern>default_stub\.php</exclude-pattern>
15-
<exclude-pattern>/vendor/</exclude-pattern>
16-
<exclude-pattern>/build/</exclude-pattern>
1713
<file>src</file>
1814
<file>tests</file>
1915

src/Autoload/ScoperAutoloadGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function dump(string $prefix): string
100100
private function createClassAliasStatements(array $whitelistedClasses, bool $hasNamespacedFunctions): array
101101
{
102102
$statements = array_map(
103-
function (string $prefixedClass): string {
103+
static function (string $prefixedClass): string {
104104
return sprintf(
105105
'class_exists(\'%s\');',
106106
$prefixedClass
@@ -118,7 +118,7 @@ function (string $prefixedClass): string {
118118

119119
if ($hasNamespacedFunctions) {
120120
$statements = array_map(
121-
function (string $statement): string {
121+
static function (string $statement): string {
122122
return str_repeat(' ', 4).$statement;
123123
},
124124
$statements
@@ -145,7 +145,7 @@ function (string $statement): string {
145145
private function createFunctionAliasStatements(array $whitelistedFunctions, bool $hasNamespacedFunctions): array
146146
{
147147
$statements = array_map(
148-
function (array $node) use ($hasNamespacedFunctions): string {
148+
static function (array $node) use ($hasNamespacedFunctions): string {
149149
/**
150150
* @var string
151151
* @var string $alias

src/Configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ private static function retrieveFilesFromPaths(array $paths): iterable
499499
$finder->files()
500500
->in($pathsToSearch)
501501
->append($filesToAppend)
502-
->filter(function (SplFileInfo $fileInfo): ?bool {
502+
->filter(static function (SplFileInfo $fileInfo): ?bool {
503503
if ($fileInfo->isLink()) {
504504
return false;
505505
}
@@ -521,7 +521,7 @@ private static function retrieveFilesWithContents(Iterator $files): array
521521
{
522522
return array_reduce(
523523
iterator_to_array($files),
524-
function (array $files, SplFileInfo $fileInfo): array {
524+
static function (array $files, SplFileInfo $fileInfo): array {
525525
$file = $fileInfo->getRealPath();
526526

527527
if (false === $file) {

src/Console/Command/AddPrefixCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private function scopeFiles(
215215

216216
usort(
217217
$vendorDirs,
218-
function ($a, $b) {
218+
static function ($a, $b) {
219219
return strlen($b) <=> strlen($a);
220220
}
221221
);
@@ -287,7 +287,7 @@ private function validatePaths(InputInterface $input): void
287287
$fileSystem = $this->fileSystem;
288288

289289
$paths = array_map(
290-
function (string $path) use ($cwd, $fileSystem) {
290+
static function (string $path) use ($cwd, $fileSystem) {
291291
if (false === $fileSystem->isAbsolutePath($path)) {
292292
return $cwd.DIRECTORY_SEPARATOR.$path;
293293
}

src/PhpParser/NodeTraverser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private function replaceGroupUseStatements(array $nodes): array
149149
private function createUses_(GroupUse $node): array
150150
{
151151
return array_map(
152-
function (UseUse $use) use ($node): Use_ {
152+
static function (UseUse $use) use ($node): Use_ {
153153
$newUse = new UseUse(
154154
Name::concat($node->prefix, $use->name, $use->name->getAttributes()),
155155
$use->alias,

src/PhpParser/NodeVisitor/Collection/NamespaceStmtCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final class NamespaceStmtCollection implements IteratorAggregate, Countable
4646
* @param Namespace_ $node New namespace, may have been prefixed.
4747
* @param Namespace_ $originalName Original unchanged namespace.
4848
*/
49-
public function add(Namespace_ $node, Namespace_ $originalName)
49+
public function add(Namespace_ $node, Namespace_ $originalName): void
5050
{
5151
$this->nodes[] = $originalName;
5252

0 commit comments

Comments
 (0)