Skip to content

Commit cda33fb

Browse files
committed
Add max_depth option to unserialize() callmap type
PHP 7.4 added max_depth as an option to unserialize(), but Psalm's callmap only declared allowed_classes in the array shape, causing a false-positive InvalidArgument error. Add max_depth?: int to the options type, version-gated to PHP 7.4+ via CallMap_74_delta.php. Add regression tests for both valid usage and invalid type detection. Fix #11295
1 parent 866382a commit cda33fb

File tree

11 files changed

+39
-10
lines changed

11 files changed

+39
-10
lines changed

dictionaries/CallMap_74.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100897,7 +100897,7 @@
100897100897
array (
100898100898
0 => 'mixed',
100899100899
'variable_representation' => 'string',
100900-
'allowed_classes=' => 'array{allowed_classes?: array<array-key, class-string>|bool}',
100900+
'allowed_classes=' => 'array{allowed_classes?: array<array-key, class-string>|bool, max_depth?: int}',
100901100901
),
100902100902
'unset' =>
100903100903
array (

dictionaries/CallMap_80.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98231,7 +98231,7 @@
9823198231
array (
9823298232
0 => 'mixed',
9823398233
'data' => 'string',
98234-
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool}',
98234+
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool, max_depth?: int}',
9823598235
),
9823698236
'unset' =>
9823798237
array (

dictionaries/CallMap_81.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96565,7 +96565,7 @@
9656596565
array (
9656696566
0 => 'mixed',
9656796567
'data' => 'string',
96568-
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool}',
96568+
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool, max_depth?: int}',
9656996569
),
9657096570
'unset' =>
9657196571
array (

dictionaries/CallMap_82.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96991,7 +96991,7 @@
9699196991
array (
9699296992
0 => 'mixed',
9699396993
'data' => 'string',
96994-
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool}',
96994+
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool, max_depth?: int}',
9699596995
),
9699696996
'unset' =>
9699796997
array (

dictionaries/CallMap_83.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97838,7 +97838,7 @@
9783897838
array (
9783997839
0 => 'mixed',
9784097840
'data' => 'string',
97841-
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool}',
97841+
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool, max_depth?: int}',
9784297842
),
9784397843
'unset' =>
9784497844
array (

dictionaries/CallMap_84.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102134,7 +102134,7 @@
102134102134
array (
102135102135
0 => 'mixed',
102136102136
'data' => 'string',
102137-
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool}',
102137+
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool, max_depth?: int}',
102138102138
),
102139102139
'unset' =>
102140102140
array (

dictionaries/CallMap_85.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83485,7 +83485,7 @@
8348583485
array (
8348683486
0 => 'mixed',
8348783487
'data' => 'string',
83488-
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool}',
83488+
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool, max_depth?: int}',
8348983489
),
8349083490
'unset' =>
8349183491
array (

dictionaries/override/CallMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65620,7 +65620,7 @@
6562065620
array (
6562165621
0 => 'mixed',
6562265622
'data' => 'string',
65623-
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool}',
65623+
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool, max_depth?: int}',
6562465624
),
6562565625
'unset' =>
6562665626
array (

dictionaries/override/CallMap_74_delta.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,21 @@
18471847
'allowable_tags=' => 'list<non-empty-string>|string',
18481848
),
18491849
),
1850+
'unserialize' =>
1851+
array (
1852+
'old' =>
1853+
array (
1854+
0 => 'mixed',
1855+
'variable_representation' => 'string',
1856+
'allowed_classes=' => 'array{allowed_classes?: array<array-key, class-string>|bool}',
1857+
),
1858+
'new' =>
1859+
array (
1860+
0 => 'mixed',
1861+
'variable_representation' => 'string',
1862+
'allowed_classes=' => 'array{allowed_classes?: array<array-key, class-string>|bool, max_depth?: int}',
1863+
),
1864+
),
18501865
),
18511866
'removed' =>
18521867
array (

dictionaries/override/CallMap_80_delta.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33376,13 +33376,13 @@
3337633376
array (
3337733377
0 => 'mixed',
3337833378
'variable_representation' => 'string',
33379-
'allowed_classes=' => 'array{allowed_classes?: array<array-key, class-string>|bool}',
33379+
'allowed_classes=' => 'array{allowed_classes?: array<array-key, class-string>|bool, max_depth?: int}',
3338033380
),
3338133381
'new' =>
3338233382
array (
3338333383
0 => 'mixed',
3338433384
'data' => 'string',
33385-
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool}',
33385+
'options=' => 'array{allowed_classes?: array<array-key, class-string>|bool, max_depth?: int}',
3338633386
),
3338733387
),
3338833388
'urldecode' =>

0 commit comments

Comments
 (0)