|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Extended class name determination test file |
|
4
|
|
|
* |
|
5
|
|
|
* @package PHPCompatibility |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Extended class name determination function tests |
|
11
|
|
|
* |
|
12
|
|
|
* @uses BaseClass_MethodTestFrame |
|
13
|
|
|
* @package PHPCompatibility |
|
14
|
|
|
*/ |
|
15
|
|
|
class BaseClass_GetFQExtendedClassNameTest extends BaseClass_MethodTestFrame |
|
|
|
|
|
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
public $filename = '../sniff-examples/utility-functions/get_fqextended_classname.php'; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* testGetFQExtendedClassName |
|
22
|
|
|
* |
|
23
|
|
|
* @requires PHP 5.3 |
|
24
|
|
|
* |
|
25
|
|
|
* @group utilityFunctions |
|
26
|
|
|
* |
|
27
|
|
|
* @dataProvider dataGetFQExtendedClassName |
|
28
|
|
|
* |
|
29
|
|
|
* @covers PHPCompatibility_Sniff::getFQExtendedClassName |
|
30
|
|
|
* |
|
31
|
|
|
* @param int $stackPtr Stack pointer for a T_CLASS token in the test file. |
|
32
|
|
|
* @param string $expected The expected fully qualified class name. |
|
33
|
|
|
*/ |
|
34
|
|
|
public function testGetFQExtendedClassName($stackPtr, $expected) { |
|
35
|
|
|
$result = $this->helperClass->getFQExtendedClassName($this->_phpcsFile, $stackPtr); |
|
36
|
|
|
$this->assertSame($expected, $result); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* dataGetFQExtendedClassName |
|
41
|
|
|
* |
|
42
|
|
|
* @see testGetFQExtendedClassName() |
|
43
|
|
|
* |
|
44
|
|
|
* @return array |
|
45
|
|
|
*/ |
|
46
|
|
|
public function dataGetFQExtendedClassName() |
|
47
|
|
|
{ |
|
48
|
|
|
return array( |
|
49
|
|
|
array(7, '\MyTesting\DateTime'), |
|
50
|
|
|
array(18, '\DateTime'), |
|
51
|
|
|
array(30, '\MyTesting\anotherNS\DateTime'), |
|
52
|
|
|
array(43, '\FQNS\DateTime'), |
|
53
|
|
|
array(65, '\AnotherTesting\DateTime'), |
|
54
|
|
|
array(77, '\DateTime'), |
|
55
|
|
|
array(90, '\AnotherTesting\anotherNS\DateTime'), |
|
56
|
|
|
array(104, '\FQNS\DateTime'), |
|
57
|
|
|
array(121, '\DateTime'), |
|
58
|
|
|
array(132, '\DateTime'), |
|
59
|
|
|
array(155, '\Yet\More\Testing\DateTime'), |
|
60
|
|
|
array(166, '\Yet\More\Testing\anotherNS\DateTime'), |
|
61
|
|
|
array(179, '\FQNS\DateTime'), |
|
62
|
|
|
); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.