Skip to content

Commit

Permalink
Defend against an essentially impossible type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bakert committed Oct 8, 2024
1 parent 1e3ac98 commit 6bf6710
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 3 additions & 0 deletions gatherling/Data/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ private static function _execute(string $sql, array $params, callable $operation
private static function safeName(string $name): string
{
$safeName = preg_replace('/[^a-zA-Z0-9_]/', '_', $name);
if ($safeName === null) {
throw new DatabaseException("Failed to safely name $name");
}
$safeName = trim($safeName, '_');
if (empty($safeName) || is_numeric($safeName[0])) {
$safeName = 'sp_'.$safeName;
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ parameters:
count: 1
path: gatherling/Data/DB.php

-
message: "#^Parameter \\#1 \\$string of function trim expects string, string\\|null given\\.$#"
count: 1
path: gatherling/Data/DB.php

-
message: "#^Parameter \\#2 \\$params of static method Gatherling\\\\Data\\\\DB\\:\\:_execute\\(\\) expects array\\<string, mixed\\>, mixed given\\.$#"
count: 1
Expand Down

0 comments on commit 6bf6710

Please sign in to comment.