fix deprecations on php 8.4+

Mark threshold parameters as explicitly nullable and silence return type
deprecations of ReflectionDecoratedFunction while keeping php 7.1 support.
This commit is contained in:
Kacper Donat 2026-10-25 16:01:51 +01:00
parent fff1013711
commit 12918eb3cb
3 changed files with 53 additions and 3 deletions

View File

@ -23,126 +23,176 @@ class ReflectionDecoratedFunction extends \ReflectionFunction
$this->reflection = reflect($decorated);
}
#[\ReturnTypeWillChange]
public function inNamespace()
{
return $this->reflection->inNamespace();
}
#[\ReturnTypeWillChange]
public function isClosure()
{
return $this->reflection->isVariadic();
}
#[\ReturnTypeWillChange]
public function isDeprecated()
{
return $this->reflection->isDeprecated();
}
#[\ReturnTypeWillChange]
public function isInternal()
{
return $this->reflection->isInternal();
}
#[\ReturnTypeWillChange]
public function isUserDefined()
{
return $this->reflection->isUserDefined();
}
#[\ReturnTypeWillChange]
public function getClosureThis()
{
return $this->reflection->getClosureThis();
}
#[\ReturnTypeWillChange]
public function getClosureScopeClass()
{
return $this->reflection->getClosureScopeClass();
}
#[\ReturnTypeWillChange]
public function getDocComment()
{
return $this->reflection->getDocComment();
}
#[\ReturnTypeWillChange]
public function getEndLine()
{
return $this->reflection->getEndLine();
}
#[\ReturnTypeWillChange]
public function getExtension()
{
return $this->reflection->getExtension();
}
#[\ReturnTypeWillChange]
public function getExtensionName()
{
return $this->reflection->getExtensionName();
}
#[\ReturnTypeWillChange]
public function getFileName()
{
return $this->reflection->getFileName();
}
#[\ReturnTypeWillChange]
public function getName()
{
return $this->reflection->getName();
}
#[\ReturnTypeWillChange]
public function getNamespaceName()
{
return $this->reflection->getNamespaceName();
}
#[\ReturnTypeWillChange]
public function getNumberOfParameters()
{
return $this->reflection->getNumberOfParameters();
}
#[\ReturnTypeWillChange]
public function getNumberOfRequiredParameters()
{
return $this->reflection->getNumberOfRequiredParameters();
}
#[\ReturnTypeWillChange]
public function getParameters()
{
return $this->reflection->getParameters();
}
#[\ReturnTypeWillChange]
public function getReturnType()
{
return $this->reflection->getReturnType();
}
#[\ReturnTypeWillChange]
public function getShortName()
{
return $this->reflection->getShortName();
}
#[\ReturnTypeWillChange]
public function getStartLine()
{
return $this->reflection->getStartLine();
}
#[\ReturnTypeWillChange]
public function getStaticVariables()
{
return $this->reflection->getStaticVariables();
}
#[\ReturnTypeWillChange]
public function hasReturnType()
{
return $this->reflection->hasReturnType();
}
#[\ReturnTypeWillChange]
public function returnsReference()
{
return $this->reflection->returnsReference();
}
#[\ReturnTypeWillChange]
public function isGenerator()
{
return $this->reflection->isGenerator();
}
#[\ReturnTypeWillChange]
public function isVariadic()
{
return $this->reflection->isVariadic();

View File

@ -25,7 +25,7 @@ class CurriedFunction extends PartiallyAppliedFunction
* @param int|null $threshold
* @param array $args
*/
public function __construct(callable $callable, int $threshold = null, ...$args)
public function __construct(callable $callable, ?int $threshold = null, ...$args)
{
parent::__construct($callable, ...$args);
$this->threshold = $threshold ?: reflect($callable)->getNumberOfRequiredParameters();
@ -36,7 +36,7 @@ class CurriedFunction extends PartiallyAppliedFunction
return $this->threshold;
}
public function withThreshold(int $threshold = null)
public function withThreshold(?int $threshold = null)
{
return new static($this, $threshold);
}

View File

@ -47,7 +47,7 @@ function apply(callable $callable, ...$args)
}
}
function curry(callable $callable, int $threshold = null, ...$args): CurriedFunction
function curry(callable $callable, ?int $threshold = null, ...$args): CurriedFunction
{
return new CurriedFunction($callable, $threshold, ...$args);
}