ymmtmsys/properties

Automatically creates a setter and getter via annotations.

0.1.0 2012-10-06 00:04 UTC

This package is not auto-updated.

Last update: 2024-04-27 13:56:46 UTC


README

Properties is automatically creates a setter and getter via annotations.

Build Status

Annotations

@accessor

The @accessor annotation is able to read and write variable.

@reader

The @reader annotation is able to read variable.

@writer

The @writer annotation is able to write variable.

Example

<?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";

Copyright

Copyright (c) 2012 ymmtmsys. See LICENSE for further details.