Ejemplo n.º 1
0
function _pprintr_object_ReflectionProperty(ReflectionProperty $property, $var, $indent, $indentStep)
{
    $modifiers = array();
    $property->setAccessible(true);
    if (defined('PPRINTR_INCLUDE_PROTECTED') && PPRINTR_INCLUDE_PROTECTED) {
        $property->isPublic() && ($modifiers[] = "public");
        $property->isProtected() && ($modifiers[] = "protected");
        $property->isPrivate() && ($modifiers[] = "private");
    }
    $property->isStatic() && ($modifiers[] = "static");
    $modifiers = implode(' ', $modifiers);
    $name = $property->getName();
    $value = pprintr($property->getValue($var), $indent + $indentStep, $indentStep);
    $str = "{$name} => {$value}";
    if ($modifiers != []) {
        $str = "{$modifiers} {$str}";
    }
    return $str;
}
Ejemplo n.º 2
0
    }
}
namespace {
    require_once 'src/pprintr.php';
    function _pprintr_object_User($var, $indent, $indentStep)
    {
        return "(User: #{$var->id} {$var->username})";
    }
    class User
    {
        public $id = 28239;
        public $username = '******';
    }
    $array = ['null' => null, 'true' => true, 'false' => false, 'integer' => 123, 'float' => 123.45, 'string' => "hello world", 'array' => [1, 2, 3]];
    $obj = (object) $array;
    $array['object'] = $obj;
    $array['object2'] = new User();
    $array['object3'] = new Mduk\Foo\Bar();
    define('PPRINTR_INDENT_STEP', 4);
    define('PPRINTR_INCLUDE_PROTECTED', true);
    echo "§";
    echo pprintr(null), "§\n\n§";
    echo pprintr(true), "§\n\n§";
    echo pprintr(false), "§\n\n§";
    echo pprintr(123), "§\n\n§";
    echo pprintr(123.45), "§\n\n§";
    echo pprintr("hello world"), "§\n\n§";
    echo pprintr([null, true, false, 123, 123.45, "hello world"]), "§\n\n§";
    echo pprintr($obj), "§\n\n§";
    echo pprintr($array), "§\n\n";
}