Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 90705e8

Browse files
committed
Focus on GeneratorAstGenerator
1 parent d258187 commit 90705e8

19 files changed

+207
-452
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Ast;
13+
14+
use PhpParser\PrettyPrinterAbstract;
15+
use PhpParser\PrettyPrinter\Standard;
16+
use PhpParser\Node\Expr;
17+
use PhpParser\Node\Name;
18+
use PhpParser\Node\Scalar;
19+
use PhpParser\ParserFactory;
20+
21+
final class AstPrinter
22+
{
23+
private $printer;
24+
25+
public function __construct(PrettyPrinterAbstract $printer = null)
26+
{
27+
if (null === $printer) {
28+
$printer = new Standard();
29+
}
30+
31+
$this->printer = $printer;
32+
}
33+
34+
public function print(NodeList $nodeList)
35+
{
36+
return $this->printer->prettyPrintFile($nodeList->getNodes());
37+
}
38+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Ast;
13+
14+
use PhpParser\Node;
15+
use PhpParser\Node\Expr;
16+
use PhpParser\Node\Name;
17+
use PhpParser\Node\Scalar;
18+
use PhpParser\ParserFactory;
19+
use PhpParser\PrettyPrinter\Standard;
20+
21+
final class NodeList
22+
{
23+
private $nodes = array();
24+
25+
/**
26+
* @param Node[] $nodes
27+
*/
28+
public function __construct(array $nodes)
29+
{
30+
foreach ($nodes as $node) {
31+
$this->addNode($node);
32+
}
33+
}
34+
35+
/**
36+
* @return Node[]
37+
*/
38+
public function getNodes()
39+
{
40+
return $this->nodes;
41+
}
42+
43+
public function addNode(Node $node)
44+
{
45+
$this->nodes[] = $node;
46+
}
47+
48+
public function append(NodeList $nodeList) {
49+
foreach ($nodeList->getNodes() as $node) {
50+
$this->addNode($node);
51+
}
52+
}
53+
}

src/Symfony/Component/AstGenerator/Util/AstHelper.php renamed to src/Symfony/Component/Ast/Util/AstHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\AstGenerator\Util;
12+
namespace Symfony\Component\Ast\Util;
1313

1414
use PhpParser\Node;
1515
use PhpParser\Node\Expr;
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "symfony/ast-generator",
2+
"name": "symfony/ast",
33
"type": "library",
4-
"description": "Symfony component to generate AST from and to various others components",
5-
"keywords": ["symfony", "ast", "generator"],
4+
"description": "Symfony AST Component",
5+
"keywords": ["symfony", "ast"],
66
"homepage": "https://symfony.com",
77
"license": "MIT",
88
"authors": [
@@ -17,22 +17,18 @@
1717
],
1818
"require": {
1919
"php": ">=5.5.9",
20-
"nikic/php-parser": "~2.0",
21-
"symfony/property-info": "~2.8|~3.0"
22-
},
23-
"require-dev": {
24-
"symfony/serializer": "~2.8|~3.0"
20+
"nikic/php-parser": "~2.0"
2521
},
2622
"autoload": {
27-
"psr-4": { "Symfony\\Component\\AstGenerator\\": "" },
23+
"psr-4": { "Symfony\\Component\\Ast\\": "" },
2824
"exclude-from-classmap": [
2925
"/Tests/"
3026
]
3127
},
3228
"minimum-stability": "dev",
3329
"extra": {
3430
"branch-alias": {
35-
"dev-master": "3.1-dev"
31+
"dev-master": "3.2-dev"
3632
}
3733
}
3834
}

src/Symfony/Component/AstGenerator/AstGeneratorChain.php

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/Symfony/Component/AstGenerator/AstGeneratorInterface.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/Symfony/Component/AstGenerator/Exception/MissingContextException.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/Symfony/Component/AstGenerator/Tests/AstGeneratorChainTest.php

Lines changed: 0 additions & 88 deletions
This file was deleted.

src/Symfony/Component/AstGenerator/Tests/UniqueVariableScopeTest.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)