diff --git a/PropertyAccessor.php b/PropertyAccessor.php index 774c2e9..3aabc5d 100644 --- a/PropertyAccessor.php +++ b/PropertyAccessor.php @@ -79,7 +79,7 @@ class PropertyAccessor implements PropertyAccessorInterface * @param int $throw A bitwise combination of the THROW_* constants * to specify when exceptions should be thrown */ - public function __construct(int $magicMethods = self::MAGIC_GET | self::MAGIC_SET, int $throw = self::THROW_ON_INVALID_PROPERTY_PATH, CacheItemPoolInterface $cacheItemPool = null, PropertyReadInfoExtractorInterface $readInfoExtractor = null, PropertyWriteInfoExtractorInterface $writeInfoExtractor = null) + public function __construct(int $magicMethods = self::MAGIC_GET | self::MAGIC_SET, int $throw = self::THROW_ON_INVALID_PROPERTY_PATH, ?CacheItemPoolInterface $cacheItemPool = null, ?PropertyReadInfoExtractorInterface $readInfoExtractor = null, ?PropertyWriteInfoExtractorInterface $writeInfoExtractor = null) { $this->magicMethodsFlags = $magicMethods; $this->ignoreInvalidIndices = 0 === ($throw & self::THROW_ON_INVALID_INDEX); @@ -187,7 +187,7 @@ public function setValue(object|array &$objectOrArray, string|PropertyPathInterf } } - private static function throwInvalidArgumentException(string $message, array $trace, int $i, string $propertyPath, \Throwable $previous = null): void + private static function throwInvalidArgumentException(string $message, array $trace, int $i, string $propertyPath, ?\Throwable $previous = null): void { if (!isset($trace[$i]['file']) || __FILE__ !== $trace[$i]['file']) { return; @@ -662,7 +662,7 @@ private function getPropertyPath(string|PropertyPath $propertyPath): PropertyPat * * @throws \LogicException When the Cache Component isn't available */ - public static function createCache(string $namespace, int $defaultLifetime, string $version, LoggerInterface $logger = null): AdapterInterface + public static function createCache(string $namespace, int $defaultLifetime, string $version, ?LoggerInterface $logger = null): AdapterInterface { if (!class_exists(ApcuAdapter::class)) { throw new \LogicException(sprintf('The Symfony Cache component must be installed to use "%s()".', __METHOD__)); diff --git a/PropertyAccessorBuilder.php b/PropertyAccessorBuilder.php index 5593e31..5dc6e4f 100644 --- a/PropertyAccessorBuilder.php +++ b/PropertyAccessorBuilder.php @@ -226,7 +226,7 @@ public function isExceptionOnInvalidPropertyPath(): bool * * @return $this */ - public function setCacheItemPool(CacheItemPoolInterface $cacheItemPool = null): static + public function setCacheItemPool(?CacheItemPoolInterface $cacheItemPool = null): static { if (1 > \func_num_args()) { trigger_deprecation('symfony/property-access', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__); diff --git a/PropertyPathBuilder.php b/PropertyPathBuilder.php index 7a87eec..e2ac3fe 100644 --- a/PropertyPathBuilder.php +++ b/PropertyPathBuilder.php @@ -21,7 +21,7 @@ class PropertyPathBuilder private array $elements = []; private array $isIndex = []; - public function __construct(PropertyPathInterface|string $path = null) + public function __construct(PropertyPathInterface|string|null $path = null) { if (null !== $path) { $this->append($path); @@ -134,7 +134,7 @@ public function replace(int $offset, int $length, PropertyPathInterface|string $ * * @throws OutOfBoundsException If the offset is invalid */ - public function replaceByIndex(int $offset, string $name = null) + public function replaceByIndex(int $offset, ?string $name = null) { if (!isset($this->elements[$offset])) { throw new OutOfBoundsException(sprintf('The offset "%s" is not within the property path.', $offset)); @@ -154,7 +154,7 @@ public function replaceByIndex(int $offset, string $name = null) * * @throws OutOfBoundsException If the offset is invalid */ - public function replaceByProperty(int $offset, string $name = null) + public function replaceByProperty(int $offset, ?string $name = null) { if (!isset($this->elements[$offset])) { throw new OutOfBoundsException(sprintf('The offset "%s" is not within the property path.', $offset));