Skip to content

Commit 5cc204d

Browse files
committed
Static analyze
1 parent 78ff3cd commit 5cc204d

File tree

90 files changed

+997
-471
lines changed

Some content is hidden

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

90 files changed

+997
-471
lines changed

.php_cs

+39-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,45 @@ return PhpCsFixer\Config::create()
88
'single_blank_line_before_namespace' => true,
99
'no_unused_imports' => true,
1010
'single_quote' => true,
11-
'native_function_invocation' => true
11+
'native_function_casing' => false,
12+
'native_function_invocation' => false,
13+
'single_import_per_statement' => true,
14+
'single_line_after_imports' => true,
15+
'blank_line_after_namespace' => true,
16+
'no_extra_blank_lines' => true,
17+
18+
'global_namespace_import' => [
19+
'import_classes' => true,
20+
'import_constants' => true,
21+
'import_functions' => true,
22+
],
23+
24+
'phpdoc_add_missing_param_annotation' => false,
25+
'phpdoc_align' => true,
26+
'phpdoc_annotation_without_dot' => true,
27+
'phpdoc_indent' => true,
28+
'phpdoc_no_access' => true,
29+
'phpdoc_no_empty_return' => true,
30+
'phpdoc_no_package' => true,
31+
'phpdoc_order' => true,
32+
'phpdoc_return_self_reference' => true,
33+
'phpdoc_scalar' => true,
34+
'phpdoc_separation' => true,
35+
'phpdoc_single_line_var_spacing' => true,
36+
'phpdoc_summary' => true,
37+
'phpdoc_to_comment' => true,
38+
'phpdoc_trim' => true,
39+
'phpdoc_trim_consecutive_blank_line_separation' => true,
40+
'phpdoc_types' => ['groups' => ['simple', 'meta']],
41+
'phpdoc_types_order' => true,
42+
'phpdoc_var_without_name' => true,
43+
'phpdoc_line_span' => true,
44+
45+
'fully_qualified_strict_types' => true,
46+
'no_spaces_after_function_name' => true,
47+
'method_separation' => true,
48+
49+
'class_attributes_separation' => ['elements' => ['const', 'method', 'property']]
1250
])
1351
->setFinder(
1452
PhpCsFixer\Finder::create()

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"php": ">=7.2",
1919
"ext-filter": "*",
2020
"ext-json": "*",
21+
"ext-simplexml": "*",
2122
"coduo/php-to-string": "^3",
2223
"symfony/property-access": "^2.3|^3.0|^4.0|^5.0",
2324
"symfony/expression-language": "^2.3|^3.0|^4.0|^5.0",
@@ -27,8 +28,7 @@
2728
"require-dev": {
2829
"friendsofphp/php-cs-fixer": "^2.4",
2930
"phpstan/phpstan": "^0.12.32",
30-
"phpunit/phpunit": "^8.4",
31-
"rector/rector-prefixed": "^0.7.43"
31+
"phpunit/phpunit": "^8.4"
3232
},
3333
"autoload": {
3434
"psr-4": {

composer.lock

+3-41
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: max
2+
level: 5
33
paths:
44
- src
55

src/AST/Expander.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@
44

55
namespace Coduo\PHPMatcher\AST;
66

7+
use function count;
8+
79
final class Expander implements Node
810
{
11+
/**
12+
* @var string
13+
*/
914
private $name;
1015

16+
/**
17+
* @var mixed[]
18+
*/
1119
private $arguments;
1220

1321
public function __construct(string $name)
@@ -21,14 +29,14 @@ public function getName() : string
2129
return $this->name;
2230
}
2331

24-
public function addArgument($argument)
32+
public function addArgument($argument): void
2533
{
2634
$this->arguments[] = $argument;
2735
}
2836

2937
public function hasArguments() : bool
3038
{
31-
return (boolean) \count($this->arguments);
39+
return (boolean) count($this->arguments);
3240
}
3341

3442
public function getArguments() : array

src/AST/Pattern.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@
44

55
namespace Coduo\PHPMatcher\AST;
66

7+
use function count;
8+
79
final class Pattern implements Node
810
{
11+
/**
12+
* @var Type
13+
*/
914
private $type;
1015

16+
/**
17+
* @var mixed[]
18+
*/
1119
private $expanders;
1220

1321
public function __construct(Type $type)
@@ -23,7 +31,7 @@ public function getType() : Type
2331

2432
public function hasExpanders() : bool
2533
{
26-
return (boolean) \count($this->expanders);
34+
return (boolean) count($this->expanders);
2735
}
2836

2937
/**
@@ -34,7 +42,7 @@ public function getExpanders() : array
3442
return $this->expanders;
3543
}
3644

37-
public function addExpander(Expander $expander)
45+
public function addExpander(Expander $expander): void
3846
{
3947
$this->expanders[] = $expander;
4048
}

src/AST/Type.php

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
final class Type implements Node
88
{
9+
/**
10+
* @var string
11+
*/
912
private $type;
1013

1114
public function __construct(string $type)

src/Backtrace.php

+18-12
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66

77
use Coduo\PHPMatcher\Value\SingleLineString;
88
use Coduo\ToString\StringConverter;
9+
use function sprintf;
10+
use function implode;
11+
use function count;
912

1013
final class Backtrace
1114
{
15+
/**
16+
* @var mixed[]
17+
*/
1218
private $trace;
1319

1420
public function __construct()
@@ -18,7 +24,7 @@ public function __construct()
1824

1925
public function matcherCanMatch(string $name, $value, bool $result) : void
2026
{
21-
$this->trace[] = \sprintf(
27+
$this->trace[] = sprintf(
2228
'#%d Matcher %s %s match pattern "%s"',
2329
$this->entriesCount(),
2430
$name,
@@ -29,7 +35,7 @@ public function matcherCanMatch(string $name, $value, bool $result) : void
2935

3036
public function matcherEntrance(string $name, $value, $pattern) : void
3137
{
32-
$this->trace[] = \sprintf(
38+
$this->trace[] = sprintf(
3339
'#%d Matcher %s matching value "%s" with "%s" pattern',
3440
$this->entriesCount(),
3541
$name,
@@ -40,7 +46,7 @@ public function matcherEntrance(string $name, $value, $pattern) : void
4046

4147
public function matcherSucceed(string $name, $value, $pattern) : void
4248
{
43-
$this->trace[] = \sprintf(
49+
$this->trace[] = sprintf(
4450
'#%d Matcher %s successfully matched value "%s" with "%s" pattern',
4551
$this->entriesCount(),
4652
$name,
@@ -51,15 +57,15 @@ public function matcherSucceed(string $name, $value, $pattern) : void
5157

5258
public function matcherFailed(string $name, $value, $pattern, string $error) : void
5359
{
54-
$this->trace[] = \sprintf(
60+
$this->trace[] = sprintf(
5561
'#%d Matcher %s failed to match value "%s" with "%s" pattern',
5662
$this->entriesCount(),
5763
$name,
5864
new SingleLineString((string) new StringConverter($value)),
5965
new SingleLineString((string) new StringConverter($pattern))
6066
);
6167

62-
$this->trace[] = \sprintf(
68+
$this->trace[] = sprintf(
6369
'#%d Matcher %s error: %s',
6470
$this->entriesCount(),
6571
$name,
@@ -69,7 +75,7 @@ public function matcherFailed(string $name, $value, $pattern, string $error) : v
6975

7076
public function expanderEntrance(string $name, $value) : void
7177
{
72-
$this->trace[] = \sprintf(
78+
$this->trace[] = sprintf(
7379
'#%d Expander %s matching value "%s"',
7480
$this->entriesCount(),
7581
$name,
@@ -79,7 +85,7 @@ public function expanderEntrance(string $name, $value) : void
7985

8086
public function expanderSucceed(string $name, $value) : void
8187
{
82-
$this->trace[] = \sprintf(
88+
$this->trace[] = sprintf(
8389
'#%d Expander %s successfully matched value "%s"',
8490
$this->entriesCount(),
8591
$name,
@@ -89,14 +95,14 @@ public function expanderSucceed(string $name, $value) : void
8995

9096
public function expanderFailed(string $name, $value, string $error) : void
9197
{
92-
$this->trace[] = \sprintf(
98+
$this->trace[] = sprintf(
9399
'#%d Expander %s failed to match value "%s"',
94100
$this->entriesCount(),
95101
$name,
96102
new SingleLineString((string) new StringConverter($value))
97103
);
98104

99-
$this->trace[] = \sprintf(
105+
$this->trace[] = sprintf(
100106
'#%d Expander %s error: %s',
101107
$this->entriesCount(),
102108
$name,
@@ -106,12 +112,12 @@ public function expanderFailed(string $name, $value, string $error) : void
106112

107113
public function isEmpty() : bool
108114
{
109-
return \count($this->trace) === 0;
115+
return count($this->trace) === 0;
110116
}
111117

112118
public function __toString() : string
113119
{
114-
return \implode("\n", $this->trace);
120+
return implode("\n", $this->trace);
115121
}
116122

117123
public function raw() : array
@@ -121,6 +127,6 @@ public function raw() : array
121127

122128
private function entriesCount(): int
123129
{
124-
return \count($this->trace) + 1;
130+
return count($this->trace) + 1;
125131
}
126132
}

src/Exception/PatternException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class PatternException extends Exception
88
{
9-
public static function syntaxError(string $message, Exception $previous = null)
9+
public static function syntaxError(string $message, Exception $previous = null): PatternException
1010
{
1111
return new self('[Syntax Error] ' . $message, 0, $previous);
1212
}

src/Exception/UnknownTypeException.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@
44

55
namespace Coduo\PHPMatcher\Exception;
66

7+
use function sprintf;
8+
79
class UnknownTypeException extends Exception
810
{
11+
/**
12+
* @var string
13+
*/
914
private $type;
1015

1116
public function __construct(string $type)
1217
{
1318
$this->type = '@' . $type . '@';
14-
parent::__construct(\sprintf('Type pattern "%s" is not supported.', $this->type), 0, null);
19+
parent::__construct(sprintf('Type pattern "%s" is not supported.', $this->type), 0, null);
1520
}
1621

1722
public function getType() : string

0 commit comments

Comments
 (0)