diff --git a/lib/Doctrine/ODM/PHPCR/DocumentClassMapper.php b/lib/Doctrine/ODM/PHPCR/DocumentClassMapper.php
index c6837b568..fe07d7b93 100644
--- a/lib/Doctrine/ODM/PHPCR/DocumentClassMapper.php
+++ b/lib/Doctrine/ODM/PHPCR/DocumentClassMapper.php
@@ -19,7 +19,7 @@ private function expandClassName(DocumentManagerInterface $dm, string $className
return null;
}
- if (false !== strpos($className, ':')) {
+ if (str_contains($className, ':')) {
$className = $dm->getClassMetadata($className)->getName();
}
diff --git a/lib/Doctrine/ODM/PHPCR/DocumentManager.php b/lib/Doctrine/ODM/PHPCR/DocumentManager.php
index 6ac78eedd..8dc0953e1 100644
--- a/lib/Doctrine/ODM/PHPCR/DocumentManager.php
+++ b/lib/Doctrine/ODM/PHPCR/DocumentManager.php
@@ -56,9 +56,9 @@ class DocumentManager implements DocumentManagerInterface
/**
* @var TranslationStrategyInterface[]
*/
- protected array $translationStrategy;
+ private array $translationStrategy;
- protected LocaleChooserInterface $localeChooserStrategy;
+ private LocaleChooserInterface $localeChooserStrategy;
private ValueConverter $valueConverter;
public function __construct(SessionInterface $session, Configuration $config = null, EventManager $evm = null)
@@ -182,7 +182,7 @@ public function find(?string $className, $id): ?object
} catch (ItemNotFoundException $e) {
return null;
}
- } elseif (0 !== strpos($id, '/')) {
+ } elseif (!str_starts_with($id, '/')) {
$id = '/'.$id;
}
@@ -220,7 +220,7 @@ public function findMany(?string $className, array $ids): Collection
foreach ($ids as $key => $id) {
if (UUIDHelper::isUUID($id)) {
$uuids[$id] = $key;
- } elseif (0 !== strpos($id, '/')) {
+ } elseif (!str_starts_with($id, '/')) {
$ids[$key] = '/'.$id;
}
}
@@ -257,7 +257,7 @@ public function findTranslation(?string $className, string $id, string $locale,
} catch (ItemNotFoundException $e) {
return null;
}
- } elseif (0 !== strpos($id, '/')) {
+ } elseif (!str_starts_with($id, '/')) {
$id = '/'.$id;
}
@@ -424,7 +424,7 @@ public function isDocumentTranslatable(object $document): bool
public function move(object $document, string $targetPath): void
{
- if (0 !== strpos($targetPath, '/')) {
+ if (!str_starts_with($targetPath, '/')) {
$targetPath = '/'.$targetPath;
}
diff --git a/lib/Doctrine/ODM/PHPCR/DocumentRepository.php b/lib/Doctrine/ODM/PHPCR/DocumentRepository.php
index 8b39524c3..584f18117 100644
--- a/lib/Doctrine/ODM/PHPCR/DocumentRepository.php
+++ b/lib/Doctrine/ODM/PHPCR/DocumentRepository.php
@@ -58,20 +58,16 @@ public function find($id): ?object
* The ids may either be PHPCR paths or UUID's, but all must be of the same type
*
* @param string[] $ids document ids
- *
- * @return array|Collection of document objects
*/
- public function findMany(array $ids): iterable
+ public function findMany(array $ids): Collection
{
return $this->dm->findMany($this->className, $ids);
}
/**
* Finds all documents in the repository.
- *
- * @return array|Collection the entities
*/
- public function findAll(): iterable
+ public function findAll(): Collection
{
return $this->findBy([]);
}
@@ -83,12 +79,9 @@ public function findAll(): iterable
* an InvalidArgumentException if certain values of the sorting or limiting details are
* not supported.
*
- * @param int|null $limit
- * @param int|null $offset
- *
- * @return array|Collection the objects matching the criteria
+ * @return Collection the objects matching the criteria
*/
- public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): iterable
+ public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): Collection
{
$qb = $this->createQueryBuilder('a');
@@ -146,7 +139,7 @@ public function findBy(array $criteria, array $orderBy = null, $limit = null, $o
* @param mixed $value The value to search for
* @param string $alias The alias used
*/
- protected function constraintField(ConstraintFactory $where, string $field, $value, string $alias): void
+ protected function constraintField(ConstraintFactory $where, string $field, mixed $value, string $alias): void
{
if ($field === $this->class->nodename) {
$where->eq()->name($alias)->literal($value);
diff --git a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php
index 6cbb54040..11f8c29d3 100644
--- a/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php
+++ b/lib/Doctrine/ODM/PHPCR/Mapping/ClassMetadata.php
@@ -73,7 +73,7 @@ class ClassMetadata implements ClassMetadataInterface
*/
public const GENERATOR_TYPE_AUTO = 4;
- protected static $validVersionableMappings = ['simple', 'full'];
+ private static $validVersionableMappings = ['simple', 'full'];
/**
* READ-ONLY: The ReflectionProperty instances of the mapped class.
@@ -837,7 +837,7 @@ public function mapLifecycleCallbacks(array $mapping): void
*
* @throws MappingException
*/
- protected function validateAndCompleteFieldMapping(array $mapping, self $inherited = null, bool $isField = true, $phpcrLabel = 'property'): array
+ private function validateAndCompleteFieldMapping(array $mapping, self $inherited = null, bool $isField = true, $phpcrLabel = 'property'): array
{
if ($inherited) {
if (!array_key_exists('inherited', $mapping)) {
@@ -916,10 +916,7 @@ protected function validateAndCompleteFieldMapping(array $mapping, self $inherit
return $mapping;
}
- /**
- * @param string|bool $phpcrLabel
- */
- protected function validateAndCompleteAssociationMapping(array $mapping, self $inherited = null, $phpcrLabel = 'property'): array
+ private function validateAndCompleteAssociationMapping(array $mapping, self $inherited = null, bool|string $phpcrLabel = 'property'): array
{
$mapping = $this->validateAndCompleteFieldMapping($mapping, $inherited, false, $phpcrLabel);
if ($inherited) {
@@ -1083,7 +1080,7 @@ public function mapManyToMany(array $mapping, self $inherited = null): void
/**
* Sets the ID generator used to generate IDs for instances of this class.
*/
- protected function setIdGenerator(int|string $generator): void
+ private function setIdGenerator(int|string $generator): void
{
if (is_string($generator)) {
$generator = constant('Doctrine\ODM\PHPCR\Mapping\ClassMetadata::GENERATOR_TYPE_'.strtoupper($generator));
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/AbstractLeafNode.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/AbstractLeafNode.php
index dbb25154c..48b36e17f 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/AbstractLeafNode.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/AbstractLeafNode.php
@@ -12,12 +12,12 @@
*/
abstract class AbstractLeafNode extends AbstractNode
{
- public function getNext()
+ public function getNext(): ?AbstractNode
{
return $this->getParent();
}
- public function getChildren()
+ public function getChildren(): array
{
throw new RuntimeException(sprintf(
'Cannot call getChildren on leaf node "%s"',
@@ -25,7 +25,7 @@ public function getChildren()
));
}
- public function addChild(AbstractNode $node)
+ public function addChild(AbstractNode $node): static
{
throw new RuntimeException(sprintf(
'Cannot call addChild to leaf node "%s"',
@@ -33,7 +33,7 @@ public function addChild(AbstractNode $node)
));
}
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
// no children , no cardinality map...
return [];
@@ -47,15 +47,13 @@ public function getCardinalityMap()
*
* e.g. my_alias.first_name
*
- * @param string $field
- *
- * @return array
+ * @return string[] with exactly 2 elements
*/
- protected function explodeField($field)
+ protected function explodeField(string $field): array
{
$parts = explode('.', $field);
- if (2 == count($parts)) {
+ if (2 === count($parts)) {
return $parts;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/AbstractNode.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/AbstractNode.php
index dac78de27..777ce3b30 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/AbstractNode.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/AbstractNode.php
@@ -60,11 +60,11 @@ abstract class AbstractNode
public const NT_WHERE_OR = 'where_or';
- protected $children = [];
+ private array $children = [];
- protected $parent;
+ private ?AbstractNode $parent;
- public function __construct(self $parent = null)
+ public function __construct(AbstractNode $parent = null)
{
$this->parent = $parent;
}
@@ -73,17 +73,13 @@ public function __construct(self $parent = null)
* Return the type of node.
*
* Must be one of self::NT_*
- *
- * @return string
*/
- abstract public function getNodeType();
+ abstract public function getNodeType(): string;
/**
* Return the parent of this node.
- *
- * @return AbstractNode
*/
- public function getParent()
+ public function getParent(): ?AbstractNode
{
return $this->parent;
}
@@ -93,15 +89,12 @@ public function getParent()
*
* This should only be used when generating exceptions
* This is also used to determine the dispatching method -- should it be?
- *
- * @return string
*/
- final public function getName()
+ final public function getName(): string
{
$refl = new \ReflectionClass($this);
- $short = $refl->getShortName();
- return $short;
+ return $refl->getShortName();
}
/**
@@ -123,9 +116,9 @@ final public function getName()
* self::NT_PROPERTY => array(null, 1), // require none to 1 properties
* );
*
- * @return array
+ * @return array>
*/
- abstract public function getCardinalityMap();
+ abstract public function getCardinalityMap(): array;
/**
* Remove any previous children and add
@@ -133,10 +126,8 @@ abstract public function getCardinalityMap();
*
* @see removeChildrenOfType
* @see addChild
- *
- * @return AbstractNode
*/
- public function setChild(self $node)
+ public function setChild(AbstractNode $node): AbstractNode
{
$this->removeChildrenOfType($node->getNodeType());
@@ -154,11 +145,9 @@ public function setChild(self $node)
* The given node will be returned EXCEPT when the current
* node is a leaf node, in which case we return the parent.
*
- * @return AbstractNode
- *
* @throws OutOfBoundsException
*/
- public function addChild(self $node)
+ public function addChild(AbstractNode $node): AbstractNode
{
$cardinalityMap = $this->getCardinalityMap();
$nodeType = $node->getNodeType();
@@ -199,12 +188,10 @@ public function addChild(self $node)
/**
* Return the next object in the fluid interface
- * chain. Leaf nodes always return the parent, deafult
+ * chain. Leaf nodes always return the parent, default
* behavior is to return /this/ class.
- *
- * @return AbstractNode
*/
- public function getNext()
+ public function getNext(): ?AbstractNode
{
return $this;
}
@@ -217,7 +204,7 @@ public function getNext()
*
* @return AbstractNode[]
*/
- public function getChildren()
+ public function getChildren(): array
{
$children = [];
foreach ($this->children as $type) {
@@ -232,16 +219,14 @@ public function getChildren()
/**
* Return children of specified type.
*
- * @param string $type the type name
- *
* @return AbstractNode[]
*/
- public function getChildrenOfType($type)
+ public function getChildrenOfType(string $type): array
{
return $this->children[$type] ?? [];
}
- public function removeChildrenOfType($type)
+ public function removeChildrenOfType(string $type): void
{
unset($this->children[$type]);
}
@@ -249,19 +234,14 @@ public function removeChildrenOfType($type)
/**
* Return child of node, there must be exactly one child of any type.
*
- * @return AbstractNode
- *
* @throws OutOfBoundsException if there are more than one or none
*/
- public function getChild()
+ public function getChild(): AbstractNode
{
$children = $this->getChildren();
if (!$children) {
- throw new OutOfBoundsException(sprintf(
- 'Expected exactly one child, got "%s"',
- count($children)
- ));
+ throw new OutOfBoundsException('Expected exactly one child, got none');
}
if (count($children) > 1) {
@@ -279,21 +259,16 @@ public function getChild()
*
* Note: This does not take inheritance into account.
*
- * @param string $type the name of the type
- *
- * @return AbstractNode
- *
* @throws OutOfBoundsException if there are more than one or none
*/
- public function getChildOfType($type)
+ public function getChildOfType(string $type): AbstractNode
{
$children = $this->getChildrenOfType($type);
if (!$children) {
throw new OutOfBoundsException(sprintf(
- 'Expected exactly one child of type "%s", got "%s"',
+ 'Expected exactly one child of type "%s", got none',
$type,
- count($children)
));
}
@@ -313,13 +288,13 @@ public function getChildOfType($type)
* Validation is performed both when the query is being
* built and when the dev explicitly calls "end()".
*
- * This method simply checks the minimum boundries are satisfied,
- * the addChild() method already validates maximum boundries and
+ * This method simply checks the minimum boundaries are satisfied,
+ * the addChild() method already validates maximum boundaries and
* types.
*
* @throws OutOfBoundsException
*/
- public function validate()
+ public function validate(): void
{
$cardinalityMap = $this->getCardinalityMap();
$typeCount = [];
@@ -351,10 +326,8 @@ public function validate()
* Validates this node and returns its parent.
* This should be used if the developer wants to
* define the entire Query in a fluid manner.
- *
- * @return AbstractNode
*/
- public function end()
+ public function end(): ?AbstractNode
{
$this->validate();
@@ -370,7 +343,7 @@ public function end()
*
* @throws BadMethodCallException if an unknown method is called
*/
- public function __call($methodName, $args)
+ public function __call(string $methodName, array $args): never
{
throw new BadMethodCallException(sprintf(
'Unknown method "%s" called on node "%s", did you mean one of: "%s"',
@@ -380,7 +353,7 @@ public function __call($methodName, $args)
));
}
- public function ensureNoArguments($method, $void)
+ public function ensureNoArguments(string $method, $void): void
{
if ($void) {
throw new InvalidArgumentException(sprintf(
@@ -390,17 +363,18 @@ public function ensureNoArguments($method, $void)
}
}
- public function getFactoryMethods()
+ /**
+ * @return string[]
+ */
+ public function getFactoryMethods(): array
{
$refl = new \ReflectionClass($this);
$fMethods = [];
foreach ($refl->getMethods() as $rMethod) {
$comment = $rMethod->getDocComment();
- if ($comment) {
- if (false !== strpos($comment, '@factoryMethod')) {
- $fMethods[] = $rMethod->name;
- }
+ if ($comment && str_contains($comment, '@factoryMethod')) {
+ $fMethods[] = $rMethod->name;
}
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintAndx.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintAndx.php
index e6f5234c9..d9135d76e 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintAndx.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintAndx.php
@@ -14,12 +14,12 @@
*/
class ConstraintAndx extends ConstraintFactory
{
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_CONSTRAINT;
}
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_CONSTRAINT => [1, null],
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintChild.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintChild.php
index 791ad3f6c..c2e7f118e 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintChild.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintChild.php
@@ -10,34 +10,27 @@
*/
class ConstraintChild extends AbstractLeafNode
{
- /**
- * @var string
- */
- private $alias;
+ private string $alias;
+ private string $parentPath;
- /**
- * @var string
- */
- private $parentPath;
-
- public function __construct(AbstractNode $parent, $alias, $parentPath)
+ public function __construct(AbstractNode $parent, string $alias, string $parentPath)
{
$this->alias = $alias;
$this->parentPath = $parentPath;
parent::__construct($parent);
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_CONSTRAINT;
}
- public function getParentPath()
+ public function getParentPath(): string
{
return $this->parentPath;
}
- public function getAlias()
+ public function getAlias(): string
{
return $this->alias;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintComparison.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintComparison.php
index 40c05c547..020a0beb1 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintComparison.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintComparison.php
@@ -24,9 +24,15 @@
*/
class ConstraintComparison extends OperandFactory
{
- protected $operator;
+ private string $operator;
- public function getCardinalityMap()
+ public function __construct(AbstractNode $parent, string $operator)
+ {
+ $this->operator = $operator;
+ parent::__construct($parent);
+ }
+
+ public function getCardinalityMap(): array
{
return [
self::NT_OPERAND_DYNAMIC => ['1', '1'],
@@ -34,18 +40,12 @@ public function getCardinalityMap()
];
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_CONSTRAINT;
}
- public function __construct(AbstractNode $parent, $operator)
- {
- $this->operator = $operator;
- parent::__construct($parent);
- }
-
- public function getOperator()
+ public function getOperator(): string
{
return $this->operator;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintDescendant.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintDescendant.php
index 8c3d83f21..7f6a14591 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintDescendant.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintDescendant.php
@@ -10,28 +10,27 @@
*/
class ConstraintDescendant extends AbstractLeafNode
{
- protected $alias;
+ private string $alias;
+ private string $ancestorPath;
- protected $ancestorPath;
-
- public function __construct(AbstractNode $parent, $alias, $ancestorPath)
+ public function __construct(AbstractNode $parent, string $alias, string $ancestorPath)
{
$this->alias = $alias;
$this->ancestorPath = $ancestorPath;
parent::__construct($parent);
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_CONSTRAINT;
}
- public function getAncestorPath()
+ public function getAncestorPath(): string
{
return $this->ancestorPath;
}
- public function getAlias()
+ public function getAlias(): string
{
return $this->alias;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintFactory.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintFactory.php
index 11b2c2f35..4f9ec016f 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintFactory.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintFactory.php
@@ -14,14 +14,14 @@
*/
class ConstraintFactory extends AbstractNode
{
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_CONSTRAINT => [1, 1],
];
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_CONSTRAINT_FACTORY;
}
@@ -71,10 +71,8 @@ public function getNodeType()
*
*
* @factoryMethod ConstraintAndx
- *
- * @return ConstraintAndx
*/
- public function andX()
+ public function andX(): ConstraintAndx
{
return $this->addChild(new ConstraintAndx($this));
}
@@ -94,10 +92,8 @@ public function andX()
* As with "andX", "orX" allows one to many operands.
*
* @factoryMethod ConstraintOrx
- *
- * @return ConstraintOrx
*/
- public function orX()
+ public function orX(): ConstraintOrx
{
return $this->addChild(new ConstraintOrx($this));
}
@@ -112,10 +108,8 @@ public function orX()
* @param string $field - Field to check
*
* @factoryMethod ConstraintFieldIsset
- *
- * @return ConstraintFactory
*/
- public function fieldIsset($field)
+ public function fieldIsset(string $field): ConstraintFactory
{
return $this->addChild(new ConstraintFieldIsset($this, $field));
}
@@ -131,10 +125,8 @@ public function fieldIsset($field)
* @param string $fullTextSearchExpression - Search expression
*
* @factoryMethod ConstraintFullTextSearch
- *
- * @return ConstraintFactory
*/
- public function fullTextSearch($field, $fullTextSearchExpression)
+ public function fullTextSearch(string $field, string $fullTextSearchExpression): ConstraintFactory
{
return $this->addChild(new ConstraintFullTextSearch($this, $field, $fullTextSearchExpression));
}
@@ -152,10 +144,8 @@ public function fullTextSearch($field, $fullTextSearchExpression)
* @param string $alias - Name of alias to use
*
* @factoryMethod ConstraintSame
- *
- * @return ConstraintFactory
*/
- public function same($path, $alias)
+ public function same(string $path, string $alias): ConstraintFactory
{
return $this->addChild(new ConstraintSame($this, $alias, $path));
}
@@ -173,10 +163,8 @@ public function same($path, $alias)
* @param string $alias - Name of alias to use
*
* @factoryMethod ConstraintDescendant
- *
- * @return ConstraintFactory
*/
- public function descendant($ancestorPath, $alias)
+ public function descendant(string $ancestorPath, string $alias): ConstraintFactory
{
return $this->addChild(new ConstraintDescendant($this, $alias, $ancestorPath));
}
@@ -194,10 +182,8 @@ public function descendant($ancestorPath, $alias)
* @param string $alias - Name of alias to use
*
* @factoryMethod ConstraintChild
- *
- * @return ConstraintFactory
*/
- public function child($parentPath, $alias)
+ public function child(string $parentPath, string $alias): ConstraintFactory
{
return $this->addChild(new ConstraintChild($this, $alias, $parentPath));
}
@@ -205,9 +191,9 @@ public function child($parentPath, $alias)
/**
* Inverts the truth of the given appended constraint.
*
- * @return ConstraintFactory
+ * @factoryMethod ConstraintNot
*/
- public function not()
+ public function not(): ConstraintFactory
{
return $this->addChild(new ConstraintNot($this));
}
@@ -224,10 +210,8 @@ public function not()
*
*
* @factoryMethod ConstraintComparison
- *
- * @return ConstraintComparison
*/
- public function eq()
+ public function eq(): ConstraintComparison
{
return $this->addChild(new ConstraintComparison(
$this,
@@ -247,10 +231,8 @@ public function eq()
*
*
* @factoryMethod ConstraintComparison
- *
- * @return ConstraintComparison
*/
- public function neq()
+ public function neq(): ConstraintComparison
{
return $this->addChild(new ConstraintComparison(
$this,
@@ -270,10 +252,8 @@ public function neq()
*
*
* @factoryMethod ConstraintComparison
- *
- * @return ConstraintComparison
*/
- public function lt()
+ public function lt(): ConstraintComparison
{
return $this->addChild(new ConstraintComparison(
$this,
@@ -293,10 +273,8 @@ public function lt()
*
*
* @factoryMethod ConstraintComparison
- *
- * @return ConstraintComparison
*/
- public function lte()
+ public function lte(): ConstraintComparison
{
return $this->addChild(new ConstraintComparison(
$this,
@@ -316,10 +294,8 @@ public function lte()
*
*
* @factoryMethod ConstraintComparison
- *
- * @return ConstraintComparison
*/
- public function gt()
+ public function gt(): ConstraintComparison
{
return $this->addChild(new ConstraintComparison(
$this,
@@ -339,10 +315,8 @@ public function gt()
*
*
* @factoryMethod ConstraintComparison
- *
- * @return ConstraintComparison
*/
- public function gte()
+ public function gte(): ConstraintComparison
{
return $this->addChild(new ConstraintComparison(
$this,
@@ -366,10 +340,8 @@ public function gte()
* The above example will match "foo" and "foobar" but not "barfoo".
*
* @factoryMethod ConstraintComparison
- *
- * @return ConstraintComparison
*/
- public function like()
+ public function like(): ConstraintComparison
{
return $this->addChild(new ConstraintComparison(
$this,
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintFieldIsset.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintFieldIsset.php
index ef7128910..7a1a5d77a 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintFieldIsset.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintFieldIsset.php
@@ -17,9 +17,8 @@
*/
class ConstraintFieldIsset extends AbstractLeafNode
{
- protected $field;
-
- protected $alias;
+ private string $field;
+ private string $alias;
public function __construct(AbstractNode $parent, $field)
{
@@ -29,17 +28,17 @@ public function __construct(AbstractNode $parent, $field)
parent::__construct($parent);
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_CONSTRAINT;
}
- public function getField()
+ public function getField(): string
{
return $this->field;
}
- public function getAlias()
+ public function getAlias(): string
{
return $this->alias;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintFullTextSearch.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintFullTextSearch.php
index 9314ce0b9..0a0f758a1 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintFullTextSearch.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintFullTextSearch.php
@@ -13,13 +13,11 @@
*/
class ConstraintFullTextSearch extends AbstractLeafNode
{
- protected $alias;
+ private string $alias;
+ private string $field;
+ private string $fullTextSearchExpression;
- protected $field;
-
- protected $fullTextSearchExpression;
-
- public function __construct(AbstractNode $parent, $field, $fullTextSearchExpression)
+ public function __construct(AbstractNode $parent, string $field, string $fullTextSearchExpression)
{
[$alias, $field] = $this->explodeField($field);
$this->alias = $alias;
@@ -28,22 +26,22 @@ public function __construct(AbstractNode $parent, $field, $fullTextSearchExpress
parent::__construct($parent);
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_CONSTRAINT;
}
- public function getAlias()
+ public function getAlias(): string
{
return $this->alias;
}
- public function getField()
+ public function getField(): string
{
return $this->field;
}
- public function getFullTextSearchExpression()
+ public function getFullTextSearchExpression(): string
{
return $this->fullTextSearchExpression;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintNot.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintNot.php
index 5933b2552..fb230256b 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintNot.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintNot.php
@@ -10,14 +10,14 @@
*/
class ConstraintNot extends ConstraintFactory
{
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_CONSTRAINT => [1, 1],
];
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_CONSTRAINT;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintOrx.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintOrx.php
index 96fa8a9d3..0edbe1eba 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintOrx.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintOrx.php
@@ -13,14 +13,14 @@
*/
class ConstraintOrx extends ConstraintFactory
{
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_CONSTRAINT => [1, null],
];
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_CONSTRAINT;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintSame.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintSame.php
index f893aa837..b19e16745 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintSame.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConstraintSame.php
@@ -10,28 +10,27 @@
*/
class ConstraintSame extends AbstractLeafNode
{
- protected $alias;
+ private string $alias;
+ private string $path;
- protected $path;
-
- public function __construct(AbstractNode $parent, $alias, $path)
+ public function __construct(AbstractNode $parent, string $alias, string $path)
{
$this->alias = $alias;
$this->path = $path;
parent::__construct($parent);
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_CONSTRAINT;
}
- public function getAlias()
+ public function getAlias(): string
{
return $this->alias;
}
- public function getPath()
+ public function getPath(): string
{
return $this->path;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterPhpcr.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterPhpcr.php
index bf0e819b9..144864d34 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterPhpcr.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterPhpcr.php
@@ -23,9 +23,9 @@
*/
class ConverterPhpcr extends ConverterBase
{
- protected QueryObjectModelFactoryInterface $qomf;
- protected ClassMetadataFactory $mdf;
- protected DocumentManagerInterface $dm;
+ private QueryObjectModelFactoryInterface $qomf;
+ private ClassMetadataFactory $mdf;
+ private DocumentManagerInterface $dm;
/**
* When document sources are registered we put the document
@@ -33,7 +33,7 @@ class ConverterPhpcr extends ConverterBase
*
* @var ClassMetadata[]
*/
- protected array $aliasMetadata = [];
+ private array $aliasMetadata = [];
/**
* When document sources are registered we put the translator
@@ -41,7 +41,7 @@ class ConverterPhpcr extends ConverterBase
*
* @var TranslationStrategyInterface[]
*/
- protected array $translator = [];
+ private array $translator = [];
/**
* Ugly: We need to store the document source types so that we
@@ -50,7 +50,7 @@ class ConverterPhpcr extends ConverterBase
*
* @var SourceDocument[]
*/
- protected array $sourceDocumentNodes = [];
+ private array $sourceDocumentNodes = [];
/**
* Used to keep track of which sources are used with translated fields, to
@@ -58,9 +58,9 @@ class ConverterPhpcr extends ConverterBase
*
* @var array keys are the alias, value is true
*/
- protected array $aliasWithTranslatedFields;
+ private array $aliasWithTranslatedFields;
- protected ?string $locale = null;
+ private ?string $locale = null;
public function __construct(
DocumentManagerInterface $dm,
@@ -244,12 +244,10 @@ protected function walkSourceDocument(SourceDocument $node): SelectorInterface
}
// get the PHPCR Alias
- $alias = $this->qomf->selector(
+ return $this->qomf->selector(
$alias,
$nodeType
);
-
- return $alias;
}
protected function walkOperandDynamicField(OperandDynamicField $node): PropertyValueInterface
@@ -292,7 +290,7 @@ protected function walkOperandStaticLiteral(OperandStaticLiteral $node): Literal
{
$value = $node->getValue();
- if ($field = $node->getParent()->getChildOfType(AbstractNode::NT_OPERAND_DYNAMIC)) {
+ if ($field = $node->getParent()?->getChildOfType(AbstractNode::NT_OPERAND_DYNAMIC)) {
if ($field instanceof OperandDynamicField) {
$meta = $this->aliasMetadata[$field->getAlias()];
$fieldMapping = $meta->getFieldMapping($field->getField());
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/Field.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/Field.php
index 04eb8e005..32f2ec2ac 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/Field.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/Field.php
@@ -4,11 +4,10 @@
class Field extends AbstractLeafNode
{
- protected $field;
+ private string $field;
+ private string $alias;
- protected $alias;
-
- public function __construct(AbstractNode $parent, $field)
+ public function __construct(AbstractNode $parent, string $field)
{
[$alias, $field] = $this->explodeField($field);
$this->field = $field;
@@ -16,17 +15,17 @@ public function __construct(AbstractNode $parent, $field)
parent::__construct($parent);
}
- public function getField()
+ public function getField(): string
{
return $this->field;
}
- public function getAlias()
+ public function getAlias(): string
{
return $this->alias;
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_PROPERTY;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/From.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/From.php
index 9bb60136b..0ca2ac608 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/From.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/From.php
@@ -10,14 +10,14 @@
*/
class From extends SourceFactory
{
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_SOURCE => [1, 1],
];
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_FROM;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicFactory.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicFactory.php
index 6bc8f63b2..e8173fd54 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicFactory.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicFactory.php
@@ -11,12 +11,12 @@
*/
class OperandDynamicFactory extends AbstractNode
{
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_OPERAND_DYNAMIC_FACTORY;
}
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_OPERAND_DYNAMIC => [1, 1],
@@ -45,10 +45,8 @@ public function getCardinalityMap()
* @param string $alias - Name of alias to use
*
* @factoryMethod OperandDynamicFullTextSearchScore
- *
- * @return OperandDynamicFactory
*/
- public function fullTextSearchScore($alias)
+ public function fullTextSearchScore(string $alias): OperandDynamicFactory
{
return $this->addChild(new OperandDynamicFullTextSearchScore($this, $alias));
}
@@ -70,10 +68,8 @@ public function fullTextSearchScore($alias)
* @param string $field - Name of field to check
*
* @factoryMethod OperandDynamicLength
- *
- * @return OperandDynamicFactory
*/
- public function length($field)
+ public function length(string $field): OperandDynamicFactory
{
return $this->addChild(new OperandDynamicLength($this, $field));
}
@@ -91,10 +87,8 @@ public function length($field)
*
*
* @factoryMethod OperandDynamicLowerCase
- *
- * @return OperandDynamicLowerCase
*/
- public function lowerCase()
+ public function lowerCase(): OperandDynamicLowerCase
{
return $this->addChild(new OperandDynamicLowerCase($this));
}
@@ -112,10 +106,8 @@ public function lowerCase()
*
*
* @factoryMethod OperandDynamicUpperCase
- *
- * @return OperandDynamicUpperCase
*/
- public function upperCase()
+ public function upperCase(): OperandDynamicUpperCase
{
return $this->addChild(new OperandDynamicUpperCase($this));
}
@@ -141,10 +133,8 @@ public function upperCase()
* @param string $alias - Name of alias to use
*
* @factoryMethod OperandDynamicLocalName
- *
- * @return OperandDynamicFactory
*/
- public function localName($alias)
+ public function localName(string $alias): OperandDynamicFactory
{
return $this->addChild(new OperandDynamicLocalName($this, $alias));
}
@@ -169,10 +159,8 @@ public function localName($alias)
* @param string $alias - Name of alias to use
*
* @factoryMethod OperandDynamicName
- *
- * @return OperandDynamicFactory
*/
- public function name($alias)
+ public function name(string $alias): OperandDynamicFactory
{
return $this->addChild(new OperandDynamicName($this, $alias));
}
@@ -189,13 +177,11 @@ public function name($alias)
* ->end();
*
*
- * @param string $field - name of field to check, including alias name
+ * @param string $field name of field to check, including alias name
*
* @factoryMethod OperandDynamicField
- *
- * @return OperandDynamicFactory
*/
- public function field($field)
+ public function field(string $field): OperandDynamicFactory
{
return $this->addChild(new OperandDynamicField($this, $field));
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicField.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicField.php
index 29a533fb2..b6eeafee1 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicField.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicField.php
@@ -10,11 +10,11 @@
*/
class OperandDynamicField extends AbstractLeafNode
{
- protected $alias;
+ private string $alias;
- protected $field;
+ private string $field;
- public function __construct(AbstractNode $parent, $field)
+ public function __construct(AbstractNode $parent, string $field)
{
[$alias, $field] = $this->explodeField($field);
$this->alias = $alias;
@@ -22,17 +22,17 @@ public function __construct(AbstractNode $parent, $field)
parent::__construct($parent);
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_OPERAND_DYNAMIC;
}
- public function getAlias()
+ public function getAlias(): string
{
return $this->alias;
}
- public function getField()
+ public function getField(): string
{
return $this->field;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicFullTextSearchScore.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicFullTextSearchScore.php
index 217f60eca..fe6ea70b2 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicFullTextSearchScore.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicFullTextSearchScore.php
@@ -4,20 +4,20 @@
class OperandDynamicFullTextSearchScore extends AbstractLeafNode
{
- protected $alias;
+ private string $alias;
- public function __construct(AbstractNode $parent, $alias)
+ public function __construct(AbstractNode $parent, string $alias)
{
$this->alias = $alias;
parent::__construct($parent);
}
- public function getAlias()
+ public function getAlias(): string
{
return $this->alias;
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_OPERAND_DYNAMIC;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicLength.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicLength.php
index db22d6ee8..1d9fd729e 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicLength.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicLength.php
@@ -4,11 +4,11 @@
class OperandDynamicLength extends AbstractLeafNode
{
- protected $alias;
+ private string $alias;
- protected $field;
+ private string $field;
- public function __construct(AbstractNode $parent, $field)
+ public function __construct(AbstractNode $parent, string $field)
{
[$alias, $field] = $this->explodeField($field);
$this->field = $field;
@@ -16,17 +16,17 @@ public function __construct(AbstractNode $parent, $field)
parent::__construct($parent);
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_OPERAND_DYNAMIC;
}
- public function getField()
+ public function getField(): string
{
return $this->field;
}
- public function getAlias()
+ public function getAlias(): string
{
return $this->alias;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicLocalName.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicLocalName.php
index bdc122818..6ea275f6b 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicLocalName.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicLocalName.php
@@ -4,20 +4,20 @@
class OperandDynamicLocalName extends AbstractLeafNode
{
- protected $alias;
+ private string $alias;
- public function __construct(AbstractNode $parent, $alias)
+ public function __construct(AbstractNode $parent, string $alias)
{
$this->alias = $alias;
parent::__construct($parent);
}
- public function getAlias()
+ public function getAlias(): string
{
return $this->alias;
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_OPERAND_DYNAMIC;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicLowerCase.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicLowerCase.php
index 6c2bf14da..9a6de2f5c 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicLowerCase.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicLowerCase.php
@@ -9,14 +9,14 @@
*/
class OperandDynamicLowerCase extends OperandDynamicFactory
{
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_OPERAND_DYNAMIC => [1, 1], // 1..*
];
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_OPERAND_DYNAMIC;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicName.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicName.php
index 8e5809dbb..49df843c4 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicName.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicName.php
@@ -4,20 +4,20 @@
class OperandDynamicName extends AbstractLeafNode
{
- protected $alias;
+ private string $alias;
- public function __construct(AbstractNode $parent, $alias)
+ public function __construct(AbstractNode $parent, string $alias)
{
$this->alias = $alias;
parent::__construct($parent);
}
- public function getAlias()
+ public function getAlias(): string
{
return $this->alias;
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_OPERAND_DYNAMIC;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicUpperCase.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicUpperCase.php
index 6a5eeedc5..be659425e 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicUpperCase.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandDynamicUpperCase.php
@@ -9,14 +9,14 @@
*/
class OperandDynamicUpperCase extends OperandDynamicFactory
{
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_OPERAND_DYNAMIC => [1, 1], // 1..*
];
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_OPERAND_DYNAMIC;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandFactory.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandFactory.php
index 10e1f5e4f..c774d5ef7 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandFactory.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandFactory.php
@@ -21,13 +21,11 @@ class OperandFactory extends OperandDynamicFactory
* $qb->setParameter('param_1', 'foo');
*
*
- * @param string $name - Name of parameter to resolve
+ * @param string $name The parameter name to resolve
*
* @factoryMethod OperandStaticParameter
- *
- * @return OperandFactory
*/
- public function parameter($name)
+ public function parameter(string $name): AbstractNode
{
return $this->addChild(new OperandStaticParameter($this, $name));
}
@@ -39,13 +37,11 @@ public function parameter($name)
* $qb->where()->eq()->field('f.foobar')->literal('Literal Value')->end();
*
*
- * @param string $value - Literal value
+ * @param string $value Literal value
*
* @factoryMethod OperandStaticLiteral
- *
- * @return OperandStaticLiteral
*/
- public function literal($value)
+ public function literal($value): AbstractNode
{
return $this->addChild(new OperandStaticLiteral($this, $value));
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandStaticFactory.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandStaticFactory.php
index 9675afc50..dada14933 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandStaticFactory.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandStaticFactory.php
@@ -12,14 +12,14 @@
*/
class OperandStaticFactory extends OperandFactory
{
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_OPERAND_STATIC => [1, 1],
];
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_OPERAND_FACTORY;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandStaticLiteral.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandStaticLiteral.php
index be4aa7d67..959cc930e 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandStaticLiteral.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandStaticLiteral.php
@@ -4,7 +4,7 @@
class OperandStaticLiteral extends AbstractLeafNode
{
- protected $value;
+ private $value;
public function __construct(AbstractNode $parent, $value)
{
@@ -17,7 +17,7 @@ public function getValue()
return $this->value;
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_OPERAND_STATIC;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandStaticParameter.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandStaticParameter.php
index e79be309e..0e7d64893 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandStaticParameter.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/OperandStaticParameter.php
@@ -4,20 +4,20 @@
class OperandStaticParameter extends AbstractLeafNode
{
- protected $variableName;
+ private string $variableName;
- public function __construct(AbstractNode $parent, $variableName)
+ public function __construct(AbstractNode $parent, string $variableName)
{
$this->variableName = $variableName;
parent::__construct($parent);
}
- public function getVariableName()
+ public function getVariableName(): string
{
return $this->variableName;
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_OPERAND_STATIC;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/OrderBy.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/OrderBy.php
index 3c68e449c..5b7ef4e70 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/OrderBy.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/OrderBy.php
@@ -16,7 +16,7 @@
*/
class OrderBy extends AbstractNode
{
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_ORDERING => [0, null],
@@ -31,10 +31,8 @@ public function getCardinalityMap()
*
*
* @factoryMethod Ordering
- *
- * @return Ordering
*/
- public function asc()
+ public function asc(): Ordering
{
return $this->addChild(new Ordering($this, QOMConstants::JCR_ORDER_ASCENDING));
}
@@ -47,15 +45,13 @@ public function asc()
*
*
* @factoryMethod Ordering
- *
- * @return Ordering
*/
- public function desc()
+ public function desc(): Ordering
{
return $this->addChild(new Ordering($this, QOMConstants::JCR_ORDER_DESCENDING));
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_ORDER_BY;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/Ordering.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/Ordering.php
index fc45f386a..765f2be9e 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/Ordering.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/Ordering.php
@@ -4,27 +4,27 @@
class Ordering extends OperandDynamicFactory
{
- protected $order;
+ private string $order;
- public function __construct(AbstractNode $parent, $order)
+ public function __construct(AbstractNode $parent, string $order)
{
$this->order = $order;
parent::__construct($parent);
}
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_OPERAND_DYNAMIC => [1, 1],
];
}
- public function getOrder()
+ public function getOrder(): string
{
return $this->order;
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_ORDERING;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/QueryBuilder.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/QueryBuilder.php
index c82ab9734..7ae48abe6 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/QueryBuilder.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/QueryBuilder.php
@@ -30,32 +30,24 @@
*/
class QueryBuilder extends AbstractNode
{
- protected $converter;
-
- protected $firstResult;
-
- protected $maxResults;
-
- protected $locale;
-
- protected $primaryAlias;
+ private ?ConverterInterface $converter = null;
+ private int $firstResult = 0;
+ private ?int $maxResults = null;
+ private ?string $locale = null;
+ private ?string $primaryAlias;
/**
- * @return string the locale for this query
+ * @return string|null the locale for this query or null if not set
*/
- public function getLocale()
+ public function getLocale(): ?string
{
return $this->locale;
}
/**
* Set the locale to use in this query.
- *
- * @param string $locale
- *
- * @return $this
*/
- public function setLocale($locale)
+ public function setLocale(?string $locale): self
{
$this->locale = $locale;
@@ -67,28 +59,22 @@ public function setLocale($locale)
*
* This is an NT_BUILDER
*/
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_BUILDER;
}
- /**
- * @return Query
- */
- public function getQuery()
+ public function getQuery(): Query
{
return $this->getConverter()->getQuery($this);
}
- public function setConverter(ConverterInterface $converter)
+ public function setConverter(ConverterInterface $converter): void
{
$this->converter = $converter;
}
- /**
- * @return ConverterInterface
- */
- protected function getConverter()
+ protected function getConverter(): ConverterInterface
{
if (!$this->converter) {
throw new RuntimeException('No query converter has been set on Builder node.');
@@ -97,7 +83,7 @@ protected function getConverter()
return $this->converter;
}
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_SELECT => [0, null], // 1..*
@@ -119,10 +105,8 @@ public function getCardinalityMap()
*
*
* @factoryMethod Where
- *
- * @return Where
*/
- public function where($void = null)
+ public function where($void = null): Where
{
$this->ensureNoArguments(__METHOD__, $void);
@@ -133,10 +117,8 @@ public function where($void = null)
* Add additional selection criteria using the AND operator.
*
* @factoryMethod WhereAnd
- *
- * @return WhereAnd
*/
- public function andWhere($void = null)
+ public function andWhere($void = null): WhereAnd
{
$this->ensureNoArguments(__METHOD__, $void);
@@ -147,10 +129,8 @@ public function andWhere($void = null)
* Add additional selection criteria using the OR operator.
*
* @factoryMethod WhereOr
- *
- * @return WhereOr
*/
- public function orWhere($void = null)
+ public function orWhere($void = null): WhereOr
{
$this->ensureNoArguments(__METHOD__, $void);
@@ -172,13 +152,11 @@ public function orWhere($void = null)
* ->end();
*
*
- * @param string $primaryAlias - Alias to use as primary source (optional for single sources)
+ * @param string|null $primaryAlias - Alias to use as primary source (optional for single sources)
*
* @factoryMethod From
- *
- * @return From
*/
- public function from($primaryAlias = null)
+ public function from(string $primaryAlias = null): From
{
$this->primaryAlias = $primaryAlias;
@@ -206,10 +184,8 @@ public function from($primaryAlias = null)
* @param string $primaryAlias - Alias for document source and primary alias when using multiple sources
*
* @factoryMethod From
- *
- * @return QueryBuilder
*/
- public function fromDocument($documentFqn, $primaryAlias)
+ public function fromDocument(string $documentFqn, string $primaryAlias): QueryBuilder
{
$this->primaryAlias = $primaryAlias;
@@ -225,7 +201,7 @@ public function fromDocument($documentFqn, $primaryAlias)
* factory methods should have no arguments (thus it is easier to determine
* which nodes are leaf nodes).
*/
- private function addJoin($joinType)
+ private function addJoin(string $joinType): SourceJoin
{
$from = $this->getChildOfType(QBConstants::NT_FROM);
$curSource = $from->getChild();
@@ -256,10 +232,8 @@ private function addJoin($joinType)
* will behave as an inner join.
*
* @factoryMethod Select
- *
- * @return SourceJoin
*/
- public function addJoinLeftOuter($void = null)
+ public function addJoinLeftOuter($void = null): SourceJoin
{
$this->ensureNoArguments(__METHOD__, $void);
@@ -285,10 +259,8 @@ public function addJoinLeftOuter($void = null)
* will behave as an inner join.
*
* @factoryMethod Select
- *
- * @return SourceJoin
*/
- public function addJoinRightOuter($void = null)
+ public function addJoinRightOuter($void = null): SourceJoin
{
$this->ensureNoArguments(__METHOD__, $void);
@@ -314,10 +286,8 @@ public function addJoinRightOuter($void = null)
* will behave as an inner join.
*
* @factoryMethod Select
- *
- * @return SourceJoin
*/
- public function addJoinInner($void = null)
+ public function addJoinInner($void = null): SourceJoin
{
$this->ensureNoArguments(__METHOD__, $void);
@@ -339,10 +309,8 @@ public function addJoinInner($void = null)
*
*
* @factoryMethod Select
- *
- * @return Select
*/
- public function select($void = null)
+ public function select($void = null): Select
{
$this->ensureNoArguments(__METHOD__, $void);
@@ -364,10 +332,8 @@ public function select($void = null)
*
*
* @factoryMethod SelectAdd
- *
- * @return SelectAdd
*/
- public function addSelect($void = null)
+ public function addSelect($void = null): SelectAdd
{
$this->ensureNoArguments(__METHOD__, $void);
@@ -387,10 +353,8 @@ public function addSelect($void = null)
*
*
* @factoryMethod OrderBy
- *
- * @return OrderBy
*/
- public function orderBy($void = null)
+ public function orderBy($void = null): OrderBy
{
$this->ensureNoArguments(__METHOD__, $void);
@@ -401,10 +365,8 @@ public function orderBy($void = null)
* Add additional orderings to the builder tree.
*
* @factoryMethod OrderByAdd
- *
- * @return OrderByAdd
*/
- public function addOrderBy($void = null)
+ public function addOrderBy($void = null): OrderByAdd
{
$this->ensureNoArguments(__METHOD__, $void);
@@ -413,55 +375,45 @@ public function addOrderBy($void = null)
/**
* Return the offset of the first result in the resultset.
- *
- * @return int
*/
- public function getFirstResult()
+ public function getFirstResult(): int
{
return $this->firstResult;
}
/**
* Set the offset of the first result in the resultset.
- *
- * @param int $firstResult
*/
- public function setFirstResult($firstResult)
+ public function setFirstResult(int $firstResult): void
{
$this->firstResult = $firstResult;
}
/**
* Return the maximum number of results to be imposed on the generated query.
- *
- * @return int
*/
- public function getMaxResults()
+ public function getMaxResults(): ?int
{
return $this->maxResults;
}
/**
* Set the maximum number of results to be returned by the generated query.
- *
- * @param int $maxResults
*/
- public function setMaxResults($maxResults)
+ public function setMaxResults(?int $maxResults): void
{
$this->maxResults = $maxResults;
}
/**
* Creates an SQL2 representation of the PHPCR query built by this builder.
- *
- * @return string
*/
- public function __toString()
+ public function __toString(): string
{
- return (string) $this->getQuery()->getStatement();
+ return $this->getQuery()->getStatement();
}
- public function getPrimaryAlias()
+ public function getPrimaryAlias(): ?string
{
return $this->primaryAlias;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/Select.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/Select.php
index d164db4f7..6ab58b980 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/Select.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/Select.php
@@ -11,7 +11,7 @@
*/
class Select extends AbstractNode
{
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_PROPERTY => [0, null],
@@ -31,15 +31,13 @@ public function getCardinalityMap()
* @param string $field - name of field to check, including alias name
*
* @factoryMethod
- *
- * @return Select
*/
- public function field($field)
+ public function field(string $field): Select
{
return $this->addChild(new Field($this, $field));
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_SELECT;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceDocument.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceDocument.php
index 06277b520..6080accd8 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceDocument.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceDocument.php
@@ -6,13 +6,13 @@
class SourceDocument extends AbstractLeafNode
{
- protected $documentFqn;
+ private string $documentFqn;
- protected $alias;
+ private string $alias;
- public function __construct(AbstractNode $parent, $documentFqn, $alias)
+ public function __construct(AbstractNode $parent, string $documentFqn, string $alias)
{
- if (!is_string($alias) || empty($alias)) {
+ if ('' === $alias) {
throw new InvalidArgumentException(sprintf(
'The alias for %s must be a non-empty string.',
$documentFqn
@@ -24,17 +24,17 @@ public function __construct(AbstractNode $parent, $documentFqn, $alias)
parent::__construct($parent);
}
- public function getDocumentFqn()
+ public function getDocumentFqn(): string
{
return $this->documentFqn;
}
- public function getAlias()
+ public function getAlias(): string
{
return $this->alias;
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_SOURCE;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceFactory.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceFactory.php
index f8dc4bf23..7234fc980 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceFactory.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceFactory.php
@@ -19,7 +19,7 @@
*/
abstract class SourceFactory extends AbstractNode
{
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_SOURCE => [1, 1],
@@ -34,14 +34,9 @@ public function getCardinalityMap()
* $qb->from('my_alias')->document('My/Document/Class', 'my_alias')->end();
*
*
- * @param string $documentFqn - Fully qualified class name for document
- * @param string $alias - Alias name
- *
* @factoryMethod SourceDocument
- *
- * @return SourceDocument
*/
- public function document($documentFqn, $alias)
+ public function document(string $documentFqn, string $alias): SourceFactory
{
return $this->addChild(new SourceDocument($this, $documentFqn, $alias));
}
@@ -60,10 +55,8 @@ public function document($documentFqn, $alias)
*
*
* @factoryMethod SourceJoin
- *
- * @return SourceJoin
*/
- public function joinInner()
+ public function joinInner(): SourceJoin
{
return $this->addChild(new SourceJoin(
$this,
@@ -85,10 +78,8 @@ public function joinInner()
*
*
* @factoryMethod SourceJoin
- *
- * @return SourceJoin
*/
- public function joinLeftOuter()
+ public function joinLeftOuter(): SourceJoin
{
return $this->addChild(new SourceJoin(
$this,
@@ -110,10 +101,8 @@ public function joinLeftOuter()
*
*
* @factoryMethod SourceJoin
- *
- * @return SourceJoin
*/
- public function joinRightOuter()
+ public function joinRightOuter(): SourceJoin
{
return $this->addChild(new SourceJoin(
$this,
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoin.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoin.php
index 3f1bc6f21..097cca4be 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoin.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoin.php
@@ -7,15 +7,15 @@
*/
class SourceJoin extends AbstractNode
{
- protected $joinType;
+ private string $joinType;
- public function __construct($parent, $joinType)
+ public function __construct(AbstractNode $parent, string $joinType)
{
$this->joinType = $joinType;
parent::__construct($parent);
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_SOURCE;
}
@@ -24,10 +24,8 @@ public function getNodeType()
* Specify the document source for the "left" side of a join.
*
* @factoryMethod
- *
- * @return SourceJoinLeft
*/
- public function left()
+ public function left(): SourceJoinLeft
{
return $this->addChild(new SourceJoinLeft($this));
}
@@ -36,10 +34,8 @@ public function left()
* Specify the document source for the "right" side of a join.
*
* @factoryMethod
- *
- * @return SourceJoinRight
*/
- public function right()
+ public function right(): SourceJoinRight
{
return $this->addChild(new SourceJoinRight($this));
}
@@ -48,20 +44,18 @@ public function right()
* Specify the join condition.
*
* @factoryMethod
- *
- * @return SourceJoinConditionFactory
*/
- public function condition()
+ public function condition(): SourceJoinConditionFactory
{
return $this->addChild(new SourceJoinConditionFactory($this));
}
- public function getJoinType()
+ public function getJoinType(): string
{
return $this->joinType;
}
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_SOURCE_JOIN_CONDITION_FACTORY => [1, 1],
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionChildDocument.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionChildDocument.php
index 4edef1915..ef85ef47f 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionChildDocument.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionChildDocument.php
@@ -4,28 +4,28 @@
class SourceJoinConditionChildDocument extends AbstractLeafNode
{
- protected $childAlias;
+ private string $childAlias;
- protected $parentAlias;
+ private string $parentAlias;
- public function __construct($parent, $childAlias, $parentAlias)
+ public function __construct(AbstractNode $parent, string $childAlias, string $parentAlias)
{
- $this->childAlias = (string) $childAlias;
- $this->parentAlias = (string) $parentAlias;
+ $this->childAlias = $childAlias;
+ $this->parentAlias = $parentAlias;
parent::__construct($parent);
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_SOURCE_JOIN_CONDITION;
}
- public function getChildAlias()
+ public function getChildAlias(): string
{
return $this->childAlias;
}
- public function getParentAlias()
+ public function getParentAlias(): string
{
return $this->parentAlias;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionDescendant.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionDescendant.php
index c4e2f9a9d..f4569a753 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionDescendant.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionDescendant.php
@@ -4,30 +4,27 @@
class SourceJoinConditionDescendant extends AbstractLeafNode
{
- protected $path;
+ private string $descendantAlias;
+ private string $ancestorAliasNode;
- protected $descendantAlias;
-
- protected $ancestorAliasNode;
-
- public function __construct($parent, $descendantAlias, $ancestorAlias)
+ public function __construct(AbstractNode $parent, string $descendantAlias, string $ancestorAlias)
{
- $this->ancestorAliasNode = (string) $ancestorAlias;
- $this->descendantAlias = (string) $descendantAlias;
+ $this->ancestorAliasNode = $ancestorAlias;
+ $this->descendantAlias = $descendantAlias;
parent::__construct($parent);
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_SOURCE_JOIN_CONDITION;
}
- public function getDescendantAlias()
+ public function getDescendantAlias(): string
{
return $this->descendantAlias;
}
- public function getAncestorAlias()
+ public function getAncestorAlias(): string
{
return $this->ancestorAliasNode;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionEqui.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionEqui.php
index d6ac4f686..3787ecd0f 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionEqui.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionEqui.php
@@ -4,15 +4,15 @@
class SourceJoinConditionEqui extends AbstractLeafNode
{
- protected $property1;
+ private string $property1;
- protected $alias1;
+ private string $alias1;
- protected $property2;
+ private string $property2;
- protected $alias2;
+ private string $alias2;
- public function __construct($parent, $field1, $field2)
+ public function __construct(AbstractNode $parent, string $field1, string $field2)
{
[$alias1, $property1] = $this->explodeField($field1);
[$alias2, $property2] = $this->explodeField($field2);
@@ -23,27 +23,27 @@ public function __construct($parent, $field1, $field2)
$this->alias2 = $alias2;
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_SOURCE_JOIN_CONDITION;
}
- public function getProperty1()
+ public function getProperty1(): string
{
return $this->property1;
}
- public function getAlias1()
+ public function getAlias1(): string
{
return $this->alias1;
}
- public function getProperty2()
+ public function getProperty2(): string
{
return $this->property2;
}
- public function getAlias2()
+ public function getAlias2(): string
{
return $this->alias2;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionFactory.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionFactory.php
index d557ec0cd..9ba3da2f7 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionFactory.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionFactory.php
@@ -11,14 +11,14 @@
*/
class SourceJoinConditionFactory extends AbstractNode
{
- public function getCardinalityMap()
+ public function getCardinalityMap(): array
{
return [
self::NT_SOURCE_JOIN_CONDITION => [1, 1],
];
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_SOURCE_JOIN_CONDITION_FACTORY;
}
@@ -41,10 +41,8 @@ public function getNodeType()
* @param string $ancestorAlias - Name of alias to match for ancestor documents
*
* @factoryMethod SourceJoinConditionDescendant
- *
- * @return SourceJoinConditionFactory
*/
- public function descendant($descendantAlias, $ancestorAlias)
+ public function descendant(string $descendantAlias, string $ancestorAlias): SourceJoinConditionFactory
{
return $this->addChild(new SourceJoinConditionDescendant(
$this,
@@ -72,10 +70,8 @@ public function descendant($descendantAlias, $ancestorAlias)
* @param string $field2 - Field name for second field
*
* @factoryMethod SourceJoinConditionEqui
- *
- * @return SourceJoinConditionFactory
*/
- public function equi($field1, $field2)
+ public function equi(string $field1, string $field2): SourceJoinConditionFactory
{
return $this->addChild(new SourceJoinConditionEqui(
$this,
@@ -101,10 +97,8 @@ public function equi($field1, $field2)
* @param string $parentAlias - Name of alias to match for parent documents
*
* @factoryMethod SourceJoinConditionChildDocument
- *
- * @return SourceJoinConditionFactory
*/
- public function child($childAlias, $parentAlias)
+ public function child(string $childAlias, string $parentAlias): SourceJoinConditionFactory
{
return $this->addChild(new SourceJoinConditionChildDocument(
$this,
@@ -133,10 +127,8 @@ public function child($childAlias, $parentAlias)
* @param string $alias2Path - Path for documents of second alias
*
* @factoryMethod SourceJoinConditionSameDocument
- *
- * @return SourceJoinConditionFactory
*/
- public function same($alias1, $alias2, $alias2Path)
+ public function same(string $alias1, string $alias2, string $alias2Path): SourceJoinConditionFactory
{
return $this->addChild(new SourceJoinConditionSameDocument(
$this,
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionSameDocument.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionSameDocument.php
index 848b35fce..9a797679a 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionSameDocument.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinConditionSameDocument.php
@@ -4,13 +4,13 @@
class SourceJoinConditionSameDocument extends AbstractLeafNode
{
- protected $alias1Name;
+ private string $alias1Name;
- protected $alias2Name;
+ private string $alias2Name;
- protected $alias2Path;
+ private string $alias2Path;
- public function __construct($parent, $alias1Name, $alias2Name, $alias2Path)
+ public function __construct(AbstractNode $parent, string $alias1Name, string $alias2Name, string $alias2Path)
{
$this->alias1Name = $alias1Name;
$this->alias2Name = $alias2Name;
@@ -18,22 +18,22 @@ public function __construct($parent, $alias1Name, $alias2Name, $alias2Path)
parent::__construct($parent);
}
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_SOURCE_JOIN_CONDITION;
}
- public function getAlias1Name()
+ public function getAlias1Name(): string
{
return $this->alias1Name;
}
- public function getAlias2Name()
+ public function getAlias2Name(): string
{
return $this->alias2Name;
}
- public function getAlias2Path()
+ public function getAlias2Path(): string
{
return $this->alias2Path;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinLeft.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinLeft.php
index e552ee406..04431c6e7 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinLeft.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinLeft.php
@@ -9,7 +9,7 @@
*/
class SourceJoinLeft extends From
{
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_SOURCE_JOIN_LEFT;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinRight.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinRight.php
index a9a14be0d..fd6e6fe69 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinRight.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/SourceJoinRight.php
@@ -9,7 +9,7 @@
*/
class SourceJoinRight extends From
{
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_SOURCE_JOIN_RIGHT;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/Where.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/Where.php
index 3773bb24d..f0ef649d0 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/Where.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/Where.php
@@ -9,7 +9,7 @@
*/
class Where extends ConstraintFactory
{
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_WHERE;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/WhereAnd.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/WhereAnd.php
index 9209d14ca..f9754ed04 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/WhereAnd.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/WhereAnd.php
@@ -9,7 +9,7 @@
*/
class WhereAnd extends Where
{
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_WHERE;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/WhereOr.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/WhereOr.php
index 2243075bc..65a320dec 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Builder/WhereOr.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/WhereOr.php
@@ -9,7 +9,7 @@
*/
class WhereOr extends Where
{
- public function getNodeType()
+ public function getNodeType(): string
{
return self::NT_WHERE;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Expression/Descendant.php b/lib/Doctrine/ODM/PHPCR/Query/Expression/Descendant.php
index 4d7ccaea9..a7d94a144 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Expression/Descendant.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Expression/Descendant.php
@@ -7,14 +7,14 @@
class Descendant implements Expression
{
- protected $path;
+ private string $path;
- public function __construct($path)
+ public function __construct(string $path)
{
$this->path = $path;
}
- public function getPath()
+ public function getPath(): string
{
return $this->path;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Expression/SameNode.php b/lib/Doctrine/ODM/PHPCR/Query/Expression/SameNode.php
index 14b285a90..c3be0f4ff 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Expression/SameNode.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Expression/SameNode.php
@@ -7,14 +7,14 @@
class SameNode implements Expression
{
- protected $path;
+ private string $path;
- public function __construct($path)
+ public function __construct(string $path)
{
$this->path = $path;
}
- public function getPath()
+ public function getPath(): string
{
return $this->path;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Query/Expression/TextSearch.php b/lib/Doctrine/ODM/PHPCR/Query/Expression/TextSearch.php
index 91f512a6d..d4ce76712 100644
--- a/lib/Doctrine/ODM/PHPCR/Query/Expression/TextSearch.php
+++ b/lib/Doctrine/ODM/PHPCR/Query/Expression/TextSearch.php
@@ -7,22 +7,21 @@
class TextSearch implements Expression
{
- protected $field;
+ private string $field;
+ private string $search;
- protected $search;
-
- public function __construct($field, $search)
+ public function __construct(string $field, string $search)
{
$this->field = $field;
$this->search = $search;
}
- public function getField()
+ public function getField(): string
{
return $this->field;
}
- public function getSearch()
+ public function getSearch(): string
{
return $this->search;
}
diff --git a/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/DumpQueryBuilderReferenceCommand.php b/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/DumpQueryBuilderReferenceCommand.php
index 3148b2bb4..e9025aa74 100644
--- a/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/DumpQueryBuilderReferenceCommand.php
+++ b/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/DumpQueryBuilderReferenceCommand.php
@@ -84,9 +84,9 @@ protected function formatMapRst(array $map): array
$out = [];
$indent = 0;
foreach (explode("\n", $string) as $line) {
- if (false !== strpos($line, '')) {
+ if (str_contains($line, '')) {
$indent = 4;
- } elseif (false !== strpos($line, '
')) {
+ } elseif (str_contains($line, '
')) {
$indent = 0;
$out[] = '';
} elseif ('' === $line) {
@@ -329,7 +329,7 @@ protected function parseDocParams(\ReflectionMethod $reflMethod): array
// parse @params
$docParams = [];
foreach (explode("\n", $docComment) as $line) {
- if (preg_match('&@param +([a-zA-Z]+) ?\$([a-zA-Z0-9_]+) +(.*)&', $line, $matches)) {
+ if (preg_match('&@param +([a-zA-Z|]+) ?\$([a-zA-Z0-9_]+) +(.*)&', $line, $matches)) {
$docParams[$matches[2]] = ['type' => $matches[1], 'doc' => $matches[3]];
}
}
@@ -341,7 +341,7 @@ protected function parseDocParams(\ReflectionMethod $reflMethod): array
if (!array_key_exists($reflParam->name, $docParams)) {
throw new \Exception(sprintf(
- 'Undocummented parameter "%s" in "%s" for method "%s"',
+ 'Undocumented parameter "%s" in "%s" for method "%s"',
$reflParam->name,
$reflMethod->class,
$reflMethod->name
@@ -358,15 +358,15 @@ protected function parseDocComment(string $comment, int $indent = 0): string
{
$out = [];
foreach (explode("\n", $comment) as $line) {
- if (false !== strpos($line, '/**')) {
+ if (str_contains($line, '/**')) {
continue;
}
- if (false !== strpos($line, '*/')) {
+ if (str_contains($line, '*/')) {
break;
}
- if (false !== strpos($line, '@')) {
+ if (str_contains($line, '@')) {
continue;
}
@@ -412,6 +412,16 @@ private function getFactoryMethodMap(\ReflectionClass $refl): array
$returnType = $matches[1];
$fMethods[$rMethod->name]['returnType'] = $returnType;
+ } elseif ($returnType = $rMethod->getReturnType()) {
+ $fMethods[$rMethod->name]['returnType'] = match (get_class($returnType)) {
+ \ReflectionNamedType::class => $returnType->getName(),
+ \ReflectionUnionType::class => implode('|', array_map(static function (\ReflectionNamedType $type): string {
+ return $type->getName();
+ }, $returnType->getTypes())),
+ \ReflectionIntersectionType::class => implode('&', array_map(static function (\ReflectionNamedType $type): string {
+ return $type->getName();
+ }, $returnType->getTypes())),
+ };
}
}
}
diff --git a/lib/Doctrine/ODM/PHPCR/UnitOfWork.php b/lib/Doctrine/ODM/PHPCR/UnitOfWork.php
index 853ff8e58..6a8571323 100644
--- a/lib/Doctrine/ODM/PHPCR/UnitOfWork.php
+++ b/lib/Doctrine/ODM/PHPCR/UnitOfWork.php
@@ -2582,7 +2582,7 @@ private function executeMoves(array $documents): void
// update all cached children of the document to reflect the move (path id changes)
foreach ($this->documentIds as $childOid => $id) {
- if (0 !== strpos($id, $sourcePath)) {
+ if (!str_starts_with($id, $sourcePath)) {
continue;
}
diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Tools/Command/DumpQueryBuilderReferenceCommandTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Tools/Command/DumpQueryBuilderReferenceCommandTest.php
index 4430c7b2f..f4777d6a8 100644
--- a/tests/Doctrine/Tests/ODM/PHPCR/Tools/Command/DumpQueryBuilderReferenceCommandTest.php
+++ b/tests/Doctrine/Tests/ODM/PHPCR/Tools/Command/DumpQueryBuilderReferenceCommandTest.php
@@ -8,15 +8,8 @@
class DumpQueryBuilderReferenceCommandTest extends TestCase
{
- /**
- * @var DumpQueryBuilderReferenceCommand
- */
- private $command;
-
- /**
- * @var CommandTester
- */
- private $commandTester;
+ private DumpQueryBuilderReferenceCommand $command;
+ private CommandTester $commandTester;
public function setUp(): void
{