Skip to content

Commit

Permalink
make sure recording information works consistent across OS (line deli…
Browse files Browse the repository at this point in the history
…ms) (#374)

Co-authored-by: Markus Staab <[email protected]>
  • Loading branch information
staabm and clxmstaab authored May 23, 2022
1 parent 3b7761e commit 2011d67
Show file tree
Hide file tree
Showing 26 changed files with 6,536 additions and 11,945 deletions.
371 changes: 361 additions & 10 deletions .phpstan-dba-mysqli.cache

Large diffs are not rendered by default.

366 changes: 355 additions & 11 deletions .phpstan-dba-pdo.cache

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions src/QueryReflection/QueryReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,26 @@ public function resolveQueryStrings(Expr $queryExpr, Scope $scope): iterable

if ($type instanceof UnionType) {
foreach (TypeUtils::getConstantStrings($type) as $constantString) {
yield $constantString->getValue();
yield $this->normalizeQueryString($constantString->getValue());
}

return;
}

$queryString = $this->resolveQueryExpr($queryExpr, $scope);
if (null !== $queryString) {
yield $queryString;
yield $this->normalizeQueryString($queryString);
}
}

/**
* Make sure query string work consistently across operating systems.
*/
private function normalizeQueryString(string $queryString): string
{
return str_replace("\r\n", "\n", $queryString);
}

/**
* @deprecated use resolveQueryStrings() instead
*
Expand Down
2 changes: 1 addition & 1 deletion src/QueryReflection/ReflectionCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

final class ReflectionCache
{
public const SCHEMA_VERSION = 'v6-schema-hash';
public const SCHEMA_VERSION = 'v7-normalized-eol';

/**
* @var string
Expand Down
1 change: 1 addition & 0 deletions tests/default/DbaInferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function dataFileAsserts(): iterable

yield from $this->gatherAssertTypes(__DIR__.'/data/pdo-union-result.php');
yield from $this->gatherAssertTypes(__DIR__.'/data/mysqli-union-result.php');
yield from $this->gatherAssertTypes(__DIR__.'/data/bug372.php');
}

/**
Expand Down
Loading

0 comments on commit 2011d67

Please sign in to comment.