-
-
Save Ocramius/c6f9504dac41530d5746a51c0e060914 to your computer and use it in GitHub Desktop.
function chaining for PHP 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types=1); | |
require_once "✨.🐘"; | |
✨($_)->strlen("foo")->var_dump($_); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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