Skip to content

Commit 3a90651

Browse files
committed
add test case with closure and use statement
1 parent 07100e6 commit 3a90651

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/unit/Types/ContextFactoryTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,31 @@ public function bar()
139139
$this->assertSame([], $context->getNamespaceAliases());
140140
}
141141

142+
public function testTraitContainsClosureWithUseStatement() : void
143+
{
144+
$php = '<?php declare(strict_types=1);
145+
namespace Foo;
146+
147+
trait FooTrait {
148+
protected function check(array $data, string $key) : void
149+
{
150+
array_walk($data, function(&$item) use ($key) {
151+
// update item based on the key
152+
});
153+
}
154+
}
155+
156+
class FooClass {
157+
use FooTrait;
158+
}
159+
';
160+
161+
$fixture = new ContextFactory();
162+
$context = $fixture->createForNamespace('Foo', $php);
163+
164+
$this->assertSame([], $context->getNamespaceAliases());
165+
}
166+
142167
/**
143168
* @covers ::createFromReflector
144169
*/

0 commit comments

Comments
 (0)