25 yield [ $prefix, $dir,
$file ];
46 "Only one class per file in PSR-4 autoloaded classes ($file)"
53 $expectedClassName = $prefix .
str_replace(
'/',
'\\', $abbrFileName );
58 "Class not autoloaded properly"
67 if ( $aliasesInFile ) {
69 foreach ( $aliasesInFile as $alias => $class ) {
71 'Alias must be in the classmap autoloader'
83 (?:final\s+)? (?:abstract\s+)? (?:class|interface|trait) \s+
86 class_alias \s* \( \s*
87 ([\'"]) (?P<original> [^\'"]+) \g{-2} \s* , \s*
88 ([\'"]) (?P<alias> [^\'"]+ ) \g{-2} \s*
91 class_alias \s* \( \s*
92 (?P<originalStatic> [\w\\\\]+)::class \s* , \s*
93 ([\'"]) (?P<aliasString> [^\'"]+ ) \g{-2} \s*
96 /imx', $contents,
$matches, PREG_SET_ORDER );
104 /imx', $contents, $namespaceMatch );
105 $fileNamespace = $namespaceMatch ? $namespaceMatch[1] .
'\\' :
'';
111 if ( !empty( $match[
'class'] ) ) {
113 $class = $fileNamespace . $match[
'class'];
114 $classesInFile[$class] =
true;
115 }
elseif ( !empty( $match[
'original'] ) ) {
117 $aliasesInFile[$match[
'alias']] = $match[
'original'];
120 $aliasesInFile[$match[
'aliasString']] = $fileNamespace . $match[
'originalStatic'];
134 $psr4Namespaces = [];
136 $psr4Namespaces[
rtrim( $ns,
'\\' ) .
'\\'] =
rtrim( $path,
'/' );
139 foreach ( $expected as $class => $file ) {
142 if (
substr( $file, 0, 1 ) !=
'/' &&
substr( $file, 1, 1 ) !=
':' ) {
143 $filePath =
"$IP/$file";
149 $actual[$class] =
"[file '$filePath' does not exist]";
157 if ( $contents ===
false ) {
158 $actual[$class] =
"[couldn't read file '$filePath']";
164 foreach ( $classesInFile as $className => $ignore ) {
166 $parts = explode(
'\\', $className );
167 for ( $i = count( $parts ) - 1; $i > 0; $i-- ) {
168 $ns = implode(
'\\',
array_slice( $parts, 0, $i ) ) .
'\\';
169 if (
isset( $psr4Namespaces[$ns] ) ) {
170 $expectedPath = $psr4Namespaces[$ns] .
'/'
173 if ( $filePath === $expectedPath ) {
186 foreach ( $aliasesInFile as $alias => $class ) {
187 if (
isset( $classesInFile[$class] ) ) {
188 $actual[$alias] =
$file;
190 $actual[$alias] =
"[original class not in $file]";
196 'expected' => $expected,
202 $path = realpath( __DIR__ .
'/../../..' );
207 $newAutoload =
$generator->getAutoload(
'maintenance/generateLocalAutoload.php' );
209 $this->
assertEquals( $oldAutoload, $newAutoload,
'autoload.php does not match' .
210 ' output of generateLocalAutoload.php script.' );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgAutoloadClasses['ReplaceTextHooks']
global $wgAutoloadLocalClasses
testAutoLoadConfig()
Assert that there were no classes loaded that are not registered with the AutoLoader.
providePSR4Completeness()
static checkAutoLoadConf()
testPSR4Completeness( $prefix, $dir, $file)
providePSR4Completeness
static parseFile( $contents)
static getAutoloadNamespaces()
Get a mapping of namespace => file path The namespaces should follow the PSR-4 standard for autoloadi...
static string[] $psr4Namespaces
Accepts a list of files and directories to search for php files and generates $wgAutoloadLocalClasses...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file