Skip to content

Commit 031bbe0

Browse files
committed
Wire up phpstan
1 parent 3edc335 commit 031bbe0

5 files changed

Lines changed: 18 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
operating-system: [ubuntu-latest]
14-
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
14+
php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
1515

1616
runs-on: ${{ matrix.operating-system }}
1717

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ README.md: $(SRC_FILES)
77
fix: cbf
88
vendor/bin/php-cs-fixer fix
99

10+
.PHONY: phpstan
11+
phpstan:
12+
vendor/bin/phpstan --memory-limit=2G
13+
1014
.PHONY: test
11-
test: cs
15+
test: cs phpstan
1216
vendor/bin/phpunit
1317

1418
.PHONY: cs
@@ -17,4 +21,4 @@ cs:
1721

1822
.PHONY: cbf
1923
cbf:
20-
vendor/bin/phpcbf
24+
vendor/bin/phpcbf

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
"description": "Simple PHP Dot Notation Parser",
44
"type": "library",
55
"require": {
6-
"php": ">=7.1"
6+
"php": ">=7.4"
77
},
88
"require-dev": {
99
"phpunit/phpunit": "~7.5 | ~9.5",
1010
"squizlabs/php_codesniffer": "^3.5",
1111
"corpus/coding-standard": "~0.6.0",
12-
"friendsofphp/php-cs-fixer": "^2.17"
12+
"friendsofphp/php-cs-fixer": "^2.17",
13+
"phpstan/phpstan": "^2.1"
1314
},
1415
"license": "MIT",
1516
"authors": [

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- src

src/DotNotationParser.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ private function scanQuotedString( \Iterator $chars ) : string {
8282
$buff = '';
8383

8484
$chars->next();
85+
/** @var int|null $lastKey */
8586
$lastKey = $chars->key();
8687
for(;;) {
8788
$token = $chars->current();
89+
/** @var int|null $key */
8890
$key = $chars->key();
8991

9092
if( !$chars->valid() ) {
@@ -98,6 +100,7 @@ private function scanQuotedString( \Iterator $chars ) : string {
98100
if( $token === '"' ) {
99101
$chars->next();
100102
$next = $chars->current();
103+
/** @var int|null $nextKey */
101104
$nextKey = $chars->key();
102105

103106
if( !$chars->valid() || $next === '.' ) {
@@ -107,7 +110,7 @@ private function scanQuotedString( \Iterator $chars ) : string {
107110

108111
throw new ParseException(
109112
sprintf('failed to parse path, expected . or EOF, got "%s" at %d', $next, $key),
110-
$nextKey ?? $key,
113+
$nextKey ?? $key ?? ($lastKey + 1),
111114
ParseException::CODE_UNEXPECTED_CHARACTER
112115
);
113116
}

0 commit comments

Comments
 (0)