Skip to content

Instantly share code, notes, and snippets.

@dimabory
Last active January 30, 2019 10:23
Show Gist options
  • Save dimabory/3351f9a2b21fcd8f7e8f204a8e134018 to your computer and use it in GitHub Desktop.
Save dimabory/3351f9a2b21fcd8f7e8f204a8e134018 to your computer and use it in GitHub Desktop.
return true
<?php
function foo($x)
{
return $x === $x();
}
<?php
class Bar {}
function foo(Bar $x)
{
return get_class($x) != 'Bar';
}
<?php
class Bar
{
private $a;
public function __construct($a)
{
$this->a = (bool) $a;
}
public function a()
{
return $this->a;
}
}
function foo(callable $x)
{
$object = new Bar(false);
$x($object);
return $object->a();
}
<?php
class Test
{
private $foo = true;
}
function foo($x)
{
$o = (array) new Test;
return $o[$x];
}
@dimabory
Copy link
Author

2

foo(new class() extends Bar {})

@dimabory
Copy link
Author

1

foo($a = function() use (&$a) { return $a; })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment