The phpstan.neon
file in the PHPWord repository is for PHPWord itself being analysed by PHPStan. It's not relevant to you if you're a user of PHPWord. You're not supposed to include that file in your project that uses PHPWord.
The error reported by PHPStan is correct:
Class PhpOffice\PhpWord\Writer\PDF\MPDF referenced with incorrect case: PhpOffice\PhpWord\Writer\PDF\Mpdf.
The class is called MPDF
, not Mpdf
: https://github.com/PHPOffice/PHPWord/blob/0.18.2/src/PhpWord/Writer/PDF/MPDF.php
So in order to fix the error reported by PHPStan, you need to reference the class by its correct name in your source code: MPDF
Although class names in PHP are case-insensitive, PHPStan chooses to report this as a problem, because historically, there might be problems with certain autoloaders and running PHP applications on file systems with different case sensitivity, like Windows vs. Linux.
So under certain circumstances, Mpdf
class might be found on Windows, because MPDF.php
is the same as Mpdf.php
and the class will load, but the same application might not run on Linux, because Mpdf.php
and MPDF.php
aren't the same file.