Skip to content

Commit 414ccd0

Browse files
committed
ProxyGenerator: do not generate long file names
1 parent 0a357f1 commit 414ccd0

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

Diff for: src/Proxy/ProxyGenerator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -979,8 +979,8 @@ public function getProxyFileName($className, $baseDirectory = null)
979979
{
980980
$baseDirectory = $baseDirectory ?: $this->proxyDirectory;
981981

982-
return rtrim($baseDirectory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . Proxy::MARKER
983-
. str_replace('\\', '', $className) . '.php';
982+
return rtrim($baseDirectory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . Proxy::MARKER . DIRECTORY_SEPARATOR
983+
. str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php';
984984
}
985985

986986
/**

Diff for: tests/Common/Proxy/ProxyGeneratorTest.php

+32-32
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function testClassWithSleepProxyGeneration()
9999
$this->generateAndRequire($proxyGenerator, $metadata);
100100
}
101101

102-
$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxySleepClass.php');
102+
$classCode = file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/SleepClass.php');
103103
self::assertEquals(1, substr_count($classCode, 'function __sleep'));
104104
self::assertEquals(1, substr_count($classCode, 'parent::__sleep()'));
105105
}
@@ -119,7 +119,7 @@ public function testClassWithStaticPropertyProxyGeneration()
119119
$this->generateAndRequire($proxyGenerator, $metadata);
120120
}
121121

122-
$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyStaticPropertyClass.php');
122+
$classCode = file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/StaticPropertyClass.php');
123123
self::assertEquals(1, substr_count($classCode, 'function __sleep'));
124124
self::assertStringNotContainsString('protectedStaticProperty', $classCode);
125125
}
@@ -141,7 +141,7 @@ public function testClassWithCallableTypeHintOnProxiedMethod()
141141
$this->generateAndRequire($proxyGenerator, $metadata);
142142
}
143143

144-
$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyCallableTypeHintClass.php');
144+
$classCode = file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/CallableTypeHintClass.php');
145145

146146
self::assertEquals(1, substr_count($classCode, 'call(callable $foo)'));
147147
}
@@ -156,7 +156,7 @@ public function testClassWithVariadicArgumentOnProxiedMethod()
156156
$this->generateAndRequire($proxyGenerator, $metadata);
157157
}
158158

159-
$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyVariadicTypeHintClass.php');
159+
$classCode = file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/VariadicTypeHintClass.php');
160160

161161
self::assertEquals(1, substr_count($classCode, 'function addType(...$types)'));
162162
self::assertEquals(1, substr_count($classCode, '__invoke($this, \'addType\', [$types])'));
@@ -173,7 +173,7 @@ public function testClassWithScalarTypeHintsOnProxiedMethods()
173173
$this->generateAndRequire($proxyGenerator, $metadata);
174174
}
175175

176-
$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyScalarTypeHintsClass.php');
176+
$classCode = file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/ScalarTypeHintsClass.php');
177177

178178
self::assertEquals(1, substr_count($classCode, 'function singleTypeHint(string $param)'));
179179
self::assertEquals(1, substr_count($classCode, 'function multipleTypeHints(int $a, float $b, bool $c, string $d)'));
@@ -193,7 +193,7 @@ public function testClassWithReturnTypesOnProxiedMethods()
193193
$this->generateAndRequire($proxyGenerator, $metadata);
194194
}
195195

196-
$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyReturnTypesClass.php');
196+
$classCode = file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/ReturnTypesClass.php');
197197

198198
self::assertEquals(1, substr_count($classCode, 'function returnsClass(): \stdClass'));
199199
self::assertEquals(1, substr_count($classCode, 'function returnsScalar(): int'));
@@ -214,7 +214,7 @@ public function testClassWithNullableTypeHintsOnProxiedMethods()
214214
$this->generateAndRequire($proxyGenerator, $metadata);
215215
}
216216

217-
$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyNullableTypeHintsClass.php');
217+
$classCode = file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/NullableTypeHintsClass.php');
218218

219219
self::assertEquals(1, substr_count($classCode, 'function nullableTypeHintInt(?int $param)'));
220220
self::assertEquals(1, substr_count($classCode, 'function nullableTypeHintObject(?\stdClass $param)'));
@@ -234,7 +234,7 @@ public function testClassWithNullableReturnTypesOnProxiedMethods()
234234
$this->generateAndRequire($proxyGenerator, $metadata);
235235
}
236236

237-
$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyNullableTypeHintsClass.php');
237+
$classCode = file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/NullableTypeHintsClass.php');
238238

239239
self::assertEquals(1, substr_count($classCode, 'function returnsNullableInt(): ?int'));
240240
self::assertEquals(1, substr_count($classCode, 'function returnsNullableObject(): ?\stdClass'));
@@ -260,12 +260,12 @@ public function testClassWithNullableOptionalNonLastParameterOnProxiedMethods()
260260

261261
self::assertStringContainsString(
262262
'public function midSignatureNullableParameter(\stdClass $param = NULL, $secondParam)',
263-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyNullableNonOptionalHintClass.php')
263+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/NullableNonOptionalHintClass.php')
264264
);
265265

266266
self::assertStringContainsString(
267267
'public function midSignatureNotNullableHintedParameter(string $param = \'foo\', $secondParam)',
268-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyNullableNonOptionalHintClass.php')
268+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/NullableNonOptionalHintClass.php')
269269
);
270270
}
271271

@@ -288,13 +288,13 @@ public function testClassWithPhp71NullableOptionalNonLastParameterOnProxiedMetho
288288

289289
self::assertStringContainsString(
290290
'public function midSignatureNullableParameter(string $param = NULL, $secondParam)',
291-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPhp71NullableDefaultedNonOptionalHintClass.php'),
291+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/Php71NullableDefaultedNonOptionalHintClass.php'),
292292
'Signature allows nullable type, although explicit "?" marker isn\'t used in the proxy'
293293
);
294294

295295
self::assertStringContainsString(
296296
'public function midSignatureNotNullableHintedParameter(?string $param = \'foo\', $secondParam)',
297-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPhp71NullableDefaultedNonOptionalHintClass.php')
297+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/Php71NullableDefaultedNonOptionalHintClass.php')
298298
);
299299
}
300300

@@ -308,7 +308,7 @@ public function testClassWithVoidReturnType()
308308
$this->generateAndRequire($proxyGenerator, $metadata);
309309
}
310310

311-
$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyVoidReturnTypeClass.php');
311+
$classCode = file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/VoidReturnTypeClass.php');
312312

313313
self::assertEquals(1, substr_count($classCode, 'function returnsVoid(): void'));
314314
}
@@ -323,7 +323,7 @@ public function testClassWithIterableTypeHint()
323323
$this->generateAndRequire($proxyGenerator, $metadata);
324324
}
325325

326-
$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyIterableTypeHintClass.php');
326+
$classCode = file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/IterableTypeHintClass.php');
327327

328328
self::assertEquals(1, substr_count($classCode, 'function parameterType(iterable $param)'));
329329
self::assertEquals(1, substr_count($classCode, 'function returnType(): iterable'));
@@ -433,7 +433,7 @@ public function testPhp8CloneWithVoidReturnType()
433433

434434
self::assertStringContainsString(
435435
'public function __clone(): void',
436-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPhp8MagicCloneClass.php')
436+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/Php8MagicCloneClass.php')
437437
);
438438
}
439439

@@ -453,12 +453,12 @@ public function testPhp8UnionTypes()
453453

454454
self::assertStringContainsString(
455455
'setValue(\stdClass|array $value): float|bool',
456-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPhp8UnionTypes.php')
456+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/Php8UnionTypes.php')
457457
);
458458

459459
self::assertStringContainsString(
460460
'setNullableValue(\stdClass|array|null $value): float|bool|null',
461-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPhp8UnionTypes.php')
461+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/Php8UnionTypes.php')
462462
);
463463
}
464464

@@ -478,7 +478,7 @@ public function testPhp8MixedType()
478478

479479
self::assertStringContainsString(
480480
'foo(mixed $bar): mixed',
481-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPhp8MixedType.php')
481+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/Php8MixedType.php')
482482
);
483483
}
484484

@@ -498,12 +498,12 @@ public function testPhp8StaticType()
498498

499499
self::assertStringContainsString(
500500
'foo(mixed $bar): static',
501-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPhp8StaticType.php')
501+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/Php8StaticType.php')
502502
);
503503

504504
self::assertStringContainsString(
505505
'fooNull(mixed $bar): ?static',
506-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPhp8StaticType.php')
506+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/Php8StaticType.php')
507507
);
508508
}
509509

@@ -523,7 +523,7 @@ public function testPhp81IntersectionType()
523523

524524
self::assertStringContainsString(
525525
'setFoo(\Traversable&\Countable $foo): \Traversable&\Countable',
526-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81IntersectionTypes.php')
526+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/PHP81IntersectionTypes.php')
527527
);
528528
}
529529

@@ -543,17 +543,17 @@ public function testPhp81NeverType()
543543

544544
self::assertStringContainsString(
545545
'__get($name): never',
546-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NeverType.php')
546+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/PHP81NeverType.php')
547547
);
548548

549549
self::assertStringContainsString(
550550
'__set($name, $value): never',
551-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NeverType.php')
551+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/PHP81NeverType.php')
552552
);
553553

554554
self::assertStringContainsString(
555555
'finishHim(): never',
556-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NeverType.php')
556+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/PHP81NeverType.php')
557557
);
558558
}
559559

@@ -575,7 +575,7 @@ public function testEnumDefaultInPublicProperty() : void
575575

576576
$this->assertStringContainsString(
577577
'use Doctrine;',
578-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPhp81EnumPublicPropertyType.php')
578+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/Php81EnumPublicPropertyType.php')
579579
);
580580

581581
$object = new \Doctrine\Tests\Common\ProxyProxy\__CG__\Doctrine\Tests\Common\Proxy\Php81EnumPublicPropertyType();
@@ -600,37 +600,37 @@ public function testPhp81NewInInitializers()
600600

601601
self::assertStringContainsString(
602602
'onlyInitializer($foo = new \stdClass()): void',
603-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NewInInitializers.php')
603+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/PHP81NewInInitializers.php')
604604
);
605605

606606
self::assertStringContainsString(
607607
'typed(\DateTimeInterface $foo = new \DateTimeImmutable(\'now\')): void',
608-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NewInInitializers.php')
608+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/PHP81NewInInitializers.php')
609609
);
610610

611611
self::assertStringContainsString(
612612
'arrayInDefault(array $foo = [new \DateTimeImmutable(\'2022-08-22 16:20\', new \DateTimeZone(\'Europe/Warsaw\'))]): void',
613-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NewInInitializers.php')
613+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/PHP81NewInInitializers.php')
614614
);
615615

616616
self::assertStringContainsString(
617617
'scalarConstInDefault(string $foo = \'foo\'): void',
618-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NewInInitializers.php')
618+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/PHP81NewInInitializers.php')
619619
);
620620

621621
self::assertStringContainsString(
622622
'constInDefault(array $foo = \Doctrine\Tests\Common\Util\TestAsset\ConstProvider::FOO): void',
623-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NewInInitializers.php')
623+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/PHP81NewInInitializers.php')
624624
);
625625

626626
self::assertStringContainsString(
627627
"globalEolInDefault(string \$foo = '\n'): void",
628-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NewInInitializers.php')
628+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/PHP81NewInInitializers.php')
629629
);
630630

631631
self::assertStringContainsString(
632632
"specialCharacterInDefault(string \$foo = '\n'): void",
633-
file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyPHP81NewInInitializers.php')
633+
file_get_contents(__DIR__ . '/generated/__CG__/Doctrine/Tests/Common/Proxy/PHP81NewInInitializers.php')
634634
);
635635
}
636636

0 commit comments

Comments
 (0)