Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102947 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47614 invoked from network); 22 Jul 2018 08:36:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jul 2018 08:36:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.49 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.49 mail-it0-f49.google.com Received: from [209.85.214.49] ([209.85.214.49:54177] helo=mail-it0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F5/0B-47674-F02445B5 for ; Sun, 22 Jul 2018 04:36:31 -0400 Received: by mail-it0-f49.google.com with SMTP id 72-v6so20075408itw.3 for ; Sun, 22 Jul 2018 01:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Z0KiC8B/zUu2JWtcJBQS5KbOIdo5A+hAE81Jyb6XCHs=; b=l6yb0DQkXYaooB0kirdFHD6zw6zc/NPYQIaTwr0A7QqzKRnFIgxRmyfY50s2M80MDn qbWr/lXf8KBRUkvglYm51ZFxODBzCUCKfxt3+n9UrtbYGL0UgRyPPOzwOqmOduxbVWwD eauQnmNdpIbTblnwxuaAhgIy0a3TheY2pbaAzZVQ3Fq0PfNt9GQYT/pQYr5ttET7uyba +eqDoFtLIm2YN2Rdly4Ggsy/R9gT3Idf7BfgCOwoobUN00Q21RlDjyzZRF5HyT+I2qCq 4wnBw0mAa9ewA3RFEbDxLNzVVaJA45efxafAImE0B8NQqLjN2FoJ+UUmFryZLVDs/3WI OykQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Z0KiC8B/zUu2JWtcJBQS5KbOIdo5A+hAE81Jyb6XCHs=; b=oKz2StsDeK4Ah1Rcj9HzD9kJF/SnsMy49iFz0oB3kEE2rHTiEbcWoBv/QKJGYBHGIB H/sMMbCETeeelS1TU28Fojc45/2xGy31Un/41ZAqri5qE40BowYYIfOHbD5HVFTqlGpy 13kBtPnEJTcf2OCTRxt+/CdGTkrmaGUoemGdLkoutY7K4zxprEFGJguhI/hSph/z93Sd My+/nIWnLXu0OjVtxrdLwdFA1xEBlhossQrzo7RnUWOy0SATYbFXZ9yYnIF498KyEBgD ODc20r6Z8X79jefpAvEKWgDcsEbRuwZ4x3N12TIOTXKZJDGeaNAqYJszYdz+SwoRwjpE Szag== X-Gm-Message-State: AOUpUlEnvOdVoI4QcNh4q0pXOE/Hu8IZuECZB6w4YRbRgjHeEeasGW0e amHdobYyfjPM6gFVCrA70f+OZHYQE+SmMX5jtqU= X-Google-Smtp-Source: AAOMgpcG5mn0zxlX40zncJU5jihBazJZX9WFtix+QlPh+KuxVFu7497aQupOz4NxveqOVeadAz7ZlpTk4ObANj43PFw= X-Received: by 2002:a24:d30d:: with SMTP id n13-v6mr7033326itg.87.1532248589011; Sun, 22 Jul 2018 01:36:29 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:148a:0:0:0:0:0 with HTTP; Sun, 22 Jul 2018 01:36:28 -0700 (PDT) In-Reply-To: References: Date: Sun, 22 Jul 2018 10:36:28 +0200 Message-ID: To: Levi Morrison Cc: internals Content-Type: multipart/alternative; boundary="000000000000db0f5e0571926c69" Subject: Re: [PHP-DEV] Implementation ideas for adding early warning for mis-use of "parent"? From: nikita.ppv@gmail.com (Nikita Popov) --000000000000db0f5e0571926c69 Content-Type: text/plain; charset="UTF-8" On Sun, Jul 22, 2018 at 2:05 AM, Levi Morrison wrote: > This code the illustrates the issue; it has no errors or warnings: > > ```php > class A { > function m(): parent { > return $this; > } > } > ``` > > However, if you run the method you will get an error. I want to add a > light warning such as E_STRICT or E_DEPRECATED at compile time. > > Using CG(active_class_entry)->parent will not work at compile time, so > that strategy is out. > > Given that `zend_compile_func_decl` is not called directly from > `zend_compile_class_decl` it would be difficult to pass the parent's > name in any way other than a compiler global. Is there anything in > particular I need to do if I add another compiler global? I intend to > set and unset it in `zend_compile_class_decl`. > > Anyone have a better way to pass around the parent's name at compile time? > Please note that for traits and closures it's not possible to determine this at compile time. Nikita --000000000000db0f5e0571926c69--