function _getParameters(ReflectionMethod $method) { return _::chain($method->getParameters())->map(function ($parameter) { return (object) ['name' => $parameter->name, 'isReference' => $parameter->isPassedByReference(), 'hasDefaultValue' => $parameter->isDefaultValueAvailable(), 'default' => $parameter->isDefaultValueAvailable() ? _valueToString($parameter->getDefaultValue()) : null, 'type' => '', 'description' => '', 'reflect' => $parameter]; })->invoke(function () { $this->asStringNoRefNoValue = "\${$this->name}"; $this->asStringNoRef = "\${$this->name}" . ($this->hasDefaultValue ? "={$this->default}" : ''); $this->asString = ($this->isReference ? '&' : '') . "\${$this->name}" . ($this->hasDefaultValue ? "={$this->default}" : ''); })->indexBy('name')->value(); }
function _chain($object) { return Underscore::chain($object); }
/** * @dataProvider peopleDataProvider * @tags chaining */ public function testChain($people, $type, $meta) { $actors = _::chain($people)->sortBy(function ($actor) { return $actor->born; })->where(['profession' => 'actor'])->pluck('name')->walk(function (&$name) { $name = strtolower($name); })->value(); $this->array($actors)->isEqualTo(['nportman' => 'nathalie portman', 'ldicaprio' => 'leonardo dicaprio', 'mfreeman' => 'morgan freeman', 'jnicholson' => 'jack nicholson']); }