diff --git a/test/Transpiler/Monomorphize/ArraySugarIntegrationTest.php b/test/Transpiler/Monomorphize/ArraySugarIntegrationTest.php index f6c328d..3f8c7d1 100644 --- a/test/Transpiler/Monomorphize/ArraySugarIntegrationTest.php +++ b/test/Transpiler/Monomorphize/ArraySugarIntegrationTest.php @@ -41,8 +41,8 @@ public function testCollectionWithArraySugarSpecializesToArray(): void $this->compile(); $fqn = Registry::generatedFqn( - 'App\\Containers\\Collection', - [new TypeRef('App\\Models\\User')], + 'App\\ArraySugar\\Containers\\Collection', + [new TypeRef('App\\ArraySugar\\Models\\User')], ); $file = $this->fqnToPath($fqn); self::assertFileExists($file); @@ -51,12 +51,12 @@ public function testCollectionWithArraySugarSpecializesToArray(): void self::assertStringContainsString('private array $items', $content, 'T[] property must lower to `array`'); self::assertStringContainsString('public function all(): array', $content, 'T[] return type must lower to `array`'); self::assertStringContainsString( - 'public function first(): ?\\App\\Models\\User', + 'public function first(): ?\\App\\ArraySugar\\Models\\User', $content, '?T return type must specialize to ?', ); self::assertStringContainsString( - 'public function __construct(\\App\\Models\\User ...$items)', + 'public function __construct(\\App\\ArraySugar\\Models\\User ...$items)', $content, 'variadic T must specialize to ', ); @@ -85,8 +85,8 @@ public function testRuntimeNullableReturnEnforcesConcreteType(): void $this->compile(); $fqn = Registry::generatedFqn( - 'App\\Containers\\Collection', - [new TypeRef('App\\Models\\User')], + 'App\\ArraySugar\\Containers\\Collection', + [new TypeRef('App\\ArraySugar\\Models\\User')], ); $collectionFile = $this->fqnToPath($fqn); @@ -98,10 +98,10 @@ public function testRuntimeNullableReturnEnforcesConcreteType(): void require '{$this->targetDir}/Containers/Collection.php'; require '{$collectionFile}'; - \$c = new \\{$fqn}(new \\App\\Models\\User('alice'), new \\App\\Models\\User('bob')); + \$c = new \\{$fqn}(new \\App\\ArraySugar\\Models\\User('alice'), new \\App\\ArraySugar\\Models\\User('bob')); \$first = \$c->first(); - echo \$first instanceof \\App\\Models\\User ? "FIRST_OK" : "FIRST_BAD"; + echo \$first instanceof \\App\\ArraySugar\\Models\\User ? "FIRST_OK" : "FIRST_BAD"; echo "\\n"; \$all = \$c->all(); @@ -127,7 +127,7 @@ public function testRuntimeNullableReturnEnforcesConcreteType(): void self::assertSame('FIRST_OK', $output[0]); self::assertSame('ALL_OK', $output[1]); self::assertSame('EMPTY_NULL_OK', $output[2]); - self::assertSame('App\\Models\\User', $output[3]); + self::assertSame('App\\ArraySugar\\Models\\User', $output[3]); self::assertSame('NULLABLE_OK', $output[4]); } diff --git a/test/Transpiler/Monomorphize/BoundedGenericIntegrationTest.php b/test/Transpiler/Monomorphize/BoundedGenericIntegrationTest.php index a291ffc..3ee2b30 100644 --- a/test/Transpiler/Monomorphize/BoundedGenericIntegrationTest.php +++ b/test/Transpiler/Monomorphize/BoundedGenericIntegrationTest.php @@ -44,12 +44,12 @@ public function testBoundIsSatisfiedByImplementingClass(): void $result = $compiler->compile($sources, $sourceDir, $this->targetDir, $this->cacheDir); - $boxFqn = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Tag')]); + $boxFqn = Registry::generatedFqn('App\\BoundsHappy\\Containers\\Box', [new TypeRef('App\\BoundsHappy\\Models\\Tag')]); $boxFile = $this->fqnToPath($boxFqn); self::assertFileExists($boxFile, 'Box must specialize when Tag implements \\Stringable (bound satisfied via hierarchy)'); $content = file_get_contents($boxFile); - self::assertStringContainsString('public \\App\\Models\\Tag $item', $content); + self::assertStringContainsString('public \\App\\BoundsHappy\\Models\\Tag $item', $content); self::assertGreaterThan(0, $result->generatedCount); } diff --git a/test/Transpiler/Monomorphize/CompilerIntegrationTest.php b/test/Transpiler/Monomorphize/CompilerIntegrationTest.php index c1b58eb..414b3a5 100644 --- a/test/Transpiler/Monomorphize/CompilerIntegrationTest.php +++ b/test/Transpiler/Monomorphize/CompilerIntegrationTest.php @@ -48,8 +48,8 @@ public function testCompilesGenericFixtureEndToEnd(): void self::assertSame(5, $result->sourceCount, 'expected 5 source .xphp files (4 top-level + 1 in sub/)'); self::assertSame(2, $result->generatedCount, 'expected 2 specializations (Box, Box)'); - $boxPlasticFqn = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); - $boxMetalFqn = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Metal')]); + $boxPlasticFqn = Registry::generatedFqn('App\\BoxGeneric\\Containers\\Box', [new TypeRef('App\\BoxGeneric\\Models\\Plastic')]); + $boxMetalFqn = Registry::generatedFqn('App\\BoxGeneric\\Containers\\Box', [new TypeRef('App\\BoxGeneric\\Models\\Metal')]); $boxPlasticFile = $this->fqnToPath($boxPlasticFqn); $boxMetalFile = $this->fqnToPath($boxMetalFqn); @@ -58,11 +58,11 @@ public function testCompilesGenericFixtureEndToEnd(): void $boxPlasticContent = file_get_contents($boxPlasticFile); self::assertStringContainsString('declare (strict_types=1)', $boxPlasticContent, 'specialized class must opt in to strict types'); - self::assertStringContainsString('namespace XPHP\\Generated\\App\\Containers\\Box', $boxPlasticContent); + self::assertStringContainsString('namespace XPHP\\Generated\\App\\BoxGeneric\\Containers\\Box', $boxPlasticContent); self::assertStringContainsString('class ' . self::shortName($boxPlasticFqn), $boxPlasticContent); - self::assertStringContainsString('public \\App\\Models\\Plastic $item', $boxPlasticContent); - self::assertStringContainsString('public function set(\\App\\Models\\Plastic $val)', $boxPlasticContent); - self::assertStringContainsString('public function get(): \\App\\Models\\Plastic', $boxPlasticContent); + self::assertStringContainsString('public \\App\\BoxGeneric\\Models\\Plastic $item', $boxPlasticContent); + self::assertStringContainsString('public function set(\\App\\BoxGeneric\\Models\\Plastic $val)', $boxPlasticContent); + self::assertStringContainsString('public function get(): \\App\\BoxGeneric\\Models\\Plastic', $boxPlasticContent); $useFile = $this->targetDir . '/Use.php'; self::assertFileExists($useFile); @@ -121,20 +121,20 @@ public function testGeneratedCodeIsLoadableViaPsr4Autoloader(): void // without explicit require statements // -> reflection on the specialized class reports the real concrete type $loader = new \Composer\Autoload\ClassLoader(); - $loader->addPsr4('App\\', $this->targetDir); + $loader->addPsr4('App\\BoxGeneric\\', $this->targetDir); $loader->addPsr4(Registry::GENERATED_NAMESPACE_PREFIX . '\\', $this->cacheDir . '/Generated'); $loader->register(); try { - self::assertTrue(class_exists('App\\Models\\Plastic'), 'user class App\\Models\\Plastic must autoload from the PSR-4 target dir'); + self::assertTrue(class_exists('App\\BoxGeneric\\Models\\Plastic'), 'user class App\\BoxGeneric\\Models\\Plastic must autoload from the PSR-4 target dir'); - $boxPlasticFqn = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); + $boxPlasticFqn = Registry::generatedFqn('App\\BoxGeneric\\Containers\\Box', [new TypeRef('App\\BoxGeneric\\Models\\Plastic')]); self::assertTrue(class_exists($boxPlasticFqn), "specialized class {$boxPlasticFqn} must autoload from the PSR-4 cache dir"); // Confirm the autoloaded specialized class carries the real concrete type on its property. $type = (new \ReflectionProperty($boxPlasticFqn, 'item'))->getType(); self::assertInstanceOf(\ReflectionNamedType::class, $type); - self::assertSame('App\\Models\\Plastic', $type->getName()); + self::assertSame('App\\BoxGeneric\\Models\\Plastic', $type->getName()); } finally { $loader->unregister(); } @@ -149,13 +149,13 @@ public function testInstanceofAgainstOriginalTemplateMatchesAllSpecializations() $compiler->compile($sources, $this->sourceDir, $this->targetDir, $this->cacheDir); $loader = new \Composer\Autoload\ClassLoader(); - $loader->addPsr4('App\\', $this->targetDir); + $loader->addPsr4('App\\BoxGeneric\\', $this->targetDir); $loader->addPsr4(Registry::GENERATED_NAMESPACE_PREFIX . '\\', $this->cacheDir . '/Generated'); $loader->register(); try { - $boxPlasticFqn = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); - $boxMetalFqn = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Metal')]); + $boxPlasticFqn = Registry::generatedFqn('App\\BoxGeneric\\Containers\\Box', [new TypeRef('App\\BoxGeneric\\Models\\Plastic')]); + $boxMetalFqn = Registry::generatedFqn('App\\BoxGeneric\\Containers\\Box', [new TypeRef('App\\BoxGeneric\\Models\\Metal')]); // Use reflection rather than `new $fqn()` to avoid coupling this test to whether // the box_generic Box template happens to declare a constructor at any given @@ -166,11 +166,11 @@ public function testInstanceofAgainstOriginalTemplateMatchesAllSpecializations() // Both specializations satisfy `instanceof OriginalTemplate` via the // marker interface emitted at the original FQN. - self::assertTrue($plasticRefl->implementsInterface('App\\Containers\\Box')); - self::assertTrue($metalRefl->implementsInterface('App\\Containers\\Box')); + self::assertTrue($plasticRefl->implementsInterface('App\\BoxGeneric\\Containers\\Box')); + self::assertTrue($metalRefl->implementsInterface('App\\BoxGeneric\\Containers\\Box')); // And reflection sees the marker as an interface, not the old class. - $r = new \ReflectionClass('App\\Containers\\Box'); + $r = new \ReflectionClass('App\\BoxGeneric\\Containers\\Box'); self::assertTrue($r->isInterface(), 'original generic class FQN must now be the marker interface'); } finally { $loader->unregister(); diff --git a/test/Transpiler/Monomorphize/GenericFunctionIntegrationTest.php b/test/Transpiler/Monomorphize/GenericFunctionIntegrationTest.php index dcc017d..8446d3e 100644 --- a/test/Transpiler/Monomorphize/GenericFunctionIntegrationTest.php +++ b/test/Transpiler/Monomorphize/GenericFunctionIntegrationTest.php @@ -62,7 +62,7 @@ public function testFunctionCallSitesAreRewrittenToMangledFqnNames(): void self::assertFileExists($usePath); $content = file_get_contents($usePath); - self::assertSame(2, preg_match_all('/\\\\App\\\\identity_T_[0-9a-f]+\(/', $content)); + self::assertSame(2, preg_match_all('/\\\\App\\\\GenericFunction\\\\identity_T_[0-9a-f]+\(/', $content)); self::assertStringNotContainsString('identity<', $content); } @@ -85,7 +85,7 @@ public function testRuntimeExecutionOfSpecializedFunctions(): void foreach (\$m[1] as \$i => \$mangled) { \$type = \$m[2][\$i]; \$sample = \$type === 'int' ? 42 : 'hi'; - \$fqn = '\\\\App\\\\' . \$mangled; + \$fqn = '\\\\App\\\\GenericFunction\\\\' . \$mangled; \$out = \$fqn(\$sample); \$expected = \$type === 'int' ? 'integer' : 'string'; echo gettype(\$out) === \$expected ? "OK_{\$type}" : "BAD_{\$type}", "\\n"; diff --git a/test/Transpiler/Monomorphize/GenericInterfaceIntegrationTest.php b/test/Transpiler/Monomorphize/GenericInterfaceIntegrationTest.php index 650e6a3..d0af166 100644 --- a/test/Transpiler/Monomorphize/GenericInterfaceIntegrationTest.php +++ b/test/Transpiler/Monomorphize/GenericInterfaceIntegrationTest.php @@ -41,12 +41,12 @@ public function testGenericInterfaceSpecializesAndIsImplementedBySpecializedClas $this->compile(); $ifaceFqn = Registry::generatedFqn( - 'App\\Containers\\Container', - [new TypeRef('App\\Models\\Plastic')], + 'App\\GenericInterface\\Containers\\Container', + [new TypeRef('App\\GenericInterface\\Models\\Plastic')], ); $boxFqn = Registry::generatedFqn( - 'App\\Containers\\Box', - [new TypeRef('App\\Models\\Plastic')], + 'App\\GenericInterface\\Containers\\Box', + [new TypeRef('App\\GenericInterface\\Models\\Plastic')], ); $ifaceFile = $this->fqnToPath($ifaceFqn); @@ -56,7 +56,7 @@ public function testGenericInterfaceSpecializesAndIsImplementedBySpecializedClas $ifaceContent = file_get_contents($ifaceFile); self::assertStringContainsString('interface ' . self::shortName($ifaceFqn), $ifaceContent, 'specialized declaration must remain an interface'); - self::assertStringContainsString('public function get(): \\App\\Models\\Plastic', $ifaceContent, 'T return type must be substituted in the interface signature'); + self::assertStringContainsString('public function get(): \\App\\GenericInterface\\Models\\Plastic', $ifaceContent, 'T return type must be substituted in the interface signature'); $boxContent = file_get_contents($boxFile); self::assertStringContainsString('class ' . self::shortName($boxFqn), $boxContent); @@ -80,29 +80,24 @@ public function testGenericInterfaceTemplateIsReplacedByEmptyMarkerInOutput(): v public function testSpecializedClassIsInstanceOfOriginalInterfaceMarker(): void { - // F3 from the review: `$x instanceof App\Containers\Container` must hold for the - // specialized Box, traveling the chain - // Box_ implements Container_ extends App\Containers\Container. + // F3 from the review: `$x instanceof App\GenericInterface\Containers\Container` + // must hold for the specialized Box, traveling the chain + // Box_ implements Container_ extends App\GenericInterface\Containers\Container. // This is the marker-interface contract (item 5) applied to the interface case. - // - // Polymer is fixture-unique (see Models/Polymer.xphp) to avoid PHP's process-wide - // class-table cache returning a Box body loaded by an earlier integration - // test (multiple fixtures specialize Box at the same hash but only this - // one's body implements Container). $this->compile(); $loader = new \Composer\Autoload\ClassLoader(); - $loader->addPsr4('App\\', $this->targetDir); + $loader->addPsr4('App\\GenericInterface\\', $this->targetDir); $loader->addPsr4(Registry::GENERATED_NAMESPACE_PREFIX . '\\', $this->cacheDir . '/Generated'); $loader->register(); try { - $boxFqn = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Polymer')]); - $box = new $boxFqn(new \App\Models\Polymer('PET')); + $boxFqn = Registry::generatedFqn('App\\GenericInterface\\Containers\\Box', [new TypeRef('App\\GenericInterface\\Models\\Polymer')]); + $box = new $boxFqn(new \App\GenericInterface\Models\Polymer('PET')); - self::assertInstanceOf('App\\Containers\\Container', $box, 'specialized Box must transitively satisfy the original Container interface marker'); + self::assertInstanceOf('App\\GenericInterface\\Containers\\Container', $box, 'specialized Box must transitively satisfy the original Container interface marker'); - $r = new \ReflectionClass('App\\Containers\\Container'); + $r = new \ReflectionClass('App\\GenericInterface\\Containers\\Container'); self::assertTrue($r->isInterface(), 'original generic interface FQN must now be the marker interface'); } finally { $loader->unregister(); @@ -114,12 +109,12 @@ public function testSpecializedClassIsInstanceOfSpecializedInterfaceAtRuntime(): $this->compile(); $ifaceFqn = Registry::generatedFqn( - 'App\\Containers\\Container', - [new TypeRef('App\\Models\\Plastic')], + 'App\\GenericInterface\\Containers\\Container', + [new TypeRef('App\\GenericInterface\\Models\\Plastic')], ); $boxFqn = Registry::generatedFqn( - 'App\\Containers\\Box', - [new TypeRef('App\\Models\\Plastic')], + 'App\\GenericInterface\\Containers\\Box', + [new TypeRef('App\\GenericInterface\\Models\\Plastic')], ); $ifaceFile = $this->fqnToPath($ifaceFqn); @@ -135,7 +130,7 @@ public function testSpecializedClassIsInstanceOfSpecializedInterfaceAtRuntime(): require '{$ifaceFile}'; require '{$boxFile}'; - \$box = new \\{$boxFqn}(new \\App\\Models\\Plastic('red')); + \$box = new \\{$boxFqn}(new \\App\\GenericInterface\\Models\\Plastic('red')); echo \$box instanceof \\{$ifaceFqn} ? "INSTANCEOF_OK" : "INSTANCEOF_BAD"; echo "\\n"; echo \$box->get()->color === 'red' ? "GET_OK" : "GET_BAD"; @@ -153,7 +148,7 @@ public function testSpecializedClassIsInstanceOfSpecializedInterfaceAtRuntime(): self::assertSame(0, $exit, "runtime check failed:\n" . implode("\n", $output)); self::assertSame('INSTANCEOF_OK', $output[0]); self::assertSame('GET_OK', $output[1]); - self::assertSame('App\\Models\\Plastic', $output[2]); + self::assertSame('App\\GenericInterface\\Models\\Plastic', $output[2]); } public function testAllOutputFilesAreSyntacticallyValid(): void diff --git a/test/Transpiler/Monomorphize/GenericMethodIntegrationTest.php b/test/Transpiler/Monomorphize/GenericMethodIntegrationTest.php index eedf922..9f5086f 100644 --- a/test/Transpiler/Monomorphize/GenericMethodIntegrationTest.php +++ b/test/Transpiler/Monomorphize/GenericMethodIntegrationTest.php @@ -65,7 +65,7 @@ public function testCallSitesAreRewrittenToMangledNames(): void $content = file_get_contents($usePath); // Three call sites (2 int + 1 string), all rewritten to fully-qualified mangled refs. - self::assertSame(3, preg_match_all('/\\\\App\\\\Util::identity_T_[0-9a-f]+\\(/', $content)); + self::assertSame(3, preg_match_all('/\\\\App\\\\GenericMethod\\\\Util::identity_T_[0-9a-f]+\\(/', $content)); // The two int call sites must share the same mangled name (single specialization // per unique arg list, not per call site — locks the alreadyGenerated dedupe). \preg_match_all('/identity_T_([0-9a-f]+)/', $content, $matches); @@ -91,7 +91,7 @@ public function testRuntimeExecutionPreservesGenericMethodSemantics(): void declare(strict_types=1); require '{$utilPath}'; - \$asInt = \\App\\Util::identity_T_FILLED_AT_RUNTIME(42); + \$asInt = \\App\\GenericMethod\\Util::identity_T_FILLED_AT_RUNTIME(42); PHP); // Pull the mangled FQNs out of Util.php and call them directly. We assert each @@ -104,7 +104,7 @@ public function testRuntimeExecutionPreservesGenericMethodSemantics(): void $type = $matches[2][$i]; $sample = $type === 'int' ? '42' : "'hello'"; $expected = $gettypeName[$type]; - $script .= "\$out{$i} = \\App\\Util::{$mangled}({$sample});\n"; + $script .= "\$out{$i} = \\App\\GenericMethod\\Util::{$mangled}({$sample});\n"; $script .= "echo gettype(\$out{$i}) === '{$expected}' ? 'OK_{$type}' : 'BAD_{$type}', \"\\n\";\n"; } file_put_contents($runScript, $script); diff --git a/test/Transpiler/Monomorphize/MultiTypeGenericsIntegrationTest.php b/test/Transpiler/Monomorphize/MultiTypeGenericsIntegrationTest.php index 0e02417..12c4a53 100644 --- a/test/Transpiler/Monomorphize/MultiTypeGenericsIntegrationTest.php +++ b/test/Transpiler/Monomorphize/MultiTypeGenericsIntegrationTest.php @@ -41,15 +41,15 @@ public function testDistinctTwoClassParamsGenerateSpecialization(): void $this->compile(); $pairUserPlasticFqn = Registry::generatedFqn( - 'App\\Containers\\Pair', - [new TypeRef('App\\Models\\User'), new TypeRef('App\\Models\\Plastic')], + 'App\\MultiType\\Containers\\Pair', + [new TypeRef('App\\MultiType\\Models\\User'), new TypeRef('App\\MultiType\\Models\\Plastic')], ); $file = $this->fqnToPath($pairUserPlasticFqn); self::assertFileExists($file); $content = file_get_contents($file); - self::assertStringContainsString('public \\App\\Models\\User $first', $content); - self::assertStringContainsString('public \\App\\Models\\Plastic $second', $content); + self::assertStringContainsString('public \\App\\MultiType\\Models\\User $first', $content); + self::assertStringContainsString('public \\App\\MultiType\\Models\\Plastic $second', $content); } public function testSameClassUsedForBothParamsStillGeneratesOneSpecialization(): void @@ -57,15 +57,15 @@ public function testSameClassUsedForBothParamsStillGeneratesOneSpecialization(): $this->compile(); $pairPlasticPlasticFqn = Registry::generatedFqn( - 'App\\Containers\\Pair', - [new TypeRef('App\\Models\\Plastic'), new TypeRef('App\\Models\\Plastic')], + 'App\\MultiType\\Containers\\Pair', + [new TypeRef('App\\MultiType\\Models\\Plastic'), new TypeRef('App\\MultiType\\Models\\Plastic')], ); $file = $this->fqnToPath($pairPlasticPlasticFqn); self::assertFileExists($file); $content = file_get_contents($file); - self::assertStringContainsString('public \\App\\Models\\Plastic $first', $content); - self::assertStringContainsString('public \\App\\Models\\Plastic $second', $content); + self::assertStringContainsString('public \\App\\MultiType\\Models\\Plastic $first', $content); + self::assertStringContainsString('public \\App\\MultiType\\Models\\Plastic $second', $content); } public function testMixedScalarAndScalarParams(): void @@ -73,7 +73,7 @@ public function testMixedScalarAndScalarParams(): void $this->compile(); $mapFqn = Registry::generatedFqn( - 'App\\Containers\\Map', + 'App\\MultiType\\Containers\\Map', [ new TypeRef('string', isScalar: true), new TypeRef('int', isScalar: true), @@ -91,8 +91,8 @@ public function testMixedScalarAndScalarParams(): void public function testParamOrderMattersForHash(): void { // Pair and Pair must be different specializations. - $a = Registry::generatedFqn('App\\Containers\\Pair', [new TypeRef('App\\Models\\User'), new TypeRef('App\\Models\\Plastic')]); - $b = Registry::generatedFqn('App\\Containers\\Pair', [new TypeRef('App\\Models\\Plastic'), new TypeRef('App\\Models\\User')]); + $a = Registry::generatedFqn('App\\MultiType\\Containers\\Pair', [new TypeRef('App\\MultiType\\Models\\User'), new TypeRef('App\\MultiType\\Models\\Plastic')]); + $b = Registry::generatedFqn('App\\MultiType\\Containers\\Pair', [new TypeRef('App\\MultiType\\Models\\Plastic'), new TypeRef('App\\MultiType\\Models\\User')]); self::assertNotSame($a, $b); $this->compile(); @@ -109,8 +109,8 @@ public function testSwapReturnTypeIsTransitivelyDiscovered(): void $registry = json_decode(file_get_contents($this->cacheDir . '/registry.json'), true); $fqns = array_column($registry['instantiations'], 'generatedFqn'); - $userPlastic = Registry::generatedFqn('App\\Containers\\Pair', [new TypeRef('App\\Models\\User'), new TypeRef('App\\Models\\Plastic')]); - $plasticUser = Registry::generatedFqn('App\\Containers\\Pair', [new TypeRef('App\\Models\\Plastic'), new TypeRef('App\\Models\\User')]); + $userPlastic = Registry::generatedFqn('App\\MultiType\\Containers\\Pair', [new TypeRef('App\\MultiType\\Models\\User'), new TypeRef('App\\MultiType\\Models\\Plastic')]); + $plasticUser = Registry::generatedFqn('App\\MultiType\\Containers\\Pair', [new TypeRef('App\\MultiType\\Models\\Plastic'), new TypeRef('App\\MultiType\\Models\\User')]); self::assertContains($userPlastic, $fqns, 'expected the explicit Pair'); self::assertContains($plasticUser, $fqns, 'expected transitive Pair from swap() return type'); @@ -121,27 +121,27 @@ public function testDeeplyNestedMultiTypeArgs(): void // Pair, Pair> — both args are themselves multi-type generics. $this->compile(); - $mapStringInt = new TypeRef('App\\Containers\\Map', [ + $mapStringInt = new TypeRef('App\\MultiType\\Containers\\Map', [ new TypeRef('string', isScalar: true), new TypeRef('int', isScalar: true), ]); - $pairPlasticUser = new TypeRef('App\\Containers\\Pair', [ - new TypeRef('App\\Models\\Plastic'), - new TypeRef('App\\Models\\User'), + $pairPlasticUser = new TypeRef('App\\MultiType\\Containers\\Pair', [ + new TypeRef('App\\MultiType\\Models\\Plastic'), + new TypeRef('App\\MultiType\\Models\\User'), ]); - $outerFqn = Registry::generatedFqn('App\\Containers\\Pair', [$mapStringInt, $pairPlasticUser]); + $outerFqn = Registry::generatedFqn('App\\MultiType\\Containers\\Pair', [$mapStringInt, $pairPlasticUser]); $file = $this->fqnToPath($outerFqn); self::assertFileExists($file, "expected deeply-nested specialization at {$file}"); $content = file_get_contents($file); - $innerMapFqn = Registry::generatedFqn('App\\Containers\\Map', [ + $innerMapFqn = Registry::generatedFqn('App\\MultiType\\Containers\\Map', [ new TypeRef('string', isScalar: true), new TypeRef('int', isScalar: true), ]); - $innerPairFqn = Registry::generatedFqn('App\\Containers\\Pair', [ - new TypeRef('App\\Models\\Plastic'), - new TypeRef('App\\Models\\User'), + $innerPairFqn = Registry::generatedFqn('App\\MultiType\\Containers\\Pair', [ + new TypeRef('App\\MultiType\\Models\\Plastic'), + new TypeRef('App\\MultiType\\Models\\User'), ]); self::assertStringContainsString('public \\' . $innerMapFqn . ' $first', $content); self::assertStringContainsString('public \\' . $innerPairFqn . ' $second', $content); @@ -170,8 +170,8 @@ public function testRuntimeTypeErrorOnWrongSlotType(): void $this->compile(); $pairUserPlasticFqn = Registry::generatedFqn( - 'App\\Containers\\Pair', - [new TypeRef('App\\Models\\User'), new TypeRef('App\\Models\\Plastic')], + 'App\\MultiType\\Containers\\Pair', + [new TypeRef('App\\MultiType\\Models\\User'), new TypeRef('App\\MultiType\\Models\\Plastic')], ); $pairFile = $this->fqnToPath($pairUserPlasticFqn); @@ -187,7 +187,7 @@ public function testRuntimeTypeErrorOnWrongSlotType(): void // Correct order try { - \$ok = new \$pair(new \\App\\Models\\User('alice'), new \\App\\Models\\Plastic('red')); + \$ok = new \$pair(new \\App\\MultiType\\Models\\User('alice'), new \\App\\MultiType\\Models\\Plastic('red')); echo "OK\\n"; } catch (\\Throwable \$e) { echo "UNEXPECTED:" . \$e->getMessage() . "\\n"; @@ -195,7 +195,7 @@ public function testRuntimeTypeErrorOnWrongSlotType(): void // Swap arg order — should fail on first slot (User vs Plastic) AND second slot (Plastic vs User) try { - \$bad = new \$pair(new \\App\\Models\\Plastic('red'), new \\App\\Models\\User('alice')); + \$bad = new \$pair(new \\App\\MultiType\\Models\\Plastic('red'), new \\App\\MultiType\\Models\\User('alice')); echo "MISSED_TYPE_ERROR\\n"; } catch (\\TypeError \$e) { echo "TYPE_ERROR_OK\\n"; diff --git a/test/Transpiler/Monomorphize/NestedArgsInSpecializedFunctionTest.php b/test/Transpiler/Monomorphize/NestedArgsInSpecializedFunctionTest.php index 766481e..daf0c4e 100644 --- a/test/Transpiler/Monomorphize/NestedArgsInSpecializedFunctionTest.php +++ b/test/Transpiler/Monomorphize/NestedArgsInSpecializedFunctionTest.php @@ -47,13 +47,13 @@ public function testWrappedReturnTypeBoxOfTSpecializesToBoxOfInt(): void $this->compile(); // The specialized `wrap_T_` must have return type pointing at - // `\XPHP\Generated\App\Containers\Box\T_`, not the unsubstituted `Box`. + // `\XPHP\Generated\App\GenericFunctionNestedArgs\Containers\Box\T_`, not the unsubstituted `Box`. $funcsPath = $this->targetDir . '/funcs.php'; self::assertFileExists($funcsPath); $content = file_get_contents($funcsPath); self::assertMatchesRegularExpression( - '#function wrap_T_[0-9a-f]+\(int \$x\): \\\\XPHP\\\\Generated\\\\App\\\\Containers\\\\Box\\\\T_[0-9a-f]+#', + '#function wrap_T_[0-9a-f]+\(int \$x\): \\\\XPHP\\\\Generated\\\\App\\\\GenericFunctionNestedArgs\\\\Containers\\\\Box\\\\T_[0-9a-f]+#', $content, 'specialized wrap must have its Box return type substituted to the matching Box specialization FQN', ); @@ -67,7 +67,7 @@ public function testRuntimeBoxOfIntIsConstructedByTheSpecializedWrap(): void $this->compile(); $loader = new \Composer\Autoload\ClassLoader(); - $loader->addPsr4('App\\', $this->targetDir); + $loader->addPsr4('App\\GenericFunctionNestedArgs\\', $this->targetDir); $loader->addPsr4(Registry::GENERATED_NAMESPACE_PREFIX . '\\', $this->cacheDir . '/Generated'); $loader->register(); @@ -80,9 +80,9 @@ public function testRuntimeBoxOfIntIsConstructedByTheSpecializedWrap(): void $content = file_get_contents($this->targetDir . '/funcs.php'); \preg_match('/function (wrap_T_[0-9a-f]+)\(/', $content, $m); self::assertNotEmpty($m, 'expected to find mangled wrap_T_'); - $mangled = '\\App\\' . $m[1]; + $mangled = '\\App\\GenericFunctionNestedArgs\\' . $m[1]; - $boxFqn = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('int', isScalar: true)]); + $boxFqn = Registry::generatedFqn('App\\GenericFunctionNestedArgs\\Containers\\Box', [new TypeRef('int', isScalar: true)]); $result = $mangled(42); self::assertInstanceOf($boxFqn, $result, 'wrap must return the specialized Box'); self::assertSame(42, $result->item); diff --git a/test/Transpiler/Monomorphize/NestedGenericsIntegrationTest.php b/test/Transpiler/Monomorphize/NestedGenericsIntegrationTest.php index 2d9757d..3db9bb8 100644 --- a/test/Transpiler/Monomorphize/NestedGenericsIntegrationTest.php +++ b/test/Transpiler/Monomorphize/NestedGenericsIntegrationTest.php @@ -42,11 +42,11 @@ public function testNestedInstantiationGeneratesInnerAndOuterSpecializations(): self::assertSame(2, $result->generatedCount, 'expected Lst + Box>'); - $plastic = new TypeRef('App\\Models\\Plastic'); - $lstOfPlastic = new TypeRef('App\\Containers\\Lst', [$plastic]); + $plastic = new TypeRef('App\\NestedInstantiation\\Models\\Plastic'); + $lstOfPlastic = new TypeRef('App\\NestedInstantiation\\Containers\\Lst', [$plastic]); - $lstFqn = Registry::generatedFqn('App\\Containers\\Lst', [$plastic]); - $boxFqn = Registry::generatedFqn('App\\Containers\\Box', [$lstOfPlastic]); + $lstFqn = Registry::generatedFqn('App\\NestedInstantiation\\Containers\\Lst', [$plastic]); + $boxFqn = Registry::generatedFqn('App\\NestedInstantiation\\Containers\\Box', [$lstOfPlastic]); $lstFile = $this->fqnToPath($lstFqn); $boxFile = $this->fqnToPath($boxFqn); @@ -54,12 +54,12 @@ public function testNestedInstantiationGeneratesInnerAndOuterSpecializations(): self::assertFileExists($boxFile, "expected {$boxFile}"); $lstContent = file_get_contents($lstFile); - self::assertStringContainsString('namespace XPHP\\Generated\\App\\Containers\\Lst', $lstContent); - self::assertStringContainsString('public function push(\\App\\Models\\Plastic $val)', $lstContent); - self::assertStringContainsString('public function first(): \\App\\Models\\Plastic', $lstContent); + self::assertStringContainsString('namespace XPHP\\Generated\\App\\NestedInstantiation\\Containers\\Lst', $lstContent); + self::assertStringContainsString('public function push(\\App\\NestedInstantiation\\Models\\Plastic $val)', $lstContent); + self::assertStringContainsString('public function first(): \\App\\NestedInstantiation\\Models\\Plastic', $lstContent); $boxContent = file_get_contents($boxFile); - self::assertStringContainsString('namespace XPHP\\Generated\\App\\Containers\\Box', $boxContent); + self::assertStringContainsString('namespace XPHP\\Generated\\App\\NestedInstantiation\\Containers\\Box', $boxContent); self::assertStringContainsString('public \\' . $lstFqn . ' $item', $boxContent); self::assertStringContainsString('public function set(\\' . $lstFqn . ' $val)', $boxContent); @@ -81,9 +81,9 @@ public function testTypeHintInsideTemplateBodyGeneratesTransitiveSpecialization( self::assertSame(2, $result->generatedCount, 'expected Wrapper + transitively Box'); - $plastic = new TypeRef('App\\Models\\Plastic'); - $boxFqn = Registry::generatedFqn('App\\Containers\\Box', [$plastic]); - $wrapperFqn = Registry::generatedFqn('App\\Containers\\Wrapper', [$plastic]); + $plastic = new TypeRef('App\\NestedTypehint\\Models\\Plastic'); + $boxFqn = Registry::generatedFqn('App\\NestedTypehint\\Containers\\Box', [$plastic]); + $wrapperFqn = Registry::generatedFqn('App\\NestedTypehint\\Containers\\Wrapper', [$plastic]); $boxFile = $this->fqnToPath($boxFqn); $wrapperFile = $this->fqnToPath($wrapperFqn); @@ -91,14 +91,14 @@ public function testTypeHintInsideTemplateBodyGeneratesTransitiveSpecialization( self::assertFileExists($boxFile); $wrapperContent = file_get_contents($wrapperFile); - self::assertStringContainsString('namespace XPHP\\Generated\\App\\Containers\\Wrapper', $wrapperContent); + self::assertStringContainsString('namespace XPHP\\Generated\\App\\NestedTypehint\\Containers\\Wrapper', $wrapperContent); self::assertStringContainsString('public \\' . $boxFqn . ' $box', $wrapperContent); self::assertStringContainsString('$this->box = new \\' . $boxFqn . '()', $wrapperContent); - self::assertStringContainsString('public function setBoxed(\\App\\Models\\Plastic $val)', $wrapperContent); - self::assertStringContainsString('public function getBoxed(): \\App\\Models\\Plastic', $wrapperContent); + self::assertStringContainsString('public function setBoxed(\\App\\NestedTypehint\\Models\\Plastic $val)', $wrapperContent); + self::assertStringContainsString('public function getBoxed(): \\App\\NestedTypehint\\Models\\Plastic', $wrapperContent); $boxContent = file_get_contents($boxFile); - self::assertStringContainsString('public \\App\\Models\\Plastic $item', $boxContent); + self::assertStringContainsString('public \\App\\NestedTypehint\\Models\\Plastic $item', $boxContent); $useFile = $this->targetDir . '/Use.php'; $useContent = file_get_contents($useFile); @@ -117,13 +117,13 @@ public function testRegistryContainsTransitiveInstantiations(): void $registry = json_decode(file_get_contents($this->cacheDir . '/registry.json'), true); $fqns = array_column($registry['instantiations'], 'generatedFqn'); - $plastic = new TypeRef('App\\Models\\Plastic'); + $plastic = new TypeRef('App\\NestedTypehint\\Models\\Plastic'); self::assertContains( - Registry::generatedFqn('App\\Containers\\Wrapper', [$plastic]), + Registry::generatedFqn('App\\NestedTypehint\\Containers\\Wrapper', [$plastic]), $fqns, ); self::assertContains( - Registry::generatedFqn('App\\Containers\\Box', [$plastic]), + Registry::generatedFqn('App\\NestedTypehint\\Containers\\Box', [$plastic]), $fqns, ); self::assertCount(2, $fqns); @@ -136,9 +136,9 @@ public function testRuntimeReflectionAndTypeErrorOnNestedSpecialization(): void $this->compile($sourceDir); - $plastic = new TypeRef('App\\Models\\Plastic'); - $boxFqn = Registry::generatedFqn('App\\Containers\\Box', [$plastic]); - $wrapperFqn = Registry::generatedFqn('App\\Containers\\Wrapper', [$plastic]); + $plastic = new TypeRef('App\\NestedTypehint\\Models\\Plastic'); + $boxFqn = Registry::generatedFqn('App\\NestedTypehint\\Containers\\Box', [$plastic]); + $wrapperFqn = Registry::generatedFqn('App\\NestedTypehint\\Containers\\Wrapper', [$plastic]); $boxFile = $this->fqnToPath($boxFqn); $wrapperFile = $this->fqnToPath($wrapperFqn); diff --git a/test/Transpiler/Monomorphize/RegistryTest.php b/test/Transpiler/Monomorphize/RegistryTest.php index 17f15fe..20f208d 100644 --- a/test/Transpiler/Monomorphize/RegistryTest.php +++ b/test/Transpiler/Monomorphize/RegistryTest.php @@ -12,63 +12,63 @@ final class RegistryTest extends TestCase { public function testGeneratedFqnIsStableForSameInput(): void { - $a = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); - $b = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); + $a = Registry::generatedFqn('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); + $b = Registry::generatedFqn('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); self::assertSame($a, $b); } public function testGeneratedFqnMirrorsTemplateNamespace(): void { - $fqn = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); - self::assertStringStartsWith('XPHP\\Generated\\App\\Containers\\Box\\T_', $fqn); + $fqn = Registry::generatedFqn('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); + self::assertStringStartsWith('XPHP\\Generated\\App\\RegistryTest\\Containers\\Box\\T_', $fqn); self::assertMatchesRegularExpression('/T_[0-9a-f]{64}$/', $fqn); } public function testDifferentTemplateNamespacesProduceDifferentFqns(): void { - $a = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); - $b = Registry::generatedFqn('App\\Other\\Box', [new TypeRef('App\\Models\\Plastic')]); + $a = Registry::generatedFqn('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); + $b = Registry::generatedFqn('App\\RegistryTest\\Other\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); self::assertNotSame($a, $b); - self::assertStringContainsString('App\\Containers\\Box', $a); - self::assertStringContainsString('App\\Other\\Box', $b); + self::assertStringContainsString('App\\RegistryTest\\Containers\\Box', $a); + self::assertStringContainsString('App\\RegistryTest\\Other\\Box', $b); } public function testDifferentArgsProduceDifferentHashes(): void { - $a = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); - $b = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Metal')]); + $a = Registry::generatedFqn('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); + $b = Registry::generatedFqn('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Metal')]); self::assertNotSame($a, $b); - self::assertStringStartsWith('XPHP\\Generated\\App\\Containers\\Box\\T_', $a); - self::assertStringStartsWith('XPHP\\Generated\\App\\Containers\\Box\\T_', $b); + self::assertStringStartsWith('XPHP\\Generated\\App\\RegistryTest\\Containers\\Box\\T_', $a); + self::assertStringStartsWith('XPHP\\Generated\\App\\RegistryTest\\Containers\\Box\\T_', $b); } public function testSameArgShortNameDifferentNamespacesDoNotCollide(): void { - $a = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); - $b = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Other\\Plastic')]); + $a = Registry::generatedFqn('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); + $b = Registry::generatedFqn('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Other\\Plastic')]); self::assertNotSame($a, $b, 'short-name collision must be prevented by hashing the full canonical arg FQCN'); } public function testNestedGenericArgsAffectHashDeterministically(): void { - $nested = new TypeRef('App\\Containers\\Lst', [new TypeRef('App\\Models\\Plastic')]); + $nested = new TypeRef('App\\RegistryTest\\Containers\\Lst', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); - $a = Registry::generatedFqn('App\\Containers\\Box', [$nested]); - $b = Registry::generatedFqn('App\\Containers\\Box', [$nested]); + $a = Registry::generatedFqn('App\\RegistryTest\\Containers\\Box', [$nested]); + $b = Registry::generatedFqn('App\\RegistryTest\\Containers\\Box', [$nested]); self::assertSame($a, $b); - self::assertStringStartsWith('XPHP\\Generated\\App\\Containers\\Box\\T_', $a); + self::assertStringStartsWith('XPHP\\Generated\\App\\RegistryTest\\Containers\\Box\\T_', $a); } public function testRecordInstantiationIsIdempotent(): void { $registry = new Registry(); - $first = $registry->recordInstantiation('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); - $second = $registry->recordInstantiation('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); + $first = $registry->recordInstantiation('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); + $second = $registry->recordInstantiation('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); self::assertSame($first, $second); self::assertCount(1, $registry->instantiations()); @@ -78,12 +78,12 @@ public function testDistinctTypesProduceDistinctEntries(): void { $registry = new Registry(); - $registry->recordInstantiation('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); - $registry->recordInstantiation('App\\Containers\\Box', [new TypeRef('App\\Models\\Metal')]); + $registry->recordInstantiation('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); + $registry->recordInstantiation('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Metal')]); self::assertCount(2, $registry->instantiations()); foreach ($registry->instantiations() as $fqn => $_) { - self::assertStringStartsWith('XPHP\\Generated\\App\\Containers\\Box\\T_', $fqn); + self::assertStringStartsWith('XPHP\\Generated\\App\\RegistryTest\\Containers\\Box\\T_', $fqn); } } @@ -91,18 +91,18 @@ public function testRecordInstantiationRecursivelyRegistersNestedInstantiations( { $registry = new Registry(); - $nested = new TypeRef('App\\Containers\\Lst', [new TypeRef('App\\Models\\Plastic')]); - $registry->recordInstantiation('App\\Containers\\Box', [$nested]); + $nested = new TypeRef('App\\RegistryTest\\Containers\\Lst', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); + $registry->recordInstantiation('App\\RegistryTest\\Containers\\Box', [$nested]); self::assertCount(2, $registry->instantiations()); $hasBox = false; $hasLst = false; foreach ($registry->instantiations() as $fqn => $_) { - if (str_starts_with($fqn, 'XPHP\\Generated\\App\\Containers\\Box\\T_')) { + if (str_starts_with($fqn, 'XPHP\\Generated\\App\\RegistryTest\\Containers\\Box\\T_')) { $hasBox = true; } - if (str_starts_with($fqn, 'XPHP\\Generated\\App\\Containers\\Lst\\T_')) { + if (str_starts_with($fqn, 'XPHP\\Generated\\App\\RegistryTest\\Containers\\Lst\\T_')) { $hasLst = true; } } @@ -114,22 +114,22 @@ public function testCustomHashLengthShortensClassName(): void { $registry = new Registry(hashLength: 16); - $instantiation = $registry->recordInstantiation('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); + $instantiation = $registry->recordInstantiation('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); self::assertMatchesRegularExpression('/T_[0-9a-f]{16}$/', $instantiation->generatedFqn); } public function testCustomHashLengthStillCollisionDistinct(): void { $reg = new Registry(hashLength: 16); - $reg->recordInstantiation('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); - $reg->recordInstantiation('App\\Containers\\Box', [new TypeRef('App\\Models\\Metal')]); + $reg->recordInstantiation('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); + $reg->recordInstantiation('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Metal')]); self::assertCount(2, $reg->instantiations()); } public function testStaticGeneratedFqnAcceptsHashLength(): void { - $fqn = Registry::generatedFqn('App\\Box', [new TypeRef('App\\Plastic')], 32); + $fqn = Registry::generatedFqn('App\\RegistryTest\\Box', [new TypeRef('App\\RegistryTest\\Plastic')], 32); self::assertMatchesRegularExpression('/T_[0-9a-f]{32}$/', $fqn); } @@ -202,22 +202,22 @@ public function testCollisionTriggersHelpfulRuntimeException(): void // the FQCN slot the next recordInstantiation() call will produce. $registry = new Registry(hashLength: 16); - $newArgs = [new TypeRef('App\\Models\\Metal')]; - $collidingFqn = Registry::generatedFqn('App\\Containers\\Box', $newArgs, 16); + $newArgs = [new TypeRef('App\\RegistryTest\\Models\\Metal')]; + $collidingFqn = Registry::generatedFqn('App\\RegistryTest\\Containers\\Box', $newArgs, 16); // Seed: pretend Box was already recorded at the Box hash slot. $reflection = new \ReflectionClass($registry); $prop = $reflection->getProperty('instantiations'); $prop->setValue($registry, [ $collidingFqn => new GenericInstantiation( - 'App\\Containers\\Box', - [new TypeRef('App\\Models\\Plastic')], + 'App\\RegistryTest\\Containers\\Box', + [new TypeRef('App\\RegistryTest\\Models\\Plastic')], $collidingFqn, ), ]); try { - $registry->recordInstantiation('App\\Containers\\Box', $newArgs); + $registry->recordInstantiation('App\\RegistryTest\\Containers\\Box', $newArgs); self::fail('expected RuntimeException for hash collision'); } catch (\RuntimeException $e) { // Exact message match locks the order and presence of every concat operand. @@ -225,8 +225,8 @@ public function testCollisionTriggersHelpfulRuntimeException(): void // that previously slipped through substring-only assertions. $expected = "Hash collision detected while monomorphizing generics.\n\n" . "Two distinct instantiations produced the same specialized FQCN:\n" - . " existing : App\\Containers\\Box\n" - . " new : App\\Containers\\Box\n" + . " existing : App\\RegistryTest\\Containers\\Box\n" + . " new : App\\RegistryTest\\Containers\\Box\n" . " collision: {$collidingFqn}\n\n" . "The current XPHP_HASH_LENGTH = 16 is too short for this codebase.\n" . "Increase it (max 64, the full sha256 digest) and re-run, e.g.:\n\n" @@ -239,21 +239,21 @@ public function testCollisionMessageSuggestsMaxWhenAlreadyAtHigherLength(): void { $registry = new Registry(hashLength: 48); - $newArgs = [new TypeRef('App\\Models\\Metal')]; - $collidingFqn = Registry::generatedFqn('App\\Containers\\Box', $newArgs, 48); + $newArgs = [new TypeRef('App\\RegistryTest\\Models\\Metal')]; + $collidingFqn = Registry::generatedFqn('App\\RegistryTest\\Containers\\Box', $newArgs, 48); $reflection = new \ReflectionClass($registry); $prop = $reflection->getProperty('instantiations'); $prop->setValue($registry, [ $collidingFqn => new GenericInstantiation( - 'App\\Containers\\Box', - [new TypeRef('App\\Models\\Plastic')], + 'App\\RegistryTest\\Containers\\Box', + [new TypeRef('App\\RegistryTest\\Models\\Plastic')], $collidingFqn, ), ]); try { - $registry->recordInstantiation('App\\Containers\\Box', $newArgs); + $registry->recordInstantiation('App\\RegistryTest\\Containers\\Box', $newArgs); self::fail('expected collision exception'); } catch (\RuntimeException $e) { // 48 * 2 = 96, clamped to MAX (64) @@ -264,8 +264,8 @@ public function testCollisionMessageSuggestsMaxWhenAlreadyAtHigherLength(): void public function testIdempotentRecordingDoesNotTriggerCollisionCheck(): void { $registry = new Registry(); - $a = $registry->recordInstantiation('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); - $b = $registry->recordInstantiation('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); + $a = $registry->recordInstantiation('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); + $b = $registry->recordInstantiation('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); self::assertSame($a, $b); } @@ -276,23 +276,23 @@ public function testIdempotentRecordingDoesNotTriggerCollisionCheck(): void public function testLeadingBackslashOnTemplateFqnIsNormalized(): void { - $withSlash = Registry::generatedFqn('\\App\\Containers\\Box', [new TypeRef('App\\Plastic')]); - $without = Registry::generatedFqn('App\\Containers\\Box', [new TypeRef('App\\Plastic')]); + $withSlash = Registry::generatedFqn('\\App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Plastic')]); + $without = Registry::generatedFqn('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Plastic')]); self::assertSame($without, $withSlash); } public function testLeadingBackslashOnArgFqnIsNormalized(): void { - $withSlash = Registry::generatedFqn('App\\Box', [new TypeRef('\\App\\Plastic')]); - $without = Registry::generatedFqn('App\\Box', [new TypeRef('App\\Plastic')]); + $withSlash = Registry::generatedFqn('App\\RegistryTest\\Box', [new TypeRef('\\App\\RegistryTest\\Plastic')]); + $without = Registry::generatedFqn('App\\RegistryTest\\Box', [new TypeRef('App\\RegistryTest\\Plastic')]); self::assertSame($without, $withSlash); } public function testRecordInstantiationTreatsBackslashFormsAsIdentical(): void { $registry = new Registry(); - $a = $registry->recordInstantiation('\\App\\Box', [new TypeRef('\\App\\Plastic')]); - $b = $registry->recordInstantiation('App\\Box', [new TypeRef('App\\Plastic')]); + $a = $registry->recordInstantiation('\\App\\RegistryTest\\Box', [new TypeRef('\\App\\RegistryTest\\Plastic')]); + $b = $registry->recordInstantiation('App\\RegistryTest\\Box', [new TypeRef('App\\RegistryTest\\Plastic')]); self::assertSame($a->generatedFqn, $b->generatedFqn); self::assertCount(1, $registry->instantiations(), 'leading backslash must not produce a duplicate entry'); @@ -301,15 +301,15 @@ public function testRecordInstantiationTreatsBackslashFormsAsIdentical(): void public function testIsSameInstantiationIgnoresLeadingBackslashOnTemplateFqn(): void { $registry = new Registry(); - $registry->recordInstantiation('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); + $registry->recordInstantiation('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); // Recording the same instantiation via the leading-backslash form must hit the // "same instantiation" branch in isSameInstantiation (which uses ltrim on $existing->templateFqn); // without ltrim, the comparison would fail and a hash collision would be falsely reported. - $second = $registry->recordInstantiation('\\App\\Containers\\Box', [new TypeRef('\\App\\Models\\Plastic')]); + $second = $registry->recordInstantiation('\\App\\RegistryTest\\Containers\\Box', [new TypeRef('\\App\\RegistryTest\\Models\\Plastic')]); self::assertCount(1, $registry->instantiations()); - self::assertSame('App\\Containers\\Box', $second->templateFqn); + self::assertSame('App\\RegistryTest\\Containers\\Box', $second->templateFqn); } // ----------------------------------------------------------------------- @@ -320,13 +320,13 @@ public function testIsSameInstantiationIgnoresLeadingBackslashOnTemplateFqn(): v public function testStaticGeneratedFqnRejectsBelowMinimum(): void { $this->expectException(\InvalidArgumentException::class); - Registry::generatedFqn('App\\Box', [new TypeRef('App\\Plastic')], 0); + Registry::generatedFqn('App\\RegistryTest\\Box', [new TypeRef('App\\RegistryTest\\Plastic')], 0); } public function testStaticGeneratedFqnRejectsOverMax(): void { $this->expectException(\InvalidArgumentException::class); - Registry::generatedFqn('App\\Box', [new TypeRef('App\\Plastic')], 100); + Registry::generatedFqn('App\\RegistryTest\\Box', [new TypeRef('App\\RegistryTest\\Plastic')], 100); } // ----------------------------------------------------------------------- @@ -341,13 +341,13 @@ public function testToArrayEmitsExpectedShapeForDefinitionsAndInstantiations(): $templateAst = new Class_(new Identifier('Box')); $registry->recordDefinition( - 'App\\Containers\\Box', + 'App\\RegistryTest\\Containers\\Box', 'Box', [new TypeParam('T')], $templateAst, '/some/source/Box.xphp', ); - $registry->recordInstantiation('App\\Containers\\Box', [new TypeRef('App\\Models\\Plastic')]); + $registry->recordInstantiation('App\\RegistryTest\\Containers\\Box', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); $out = $registry->toArray(); @@ -355,7 +355,7 @@ public function testToArrayEmitsExpectedShapeForDefinitionsAndInstantiations(): self::assertCount(1, $out['definitions']); $def = $out['definitions'][0]; self::assertSame(['name', 'typeParams', 'sourceFile'], array_keys($def), 'definition keys must be exactly these three'); - self::assertSame('App\\Containers\\Box', $def['name']); + self::assertSame('App\\RegistryTest\\Containers\\Box', $def['name']); self::assertSame(['T'], $def['typeParams']); self::assertSame('/some/source/Box.xphp', $def['sourceFile']); @@ -363,32 +363,32 @@ public function testToArrayEmitsExpectedShapeForDefinitionsAndInstantiations(): self::assertCount(1, $out['instantiations']); $inst = $out['instantiations'][0]; self::assertSame(['template', 'concreteTypes', 'generatedFqn'], array_keys($inst), 'instantiation keys must be exactly these three'); - self::assertSame('App\\Containers\\Box', $inst['template']); + self::assertSame('App\\RegistryTest\\Containers\\Box', $inst['template']); // concreteTypes must be a list of display strings (UnwrapArrayMap would leave raw TypeRefs). self::assertIsArray($inst['concreteTypes']); - self::assertSame(['App\\Models\\Plastic'], $inst['concreteTypes']); - self::assertStringStartsWith('XPHP\\Generated\\App\\Containers\\Box\\T_', $inst['generatedFqn']); + self::assertSame(['App\\RegistryTest\\Models\\Plastic'], $inst['concreteTypes']); + self::assertStringStartsWith('XPHP\\Generated\\App\\RegistryTest\\Containers\\Box\\T_', $inst['generatedFqn']); } public function testToArraySerializesNestedGenericArgAsDisplayString(): void { $registry = new Registry(); - $lstOfPlastic = new TypeRef('App\\Containers\\Lst', [new TypeRef('App\\Models\\Plastic')]); - $registry->recordInstantiation('App\\Containers\\Box', [$lstOfPlastic]); + $lstOfPlastic = new TypeRef('App\\RegistryTest\\Containers\\Lst', [new TypeRef('App\\RegistryTest\\Models\\Plastic')]); + $registry->recordInstantiation('App\\RegistryTest\\Containers\\Box', [$lstOfPlastic]); $out = $registry->toArray(); // Find the outer Box> entry; concreteTypes should be the angle-bracket form. $boxEntry = null; foreach ($out['instantiations'] as $entry) { - if ($entry['template'] === 'App\\Containers\\Box') { + if ($entry['template'] === 'App\\RegistryTest\\Containers\\Box') { $boxEntry = $entry; break; } } self::assertNotNull($boxEntry); self::assertSame( - ['App\\Containers\\Lst'], + ['App\\RegistryTest\\Containers\\Lst'], $boxEntry['concreteTypes'], ); } diff --git a/test/fixture/compile/array_sugar/source/Containers/Collection.xphp b/test/fixture/compile/array_sugar/source/Containers/Collection.xphp index 014b802..e86d8f1 100644 --- a/test/fixture/compile/array_sugar/source/Containers/Collection.xphp +++ b/test/fixture/compile/array_sugar/source/Containers/Collection.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Containers; +namespace App\ArraySugar\Containers; class Collection { diff --git a/test/fixture/compile/array_sugar/source/Models/User.xphp b/test/fixture/compile/array_sugar/source/Models/User.xphp index e750b01..84d0a24 100644 --- a/test/fixture/compile/array_sugar/source/Models/User.xphp +++ b/test/fixture/compile/array_sugar/source/Models/User.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Models; +namespace App\ArraySugar\Models; final class User { diff --git a/test/fixture/compile/array_sugar/source/Use.xphp b/test/fixture/compile/array_sugar/source/Use.xphp index d25bcbb..045f442 100644 --- a/test/fixture/compile/array_sugar/source/Use.xphp +++ b/test/fixture/compile/array_sugar/source/Use.xphp @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App; +namespace App\ArraySugar; -use App\Containers\Collection; -use App\Models\User; +use App\ArraySugar\Containers\Collection; +use App\ArraySugar\Models\User; $users = new Collection(new User('Alice'), new User('Bob')); $first = $users->first(); diff --git a/test/fixture/compile/bounds_happy/source/Containers/Box.xphp b/test/fixture/compile/bounds_happy/source/Containers/Box.xphp index 65ae30f..c623a65 100644 --- a/test/fixture/compile/bounds_happy/source/Containers/Box.xphp +++ b/test/fixture/compile/bounds_happy/source/Containers/Box.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Containers; +namespace App\BoundsHappy\Containers; class Box { diff --git a/test/fixture/compile/bounds_happy/source/Models/Tag.xphp b/test/fixture/compile/bounds_happy/source/Models/Tag.xphp index 69be10f..fd0c5d0 100644 --- a/test/fixture/compile/bounds_happy/source/Models/Tag.xphp +++ b/test/fixture/compile/bounds_happy/source/Models/Tag.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Models; +namespace App\BoundsHappy\Models; final class Tag implements \Stringable { diff --git a/test/fixture/compile/bounds_happy/source/Use.xphp b/test/fixture/compile/bounds_happy/source/Use.xphp index fced0f4..13e7819 100644 --- a/test/fixture/compile/bounds_happy/source/Use.xphp +++ b/test/fixture/compile/bounds_happy/source/Use.xphp @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App; +namespace App\BoundsHappy; -use App\Containers\Box; -use App\Models\Tag; +use App\BoundsHappy\Containers\Box; +use App\BoundsHappy\Models\Tag; $tagBox = new Box(new Tag('hello')); diff --git a/test/fixture/compile/box_generic/source/Containers/Box.xphp b/test/fixture/compile/box_generic/source/Containers/Box.xphp index c277b57..2181f18 100644 --- a/test/fixture/compile/box_generic/source/Containers/Box.xphp +++ b/test/fixture/compile/box_generic/source/Containers/Box.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Containers; +namespace App\BoxGeneric\Containers; class Box { diff --git a/test/fixture/compile/box_generic/source/Helpers/Helper.xphp b/test/fixture/compile/box_generic/source/Helpers/Helper.xphp index afeb97f..22ccba4 100644 --- a/test/fixture/compile/box_generic/source/Helpers/Helper.xphp +++ b/test/fixture/compile/box_generic/source/Helpers/Helper.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Helpers; +namespace App\BoxGeneric\Helpers; final class Helper { diff --git a/test/fixture/compile/box_generic/source/Models/Metal.xphp b/test/fixture/compile/box_generic/source/Models/Metal.xphp index f06e4cb..ebe1009 100644 --- a/test/fixture/compile/box_generic/source/Models/Metal.xphp +++ b/test/fixture/compile/box_generic/source/Models/Metal.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Models; +namespace App\BoxGeneric\Models; final class Metal { diff --git a/test/fixture/compile/box_generic/source/Models/Plastic.xphp b/test/fixture/compile/box_generic/source/Models/Plastic.xphp index a17c3ad..e6fe907 100644 --- a/test/fixture/compile/box_generic/source/Models/Plastic.xphp +++ b/test/fixture/compile/box_generic/source/Models/Plastic.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Models; +namespace App\BoxGeneric\Models; final class Plastic { diff --git a/test/fixture/compile/box_generic/source/Use.xphp b/test/fixture/compile/box_generic/source/Use.xphp index 8d074c1..6de8ec3 100644 --- a/test/fixture/compile/box_generic/source/Use.xphp +++ b/test/fixture/compile/box_generic/source/Use.xphp @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace App; +namespace App\BoxGeneric; -use App\Containers\Box; -use App\Models\Metal; -use App\Models\Plastic; +use App\BoxGeneric\Containers\Box; +use App\BoxGeneric\Models\Metal; +use App\BoxGeneric\Models\Plastic; $plasticBox = new Box(); $plasticBox->set(new Plastic('red')); diff --git a/test/fixture/compile/depth_cap/source/Containers/Recursive.xphp b/test/fixture/compile/depth_cap/source/Containers/Recursive.xphp index 4b427de..539b736 100644 --- a/test/fixture/compile/depth_cap/source/Containers/Recursive.xphp +++ b/test/fixture/compile/depth_cap/source/Containers/Recursive.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Containers; +namespace App\DepthCap\Containers; /** * Pathologically recursive template: each specialization references a deeper diff --git a/test/fixture/compile/depth_cap/source/Use.xphp b/test/fixture/compile/depth_cap/source/Use.xphp index 57ea1db..be1fb87 100644 --- a/test/fixture/compile/depth_cap/source/Use.xphp +++ b/test/fixture/compile/depth_cap/source/Use.xphp @@ -2,8 +2,8 @@ declare(strict_types=1); -namespace App; +namespace App\DepthCap; -use App\Containers\Recursive; +use App\DepthCap\Containers\Recursive; $x = new Recursive(); diff --git a/test/fixture/compile/generic_function/source/Use.xphp b/test/fixture/compile/generic_function/source/Use.xphp index e579416..169c5ff 100644 --- a/test/fixture/compile/generic_function/source/Use.xphp +++ b/test/fixture/compile/generic_function/source/Use.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App; +namespace App\GenericFunction; $asInt = identity(42); $asString = identity('world'); diff --git a/test/fixture/compile/generic_function/source/funcs.xphp b/test/fixture/compile/generic_function/source/funcs.xphp index daf3f6e..b18633f 100644 --- a/test/fixture/compile/generic_function/source/funcs.xphp +++ b/test/fixture/compile/generic_function/source/funcs.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App; +namespace App\GenericFunction; function identity(T $x): T { diff --git a/test/fixture/compile/generic_function_nested_args/source/Containers/Box.xphp b/test/fixture/compile/generic_function_nested_args/source/Containers/Box.xphp index 0172c73..2d07b6f 100644 --- a/test/fixture/compile/generic_function_nested_args/source/Containers/Box.xphp +++ b/test/fixture/compile/generic_function_nested_args/source/Containers/Box.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Containers; +namespace App\GenericFunctionNestedArgs\Containers; class Box { diff --git a/test/fixture/compile/generic_function_nested_args/source/Use.xphp b/test/fixture/compile/generic_function_nested_args/source/Use.xphp index adb6bb2..bf509db 100644 --- a/test/fixture/compile/generic_function_nested_args/source/Use.xphp +++ b/test/fixture/compile/generic_function_nested_args/source/Use.xphp @@ -2,6 +2,6 @@ declare(strict_types=1); -namespace App; +namespace App\GenericFunctionNestedArgs; $boxed = wrap(42); diff --git a/test/fixture/compile/generic_function_nested_args/source/funcs.xphp b/test/fixture/compile/generic_function_nested_args/source/funcs.xphp index a911ab4..71e7d48 100644 --- a/test/fixture/compile/generic_function_nested_args/source/funcs.xphp +++ b/test/fixture/compile/generic_function_nested_args/source/funcs.xphp @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App; +namespace App\GenericFunctionNestedArgs; -use App\Containers\Box; +use App\GenericFunctionNestedArgs\Containers\Box; function wrap(T $x): Box { diff --git a/test/fixture/compile/generic_interface/source/Containers/Box.xphp b/test/fixture/compile/generic_interface/source/Containers/Box.xphp index 3fb2681..990c230 100644 --- a/test/fixture/compile/generic_interface/source/Containers/Box.xphp +++ b/test/fixture/compile/generic_interface/source/Containers/Box.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Containers; +namespace App\GenericInterface\Containers; class Box implements Container { diff --git a/test/fixture/compile/generic_interface/source/Containers/Container.xphp b/test/fixture/compile/generic_interface/source/Containers/Container.xphp index 0ca8819..29eb4ce 100644 --- a/test/fixture/compile/generic_interface/source/Containers/Container.xphp +++ b/test/fixture/compile/generic_interface/source/Containers/Container.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Containers; +namespace App\GenericInterface\Containers; interface Container { diff --git a/test/fixture/compile/generic_interface/source/Models/Plastic.xphp b/test/fixture/compile/generic_interface/source/Models/Plastic.xphp index a17c3ad..63854d4 100644 --- a/test/fixture/compile/generic_interface/source/Models/Plastic.xphp +++ b/test/fixture/compile/generic_interface/source/Models/Plastic.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Models; +namespace App\GenericInterface\Models; final class Plastic { diff --git a/test/fixture/compile/generic_interface/source/Models/Polymer.xphp b/test/fixture/compile/generic_interface/source/Models/Polymer.xphp index 0cdee27..c0d85c7 100644 --- a/test/fixture/compile/generic_interface/source/Models/Polymer.xphp +++ b/test/fixture/compile/generic_interface/source/Models/Polymer.xphp @@ -2,13 +2,8 @@ declare(strict_types=1); -namespace App\Models; +namespace App\GenericInterface\Models; -// Fixture-unique concrete type. Earlier fixtures' Box specializations -// share a hash key (Plastic is a popular sample concrete) and PHP's process-wide -// class table caches the first loader's body — which doesn't implement the -// Container marker we want to assert here. Using a name no other fixture uses -// gives this test a deterministic, non-shared specialization to inspect. final class Polymer { public function __construct(public readonly string $label) diff --git a/test/fixture/compile/generic_interface/source/Use.xphp b/test/fixture/compile/generic_interface/source/Use.xphp index 51e4451..18c1661 100644 --- a/test/fixture/compile/generic_interface/source/Use.xphp +++ b/test/fixture/compile/generic_interface/source/Use.xphp @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace App; +namespace App\GenericInterface; -use App\Containers\Box; -use App\Models\Plastic; -use App\Models\Polymer; +use App\GenericInterface\Containers\Box; +use App\GenericInterface\Models\Plastic; +use App\GenericInterface\Models\Polymer; $plasticBox = new Box(new Plastic('red')); $polymerBox = new Box(new Polymer('PET')); diff --git a/test/fixture/compile/generic_method/source/Use.xphp b/test/fixture/compile/generic_method/source/Use.xphp index 8348a31..5433dac 100644 --- a/test/fixture/compile/generic_method/source/Use.xphp +++ b/test/fixture/compile/generic_method/source/Use.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App; +namespace App\GenericMethod; $asInt = Util::identity(42); $asString = Util::identity('hello'); diff --git a/test/fixture/compile/generic_method/source/Util.xphp b/test/fixture/compile/generic_method/source/Util.xphp index b4c0c71..b987e65 100644 --- a/test/fixture/compile/generic_method/source/Util.xphp +++ b/test/fixture/compile/generic_method/source/Util.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App; +namespace App\GenericMethod; class Util { diff --git a/test/fixture/compile/multi_type/source/Containers/Map.xphp b/test/fixture/compile/multi_type/source/Containers/Map.xphp index b7af480..1f41277 100644 --- a/test/fixture/compile/multi_type/source/Containers/Map.xphp +++ b/test/fixture/compile/multi_type/source/Containers/Map.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Containers; +namespace App\MultiType\Containers; class Map { diff --git a/test/fixture/compile/multi_type/source/Containers/Pair.xphp b/test/fixture/compile/multi_type/source/Containers/Pair.xphp index d9d1789..cd38261 100644 --- a/test/fixture/compile/multi_type/source/Containers/Pair.xphp +++ b/test/fixture/compile/multi_type/source/Containers/Pair.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Containers; +namespace App\MultiType\Containers; class Pair { diff --git a/test/fixture/compile/multi_type/source/Models/Plastic.xphp b/test/fixture/compile/multi_type/source/Models/Plastic.xphp index a17c3ad..7e67c79 100644 --- a/test/fixture/compile/multi_type/source/Models/Plastic.xphp +++ b/test/fixture/compile/multi_type/source/Models/Plastic.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Models; +namespace App\MultiType\Models; final class Plastic { diff --git a/test/fixture/compile/multi_type/source/Models/User.xphp b/test/fixture/compile/multi_type/source/Models/User.xphp index e750b01..ea37edc 100644 --- a/test/fixture/compile/multi_type/source/Models/User.xphp +++ b/test/fixture/compile/multi_type/source/Models/User.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Models; +namespace App\MultiType\Models; final class User { diff --git a/test/fixture/compile/multi_type/source/Use.xphp b/test/fixture/compile/multi_type/source/Use.xphp index f720939..1495961 100644 --- a/test/fixture/compile/multi_type/source/Use.xphp +++ b/test/fixture/compile/multi_type/source/Use.xphp @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace App; +namespace App\MultiType; -use App\Containers\Map; -use App\Containers\Pair; -use App\Models\Plastic; -use App\Models\User; +use App\MultiType\Containers\Map; +use App\MultiType\Containers\Pair; +use App\MultiType\Models\Plastic; +use App\MultiType\Models\User; // Two distinct classes as type params $userPlastic = new Pair(new User('alice'), new Plastic('red')); diff --git a/test/fixture/compile/nested_instantiation/source/Containers/Box.xphp b/test/fixture/compile/nested_instantiation/source/Containers/Box.xphp index c277b57..8acbe09 100644 --- a/test/fixture/compile/nested_instantiation/source/Containers/Box.xphp +++ b/test/fixture/compile/nested_instantiation/source/Containers/Box.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Containers; +namespace App\NestedInstantiation\Containers; class Box { diff --git a/test/fixture/compile/nested_instantiation/source/Containers/Lst.xphp b/test/fixture/compile/nested_instantiation/source/Containers/Lst.xphp index 717f285..8d350db 100644 --- a/test/fixture/compile/nested_instantiation/source/Containers/Lst.xphp +++ b/test/fixture/compile/nested_instantiation/source/Containers/Lst.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Containers; +namespace App\NestedInstantiation\Containers; class Lst { diff --git a/test/fixture/compile/nested_instantiation/source/Models/Plastic.xphp b/test/fixture/compile/nested_instantiation/source/Models/Plastic.xphp index a17c3ad..c90bdc8 100644 --- a/test/fixture/compile/nested_instantiation/source/Models/Plastic.xphp +++ b/test/fixture/compile/nested_instantiation/source/Models/Plastic.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Models; +namespace App\NestedInstantiation\Models; final class Plastic { diff --git a/test/fixture/compile/nested_instantiation/source/Use.xphp b/test/fixture/compile/nested_instantiation/source/Use.xphp index 67d478e..51a4478 100644 --- a/test/fixture/compile/nested_instantiation/source/Use.xphp +++ b/test/fixture/compile/nested_instantiation/source/Use.xphp @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace App; +namespace App\NestedInstantiation; -use App\Containers\Box; -use App\Containers\Lst; -use App\Models\Plastic; +use App\NestedInstantiation\Containers\Box; +use App\NestedInstantiation\Containers\Lst; +use App\NestedInstantiation\Models\Plastic; $boxOfList = new Box>(); diff --git a/test/fixture/compile/nested_typehint/source/Containers/Box.xphp b/test/fixture/compile/nested_typehint/source/Containers/Box.xphp index c277b57..0f11e45 100644 --- a/test/fixture/compile/nested_typehint/source/Containers/Box.xphp +++ b/test/fixture/compile/nested_typehint/source/Containers/Box.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Containers; +namespace App\NestedTypehint\Containers; class Box { diff --git a/test/fixture/compile/nested_typehint/source/Containers/Wrapper.xphp b/test/fixture/compile/nested_typehint/source/Containers/Wrapper.xphp index a5e774f..1fef414 100644 --- a/test/fixture/compile/nested_typehint/source/Containers/Wrapper.xphp +++ b/test/fixture/compile/nested_typehint/source/Containers/Wrapper.xphp @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace App\Containers; +namespace App\NestedTypehint\Containers; -use App\Containers\Box; +use App\NestedTypehint\Containers\Box; class Wrapper { diff --git a/test/fixture/compile/nested_typehint/source/Models/Plastic.xphp b/test/fixture/compile/nested_typehint/source/Models/Plastic.xphp index a17c3ad..e037dbd 100644 --- a/test/fixture/compile/nested_typehint/source/Models/Plastic.xphp +++ b/test/fixture/compile/nested_typehint/source/Models/Plastic.xphp @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Models; +namespace App\NestedTypehint\Models; final class Plastic { diff --git a/test/fixture/compile/nested_typehint/source/Use.xphp b/test/fixture/compile/nested_typehint/source/Use.xphp index 0df8d31..46fb0bf 100644 --- a/test/fixture/compile/nested_typehint/source/Use.xphp +++ b/test/fixture/compile/nested_typehint/source/Use.xphp @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App; +namespace App\NestedTypehint; -use App\Containers\Wrapper; -use App\Models\Plastic; +use App\NestedTypehint\Containers\Wrapper; +use App\NestedTypehint\Models\Plastic; $wrapper = new Wrapper(); $wrapper->setBoxed(new Plastic('blue'));