ApnsPHP icon indicating copy to clipboard operation
ApnsPHP copied to clipboard

Autoloader fails on '0' class

Open JanMikes opened this issue 4 years ago • 1 comments

Hi, we are using PHPStan and we have lot of tests analysed by phpstan, with data providers, that looks like this:

yield [
    [
        'a' => '1',
        'b' => '0',
    ],
];

Since phpstan checks if class exists, it calls class_exists on strings and it throws exception Exception (Class name is empty) thrown while autoloading class 0.

While debugging i found out it is caused by the custom autoloader, here is minimal code to break things up:

<?php

require __DIR__ . '/vendor/duccio/apns-php/ApnsPHP/Autoload.php';

var_dump(class_exists('0'));

It would be nice to make this package use composer autoloader (classmaps) or PSR-4 as suggested in #135 ?

I can send PR migrating this repository to PSR-4 as i can do it automatically with rector - https://github.com/rectorphp/rector

JanMikes avatar Feb 03 '20 11:02 JanMikes

Basically this library breaks this assumption and throws an exception instead: https://3v4l.org/RIFmv

ondrejmirtes avatar Feb 03 '20 12:02 ondrejmirtes