Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102950 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59125 invoked from network); 22 Jul 2018 12:51:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jul 2018 12:51:09 -0000 Authentication-Results: pb1.pair.com header.from=levim@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.208.179 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.208.179 mail-lj1-f179.google.com Received: from [209.85.208.179] ([209.85.208.179:37812] helo=mail-lj1-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D4/7C-47674-8BD745B5 for ; Sun, 22 Jul 2018 08:51:05 -0400 Received: by mail-lj1-f179.google.com with SMTP id v9-v6so14650447ljk.4 for ; Sun, 22 Jul 2018 05:51:04 -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=lrSLv/Wx+FS8VVG4+6fFokH6eBMnwBeBJ530Fm7w2+Q=; b=SANvWuE9qMweBV0BHtiNUMgRHVMAyaGWtwhgMEYL/RU6B/Ds0jL9XXIT1YGHkLGsqo ofZ3Gu50k5HB+SeusOI6lJct4dlXYPgOk3IWCAXOVx0EzzuloVVMKorExeQsAPZDDtj6 QoCzBk7WLkJ1xGzlg7i8jM9ySwah/EWiBec6K68ky92mlZiau/5XexnBTWF9QyIBe5gU UHLkksojMu6/6ShRVVGm+wfSN55tX/DeQmPTbg6BZaFSRMZdUAkkEYu4Ue4cYnhL/ehF oh/xDElDk7WcjjE5otXdan3J7Eki2ms6hY10ky8HCznz/eyrFdumpBBGQ8R2ZUzXZvC7 xGCw== X-Gm-Message-State: AOUpUlF5t3sh8Mz6EQnDXXzpluEFyG7JYLsku7+2opGdGoMQ0XlhI3V+ ftEBYo5MIjFQtVMIOJGDDscjhDcAH+AXOedu+OM= X-Google-Smtp-Source: AAOMgpfY5+rKkT/rleco479FYzgzcA42l7WVvglhJNLL/2WHJR/zMt2v3PwWyzpWVqRrXXBSrzLm3ihBOlk8nfKahwU= X-Received: by 2002:a2e:5687:: with SMTP id k7-v6mr6721764lje.105.1532263861986; Sun, 22 Jul 2018 05:51:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 22 Jul 2018 12:50:46 -0600 Message-ID: To: Nikita Popov Cc: internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Implementation ideas for adding early warning for mis-use of "parent"? From: levim@php.net (Levi Morrison) On Sun, Jul 22, 2018 at 2:36 AM Nikita Popov wrote: > > 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 Thanks for the note. Fortunately I'm already aware of `zend_is_scope_known`. Is another compiler global the best way to add this info? Any gotchas with adding another one?