src/Leevel/Database/Ddd/Entity.php
protected function withPropValue(string $prop, $value, bool $force = true, bool $ignoreReadonly = false): void
    {
        $prop = $this->normalize($prop);

        $this->validate($prop);

        if ($this->isRelation($prop)) {
            $e = sprintf('Cannot set a relation prop `%s` on entity `%s`.', $prop, static::class);

            throw new InvalidArgumentException($e);
        }

        $this->propSetter($prop, $value);

        if (!$force) {
            return;
        }

        if (false === $ignoreReadonly &&
            isset(static::STRUCT[$prop]['readonly']) &&
            true === static::STRUCT[$prop]['readonly']) {
            $e = sprintf('Cannot set a read-only prop `%s` on entity `%s`.', $prop, static::class);

            throw new InvalidArgumentException($e);
        }

        if (in_array($prop, $this->leevelChangedProp, true)) {
            return;
        }

        $this->leevelChangedProp[] = $prop;
    }
protected function withPropValue(string $prop, $value, bool $force = true, bool $ignoreReadonly = false): void
    {
        $prop = $this->normalize($prop);

        $this->validate($prop);

        if ($this->isRelation($prop)) {
            $e = sprintf('Cannot set a relation prop `%s` on entity `%s`.', $prop, static::class);

            throw new InvalidArgumentException($e);
        }

        $this->propSetter($prop, $value);

        if (!$force) {
            return;
        }

        if (false === $ignoreReadonly &&
            isset(static::STRUCT[$prop]['readonly']) &&
            true === static::STRUCT[$prop]['readonly']) {
            $e = sprintf('Cannot set a read-only prop `%s` on entity `%s`.', $prop, static::class);

            throw new InvalidArgumentException($e);
        }

        if (in_array($prop, $this->leevelChangedProp, true)) {
            return;
        }

        $this->leevelChangedProp[] = $prop;
    }
改变属性.

@param string $prop
@param mixed  $value
@param bool   $force
@param bool   $ignoreReadonly