1. Go to this page and download the library: Download bhittani/php-parser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bhittani / php-parser example snippets
use Bhittani\PhpParser\GroupToSingleImportsVisitor;
$traverser->addVisitor(new GroupToSingleImportsVisitor);
use Grouped\Imports\{Acme, Foo\Bar}
use Grouped\Imports\Acme;
use Grouped\Imports\Foo\Bar;
use Bhittani\PhpParser\SplatToCallUserFuncArrayVisitor;
$traverser->addVisitor(new SplatToCallUserFuncArrayVisitor);
use Bhittani\PhpParser\RemoveImportsVisitor;
$traverser->addVisitor(new RemoveImportsVisitor);
use Bhittani\PhpParser\AppendSuffixVisitor;
$traverser->addVisitor(new AppendSuffixVisitor('_1'));
namespace Company\Package;
use Acme\Foo;
use Acme\Bar\{Beep, Boop};
interface Contract {}
abstract class AnAbstract {}
trait OurTrait {}
class Person extends AnAbstract implements Contract, AnotherContract
{
use OurTrait;
use Their\Trait;
public function handle(Beep $beep, Model\User $age)
{
$foo = new Foo();
$bar = new Bar();
if ($beep->boop()) {
throw new Exception('Error thrown.');
}
}
}
namespace Company\Package;
use Acme\Foo_1 as Foo;
use Acme\Bar\{Beep_1 as Beep, Boop_1 as Boop};
interface Contract_1 {}
abstract class AnAbstract_1 {}
trait OurTrait_1 {}
class Person_1 extends AnAbstract_1 implements Contract_1, AnotherContract_1
{
use OurTrait_1;
use Their\Trait_1;
public function handle(Beep $beep, Model\User_1 $age)
{
$foo = new Foo();
$bar = new Bar_1();
if ($beep->boop()) {
throw new Exception('Error thrown.');
}
}
}
shell
$ composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.