Skip to content

Commit 36db1ff

Browse files
phpstan-botclaude
andcommitted
Mark mysqli_connect as having side effects in function metadata
mysqli_connect establishes a network connection to a database server, which is inherently a side effect. Marking it as hasSideEffects => true causes TypeSpecifier to return empty SpecifiedTypes for the call, which prevents stale conditional expressions from being created and fixes the false positive logicalOr.leftAlwaysTrue on repeated calls. Fixes phpstan/phpstan#14473 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 55c63e4 commit 36db1ff

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

bin/functionMetadata_original.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
'link' => ['hasSideEffects' => true],
9595
'mkdir' => ['hasSideEffects' => true],
9696
'move_uploaded_file' => ['hasSideEffects' => true],
97+
'mysqli_connect' => ['hasSideEffects' => true],
9798
'ob_clean' => ['hasSideEffects' => true],
9899
'ob_end_clean' => ['hasSideEffects' => true],
99100
'ob_end_flush' => ['hasSideEffects' => true],

resources/functionMetadata.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,7 @@
13921392
'msgfmt_parse_message' => ['hasSideEffects' => false],
13931393
'mt_getrandmax' => ['hasSideEffects' => false],
13941394
'mt_rand' => ['hasSideEffects' => true],
1395+
'mysqli_connect' => ['hasSideEffects' => true],
13951396
'net_get_interfaces' => ['hasSideEffects' => false],
13961397
'ngettext' => ['hasSideEffects' => false],
13971398
'nl2br' => ['hasSideEffects' => false],

0 commit comments

Comments
 (0)