Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103248 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 9141 invoked from network); 24 Sep 2018 18:21:13 -0000 Received: from unknown (HELO mail-oi0-f52.google.com) (209.85.218.52) by pb1.pair.com with SMTP; 24 Sep 2018 18:21:13 -0000 Received: by mail-oi0-f52.google.com with SMTP id n1-v6so4403779oic.4 for ; Mon, 24 Sep 2018 07:28:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=K0Mak63BzftWnvfIpvDTgzrzHgsOZG/YZMdAofGBq60=; b=LQduCls0vq8SZTmvAuuM+AtgnxA/2HrJ+YeMHRDRvnYY4OUblS8hwg4HQQJEpECG5U E9sV1Ip5yXGBGXJyHpn44FHEw7zN9i331Tmuxu125YNLTF6HSD47szusNGXx/EEIwOPV Vxvx3Pd36056lgHXTJzAUFj2VobjUtFxYPe6w8yyG4+9fzeNAu/I0dTAn3km91m+Nl0i e1RRSM/XZythUl3aXxVDNldNlXSdUzjMd7TLFlwMi6NE/oyCdVpy+5xc5JAy8PFuCWRK 7fZluoupMtALir2YMbqqMiVgKmFM1Hf29WnnPfJQiDAEM2b8oSF4NiqzSH2Fjv1xhT3P C2CA== X-Gm-Message-State: APzg51D1H0lSgTBsYz9oKU3wTtL1BhceqiwXwOXmqsbVz3IHpIdZWnCN EhBcGUp/Iz4QivDaaWFDzt/mRmb+p3AodkhzjexlWQ== X-Google-Smtp-Source: ANB0VdYmJ3oyZ3x7xzwKIrFErhGRPACdxHKcrOuBY98AVIWnd/TJpOpWpBEkdSD47awy9AJqlj0aGDe6ddSh2ZM4kfs= X-Received: by 2002:aca:91a:: with SMTP id 26-v6mr5366686oij.33.1537799331591; Mon, 24 Sep 2018 07:28:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 24 Sep 2018 09:28:39 -0500 Message-ID: To: AGromov@alfabank.ru Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Pre proposal for "Class extension functions" From: pollita@php.net (Sara Golemon) On Mon, Sep 24, 2018 at 6:21 AM Andrey O Gromov wrote: > > I want to do RFS proposal for new language concept - Class extension > functions. > Bring a little Javascript into PHP? Hrmm, maybe. I can see some value, though I'd offer a few thoughts: 1. Consider requiring that a class opt in to allowing these methods. e.g. `class DateTime implements MethodExtensions {}`. I know that this cuts out the power of this feature considerable, but it also limits the unexpected damage from that power. 2. Consider the impact on scoping. If a mixin can suddently access private properties in a foreign class, that may violate assumptions made by that class. Maybe treat mixins as having public scope to avoid this problem, that would also avoid much of my worries expressed in #1. 3. Pure bikeshed, I would make the syntax use the :: delimiter rather than ->. e.g. function DateTime::localTime() { ... } But that's my C++ hat speaking. -Sara