Krinkle has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/338509 )
Change subject: AutoloadGenerator: Add support for class_alias()
......................................................................
AutoloadGenerator: Add support for class_alias()
Blob, Field, DatabaseBase are now auto-detected.
Change-Id: Ib8fae2ec3fbb3f5e4aca7965f81631c5f0485ea1
---
M includes/utils/AutoloadGenerator.php
1 file changed, 37 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/09/338509/1
diff --git a/includes/utils/AutoloadGenerator.php
b/includes/utils/AutoloadGenerator.php
index 0bfd4a27..ec0c87d 100644
--- a/includes/utils/AutoloadGenerator.php
+++ b/includes/utils/AutoloadGenerator.php
@@ -291,15 +291,6 @@
foreach ( glob( $this->basepath . '/*.php' ) as $file ) {
$this->readFile( $file );
}
-
- // Legacy aliases (1.28)
- $this->forceClassPath( 'DatabaseBase',
- $this->basepath .
'/includes/libs/rdbms/database/Database.php' );
- // Legacy aliases (1.29)
- $this->forceClassPath( 'Blob',
- $this->basepath .
'/includes/libs/rdbms/encasing/Blob.php' );
- $this->forceClassPath( 'Field',
- $this->basepath .
'/includes/libs/rdbms/field/Field.php' );
}
}
@@ -336,6 +327,7 @@
$this->namespace = '';
$this->classes = [];
$this->startToken = null;
+ $this->alias = null;
$this->tokens = [];
foreach ( token_get_all( $code ) as $token ) {
@@ -365,6 +357,12 @@
case T_TRAIT:
case T_DOUBLE_COLON:
$this->startToken = $token;
+ break;
+ case T_STRING:
+ if ( $token[1] === 'class_alias' ) {
+ $this->startToken = $token;
+ $this->alias = array();
+ }
}
}
@@ -388,6 +386,36 @@
}
break;
+ case T_STRING:
+ if ( $this->alias !== null ) {
+ // Normal flow:
+ // - T_STRING class_alias
+ // - '('
+ // - T_CONSTANT_ENCAPSED_STRING 'TargetClass'
+ // - ','
+ // - T_WHITESPACE
+ // - T_CONSTANT_ENCAPSED_STRING 'AliasName'
+ // - ')'
+ if ( $token === '(' ) {
+ // Start of a function call to
class_alias()
+ $this->alias = array( 'target' => null,
'name' => null );
+ } elseif ( is_array( $token ) && $token[0] ===
T_CONSTANT_ENCAPSED_STRING ) {
+ if ( $this->alias['target'] === null ) {
+ // First argument (strip quotes)
+ $this->alias['target'] =
substr( $token[1], 1, -1 );
+ } else {
+ // Second argument (strip
quotes)
+ $this->alias['name'] = substr(
$token[1], 1, -1 );
+ }
+ } elseif ( $token === ')' ) {
+ // End of function call
+ $this->classes[] = $this->alias['name'];
+ $this->alias = null;
+ $this->startToken = null;
+ }
+ }
+ break;
+
case T_CLASS:
case T_INTERFACE:
case T_TRAIT:
--
To view, visit https://gerrit.wikimedia.org/r/338509
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib8fae2ec3fbb3f5e4aca7965f81631c5f0485ea1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits