Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Commit c4ca9ac

Browse files
authored
Fix type error #27 (#28)
* fix type error #27 * fix phpsan errors
1 parent c3511f3 commit c4ca9ac

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

phpstan.neon

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,3 @@ parameters:
33

44
paths:
55
- src
6-
7-
ignoreErrors:
8-
- '#Parameter \#2 \$operator of method JqlBuilder\\Jql::invalidBooleanOrOperator\(\) expects string, mixed given.#'
9-
- '#Parameter \#1 \$operator of method JqlBuilder\\Jql::quote\(\) expects string, mixed given.#'
10-
- '#Part \$operator \(mixed\) of encapsed string cannot be cast to string.#'
11-
- '#Parameter \#3 \$subject of function str_replace expects array\|string, mixed given.#'
12-
- '#Parameter \#2 ...\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given.#'

src/Jql.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public function where(
4040
[$column, $operator, $value] = [$column, is_array($operator) ? Operator::IN : Operator::EQUALS, $operator];
4141
}
4242

43+
/** @var string $operator */
44+
4345
$this->invalidBooleanOrOperator($boolean, $operator, $value);
4446

4547
$this->appendQuery("{$this->escapeSpaces($column)} $operator {$this->quote($operator, $value)}", $boolean);
@@ -130,9 +132,10 @@ function ($prev, $current) {
130132
return "($values)";
131133
}
132134

133-
$value = str_replace('"', '\\"', $value);
135+
/** @var string|int $value */
136+
$escapedValue = str_replace('"', '\\"', (string) $value);
134137

135-
return "\"$value\"";
138+
return "\"$escapedValue\"";
136139
}
137140

138141
private function appendQuery(string $query, string $boolean = ''): void
@@ -147,7 +150,7 @@ private function appendQuery(string $query, string $boolean = ''): void
147150
/**
148151
* @throws \InvalidArgumentException
149152
*/
150-
private function invalidBooleanOrOperator(mixed $boolean, string $operator, mixed $value): void
153+
private function invalidBooleanOrOperator(string $boolean, string $operator, mixed $value): void
151154
{
152155
if (! in_array($boolean, [Keyword::AND, Keyword::OR])) {
153156
throw new InvalidArgumentException(sprintf(

0 commit comments

Comments
 (0)