Skip to content

Commit 4aff517

Browse files
committed
PHP 7.4 compatibility fixes
1 parent 4411573 commit 4aff517

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/Bridges/DITracy/ContainerPanel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getPanel(): string
6464
$types = [];
6565
foreach ($rc->getMethods() as $method) {
6666
if (preg_match('#^createService(.+)#', $method->getName(), $m) && $method->getReturnType()) {
67-
$types[lcfirst(str_replace('__', '.', $m[1]))] = (string) $method->getReturnType();
67+
$types[lcfirst(str_replace('__', '.', $m[1]))] = $method->getReturnType()->getName();
6868
}
6969
}
7070
$types = $this->getContainerProperty('types') + $types;

src/DI/Container.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function addService(string $name, $service)
7373
}
7474

7575
$type = $service instanceof \Closure
76-
? (string) (new \ReflectionFunction($service))->getReturnType()
76+
? (($tmp = (new \ReflectionFunction($service))->getReturnType()) ? $tmp->getName() : '')
7777
: get_class($service);
7878

7979
if (!isset($this->methods[self::getMethodName($name)])) {
@@ -135,7 +135,8 @@ public function getServiceType(string $name): string
135135
return $this->types[$name];
136136

137137
} elseif (isset($this->methods[$method])) {
138-
return (string) (new \ReflectionMethod($this, $method))->getReturnType();
138+
$type = (new \ReflectionMethod($this, $method))->getReturnType();
139+
return $type ? $type->getName() : '';
139140

140141
} else {
141142
throw new MissingServiceException("Service '$name' not found.");

src/DI/ContainerLoader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private function isExpired(string $file, string &$updatedMeta = null): bool
100100
{
101101
if ($this->autoRebuild) {
102102
$meta = @unserialize((string) file_get_contents("$file.meta")); // @ - file may not exist
103-
$orig = $meta[2];
103+
$orig = $meta[2] ?? null;
104104
return empty($meta[0])
105105
|| DependencyChecker::isExpired(...$meta)
106106
|| ($orig !== $meta[2] && $updatedMeta = serialize($meta));

0 commit comments

Comments
 (0)