Releases: sagittaracc/decorator
Releases · sagittaracc/decorator
v6.4.2
- Add generic support for method parameters
use Sagittaracc\PhpPythonDecorator\Decorator;
use Sagittaracc\PhpPythonDecorator\modules\generics\aliases\T;
use Sagittaracc\PhpPythonDecorator\modules\validation\core\validators\ArrayOf;
#[T]
class Box
{
use Decorator;
#[ArrayOf(T::class)]
public $items;
public function addItem(#[T] $item)
{
$this->items[] = $item;
}
}
$box = new Box();
$box(Pen::class); // new Box<Pen>();
call_decorator_func_array([$box, 'addItem'], [new Pencil]); // throws a GenericError
v6.4.1
- Add console support
use Sagittaracc\PhpPythonDecorator\Decorator;
use Sagittaracc\PhpPythonDecorator\modules\console\core\Console;
class Controller
{
use Decorator;
#[Console('hello')]
function greetingPerson($name)
{
return "Hello, $name";
}
}
in the command line it would be calling for example something like this:
php index.php -c hello --name Yuriy
then in index.php
you should read the command and the parameters and after that call it like this:
(new Console('hello'))->setParameters(['name' => 'Yuriy'])->getMethod(Controller::class)->run();
v6.4.0
Done generics refactor
v6.3.0
Done generics refactor
v6.2.1
- I am still working on Generics
use Sagittaracc\PhpPythonDecorator\Decorator;
use Sagittaracc\PhpPythonDecorator\modules\generics\aliases\T;
#[T]
class PaymentInfo
{
use Decorator;
public string $id;
public int $amount;
#[T]
public $currency;
}
$paymentInfo = new PaymentInfo();
$paymentInfo(Number::class); // new PaymentInfo<Number>();
set_decorator_prop($paymentInfo, 'currency', 'rubles'); // throws a GenericError
v6.1.1
- Add Generics
use Sagittaracc\PhpPythonDecorator\Decorator;
use Sagittaracc\PhpPythonDecorator\T;
#[T]
class Box
{
use Decorator;
#[T]
public array $items;
}
$box = new Box();
$box(Pencil::class); // new Box<Pencil>();
$pencil = new Pencil();
$pen = new Pen();
$box->_items = [$pencil, $pen]; // throws a GenericError
v6.1.0
- Выпилил PhpDecorator
v6.0.0
поправил все тесты
v5.0.0
Pass the arguments of a method into the decorator wrappers
v4.3.3
- add
call_decorator_func_array
method to call a method with its decorators