This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * phpDocumentor |
||
4 | * |
||
5 | * PHP Version 5.3 |
||
6 | * |
||
7 | * @author Mike van Riel <[email protected]> |
||
8 | * @author Sven Hagemann <[email protected]> |
||
9 | * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
||
10 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
||
11 | * @link http://phpdoc.org |
||
12 | */ |
||
13 | |||
14 | namespace phpDocumentor\Descriptor\Builder\Reflector; |
||
15 | |||
16 | use Mockery as m; |
||
17 | use phpDocumentor\Reflection\DocBlock; |
||
18 | use phpDocumentor\Reflection\Fqsen; |
||
19 | use phpDocumentor\Reflection\Php\Class_; |
||
20 | use phpDocumentor\Reflection\Php\Constant; |
||
21 | use phpDocumentor\Reflection\Php\Method; |
||
22 | use phpDocumentor\Reflection\Php\Property; |
||
23 | |||
24 | /** |
||
25 | * Test class for \phpDocumentor\Descriptor\Builder |
||
26 | * |
||
27 | * @covers \phpDocumentor\Descriptor\Builder\Reflector\ClassAssembler |
||
28 | */ |
||
29 | class ClassAssemblerTest extends \Mockery\Adapter\Phpunit\MockeryTestCase |
||
30 | { |
||
31 | /** @var ClassAssembler $fixture */ |
||
32 | protected $fixture; |
||
33 | |||
34 | /** |
||
35 | * Creates a new fixture to test with. |
||
36 | */ |
||
37 | protected function setUp() |
||
38 | { |
||
39 | $this->fixture = new ClassAssembler(); |
||
40 | $this->fixture->setBuilder($this->getProjectDescriptorBuilderMock()); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Creates a Descriptor from a provided class. |
||
45 | * |
||
46 | * @covers \phpDocumentor\Descriptor\Builder\Reflector\ClassAssembler::create |
||
47 | */ |
||
48 | public function testCreateClassDescriptorFromReflector() |
||
49 | { |
||
50 | $name = 'ClassName'; |
||
51 | $namespace = 'Namespace'; |
||
52 | $docBlockDescriptionContent = <<<DOCBLOCK |
||
53 | /** |
||
54 | * This is a example description |
||
55 | */ |
||
56 | DOCBLOCK; |
||
57 | |||
58 | $classReflectorMock = $this->getClassReflectorDescriptor(); |
||
59 | |||
60 | $descriptor = $this->fixture->create($classReflectorMock); |
||
61 | |||
62 | $this->assertSame( |
||
63 | '\\' . $namespace . '\\' . $name, |
||
64 | (string) $descriptor->getFullyQualifiedStructuralElementName() |
||
65 | ); |
||
66 | $this->assertSame($name, $descriptor->getName()); |
||
67 | $this->assertSame((string) $descriptor->getDescription(), $docBlockDescriptionContent); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Create a ClassReflector mock |
||
72 | * |
||
73 | * @return Class_ |
||
74 | */ |
||
75 | protected function getClassReflectorDescriptor() |
||
76 | { |
||
77 | $name = 'ClassName'; |
||
78 | $namespace = 'Namespace'; |
||
79 | $docBlockDescriptionContent = <<<DOCBLOCK |
||
80 | /** |
||
81 | * This is a example description |
||
82 | */ |
||
83 | DOCBLOCK; |
||
84 | $docBlockMock = new DocBlock( |
||
85 | 'This is a example description', |
||
86 | new DocBlock\Description($docBlockDescriptionContent), |
||
87 | [] |
||
88 | ); |
||
89 | |||
90 | $classFqsen = new Fqsen('\\' . $namespace . '\\' . $name); |
||
91 | $classReflectorMock = new Class_( |
||
92 | $classFqsen, |
||
93 | $docBlockMock |
||
94 | ); |
||
95 | |||
96 | $classReflectorMock->addConstant(new Constant(new Fqsen($classFqsen . '::Constant'))); |
||
97 | $classReflectorMock->addInterface(new Fqsen('\\TestInterface')); |
||
98 | $classReflectorMock->addProperty(new Property(new Fqsen($classFqsen . '::$property'))); |
||
99 | $classReflectorMock->addMethod(new Method(new Fqsen($classFqsen . '::method()'))); |
||
100 | |||
101 | return $classReflectorMock; |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * Create a descriptor builder mock |
||
106 | * |
||
107 | * @return m\MockInterface |
||
108 | */ |
||
109 | protected function getProjectDescriptorBuilderMock() |
||
110 | { |
||
111 | $projectDescriptorBuilderMock = m::mock('phpDocumentor\Descriptor\ProjectDescriptorBuilder'); |
||
112 | $projectDescriptorBuilderMock->shouldReceive('getDefaultPackage')->andReturn('\\'); |
||
0 ignored issues
–
show
|
|||
113 | $projectDescriptorBuilderMock->shouldReceive('buildDescriptor')->andReturnUsing(function ($param) { |
||
114 | $mock = null; |
||
115 | |||
116 | switch ($param) { |
||
117 | case 'Properties': |
||
118 | $mock = m::mock('phpDocumentor\Descriptor\PropertiesDescriptor'); |
||
119 | $mock->shouldReceive('getName')->once()->andReturn('Mock'); |
||
120 | $mock->shouldReceive('setParent')->once()->andReturn(); |
||
121 | break; |
||
122 | |||
123 | case 'Method': |
||
124 | $mock = m::mock('phpDocumentor\Descriptor\MethodDescriptor'); |
||
125 | $mock->shouldReceive('getName')->once()->andReturn('Mock'); |
||
126 | $mock->shouldReceive('setParent')->once()->andReturn(); |
||
127 | break; |
||
128 | |||
129 | case 'Constant': |
||
130 | $mock = m::mock('phpDocumentor\Descriptor\ConstantDescriptor'); |
||
131 | $mock->shouldReceive('getName')->once()->andReturn('Mock'); |
||
132 | $mock->shouldReceive('setParent')->once()->andReturn(); |
||
133 | break; |
||
134 | } |
||
135 | |||
136 | return $mock; |
||
137 | }); |
||
138 | |||
139 | return $projectDescriptorBuilderMock; |
||
140 | } |
||
141 | } |
||
142 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: