History log of /PHP-Parser/lib/PhpParser/NodeAbstract.php (Results 1 – 25 of 29)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 09691fc8 13-Mar-2024 Markus Staab

Prevent off-by-one errors in line-number related methods


# 502b0909 16-Aug-2023 Nikita Popov

Add property types

Types omitted in two places where we violate them currently:
Namespace_::$stmts can be null during parsing, and Enum_::$scalarType
can be a complex type for invali

Add property types

Types omitted in two places where we violate them currently:
Namespace_::$stmts can be null during parsing, and Enum_::$scalarType
can be a complex type for invalid programs.

show more ...


# f98341f6 17-Sep-2022 Nikita Popov

Specify more types


# a099803d 11-Sep-2022 Nikita Popov

Use array<string, mixed> type for $attributes

Slightly more accurate, and stops PHPStan from complaining about
the missing array type information.


# 48f470ea 11-Sep-2022 Nikita Popov

Add missing return types


# dd63ddbc 28-Aug-2022 Nikita Popov

Add php-cs-fixer config and reformat

The formatting in this project has become something of a mess,
because it changed over time. Add a CS fixer config and reformat
to the desired st

Add php-cs-fixer config and reformat

The formatting in this project has become something of a mess,
because it changed over time. Add a CS fixer config and reformat
to the desired style, which is PSR-12, but with sane brace placement.

show more ...


# 9c5eb3cc 04-Jun-2022 Nikita Popov

Add some missing type annotations


# 3ec87ef7 15-Feb-2020 Nikita Popov

Don't require doc comment to be last comment

Fixes #652.


Revision tags: v4.3.0, v4.2.5, v4.2.4, v4.2.3, v4.2.2, v4.2.1
# b7e63615 19-Jan-2019 Lars Moelleken

updates via "rectorphp/rector" (#573)

- "global" -> remove unused "use" statements
- "phpunit" -> fix "@covers" comments
- "phpunit" -> replace "->will($this->returnValue()" with "->

updates via "rectorphp/rector" (#573)

- "global" -> remove unused "use" statements
- "phpunit" -> fix "@covers" comments
- "phpunit" -> replace "->will($this->returnValue()" with "->willReturn()"
- "UseTest.php" -> add missing namespace
- "composer.json" -> use "autoload-dev"
- remove -> "require_once" usage in the tests (use autoload-dev via composer.json)

-> most of the changes are done automatically by "https://github.com/rectorphp/rector"

show more ...


Revision tags: v4.2.0, v4.1.1, v4.1.0, v4.0.4, v4.0.3, v4.0.2, v4.0.1, v4.0.0, v3.1.5
# 1c3eabb0 23-Feb-2018 Théo FIDRY

Replace string by class call (#477)

For better PHP-Scoper compatibility


Revision tags: v4.0.0beta1, v3.1.4
# 24995347 10-Jan-2018 Gabriel Caruso

[CS] Whitespace before return type


Revision tags: v4.0.0alpha3, v3.1.3
# 1c11626f 12-Nov-2017 Nikita Popov

Add explicit getType() methods

Rather than automatically deriving getType() from the class name.


# bac91b42 11-Nov-2017 Maks Rafalko

Correctly determine Type of Node when PHP-Parser's namespaces are prefixed

Hi there,

I'm working on mutation testing framework ([Infection](https://github.com/infection/infection/))

Correctly determine Type of Node when PHP-Parser's namespaces are prefixed

Hi there,

I'm working on mutation testing framework ([Infection](https://github.com/infection/infection/)) that is distributed as a PHAR. One of this goal is to run target project's test suite against mutated code. Since we use reflection and load project's autoloader, we want to avoid potential conflicts between vendor files of Infection itself and the target project.

To avoid this issue, there is a project calld [PHP-Scoper](https://github.com/humbug/php-scoper). What it does is it prefixes all the namespaces of the library (including vendor folder) with some character(s), for example namespace `Infection\Mutator\PublicVisibility` is transformed to `ScoperAbc123\Infection\Mutant\PublicVisibility`.

But since it also prefixes vendor folder, PHP-Parser's classes are prefixed as well and `NodeAbstract::getType()` after this prefixing works incorrectly.

There is a hardcoded number `15` which means to remove `'PhpParser\Node'` (length=15) substring from the FQCN.

Code:

```php
// PHPParser\Node\Stmt\Declare_ -> Stmt_Declare

return strtr(substr(rtrim(get_class($this), '_'), 15), '\\', '_');
```

What I suggest is a little be more dynamic solution, to correctly extract class name (type) from the ***prefixed*** FQCL:

`ScoperAbc123\PHPParser\Node\Stmt\Declare_` -> `Stmt_Declare`

show more ...


Revision tags: v4.0.0alpha2, v3.1.2, v4.0.0alpha1
# cc328a4c 29-Sep-2017 Nikita Popov

Add get{Start,End}{Line,TokenPos,FilePos}() methods


# 3d4621bb 29-Sep-2017 Nikita Popov

Don't return by ref from getAttribute()

This is not worth the few times where it might be useful.


# d8f91733 29-Sep-2017 Nikita Popov

Add Node::getComments() method


Revision tags: v3.1.1
# e2e99f26 18-Aug-2017 TomasVotruba

Add strict_types to lib code


# ec535ea1 13-Aug-2017 TomasVotruba

[cs] use PHP 5.4 short array, since PHP 7.0 is min version


Revision tags: v3.1.0, v3.0.6
# 92275bdf 29-Apr-2017 Nikita Popov

Remove Node::setLine() method


# 3da86df4 29-Apr-2017 Nikita Popov

Deprecate Node::setLine()


# a32e3797 28-Apr-2017 Nikita Popov

Generate PHP 7 type annotations


Revision tags: v3.0.5, v3.0.4, v3.0.3
# e3b87f40 24-Jan-2017 Matthew Brown

Add non-void return types


# 4d2a4d02 23-Dec-2016 Nikita Popov

Add first shot at format preserving pretty printer


Revision tags: v3.0.2, v3.0.1, v3.0.0, v3.0.0beta2
# ea47b6e0 17-Sep-2016 Nikita Popov

Add NodeAbstract::setDocComment()


Revision tags: v3.0.0beta1, v2.1.1
# 7dae6c7a 25-Jul-2016 Nikita Popov

Implement JsonSerializable for Nodes and Comments

Exposes the properties and adds an additional nodeType property.


12