Hacker News new | ask | show | jobs
by kemo 5194 days ago
IMHO, you're trying too hard to fix the things which aren't broken in the first place. Covering the main flaws in PHP would be sufficient, e.g.

    str = 'foo'.replace('#', '').substr(1).as_array();
    int = 5.something();
would translate to

    $str = 'foo';
    $str = str_replace('#', '', $str);
    $str = substr($str, 1);
    $str = (array) $str;
    
    $int = 5;
    $int = something($int);
This would allow us to do things that aren't native to PHP but still have something much easier. Having strings, integers and other types used as objects (with a solid proxy syntax to the native functions) would be the first (and best) step forward.

Class definitions as well:

    Foo {
        // constants 
        BAR = 'fubar',
        BAR2 = 'foo';
        
        // properties
        protected _bar, _fubar;
    
        // public properties / methods
        public
        bar() {
            return ._bar;
        },
        fubar() {
            return ._bar + ._fubar;
        }
    }