Skip to content

Commit 775b002

Browse files
committed
Use object typehint for type object
1 parent e1b781d commit 775b002

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed

src/Util/ClassSourceManipulator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,8 @@ private function getEntityTypeHint($doctrineType): ?string
11991199
return '\\'.\DateInterval::class;
12001200

12011201
case 'object':
1202+
return 'object';
1203+
12021204
case 'binary':
12031205
case 'blob':
12041206
default:

tests/Util/ClassSourceManipulatorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,15 @@ public function getAddEntityFieldTests(): \Generator
318318
],
319319
'User_simple_prop_zero.php',
320320
];
321+
322+
yield 'entity_add_object' => [
323+
'User_simple.php',
324+
'someObject',
325+
[
326+
'type' => 'object',
327+
],
328+
'User_simple_object.php',
329+
];
321330
}
322331

323332
/**
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace App\Entity;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
#[ORM\Entity]
8+
class User
9+
{
10+
#[ORM\Id]
11+
#[ORM\GeneratedValue]
12+
#[ORM\Column(type: 'integer')]
13+
private $id;
14+
15+
#[ORM\Column(type: 'object')]
16+
private $someObject;
17+
18+
public function getId(): ?int
19+
{
20+
return $this->id;
21+
}
22+
23+
public function getSomeObject(): ?object
24+
{
25+
return $this->someObject;
26+
}
27+
28+
public function setSomeObject(object $someObject): self
29+
{
30+
$this->someObject = $someObject;
31+
32+
return $this;
33+
}
34+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Entity;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
/**
8+
* @ORM\Entity()
9+
*/
10+
class User
11+
{
12+
/**
13+
* @ORM\Id
14+
* @ORM\GeneratedValue
15+
* @ORM\Column(type="integer")
16+
*/
17+
private $id;
18+
19+
/**
20+
* @ORM\Column(type="object")
21+
*/
22+
private $someObject;
23+
24+
public function getId(): ?int
25+
{
26+
return $this->id;
27+
}
28+
29+
public function getSomeObject(): ?object
30+
{
31+
return $this->someObject;
32+
}
33+
34+
public function setSomeObject(object $someObject): self
35+
{
36+
$this->someObject = $someObject;
37+
38+
return $this;
39+
}
40+
}

0 commit comments

Comments
 (0)