1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
return [ |
4
|
|
|
'patchers' => [ |
5
|
|
|
function ($filePath, $prefix, $contents) { |
6
|
|
|
// |
7
|
|
|
// PHP-Parser patch |
8
|
|
|
// |
9
|
|
|
if ($filePath === 'vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php') { |
10
|
|
|
$length = 15 + strlen($prefix) + 1; |
11
|
|
|
|
12
|
|
|
return preg_replace( |
13
|
|
|
'%strpos\((.+?)\) \+ 15%', |
14
|
|
|
sprintf('strpos($1) + %d', $length), |
15
|
|
|
$contents |
16
|
|
|
); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
return $contents; |
20
|
|
|
}, |
21
|
|
|
function ($filePath, $prefix, $contents) { |
22
|
|
|
return str_replace( |
23
|
|
|
'\\'.$prefix.'\Composer\Autoload\ClassLoader', |
24
|
|
|
'\Composer\Autoload\ClassLoader', |
25
|
|
|
$contents |
26
|
|
|
); |
27
|
|
|
}, |
28
|
|
|
function ($filePath, $prefix, $contents) { |
29
|
|
|
if (strpos($filePath, 'src/Psalm') === 0) { |
30
|
|
|
return str_replace( |
31
|
|
|
[' \\PhpParser\\'], |
32
|
|
|
[' \\' . $prefix . '\\PhpParser\\'], |
33
|
|
|
$contents |
34
|
|
|
); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
return $contents; |
38
|
|
|
}, |
39
|
|
View Code Duplication |
function ($filePath, $prefix, $contents) { |
|
|
|
|
40
|
|
|
if (strpos($filePath, 'vendor/phpmyadmin/sql-parser/src/Context.php') === 0) { |
41
|
|
|
return str_replace( |
42
|
|
|
'\'' . $prefix, |
43
|
|
|
'\'\\\\' . $prefix, |
44
|
|
|
$contents |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
return $contents; |
49
|
|
|
}, |
50
|
|
View Code Duplication |
function ($filePath, $prefix, $contents) { |
|
|
|
|
51
|
|
|
if (strpos($filePath, 'vendor/openlss') === 0) { |
52
|
|
|
return str_replace( |
53
|
|
|
$prefix . '\\DomDocument', |
54
|
|
|
'DomDocument', |
55
|
|
|
$contents |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
return $contents; |
60
|
|
|
}, |
61
|
|
View Code Duplication |
function ($filePath, $prefix, $contents) { |
|
|
|
|
62
|
|
|
if ($filePath === 'src/psalm.php') { |
63
|
|
|
return str_replace( |
64
|
|
|
'\\' . $prefix . '\\PSALM_VERSION', |
65
|
|
|
'PSALM_VERSION', |
66
|
|
|
$contents |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
return $contents; |
71
|
|
|
}, |
72
|
|
|
function ($filePath, $prefix, $contents) { |
73
|
|
|
$ret = str_replace( |
74
|
|
|
$prefix . '\\Psalm\\', |
75
|
|
|
'Psalm\\', |
76
|
|
|
$contents |
77
|
|
|
); |
78
|
|
|
return $ret; |
79
|
|
|
}, |
80
|
|
|
], |
81
|
|
|
'whitelist' => [ |
82
|
|
|
\Composer\Autoload\ClassLoader::class, |
83
|
|
|
'Psalm\*', |
84
|
|
|
], |
85
|
|
|
'files-whitelist' => [ |
86
|
|
|
'src/Psalm/Internal/PropertyMap.php', |
87
|
|
|
'src/Psalm/Internal/CallMap.php', |
88
|
|
|
'src/Psalm/Internal/Stubs/CoreGenericFunctions.phpstub', |
89
|
|
|
'src/Psalm/Internal/Stubs/CoreGenericClasses.phpstub', |
90
|
|
|
'src/spl_object_id.php', |
91
|
|
|
], |
92
|
|
|
]; |
93
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.