Consider the following code:
<?php
namespace abc;
use function is_string;
use function get_class;
class main {
protected $string;
public function __construct( $string ) {
if ( is_string( $string )) {
$this->string = $string;
} else {
$this->string = get_class( $this );
}
}
}
Nothing fancy. Just a class in a namespace using two functions from the global namespace (is_string
& get_class
).
Those two functions are imported from the global namespace as that will give a small performance boost.
But if you have 20-30 build in PHP functions that list will get very long….
Luckily you can merge them:
use function is_string, get_class;
For now I’m not sure I’ll always import build in PHP functions, the boost is small. And it’s annoying to keep track of.