Issues (83)

src/Builder/Helpers/ConditionAddHelper.php (1 issue)

Labels
Severity
1
<?php
2
namespace Kir\MySQL\Builder\Helpers;
3
4
use Kir\MySQL\Builder\Expr\OptionalExpression;
5
use Kir\MySQL\Builder\Internal\Types;
6
use Kir\MySQL\Builder\Traits\WhereBuilder;
7
8
/**
9
 * @phpstan-import-type DBParameterValueType from Types
10
 * @phpstan-import-type DBWhereExpressionType from WhereBuilder
11
 */
12
abstract class ConditionAddHelper {
13
	/**
14
	 * @param callable(string|array<string, null|scalar>, array<int, DBParameterValueType>): void $addFn
15
	 * @param DBWhereExpressionType $expression
0 ignored issues
show
The type Kir\MySQL\Builder\Helpers\DBWhereExpressionType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
	 * @param array<DBParameterValueType> $args
17
	 */
18
	public static function addCondition(callable $addFn, $expression, array $args): void {
19
		if($expression instanceof OptionalExpression) {
20
			if($expression->isValid()) {
21
				$addFn($expression->getExpression(), [$expression->getValue()]);
22
			}
23
		} elseif(is_object($expression)) {
24
			self::addAsArray($addFn, (array) $expression, $args);
25
		} elseif(is_array($expression)) {
26
			self::addAsArray($addFn, $expression, $args);
27
		} else {
28
			$addFn($expression, $args);
29
		}
30
	}
31
32
	/**
33
	 * @param callable(string|array<string, mixed>, array<int, mixed>): void $addFn
34
	 * @param array<string, mixed> $expression
35
	 * @param array<int, DBParameterValueType> $args
36
	 */
37
	private static function addAsArray(callable $addFn, array $expression, array $args): void {
38
		if(count($expression) > 0) {
39
			$addFn($expression, $args);
40
		}
41
	}
42
}
43