Skip to content

Commit c33e710

Browse files
committed
BREAKING CHANGE: the default namespace is now App
1 parent 07888de commit c33e710

File tree

10 files changed

+37
-33
lines changed

10 files changed

+37
-33
lines changed

bin/compile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ php "$BOX_BIN" compile;
66

77
php schema.phar generate-types tmp/ tests/e2e/schema.yml;
88

9-
diff tests/e2e/src/AppBundle/Entity/Person.php tmp/AppBundle/Entity/Person.php;
10-
diff tests/e2e/src/AppBundle/Entity/PostalAddress.php tmp/AppBundle/Entity/PostalAddress.php;
11-
diff tests/e2e/src/AppBundle/Entity/Thing.php tmp/AppBundle/Entity/Thing.php;
9+
diff tests/e2e/src/App/Entity/Person.php tmp/App/Entity/Person.php;
10+
diff tests/e2e/src/App/Entity/PostalAddress.php tmp/App/Entity/PostalAddress.php;
11+
diff tests/e2e/src/App/Entity/Thing.php tmp/App/Entity/Thing.php;

src/TypesGeneratorConfiguration.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ public function __construct(?string $defaultPrefix = null)
5151
*/
5252
public function getConfigTreeBuilder(): TreeBuilder
5353
{
54-
$namespacePrefix = $this->defaultPrefix ?? 'AppBundle\\';
54+
$namespacePrefix = $this->defaultPrefix ?? 'App\\';
5555

56-
return (new TreeBuilder('config'))
56+
$treeBuilder = new TreeBuilder('config');
57+
58+
$treeBuilder
5759
->getRootNode()
5860
->children()
5961
->arrayNode('rdfa')
@@ -215,5 +217,7 @@ function ($rdfa) {
215217
->prototype('scalar')->end()
216218
->end()
217219
->end();
220+
221+
return $treeBuilder;
218222
}
219223
}

tests/Command/DumpConfigurationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ public function testDumpConfiguration(): void
8080
prefix: null # Example: App\
8181
8282
# The namespace of the generated entities
83-
entity: AppBundle\Entity # Example: App\Entity
83+
entity: App\Entity # Example: App\Entity
8484
8585
# The namespace of the generated enumerations
86-
enum: AppBundle\Enum # Example: App\Enum
86+
enum: App\Enum # Example: App\Enum
8787
8888
# The namespace of the generated interfaces
89-
interface: AppBundle\Model # Example: App\Model
89+
interface: App\Model # Example: App\Model
9090
9191
# Doctrine
9292
doctrine:

tests/Command/GenerateTypesCommandTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function testFluentMutators(): void
8787
$commandTester = new CommandTester(new GenerateTypesCommand());
8888
$this->assertEquals(0, $commandTester->execute(['output' => $outputDir, 'config' => $config]));
8989

