File tree 3 files changed +20
-2
lines changed
src/phpDocumentor/Reflection/Php/Factory
unit/phpDocumentor/Reflection/Php/Factory
3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ final class Function_ extends AbstractFactory implements ProjectFactoryStrategy
33
33
{
34
34
public function matches (ContextStack $ context , object $ object ): bool
35
35
{
36
- return $ object instanceof FunctionNode;
36
+ return $ object instanceof FunctionNode && $ context -> peek () instanceof FileElement ;
37
37
}
38
38
39
39
/**
Original file line number Diff line number Diff line change @@ -83,4 +83,22 @@ public function testGlobalNamespacedFunctionDefine() : void
83
83
$ project ->getFiles ()[$ fileName ]->getFunctions ()
84
84
);
85
85
}
86
+
87
+ /**
88
+ * @covers \phpDocumentor\Reflection\Php\Factory\File::create
89
+ * @covers \phpDocumentor\Reflection\Php\Factory\File::<private>
90
+ */
91
+ public function testFileWithInlineFunction () : void
92
+ {
93
+ $ fileName = __DIR__ . '/data/GlobalFiles/inline_function.php ' ;
94
+ $ project = $ this ->fixture ->create (
95
+ 'MyProject ' ,
96
+ [new LocalFile ($ fileName )]
97
+ );
98
+
99
+ $ this ->assertCount (
100
+ 1 ,
101
+ $ project ->getFiles ()[$ fileName ]->getClasses ()
102
+ );
103
+ }
86
104
}
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ public function testMatches(): void
63
63
{
64
64
$ this ->assertFalse ($ this ->fixture ->matches (self ::createContext (null ), new stdClass ()));
65
65
$ this ->assertTrue ($ this ->fixture ->matches (
66
- self ::createContext (null ),
66
+ self ::createContext (null )-> push ( new File ( ' hash ' , ' path ' )) ,
67
67
$ this ->prophesize (\PhpParser \Node \Stmt \Function_::class)->reveal ()
68
68
));
69
69
}
You can’t perform that action at this time.
0 commit comments