fix deprecations in PHP 8
parent
541692bbfe
commit
30f994e424
|
@ -326,13 +326,22 @@ class EventDispatcher
|
||||||
return $event;
|
return $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
$typehint = $reflected->getClass();
|
$expected = null;
|
||||||
|
$isClass = false;
|
||||||
if (!$typehint instanceof \ReflectionClass) {
|
if (\PHP_VERSION_ID >= 70000) {
|
||||||
return $event;
|
$reflectionType = $reflected->getType();
|
||||||
|
if ($reflectionType) {
|
||||||
|
$expected = $reflectionType instanceof \ReflectionNamedType ? $reflectionType->getName() : (string)$reflectionType;
|
||||||
|
$isClass = !$reflectionType->isBuiltin();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$expected = $reflected->getClass() ? $reflected->getClass()->getName() : null;
|
||||||
|
$isClass = null !== $expected;
|
||||||
}
|
}
|
||||||
|
|
||||||
$expected = $typehint->getName();
|
if (!$isClass) {
|
||||||
|
return $event;
|
||||||
|
}
|
||||||
|
|
||||||
// BC support
|
// BC support
|
||||||
if (!$event instanceof $expected && $expected === 'Composer\Script\CommandEvent') {
|
if (!$event instanceof $expected && $expected === 'Composer\Script\CommandEvent') {
|
||||||
|
|
|
@ -127,8 +127,20 @@ class RepositoryManager
|
||||||
|
|
||||||
$reflMethod = new \ReflectionMethod($class, '__construct');
|
$reflMethod = new \ReflectionMethod($class, '__construct');
|
||||||
$params = $reflMethod->getParameters();
|
$params = $reflMethod->getParameters();
|
||||||
if (isset($params[4]) && $params[4]->getClass() && $params[4]->getClass()->getName() === 'Composer\Util\RemoteFilesystem') {
|
if (isset($params[4])) {
|
||||||
return new $class($config, $this->io, $this->config, $this->eventDispatcher, $this->rfs);
|
$paramType = null;
|
||||||
|
if (\PHP_VERSION_ID >= 70000) {
|
||||||
|
$reflectionType = $params[4]->getType();
|
||||||
|
if ($reflectionType) {
|
||||||
|
$paramType = $reflectionType instanceof \ReflectionNamedType ? $reflectionType->getName() : (string)$reflectionType;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$paramType = $params[4]->getClass() ? $params[4]->getClass()->getName() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($paramType === 'Composer\Util\RemoteFilesystem') {
|
||||||
|
return new $class($config, $this->io, $this->config, $this->eventDispatcher, $this->rfs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new $class($config, $this->io, $this->config, $this->eventDispatcher);
|
return new $class($config, $this->io, $this->config, $this->eventDispatcher);
|
||||||
|
|
Loading…
Reference in New Issue