-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a compat trait to address B/C issues with EntityRepository
- Loading branch information
Showing
3 changed files
with
181 additions
and
88 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,82 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Doctrine Behavioral Extensions package. | ||
* (c) Gediminas Morkevicius <[email protected]> http://www.gediminasm.org | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Gedmo\Tool\ORM\Repository; | ||
|
||
use Doctrine\ORM\EntityRepository; | ||
|
||
if ((new \ReflectionClass(EntityRepository::class))->getMethod('__call')->hasReturnType()) { | ||
// ORM 3.x | ||
/** | ||
* Helper trait to address compatibility issues between ORM 2.x and 3.x. | ||
* | ||
* @mixin EntityRepository | ||
* | ||
* @internal | ||
*/ | ||
trait EntityRepositoryCompat | ||
{ | ||
/** | ||
* @param string $method | ||
* @param array $args | ||
* | ||
* @return mixed | ||
* | ||
* @phpstan-param list<mixed> $args | ||
*/ | ||
public function __call(string $method, array $args): mixed | ||
{ | ||
return $this->doCallWithCompat($method, $args); | ||
} | ||
|
||
/** | ||
* @param string $method | ||
* @param array $args | ||
* | ||
* @return mixed | ||
* | ||
* @phpstan-param list<mixed> $args | ||
*/ | ||
abstract protected function doCallWithCompat($method, $args); | ||
} | ||
} else { | ||
// ORM 2.x | ||
/** | ||
* Helper trait to address compatibility issues between ORM 2.x and 3.x. | ||
* | ||
* @mixin EntityRepository | ||
* | ||
* @internal | ||
*/ | ||
trait EntityRepositoryCompat | ||
{ | ||
/** | ||
* @param string $method | ||
* @param array $args | ||
* | ||
* @return mixed | ||
* | ||
* @phpstan-param list<mixed> $args | ||
*/ | ||
public function __call($method, $args) | ||
{ | ||
return $this->doCallWithCompat($method, $args); | ||
} | ||
|
||
/** | ||
* @param string $method | ||
* @param array $args | ||
* | ||
* @return mixed | ||
* | ||
* @phpstan-param list<mixed> $args | ||
*/ | ||
abstract protected function doCallWithCompat($method, $args); | ||
} | ||
} |
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