-
-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ProxyGenerator): update regex pattern to match simple id getters…
… with custom id type
- Loading branch information
Showing
7 changed files
with
403 additions
and
5 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,26 @@ | ||
<?php | ||
namespace Doctrine\Tests\Common\Proxy; | ||
|
||
use Doctrine; | ||
|
||
/** | ||
* Test asset representing a lazy loadable object | ||
*/ | ||
class LazyLoadableObjectWithCustomIdType | ||
{ | ||
/** @var string */ | ||
private $identifierFieldWithStaticVOConstructor; | ||
|
||
/** @var string */ | ||
private $identifierFieldWithVOConstructor; | ||
|
||
public function getIdentifierFieldWithStaticVOConstructor() : ValueId | ||
{ | ||
return ValueId::new($this->identifierFieldWithStaticVOConstructor); | ||
} | ||
|
||
public function getIdentifierFieldWithVOConstructor() : ValueId | ||
{ | ||
return new ValueId($this->identifierFieldWithVOConstructor); | ||
} | ||
} |
164 changes: 164 additions & 0 deletions
164
tests/Common/Proxy/LazyLoadableObjectWithCustomIdTypeClassMetadata.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,164 @@ | ||
<?php | ||
namespace Doctrine\Tests\Common\Proxy; | ||
|
||
use Doctrine\Persistence\Mapping\ClassMetadata; | ||
use ReflectionClass; | ||
|
||
/** | ||
* Class metadata test asset for @see LazyLoadableObject | ||
*/ | ||
class LazyLoadableObjectWithCustomIdTypeClassMetadata implements ClassMetadata | ||
{ | ||
/** | ||
* @var ReflectionClass | ||
*/ | ||
protected $reflectionClass; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $identifier = [ | ||
'identifierFieldWithStaticVOConstructor' => true, | ||
'identifierFieldWithVOConstructor' => true, | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $fields = [ | ||
'identifierFieldWithStaticVOConstructor' => true, | ||
'identifierFieldWithVOConstructor' => true, | ||
]; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->getReflectionClass()->getName(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getIdentifier() | ||
{ | ||
return array_keys($this->identifier); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getReflectionClass() | ||
{ | ||
if (null === $this->reflectionClass) { | ||
$this->reflectionClass = new \ReflectionClass(__NAMESPACE__ . '\LazyLoadableObjectWithCustomIdType'); | ||
} | ||
|
||
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 'string'; | ||
} | ||
|
||
/** | ||
* {@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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
namespace Doctrine\Tests\Common\Proxy; | ||
|
||
use Doctrine; | ||
|
||
/** | ||
* Test asset representing a lazy loadable object | ||
*/ | ||
class LazyLoadableObjectWithNoGetPrefix | ||
{ | ||
/** @var string */ | ||
private $identifierField; | ||
|
||
public function identifierField() : ValueId | ||
{ | ||
return new ValueId($this->identifierField); | ||
} | ||
|
||
} |
162 changes: 162 additions & 0 deletions
162
tests/Common/Proxy/LazyLoadableObjectWithNoGetPrefixClassMetadata.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,162 @@ | ||
<?php | ||
namespace Doctrine\Tests\Common\Proxy; | ||
|
||
use Doctrine\Persistence\Mapping\ClassMetadata; | ||
use ReflectionClass; | ||
|
||
/** | ||
* Class metadata test asset for @see LazyLoadableObject | ||
*/ | ||
class LazyLoadableObjectWithNoGetPrefixClassMetadata implements ClassMetadata | ||
{ | ||
/** | ||
* @var ReflectionClass | ||
*/ | ||
protected $reflectionClass; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $identifier = [ | ||
'identifierField' => true, | ||
]; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $fields = [ | ||
'identifierField' => true, | ||
]; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->getReflectionClass()->getName(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getIdentifier() | ||
{ | ||
return array_keys($this->identifier); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getReflectionClass() | ||
{ | ||
if (null === $this->reflectionClass) { | ||
$this->reflectionClass = new \ReflectionClass(__NAMESPACE__ . '\LazyLoadableObjectWithNoGetPrefix'); | ||
} | ||
|
||
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 'string'; | ||
} | ||
|
||
/** | ||
* {@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'); | ||
} | ||
} |
Oops, something went wrong.