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.4 |
||
6 | * |
||
7 | * @copyright 2010-2014 Mike van Riel / Naenius (http://www.naenius.com) |
||
8 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
||
9 | * @link http://phpdoc.org |
||
10 | */ |
||
11 | |||
12 | namespace phpDocumentor\Application\Renderer\Router\UrlGenerator\Standard; |
||
13 | |||
14 | use phpDocumentor\Descriptor; |
||
15 | use phpDocumentor\DomainModel\Renderer\Router\UrlGenerator\UrlGeneratorInterface; |
||
16 | |||
17 | class ConstantDescriptor implements UrlGeneratorInterface |
||
18 | { |
||
19 | /** @var QualifiedNameToUrlConverter */ |
||
20 | private $converter; |
||
21 | |||
22 | /** |
||
23 | * Initializes this generator. |
||
24 | */ |
||
25 | public function __construct() |
||
26 | { |
||
27 | $this->converter = new QualifiedNameToUrlConverter(); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * Generates a URL from the given node or returns false if unable. |
||
32 | * |
||
33 | * @param string|Descriptor\ConstantDescriptor $node |
||
34 | * |
||
35 | * @return string|false |
||
36 | */ |
||
37 | public function __invoke($node) |
||
38 | { |
||
39 | if (!($node instanceof Descriptor\ConstantDescriptor)) { |
||
0 ignored issues
–
show
|
|||
40 | return false; |
||
41 | } |
||
42 | |||
43 | $prefix = ($node->getParent() instanceof Descriptor\FileDescriptor || ! $node->getParent()) |
||
0 ignored issues
–
show
The class
phpDocumentor\Descriptor\FileDescriptor does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
44 | ? $this->getUrlPathPrefixForGlobalConstants($node) |
||
45 | : $this->getUrlPathPrefixForClassConstants($node); |
||
46 | |||
47 | return $prefix . '.html#constant_' . $node->getName(); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Returns the first part of the URL path that is specific to global constants. |
||
52 | * |
||
53 | * @param Descriptor\ConstantDescriptor $node |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | private function getUrlPathPrefixForGlobalConstants($node) |
||
58 | { |
||
59 | return '/namespaces/' . $this->converter->fromNamespace($node->getNamespace()); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Returns the first part of the URL path that is specific to class constants. |
||
64 | * |
||
65 | * @param Descriptor\ConstantDescriptor $node |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | private function getUrlPathPrefixForClassConstants($node) |
||
70 | { |
||
71 | return '/classes/' . $this->converter->fromClass($node->getParent()->getFullyQualifiedStructuralElementName()); |
||
72 | } |
||
73 | } |
||
74 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.