- var_dump: documentation ( source)
- preg_match: documentation ( source)
<?php
// Copied from tests/_support/Commands/Foobar.php
$template = "<?php
use Config\App;
use CodeIgniter\CLI\CLI;
return [
'foo' => 'The command will use this as foo.',
'bar' => 'The command will use this as bar.',
'baz' => 'The baz is here.',
'bas' => CLI::color('bas', 'green') . (new App())->baseURL,
];
";
preg_match(
'/(?P<imports>(?:^use [^;]+;$\n?)+)/m',
$template,
$match
);
var_dump($match); // empty 'imports'