Wrap CallbackFilterIterator in a condition check

Wrap the CallbackFilterIterator backport class in a conditional check
for PHP runtimes that include the class natively. This really should
only be needed for linting as the class is loaded via an autoloader
and thus should not be loaded if the runtime already has it
available.

Bug: T124828
Change-Id: I39d27385186d4693a8babdd2b818e6b4bc16255a
This commit is contained in:
Bryan Davis 2016-01-26 14:49:38 -07:00
parent e28a912c3b
commit 3f7436c959
2 changed files with 22 additions and 19 deletions

View file

@ -5,7 +5,7 @@
},
"scripts": {
"test": [
"parallel-lint . --exclude vendor --exclude includes/iterator/CallbackFilterIterator.php",
"parallel-lint . --exclude vendor",
"phpcs"
]
}

View file

@ -1,11 +1,13 @@
<?php
/**
// T124828: conditional is a linter compatibility hack
if ( !class_exists( 'CallbackFilterIterator' ) ) {
/**
* This class is implemented as part of SPL starting at PHP5.4. This
* re-implementation provides backwards compatibility to mediawiki
* running on PHP5.3.
*/
class CallbackFilterIterator extends FilterIterator {
class CallbackFilterIterator extends FilterIterator {
protected $callback;
public function __construct( Iterator $iterator, $callback ) {
@ -21,4 +23,5 @@ class CallbackFilterIterator extends FilterIterator {
$this->getInnerIterator()
);
}
}
}