Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b653833
Add TIntMaskVerifier for enhanced TIntMask and TIntMaskOf checks
il-yb-ono Jun 18, 2025
9b91dd0
Fixed import of TIntMaskVerifier and removed some whitespace.
il-yb-ono Jun 18, 2025
9ab5b4c
Refactor TIntMaskVerifier to initialize mask in constructor and simpl…
il-yb-ono Jun 18, 2025
4565314
Update test assertions for int-mask to use int-mask-verifier format
il-yb-ono Jun 20, 2025
b7979fd
TIntMaskVerifier cannot be converted to TIntRange
il-yb-ono Jul 11, 2025
281e6d1
Add TIntMaskVerifier comparison support. TIntMaskVerifier-to-TIntMask…
il-yb-ono Jul 17, 2025
04844c3
Added the ability to analyze operations in TIntMaskVerifier.
il-yb-ono Aug 1, 2025
f385a5c
Added intersection handling to TIntMaskVerifier, creating an intersec…
il-yb-ono Aug 1, 2025
24910c6
For TIntMaskVerifier, only one conditional expression could be selected,
il-yb-ono Aug 15, 2025
8ff4527
TIntMaskVerifier: prepend 0 to potential_ints if not present; update …
il-yb-ono Aug 15, 2025
18cbc97
TIntMaskVerifier: add getPossibleInts method to compute possible conc…
il-yb-ono Aug 15, 2025
ecc9247
ArithmeticOpAnalyzer: add checks for non-empty calculated masks befor…
il-yb-ono Aug 21, 2025
9b41860
cs-fix
il-yb-ono Aug 21, 2025
adaa6be
config: add maxIntMaskCombinations attribute to control integer mask …
il-yb-ono Aug 21, 2025
250addb
ArithmeticOpAnalyzer: refine BitwiseAnd operation to retain only comm…
il-yb-ono Aug 22, 2025
ce23a10
TIntMaskVerifierTest: add unit tests for TIntMaskVerifier functionality
il-yb-ono Aug 22, 2025
71fc00e
Simplify XOR mask combination logic
il-yb-ono Aug 22, 2025
7b18642
ArithmeticOpAnalyzer: add support for left and right shift operations…
il-yb-ono Aug 22, 2025
b821530
refactor bitwise and shift operations to use dedicated analysis metho…
il-yb-ono Aug 22, 2025
497f2d2
refactor: move TIntMaskVerifier ops to separate class
il-yb-ono Aug 22, 2025
35112e9
refactor: clean up TIntMaskVerifier operation
il-yb-ono Aug 22, 2025
a2cee21
Revert "refactor bitwise and shift operations to use dedicated analys…
il-yb-ono Aug 22, 2025
bd024c3
refactor: Split out arithmetic analysis in TIntMaskVerifier
il-yb-ono Aug 22, 2025
817a8dc
fix-cs
il-yb-ono Aug 22, 2025
2385a24
refactor: Move TIntMaskVerifier operations to dedicated TIntMaskVerif…
il-yb-ono Aug 27, 2025
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
1 change: 1 addition & 0 deletions config.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<xs:attribute name="errorBaseline" type="xs:string" />
<xs:attribute name="maxStringLength" type="xs:string" />
<xs:attribute name="maxShapedArraySize" type="xs:integer" default="100" />
<xs:attribute name="maxIntMaskCombinations" type="xs:integer" default="10" />
<xs:attribute name="longScanWarning" type="xs:float" default="10.0" />
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="phpVersion" type="xs:string" />
Expand Down
11 changes: 11 additions & 0 deletions docs/running_psalm/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,17 @@ Arrays bigger than this value (100 by default) will be transformed in a generic

Please note that changing this setting might introduce unwanted side effects and those side effects won't be considered as bugs.

#### maxIntMaskCombinations
```xml
<psalm
maxIntMaskCombinations="10"
>
```

This setting controls the maximum number of integer mask combinations that Psalm will process when analyzing bitwise operations with `TIntMaskVerifier` types. When the number of potential combinations exceeds this limit, Psalm will fall back to using a more generic type to avoid performance issues.

The default value is 10. Increasing this value may provide more precise type analysis for complex bitwise operations but could negatively impact performance.

#### longScanWarning
```xml
<psalm
Expand Down
7 changes: 7 additions & 0 deletions src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ final class Config

public int $max_string_length = 1_000;

public int $max_int_mask_combinations = 10;

private ?IncludeCollector $include_collector = null;

private ?TaintAnalysisFileFilter $taint_analysis_ignored_files = null;
Expand Down Expand Up @@ -1201,6 +1203,11 @@ private static function fromXmlAndPaths(
$config->max_shaped_array_size = $attribute_text;
}

if (isset($config_xml['maxIntMaskCombinations'])) {
$attribute_text = (int)$config_xml['maxIntMaskCombinations'];
$config->max_int_mask_combinations = $attribute_text;
}

if (isset($config_xml['longScanWarning'])) {
$attribute_text = (float)$config_xml['longScanWarning'];
$config->long_scan_warning = $attribute_text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Psalm\Type\Atomic\TFalse;
use Psalm\Type\Atomic\TFloat;
use Psalm\Type\Atomic\TInt;
use Psalm\Type\Atomic\TIntMaskVerifier;
use Psalm\Type\Atomic\TIntRange;
use Psalm\Type\Atomic\TKeyedArray;
use Psalm\Type\Atomic\TLiteralFloat;
Expand Down Expand Up @@ -310,6 +311,18 @@ private static function analyzeOperands(
bool &$has_string_increment,
?Union &$result_type = null,
): ?Union {
if ($left_type_part instanceof TIntMaskVerifier || $right_type_part instanceof TIntMaskVerifier) {
return TIntMaskVerifierAnalyzer::analyze(
$parent,
$left_type_part,
$right_type_part,
$has_valid_left_operand,
$has_valid_right_operand,
$result_type,
$config->max_int_mask_combinations,
);
}

if (($left_type_part instanceof TLiteralInt || $left_type_part instanceof TLiteralFloat)
&& ($right_type_part instanceof TLiteralInt || $right_type_part instanceof TLiteralFloat)
&& (
Expand Down
Loading