36
36
*/
37
37
namespace TheSeer \phpDox \Collector \Backend {
38
38
39
+ use PhpParser \Node \Expr ;
40
+ use PhpParser \Node \Expr \Array_ ;
41
+ use PhpParser \Node \Expr \BinaryOp ;
42
+ use PhpParser \Node \Expr \ClassConstFetch ;
43
+ use PhpParser \Node \Expr \ConstFetch ;
44
+ use PhpParser \Node \Expr \UnaryMinus ;
45
+ use PhpParser \Node \Expr \UnaryPlus ;
46
+ use PhpParser \Node \NullableType ;
47
+ use PhpParser \Node \Scalar \DNumber ;
48
+ use PhpParser \Node \Scalar \LNumber ;
49
+ use PhpParser \Node \Scalar \MagicConst ;
50
+ use PhpParser \Node \Scalar \String_ ;
39
51
use TheSeer \phpDox \Collector \AbstractUnitObject ;
40
52
use TheSeer \phpDox \Collector \AbstractVariableObject ;
41
53
use TheSeer \phpDox \Collector \InlineComment ;
@@ -271,7 +283,7 @@ private function processMethodReturnType(MethodObject $method, $returnType) {
271
283
return ;
272
284
}
273
285
274
- if ($ returnType instanceof \ PhpParser \ Node \ NullableType) {
286
+ if ($ returnType instanceof NullableType) {
275
287
if ((string )$ returnType ->type === 'self ' ) {
276
288
$ returnTypeObject = $ method ->setReturnType ($ this ->unit ->getName ());
277
289
} else {
@@ -366,7 +378,7 @@ private function processProperty(NodeType\Property $node) {
366
378
}
367
379
368
380
private function setVariableType (AbstractVariableObject $ variable , $ type = NULL ) {
369
- if ($ type instanceof \ PhpParser \ Node \ NullableType) {
381
+ if ($ type instanceof NullableType) {
370
382
$ variable ->setNullable (true );
371
383
$ type = $ type ->type ;
372
384
}
@@ -395,46 +407,46 @@ private function setVariableType(AbstractVariableObject $variable, $type = NULL)
395
407
$ variable ->setType ($ type );
396
408
}
397
409
398
- private function resolveExpressionValue (\ PhpParser \ Node \ Expr $ expr ) {
399
- if ($ expr instanceof \ PhpParser \ Node \ Scalar \ String_) {
410
+ private function resolveExpressionValue (Expr $ expr ) {
411
+ if ($ expr instanceof String_) {
400
412
return array (
401
413
'type ' => 'string ' ,
402
414
'value ' => $ expr ->getAttribute ('originalValue ' )
403
415
);
404
416
}
405
417
406
- if ($ expr instanceof \ PhpParser \ Node \ Scalar \ LNumber ||
407
- $ expr instanceof \ PhpParser \ Node \ Expr \ UnaryMinus ||
408
- $ expr instanceof \ PhpParser \ Node \ Expr \ UnaryPlus) {
418
+ if ($ expr instanceof LNumber ||
419
+ $ expr instanceof UnaryMinus ||
420
+ $ expr instanceof UnaryPlus) {
409
421
return array (
410
422
'type ' => 'integer ' ,
411
423
'value ' => $ expr ->getAttribute ('originalValue ' )
412
424
);
413
425
}
414
426
415
- if ($ expr instanceof \ PhpParser \ Node \ Scalar \ DNumber) {
427
+ if ($ expr instanceof DNumber) {
416
428
return array (
417
429
'type ' => 'float ' ,
418
430
'value ' => $ expr ->getAttribute ('originalValue ' )
419
431
);
420
432
}
421
433
422
- if ($ expr instanceof \ PhpParser \ Node \ Expr \ Array_) {
434
+ if ($ expr instanceof Array_) {
423
435
return array (
424
436
'type ' => 'array ' ,
425
437
'value ' => '' // @todo add array2xml?
426
438
);
427
439
}
428
440
429
- if ($ expr instanceof \ PhpParser \ Node \ Expr \ ClassConstFetch) {
441
+ if ($ expr instanceof ClassConstFetch) {
430
442
return array (
431
443
'type ' => '{unknown} ' ,
432
444
'value ' => '' ,
433
445
'constant ' => implode ('\\' , $ expr ->class ->parts ) . ':: ' . $ expr ->name
434
446
);
435
447
}
436
448
437
- if ($ expr instanceof \ PhpParser \ Node \ Expr \ ConstFetch) {
449
+ if ($ expr instanceof ConstFetch) {
438
450
$ reference = implode ('\\' , $ expr ->name ->parts );
439
451
if (strtolower ($ reference ) === 'null ' ) {
440
452
return array (
@@ -454,15 +466,15 @@ private function resolveExpressionValue(\PhpParser\Node\Expr $expr) {
454
466
);
455
467
}
456
468
457
- if ($ expr instanceof \ PhpParser \ Node \ Scalar \ MagicConst \Line) {
469
+ if ($ expr instanceof MagicConst \Line) {
458
470
return array (
459
471
'type ' => 'integer ' ,
460
472
'value ' => '' ,
461
473
'constant ' => $ expr ->getName ()
462
474
);
463
475
}
464
476
465
- if ($ expr instanceof \ PhpParser \ Node \ Scalar \ MagicConst) {
477
+ if ($ expr instanceof MagicConst) {
466
478
return array (
467
479
'type ' => 'string ' ,
468
480
'value ' => '' ,
@@ -478,11 +490,12 @@ private function resolveExpressionValue(\PhpParser\Node\Expr $expr) {
478
490
}
479
491
480
492
/**
481
- * @param AbstractVariableObject $variable
482
- * @param \PhpParser\Node\Expr $default
483
- * @return string
493
+ * @param AbstractVariableObject $variable
494
+ * @param Expr $default
495
+ *
496
+ * @throws ParseErrorException
484
497
*/
485
- private function setVariableDefaultValue (AbstractVariableObject $ variable , \ PhpParser \ Node \ Expr $ default = NULL ) {
498
+ private function setVariableDefaultValue (AbstractVariableObject $ variable , Expr $ default = NULL ) {
486
499
if ($ default === NULL ) {
487
500
return ;
488
501
}
@@ -498,6 +511,5 @@ private function setVariableDefaultValue(AbstractVariableObject $variable, \PhpP
498
511
$ variable ->setConstant ($ resolved ['constant ' ]);
499
512
}
500
513
}
501
-
502
514
}
503
515
}
0 commit comments