Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions .phpstan-dba.cache

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/QueryReflection/MysqliQueryReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ final class MysqliQueryReflector implements QueryReflector

public const MYSQL_HOST_NOT_FOUND = 2002;

public const DATE_FORMAT = 'Y-m-d';

private const MAX_CACHE_SIZE = 50;

/**
Expand Down
5 changes: 4 additions & 1 deletion src/QueryReflection/QuerySimulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ public static function simulateParamValueType(Type $paramType, bool $preparedPar
if ($stringType->isSuperTypeOf($paramType)->yes() || $paramType instanceof ObjectType && $paramType->isInstanceOf(Stringable::class)->yes()) {
// in a prepared context, regular strings are fine
if (true === $preparedParam) {
return '1';
// returns a string in date-format, so in case the simulated value is used against a date/datetime column
// we won't run into a sql error.
// XX in case we would have a proper sql parser, we could feed schema-type-dependent default values in case of strings.
return date(MysqliQueryReflector::DATE_FORMAT);
}

// plain string types can contain anything.. we cannot reason about it
Expand Down
Loading