-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/1.3.x' into 1.4.x
- Loading branch information
Showing
6 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Type\Doctrine\Descriptors; | ||
|
||
use PHPStan\Type\StringType; | ||
use PHPStan\Type\Type; | ||
|
||
class AsciiStringType implements DoctrineTypeDescriptor | ||
{ | ||
|
||
public function getType(): string | ||
{ | ||
return \Doctrine\DBAL\Types\AsciiStringType::class; | ||
} | ||
|
||
public function getWritableToPropertyType(): Type | ||
{ | ||
return new StringType(); | ||
} | ||
|
||
public function getWritableToDatabaseType(): Type | ||
{ | ||
return new StringType(); | ||
} | ||
|
||
public function getDatabaseInternalType(): Type | ||
{ | ||
return new StringType(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Rules\Doctrine\ORM; | ||
|
||
use Doctrine\Common\Collections\Criteria; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Doctrine\ORM\Query\Expr\Andx; | ||
use Doctrine\ORM\Query\Expr\From; | ||
|
||
class DynamicCalls | ||
{ | ||
public function testDynamicMethodCall( | ||
EntityManagerInterface $em, | ||
Andx $and, | ||
Criteria $criteria, | ||
string $string | ||
): void | ||
{ | ||
$em->createQueryBuilder() | ||
->select('m') | ||
->from(MyEntity::class, 'm') | ||
->andWhere($and) | ||
->setParameter($string, $string) | ||
->setParameters([$string]) | ||
->orWhere($string) | ||
->addOrderBy($string) | ||
->addGroupBy($string) | ||
->addCriteria($criteria) | ||
->getQuery(); | ||
|
||
$em->createQueryBuilder() | ||
->select('m') | ||
->add('from', new From(MyEntity::class, 'm', null), true) | ||
->where($string) | ||
->orderBy($string) | ||
->groupBy($string) | ||
->getQuery(); | ||
|
||
// all below are disallowed dynamic | ||
$em->createQueryBuilder() | ||
->select('m') | ||
->from($string, 'm') | ||
->getQuery(); | ||
|
||
$em->createQueryBuilder() | ||
->select('m') | ||
->from(MyEntity::class, 'm') | ||
->indexBy($string, $string) | ||
->getQuery(); | ||
|
||
$em->createQueryBuilder() | ||
->select('m') | ||
->from(MyEntity::class, 'm', $string) | ||
->getQuery(); | ||
|
||
$em->createQueryBuilder() | ||
->select([$string]) | ||
->from(MyEntity::class, 'm') | ||
->getQuery(); | ||
|
||
$em->createQueryBuilder() | ||
->select(['m']) | ||
->from(MyEntity::class, $string) | ||
->getQuery(); | ||
|
||
$em->createQueryBuilder() | ||
->addSelect($string) | ||
->from(MyEntity::class, 'm') | ||
->getQuery(); | ||
|
||
$em->createQueryBuilder() | ||
->addSelect('m') | ||
->from(MyEntity::class, 'm') | ||
->join($string, $string) | ||
->getQuery(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters