Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109956 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 38741 invoked from network); 1 May 2020 16:59:01 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 May 2020 16:59:01 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5F93518050A for ; Fri, 1 May 2020 08:32:59 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: ** X-Spam-Status: No, score=2.6 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-vk1-f169.google.com (mail-vk1-f169.google.com [209.85.221.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 1 May 2020 08:32:59 -0700 (PDT) Received: by mail-vk1-f169.google.com with SMTP id v192so2774743vkd.3 for ; Fri, 01 May 2020 08:32:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bukrek-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oTXlGtvvYEVqxHDdjC7Kw+YJfoTquLXobmYwD4jVLig=; b=m+TDkQn32t5si9xzWjJldQHNJzNqOD7H8JMATgPpPIckaRGJQeqQfg1msqNrwArJce 927lel2rp3HmL+it+d/XulBhv0PH7LUA05NCFdrc5QE5KflqGFNE9jPKx3uDC8Zfa4ce pyZvxJRg5x7dEdF7is4Li4kjO1y6aZnlAbW0Mdrxg9TaxMD4dkYaHUeWnYVUM6TzVeuF Gb5LuUHeRFcwzcip04hfTUkFSnt97qnfd3fmXy7b8Cmm5Z/ZJREfWAK2MLgCgNYFlb7u 5EVja4zDxNSEbfvlP28ujhGxrSyO9Ipd69EJzNQmiwAVpUSqFUxpZ7uf6i9aIuCbuTVQ jO0w== 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=oTXlGtvvYEVqxHDdjC7Kw+YJfoTquLXobmYwD4jVLig=; b=qGMivxvWSWhoa8KFrqRhjG9CJuxzOo8NzjYnNrW1H1CA3NmmdTkVjb5H+K4DbOpG3U xmyEkwXnxkYbHLGd8YYjfYksQBmHEzIvRIg7UHiCO2w6CalYOH3U0PzAoStmbXR+O1Kw MOznaH5rNzR4z/i41RDbtXNAHtCrPO5ofSidcIVUsGj8qZ+kmjgh8fFen6WWAI89nvN/ rFs8BAGukC6ph1wwsn/KPT3NgFfFhRQseThw3nCD4QKsMB5cgywHLO+LtK6UM59vkXsa G6iBF+daEwqntLHWpXsgn1cuwfkNd7HeCE3rmAMsfpaFIAycju/tCanSIQa5Rn/nZgQQ fKxg== X-Gm-Message-State: AGi0PubfG9lurBRspz9nPRd/3zv2spt04taeMkR5VWCbNEPrFKAy5xi1 FbGoIOLgCw4WfFcySANANlLXX9EoRIOV3QdSL5PYvA== X-Google-Smtp-Source: APiQypIgWxfdT+azKfE+aXURHPrewwnMj8VXWsVdl/6aOMYYLxW6lmQVUJoUe6BrLU+iC3M6A8bvFsoTPQ/TXH0oZmI= X-Received: by 2002:a1f:a3d0:: with SMTP id m199mr3160221vke.13.1588347175909; Fri, 01 May 2020 08:32:55 -0700 (PDT) MIME-Version: 1.0 References: <647703CF-1015-4FBF-868F-8E3525706A43@benramsey.com> In-Reply-To: <647703CF-1015-4FBF-868F-8E3525706A43@benramsey.com> Date: Fri, 1 May 2020 18:32:43 +0300 Message-ID: To: Ben Ramsey Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000334f1405a497e5af" Subject: Re: [PHP-DEV] Simplify classes syntax proposal From: max@bukrek.net (Max D) --000000000000334f1405a497e5af Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Forgot to add. As for me, poor developers experience is that I am forced to write the same 6-symbols prefix with 1 or 2 Shift-keystrokes 20-30 times per one code page - without alternatives. With best regards, MaxD =D0=BF=D1=82, 1 =D1=82=D1=80=D0=B0=D0=B2. 2020 =D0=BE 18:02 Ben Ramsey =D0=BF=D0=B8=D1=88=D0=B5: > > On May 1, 2020, at 09:44, Max D wrote: > > > > Greetings, Internals! > > > > This is my first try to input the proposal, please don't be strict ) > > > > All the years with PHP I hate writing classes. The need to prefix EVERY > > property and method use looks horrible and writes horrible. So, the > > proposal: > > > > Lets introduce directive > > declare(simple_classes=3D1); > > > > This directive will switch interpreter mode, where class declared > > properties and methods are accessible as regular variables and function= s > at > > class code. > > > > So, such a fragment > > > > public function __construct() { > > $this->get =3D $this->clean($_GET); > > $this->post =3D $this->clean($_POST); > > $this->request =3D $this->clean($_REQUEST); > > $this->cookie =3D $this->clean($_COOKIE); > > $this->files =3D $this->clean($_FILES); > > $this->server =3D $this->clean($_SERVER); > > } > > > > will look so with the proposed directive: > > > > public function __construct() { > > $get =3D clean($_GET); > > $post =3D clean($_POST); > > $request =3D clean($_REQUEST); > > $cookie =3D clean($_COOKIE); > > $files =3D clean($_FILES); > > $server =3D clean($_SERVER); > > } > > > > What do we lose with such an approach? The ability to use local variabl= es > > named as class properties and the ability to call regular functions, > called > > as class methods. Both things are super-rarely used and programmers hav= e > > the ability to change naming to achieve them. > > > > For static properties/methods, dynamic ones will have an advantage if > > naming matches. > > Of course, the ability to use usual prefixes will be preserved. > > > > I'm not going to implement this, hoping someone will volunteer if the > > reaction is positive. > > Also I have some more proposals I will post if this one goes nice. > > > > With best regards, > > MaxD > > > Hi, MaxD! > > Is there a particular problem you=E2=80=99re trying to solve with this pr= oposal? > You say, =E2=80=9CAll the years with PHP I hate writing classes. The need= to prefix > EVERY property and method use looks horrible and writes horrible.=E2=80= =9D > > I=E2=80=99m generally in favor of changes that make it easier for develop= ers to do > their jobs well, but I don=E2=80=99t think writing `$this->` in front of = property > and method names is a detriment to the development process. In fact, I > think it aids in writing safe code. Without `$this->`, it=E2=80=99s possi= ble to > unknowingly use or overwrite a class property, when that is not the inten= t. > I think this leads to a poor developer experience, so I would be against > this change. > > Cheers, > Ben > > > > --000000000000334f1405a497e5af--