Skip to content

Commit e13a8d8

Browse files
committed
Merge pull request #93 from jaapio/phpParserUpgrade
Php parser upgrade
2 parents fc40c3f + f5c460e commit e13a8d8

24 files changed

+211
-208
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"require": {
1313
"php": ">=5.3.3",
1414
"psr/log": "~1.0",
15-
"nikic/php-parser": "~0.9.4",
15+
"nikic/php-parser": "^1.0",
1616
"phpdocumentor/reflection-docblock": "~2.0"
1717
},
1818
"suggests": {

composer.lock

Lines changed: 24 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/phpDocumentor/Reflection/BaseReflector.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
use phpDocumentor\Reflection\DocBlock\Context;
2020
use phpDocumentor\Reflection\DocBlock\Location;
2121
use phpDocumentor\Reflection\Event\PostDocBlockExtractionEvent;
22+
use PhpParser\NodeAbstract;
2223
use Psr\Log\LogLevel;
23-
use PHPParser_Node_Expr;
24-
use PHPParser_Node_Stmt;
25-
use PHPParser_NodeAbstract;
26-
use PHPParser_PrettyPrinterAbstract;
24+
use PhpParser\Node\Expr;
25+
use PhpParser\Node\Stmt;
26+
use PhpParser\PrettyPrinterAbstract;
2727

2828
/**
2929
* Basic reflection providing support for events and basic properties as a
@@ -35,7 +35,7 @@
3535
*/
3636
abstract class BaseReflector extends ReflectionAbstract
3737
{
38-
/** @var PHPParser_Node_Stmt */
38+
/** @var \PhpParser\Node\Stmt */
3939
protected $node;
4040

4141
/**
@@ -51,20 +51,20 @@ abstract class BaseReflector extends ReflectionAbstract
5151
/**
5252
* PHP AST pretty printer used to get representations of values.
5353
*
54-
* @var PHPParser_PrettyPrinterAbstract
54+
* @var \PhpParser\PrettyPrinterAbstract
5555
*/
5656
protected static $prettyPrinter = null;
5757

5858
/**
5959
* Initializes this reflector with the correct node as produced by
6060
* PHP-Parser.
6161
*
62-
* @param PHPParser_NodeAbstract $node
62+
* @param NodeAbstract $node
6363
* @param Context $context
6464
*
6565
* @link http://github.com/nikic/PHP-Parser
6666
*/
67-
public function __construct(PHPParser_NodeAbstract $node, Context $context)
67+
public function __construct(NodeAbstract $node, Context $context)
6868
{
6969
$this->node = $node;
7070
$context->setLSEN($this->getLSEN());
@@ -74,7 +74,7 @@ public function __construct(PHPParser_NodeAbstract $node, Context $context)
7474
/**
7575
* Returns the current PHP-Parser node that holds more detailed information
7676
* about the reflected object. e.g. position in the file and further attributes.
77-
* @return PHPParser_Node_Stmt|PHPParser_NodeAbstract
77+
* @return \PhpParser\Node\Stmt|\PhpParser\NodeAbstract
7878
*/
7979
public function getNode()
8080
{
@@ -198,7 +198,7 @@ public function getLSEN()
198198
*/
199199
public function getNamespace()
200200
{
201-
if (!$this->node->namespacedName) {
201+
if (!isset($this->node->namespacedName)) {
202202
return $this->context->getNamespace();
203203
}
204204

@@ -291,13 +291,13 @@ public function getDefaultPackageName()
291291
/**
292292
* Returns a simple human readable output for a value.
293293
*
294-
* @param PHPParser_Node_Expr $value The value node as provided by
294+
* @param \PhpParser\Node\Expr $value The value node as provided by
295295
* PHP-Parser.
296296
*
297297
* @return string
298298
*/
299299
protected function getRepresentationOfValue(
300-
PHPParser_Node_Expr $value = null
300+
\PhpParser\Node\Expr $value = null
301301
) {
302302
if (null === $value) {
303303
return '';

src/phpDocumentor/Reflection/ClassReflector.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
namespace phpDocumentor\Reflection;
1414

15-
use PHPParser_Node_Name;
16-
use PHPParser_Node_Stmt_Class;
17-
use PHPParser_Node_Stmt_TraitUse;
15+
use PhpParser\Node\Name;
16+
use PhpParser\Node\Stmt\Class_;
17+
use PhpParser\Node\Stmt\TraitUse;
1818

1919
/**
2020
* Provides static reflection for a class.
@@ -25,17 +25,17 @@
2525
*/
2626
class ClassReflector extends InterfaceReflector
2727
{
28-
/** @var \PHPParser_Node_Stmt_Class */
28+
/** @var Class_ */
2929
protected $node;
3030

3131
/** @var string[] */
3232
protected $traits = array();
3333

3434
public function parseSubElements()
3535
{
36-
/** @var \PHPParser_Node_Stmt_TraitUse $stmt */
36+
/** @var TraitUse $stmt */
3737
foreach ($this->node->stmts as $stmt) {
38-
if ($stmt instanceof \PHPParser_Node_Stmt_TraitUse) {
38+
if ($stmt instanceof TraitUse) {
3939
foreach ($stmt->traits as $trait) {
4040
$this->traits[] = '\\' . (string) $trait;
4141
}
@@ -52,7 +52,7 @@ public function parseSubElements()
5252
*/
5353
public function isAbstract()
5454
{
55-
return (bool) ($this->node->type & PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT);
55+
return (bool) ($this->node->type & Class_::MODIFIER_ABSTRACT);
5656
}
5757

5858
/**
@@ -62,7 +62,7 @@ public function isAbstract()
6262
*/
6363
public function isFinal()
6464
{
65-
return (bool) ($this->node->type & PHPParser_Node_Stmt_Class::MODIFIER_FINAL);
65+
return (bool) ($this->node->type & Class_::MODIFIER_FINAL);
6666
}
6767

6868
/**
@@ -77,7 +77,7 @@ public function getTraits()
7777

7878
public function getParentClass()
7979
{
80-
return $this->node->extends ? '\\'.(string) $this->node->extends : '';
80+
return isset($this->node->extends) ? '\\'.(string) $this->node->extends : '';
8181
}
8282

8383
/**
@@ -88,8 +88,8 @@ public function getParentClass()
8888
public function getInterfaces()
8989
{
9090
$names = array();
91-
if ($this->node->implements) {
92-
/** @var PHPParser_Node_Name */
91+
if (isset($this->node->implements)) {
92+
/** @var Name */
9393
foreach ($this->node->implements as $node) {
9494
$names[] = '\\'.(string) $node;
9595
}

src/phpDocumentor/Reflection/ClassReflector/ConstantReflector.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@
1515
use phpDocumentor\Reflection\BaseReflector;
1616
use phpDocumentor\Reflection\ConstantReflector as BaseConstantReflector;
1717
use phpDocumentor\Reflection\DocBlock\Context;
18-
use PHPParser_Node_Const;
19-
use PHPParser_Node_Stmt_ClassConst;
18+
use PhpParser\Node\Stmt\ClassConst;
19+
use PhpParser\Node\Const_;
2020

2121
class ConstantReflector extends BaseConstantReflector
2222
{
23-
/** @var PHPParser_Node_Stmt_ClassConst */
23+
/** @var ClassConst */
2424
protected $constant;
2525

2626
/**
2727
* Registers the Constant Statement and Node with this reflector.
2828
*
29-
* @param PHPParser_Node_Stmt_Const $stmt
30-
* @param Context $context
31-
* @param PHPParser_Node_Const $node
29+
* @param ClassConst $stmt
30+
* @param Context $context
31+
* @param Const_ $node
3232
*/
3333
public function __construct(
34-
PHPParser_Node_Stmt_ClassConst $stmt,
34+
ClassConst $stmt,
3535
Context $context,
36-
PHPParser_Node_Const $node
36+
Const_ $node
3737
) {
3838
BaseReflector::__construct($node, $context);
3939
$this->constant = $stmt;

src/phpDocumentor/Reflection/ClassReflector/MethodReflector.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
namespace phpDocumentor\Reflection\ClassReflector;
1414

1515
use phpDocumentor\Reflection\FunctionReflector;
16-
use PHPParser_Node_Stmt_Class;
17-
use PHPParser_Node_Stmt_ClassMethod;
16+
use PhpParser\Node\Stmt\Class_;
1817

1918
class MethodReflector extends FunctionReflector
2019
{
21-
/** @var PHPParser_Node_Stmt_ClassMethod */
20+
/** @var \PhpParser\Node\Stmt\ClassMethod */
2221
protected $node;
2322

2423
/**
@@ -37,10 +36,10 @@ class MethodReflector extends FunctionReflector
3736
*/
3837
public function getVisibility()
3938
{
40-
if ($this->node->type & PHPParser_Node_Stmt_Class::MODIFIER_PROTECTED) {
39+
if ($this->node->type & Class_::MODIFIER_PROTECTED) {
4140
return 'protected';
4241
}
43-
if ($this->node->type & PHPParser_Node_Stmt_Class::MODIFIER_PRIVATE) {
42+
if ($this->node->type & Class_::MODIFIER_PRIVATE) {
4443
return 'private';
4544
}
4645

@@ -54,7 +53,7 @@ public function getVisibility()
5453
*/
5554
public function isAbstract()
5655
{
57-
return (bool) ($this->node->type & PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT);
56+
return (bool) ($this->node->type & Class_::MODIFIER_ABSTRACT);
5857
}
5958

6059
/**
@@ -64,7 +63,7 @@ public function isAbstract()
6463
*/
6564
public function isStatic()
6665
{
67-
return (bool) ($this->node->type & PHPParser_Node_Stmt_Class::MODIFIER_STATIC);
66+
return (bool) ($this->node->type & Class_::MODIFIER_STATIC);
6867
}
6968

7069
/**
@@ -74,6 +73,6 @@ public function isStatic()
7473
*/
7574
public function isFinal()
7675
{
77-
return (bool) ($this->node->type & PHPParser_Node_Stmt_Class::MODIFIER_FINAL);
76+
return (bool) ($this->node->type & Class_::MODIFIER_FINAL);
7877
}
7978
}

0 commit comments

Comments
 (0)