How can I add a namespace to a PHP file?
ajiho opened this issue · comments
ajiho commented
I have a PHP file helpers.php
<?php
if (!function_exists('abc')) {
function abc(array $array)
{
//...
}
}
I want to add a namespace to it
Just like this
<?php
namespace MyNamespace\Helper;
if (!function_exists('abc')) {
function abc(array $array)
{
//...
}
}
I have searched for relevant documents and tried for a long time, but failed. Can you give me some guidance? Thank you again
Nikita Popov commented
I think something along these lines should do it?
$stmts = [new Namespace_(new Name('MyNamespace\Helper'), $stmts)];
ajiho commented
I think something along these lines should do it?
$stmts = [new Namespace_(new Name('MyNamespace\Helper'), $stmts)];
Thank you for your prompt. I have successfully added the namespace. This issue can be closed. Thank you again