feat(diagnostics): detect declare(strict_types=1) for stricter type checking - #193
Merged
Merged
Conversation
calebdw
force-pushed
the
calebdw/push-mtpqxwvyzmrq
branch
from
July 4, 2026 03:21
39a1369 to
3da1862
Compare
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
calebdw
force-pushed
the
calebdw/push-mtpqxwvyzmrq
branch
3 times, most recently
from
July 7, 2026 03:36
41f2724 to
7d2e004
Compare
calebdw
marked this pull request as draft
July 7, 2026 17:02
calebdw
added a commit
to calebdw/phpantom_lsp
that referenced
this pull request
Jul 7, 2026
…hecking Read declare(strict_types=1) from the calling file when checking call argument compatibility so PHP's strict scalar call semantics are reflected in type_mismatch_argument diagnostics. This hardens the implementation by preserving literal kinds for int, float, and string values instead of flattening them to raw strings. That keeps float literals from being misclassified as ints and lets numeric literals retain PHP-specific forms such as underscores, scientific notation, and hex/binary/octal integers during checks. Non-strict mode continues to allow PHP's call-time scalar coercions such as int/float to string and numeric-string to int/float, while strict mode flags those mismatches. Concatenation and other non-call contexts are unchanged. Closes PHPantom-dev#193
calebdw
force-pushed
the
calebdw/push-mtpqxwvyzmrq
branch
from
July 7, 2026 17:36
7d2e004 to
991a13e
Compare
calebdw
added a commit
to calebdw/phpantom_lsp
that referenced
this pull request
Jul 7, 2026
…hecking Read declare(strict_types=1) from the calling file when checking call argument compatibility so PHP's strict scalar call semantics are reflected in type_mismatch_argument diagnostics. This hardens the implementation by preserving literal kinds for int, float, and string values instead of flattening them to raw strings. That keeps float literals from being misclassified as ints and lets numeric literals retain PHP-specific forms such as underscores, scientific notation, and hex/binary/octal integers during checks. Non-strict mode continues to allow PHP's call-time scalar coercions such as int/float to string and numeric-string to int/float, while strict mode flags those mismatches. Concatenation and other non-call contexts are unchanged. Closes PHPantom-dev#193
calebdw
force-pushed
the
calebdw/push-mtpqxwvyzmrq
branch
from
July 7, 2026 17:42
991a13e to
0b0ad70
Compare
calebdw
added a commit
to calebdw/phpantom_lsp
that referenced
this pull request
Jul 7, 2026
…hecking Read declare(strict_types=1) from the calling file when checking call argument compatibility so PHP's strict scalar call semantics are reflected in type_mismatch_argument diagnostics. This hardens the implementation by preserving literal kinds for int, float, and string values instead of flattening them to raw strings. That keeps float literals from being misclassified as ints and lets numeric literals retain PHP-specific forms such as underscores, scientific notation, and hex/binary/octal integers during checks. Non-strict mode continues to allow PHP's call-time scalar coercions such as int/float to string and numeric-string to int/float, while strict mode flags those mismatches. Concatenation and other non-call contexts are unchanged. Closes PHPantom-dev#193
calebdw
force-pushed
the
calebdw/push-mtpqxwvyzmrq
branch
from
July 7, 2026 17:46
0b0ad70 to
fa72ea3
Compare
calebdw
added a commit
to calebdw/phpantom_lsp
that referenced
this pull request
Jul 7, 2026
…hecking Read declare(strict_types=1) from the calling file when checking call argument compatibility so PHP's strict scalar call semantics are reflected in type_mismatch_argument diagnostics. This hardens the implementation by preserving literal kinds for int, float, and string values instead of flattening them to raw strings. That keeps float literals from being misclassified as ints and lets numeric literals retain PHP-specific forms such as underscores, scientific notation, and hex/binary/octal integers during checks. Non-strict mode continues to allow PHP's call-time scalar coercions such as int/float to string and numeric-string to int/float, while strict mode flags those mismatches. Concatenation and other non-call contexts are unchanged. Closes PHPantom-dev#193
calebdw
force-pushed
the
calebdw/push-mtpqxwvyzmrq
branch
from
July 7, 2026 17:47
fa72ea3 to
e742c72
Compare
calebdw
marked this pull request as ready for review
July 7, 2026 17:47
calebdw
force-pushed
the
calebdw/push-mtpqxwvyzmrq
branch
2 times, most recently
from
July 7, 2026 21:17
b653167 to
febc364
Compare
checking Read declare(strict_types=1) from the calling file when checking call argument compatibility so PHP's strict scalar call semantics are reflected in type_mismatch_argument diagnostics. This hardens the implementation by preserving literal kinds for int, float, and string values instead of flattening them to raw strings. That keeps float literals from being misclassified as ints and lets numeric literals retain PHP-specific forms such as underscores, scientific notation, and hex/binary/octal integers during checks. Non-strict mode continues to allow PHP's call-time scalar coercions such as int/float to string and numeric-string to int/float, while strict mode flags those mismatches. Concatenation and other non-call contexts are unchanged. Closes PHPantom-dev#203
AJenbo
force-pushed
the
calebdw/push-mtpqxwvyzmrq
branch
from
July 8, 2026 23:31
febc364 to
a26d5df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reads
declare(strict_types=1)from the calling file and tightens call-argument type checking accordingly.Under strict types, PHP's implicit scalar call-time coercions are now flagged in
type_mismatch_argumentdiagnostics:int/float->stringnumeric-string->int/floatThe
int->floatexception is preserved to match PHP runtime semantics. Concatenation and other non-call contexts are unaffected because this change is scoped to call argument diagnostics only.The implementation is hardened by preserving literal kinds for
int,float, andstringvalues instead of flattening literals to raw strings. That avoids cases like1.0being misclassified as an integer and keeps PHP numeric syntaxes such as underscores, scientific notation, and hex/binary/octal integers meaningful during compatibility checks.Includes focused tests for:
int->stringmismatchesfloat->stringmismatchesint->floatbehaviorCloses #203