Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[Finder] made the Custom filter accept all PHP callbacks

  • Loading branch information...
commit 37d5bafb16444a66c1acfbde675e0f23b0866685 1 parent 46ea1e6
@fabpot fabpot authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 Iterator/CustomFilterIterator.php
View
9 Iterator/CustomFilterIterator.php
@@ -27,10 +27,15 @@ class CustomFilterIterator extends \FilterIterator
* Constructor.
*
* @param \Iterator $iterator The Iterator to filter
- * @param array $filters An array of \Closure
+ * @param array $filters An array of PHP callbacks
*/
public function __construct(\Iterator $iterator, array $filters)
{
+ foreach ($filters as $filter) {
+ if (!is_callable($filter)) {
+ throw new \InvalidArgumentException('Invalid PHP callback.');
+ }
+ }
$this->filters = $filters;
parent::__construct($iterator);
@@ -46,7 +51,7 @@ public function accept()
$fileinfo = $this->current();
foreach ($this->filters as $filter) {
- if (false === $filter($fileinfo)) {
+ if (false === call_user_func($filter, $fileinfo)) {
return false;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.