Skip to content

Instantly share code, notes, and snippets.

@jensscherbl
Created August 26, 2017 20:17
Show Gist options
  • Select an option

  • Save jensscherbl/6563e124766b1c419b3e26e0caaf0787 to your computer and use it in GitHub Desktop.

Select an option

Save jensscherbl/6563e124766b1c419b3e26e0caaf0787 to your computer and use it in GitHub Desktop.
<?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