Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105104 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 79637 invoked from network); 5 Apr 2019 12:41:23 -0000 Received: from unknown (HELO mail-it1-f172.google.com) (209.85.166.172) by pb1.pair.com with SMTP; 5 Apr 2019 12:41:23 -0000 Received: by mail-it1-f172.google.com with SMTP id y134so1857360itc.5 for ; Fri, 05 Apr 2019 02:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=E1VW+B/9DRQtewjEluFgDVCAF6omujMrk6cehtw85/c=; b=TJdzE08ePBisumYItFV4xCBvGTz1y7lnCRRkJKYeFx7oYga3QbhJfUdyQRcwko93F3 1THi8/CDHQbB8ND7v4mFvy+2kmpHCZCVWTjRua0INaDS+oy7sTJivbUyDqeX+9Cj1/eh KpM6NP5PEhWbe1jGDNGKBXIOwm8vdzCGmsDoS6Zdjd+f5K9OQPtQCkjSgZ28UWsbRhor IlS26P2k9EkY9KNhQa9c2IT/85dd4B3i3LL08lf+M8RYgduP8Z+HrEL1Y31EwJ1tC1nK caYJ1kYJuD9HpSkWkiP34KuTENsfbSedl9iBklFS+CxxGm+9vreSOG60n7Ce3lFwm/+n OQjA== 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; bh=E1VW+B/9DRQtewjEluFgDVCAF6omujMrk6cehtw85/c=; b=IUftZIuXAHWm0r9LfcFXSPNu35OO0ki2YGPJpdOKPip2YEvuzzhMwJsF88NksFE08m J1fgGM/o6RxOrl71iKyYGI6rQUxGQL5BQIwkARExUUtruzdEQFWPpPQcm/f3fSMrMTRV 1Sx3qYpWTgZ+4F0mC0Y+uHkD/6DLvuYXq/l2dSnYrtuBkraQXqsjdVdO2L8MuBZ9LCz3 ZzWAUdx6qnKWiCBXrPe7BrfxhfQgctaaeZIaGPOCvxTYTSPuiLcXztqJdpVAM9oKy8s9 jp47hVhDuFcZc+qN7yRELzGkXbCMRKIifjjpydJ96hxfQfPp1h/6615bgSWmH82y85wf BCRQ== X-Gm-Message-State: APjAAAUi296xz9V2uutLomm2BC/ngrfw8VyXyprhCLB2oQq0em3DAF/A mG/Cc4bv9D46+Yo/RhE64x0fsyecjewD3qxQuDFdVg== X-Google-Smtp-Source: APXvYqyfRfEWQnhjwLUnsjQzqITO20pxuPBV6FMtp7KeAlvOQLAxWZFP5W9mtdXAi3AbGXBwTupaHQgnCaenP98ZgQM= X-Received: by 2002:a24:5a8d:: with SMTP id v135mr8786475ita.87.1554457034478; Fri, 05 Apr 2019 02:37:14 -0700 (PDT) MIME-Version: 1.0 References: <65AF9E1E-DFA6-47AE-952B-9ABEBD9B6038@gmail.com> <284d1f9f-03d3-1488-77dd-82e18edf9f4c@gmail.com> <3144F5D1-1F18-4C42-9B3E-AF1B1E598E47@koalephant.com> <917cb7bc-4abc-4bae-1a5a-b2ba1777fa55@gmail.com> In-Reply-To: Date: Fri, 5 Apr 2019 10:37:03 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="0000000000005bdc770585c53bde" Subject: Re: [PHP-DEV] Question about adding !function_identifier From: rowan.collins@gmail.com (Rowan Collins) --0000000000005bdc770585c53bde Content-Type: text/plain; charset="UTF-8" On Fri, 5 Apr 2019 at 09:57, Robert Hickman wrote: > > > > For instance: > > > > function foo(): type nothrow { > > throw new SomethingException; > > } > > Would it be possible to analyse the call graph at compile time > (bytecode generation) and then trigger a fatal error? It wouldn't be > possible for variable functions/methods though. A separate static > analyser could do the same thing. > Yes, I think we are rapidly approaching the limit where to make the language stricter, we need an official static analysis tool, like Hack has, rather than trying to do everything at run-time. It might even be possible to build this into OpCache somehow, so that if you pre-analyse your code, it will skip runtime checks that it can prove will never fail (e.g. return type annotation on a function that always returns literals). The tricky part is that PHP is a highly dynamic language, so there's a lot of cases where the analysis can only return "maybe". My understanding is that this is what a lot of the work on Hack is doing: creating a language which looks a lot like PHP, but doesn't have as many ambiguous cases which can't be analysed statically. Regards, -- Rowan Collins [IMSoP] --0000000000005bdc770585c53bde--