Kahlan\Jit\Node\FunctionDef::argsToParams PHP 메소드

argsToParams() 공개 메소드

Returns function's arguments into a list of callable parameters
public argsToParams ( ) : string
리턴 string
    public function argsToParams()
    {
        $args = [];
        foreach ($this->args as $key => $value) {
            $value = is_int($key) ? $value : $key;
            preg_match("/(\\\$[\\\\a-z_\\x7f-\\xff][a-z0-9_\\x7f-\\xff]*)/i", $value, $match);
            $args[] = $match[1];
        }
        return join(', ', $args);
    }

Usage Example

예제 #1
0
<?php

namespace Kahlan\Spec\Suite\Jit\Node;

use Kahlan\Jit\Node\FunctionDef;
describe("FunctionDef", function () {
    describe("->argsToParams()", function () {
        it("builds a list of params from function arguments", function () {
            $node = new FunctionDef();
            $node->args = ['$required', '$param' => '"value"', '$boolean' => 'false', '$array' => '[]', '$array2' => 'array()', '$constant' => 'PI'];
            expect($node->argsToParams())->toBe('$required, $param, $boolean, $array, $array2, $constant');
        });
    });
});
FunctionDef