Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #29355 [PropertyAccess] calculate cache keys for property setters…
… depending on the value (xabbuh) This PR was merged into the 3.4 branch. Discussion ---------- [PropertyAccess] calculate cache keys for property setters depending on the value | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29340 | License | MIT | Doc PR | Commits ------- fa23437 calculate cache keys for property setters depending on the value
- Loading branch information
Showing
4 changed files
with
121 additions
and
19 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
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
37 changes: 37 additions & 0 deletions
37
src/Symfony/Component/PropertyAccess/Tests/TestPluralAdderRemoverAndSetter.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,37 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\PropertyAccess\Tests; | ||
|
||
class TestPluralAdderRemoverAndSetter | ||
{ | ||
private $emails = array(); | ||
|
||
public function getEmails() | ||
{ | ||
return $this->emails; | ||
} | ||
|
||
public function setEmails(array $emails) | ||
{ | ||
$this->emails = array('foo@email.com'); | ||
} | ||
|
||
public function addEmail($email) | ||
{ | ||
$this->emails[] = $email; | ||
} | ||
|
||
public function removeEmail($email) | ||
{ | ||
$this->emails = array_diff($this->emails, array($email)); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...y/Component/PropertyAccess/Tests/TestPluralAdderRemoverAndSetterSameSingularAndPlural.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,28 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\PropertyAccess\Tests; | ||
|
||
class TestPluralAdderRemoverAndSetterSameSingularAndPlural | ||
{ | ||
private $aircraft = array(); | ||
|
||
public function getAircraft() | ||
{ | ||
return $this->aircraft; | ||
} | ||
|
||
public function setAircraft(array $aircraft) | ||
{ | ||
$this->aircraft = array('plane'); | ||
} | ||
|
||
public function addAircraft($aircraft) | ||
{ | ||
$this->aircraft[] = $aircraft; | ||
} | ||
|
||
public function removeAircraft($aircraft) | ||
{ | ||
$this->aircraft = array_diff($this->aircraft, array($aircraft)); | ||
} | ||
} |