Skip to content

Instantly share code, notes, and snippets.

@Danack
Last active March 19, 2020 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Danack/49c6e39a97cfcd978388276649682e7a to your computer and use it in GitHub Desktop.
Save Danack/49c6e39a97cfcd978388276649682e7a to your computer and use it in GitHub Desktop.
auto vs explicit unboxing.
<?php
// a function in the email api library we're using.
function sendEmail(string $email, string $body, string $subject) {}
// A function in our application
function foo(EmailString $es, NameString $ns)
{
$body = "Hello " . $ns;
sendEmail($es, $body, "howdy");
}
// vs A function in our application with unboxing.
function foo(EmailString $es, NameString $ns)
{
$body = "Hello " . $ns->unbox();
sendEmail($es->unbox(), $body, "howdy");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment