Skip to content

Commit d65fca7

Browse files
authored
Move classes under the PHP-Parser namespace (#184)
- Move the classes related to PHP-Parser under `Humbug\Scoper\PhpParser` - Mark those classes as `@private`: they are not part of the public API - Add code coverage validation
1 parent 62af2e2 commit d65fca7

21 files changed

+1838
-73
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
/fixtures/set004/scoper.inc.php
88
/fixtures/*/vendor
99
/vendor/
10-
/vendor-bin/box/vendor/
10+
/vendor-bin/*/vendor/
11+
/vendor-bin/*/bin/
1112
/.travis/
1213
!/.travis/.gitkeep
1314
!/.travis/secrets.tar.enc

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
BLACKFIRE=blackfire
12
BOX=vendor-bin/box/vendor/bin/box
2-
PHPUNIT=vendor/bin/phpunit
3+
COVERS_VALIDATOR=php -d zend.enable_gc=0 vendor-bin/covers-validator/bin/covers-validator
34
PHPSCOPER=bin/php-scoper.phar
4-
BLACKFIRE=blackfire
5+
PHPUNIT=vendor/bin/phpunit
56

67

78
.DEFAULT_GOAL := help
@@ -54,7 +55,8 @@ tu: vendor/bin/phpunit
5455
php -d zend.enable_gc=0 $(PHPUNIT)
5556

5657
tc: ## Run PHPUnit tests with test coverage
57-
tc: vendor/bin/phpunit
58+
tc: vendor/bin/phpunit vendor-bin/covers-validator/vendor
59+
$(COVERS_VALIDATOR)
5860
phpdbg -qrr -d zend.enable_gc=0 $(PHPUNIT) --coverage-html=dist/coverage --coverage-text
5961

6062
tm: ## Run Infection (Mutation Testing)
@@ -193,6 +195,9 @@ vendor/bin/phpunit: composer.lock
193195
vendor-bin/box/vendor: vendor-bin/box/composer.lock vendor/bamarni
194196
composer bin all install
195197

198+
vendor-bin/covers-validator/vendor: vendor-bin/covers-validator/composer.lock vendor/bamarni
199+
composer bin covers-validator install
200+
196201
fixtures/set005/vendor: fixtures/set005/composer.lock
197202
composer --working-dir=fixtures/set005 install
198203

@@ -223,6 +228,9 @@ composer.lock: composer.json
223228
vendor-bin/box/composer.lock: composer.lock
224229
@echo composer.lock is not up to date.
225230

231+
vendor-bin/covers-validator/composer.lock: vendor-bin/covers-validator/composer.json
232+
@echo covers-validator composer.lock is not up to date
233+
226234
fixtures/set005/composer.lock: fixtures/set005/composer.json
227235
@echo fixtures/set005/composer.lock is not up to date.
228236

src/NodeTraverser.php renamed to src/PhpParser/NodeTraverser.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
* file that was distributed with this source code.
1313
*/
1414

15-
namespace Humbug\PhpScoper;
15+
namespace Humbug\PhpScoper\PhpParser;
1616

17-
// TODO: re-organise the classes location as this no longer makes sense. Not done here to try to keep the diff humanly
18-
// readable.
1917
use PhpParser\Node;
2018
use PhpParser\Node\Name;
2119
use PhpParser\Node\Stmt\Declare_;
@@ -26,6 +24,9 @@
2624
use PhpParser\Node\Stmt\UseUse;
2725
use PhpParser\NodeTraverser as PhpParserNodeTraverser;
2826

27+
/**
28+
* @private
29+
*/
2930
final class NodeTraverser extends PhpParserNodeTraverser
3031
{
3132
private $prefix;

src/NodeVisitor/AppendParentNode.php renamed to src/PhpParser/NodeVisitor/AppendParentNode.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* file that was distributed with this source code.
1313
*/
1414

15-
namespace Humbug\PhpScoper\NodeVisitor;
15+
namespace Humbug\PhpScoper\PhpParser\NodeVisitor;
1616

1717
use PhpParser\Node;
1818
use PhpParser\NodeVisitorAbstract;
@@ -21,6 +21,8 @@
2121
* Appends the parent node as an attribute to each node. This allows to have more context in the other visitors when
2222
* inspecting a node.
2323
* TODO: rename to ParentNodeAppender.
24+
*
25+
* @private
2426
*/
2527
final class AppendParentNode extends NodeVisitorAbstract
2628
{

src/NodeVisitor/Collection/NamespaceStmtCollection.php renamed to src/PhpParser/NodeVisitor/Collection/NamespaceStmtCollection.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
* file that was distributed with this source code.
1313
*/
1414

15-
namespace Humbug\PhpScoper\NodeVisitor\Collection;
15+
namespace Humbug\PhpScoper\PhpParser\NodeVisitor\Collection;
1616

1717
use ArrayIterator;
1818
use Countable;
19-
use Humbug\PhpScoper\NodeVisitor\AppendParentNode;
19+
use Humbug\PhpScoper\PhpParser\NodeVisitor\AppendParentNode;
2020
use IteratorAggregate;
2121
use PhpParser\Node;
2222
use PhpParser\Node\Name;
@@ -25,6 +25,8 @@
2525
/**
2626
* Utility class collecting all the namespaces for the scoped files allowing to easily find the namespace to which
2727
* belongs a node.
28+
*
29+
* @private
2830
*/
2931
final class NamespaceStmtCollection implements IteratorAggregate, Countable
3032
{

src/NodeVisitor/Collection/UseStmtCollection.php renamed to src/PhpParser/NodeVisitor/Collection/UseStmtCollection.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
* file that was distributed with this source code.
1313
*/
1414

15-
namespace Humbug\PhpScoper\NodeVisitor\Collection;
15+
namespace Humbug\PhpScoper\PhpParser\NodeVisitor\Collection;
1616

1717
use ArrayIterator;
18-
use Humbug\PhpScoper\NodeVisitor\AppendParentNode;
18+
use Humbug\PhpScoper\PhpParser\NodeVisitor\AppendParentNode;
1919
use IteratorAggregate;
2020
use PhpParser\Node\Expr\ConstFetch;
2121
use PhpParser\Node\Expr\FuncCall;
@@ -27,6 +27,8 @@
2727
/**
2828
* Utility class collecting all the use statements for the scoped files allowing to easily find the use which a node
2929
* may use.
30+
*
31+
* @private
3032
*/
3133
final class UseStmtCollection implements IteratorAggregate
3234
{

src/NodeVisitor/NameStmtPrefixer.php renamed to src/PhpParser/NodeVisitor/NameStmtPrefixer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
* file that was distributed with this source code.
1313
*/
1414

15-
namespace Humbug\PhpScoper\NodeVisitor;
15+
namespace Humbug\PhpScoper\PhpParser\NodeVisitor;
1616

17-
use Humbug\PhpScoper\NodeVisitor\Resolver\FullyQualifiedNameResolver;
17+
use Humbug\PhpScoper\PhpParser\NodeVisitor\Resolver\FullyQualifiedNameResolver;
1818
use Humbug\PhpScoper\Reflector;
1919
use PhpParser\Node;
2020
use PhpParser\Node\Expr\ClassConstFetch;

src/NodeVisitor/NamespaceStmtPrefixer.php renamed to src/PhpParser/NodeVisitor/NamespaceStmtPrefixer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
* file that was distributed with this source code.
1313
*/
1414

15-
namespace Humbug\PhpScoper\NodeVisitor;
15+
namespace Humbug\PhpScoper\PhpParser\NodeVisitor;
1616

17-
use Humbug\PhpScoper\NodeVisitor\Collection\NamespaceStmtCollection;
17+
use Humbug\PhpScoper\PhpParser\NodeVisitor\Collection\NamespaceStmtCollection;
1818
use PhpParser\Node;
1919
use PhpParser\Node\Name;
2020
use PhpParser\Node\Stmt\Class_;
@@ -35,6 +35,8 @@
3535
* ```
3636
* namespace Humbug\Foo;
3737
* ```
38+
*
39+
* @private
3840
*/
3941
final class NamespaceStmtPrefixer extends NodeVisitorAbstract
4042
{

src/NodeVisitor/Resolver/FullyQualifiedNameResolver.php renamed to src/PhpParser/NodeVisitor/Resolver/FullyQualifiedNameResolver.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
* file that was distributed with this source code.
1313
*/
1414

15-
namespace Humbug\PhpScoper\NodeVisitor\Resolver;
15+
namespace Humbug\PhpScoper\PhpParser\NodeVisitor\Resolver;
1616

17-
use Humbug\PhpScoper\NodeVisitor\AppendParentNode;
18-
use Humbug\PhpScoper\NodeVisitor\Collection\NamespaceStmtCollection;
19-
use Humbug\PhpScoper\NodeVisitor\Collection\UseStmtCollection;
20-
use Humbug\PhpScoper\NodeVisitor\NameStmtPrefixer;
17+
use Humbug\PhpScoper\PhpParser\NodeVisitor\AppendParentNode;
18+
use Humbug\PhpScoper\PhpParser\NodeVisitor\Collection\NamespaceStmtCollection;
19+
use Humbug\PhpScoper\PhpParser\NodeVisitor\Collection\UseStmtCollection;
20+
use Humbug\PhpScoper\PhpParser\NodeVisitor\NameStmtPrefixer;
2121
use PhpParser\Node\Expr\ConstFetch;
2222
use PhpParser\Node\Expr\FuncCall;
2323
use PhpParser\Node\Name;
@@ -27,6 +27,8 @@
2727
/**
2828
* Attempts to resolve the node name into a fully qualified node. Returns a valid (non fully-qualified) name node on
2929
* failure.
30+
*
31+
* @private
3032
*/
3133
final class FullyQualifiedNameResolver
3234
{

src/NodeVisitor/Resolver/ResolvedValue.php renamed to src/PhpParser/NodeVisitor/Resolver/ResolvedValue.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
* file that was distributed with this source code.
1313
*/
1414

15-
namespace Humbug\PhpScoper\NodeVisitor\Resolver;
15+
namespace Humbug\PhpScoper\PhpParser\NodeVisitor\Resolver;
1616

1717
use PhpParser\Node\Name;
1818

19+
/**
20+
* @private
21+
*/
1922
final class ResolvedValue
2023
{
2124
private $name;

0 commit comments

Comments
 (0)