Skip to content

Commit 7744700

Browse files
committed
Normalize usages of instanceof operator
1 parent e7a6aae commit 7744700

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

src/Tree/Document/MongoDB/Repository/MaterializedPathRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function childCount($node = null, $direct = false)
8585
$meta = $this->getClassMetadata();
8686

8787
if (is_object($node)) {
88-
if (!($node instanceof $meta->name)) {
88+
if (!is_a($node, $meta->getName())) {
8989
throw new InvalidArgumentException('Node is not related to this repository');
9090
}
9191

@@ -115,7 +115,7 @@ public function getChildrenQueryBuilder($node = null, $direct = false, $sortByFi
115115
->find($meta->name);
116116
$regex = false;
117117

118-
if (is_object($node) && $node instanceof $meta->name) {
118+
if (is_a($node, $meta->getName())) {
119119
$node = new MongoDocumentWrapper($node, $this->dm);
120120
$nodePath = preg_quote($node->getPropertyValue($config['path']));
121121

src/Tree/Entity/Repository/AbstractTreeRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function childCount($node = null, $direct = false)
9696
$meta = $this->getClassMetadata();
9797

9898
if (is_object($node)) {
99-
if (!($node instanceof $meta->name)) {
99+
if (!is_a($node, $meta->getName())) {
100100
throw new InvalidArgumentException('Node is not related to this repository');
101101
}
102102

src/Tree/Entity/Repository/ClosureTreeRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function getRootNodes($sortByField = null, $direction = 'asc')
6969
public function getPathQuery($node)
7070
{
7171
$meta = $this->getClassMetadata();
72-
if (!$node instanceof $meta->name) {
72+
if (!is_a($node, $meta->getName())) {
7373
throw new InvalidArgumentException('Node is not related to this repository');
7474
}
7575
if (!$this->_em->getUnitOfWork()->isInIdentityMap($node)) {
@@ -112,7 +112,7 @@ public function childrenQueryBuilder($node = null, $direct = false, $sortByField
112112

113113
$qb = $this->getQueryBuilder();
114114
if (null !== $node) {
115-
if ($node instanceof $meta->name) {
115+
if (is_a($node, $meta->getName())) {
116116
if (!$this->_em->getUnitOfWork()->isInIdentityMap($node)) {
117117
throw new InvalidArgumentException('Node is not managed by UnitOfWork');
118118
}
@@ -220,7 +220,7 @@ public function getChildren($node = null, $direct = false, $sortByField = null,
220220
public function removeFromTree($node)
221221
{
222222
$meta = $this->getClassMetadata();
223-
if (!$node instanceof $meta->name) {
223+
if (!is_a($node, $meta->getName())) {
224224
throw new InvalidArgumentException('Node is not related to this repository');
225225
}
226226
$wrapped = new EntityWrapper($node, $this->_em);

src/Tree/Entity/Repository/MaterializedPathRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function getChildrenQueryBuilder($node = null, $direct = false, $sortByFi
162162
$expr = '';
163163
$includeNodeExpr = '';
164164

165-
if (is_object($node) && $node instanceof $meta->name) {
165+
if (is_a($node, $meta->getName())) {
166166
$node = new EntityWrapper($node, $this->_em);
167167
$nodePath = $node->getPropertyValue($path);
168168
$expr = $qb->expr()->andx()->add(

src/Tree/Entity/Repository/NestedTreeRepository.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function __call($method, $args)
144144
public function getPathQueryBuilder($node)
145145
{
146146
$meta = $this->getClassMetadata();
147-
if (!$node instanceof $meta->name) {
147+
if (!is_a($node, $meta->getName())) {
148148
throw new InvalidArgumentException('Node is not related to this repository');
149149
}
150150
$config = $this->listener->getConfiguration($this->_em, $meta->name);
@@ -207,7 +207,7 @@ public function childrenQueryBuilder($node = null, $direct = false, $sortByField
207207
->from($config['useObjectClass'], 'node')
208208
;
209209
if (null !== $node) {
210-
if ($node instanceof $meta->name) {
210+
if (is_a($node, $meta->getName())) {
211211
$wrapped = new EntityWrapper($node, $this->_em);
212212
if (!$wrapped->hasValidIdentifier()) {
213213
throw new InvalidArgumentException('Node is not managed by UnitOfWork');
@@ -330,7 +330,7 @@ public function getLeafsQueryBuilder($root = null, $sortByField = null, $directi
330330
->where($qb->expr()->eq('node.'.$config['right'], '1 + node.'.$config['left']))
331331
;
332332
if (isset($config['root'])) {
333-
if ($root instanceof $meta->name) {
333+
if (is_a($root, $meta->getName())) {
334334
$wrapped = new EntityWrapper($root, $this->_em);
335335
$rootId = $wrapped->getPropertyValue($config['root']);
336336
if (!$rootId) {
@@ -399,7 +399,7 @@ public function getLeafs($root = null, $sortByField = null, $direction = 'ASC')
399399
public function getNextSiblingsQueryBuilder($node, $includeSelf = false)
400400
{
401401
$meta = $this->getClassMetadata();
402-
if (!$node instanceof $meta->name) {
402+
if (!is_a($node, $meta->getName())) {
403403
throw new InvalidArgumentException('Node is not related to this repository');
404404
}
405405
$wrapped = new EntityWrapper($node, $this->_em);
@@ -476,7 +476,7 @@ public function getNextSiblings($node, $includeSelf = false)
476476
public function getPrevSiblingsQueryBuilder($node, $includeSelf = false)
477477
{
478478
$meta = $this->getClassMetadata();
479-
if (!$node instanceof $meta->name) {
479+
if (!is_a($node, $meta->getName())) {
480480
throw new InvalidArgumentException('Node is not related to this repository');
481481
}
482482
$wrapped = new EntityWrapper($node, $this->_em);
@@ -557,7 +557,7 @@ public function moveDown($node, $number = 1)
557557
{
558558
$result = false;
559559
$meta = $this->getClassMetadata();
560-
if ($node instanceof $meta->name) {
560+
if (is_a($node, $meta->getName())) {
561561
$nextSiblings = $this->getNextSiblings($node);
562562
if ($numSiblings = count($nextSiblings)) {
563563
$result = true;
@@ -592,7 +592,7 @@ public function moveUp($node, $number = 1)
592592
{
593593
$result = false;
594594
$meta = $this->getClassMetadata();
595-
if ($node instanceof $meta->name) {
595+
if (is_a($node, $meta->getName())) {
596596
$prevSiblings = array_reverse($this->getPrevSiblings($node));
597597
if ($numSiblings = count($prevSiblings)) {
598598
$result = true;
@@ -624,7 +624,7 @@ public function moveUp($node, $number = 1)
624624
public function removeFromTree($node)
625625
{
626626
$meta = $this->getClassMetadata();
627-
if ($node instanceof $meta->name) {
627+
if (is_a($node, $meta->getName())) {
628628
$wrapped = new EntityWrapper($node, $this->_em);
629629
$config = $this->listener->getConfiguration($this->_em, $meta->name);
630630
$right = $wrapped->getPropertyValue($config['right']);
@@ -744,7 +744,7 @@ public function removeFromTree($node)
744744
public function reorder($node, $sortByField = null, $direction = 'ASC', $verify = true)
745745
{
746746
$meta = $this->getClassMetadata();
747-
if ($node instanceof $meta->name || null === $node) {
747+
if (null === $node || is_a($node, $meta->getName())) {
748748
$config = $this->listener->getConfiguration($this->_em, $meta->name);
749749
if ($verify && is_array($this->verify())) {
750750
return false;

src/Tree/RepositoryUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function childrenHierarchy($node = null, $direct = false, array $options
5151
$meta = $this->getClassMetadata();
5252

5353
if (null !== $node) {
54-
if ($node instanceof $meta->name) {
54+
if (is_a($node, $meta->getName())) {
5555
$wrapperClass = $this->om instanceof \Doctrine\ORM\EntityManagerInterface ?
5656
EntityWrapper::class :
5757
MongoDocumentWrapper::class;

tests/Gedmo/Mapping/Annotation/BaseClassAnnotationTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private function getClassAnnotation(bool $attributes): Annotation
4949
$annotation = $reader->getClassAnnotation($reflection, $annotationClass);
5050
}
5151

52-
if (!$annotation instanceof $annotationClass) {
52+
if (!is_a($annotation, $annotationClass)) {
5353
throw new \LogicException('Can\'t parse annotation.');
5454
}
5555

tests/Gedmo/Mapping/Annotation/BasePropertyAnnotationTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private function getMethodAnnotation(string $property, bool $attributes): Annota
4949
$annotation = $reader->getPropertyAnnotation($reflection, $annotationClass);
5050
}
5151

52-
if (!$annotation instanceof $annotationClass) {
52+
if (!is_a($annotation, $annotationClass)) {
5353
throw new \LogicException('Can\'t parse annotation.');
5454
}
5555

0 commit comments

Comments
 (0)