davtk/nette-schema-reflection

Tuned Nette Schema

dev-master / 1.2.x-dev 2023-02-05 00:08 UTC

This package is auto-updated.

Last update: 2024-05-05 02:50:32 UTC


README

Original Nette schema: https://github.com/nette/schema

Additional functionality:

Instantiate object via Reflection

Let's imagine following class:

class Foo
{
    public function __construct(
        public int $a,
        public int $b,
    ) {
    }
}

Casting to this class will result in ArgumentCountError because Schema is instantiating the class using new keyword.

I solved this with adding second argument to castTo: castTo(string $type, bool $usingReflection = false): self - default behavior is not changed, so it's not causing BC break.