Skip to content

Instantly share code, notes, and snippets.

@lunetics
Created May 14, 2019 09:23
Show Gist options
  • Save lunetics/5a26646f2394cbbc46bbf949a0f0d03f to your computer and use it in GitHub Desktop.
Save lunetics/5a26646f2394cbbc46bbf949a0f0d03f to your computer and use it in GitHub Desktop.
<?php
function Loose(?array $foo) : ?array
{
$localScoped = null;
if ($foo !== null) {
foreach ($foo as $bar) {
$localScoped[] = $bar->stuff();
}
}
return $localScoped;
}
function LooseCallee(?array $other) : ?array
{
$localScoped = null;
if ($other !== null) {
foreach ($other as $bar) {
$localScoped[] = $bar->stuff();
}
}
return $localScoped;
}
<?php
function tight(array $foo) : array
{
$localScoped = [];
foreach ($foo as $bar) {
$localScoped[] = $bar->stuff();
}
return $localScoped;
}
function tightCallee(array $resultSet) : array
{
$localScoped = [];
foreach ($resultSet as $bar) {
$localScoped[] = $bar->stuff();
}
return $localScoped;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment