Skip to content

Require a digit before separators in float fractions - #356

Open
Boulea7 wants to merge 1 commit into
phpstan:2.5.xfrom
Boulea7:fix/fraction-digit-separators
Open

Boulea7 wants to merge 1 commit into
phpstan:2.5.xfrom
Boulea7:fix/fraction-digit-separators

Conversation

@Boulea7

@Boulea7 Boulea7 commented Nov 30, 2026

Copy link
Copy Markdown

The lexer currently accepts 1._5 as one float token and normalizes it to 1.5. This lets a malformed numeric literal pass as an @return type.

Require a fractional digit before its first separator in both the lexer and the reference grammar. The full PHPDoc parser now rejects the malformed literal. Valid forms such as 1., 1.e2, and 1.0_5 still parse normally.

The compiled type grammar agrees on the literal syntax. The block grammar still treats a suffix as description text without checking for a separating space. The runtime PHPDoc parser performs that check.

Addresses observation 6 in #343.

Ran 7,822 PHPUnit tests with the grammar toolchain, PHPStan, coding standards, and PHP syntax checks. AI assistance was used for implementation and independent review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant