Skip to content

Commit 5a5454c

Browse files
authored
literal-string in QueryBuilder::where()
* Start implementing literal-string checks with bleedingEdge * Use array<mixed> for where() for now * Use original stub whe not using bleedingEdge * Preserve QueryBuilder methods from original stub * Move stubs to a bleedingEdge sub-folder * Add 'use function' for phpcs
1 parent aefeca7 commit 5a5454c

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

extension.neon

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ parameters:
3838
- stubs/Collections/ArrayCollection.stub
3939
- stubs/Collections/Collection.stub
4040
- stubs/Collections/Selectable.stub
41-
- stubs/ORM/QueryBuilder.stub
4241
- stubs/ORM/AbstractQuery.stub
4342
- stubs/ORM/Mapping/ClassMetadata.stub
4443
- stubs/ORM/Mapping/ClassMetadataInfo.stub
@@ -151,6 +150,13 @@ services:
151150
descendIntoOtherMethods: %doctrine.searchOtherMethodsForQueryBuilderBeginning%
152151
parser: @defaultAnalysisParser
153152

153+
-
154+
class: PHPStan\Stubs\Doctrine\StubFilesExtensionLoader
155+
tags:
156+
- phpstan.stubFilesExtension
157+
arguments:
158+
bleedingEdge: %featureToggles.bleedingEdge%
159+
154160
doctrineQueryBuilderArgumentsProcessor:
155161
class: PHPStan\Type\Doctrine\ArgumentsProcessor
156162
autowired: false
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Stubs\Doctrine;
4+
5+
use PHPStan\PhpDoc\StubFilesExtension;
6+
use function dirname;
7+
8+
class StubFilesExtensionLoader implements StubFilesExtension
9+
{
10+
11+
/** @var bool */
12+
private $bleedingEdge;
13+
14+
public function __construct(
15+
bool $bleedingEdge
16+
)
17+
{
18+
$this->bleedingEdge = $bleedingEdge;
19+
}
20+
21+
public function getFiles(): array
22+
{
23+
$path = dirname(dirname(dirname(__DIR__))) . '/stubs';
24+
25+
if ($this->bleedingEdge === true) {
26+
$path .= '/bleedingEdge';
27+
}
28+
29+
return [
30+
$path . '/ORM/QueryBuilder.stub',
31+
];
32+
}
33+
34+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Doctrine\ORM;
4+
5+
class QueryBuilder
6+
{
7+
8+
/**
9+
* @return Query<mixed>
10+
*/
11+
public function getQuery()
12+
{
13+
}
14+
15+
/**
16+
* @param \Doctrine\Common\Collections\ArrayCollection<array-key, mixed>|array<mixed> $parameters
17+
* @return static
18+
*/
19+
public function setParameters($parameters)
20+
{
21+
22+
}
23+
24+
/**
25+
* @param literal-string|object|array<mixed> $predicates
26+
* @return $this
27+
*/
28+
public function where($predicates)
29+
{
30+
31+
}
32+
33+
}

0 commit comments

Comments
 (0)