1
- <?php declare (strict_types=1 );
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
2
5
/**
3
6
* This file is part of phpDocumentor.
4
7
*
5
8
* For the full copyright and license information, please view the LICENSE
6
9
* file that was distributed with this source code.
7
10
*
8
- * @copyright 2010-2018 Mike van Riel<[email protected] >
9
- * @license http://www.opensource.org/licenses/mit-license.php MIT
10
11
* @link http://phpdoc.org
11
12
*/
12
13
13
14
namespace phpDocumentor \Reflection ;
14
15
16
+ use InvalidArgumentException ;
15
17
use phpDocumentor \Reflection \Types \Context ;
18
+ use function explode ;
19
+ use function implode ;
20
+ use function strpos ;
16
21
17
22
class FqsenResolver
18
23
{
19
24
/** @var string Definition of the NAMESPACE operator in PHP */
20
25
private const OPERATOR_NAMESPACE = '\\' ;
21
26
22
- public function resolve (string $ fqsen , Context $ context = null ): Fqsen
27
+ public function resolve (string $ fqsen , ? Context $ context = null ) : Fqsen
23
28
{
24
29
if ($ context === null ) {
25
30
$ context = new Context ('' );
@@ -34,12 +39,8 @@ public function resolve(string $fqsen, Context $context = null): Fqsen
34
39
35
40
/**
36
41
* Tests whether the given type is a Fully Qualified Structural Element Name.
37
- *
38
- * @param string $type
39
- *
40
- * @return bool
41
42
*/
42
- private function isFqsen (string $ type ): bool
43
+ private function isFqsen (string $ type ) : bool
43
44
{
44
45
return strpos ($ type , self ::OPERATOR_NAMESPACE ) === 0 ;
45
46
}
@@ -48,11 +49,9 @@ private function isFqsen(string $type): bool
48
49
* Resolves a partial Structural Element Name (i.e. `Reflection\DocBlock`) to its FQSEN representation
49
50
* (i.e. `\phpDocumentor\Reflection\DocBlock`) based on the Namespace and aliases mentioned in the Context.
50
51
*
51
- * @param string $type
52
- * @return Fqsen
53
- * @throws \InvalidArgumentException when type is not a valid FQSEN.
52
+ * @throws InvalidArgumentException When type is not a valid FQSEN.
54
53
*/
55
- private function resolvePartialStructuralElementName (string $ type , Context $ context ): Fqsen
54
+ private function resolvePartialStructuralElementName (string $ type , Context $ context ) : Fqsen
56
55
{
57
56
$ typeParts = explode (self ::OPERATOR_NAMESPACE , $ type , 2 );
58
57
@@ -61,7 +60,7 @@ private function resolvePartialStructuralElementName(string $type, Context $cont
61
60
// if the first segment is not an alias; prepend namespace name and return
62
61
if (!isset ($ namespaceAliases [$ typeParts [0 ]])) {
63
62
$ namespace = $ context ->getNamespace ();
64
- if ('' !== $ namespace ) {
63
+ if ($ namespace !== '' ) {
65
64
$ namespace .= self ::OPERATOR_NAMESPACE ;
66
65
}
67
66
0 commit comments