File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -37,8 +37,6 @@ final class ContextFactory
3737 * @see Context for more information on Contexts.
3838 *
3939 * @return Context
40- *
41- * @throws \InvalidArgumentException
4240 */
4341 public function createFromReflector (\Reflector $ reflector )
4442 {
@@ -47,8 +45,10 @@ public function createFromReflector(\Reflector $reflector)
4745 }
4846
4947 $ fileName = $ reflector ->getFileName ();
48+ $ namespace = $ reflector ->getNamespaceName ();
49+
5050 if (!$ fileName ) {
51- throw new \ InvalidArgumentException ( ' There is no file name associated with this reflector. ' );
51+ return new Context ( $ namespace , [] );
5252 }
5353
5454 return $ this ->createForNamespace ($ reflector ->getNamespaceName (), file_get_contents ($ fileName ));
Original file line number Diff line number Diff line change @@ -151,13 +151,14 @@ public function bar()
151151 }
152152
153153 /**
154- * @expectedException \InvalidArgumentException
155154 * @covers ::createFromReflector
156155 */
157- public function testThrowExceptionWhenEmptyFileName ()
156+ public function testEmptyFileName ()
158157 {
159158 $ fixture = new ContextFactory ();
160- $ fixture ->createFromReflector (new \ReflectionClass ('stdClass ' ));
159+ $ context = $ fixture ->createFromReflector (new \ReflectionClass ('stdClass ' ));
160+
161+ $ this ->assertSame ([], $ context ->getNamespaceAliases ());
161162 }
162163 }
163164}
You can’t perform that action at this time.
0 commit comments