Skip to content

Commit d5d142e

Browse files
committed
bug #367 Question helper return zero as string (LeJeanbono)
This PR was squashed before being merged into the 1.0-dev branch (closes #367). Discussion ---------- Question helper return zero as string Fix #366 Commits ------- af48996 Question helper return zero as string
2 parents 186ffc8 + af48996 commit d5d142e

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

src/Util/ClassSourceManipulator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ private function quoteAnnotationValue($value)
404404
return 'null';
405405
}
406406

407-
if (\is_int($value)) {
407+
if (\is_int($value) || '0' === $value) {
408408
return $value;
409409
}
410410

tests/Util/ClassSourceManipulatorTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,17 @@ public function getAddEntityFieldTests()
237237
],
238238
'User_simple_prop_already_exists.php'
239239
];
240+
241+
yield 'entity_field_property_zero' => [
242+
'User_simple.php',
243+
'decimal',
244+
[
245+
'type' => 'decimal',
246+
'precision' => 6,
247+
'scale' => 0,
248+
],
249+
'User_simple_prop_zero.php'
250+
];
240251
}
241252

242253
/**
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="decimal", precision=6, scale=0)
21+
*/
22+
private $decimal;
23+
24+
public function getId(): ?int
25+
{
26+
return $this->id;
27+
}
28+
29+
public function getDecimal()
30+
{
31+
return $this->decimal;
32+
}
33+
34+
public function setDecimal($decimal): self
35+
{
36+
$this->decimal = $decimal;
37+
38+
return $this;
39+
}
40+
}

0 commit comments

Comments
 (0)