Prefix phpstan-doctrine for MailPoetVendor

[MAILPOET-2945]
This commit is contained in:
Jan Jakeš
2020-05-25 17:56:27 +02:00
committed by Veljko V
parent fb2e1c707e
commit df6bf552b1
2 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
<?php
// throw exception if anything fails
set_error_handler(function ($severity, $message, $file, $line) {
throw new ErrorException($message, 0, $severity, $file, $line);
});
$iterator = new RecursiveDirectoryIterator(__DIR__ . '/vendor/phpstan/phpstan-doctrine', RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
foreach ($files as $file) {
if (substr($file, -4) === '.php' || substr($file, -5) === '.stub') {
$data = file_get_contents($file);
// when string 'Doctrine' is prefixed by a whitespace, ', ", or ( plus zero or more \, and suffixed by
// one or more \, prefix it with 'MailPoetDoctrine' + the number of trailing \ in the original string
$data = preg_replace('/([\'"\s(]\\\\*)(Doctrine)(\\\\+)/', '$1MailPoetVendor$3$2$3', $data);
file_put_contents($file, $data);
}
}