CloneableInstantiable
ImplementsPhpParser\ErrorHandler
Methods
public __construct()
public addActor(PHPFUI\RefActor\Actor\Base $actor) : self
 

Actors are processed in order of addition for each file processed.

public addDirectory(string $directory, bool $recurseIntoDirectories = true, array $fileExtensions = ['.php']) : self
 

Directories are processed in order of adding, then files by OS order defined by DirectoryIterator

public addFile(string $file) : self
 

Files are processed after directories in order added. You can add a file from an Actor if
desired.

public clearReviews() : self
public getPHPVersion() : int
 

Return the current PHP version being parsed

public getReviews(array $types = []) : array
 

Reviews are critiques of Actors, generally errors, warnings, etc.

  • return
public getTests() : array
 

Return results if testing is turned on. Array keys are file names.

public handleError(PhpParser\Error $error) : void
 

PHPParser error handler

public log(string $type, string $message, array $context = []) : self
public perform() : self
 

Start Actors peforming refactoring with the current settings

public printToFile(string $newFile, array $statements) : self
 

Output statements to a file. Will include the beginning opening php tag.

public processFile(string $file) : self
 

You can process one file at a time if you like

public processPHP(string $PHP, string $file = '') : string
 

Process a string as PHP code

  • return ?string null is an error, an empty string is no change, else changed PHP code
public removeActor(PHPFUI\RefActor\Actor $actor) : self
public removeDirectory(string $directory) : self
public removeFile(string $file) : self
public setLogger(?Psr\Log\LoggerInterface $logger = NULL) : self
 

Register a logger to get immediate feedback, or call getReviews after calling execute for all
reviews so far.

public setPHPVersion(int $PHPVersion = 1) : self
 

What version of PHP should the parser expect. Default \PhpParser\ParserFactory::PREFER_PHP7

Possible values:

  • \PhpParser\ParserFactory::PREFER_PHP7
  • \PhpParser\ParserFactory::PREFER_PHP5
  • \PhpParser\ParserFactory::ONLY_PHP7
  • \PhpParser\ParserFactory::ONLY_PHP5
public setTesting(bool $testing = false) : self
 

If testing is turned on, no files will be written

Properties
private array $actors
private string $currentFile
private array $directories
private array $files
private PhpParser\Lexer\Emulative $lexer
private Psr\Log\LoggerInterface $logger
private PhpParser\Parser $parser
private int $PHPVersion
private PhpParser\PrettyPrinter\Standard $printer
private array $reviews
private bool $testing
private array $tests
Methods
private output(string $file, string $PHP) : self
 

Output the generated PHP code

© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only