-
-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not cast BackedEnum identifiers
- Loading branch information
Showing
4 changed files
with
188 additions
and
2 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
24 changes: 24 additions & 0 deletions
24
tests/Common/Proxy/LazyLoadableObjectWithPHP81EnumIntType.php
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,24 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\Common\Proxy; | ||
|
||
class LazyLoadableObjectWithPHP81EnumIntType | ||
{ | ||
private LazyLoadableObjectWithPHP81EnumIntTypeIdentfier $identifierFieldEnumIntType; | ||
|
||
public function getIdentifierFieldEnumIntType(): LazyLoadableObjectWithPHP81EnumIntTypeIdentfier | ||
{ | ||
return $this->identifierFieldEnumIntType; | ||
} | ||
|
||
public static function getFooIdentifier(): LazyLoadableObjectWithPHP81EnumIntTypeIdentfier | ||
{ | ||
return LazyLoadableObjectWithPHP81EnumIntTypeIdentfier::FOO; | ||
} | ||
} | ||
|
||
enum LazyLoadableObjectWithPHP81EnumIntTypeIdentfier: int | ||
{ | ||
case FOO = 1; | ||
case BAR = 2; | ||
} |
157 changes: 157 additions & 0 deletions
157
tests/Common/Proxy/LazyLoadableObjectWithPHP81EnumIntTypeClassMetadata.php
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,157 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\Common\Proxy; | ||
|
||
use BadMethodCallException; | ||
use Doctrine\Persistence\Mapping\ClassMetadata; | ||
use ReflectionClass; | ||
use function array_keys; | ||
|
||
class LazyLoadableObjectWithPHP81EnumIntTypeClassMetadata implements ClassMetadata | ||
{ | ||
/** @var ReflectionClass */ | ||
protected $reflectionClass; | ||
|
||
/** @var array<string,bool> */ | ||
protected $identifier = [ | ||
'identifierFieldEnumIntType' => true, | ||
]; | ||
|
||
/** @var array<string,bool> */ | ||
protected $fields = [ | ||
'identifierFieldEnumIntType' => true, | ||
]; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->getReflectionClass()->getName(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getIdentifier() | ||
{ | ||
return array_keys($this->identifier); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getReflectionClass() | ||
{ | ||
if ($this->reflectionClass === null) { | ||
$this->reflectionClass = new ReflectionClass(__NAMESPACE__ . '\LazyLoadableObjectWithPHP81EnumIntType'); | ||
} | ||
|
||
return $this->reflectionClass; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function isIdentifier($fieldName) | ||
{ | ||
return isset($this->identifier[$fieldName]); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function hasField($fieldName) | ||
{ | ||
return isset($this->fields[$fieldName]); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function hasAssociation($fieldName) | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function isSingleValuedAssociation($fieldName) | ||
{ | ||
throw new BadMethodCallException('not implemented'); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function isCollectionValuedAssociation($fieldName) | ||
{ | ||
throw new BadMethodCallException('not implemented'); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getFieldNames() | ||
{ | ||
return array_keys($this->fields); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getIdentifierFieldNames() | ||
{ | ||
return $this->getIdentifier(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getAssociationNames() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getTypeOfField($fieldName) | ||
{ | ||
return 'integer'; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getAssociationTargetClass($assocName) | ||
{ | ||
throw new BadMethodCallException('not implemented'); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function isAssociationInverseSide($assocName) | ||
{ | ||
throw new BadMethodCallException('not implemented'); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getAssociationMappedByTargetField($assocName) | ||
{ | ||
throw new BadMethodCallException('not implemented'); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getIdentifierValues($object) | ||
{ | ||
throw new BadMethodCallException('not implemented'); | ||
} | ||
} |
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