Skip to content

Commit f3d2f95

Browse files
authored
Merge pull request #51 from magento-commerce/revert-49-add-enum
Revert "Add enum to visitor"
2 parents 7f240cf + 2f0654c commit f3d2f95

File tree

5 files changed

+4
-98
lines changed

5 files changed

+4
-98
lines changed

dev/tests/Unit/ClassHierarchy/EntityTest.php

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -479,21 +479,6 @@ public function testIsTrait(string $type, bool $expected)
479479
);
480480
}
481481

482-
/**
483-
* @dataProvider dataProviderIsEnum
484-
* @param string $type
485-
* @param bool $expected
486-
*/
487-
public function testIsEnum(string $type, bool $expected)
488-
{
489-
$entity = new Entity('myName', $type);
490-
491-
$this->assertEquals(
492-
$expected,
493-
$entity->isEnum()
494-
);
495-
}
496-
497482
/*
498483
* Data providers
499484
*/
@@ -518,10 +503,6 @@ public function dataProviderIsClass()
518503
Entity::TYPE_TRAIT,
519504
false,
520505
],
521-
'entity-is-enum-returns-false' => [
522-
Entity::TYPE_ENUM,
523-
false,
524-
],
525506
];
526507
}
527508

@@ -545,10 +526,6 @@ public function dataProviderIsInterface()
545526
Entity::TYPE_TRAIT,
546527
false,
547528
],
548-
'entity-is-enum-returns-false' => [
549-
Entity::TYPE_ENUM,
550-
false,
551-
],
552529
];
553530
}
554531

@@ -572,37 +549,6 @@ public function dataProviderIsTrait()
572549
Entity::TYPE_TRAIT,
573550
true,
574551
],
575-
'entity-is-enum-returns-false' => [
576-
Entity::TYPE_ENUM,
577-
false,
578-
],
579-
];
580-
}
581-
582-
/**
583-
* Provides test data for {@link EntityTest::testIsEnum()}
584-
*
585-
* @return array
586-
*/
587-
public function dataProviderIsEnum()
588-
{
589-
return [
590-
'entity-is-class-returns-false' => [
591-
Entity::TYPE_CLASS,
592-
false,
593-
],
594-
'entity-is-interface-returns-false' => [
595-
Entity::TYPE_INTERFACE,
596-
false,
597-
],
598-
'entity-is-trait-returns-false' => [
599-
Entity::TYPE_TRAIT,
600-
false,
601-
],
602-
'entity-is-enum-returns-true' => [
603-
Entity::TYPE_ENUM,
604-
true,
605-
],
606552
];
607553
}
608554

src/ClassHierarchy/DependencyGraph.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,4 @@ public function findOrCreateTrait(string $fullyQualifiedName): Entity
103103

104104
return $trait;
105105
}
106-
107-
/**
108-
* @param string $fullyQualifiedName
109-
* @return Entity
110-
*/
111-
public function findOrCreateEnum(string $fullyQualifiedName): Entity
112-
{
113-
$enum = $this->findEntityByName($fullyQualifiedName);
114-
115-
if (!$enum) {
116-
$enum = $this->entityFactory->createEnum($fullyQualifiedName);
117-
$this->addEntity($enum);
118-
}
119-
120-
return $enum;
121-
}
122106
}

src/ClassHierarchy/DependencyInspectionVisitor.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
use Magento\SemanticVersionChecker\Helper\Node as NodeHelper;
1313
use PhpParser\Node;
14-
use PhpParser\Node\Stmt\Enum_ as EnumNode;
1514
use PhpParser\Node\Stmt\Class_ as ClassNode;
1615
use PhpParser\Node\Stmt\ClassLike;
1716
use PhpParser\Node\Stmt\ClassMethod;
@@ -23,7 +22,7 @@
2322
use PhpParser\NodeVisitorAbstract;
2423

2524
/**
26-
* Implements a visitor for `class`, `interface`, `trait` and `enum` nodes that generates a dependency graph.
25+
* Implements a visitor for `class`, `interface` and `trait` nodes that generates a dependency graph.
2726
*/
2827
class DependencyInspectionVisitor extends NodeVisitorAbstract
2928
{
@@ -95,8 +94,8 @@ public function enterNode(Node $node)
9594
}
9695

9796
/**
98-
* Handles Class, Interface, Traits and Enum nodes. Sets currentClassLike entity and will populate extends,
99-
* implements, and API information
97+
* Handles Class, Interface, and Traits nodes. Sets currentClassLike entity and will populate extends, implements,
98+
* and API information
10099
*
101100
* @param ClassLike $node
102101
* @return int|null
@@ -136,9 +135,6 @@ private function handleClassLike(ClassLike $node)
136135
case $node instanceof TraitNode:
137136
$this->currentClassLike = $this->dependencyGraph->findOrCreateTrait((string)$namespacedName);
138137
break;
139-
case $node instanceof EnumNode:
140-
$this->currentClassLike = $this->dependencyGraph->findOrCreateEnum((string)$namespacedName);
141-
break;
142138
}
143139
$this->currentClassLike->setIsApi($this->nodeHelper->isApiNode($node));
144140
return null;

src/ClassHierarchy/Entity.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use PhpParser\Node\Stmt\PropertyProperty;
1515

1616
/**
17-
* Implements an entity that reflects a `class`, `interface`, `enum` or `trait` and its dependencies.
17+
* Implements an entity that reflects a `class`, `interface` or `trait` and its dependencies.
1818
*/
1919
class Entity
2020
{
@@ -24,7 +24,6 @@ class Entity
2424
public const TYPE_CLASS = 'class';
2525
public const TYPE_INTERFACE = 'interface';
2626
public const TYPE_TRAIT = 'trait';
27-
public const TYPE_ENUM = 'enum';
2827
/**#@-*/
2928

3029
/**
@@ -328,16 +327,6 @@ public function isTrait(): bool
328327
return $this->type === self::TYPE_TRAIT;
329328
}
330329

331-
/**
332-
* Reflects whether current entity reflects an `enum`.
333-
*
334-
* @return bool
335-
*/
336-
public function isEnum(): bool
337-
{
338-
return $this->type === self::TYPE_ENUM;
339-
}
340-
341330
/*
342331
* Private methods
343332
*/

src/ClassHierarchy/EntityFactory.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,4 @@ public function createTrait(string $name): Entity
4040
{
4141
return new Entity($name, Entity::TYPE_TRAIT);
4242
}
43-
44-
/**
45-
* @param string $name
46-
* @return Entity
47-
*/
48-
public function createEnum(string $name): Entity
49-
{
50-
return new Entity($name, Entity::TYPE_ENUM);
51-
}
5243
}

0 commit comments

Comments
 (0)