LoginSignup
4
4

More than 5 years have passed since last update.

やったー!php-decoratorsでアノテーションvar_dumpできたよー\(^o^)/

Posted at

php-decoratorsは必ずコールバックを受け取るのが最初ちょっとやっかいですね
https://github.com/AterCattus/php-decorators

<?php
namespace My{
    function var_dump($func, $args) {
        call_user_func_array('\var_dump', $args);
        return function() use ($func) {
            return call_user_func_array($func, func_get_args());
        };
    }

    # @var_dump(func_get_args())
    function test($name, $foo = null){
        echo 'hello', PHP_EOL;
    }

    test('bar');
    test('bar', 'baz');
}

出力は


string(3) "bar"
hello
string(3) "bar"
string(3) "baz"
hello
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4