-
-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #788 [Live] Ignore problems with writing bad types for writab…
…le paths (weaverryan) This PR was merged into the 2.x branch. Discussion ---------- [Live] Ignore problems with writing bad types for writable paths | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Tickets | None | License | MIT Found when building some components. The motivating use-case is where you have a writable property that starts null but the setter method does NOT allow null (this is common with entity properties and methods). When that null is rehydrated later, we attempt to call the setter with a null value, which explodes. This makes for a better UX... though with a sprinkle of magic to make it happen. Without this, you would need to make your setter methods allow null (e.g. `setName(?string $name)`) *just* because the original property starts as null. Cheers! Commits ------- 1cd97fd [Live] Ignore problems with writing bad types for writable paths
- Loading branch information
Showing
3 changed files
with
73 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/LiveComponent/tests/Fixtures/Entity/CategoryFixtureEntity.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* @ORM\Entity | ||
*/ | ||
class CategoryFixtureEntity | ||
{ | ||
/** | ||
* @ORM\Id | ||
* @ORM\GeneratedValue | ||
* @ORM\Column(type="integer") | ||
*/ | ||
private ?int $id = null; | ||
|
||
/** | ||
* @ORM\Column(type="string") | ||
*/ | ||
private ?string $name = null; | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getName(): ?string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setName(string $name) | ||
{ | ||
$this->name = $name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters