Skip to content

Commit 08e7dc3

Browse files
committed
Import PhpParser classes
1 parent eb803eb commit 08e7dc3

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

src/collector/backend/parser/UnitCollectingVisitor.php

+30-18
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@
3636
*/
3737
namespace TheSeer\phpDox\Collector\Backend {
3838

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_;
3951
use TheSeer\phpDox\Collector\AbstractUnitObject;
4052
use TheSeer\phpDox\Collector\AbstractVariableObject;
4153
use TheSeer\phpDox\Collector\InlineComment;
@@ -271,7 +283,7 @@ private function processMethodReturnType(MethodObject $method, $returnType) {
271283
return;
272284
}
273285

274-
if ($returnType instanceof \PhpParser\Node\NullableType) {
286+
if ($returnType instanceof NullableType) {
275287
if ((string)$returnType->type === 'self') {
276288
$returnTypeObject = $method->setReturnType($this->unit->getName());
277289
} else {
@@ -366,7 +378,7 @@ private function processProperty(NodeType\Property $node) {
366378
}
367379

368380
private function setVariableType(AbstractVariableObject $variable, $type = NULL) {
369-
if ($type instanceof \PhpParser\Node\NullableType) {
381+
if ($type instanceof NullableType) {
370382
$variable->setNullable(true);
371383
$type = $type->type;
372384
}
@@ -395,46 +407,46 @@ private function setVariableType(AbstractVariableObject $variable, $type = NULL)
395407
$variable->setType($type);
396408
}
397409

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_) {
400412
return array(
401413
'type' => 'string',
402414
'value' => $expr->getAttribute('originalValue')
403415
);
404416
}
405417

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) {
409421
return array(
410422
'type' => 'integer',
411423
'value' => $expr->getAttribute('originalValue')
412424
);
413425
}
414426

415-
if ($expr instanceof \PhpParser\Node\Scalar\DNumber) {
427+
if ($expr instanceof DNumber) {
416428
return array(
417429
'type' => 'float',
418430
'value' => $expr->getAttribute('originalValue')
419431
);
420432
}
421433

422-
if ($expr instanceof \PhpParser\Node\Expr\Array_) {
434+
if ($expr instanceof Array_) {
423435
return array(
424436
'type' => 'array',
425437
'value' => '' // @todo add array2xml?
426438
);
427439
}
428440

429-
if ($expr instanceof \PhpParser\Node\Expr\ClassConstFetch) {
441+
if ($expr instanceof ClassConstFetch) {
430442
return array(
431443
'type' => '{unknown}',
432444
'value' => '',
433445
'constant' => implode('\\', $expr->class->parts) . '::' . $expr->name
434446
);
435447
}
436448

437-
if ($expr instanceof \PhpParser\Node\Expr\ConstFetch) {
449+
if ($expr instanceof ConstFetch) {
438450
$reference = implode('\\', $expr->name->parts);
439451
if (strtolower($reference) === 'null') {
440452
return array(
@@ -454,15 +466,15 @@ private function resolveExpressionValue(\PhpParser\Node\Expr $expr) {
454466
);
455467
}
456468

457-
if ($expr instanceof \PhpParser\Node\Scalar\MagicConst\Line) {
469+
if ($expr instanceof MagicConst\Line) {
458470
return array(
459471
'type' => 'integer',
460472
'value' => '',
461473
'constant' => $expr->getName()
462474
);
463475
}
464476

465-
if ($expr instanceof \PhpParser\Node\Scalar\MagicConst) {
477+
if ($expr instanceof MagicConst) {
466478
return array(
467479
'type' => 'string',
468480
'value' => '',
@@ -478,11 +490,12 @@ private function resolveExpressionValue(\PhpParser\Node\Expr $expr) {
478490
}
479491

480492
/**
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
484497
*/
485-
private function setVariableDefaultValue(AbstractVariableObject $variable, \PhpParser\Node\Expr $default = NULL) {
498+
private function setVariableDefaultValue(AbstractVariableObject $variable, Expr $default = NULL) {
486499
if ($default === NULL) {
487500
return;
488501
}
@@ -498,6 +511,5 @@ private function setVariableDefaultValue(AbstractVariableObject $variable, \PhpP
498511
$variable->setConstant($resolved['constant']);
499512
}
500513
}
501-
502514
}
503515
}

0 commit comments

Comments
 (0)