rlvdx
3/20/2017 - 8:02 PM

function chaining for PHP 7

function chaining for PHP 7

<?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;
        }
    };
}
<?php declare(strict_types=1);

require_once "✨.";

✨($_)->strlen("foo")->var_dump($_);