Skip to content

Releases: sagittaracc/decorator

v6.4.3

19 Nov 16:45
Compare
Choose a tag to compare
  • add Rpc
use Sagittaracc\PhpPythonDecorator\Decorator;
use Sagittaracc\PhpPythonDecorator\modules\rpc\core\Rpc;

#[Rpc]
class Controller
{
    use Decorator;

    public function sum($a, $b)
    {
        return $a + $b;
    }
}

in index.php

$requestBody = file_get_contents('php://input');

$controller = new Controller();
$controller($requestBody);

in terminal

$ curl -d "{"id":1,"method":"sum","params":[1,4]}" http://localhost:4000
{"json-rpc":"2.0","id":1,"result":5}

v6.4.2

22 Apr 13:46
Compare
Choose a tag to compare
  • 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

22 Apr 12:22
Compare
Choose a tag to compare
  • 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

19 Apr 14:29
Compare
Choose a tag to compare

Done generics refactor

v6.3.0

19 Apr 06:51
Compare
Choose a tag to compare

Done generics refactor

v6.2.1

16 Apr 11:37
Compare
Choose a tag to compare
  • 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

02 Apr 08:49
Compare
Choose a tag to compare
  • 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

29 Mar 12:41
Compare
Choose a tag to compare
  • Выпилил PhpDecorator

v6.0.0

29 Mar 11:10
Compare
Choose a tag to compare
поправил все тесты

v5.0.0

29 Mar 06:12
860fd5a
Compare
Choose a tag to compare

Pass the arguments of a method into the decorator wrappers