ApnsPHP
ApnsPHP copied to clipboard
Autoloader fails on '0' class
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
Basically this library breaks this assumption and throws an exception instead: https://3v4l.org/RIFmv