Re: [RFC] Throw Exception on Attempt of Constant Redefinition
| From: | Dmitry Stogov | Date: | Fri, 10 Jun 2016 21:27:29 +0000 |
| Subject: | Re: [RFC] Throw Exception on Attempt of Constant Redefinition | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-93890@lists.php.net to get a copy of this message | ||
In general, you are right, but this is possible only if application ignores Error exceptions...
________________________________
From: morrison.levi@gmail.com <morrison.levi@gmail.com> on behalf of Levi Morrison
<levim@php.net>
Sent: Friday, June 10, 2016 11:50:26 PM
To: Dmitry Stogov
Cc: PHP internals
Subject: Re: [PHP-DEV] [RFC] Throw Exception on Attempt of Constant Redefinition
On Fri, Jun 10, 2016 at 2:06 PM, Dmitry Stogov <dmitry@zend.com> wrote:
> Hi internals,
>
>
> Please review: https://wiki.php.net/rfc/constant_redefinition
>
>
> Thanks. Dmitry.
Dmitry, I am not sure this change will actually allow constant
propagation either. Consider this code:
<?php
const Foo = 1;
class FooFactory {
static function make() {
return Foo;
}
}
?>
In this series of events:
- Foo is declared to be 0
- This above file is now included inside a try-catch block that
catches the error
- FooFactory::make() is now called
If Foo = 1 was propagated then FooFactory::make() will return 1 instead of 0.
Am I missing something?