ymmtmsys/properties

通过注解自动创建setter和getter。

0.1.0 2012-10-06 00:04 UTC

This package is not auto-updated.

Last update: 2024-09-28 16:51:43 UTC


README

Properties通过注解自动创建setter和getter。

Build Status

注解

@accessor

@accessor注解能够读写变量。

@reader

@reader注解能够读取变量。

@writer

@writer注解能够写入变量。

示例

<?php
use Ymmtmsys\Properties\Properties;

class SubClass extends Properties // extend Properties class
{
    /**
     * @accessor
     */
    protected $rdwr = 'Read and wirte property';

    /**
     * @reader
     */
    protected $rdonly = 'Read only property';

    /**
     * @writer
     */
    protected $wronly = 'Write only property';

    protected $no_annotation = 'no annotation';
}

$obj = new SubClass;

// Read
echo $obj->rdonly, "\n"; // => "Read only property"
echo $obj->rdwr,   "\n"; // => "Read and wirte property" 

// Write 
$obj->wronly = 'Yippee!';
$obj->rdwr   = 'Yup!';

// Error!!
$obj->rdonly = 'Oops!';
echo $obj->wronly, "\n";
$obj->no_annotation = 'php';
echo $obj->no_annotation, "\n";

版权

版权所有(c)2012 ymmtmsys。有关更多信息,请参阅LICENSE。