Files
piratepoet/mailpoet/prefixer/fix-attributes.php
John Oleksowicz e3a8db7de9 Ensure we're checking file extension
This prevents an error when adding packages whose names end in php

MAILPOET-5161
2023-10-23 17:40:54 +02:00

19 lines
945 B
PHP

<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
// throw exception if anything fails
set_error_handler(function ($severity, $message, $file, $line) {
throw new ErrorException($message, 0, $severity, $file, $line);
});
// because php-scoper contains an issue with PHP attributes we need to replace the use of ReturnTypeWillChange
// this can be deleted when the issue will be solved https://github.com/humbug/php-scoper/issues/539
$iterator = new RecursiveDirectoryIterator(__DIR__ . '/../vendor-prefixed', RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
foreach ($files as $file) {
if (substr($file, -4) === '.php') {
$data = file_get_contents($file);
$data = str_replace('use MailPoetVendor\\ReturnTypeWillChange;', 'use ReturnTypeWillChange;', $data);
file_put_contents($file, $data);
}
}