Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109952 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25891 invoked from network); 1 May 2020 16:10:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 May 2020 16:10:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 352991804C7 for ; Fri, 1 May 2020 07:44:48 -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=1.1 required=5.0 tests=BAYES_00,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-vs1-f53.google.com (mail-vs1-f53.google.com [209.85.217.53]) (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 07:44:47 -0700 (PDT) Received: by mail-vs1-f53.google.com with SMTP id a5so6395398vsm.7 for ; Fri, 01 May 2020 07:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bukrek-net.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=vSW1yTaYzxkfvg+gNWqXOhX+o0iGoh3JM6du8MaVmFQ=; b=NAXi++EqjJ14Wzi11KUiffL+OipJD9RfTLVZPh+FCgDEX6rPOmyp2PhOvbQg0LxdyA bS4K5V0MS8lV5KFkIG9bAuQYE4ofFAuyfEfu+6njXYKhQVNtCmrfR/3LERPy0hN15VBt jlF4o+Ye+tL2nKdebTA4t2S/0DLKqumfiTH2i8IRGbT1dw2wsrtlo1cKA8qD/8mt8VP8 hRNj5AMLE9DsSaqLLCgpFLf+Mq/7tUvIs4Lz+vL6EYwuL4ilPuGEEy8o1tcqhoAjCGvw KhR3fIzchzJ/auEGoQ1pbMYp6tfOs2vZGzLQaWF0OSL2HRZRF1AwlgCV4QECr35AKV5l bPbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=vSW1yTaYzxkfvg+gNWqXOhX+o0iGoh3JM6du8MaVmFQ=; b=cYg56nAIVpPexmJ17eYAhQzdUMvClTSoQov1JPFkhFgwLT36yCYQRjhwgA6NwcesD2 +GkjB2CvrjCcr65YXcNvE4lydw+thXIBOogo9dVyJROKYg4OCdjHaWXQ6bGUZDqzDT5F Nah8F8Vt6q0/c3e8w6UE/s63ns59YY2ott93227zAet6k7VKvxZVu7VLudEMCtvzaVqi U607LczPEyWvLQ2ulv1CM+mR+ZnBlbE/G9vpoqZWYuOpsYokL/1olVl3HIgcB0Bn1/5V AHrPLuUaB18NU1lGTSZnND/TCN6ZNkaWsCgH5nGd5TIxpIkt92aWh/UxRlaU4BhGiq2K ZNNA== X-Gm-Message-State: AGi0PuZo/tRB2bhQFiTJQgAB+WEOEGgXti2KCvSuWqS7u+nXSGRjFyJE RyyyCaYmzhh1YDbatDYQkx0splm/4e+pjsd5G4hW4Ne3lL7obw== X-Google-Smtp-Source: APiQypLjUH/wA5ou7sw0j3OZhmLFHlC9FJrmH/hulwzzBQW4j6r2ClKfMPvKjmcxj9Iaa6QZ8EcBgB9lcKPG12Lw8E0= X-Received: by 2002:a67:902:: with SMTP id 2mr3731310vsj.133.1588344285219; Fri, 01 May 2020 07:44:45 -0700 (PDT) MIME-Version: 1.0 Date: Fri, 1 May 2020 17:44:33 +0300 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000e6d4b105a4973865" Subject: Simplify classes syntax proposal From: max@bukrek.net (Max D) --000000000000e6d4b105a4973865 Content-Type: text/plain; charset="UTF-8" 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=1); This directive will switch interpreter mode, where class declared properties and methods are accessible as regular variables and functions at class code. So, such a fragment public function __construct() { $this->get = $this->clean($_GET); $this->post = $this->clean($_POST); $this->request = $this->clean($_REQUEST); $this->cookie = $this->clean($_COOKIE); $this->files = $this->clean($_FILES); $this->server = $this->clean($_SERVER); } will look so with the proposed directive: public function __construct() { $get = clean($_GET); $post = clean($_POST); $request = clean($_REQUEST); $cookie = clean($_COOKIE); $files = clean($_FILES); $server = clean($_SERVER); } What do we lose with such an approach? The ability to use local variables named as class properties and the ability to call regular functions, called as class methods. Both things are super-rarely used and programmers have 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 --000000000000e6d4b105a4973865--