Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,4 +21,4 @@ cs:

.PHONY: cbf
cbf:
vendor/bin/phpcbf
vendor/bin/phpcbf
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"phpunit/phpunit": "~8.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": [
Expand Down
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: max
paths:
- src
5 changes: 4 additions & 1 deletion src/DotNotationParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() ) {
Expand All @@ -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 === '.' ) {
Expand All @@ -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),
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ParseException message reports the unexpected character as occurring at $key (the closing quote position), but the exception index being passed is $nextKey (the position of the unexpected character after the quote). This mismatch makes debugging harder; use the same position (preferably $nextKey) consistently in both the message and the $charIndex argument.

Suggested change
sprintf('failed to parse path, expected . or EOF, got "%s" at %d', $next, $key),
sprintf('failed to parse path, expected . or EOF, got "%s" at %d', $next, $nextKey ?? $key ?? ($lastKey + 1)),

Copilot uses AI. Check for mistakes.
$nextKey ?? $key,
$nextKey ?? $key ?? ($lastKey + 1),
ParseException::CODE_UNEXPECTED_CHARACTER
);
}
Expand Down