- var_dump: documentation ( source)
- preg_match_all: documentation ( source)
- str_replace: documentation ( source)
<?php
$str = <<<EOT
<?php
declare(strict_types=1);
namespace %namespace%
class %classname% {
%attributes%
%methods%
}
EOT;
preg_match_all('/\%(?P<name>\w+)\%/', $str, $data);
$str = str_replace('%classname%', 'test', $str);
var_dump($str);