Skip to content

Commit

Permalink
Merge pull request #202 from ray-di/fix_compile
Browse files Browse the repository at this point in the history
  • Loading branch information
koriym authored Sep 6, 2023
2 parents 18f58cf + 21217d8 commit 918e6f5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/CodeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private function validateClass(Class_ $class): void
*/
private function enterNodeClass(Node $node)
{
if ($node instanceof Class_) {
if ($node instanceof Class_ && $node->name !== null) {
$this->validateClass($node);
$this->class = $node;

Expand Down
7 changes: 7 additions & 0 deletions tests/CompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,11 @@ public function testCompileMultipleFile(): void
$bind = (new Bind())->bindInterceptors('foo', [new FakeDoubleInterceptor()]);
$compiler->newInstance(FakeTwoClass::class, [], $bind);
}

public function testNewInstanceWithAnonymousClass(): void
{
$mock = $this->compiler->newInstance(FakeAnonymousClass::class, [], $this->bind);
$this->assertInstanceOf(FakeAnonymousClass::class, $mock);
$this->assertInstanceOf(WeavedInterface::class, $mock);
}
}
13 changes: 13 additions & 0 deletions tests/Fake/FakeAnonymousClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace Ray\Aop;

class FakeAnonymousClass
{
public function hasAnonymousClass(): object
{
return new class {};
}
}

0 comments on commit 918e6f5

Please sign in to comment.