Dashboard
PHP:
8.2.30
OS:
Linux
User:
dh_nv8b2m
/
/
usr
/
local
/
wp
/
php
/
WP_CLI
/
Iterators
📤 Upload
📝 New File
📁 New Folder
Close
Editing: Transform.php
<?php namespace WP_CLI\Iterators; use IteratorIterator; /** * Applies one or more callbacks to an item before returning it. */ class Transform extends IteratorIterator { private $transformers = []; public function add_transform( $fn ) { $this->transformers[] = $fn; } #[\ReturnTypeWillChange] public function current() { $value = parent::current(); foreach ( $this->transformers as $fn ) { $value = call_user_func( $fn, $value ); } return $value; } }
Save
Cancel