Arbit - project tracking

PHP Depend

History

Diff

1009 1010 /tests/PHP/Depend/Bugs/AllTests.php
73 73 require_once dirname(__FILE__) . '/NPathComplexityIsBrokenInVersion096Bug095Test.php';
74 74 require_once dirname(__FILE__) . '/DefaultPackageContainsBrokenAritfactsBug098Test.php';
75 75 require_once dirname(__FILE__) . '/ParserSetsIncorrectStartLineBug101Test.php';
76 +require_once dirname(__FILE__) . '/NamespaceKeywordInParameterTypeHintBug102Test.php';
76 77 require_once dirname(__FILE__) . '/ParameterStringDefaultValueBug103Test.php';
77 78
78 79 /**
127 128 $suite->addTestSuite('PHP_Depend_Bugs_NPathComplexityIsBrokenInVersion096Bug095Test');
128 129 $suite->addTestSuite('PHP_Depend_Bugs_DefaultPackageContainsBrokenAritfactsBug098Test');
129 130 $suite->addTestSuite('PHP_Depend_Bugs_ParserSetsIncorrectStartLineBug101Test');
131 + $suite->addTestSuite('PHP_Depend_Bugs_NamespaceKeywordInParameterTypeHintBug102Test');
130 132 $suite->addTestSuite('PHP_Depend_Bugs_ParameterStringDefaultValueBug103Test');
131 133
132 134 return $suite;
1009 1010 /tests/PHP/Depend/Bugs/NamespaceKeywordInParameterTypeHintBug102Test.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 102. The current parser implementation does not handle
54 + * the <b>namespace</b> keyword in parameter type hints.
55 + *
56 + * http://tracker.pdepend.org/pdepend/issue_tracker/issue/102
57 + *
58 + * @category PHP
59 + * @package PHP_Depend
60 + * @subpackage Bugs
61 + * @author Manuel Pichler <mapi@pdepend.org>
62 + * @copyright 2008-2009 Manuel Pichler. All rights reserved.
63 + * @license http://www.opensource.org/licenses/bsd-license.php BSD License
64 + * @version Release: @package_version@
65 + * @link http://www.pdepend.org/
66 + */
67 +class PHP_Depend_Bugs_NamespaceKeywordInParameterTypeHintBug102Test
68 + extends PHP_Depend_Bugs_AbstractTest
69 +{
70 + /**
71 + * testParserHandlesNamespaceKeywordInFunctionParameterTypeHint
72 + *
73 + * @return void
74 + * @covers PHP_Depend_Parser
75 + * @group parser
76 + * @group bugs
77 + */
78 + public function testParserHandlesNamespaceKeywordInFunctionParameterTypeHint()
79 + {
80 + $packages = self::parseTestCaseSource(__METHOD__);
81 + $parameter = $packages->current()
82 + ->getFunctions()
83 + ->current()
84 + ->getParameters()
85 + ->current();
86 +
87 + $this->assertEquals('foo\bar', $parameter->getClass()->getPackage()->getName());
88 + }
89 +
90 + /**
91 + * testParserHandlesNamespaceKeywordInMethodParameterTypeHint
92 + *
93 + * @return void
94 + * @covers PHP_Depend_Parser
95 + * @group parser
96 + * @group bugs
97 + */
98 + public function testParserHandlesNamespaceKeywordInMethodParameterTypeHint()
99 + {
100 + $packages = self::parseTestCaseSource(__METHOD__);
101 + $parameter = $packages->current()
102 + ->getClasses()
103 + ->current()
104 + ->getMethods()
105 + ->current()
106 + ->getParameters()
107 + ->current();
108 +
109 + $this->assertEquals('foo\bar', $parameter->getClass()->getPackage()->getName());
110 + }
111 +}
1009 1010 /tests/PHP/Depend/_code/bugs/102/testParserHandlesNamespaceKeywordInMethodParameterTypeHint.php
2 +<?php
3 +namespace foo;
4 +
5 +class Bar {
6 + function baz(namespace\bar\Baz $x) {}
7 +}
1009 1010 /tests/PHP/Depend/_code/bugs/102/testParserHandlesNamespaceKeywordInFunctionParameterTypeHint.php
2 +<?php
3 +namespace foo\bar;
4 +
5 +function testParserHandlesNamespaceKeywordInFunctionParameterTypeHint(namespace\Baz $x)
6 +{
7 +
8 +}
1009 1010 /CHANGELOG
2 2 PHP_Depend 0.9.8
3 3 ----------------
4 4
5 +- Implemented #93: Implement an assignment expression, Implemented in svn
6 + revision #992.
5 7 - Fixed #94: Parser throws exception for closures that return by reference,
6 8 fixed in svn revision #962.
7 9 - Fixed #98: Functions with an invalid signature result in an inconsistent
8 10 object graph, fixed in svn revision #986.
11 +- Fixed #103: The parser does not handle all strings as parameter default value
12 + correct, fixed in svn revision #1009.
9 13
10 14 PHP_Depend 0.9.7
11 15 ----------------
1009 1010 /PHP/Depend/Parser.php
2605 2605
2606 2606 case self::T_STRING:
2607 2607 case self::T_BACKSLASH:
2608 + case self::T_NAMESPACE:
2608 2609 $parameter = $this->_parseFormalParameterAndTypeHint();
2609 2610 break;
2610 2611