Level-2 / Axel

A modular, extensible, fast, ultra-lightweight PHP autoloader with inbuilt caching
15 stars 5 forks source link

Module PS4 : $namespace of constructor must be a string #12

Open jerrywham opened 1 year ago

jerrywham commented 1 year ago

Actually, by default it is null :

    public function __construct($baseDir, $namespace = null) {

but it must be a string because of trim function :

        $this->namespace = trim($namespace, '\\');

So constructor must be defined by :

    public function __construct($baseDir, $namespace = '') {
garrettw commented 1 year ago

Have you tried adding a string typehint to the constructor param? Or replacing the whole param with just ?string $namespace? Also you probably shouldn't be trimming $namespace without first checking that it's not null.