From 031bbe0ddc8fed13612bbcb79fbbdc275e1e3f3a Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Fri, 3 Apr 2026 04:48:03 -0500 Subject: [PATCH 1/3] Wire up phpstan --- .github/workflows/ci.yml | 2 +- Makefile | 8 ++++++-- composer.json | 5 +++-- phpstan.neon | 4 ++++ src/DotNotationParser.php | 5 ++++- 5 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 phpstan.neon diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 405987f..48bc92f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: operating-system: [ubuntu-latest] - php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] + php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] runs-on: ${{ matrix.operating-system }} diff --git a/Makefile b/Makefile index 796d48e..9fc0f70 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,12 @@ README.md: $(SRC_FILES) fix: cbf vendor/bin/php-cs-fixer fix +.PHONY: phpstan +phpstan: + vendor/bin/phpstan --memory-limit=2G + .PHONY: test -test: cs +test: cs phpstan vendor/bin/phpunit .PHONY: cs @@ -17,4 +21,4 @@ cs: .PHONY: cbf cbf: - vendor/bin/phpcbf \ No newline at end of file + vendor/bin/phpcbf diff --git a/composer.json b/composer.json index 3b5abe4..3db08da 100644 --- a/composer.json +++ b/composer.json @@ -3,13 +3,14 @@ "description": "Simple PHP Dot Notation Parser", "type": "library", "require": { - "php": ">=7.1" + "php": ">=7.4" }, "require-dev": { "phpunit/phpunit": "~7.5 | ~9.5", "squizlabs/php_codesniffer": "^3.5", "corpus/coding-standard": "~0.6.0", - "friendsofphp/php-cs-fixer": "^2.17" + "friendsofphp/php-cs-fixer": "^2.17", + "phpstan/phpstan": "^2.1" }, "license": "MIT", "authors": [ diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..309bd4f --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: max + paths: + - src diff --git a/src/DotNotationParser.php b/src/DotNotationParser.php index 43558db..a5c1897 100644 --- a/src/DotNotationParser.php +++ b/src/DotNotationParser.php @@ -82,9 +82,11 @@ private function scanQuotedString( \Iterator $chars ) : string { $buff = ''; $chars->next(); + /** @var int|null $lastKey */ $lastKey = $chars->key(); for(;;) { $token = $chars->current(); + /** @var int|null $key */ $key = $chars->key(); if( !$chars->valid() ) { @@ -98,6 +100,7 @@ private function scanQuotedString( \Iterator $chars ) : string { if( $token === '"' ) { $chars->next(); $next = $chars->current(); + /** @var int|null $nextKey */ $nextKey = $chars->key(); if( !$chars->valid() || $next === '.' ) { @@ -107,7 +110,7 @@ private function scanQuotedString( \Iterator $chars ) : string { throw new ParseException( sprintf('failed to parse path, expected . or EOF, got "%s" at %d', $next, $key), - $nextKey ?? $key, + $nextKey ?? $key ?? ($lastKey + 1), ParseException::CODE_UNEXPECTED_CHARACTER ); } From 3e45747b5b28fbad43cede75c29fb5e5b23bbe0e Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Fri, 3 Apr 2026 04:49:25 -0500 Subject: [PATCH 2/3] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 43883b9..267d3e7 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ DotNotationParser is a simple parser that will parse `foo.bar.baz` into `[ 'foo' ## Requirements -- **php**: >=7.1 +- **php**: >=7.4 ## Installing From 3de53bb038d87ffb530d12a4e7e8fbed8c64bb45 Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Fri, 3 Apr 2026 04:50:09 -0500 Subject: [PATCH 3/3] Update phpunit --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3db08da..003ab61 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "php": ">=7.4" }, "require-dev": { - "phpunit/phpunit": "~7.5 | ~9.5", + "phpunit/phpunit": "~8.5 | ~9.5", "squizlabs/php_codesniffer": "^3.5", "corpus/coding-standard": "~0.6.0", "friendsofphp/php-cs-fixer": "^2.17",