1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 16:59:45 +01:00
psalm/scoper.inc.php

73 lines
2.2 KiB
PHP
Raw Normal View History

2018-03-11 17:35:46 +01:00
<?php
2022-03-07 22:57:18 +01:00
use Composer\Autoload\ClassLoader;
2018-03-11 17:35:46 +01:00
return [
'patchers' => [
function (string $filePath, string $prefix, string $contents): string {
2018-03-11 17:35:46 +01:00
//
// PHP-Parser patch
//
if ($filePath === 'vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php') {
2018-03-11 17:35:46 +01:00
$length = 15 + strlen($prefix) + 1;
return preg_replace(
'%strpos\((.+?)\) \+ 15%',
sprintf('strpos($1) + %d', $length),
$contents
);
}
return $contents;
},
function (string $_filePath, string $prefix, string $contents): string {
2018-05-05 02:43:43 +02:00
return str_replace(
'\\' . $prefix . '\Composer\Autoload\ClassLoader',
2018-05-05 02:43:43 +02:00
'\Composer\Autoload\ClassLoader',
$contents
);
},
function (string $filePath, string $prefix, string $contents): string {
if (strpos($filePath, 'src/Psalm') === 0) {
2018-03-18 15:52:54 +01:00
return str_replace(
2020-05-15 01:56:20 +02:00
[' \\PhpParser\\'],
[' \\' . $prefix . '\\PhpParser\\'],
2018-03-18 15:52:54 +01:00
$contents
);
}
return $contents;
},
function (string $filePath, string $prefix, string $contents): string {
if (strpos($filePath, 'vendor/openlss') === 0) {
2018-03-18 15:52:54 +01:00
return str_replace(
$prefix . '\\DomDocument',
'DomDocument',
$contents
);
}
return $contents;
},
2018-03-11 17:35:46 +01:00
],
'exclude-classes' => [
2022-03-07 22:57:18 +01:00
ClassLoader::class,
Stringable::class,
],
'exclude-namespaces' => [
'Psalm',
],
'exclude-constants' => [
'PSALM_VERSION',
'PHP_PARSER_VERSION',
],
'exclude-files' => [
'src/spl_object_id.php',
2022-03-07 22:57:18 +01:00
'vendor/symfony/polyfill-php80/Php80.php',
'vendor/symfony/polyfill-php80/PhpToken.php',
'vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php',
'vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php',
'vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php',
],
2018-03-11 17:35:46 +01:00
];