コード例 #1
0
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();
}
コード例 #2
0
function _chain($object)
{
    return Underscore::chain($object);
}
コード例 #3
0
ファイル: Underscore.php プロジェクト: brombal/underscore.php
 /**
  * @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']);
 }