This adds support for a PSR-4 (<http://www.php-fig.org/psr/psr-4/>)
autoloader, so instead of needing to manually list each class, just the
namespace prefix is needed.
Extensions can set a "AutoloadNamespaces" property in extension.json to
register PSR-4 compatible namespaces to be autoloaded.
The implementation is based off of the example implementation
(<http://www.php-fig.org/psr/psr-4/examples/>) with some modifications
for performance, notably cutting down on function calls, and only trying
to look up classes that are namespaced.
The generateLocalAutoload.php script will ignore any directory that is
registered as a PSR-4 namespace.
Bug: T99865
Bug: T173799
Change-Id: Id095dde37cbb40aa424fb628bd3c94e684ca2f65
If a class is added manually to the autoload.php another run of
the maintenance script will probably add unnecessary noise to
another change. The added structure test checks, if the output of
the maintenance script equals to the contents of the commited
autoload.php.
Bug: T121921
Change-Id: I3a426b92892f4c00cab33a13f6a717751120367c
AutoLoaderTest didn't know about traits.
generateLocalAutoload found a missing Trait from the autoloader and
a class map ordering issue.
Change-Id: I34bf2698ad838b6a977c9bf39f6e416330ff0e5d
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.
Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.
Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.
Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
Avoids:
1) AutoLoaderTest::testWrongCaseClass
Failed asserting that false is true.
2) AutoLoaderTest::testWrongCaseSerializedClass
unserialize() can load classes case-insensitively.
Failed asserting that true is false.
Change-Id: Ic5c271906fb9b2e27639aa8ecfc04ffe6788d3eb
Previously, it just failed with "No such file or directory" without explaining
what's wrong where why.
Change-Id: I776e8fe61f74fd21295da48a45c86ffed9489e23
* Changed the regex to match class aliases, and added a check to
also ensure that all aliases for a class are in the same file as
the class (see cb77e59f7c for explanation).
* Removed support for the seemingly unmaintained Parsekit extension
(no release since 2009, and known not to compile against PHP 5.4).
The test would currently fail if Parsekit were used anyway because
the class MyLocalSettingsGenerator is commented out.
Change-Id: I7be2352f4659abc7b4952a9f74a14d0cef911614
Seems good in theory, though not quite usable in practice.
As with subclassing, the aliases would not work reliably
for code that uses type hints and/or instanceof.
See <https://bugs.php.net/bug.php?id=61422>, which I was
previously unaware of.
The best alternative is to add class_alias() calls to the
class files themselves, as well as duplicate entries to the
AutoLoader (just like when multiple classes are in the same
file).
There is no good way to show deprecation warnings, which
likely would have to be implemented in PHP itself. For now,
renamed classes should be indicated in RELEASE-NOTES. Maybe
I will file an RfC (at <https://wiki.php.net/rfc>) for this
and related improvements (e.g. making class names case
sensitive).
This reverts commit c61fdb4ef5.
Change-Id: I9771b4239543b543cfa078f357db1cd3918f081e
Sometimes it is desirable to change a class name that is still referenced
in extensions or config files (e.g. for consistency, as in I507ba00a).
PHP's class_alias() function can help in preserving backward compatibility;
however, creating an alias first requires that the class be loaded.
Hence this is implemented in AutoLoader. Lazy loading continues to work,
the list of class names is still maintained in a central location, and
optionally, deprecation warnings can be generated.
Change-Id: I1d3fb04a448647b5be10bed7fec05238b9fc6fc7
- Removed double spaces
- Added space after if/switch/foreach
- Removed space on elseif
- Added space around parentheses
- Added newline at end of file
- Removed space before semicolon at end of line
Change-Id: Id40b87e04786c6111e6686d7f7eea1e588bdf37d
Make protected, add method to allow tests to clear the protected class
property, and remove a now unneeded class from the test.
Change-Id: I269cab8d3f4419c91dfe15d5722e19ff6da828d1
When MediaWiki autoloading fails, we should gracefully return false.
Instead, we have been calling strtolower roughly 1,000 times in the hope
of finding a case-insensitive match.
This patch preserves the legacy case-insensitivity, but improves its
performance by approximately 100x, by storing the case-insensitive class
lookups as a static variable.
There is a new global $wgAutoloadAttemptLowercase which will switch the
behavior if desired. The default is to support case-insensitive loading.
Change-Id: Ifb12e05614a48390b730167e9d4ddcd8545db764
The phpunit root directory has two test file:
AutoLoaderTest.php
StructureTest.php
The later was registered in phpunit under the `structure` test suite
while the former was not registered and hence never run (bug 47750).
This patch moves both files under the `structure` subdirectory and
change the suite to look in that directory. That will avoid us having
to manually maintain a list of test files.
Updated the __DIR__ in StructureTest.php.
Change-Id: I419c9157f32bdf7e1ff26a42f4bb3f3922b7be37
2013-05-21 12:33:42 +02:00
Renamed from tests/phpunit/AutoLoaderTest.php (Browse further)