Created
August 26, 2017 20:17
-
-
Save jensscherbl/6563e124766b1c419b3e26e0caaf0787 to your computer and use it in GitHub Desktop.
An example to demonstrate https://github.com/symphonycms/symphony-2/issues/2742
This file contains hidden or 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
| <?php | |
| /* | |
| Some extension. | |
| */ | |
| function delegate(array $context) | |
| { | |
| if (!isset($context['section_ids'])) { | |
| return; | |
| } | |
| if (!is_array($context['section_ids'])) { | |
| return; | |
| } | |
| /* | |
| Things an extension could do with the array... | |
| */ | |
| unset($context['section_ids'][0]); | |
| $context['section_ids'][] = 5; | |
| $context['section_ids'][] = 42; | |
| } | |
| /* | |
| Symphony core 2.7.0. | |
| */ | |
| $section_id = 23; | |
| $section_ids = [ $section_id ]; | |
| delegate([ 'section_ids' => &$section_ids ]); | |
| foreach ($section_ids as $section_id) { | |
| echo $section_id . PHP_EOL; | |
| } | |
| echo PHP_EOL; | |
| /* | |
| Proposed patch. | |
| */ | |
| $section_id = 23; | |
| delegate([ 'section_ids' => [ &$section_id ] ]); | |
| echo $section_id . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment