feat(diagnostics): detect declare(strict_types=1) for stricter type checking#193
Open
calebdw wants to merge 1 commit into
Open
feat(diagnostics): detect declare(strict_types=1) for stricter type checking#193calebdw wants to merge 1 commit into
calebdw wants to merge 1 commit into
Conversation
39a1369 to
3da1862
Compare
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…hecking Scans the calling file for `declare(strict_types=1)` and tightens argument type checking accordingly. Under strict types, implicit scalar coercions that PHP normally allows are now flagged: - int/float → string (TypeError in strict mode) - numeric-string → int/float (string-to-number coercion forbidden) The int → float exception is preserved, matching PHP's runtime semantics. Concatenation (`.`) is unaffected since it is not a scalar type declaration context. The `strict_types` flag is detected once per file inside the `with_parsed_program` closure and threaded through `is_type_compatible` to the affected MAYBE rules. Includes 7 new integration tests covering: int→string flagging, int→float exception, numeric-string→int flagging, int literal→string, float→string, concatenation unaffected, and the non-strict baseline.
3da1862 to
bbe035f
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.
Important
Depends on #192
Scans the calling file for
declare(strict_types=1)and tightensargument type checking accordingly. Under strict types, implicit
scalar coercions that PHP normally allows are now flagged:
The int → float exception is preserved, matching PHP's runtime
semantics. Concatenation (
.) is unaffected since it is not ascalar type declaration context.
The
strict_typesflag is detected once per file inside thewith_parsed_programclosure and threaded throughis_type_compatibleto the affected MAYBE rules.Includes 7 new integration tests covering: int→string flagging,
int→float exception, numeric-string→int flagging, int literal→string,
float→string, concatenation unaffected, and the non-strict baseline.