Skip to content

linter: better type inferring #1252

Merged
Hidanio merged 37 commits intomasterfrom
hidanio/safety_call_inferring
Apr 16, 2025
Merged

linter: better type inferring #1252
Hidanio merged 37 commits intomasterfrom
hidanio/safety_call_inferring

Conversation

@Hidanio
Copy link
Copy Markdown
Contributor

@Hidanio Hidanio commented Mar 28, 2025

We have some false-positives for null-safety and this pull-request should help us. I improved type inferring by true/false context and merge null-safety with more general rule: safety call (but null-safety separated)

  • Improve type-inferring for bool/null
  • Improve type-inferring for another type and checkers like is_bool, is_int, is_null and etc
  • Merge null-safety with more general safety-call rule

Very important note: i improved type inferring only for if/else conditions and context inside it. Throwing context up is the future task.


$x <== User|false
if ($x === false){
$y = is_object($x); <=== here will be User
 return;
}

some code....

$y = is_object($x); <== will be false; current type will be User|false

@Hidanio Hidanio self-assigned this Mar 30, 2025
@Hidanio Hidanio added the enhancement New feature or request label Mar 30, 2025
@Hidanio Hidanio changed the title Hidanio/safety call inferring linter: better type inferring Mar 31, 2025
@Hidanio Hidanio force-pushed the hidanio/safety_call_inferring branch from dd1e43a to a94e225 Compare April 1, 2025 01:39
@Hidanio Hidanio force-pushed the hidanio/safety_call_inferring branch from 43907dc to 184a9c1 Compare April 1, 2025 02:29
@Hidanio Hidanio marked this pull request as ready for review April 1, 2025 02:33
@Hidanio Hidanio requested a review from Danil42Russia April 1, 2025 15:09
@Hidanio Hidanio force-pushed the hidanio/safety_call_inferring branch from 700f9e9 to 560eb35 Compare April 8, 2025 03:51
@Hidanio Hidanio force-pushed the hidanio/safety_call_inferring branch from 31a757f to 2d9eb7a Compare April 9, 2025 23:20
@Hidanio Hidanio force-pushed the hidanio/safety_call_inferring branch from 3023358 to 80aa152 Compare April 15, 2025 01:47
@Hidanio Hidanio merged commit 59cc669 into master Apr 16, 2025
4 checks passed
@Hidanio Hidanio deleted the hidanio/safety_call_inferring branch April 16, 2025 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants