Skip to content

Commit 32323d0

Browse files
committed
removed shortArraySyntaxFixer and invalidDoubleQuotedStringChecker
These checks are now handled by the nette/coding-standard package.
1 parent 65f14d6 commit 32323d0

4 files changed

Lines changed: 1 addition & 101 deletions

File tree

src/Tasks.php

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -49,43 +49,6 @@ public static function invalidPhpDocChecker(string $contents, Result $result): v
4949
}
5050

5151

52-
public static function shortArraySyntaxFixer(string &$contents, Result $result): void
53-
{
54-
$out = '';
55-
$brackets = [];
56-
try {
57-
$tokens = @token_get_all($contents, TOKEN_PARSE); // @ can trigger error
58-
} catch (\ParseError) {
59-
return;
60-
}
61-
62-
for ($i = 0; $i < count($tokens); $i++) {
63-
$token = $tokens[$i];
64-
if ($token === '(') {
65-
$brackets[] = false;
66-
67-
} elseif ($token === ')') {
68-
$token = array_pop($brackets) ? ']' : ')';
69-
70-
} elseif (is_array($token) && $token[0] === T_ARRAY) {
71-
$a = $i + 1;
72-
if (isset($tokens[$a]) && $tokens[$a][0] === T_WHITESPACE) {
73-
$a++;
74-
}
75-
if (isset($tokens[$a]) && $tokens[$a] === '(') {
76-
$result->fix('uses old array() syntax', $token[2]);
77-
$i = $a;
78-
$brackets[] = true;
79-
$token = '[';
80-
}
81-
}
82-
$out .= is_array($token) ? $token[1] : $token;
83-
}
84-
85-
$contents = $out;
86-
}
87-
88-
8952
public static function strictTypesDeclarationChecker(string $contents, Result $result): void
9053
{
9154
$declarations = '';
@@ -108,23 +71,6 @@ public static function strictTypesDeclarationChecker(string $contents, Result $r
10871
}
10972

11073

111-
public static function invalidDoubleQuotedStringChecker(string $contents, Result $result): void
112-
{
113-
$prev = [0, '', 0];
114-
foreach (@token_get_all($contents) as $token) { // @ can trigger error
115-
if (($token[0] === T_ENCAPSED_AND_WHITESPACE && ($prev[0] !== T_START_HEREDOC || !strpos($prev[1], "'")))
116-
|| ($token[0] === T_CONSTANT_ENCAPSED_STRING && $token[1][0] === '"')
117-
) {
118-
$m = Strings::match($token[1], '#^([^\\\]|\\\[\\\nrtvefxu0-7\W])*+#') ?? ['']; // more strict: '#^([^\\\\]|\\\\[\\\\nrtvefu$"x0-7])*+#'
119-
if ($token[1] !== $m[0]) {
120-
$result->warning('Invalid escape sequence ' . substr($token[1], strlen($m[0]), 2) . ' in double quoted string', $token[2]);
121-
}
122-
}
123-
$prev = $token;
124-
}
125-
}
126-
127-
12874
public static function docSyntaxtHinter(string $contents, Result $result): void
12975
{
13076
$prev = [0, '', 0];

src/bootstrap.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php declare(strict_types=1);
1+
<?php
22

33
/**
44
* Source Codes Checker.
@@ -102,13 +102,11 @@
102102
$checker->addTask([$tasks, 'utf8Checker']);
103103
$checker->addTask([$tasks, 'phpSyntaxChecker'], '*.php,*.phpt');
104104
$checker->addTask([$tasks, 'invalidPhpDocChecker'], '*.php,*.phpt');
105-
$checker->addTask([$tasks, 'shortArraySyntaxFixer'], '*.php,*.phpt');
106105
$checker->addTask([$tasks, 'strictTypesDeclarationChecker'], '*.php,*.phpt');
107106
if (isset($options['--eol'])) {
108107
$checker->addTask([$tasks, 'newlineNormalizer'], '!*.sh');
109108
}
110109

111-
$checker->addTask([$tasks, 'invalidDoubleQuotedStringChecker'], '*.php,*.phpt');
112110
$checker->addTask([$tasks, 'trailingPhpTagRemover'], '*.php,*.phpt');
113111
$checker->addTask([$tasks, 'latteSyntaxChecker'], '*.latte');
114112
$checker->addTask([$tasks, 'neonSyntaxChecker'], '*.neon');

tests/Tasks.invalidDoubleQuotedStringChecker.phpt

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/Tasks.shortArraySyntaxFixer.phpt

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)