45 $files = array_unique( $expected );
47 foreach ( $files as $class => $file ) {
50 if ( substr( $file, 0, 1 ) !=
'/' && substr( $file, 1, 1 ) !=
':' ) {
51 $filePath =
"$IP/$file";
56 if ( !file_exists( $filePath ) ) {
57 $actual[$class] =
"[file '$filePath' does not exist]";
61 Wikimedia\suppressWarnings();
62 $contents = file_get_contents( $filePath );
63 Wikimedia\restoreWarnings();
65 if ( $contents ===
false ) {
66 $actual[$class] =
"[couldn't read file '$filePath']";
75 (?:final\s+)? (?:abstract\s+)? (?:class|interface|trait) \s+
76 (?P<class> [a-zA-Z0-9_]+)
78 class_alias \s* \( \s*
79 ([\'"]) (?P<original> [^\'"]+) \g{-2} \s* , \s*
80 ([\'"]) (?P<alias> [^\'"]+ ) \g{-2} \s*
83 class_alias \s* \( \s*
84 (?P<originalStatic> [a-zA-Z0-9_]+)::class \s* , \s*
85 ([\'"]) (?P<aliasString> [^\'"]+ ) \g{-2} \s*
88 /imx', $contents,
$matches, PREG_SET_ORDER );
94 ([a-zA-Z0-9_]+(\\\\[a-zA-Z0-9_]+)*)
96 /imx', $contents, $namespaceMatch );
97 $fileNamespace = $namespaceMatch ? $namespaceMatch[1] .
'\\' :
'';
103 if ( !empty( $match[
'class'] ) ) {
105 $class = $fileNamespace . $match[
'class'];
106 $actual[$class] = $file;
107 $classesInFile[$class] =
true;
109 if ( !empty( $match[
'original'] ) ) {
111 $aliasesInFile[$match[
'alias']] = $match[
'original'];
114 $aliasesInFile[$match[
'aliasString']] = $fileNamespace . $match[
'originalStatic'];
122 foreach ( $aliasesInFile as $alias => $class ) {
123 if ( isset( $classesInFile[$class] ) ) {
124 $actual[$alias] = $file;
126 $actual[$alias] =
"[original class not in $file]";
132 'expected' => $expected,