This repository was archived by the owner on Jan 29, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ public function isTrait()
236236 public function isInstantiable ()
237237 {
238238 $ this ->scan ();
239- return (!$ this ->isAbstract && !$ this ->isInterface );
239+ return (!$ this ->isAbstract && !$ this ->isInterface && ! $ this -> isTrait );
240240 }
241241
242242 /**
Original file line number Diff line number Diff line change @@ -274,4 +274,36 @@ public function testGetMethodsThrowsExceptionOnDuplicateMethods()
274274
275275 $ class ->getMethods ();
276276 }
277+
278+ public function testClassIsInstantiable ()
279+ {
280+ $ file = new FileScanner (__DIR__ . '/../TestAsset/FooBarClass.php ' );
281+ $ class = $ file ->getClass ('ZendTest_Code_TestAsset_FooBar ' );
282+ $ this ->assertFalse ($ class ->isAbstract ());
283+ $ this ->assertTrue ($ class ->isInstantiable ());
284+ }
285+
286+ public function testAbstractClassIsNotInstantiable ()
287+ {
288+ $ file = new FileScanner (__DIR__ . '/../TestAsset/FooClass.php ' );
289+ $ class = $ file ->getClass ('ZendTest\Code\TestAsset\FooClass ' );
290+ $ this ->assertTrue ($ class ->isAbstract ());
291+ $ this ->assertFalse ($ class ->isInstantiable ());
292+ }
293+
294+ public function testInterfaceIsNotInstantiable ()
295+ {
296+ $ file = new FileScanner (__DIR__ . '/../TestAsset/FooInterface.php ' );
297+ $ class = $ file ->getClass ('ZendTest\Code\TestAsset\FooInterface ' );
298+ $ this ->assertTrue ($ class ->isInterface ());
299+ $ this ->assertFalse ($ class ->isInstantiable ());
300+ }
301+
302+ public function testTraitIsNotInstantiable ()
303+ {
304+ $ file = new FileScanner (__DIR__ . '/../TestAsset/FooTrait.php ' );
305+ $ class = $ file ->getClass ('ZendTest\Code\TestAsset\FooTrait ' );
306+ $ this ->assertTrue ($ class ->isTrait ());
307+ $ this ->assertFalse ($ class ->isInstantiable ());
308+ }
277309}
You can’t perform that action at this time.
0 commit comments