- token_get_all: documentation ( source)
- print_r: documentation ( source)
<?php
$code = '
/**
*
* @param string $script The PHP script
* @param string $class The full qualified class name with namespace
* @param string $alias An optional alias for the class
*/
protected function addUseStatement(&$script, $class, $alias = null)
{
if (isset($this->getTable()->useStatements) && in_array($class, $this->getTable()->useStatements)) {
return;
}
if ($alias)
{
$script = "use $class as $alias;\n$script";
}
else
{
$script = "use $class;\n$script";
}
if (!isset($this->getTable()->useStatements)) {
$this->getTable()->useStatements = array();
}
$this->getTable()->useStatements[] = $class;
}
';
print_r(token_get_all("<?php\n$code"));