Skip to content

Commit 019e21c

Browse files
authored
fix: inheritance from Intangible should not create warning (#365)
1 parent 5115f5e commit 019e21c

File tree

5 files changed

+141
-1
lines changed

5 files changed

+141
-1
lines changed

bin/compile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ rm -rf tmp/original
88

99
php schema.phar generate tmp/original tests/e2e/schema.yml -n -vv --ansi;
1010

11+
diff tests/e2e/original/App/Entity/Brand.php tmp/original/App/Entity/Brand.php;
1112
diff tests/e2e/original/App/Entity/Person.php tmp/original/App/Entity/Person.php;
1213
diff tests/e2e/original/App/Entity/PostalAddress.php tmp/original/App/Entity/PostalAddress.php;
1314
diff tests/e2e/original/App/Entity/Thing.php tmp/original/App/Entity/Thing.php;
@@ -19,6 +20,7 @@ cp -r tests/e2e/customized tmp/
1920

2021
php schema.phar generate tmp/customized tests/e2e/schema.yml -n -vv --ansi;
2122

23+
diff tests/e2e/customized/App/Entity/Brand.php tmp/customized/App/Entity/Brand.php;
2224
diff tests/e2e/customized/App/Entity/Person.php tmp/customized/App/Entity/Person.php;
2325
diff tests/e2e/customized/App/Entity/PostalAddress.php tmp/customized/App/Entity/PostalAddress.php;
2426
diff tests/e2e/customized/App/Entity/Thing.php tmp/customized/App/Entity/Thing.php;

src/ClassMutator/ClassPropertiesAppender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __invoke(Class_ $class): Class_
6262
}
6363

6464
foreach ($this->getParentClasses($class->resource()) as $typeInHierarchy) {
65-
foreach ($this->propertiesMap[$typeInHierarchy->getUri()] as $property) {
65+
foreach ($this->propertiesMap[$typeInHierarchy->getUri()] ?? [] as $property) {
6666
if ($key !== $property->localName()) {
6767
continue;
6868
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Entity;
6+
7+
use ApiPlatform\Core\Annotation\ApiProperty;
8+
use ApiPlatform\Core\Annotation\ApiResource;
9+
use Doctrine\ORM\Mapping as ORM;
10+
11+
/**
12+
* A brand is a name used by an organization or business person for labeling a product, product group, or similar.
13+
*
14+
* @see https://schema.org/Brand
15+
*/
16+
#[ORM\Entity]
17+
#[ApiResource(iri: 'https://schema.org/Brand')]
18+
class Brand
19+
{
20+
#[ORM\Id]
21+
#[ORM\GeneratedValue(strategy: 'AUTO')]
22+
#[ORM\Column(type: 'integer')]
23+
private ?int $id = null;
24+
25+
/**
26+
* The name of the item.
27+
*
28+
* @see https://schema.org/name
29+
*/
30+
#[ORM\Column(type: 'text', nullable: true)]
31+
#[ApiProperty(iri: 'https://schema.org/name')]
32+
private ?string $name = null;
33+
34+
/**
35+
* A slogan or motto associated with the item.
36+
*
37+
* @see https://schema.org/slogan
38+
*/
39+
#[ORM\Column(type: 'text', nullable: true)]
40+
#[ApiProperty(iri: 'https://schema.org/slogan')]
41+
private ?string $slogan = null;
42+
43+
public function getId(): ?int
44+
{
45+
return $this->id;
46+
}
47+
48+
public function setName(?string $name): void
49+
{
50+
$this->name = $name;
51+
}
52+
53+
public function getName(): ?string
54+
{
55+
return $this->name;
56+
}
57+
58+
public function setSlogan(?string $slogan): void
59+
{
60+
$this->slogan = $slogan;
61+
}
62+
63+
public function getSlogan(): ?string
64+
{
65+
return $this->slogan;
66+
}
67+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Entity;
6+
7+
use ApiPlatform\Core\Annotation\ApiProperty;
8+
use ApiPlatform\Core\Annotation\ApiResource;
9+
use Doctrine\ORM\Mapping as ORM;
10+
11+
/**
12+
* A brand is a name used by an organization or business person for labeling a product, product group, or similar.
13+
*
14+
* @see https://schema.org/Brand
15+
*/
16+
#[ORM\Entity]
17+
#[ApiResource(iri: 'https://schema.org/Brand')]
18+
class Brand
19+
{
20+
#[ORM\Id]
21+
#[ORM\GeneratedValue(strategy: 'AUTO')]
22+
#[ORM\Column(type: 'integer')]
23+
private ?int $id = null;
24+
25+
/**
26+
* The name of the item.
27+
*
28+
* @see https://schema.org/name
29+
*/
30+
#[ORM\Column(type: 'text', nullable: true)]
31+
#[ApiProperty(iri: 'https://schema.org/name')]
32+
private ?string $name = null;
33+
34+
/**
35+
* A slogan or motto associated with the item.
36+
*
37+
* @see https://schema.org/slogan
38+
*/
39+
#[ORM\Column(type: 'text', nullable: true)]
40+
#[ApiProperty(iri: 'https://schema.org/slogan')]
41+
private ?string $slogan = null;
42+
43+
public function getId(): ?int
44+
{
45+
return $this->id;
46+
}
47+
48+
public function setName(?string $name): void
49+
{
50+
$this->name = $name;
51+
}
52+
53+
public function getName(): ?string
54+
{
55+
return $this->name;
56+
}
57+
58+
public function setSlogan(?string $slogan): void
59+
{
60+
$this->slogan = $slogan;
61+
}
62+
63+
public function getSlogan(): ?string
64+
{
65+
return $this->slogan;
66+
}
67+
}

tests/e2e/schema.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ types:
3131
url: ~
3232
siblings: { cardinality: "(0..*)" }
3333
customColumn: { ormColumn: {type: "decimal", precision: 5, scale: 1, options: {comment: "my comment"}} }
34+
Brand:
35+
properties:
36+
name: ~
37+
slogan: ~
3438
PostalAddress:
3539
properties:
3640
addressCountry: { range: https://schema.org/Text }

0 commit comments

Comments
 (0)