History
Version 986
at Saturday 19 September 2009 20:01:08 UTC - Fixed #98: Fatal error caused by Null-Package fixed.Diff
| 985 | 986 | /tests/PHP/Depend/ParserTest.php |
|---|---|---|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
| 192 | - * Tests that the parser handles function with reference return values | |
| 193 | - * correct. | |
| 194 | - * | |
| 195 | - * @return void | |
| 196 | - * @group parser | |
| 197 | - */ | |
| 198 | - public function testParserFunctionReturnsReferenceBug004() | |
| 199 | - { | |
| 200 | - $packages = self::parseSource(dirname(__FILE__) . '/_code/bugs/004.php'); | |
| 201 | -// $packages->next(); | |
| 202 | - | |
| 203 | - $package = $packages->current(); | |
| 204 | - | |
| 205 | - $function = $package->getFunctions()->current(); | |
| 206 | - $this->assertEquals('barBug08', $function->getName()); | |
| 207 | - } | |
| 208 | - | |
| 209 | - /** | |
| 210 | - * Tests that the parser handles function with reference return values | |
| 211 | - * correct. | |
| 212 | - * | |
| 213 | - * @return void | |
| 214 | - * @group parser | |
| 215 | - */ | |
| 216 | - public function testParserMethodReturnsByReferenceBug004() | |
| 217 | - { | |
| 218 | - $packages = self::parseSource(dirname(__FILE__) . '/_code/bugs/004.php'); | |
| 219 | - $package = $packages->current(); | |
| 220 | - | |
| 221 | - $method = $package->getTypes() | |
| 222 | - ->current() | |
| 223 | - ->getMethods() | |
| 224 | - ->current(); | |
| 225 | - $this->assertEquals('fooBug08', $method->getName()); | |
| 226 | - } | |
| 227 | - | |
| 228 | - /** | |
| 229 | 192 | * Tests that the parser sets the correct line number for a function. |
| 230 | 193 | * |
| 231 | 194 | * @return void |
| 985 | 986 | /tests/PHP/Depend/Builder/DefaultTest.php |
| 72 | 72 | public function testBuildClassUnique() |
| 73 | 73 | { |
| 74 | 74 | $builder = new PHP_Depend_Builder_Default(); |
| 75 | - $class1 = $builder->buildClass('clazz1'); | |
| 76 | - $class2 = $builder->getClass('clazz1'); | |
| 77 | 75 | |
| 78 | - $this->assertType('PHP_Depend_Code_Class', $class1); | |
| 79 | - $this->assertType('PHP_Depend_Code_Class', $class2); | |
| 80 | - | |
| 81 | - $this->assertSame($class1, $class2); | |
| 76 | + $class = $builder->buildClass(__FUNCTION__); | |
| 77 | + $class->setPackage($builder->buildPackage(__FUNCTION__)); | |
| 78 | + | |
| 79 | + $this->assertSame($class, $builder->getClass(__FUNCTION__)); | |
| 82 | 80 | } |
| 83 | 81 | |
| 84 | 82 | /** |
| 85 | - * Tests that the node builder appends a default package to all new created | |
| 86 | - * classes. | |
| 87 | - * | |
| 88 | - * @return void | |
| 89 | - */ | |
| 90 | - public function testBuildClassDefaultPackage() | |
| 91 | - { | |
| 92 | - $defaultPackage = PHP_Depend_BuilderI::DEFAULT_PACKAGE; | |
| 93 | - | |
| 94 | - $builder = new PHP_Depend_Builder_Default(); | |
| 95 | - $class1 = $builder->buildClass('clazz1'); | |
| 96 | - $class2 = $builder->buildClass('clazz2'); | |
| 97 | - | |
| 98 | - $this->assertNotNull($class1->getPackage()); | |
| 99 | - $this->assertNotNull($class2->getPackage()); | |
| 100 | - | |
| 101 | - $this->assertSame($class1->getPackage(), $class2->getPackage()); | |
| 102 | - $this->assertEquals($defaultPackage, $class1->getPackage()->getName()); | |
| 103 | - } | |
| 104 | - | |
| 105 | - /** | |
| 106 | 83 | * Tests that the {@link PHP_Depend_Builder_Default::buildClass()} method |
| 107 | 84 | * creates two different class instances for the same class name, but |
| 108 | 85 | * different packages. |
| 130 | 107 | $builder = new PHP_Depend_Builder_Default(); |
| 131 | 108 | |
| 132 | 109 | $class1 = $builder->buildClass('php\depend\Parser'); |
| 110 | + $class1->setPackage($builder->buildPackage(__FUNCTION__)); | |
| 111 | + | |
| 133 | 112 | $class2 = $builder->getClass('Parser'); |
| 134 | 113 | |
| 135 | 114 | $this->assertSame($class1, $class2); |
| 147 | 126 | */ |
| 148 | 127 | public function testBuildInterfaceUnique() |
| 149 | 128 | { |
| 150 | - $builder = new PHP_Depend_Builder_Default(); | |
| 129 | + $builder = new PHP_Depend_Builder_Default(); | |
| 151 | 130 | |
| 152 | - $interface1 = $builder->buildInterface('interface1'); | |
| 153 | - $interface2 = $builder->getInterface('interface1'); | |
| 131 | + $interface = $builder->buildInterface(__FUNCTION__); | |
| 132 | + $interface->setPackage($builder->buildPackage(__FUNCTION__)); | |
| 154 | 133 | |
| 155 | - $this->assertType('PHP_Depend_Code_Interface', $interface1); | |
| 156 | - $this->assertType('PHP_Depend_Code_Interface', $interface2); | |
| 157 | - | |
| 158 | - $this->assertSame($interface1, $interface2); | |
| 134 | + $this->assertSame($interface, $builder->getInterface(__FUNCTION__)); | |
| 159 | 135 | } |
| 160 | 136 | |
| 161 | 137 | /** |
| 232 | 208 | $builder = new PHP_Depend_Builder_Default(); |
| 233 | 209 | |
| 234 | 210 | $pdependInterface = $builder->buildInterface('php\depend\ParserI'); |
| 235 | - $pdependPackage = $pdependInterface->getPackage(); | |
| 211 | + $pdependInterface->setPackage($builder->buildPackage(__FUNCTION__)); | |
| 236 | 212 | |
| 237 | 213 | $defaultInterface = $builder->getInterface('ParserI'); |
| 238 | - $defaultPackage = $defaultInterface->getPackage(); | |
| 239 | 214 | |
| 240 | 215 | $this->assertSame($defaultInterface, $pdependInterface); |
| 241 | - $this->assertSame($defaultPackage, $pdependPackage); | |
| 216 | + $this->assertSame($defaultInterface->getPackage(), $pdependInterface->getPackage()); | |
| 242 | 217 | } |
| 243 | 218 | |
| 244 | 219 | /** |
| 326 | 301 | $builder = new PHP_Depend_Builder_Default(); |
| 327 | 302 | |
| 328 | 303 | $class1 = $builder->buildClass('FooBar'); |
| 304 | + $class1->setPackage($builder->buildPackage(__FUNCTION__)); | |
| 305 | + | |
| 329 | 306 | $class2 = $builder->buildClass('FooBar'); |
| 307 | + $class2->setPackage($builder->buildPackage(__FUNCTION__)); | |
| 330 | 308 | |
| 331 | 309 | $this->assertNotSame($class1, $class2); |
| 332 | 310 | $this->assertSame($class1, $builder->getClass('FooBar')); |
| 342 | 320 | { |
| 343 | 321 | $builder = new PHP_Depend_Builder_Default(); |
| 344 | 322 | |
| 345 | - $interface1 = $builder->buildInterface('FooBar'); | |
| 346 | - $interface2 = $builder->buildInterface('FooBar'); | |
| 323 | + $interface = $builder->buildInterface('FooBar'); | |
| 324 | + $interface->setPackage($builder->buildPackage(__FUNCTION__)); | |
| 347 | 325 | |
| 348 | - $this->assertNotSame($interface1, $interface2); | |
| 349 | - $this->assertSame($interface1, $builder->getInterface('FooBar')); | |
| 326 | + $this->assertNotSame($interface, $builder->buildInterface('FooBar')); | |
| 327 | + $this->assertSame($interface, $builder->getInterface('FooBar')); | |
| 350 | 328 | } |
| 351 | 329 | |
| 352 | 330 | /** |
| 358 | 336 | { |
| 359 | 337 | $builder = new PHP_Depend_Builder_Default(); |
| 360 | 338 | |
| 361 | - $classA = $builder->buildClass('PHP_Depend_Parser'); | |
| 362 | - $classB = $builder->getClass('php_Depend_parser'); | |
| 339 | + $class = $builder->buildClass('PHP_Depend_Parser'); | |
| 340 | + $class->setPackage($builder->buildPackage(__FUNCTION__)); | |
| 363 | 341 | |
| 364 | - $this->assertSame($classA, $classB); | |
| 342 | + $this->assertSame($class, $builder->getClass('php_Depend_parser')); | |
| 365 | 343 | } |
| 366 | 344 | |
| 367 | 345 | /** |
| 373 | 351 | { |
| 374 | 352 | $builder = new PHP_Depend_Builder_Default(); |
| 375 | 353 | |
| 376 | - $interfaceA = $builder->buildInterface('PHP_Depend_TokenizerI'); | |
| 377 | - $interfaceB = $builder->getInterface('php_Depend_tokenizeri'); | |
| 354 | + $interface = $builder->buildInterface('PHP_Depend_TokenizerI'); | |
| 355 | + $interface->setPackage($builder->buildPackage(__FUNCTION__)); | |
| 378 | 356 | |
| 379 | - $this->assertSame($interfaceA, $interfaceB); | |
| 357 | + $this->assertSame($interface, $builder->getInterface('php_Depend_tokenizeri')); | |
| 380 | 358 | } |
| 381 | 359 | |
| 382 | 360 | /** |
| 388 | 366 | { |
| 389 | 367 | $builder = new PHP_Depend_Builder_Default(); |
| 390 | 368 | |
| 391 | - $interfaceA = $builder->buildInterface('PHP_Depend_TokenizerI'); | |
| 392 | - $interfaceB = $builder->getClassOrInterface('php_Depend_tokenizeri'); | |
| 369 | + $interface = $builder->buildInterface('PHP_Depend_TokenizerI'); | |
| 370 | + $interface->setPackage($builder->buildPackage(__FUNCTION__)); | |
| 393 | 371 | |
| 394 | - $this->assertSame($interfaceA, $interfaceB); | |
| 372 | + $this->assertSame($interface, $builder->getClassOrInterface('php_Depend_tokenizeri')); | |
| 395 | 373 | } |
| 396 | 374 | |
| 397 | 375 | /** |
| 403 | 381 | { |
| 404 | 382 | $builder = new PHP_Depend_Builder_Default(); |
| 405 | 383 | |
| 406 | - $classA = $builder->buildClass('PHP_Depend_Parser'); | |
| 407 | - $classB = $builder->getClassOrInterface('php_Depend_parser'); | |
| 384 | + $class = $builder->buildClass('PHP_Depend_Parser'); | |
| 385 | + $class->setPackage($builder->buildPackage(__FUNCTION__)); | |
| 408 | 386 | |
| 409 | - $this->assertSame($classA, $classB); | |
| 387 | + $this->assertSame($class, $builder->getClassOrInterface('php_Depend_parser')); | |
| 410 | 388 | } |
| 411 | 389 | |
| 412 | 390 | /** |
| 985 | 986 | /tests/PHP/Depend/Bugs/AllTests.php |
| 54 | 54 | require_once 'PHPUnit/Framework/TestSuite.php'; |
| 55 | 55 | require_once 'PHPUnit/TextUI/TestRunner.php'; |
| 56 | 56 | |
| 57 | +require_once dirname(__FILE__) . '/InvalidResultWhenFunctionReturnsByReferenceBug004Test.php'; | |
| 57 | 58 | require_once dirname(__FILE__) . '/InstanceOfExpressionReferenceHandlingBug062Test.php'; |
| 58 | 59 | require_once dirname(__FILE__) . '/ClassDeclarationWithoutBodyBug065Test.php'; |
| 59 | 60 | require_once dirname(__FILE__) . '/IncorrectPropertyEndlineBug068Test.php'; |
| 105 | 106 | { |
| 106 | 107 | $suite = new PHPUnit_Framework_TestSuite('PHP_Depend_Bugs - AllTests'); |
| 107 | 108 | |
| 109 | + $suite->addTestSuite('PHP_Depend_Bugs_InvalidResultWhenFunctionReturnsByReferenceBug004Test'); | |
| 108 | 110 | $suite->addTestSuite('PHP_Depend_Bugs_InstanceOfExpressionReferenceHandlingBug062Test'); |
| 109 | 111 | $suite->addTestSuite('PHP_Depend_Bugs_ClassDeclarationWithoutBodyBug065Test'); |
| 110 | 112 | $suite->addTestSuite('PHP_Depend_Bugs_IncorrectPropertyEndlineBug068Test'); |
| 985 | 986 | /tests/PHP/Depend/Bugs/InvalidResultWhenFunctionReturnsByReferenceBug004Test.php |
| 2 | +<?php | |
| 3 | +/** | |
| 4 | + * This file is part of PHP_Depend. | |
| 5 | + * | |
| 6 | + * PHP Version 5 | |
| 7 | + * | |
| 8 | + * Copyright (c) 2008-2009, Manuel Pichler <mapi@pdepend.org>. | |
| 9 | + * All rights reserved. | |
| 10 | + * | |
| 11 | + * Redistribution and use in source and binary forms, with or without | |
| 12 | + * modification, are permitted provided that the following conditions | |
| 13 | + * are met: | |
| 14 | + * | |
| 15 | + * * Redistributions of source code must retain the above copyright | |
| 16 | + * notice, this list of conditions and the following disclaimer. | |
| 17 | + * | |
| 18 | + * * Redistributions in binary form must reproduce the above copyright | |
| 19 | + * notice, this list of conditions and the following disclaimer in | |
| 20 | + * the documentation and/or other materials provided with the | |
| 21 | + * distribution. | |
| 22 | + * | |
| 23 | + * * Neither the name of Manuel Pichler nor the names of his | |
| 24 | + * contributors may be used to endorse or promote products derived | |
| 25 | + * from this software without specific prior written permission. | |
| 26 | + * | |
| 27 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 28 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 29 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
| 30 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
| 31 | + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |
| 32 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
| 33 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 34 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
| 35 | + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 36 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
| 37 | + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 38 | + * POSSIBILITY OF SUCH DAMAGE. | |
| 39 | + * | |
| 40 | + * @category PHP | |
| 41 | + * @package PHP_Depend | |
| 42 | + * @subpackage Bugs | |
| 43 | + * @author Manuel Pichler <mapi@pdepend.org> | |
| 44 | + * @copyright 2008-2009 Manuel Pichler. All rights reserved. | |
| 45 | + * @license http://www.opensource.org/licenses/bsd-license.php BSD License | |
| 46 | + * @version SVN: $Id$ | |
| 47 | + * @link http://www.pdepend.org/ | |
| 48 | + */ | |
| 49 | + | |
| 50 | +require_once dirname(__FILE__) . '/AbstractTest.php'; | |
| 51 | + | |
| 52 | +/** | |
| 53 | + * Test case for bug #4 | |
| 54 | + * | |
| 55 | + * @category PHP | |
| 56 | + * @package PHP_Depend | |
| 57 | + * @subpackage Bugs | |
| 58 | + * @author Manuel Pichler <mapi@pdepend.org> | |
| 59 | + * @copyright 2008-2009 Manuel Pichler. All rights reserved. | |
| 60 | + * @license http://www.opensource.org/licenses/bsd-license.php BSD License | |
| 61 | + * @version Release: @package_version@ | |
| 62 | + * @link http://www.pdepend.org/ | |
| 63 | + */ | |
| 64 | +class PHP_Depend_Bugs_InvalidResultWhenFunctionReturnsByReferenceBug004Test | |
| 65 | + extends PHP_Depend_Bugs_AbstractTest | |
| 66 | +{ | |
| 67 | + /** | |
| 68 | + * Tests that the parser handles function with reference return values | |
| 69 | + * correct. | |
| 70 | + * | |
| 71 | + * @return void | |
| 72 | + * @group bugs | |
| 73 | + */ | |
| 74 | + public function testParserCreatesInvalidFunctionWhenReturnsByReference() | |
| 75 | + { | |
| 76 | + $package = self::parseTestCaseSource(__METHOD__)->current(); | |
| 77 | + | |
| 78 | + $function = $package->getFunctions()->current(); | |
| 79 | + $this->assertEquals('barBug08', $function->getName()); | |
| 80 | + } | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * Tests that the parser handles function with reference return values | |
| 84 | + * correct. | |
| 85 | + * | |
| 86 | + * @return void | |
| 87 | + * @group bugs | |
| 88 | + */ | |
| 89 | + public function testParserCreatesInvalidMethodWhenReturnsByReference() | |
| 90 | + { | |
| 91 | + $package = self::parseTestCaseSource(__METHOD__)->current(); | |
| 92 | + | |
| 93 | + $method = $package->getTypes() | |
| 94 | + ->current() | |
| 95 | + ->getMethods() | |
| 96 | + ->current(); | |
| 97 | + $this->assertEquals('fooBug08', $method->getName()); | |
| 98 | + } | |
| 99 | +} | |
| 985 | 986 | /tests/PHP/Depend/Bugs/DefaultPackageContainsBrokenAritfactsBug098Test.php |
| 105 | 105 | |
| 106 | 106 | $this->assertSame(1, $classes->count()); |
| 107 | 107 | } |
| 108 | + | |
| 109 | + /** | |
| 110 | + * Tests that the result does not contain an interface with a broken body. | |
| 111 | + * | |
| 112 | + * @return void | |
| 113 | + * @group bugs | |
| 114 | + */ | |
| 115 | + public function testDefaultPackageDoesNotContainsInterfaceWithBrokenBody() | |
| 116 | + { | |
| 117 | + $pdepend = new PHP_Depend(); | |
| 118 | + $pdepend->addFile(self::getSourceFileForTestCase(__METHOD__)); | |
| 119 | + $pdepend->setSupportBadDocumentation(); | |
| 120 | + $pdepend->analyze(); | |
| 121 | + | |
| 122 | + $interfaces = $pdepend->getPackages() | |
| 123 | + ->current() | |
| 124 | + ->getInterfaces(); | |
| 125 | + | |
| 126 | + $this->assertSame(1, $interfaces->count()); | |
| 127 | + } | |
| 108 | 128 | } |
| 985 | 986 | /tests/PHP/Depend/_code/bugs/004.php |
| 2 | -<?php | |
| 3 | -/** | |
| 4 | - * The parser implementation didn't handle reference return values correct. | |
| 5 | - * | |
| 6 | - * http://bugs.xplib.de/index.php?do=details&task_id=8&project=3 | |
| 7 | - * | |
| 8 | - * @package package0 | |
| 9 | - */ | |
| 10 | -class clazz0 | |
| 11 | -{ | |
| 12 | - public function &fooBug08() | |
| 13 | - { | |
| 14 | - } | |
| 15 | -} | |
| 16 | - | |
| 17 | -/** | |
| 18 | - * @package package0 | |
| 19 | - */ | |
| 20 | -function &barBug08() | |
| 21 | -{ | |
| 22 | - | |
| 23 | -} | |
| 985 | 986 | /tests/PHP/Depend/_code/bugs/004/testParserCreatesInvalidMethodWhenReturnsByReference.php |
| 2 | +<?php | |
| 3 | +/** | |
| 4 | + * The parser implementation didn't handle reference return values correct. | |
| 5 | + * | |
| 6 | + * http://bugs.xplib.de/index.php?do=details&task_id=8&project=3 | |
| 7 | + * | |
| 8 | + * @package package0 | |
| 9 | + */ | |
| 10 | +class clazz0 | |
| 11 | +{ | |
| 12 | + public function &fooBug08() | |
| 13 | + { | |
| 14 | + } | |
| 15 | +} | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * @package package0 | |
| 19 | + */ | |
| 20 | +function &barBug08() | |
| 21 | +{ | |
| 22 | + | |
| 23 | +} | |
| 985 | 986 | /tests/PHP/Depend/_code/bugs/004/testParserCreatesInvalidFunctionWhenReturnsByReference.php |
| 2 | +<?php | |
| 3 | +/** | |
| 4 | + * The parser implementation didn't handle reference return values correct. | |
| 5 | + * | |
| 6 | + * http://bugs.xplib.de/index.php?do=details&task_id=8&project=3 | |
| 7 | + * | |
| 8 | + * @package package0 | |
| 9 | + */ | |
| 10 | +class clazz0 | |
| 11 | +{ | |
| 12 | + public function &fooBug08() | |
| 13 | + { | |
| 14 | + } | |
| 15 | +} | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * @package package0 | |
| 19 | + */ | |
| 20 | +function &barBug08() | |
| 21 | +{ | |
| 22 | + | |
| 23 | +} | |
| 985 | 986 | /tests/PHP/Depend/_code/bugs/098/testDefaultPackageDoesNotContainsInterfaceWithBrokenBody.php |
| 2 | +<?php | |
| 3 | +interface Foo extends Bar {} | |
| 4 | +interface Bar { ; } | |
| 985 | 986 | /PHP/Depend/Parser.php |
| 295 | 295 | break; |
| 296 | 296 | |
| 297 | 297 | case self::T_INTERFACE: |
| 298 | - $this->_parseInterfaceDeclaration(); | |
| 298 | + $package = $this->_builder->buildPackage( | |
| 299 | + $this->_getNamespaceOrPackageName() | |
| 300 | + ); | |
| 301 | + $package->addType($this->_parseInterfaceDeclaration()); | |
| 299 | 302 | break; |
| 300 | 303 | |
| 301 | 304 | case self::T_CLASS: |
| 302 | 305 | case self::T_FINAL: |
| 303 | 306 | case self::T_ABSTRACT: |
| 304 | - $this->_parseClassDeclaration(); | |
| 307 | + $package = $this->_builder->buildPackage( | |
| 308 | + $this->_getNamespaceOrPackageName() | |
| 309 | + ); | |
| 310 | + $package->addType($this->_parseClassDeclaration()); | |
| 305 | 311 | break; |
| 306 | 312 | |
| 307 | 313 | case self::T_FUNCTION: |
| 446 | 452 | |
| 447 | 453 | $class->setTokens($this->_tokenStack->pop()); |
| 448 | 454 | |
| 449 | -// $package = $this->_builder->buildPackage($this->_getNamespaceOrPackageName()); | |
| 450 | -// $package->addType($class); | |
| 451 | - | |
| 452 | - // Reset parser settings | |
| 453 | 455 | $this->reset(); |
| 454 | 456 | |
| 455 | 457 | return $class; |
| 985 | 986 | /PHP/Depend/Builder/Default.php |
| 237 | 237 | $class = new PHP_Depend_Code_Class($className); |
| 238 | 238 | $class->setSourceFile($this->defaultFile); |
| 239 | 239 | |
| 240 | - $package = $this->buildPackage($packageName); | |
| 241 | - $package->addType($class); | |
| 242 | - | |
| 243 | 240 | $this->storeClass($className, $packageName, $class); |
| 244 | 241 | |
| 245 | 242 | return $class; |
| 349 | 346 | $interface = new PHP_Depend_Code_Interface($interfaceName); |
| 350 | 347 | $interface->setSourceFile($this->defaultFile); |
| 351 | 348 | |
| 352 | - $package = $this->buildPackage($packageName); | |
| 353 | - $package->addType($interface); | |
| 354 | - | |
| 355 | 349 | $this->storeInterface($interfaceName, $packageName, $interface); |
| 356 | 350 | |
| 357 | 351 | return $interface; |
| 1370 | 1364 | protected function buildInterfaceInternal($qualifiedName) |
| 1371 | 1365 | { |
| 1372 | 1366 | $this->_internal = true; |
| 1373 | - return $this->buildInterface($qualifiedName); | |
| 1367 | + | |
| 1368 | + $package = $this->buildPackage($this->extractPackageName($qualifiedName)); | |
| 1369 | + return $package->addType( | |
| 1370 | + $this->buildInterface($qualifiedName) | |
| 1371 | + ); | |
| 1374 | 1372 | } |
| 1375 | 1373 | |
| 1376 | 1374 | /** |
| 1433 | 1431 | protected function buildClassInternal($qualifiedName) |
| 1434 | 1432 | { |
| 1435 | 1433 | $this->_internal = true; |
| 1436 | - return $this->buildClass($qualifiedName); | |
| 1434 | + | |
| 1435 | + $package = $this->buildPackage($this->extractPackageName($qualifiedName)); | |
| 1436 | + return $package->addType( | |
| 1437 | + $this->buildClass($qualifiedName) | |
| 1438 | + ); | |
| 1437 | 1439 | } |
| 1438 | 1440 | |
| 1439 | 1441 | /** |
| 1511 | 1513 | |
| 1512 | 1514 | $this->_frozen = true; |
| 1513 | 1515 | |
| 1514 | - $this->_frozenClasses = $this->_classes; | |
| 1515 | - $this->_frozenInterfaces = $this->_interfaces; | |
| 1516 | + $this->_frozenClasses = $this->_copyTypesWithPackage($this->_classes); | |
| 1517 | + $this->_frozenInterfaces = $this->_copyTypesWithPackage($this->_interfaces); | |
| 1518 | + //$this->_frozenClasses = $this->_classes; | |
| 1519 | + //$this->_frozenInterfaces = $this->_interfaces; | |
| 1516 | 1520 | |
| 1517 | 1521 | $this->_classes = array(); |
| 1518 | 1522 | $this->_interfaces = array(); |
| 1519 | 1523 | } |
| 1520 | 1524 | |
| 1521 | 1525 | /** |
| 1526 | + * Creates a copy of the given input array, but skips all types that do not | |
| 1527 | + * contain a parent package. | |
| 1528 | + * | |
| 1529 | + * @param array $originalTypes The original types created during the parsing | |
| 1530 | + * process. | |
| 1531 | + * | |
| 1532 | + * @return array | |
| 1533 | + */ | |
| 1534 | + private function _copyTypesWithPackage(array $originalTypes) | |
| 1535 | + { | |
| 1536 | + $copiedTypes = array(); | |
| 1537 | + foreach ($originalTypes as $typeName => $packages) { | |
| 1538 | + foreach ($packages as $package => $types) { | |
| 1539 | + foreach ($types as $index => $type) { | |
| 1540 | + if (is_object($type->getPackage())) { | |
| 1541 | + $copiedTypes[$typeName][$package][$index] = $type; | |
| 1542 | + } | |
| 1543 | + } | |
| 1544 | + } | |
| 1545 | + } | |
| 1546 | + return $copiedTypes; | |
| 1547 | + } | |
| 1548 | + | |
| 1549 | + /** | |
| 1522 | 1550 | * This method will persist a class instance for later reuse. |
| 1523 | 1551 | * |
| 1524 | 1552 | * @param string $className The local class name. |
| 985 | 986 | /PHP/Depend/Code/Package.php |
| 183 | 183 | { |
| 184 | 184 | // Skip if this package already contains this type |
| 185 | 185 | if (in_array($type, $this->types, true)) { |
| 186 | - return; | |
| 186 | + return $type; | |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | if ($type->getPackage() !== null) { |
| 985 | 986 | /PHP/Depend/Code/AbstractCallable.php |
| 251 | 251 | public function getDependencies() |
| 252 | 252 | { |
| 253 | 253 | $classReferences = $this->_dependencyClassReferences; |
| 254 | - foreach ($this->getParameters() as $parameter) { | |
| 255 | - if ($parameter->getClassReference() === null) { | |
| 256 | - continue; | |
| 257 | - } | |
| 258 | - $classReferences[] = $parameter->getClassReference(); | |
| 259 | - } | |
| 260 | 254 | |
| 261 | 255 | $references = $this->findChildrenOfType( |
| 262 | 256 | PHP_Depend_Code_ASTClassOrInterfaceReference::CLAZZ |