90-
$person = file_get_contents("$outputDir/AppBundle/Entity/Person.php");
90+
$person = file_get_contents("$outputDir/App/Entity/Person.php");
9191
$this->assertStringContainsString(<<<'PHP'
9292
public function setUrl(?string $url): self
9393
{
@@ -126,7 +126,7 @@ public function testDoNotGenerateAccessorMethods(): void
126126
$commandTester = new CommandTester(new GenerateTypesCommand());
127127
$this->assertEquals(0, $commandTester->execute(['output' => $outputDir, 'config' => $config]));
128128

129-
$person = file_get_contents("$outputDir/AppBundle/Entity/Person.php");
129+
$person = file_get_contents("$outputDir/App/Entity/Person.php");
130130
$this->assertStringNotContainsString('function get', $person);
131131
$this->assertStringNotContainsString('function set', $person);
132132
$this->assertStringNotContainsString('function add', $person);
@@ -143,7 +143,7 @@ public function testImplicitAndExplicitPropertyInheritance(): void
143143
$commandTester = new CommandTester(new GenerateTypesCommand());
144144
$this->assertEquals(0, $commandTester->execute(['output' => $outputDir, 'config' => $config]));
145145

146-
$creativeWork = file_get_contents("$outputDir/AppBundle/Entity/CreativeWork.php");
146+
$creativeWork = file_get_contents("$outputDir/App/Entity/CreativeWork.php");
147147
$this->assertStringContainsString('class CreativeWork extends Thing', $creativeWork);
148148
$this->assertStringContainsString('private $copyrightYear;', $creativeWork);
149149
$this->assertStringContainsString('function getCopyrightYear(', $creativeWork);
@@ -152,7 +152,7 @@ public function testImplicitAndExplicitPropertyInheritance(): void
152152
$this->assertStringNotContainsString('function getName(', $creativeWork);
153153
$this->assertStringNotContainsString('function setName(', $creativeWork);
154154

155-
$webPage = file_get_contents("$outputDir/AppBundle/Entity/WebPage.php");
155+
$webPage = file_get_contents("$outputDir/App/Entity/WebPage.php");
156156
$this->assertStringContainsString('class WebPage extends CreativeWork', $webPage);
157157
$this->assertStringContainsString('private $mainEntity;', $webPage);
158158
$this->assertStringContainsString('function getMainEntity(', $webPage);
@@ -175,7 +175,7 @@ public function testReadableWritable(): void
175175
$commandTester = new CommandTester(new GenerateTypesCommand());
176176
$this->assertEquals(0, $commandTester->execute(['output' => $outputDir, 'config' => $config]));
177177

178-
$person = file_get_contents("$outputDir/AppBundle/Entity/Person.php");
178+
$person = file_get_contents("$outputDir/App/Entity/Person.php");
179179
$this->assertStringContainsString('private $sameAs;', $person);
180180
$this->assertStringContainsString('public function getId(', $person);
181181
$this->assertStringNotContainsString('function setId(', $person);
@@ -197,7 +197,7 @@ public function testGeneratedId(): void
197197
$commandTester = new CommandTester(new GenerateTypesCommand());
198198
$this->assertEquals(0, $commandTester->execute(['output' => $outputDir, 'config' => $config]));
199199

200-
$person = file_get_contents("$outputDir/AppBundle/Entity/Person.php");
200+
$person = file_get_contents("$outputDir/App/Entity/Person.php");
201201

202202
$this->assertStringContainsString(<<<'PHP'
203203
/**
@@ -232,7 +232,7 @@ public function testNonGeneratedId(): void
232232
$commandTester = new CommandTester(new GenerateTypesCommand());
233233
$this->assertEquals(0, $commandTester->execute(['output' => $outputDir, 'config' => $config]));
234234

235-
$person = file_get_contents("$outputDir/AppBundle/Entity/Person.php");
235+
$person = file_get_contents("$outputDir/App/Entity/Person.php");
236236

237237
$this->assertStringContainsString(<<<'PHP'
238238
/**
@@ -266,7 +266,7 @@ public function testGeneratedUuid(): void
266266
$commandTester = new CommandTester(new GenerateTypesCommand());
267267
$this->assertEquals(0, $commandTester->execute(['output' => $outputDir, 'config' => $config]));
268268

269-
$person = file_get_contents("$outputDir/AppBundle/Entity/Person.php");
269+
$person = file_get_contents("$outputDir/App/Entity/Person.php");
270270

271271
$this->assertStringContainsString(<<<'PHP'
272272
/**
@@ -302,7 +302,7 @@ public function testNonGeneratedUuid(): void
302302
$commandTester = new CommandTester(new GenerateTypesCommand());
303303
$this->assertEquals(0, $commandTester->execute(['output' => $outputDir, 'config' => $config]));
304304

305-
$person = file_get_contents("$outputDir/AppBundle/Entity/Person.php");
305+
$person = file_get_contents("$outputDir/App/Entity/Person.php");
306306

307307
$this->assertStringContainsString(<<<'PHP'
308308
/**
@@ -337,7 +337,7 @@ public function testDoNotGenerateId(): void
337337
$commandTester = new CommandTester(new GenerateTypesCommand());
338338
$this->assertEquals(0, $commandTester->execute(['output' => $outputDir, 'config' => $config]));
339339

340-
$person = file_get_contents("$outputDir/AppBundle/Entity/Person.php");
340+
$person = file_get_contents("$outputDir/App/Entity/Person.php");
341341

342342
$this->assertStringNotContainsString('$id', $person);
343343
$this->assertStringNotContainsString('function getId', $person);
@@ -391,7 +391,7 @@ public function testGeneratedEnum(): void
391391
$commandTester = new CommandTester(new GenerateTypesCommand());
392392
$this->assertEquals(0, $commandTester->execute(['output' => $outputDir, 'config' => $config]));
393393

394-
$gender = file_get_contents("$outputDir/AppBundle/Enum/GenderType.php");
394+
$gender = file_get_contents("$outputDir/App/Enum/GenderType.php");
395395

396396
$this->assertStringContainsString(<<<'PHP'
397397
/**
@@ -414,7 +414,7 @@ public function testSupersededProperties(): void
414414
$commandTester = new CommandTester(new GenerateTypesCommand());
415415
$this->assertEquals(0, $commandTester->execute(['output' => $outputDir, 'config' => $config]));
416416

417-
$creativeWork = file_get_contents("$outputDir/AppBundle/Entity/CreativeWork.php");
417+
$creativeWork = file_get_contents("$outputDir/App/Entity/CreativeWork.php");
418418

419419
$this->assertStringContainsString(<<<'PHP'
420420
/**

tests/TypesGeneratorTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private function getConfig(): array
127127
],
128128
'checkIsGoodRelations' => false,
129129
'namespaces' => [
130-
'entity' => 'AppBundle\Entity',
130+
'entity' => 'App\Entity',
131131
],
132132
'output' => 'build/type-generator-test',
133133
'types' => [
@@ -221,7 +221,7 @@ private function getClasses(): array
221221
'hasChild' => true,
222222
'isEnum' => false,
223223
'name' => 'Article',
224-
'namespace' => 'AppBundle\Entity',
224+
'namespace' => 'App\Entity',
225225
'parent' => 'CreativeWork',
226226
],
227227
'BlogPosting' => [
@@ -245,7 +245,7 @@ private function getClasses(): array
245245
'hasChild' => false,
246246
'isEnum' => false,
247247
'name' => 'BlogPosting',
248-
'namespace' => 'AppBundle\Entity',
248+
'namespace' => 'App\Entity',
249249
'parent' => 'SocialMediaPosting',
250250
],
251251
'CreativeWork' => [
@@ -308,7 +308,7 @@ private function getClasses(): array
308308
'hasChild' => true,
309309
'isEnum' => false,
310310
'name' => 'CreativeWork',
311-
'namespace' => 'AppBundle\Entity',
311+
'namespace' => 'App\Entity',
312312
'parent' => 'Thing',
313313
],
314314
'Person' => [
@@ -332,7 +332,7 @@ private function getClasses(): array
332332
'hasChild' => false,
333333
'isEnum' => false,
334334
'name' => 'Person',
335-
'namespace' => 'AppBundle\Entity',
335+
'namespace' => 'App\Entity',
336336
'parent' => 'Thing',
337337
],
338338
'SocialMediaPosting' => [
@@ -356,7 +356,7 @@ private function getClasses(): array
356356
'hasChild' => true,
357357
'isEnum' => false,
358358
'name' => 'SocialMediaPosting',
359-
'namespace' => 'AppBundle\Entity',
359+
'namespace' => 'App\Entity',
360360
'parent' => 'Article',
361361
],
362362
'Thing' => [
@@ -380,7 +380,7 @@ private function getClasses(): array
380380
'hasChild' => true,
381381
'isEnum' => false,
382382
'name' => 'Thing',
383-
'namespace' => 'AppBundle\Entity',
383+
'namespace' => 'App\Entity',
384384
'parent' => false,
385385
],
386386
];

tests/config/blog.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ annotationGenerators: # Generators we want to use
33
- ApiPlatform\SchemaGenerator\AnnotationGenerator\DoctrineOrmAnnotationGenerator
44
- ApiPlatform\SchemaGenerator\AnnotationGenerator\ConstraintAnnotationGenerator
55
namespaces:
6-
entity: AppBundle\Entity # The default namespace for entities, following API Platform and Symfony best practices
6+
entity: App\Entity # The default namespace for entities, following API Platform and Symfony best practices
77
types: # The list of type to generated (a PHP entity class by type will be generated)
88
SocialMediaPosting: ~
99
BlogPosting: ~ # A type to generate a PHP entity class from, including all its properties (here this type has no specific property, they are all inherited)

tests/config/vgo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ annotationGenerators:
66
- ApiPlatform\SchemaGenerator\AnnotationGenerator\ConstraintAnnotationGenerator
77

88
namespaces:
9-
entity: 'AppBundle\Entity'
9+
entity: 'App\Entity'
1010

1111
types:
1212
Session:

tests/e2e/src/AppBundle/Entity/Person.php renamed to tests/e2e/src/App/Entity/Person.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace AppBundle\Entity;
5+
namespace App\Entity;
66

77
use ApiPlatform\Core\Annotation\ApiProperty;
88
use ApiPlatform\Core\Annotation\ApiResource;
@@ -63,7 +63,7 @@ class Person
6363
/**
6464
* @var PostalAddress|null physical address of the item
6565
*
66-
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\PostalAddress")
66+
* @ORM\ManyToOne(targetEntity="App\Entity\PostalAddress")
6767
* @ApiProperty(iri="http://schema.org/address")
6868
*/
6969
private $address;

tests/e2e/src/AppBundle/Entity/PostalAddress.php renamed to tests/e2e/src/App/Entity/PostalAddress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace AppBundle\Entity;
5+
namespace App\Entity;
66

77
use ApiPlatform\Core\Annotation\ApiProperty;
88
use ApiPlatform\Core\Annotation\ApiResource;

tests/e2e/src/AppBundle/Entity/Thing.php renamed to tests/e2e/src/App/Entity/Thing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace AppBundle\Entity;
5+
namespace App\Entity;
66

77
use ApiPlatform\Core\Annotation\ApiProperty;
88
use ApiPlatform\Core\Annotation\ApiResource;

0 commit comments

Comments
 (0)