Skip to content

Commit df68ae9

Browse files
Merge branch '3.4' into 4.4
* 3.4: [3.4] Fix support for PHP8 union types [PhpUnitBridge] Streamline ansi/no-ansi of composer according to phpunit --colors option [3.4] Small update in our internal terminology [Cache] fix compat with DBAL v3 [VarDumper] Fix CliDumper coloration [DI] tighten detection of local dirs to prevent false positives [FrameworkBundle] preserve dots in query-string when redirecting bumped Symfony version to 3.4.43 updated VERSION for 3.4.42 update CONTRIBUTORS for 3.4.42 updated CHANGELOG for 3.4.42
2 parents a37cc0a + 10d379a commit df68ae9

File tree

4 files changed

+32
-21
lines changed

4 files changed

+32
-21
lines changed

Dumper/PhpDumper.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public function dump(array $options = [])
222222
$regex = preg_quote(\DIRECTORY_SEPARATOR.$dir[$i], '#').$regex;
223223
} while (0 < --$i);
224224

225-
$this->targetDirRegex = '#'.preg_quote($dir[0], '#').$regex.'#';
225+
$this->targetDirRegex = '#(^|file://|[:;, \|\r\n])'.preg_quote($dir[0], '#').$regex.'#';
226226
}
227227
}
228228

@@ -2006,11 +2006,12 @@ private function isSingleUsePrivateNode(ServiceReferenceGraphNode $node): bool
20062006
private function export($value)
20072007
{
20082008
if (null !== $this->targetDirRegex && \is_string($value) && preg_match($this->targetDirRegex, $value, $matches, PREG_OFFSET_CAPTURE)) {
2009-
$prefix = $matches[0][1] ? $this->doExport(substr($value, 0, $matches[0][1]), true).'.' : '';
20102009
$suffix = $matches[0][1] + \strlen($matches[0][0]);
2010+
$matches[0][1] += \strlen($matches[1][0]);
2011+
$prefix = $matches[0][1] ? $this->doExport(substr($value, 0, $matches[0][1]), true).'.' : '';
20112012
$suffix = isset($value[$suffix]) ? '.'.$this->doExport(substr($value, $suffix), true) : '';
20122013
$dirname = $this->asFiles ? '$this->containerDir' : '__DIR__';
2013-
$offset = 1 + $this->targetDirMaxMatches - \count($matches);
2014+
$offset = 2 + $this->targetDirMaxMatches - \count($matches);
20142015

20152016
if (0 < $offset) {
20162017
$dirname = sprintf('\dirname(__DIR__, %d)', $offset + (int) $this->asFiles);

LazyProxy/ProxyHelper.php

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,36 @@ public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionPa
3131
if (!$type) {
3232
return null;
3333
}
34-
if (!\is_string($type)) {
35-
$name = $type->getName();
34+
35+
$types = [];
36+
37+
foreach ($type instanceof \ReflectionUnionType ? $type->getTypes() : [$type] as $type) {
38+
$name = $type instanceof \ReflectionNamedType ? $type->getName() : (string) $type;
3639

3740
if ($type->isBuiltin()) {
38-
return $noBuiltin ? null : $name;
41+
if (!$noBuiltin) {
42+
$types[] = $name;
43+
}
44+
continue;
3945
}
40-
}
41-
$lcName = strtolower($name);
42-
$prefix = $noBuiltin ? '' : '\\';
4346

44-
if ('self' !== $lcName && 'parent' !== $lcName) {
45-
return $prefix.$name;
46-
}
47-
if (!$r instanceof \ReflectionMethod) {
48-
return null;
49-
}
50-
if ('self' === $lcName) {
51-
return $prefix.$r->getDeclaringClass()->name;
47+
$lcName = strtolower($name);
48+
$prefix = $noBuiltin ? '' : '\\';
49+
50+
if ('self' !== $lcName && 'parent' !== $lcName) {
51+
$types[] = '' !== $prefix ? $prefix.$name : $name;
52+
continue;
53+
}
54+
if (!$r instanceof \ReflectionMethod) {
55+
continue;
56+
}
57+
if ('self' === $lcName) {
58+
$types[] = $prefix.$r->getDeclaringClass()->name;
59+
} else {
60+
$types[] = ($parent = $r->getDeclaringClass()->getParentClass()) ? $prefix.$parent->name : null;
61+
}
5262
}
5363

54-
return ($parent = $r->getDeclaringClass()->getParentClass()) ? $prefix.$parent->name : null;
64+
return $types ? implode('|', $types) : null;
5565
}
5666
}

Tests/Dumper/PhpDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function testDumpRelativeDir()
107107

108108
$container = new ContainerBuilder();
109109
$container->setDefinition('test', $definition);
110-
$container->setParameter('foo', 'wiz'.\dirname(__DIR__));
110+
$container->setParameter('foo', 'file://'.\dirname(__DIR__));
111111
$container->setParameter('bar', __DIR__);
112112
$container->setParameter('baz', '%bar%/PhpDumperTest.php');
113113
$container->setParameter('buz', \dirname(__DIR__, 2));

Tests/Fixtures/php/services12.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function getRemovedIds(): array
5656
*/
5757
protected function getTestService()
5858
{
59-
return $this->services['test'] = new \stdClass(('wiz'.\dirname(__DIR__, 1)), [('wiz'.\dirname(__DIR__, 1)) => (\dirname(__DIR__, 2).'/')]);
59+
return $this->services['test'] = new \stdClass(('file://'.\dirname(__DIR__, 1)), [('file://'.\dirname(__DIR__, 1)) => (\dirname(__DIR__, 2).'/')]);
6060
}
6161

6262
public function getParameter($name)
@@ -109,7 +109,7 @@ private function getDynamicParameter(string $name)
109109
protected function getDefaultParameters(): array
110110
{
111111
return [
112-
'foo' => ('wiz'.\dirname(__DIR__, 1)),
112+
'foo' => ('file://'.\dirname(__DIR__, 1)),
113113
'bar' => __DIR__,
114114
'baz' => (__DIR__.'/PhpDumperTest.php'),
115115
'buz' => \dirname(__DIR__, 2),

0 commit comments

Comments
 (0)