db icon indicating copy to clipboard operation
db copied to clipboard

Replace `object` type for constraint name with `Stringable`

Open vjik opened this issue 10 months ago • 4 comments

https://github.com/yiisoft/db/blob/c5aa0b150aa2ba176a4660049ff6d98a2a92f067/src/Constraint/Constraint.php#L53

object|string|nullStringable|string|null

vjik avatar Aug 08 '23 14:08 vjik

The reason it is like this now is that we've started DB for PHP 7.4 and \Stringable is available only since 8.0.

samdark avatar Aug 08 '23 14:08 samdark

Why should it accept Stringable objects? Just use it as $constraint->name((string) $stringable) and accept string|null $value only

Tigrov avatar Aug 20 '23 10:08 Tigrov

Agree with @Tigrov. Seems, in all cases to name() pass string value.

Moreover. Seems, not need pass null to name(), because this method use for configure constraint once, right?

vjik avatar Sep 26 '23 10:09 vjik

For internal initialization string is enough.

Some class instances are initialized only in the package.

Tigrov avatar Oct 07 '23 05:10 Tigrov