1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of phpDocumentor. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
* |
8
|
|
|
* @copyright 2010-2015 Mike van Riel<[email protected]> |
9
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
10
|
|
|
* @link http://phpdoc.org |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace phpDocumentor\Reflection\Php\Factory; |
14
|
|
|
|
15
|
|
|
use InvalidArgumentException; |
16
|
|
|
use phpDocumentor\Reflection\Fqsen; |
17
|
|
|
use phpDocumentor\Reflection\Php\Factory; |
18
|
|
|
use phpDocumentor\Reflection\Php\Function_ as FunctionDescriptor; |
19
|
|
|
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy; |
20
|
|
|
use phpDocumentor\Reflection\Php\StrategyContainer; |
21
|
|
|
use phpDocumentor\Reflection\Types\Context; |
22
|
|
|
use PhpParser\Comment\Doc; |
23
|
|
|
use PhpParser\Node\Stmt\Function_ as FunctionNode; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Strategy to convert Function_ to FunctionDescriptor |
27
|
|
|
* |
28
|
|
|
* @see FunctionDescriptor |
29
|
|
|
* @see \PhpParser\Node\ |
30
|
|
|
*/ |
31
|
|
|
// @codingStandardsIgnoreStart |
32
|
|
|
final class Function_ extends AbstractFactory implements ProjectFactoryStrategy |
33
|
|
|
// @codingStandardsIgnoreEnd |
34
|
|
|
{ |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Returns true when the strategy is able to handle the object. |
38
|
|
|
* |
39
|
|
|
* @param FunctionNode $object object to check. |
40
|
|
|
* @return boolean |
41
|
|
|
*/ |
42
|
1 |
|
public function matches($object) |
43
|
|
|
{ |
44
|
1 |
|
return $object instanceof FunctionNode; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Creates an FunctionDescriptor out of the given object including its child elements. |
49
|
|
|
* |
50
|
|
|
* @param \PhpParser\Node\Stmt\Function_ $object object to convert to an Element |
51
|
|
|
* @param StrategyContainer $strategies used to convert nested objects. |
52
|
|
|
* @param Context $context of the created object |
53
|
|
|
* @return FunctionDescriptor |
54
|
|
|
*/ |
55
|
3 |
|
protected function doCreate($object, StrategyContainer $strategies, Context $context = null) |
56
|
|
|
{ |
57
|
3 |
|
$docBlock = $this->createDocBlock($strategies, $object->getDocComment(), $context); |
58
|
|
|
|
59
|
3 |
|
$function = new FunctionDescriptor($object->fqsen, $docBlock); |
|
|
|
|
60
|
|
|
|
61
|
3 |
|
foreach ($object->params as $param) { |
62
|
1 |
|
$strategy = $strategies->findMatching($param); |
63
|
1 |
|
$function->addArgument($strategy->create($param, $strategies, $context)); |
|
|
|
|
64
|
3 |
|
} |
65
|
|
|
|
66
|
3 |
|
return $function; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.