Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105114 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 82048 invoked from network); 5 Apr 2019 20:07:06 -0000 Received: from unknown (HELO mail-io1-f65.google.com) (209.85.166.65) by pb1.pair.com with SMTP; 5 Apr 2019 20:07:06 -0000 Received: by mail-io1-f65.google.com with SMTP id d201so5581679iof.7 for ; Fri, 05 Apr 2019 10:03:02 -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 :cc; bh=4l1js+c8S0TBZVghO50fLKwfqHXk5GZmyz2m5kvXdKM=; b=E7xeEZxU+eynMNAJX1ycsmkLgdJwM7H8j2BaNpsZxXxQBFessKeN93eQQvEqtNUmS3 bzVwjCKcjmeGHNRmsibG62UFMMseYOU7JOp/rPhYAXdgA4zihVmsrLrZ12WB+DsNz4jD lzoqnFqEfJW5hyFaveKpOG589ZR4QoPuGGqVP4g8+QMMKW8G/ccdXirFp0HRJei1ZZib gmij8VB7pxzEu4lTnOk475hVI0CoIpS+f+IhYtCWDHvGyNicuLYbuxOTwzT8mMr9gukp PKtNZXlNNRWcOd9ofSCHkD20NHGAkwtMVHI/YhSL7Dvz4uaENdtTQeMA+cbf+1oiriMs ewKA== 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=4l1js+c8S0TBZVghO50fLKwfqHXk5GZmyz2m5kvXdKM=; b=gbzRBYjwOgHU+EWP3BFodA1aLvk9zBnEek2ziOSkNzc2oMjn4UHgv3ERSzdub5M2b/ 4Dw4Vs5FKgCoSHg3Qi1sbMmiWiU/U6xc/t3oCJuOWpSGV3T8BfVoC5xaH/G9d9l51fj+ hV4HG5dhq2oTGo7rUYfd9NnrYst1CiWmP8snIOac45i1QzxgUgSgK579JyDsq205lygE qSC+hJ1suenuf/Iuk7F1meGMhfLUZ0PkDJUHdePQMlWjQbQgXASHtDkme+RqzYmyhg1s 0+8bn/pGvAloLuNa9BdrYWbK0vzKewxt5oHWQ9xbkgFvQ6H10cVn3FmEtZyx5uSoxxDq w5bg== X-Gm-Message-State: APjAAAXmhpYxYGkvcaF3LmsJAUI2y4STFf+GAs+eODFpshMNXsmeoKYs 7SY3oZqMOcOBnVvO4QW9CvlwYw2wPa1LmKweTCw= X-Google-Smtp-Source: APXvYqwYTfvhxnUUiRQ8oyk5ayiye/nT4crZ1dGyWYe+sfOHLCXg1sss2qkarargsvwfj+dsfmkSuV+w7RzQPG4N6Ns= X-Received: by 2002:a6b:3905:: with SMTP id g5mr8814959ioa.39.1554483782439; Fri, 05 Apr 2019 10:03:02 -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 19:02:51 +0200 Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000a957b50585cb75e3" Subject: Re: [PHP-DEV] Question about adding !function_identifier From: benjamin.morel@gmail.com (Benjamin Morel) --000000000000a957b50585cb75e3 Content-Type: text/plain; charset="UTF-8" > > 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 (...) Features like scalar type hints, return types, property type hints, and preloading (which makes the definition of a type-hinted class available at compile time), should definitely help towards skipping a lot of runtime checks! On Fri, 5 Apr 2019 at 11:37, Rowan Collins wrote: > 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] > --000000000000a957b50585cb75e3--