Skip to content

Instantly share code, notes, and snippets.

@nikita2206
Created March 20, 2015 15:47
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 nikita2206/efbd3148101ea08cbc73 to your computer and use it in GitHub Desktop.
Save nikita2206/efbd3148101ea08cbc73 to your computer and use it in GitHub Desktop.
<?php
class A {}
class B extends A {}
$foo = function (callable(callable(A)) $cb) {
$cb(function (A $b) { });
};
$foo(function (callable(B) $cb) {
$cb(new B);
});
$foo = function (callable: A $cb) {
$cb();
};
$foo(function (): B { return new B; });
$foo = function (callable: (callable: B) $cb) {
assert($cb()() instanceof B);
};
$foo(function (): callable: B { return function (): B{ return new B; }; });
$foo = function(callable(callable(callable(callable(A)))) $cb) {
$cb(function (callable(callable(A)) $cb) {
$cb(function (A $cb) {
});
});
};
$foo(function (callable(callable(callable(B))) $cb) {
$cb(function (callable(B) $cb) {
$cb(new B);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment