<story><title>Underscore.php</title><url>http://brianhaveri.github.com/Underscore.php/</url></story><parent_chain></parent_chain><comment><author>yahelc</author><text>This will be even more aesthetically pleasing once PHP 5.4 is released with support for array literals:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    __::map([1, 2, 3]), function($n) { return $n * 2; });
    __([1, 2, 3])-&amp;#62;map(function($n) { return $n * 2; });
&lt;/code&gt;&lt;/pre&gt;
That, combined with array dereferencing (ie, explode(&quot;,&quot;,$str)[0] ), PHP will start to look a lot like JavaScript.</text></comment>
<story><title>Underscore.php</title><url>http://brianhaveri.github.com/Underscore.php/</url></story><parent_chain></parent_chain><comment><author>fooyc</author><text>Why not using namespaced functions instead of static methods all in the same class ? This would have allowed to add new functions. This would even have allowed to use the _ namespace.&lt;p&gt;With namespaces:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    namespace _;  
    function each() {
    }

    // chaining can be achieved with this:

    class Wrapper {
        private $coll;
        function __construct($coll) {
            $this-&amp;#62;coll = $coll;
        }
        function __call($name, $args) {
            array_unshift($this-&amp;#62;coll,$args);
            return new self(call_user_func_array(&apos;_\\&apos;.$name, $args));
        }
    }

    function __($coll) {
        return new Wrapper($coll);
    }

    use _;  
    _\each(...);

    // or
  
    __($coll)-&amp;#62;each(...);

    // I can add new functions

    namespace _;
    function something(){}

&lt;/code&gt;&lt;/pre&gt;
With static methods:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    class __ {  
        function each() {  
        }  
    }

    // throws strict errors

    __::each(...);

    // can&apos;t add functions
&lt;/code&gt;&lt;/pre&gt;
Also it seems that the normal way to use the library is to call isntance methods statically, which triggers many warnings with E_STRICT :(&lt;p&gt;&lt;a href=&quot;https://github.com/lstrojny/functional-php&quot; rel=&quot;nofollow&quot;&gt;https://github.com/lstrojny/functional-php&lt;/a&gt; also brings some functional stuff to php.</text></comment>