You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHP 7.3.13 (cli) (built: Dec 26 2019 22:25:59) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.13, Copyright (c) 1998-2018 Zend Technologies
PHP-Parser version
nikic/php-parser v4.10.2 A PHP parser written in PHP
MISS semicolon
below code can not show correct result
use PhpParser\Error;
use PhpParser\NodeDumper;
use PhpParser\ParserFactory;
use PhpParser\BuilderFactory;
use PhpParser\PrettyPrinter;
use PhpParser\Node;
use PhpParser\Node\Stmt\If_;
$factor = new BuilderFactory;
$node = $factor->namespace('Name\Space')
->addStmt(
$factor->class('SomeClass')
->addStmt($factor->method('check')
->makeProtected()
->addParam($factor->param('orderData'))
->addStmt(
new If_($factor->var('result'), [
'stmts' => array(
new Node\Expr\Print_(new Node\Expr\Variable('someParam'))
)
])
)))
->getNode();
$stmts = array($node);
$prettyPrinter = new PrettyPrinter\Standard();
echo $prettyPrinter->prettyPrintFile($stmts);
output :
<?php
namespace Name\Space;
class SomeClass
{
protected function check($orderData)
{
if ($result) {
print $someParam
}
}
}
NOTICE print $someParam miss semicolon
The text was updated successfully, but these errors were encountered:
BASE INFO
php version
PHP 7.3.13 (cli) (built: Dec 26 2019 22:25:59) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.13, Copyright (c) 1998-2018 Zend Technologies
PHP-Parser version
MISS semicolon
below code can not show correct result
output :
NOTICE print $someParam miss semicolon
The text was updated successfully, but these errors were encountered: