Skip to content

Instantly share code, notes, and snippets.

@harikt
Forked from hikari-no-yume/example.php
Created March 21, 2017 09:35
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 harikt/8978f8a0c09e3ab2f4144946c47d01c8 to your computer and use it in GitHub Desktop.
Save harikt/8978f8a0c09e3ab2f4144946c47d01c8 to your computer and use it in GitHub Desktop.
function chaining for PHP 7
<?php declare(strict_types=1);
require_once "✨.🐘";
✨($_)->strlen("foo")->var_dump($_);
<?php declare(strict_types=1);
function ✨(&$_) {
return new class($_) {
private $_;
public function __construct(&$_) {
$this->_ = &$_;
}
public function __call(string $name, array $args): self {
$this->_ = $name(...$args);
return $this;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment