davtk/nette-schema-reflection

调优后的Nette Schema

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

This package is auto-updated.

Last update: 2024-09-05 03:36:43 UTC


README

原始Nette schema: https://github.com/nette/schema

附加功能

通过反射实例化对象

让我们想象以下类

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

将该值转换为该类将导致ArgumentCountError,因为Schema正在使用new关键字实例化该类。

我在castTo: castTo(string $type, bool $usingReflection = false): self中添加了第二个参数来解决这个问题 - 默认行为未改变,因此不会引起BC中断。