throw type error when incompatible types are passed

This commit is contained in:
Christian Flothmann 2021-01-03 12:58:52 +01:00
parent 5b9e187631
commit 4c5cff6558
2 changed files with 3 additions and 1 deletions

View File

@ -127,7 +127,7 @@ PhpUnitBridge
PropertyAccess
--------------
* Dropped support of a boolean as the first argument of `PropertyAccessor::__construct()`.
* Dropped support for booleans as the first argument of `PropertyAccessor::__construct()`.
Pass a combination of bitwise flags instead.
PropertyInfo

View File

@ -92,6 +92,8 @@ class PropertyAccessor implements PropertyAccessorInterface
trigger_deprecation('symfony/property-access', '5.2', 'Passing a boolean as the first argument to "%s()" is deprecated. Pass a combination of bitwise flags instead (i.e an integer).', __METHOD__);
$magicMethods = ($magicMethods ? self::MAGIC_CALL : 0) | self::MAGIC_GET | self::MAGIC_SET;
} elseif (!\is_int($magicMethods)) {
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be an integer, "%s" given.', __METHOD__, get_debug_type($readInfoExtractor)));
}
$this->magicMethodsFlags = $magicMethods;