mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
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:
parent
e28a912c3b
commit
3f7436c959
|
@ -5,7 +5,7 @@
|
|||
},
|
||||
"scripts": {
|
||||
"test": [
|
||||
"parallel-lint . --exclude vendor --exclude includes/iterator/CallbackFilterIterator.php",
|
||||
"parallel-lint . --exclude vendor",
|
||||
"phpcs"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
protected $callback;
|
||||
// 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 {
|
||||
protected $callback;
|
||||
|
||||
public function __construct( Iterator $iterator, $callback ) {
|
||||
parent::__construct( $iterator );
|
||||
$this->callback = $callback;
|
||||
}
|
||||
public function __construct( Iterator $iterator, $callback ) {
|
||||
parent::__construct( $iterator );
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
public function accept() {
|
||||
return call_user_func(
|
||||
$this->callback,
|
||||
$this->current(),
|
||||
$this->key(),
|
||||
$this->getInnerIterator()
|
||||
);
|
||||
public function accept() {
|
||||
return call_user_func(
|
||||
$this->callback,
|
||||
$this->current(),
|
||||
$this->key(),
|
||||
$this->getInnerIterator()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue