Hello, this would be very possible constant with the actual without breaking BC
allow declare var = value : type; -> throws if assignment + type fails the grammar context is exactly the same than a function return. Best. On Wed, Sep 4, 2019 at 10:18 AM Andreas Hennings <andr...@dqxtech.net> wrote: > On Wed, 4 Sep 2019 at 09:22, Lynn <kja...@gmail.com> wrote: > > > > Note that this behavior would require making some decisions whether or > not > > in the future this opt-in behavior should change when a default value is > > given, such as with C# and type inference when declaring a variable, > based > > on its assigned value. > > I think this would too easily lead to mistakes. > E.g. if in a git commit, "$x = 5.6;" is replaced with "$x = 5;" or "$x > = '5.6';", then would a reviewer notice that this implicitly changes > the type? > Also, what if the initialization is inside an if branch? Later the > if/else gets reordered, or one of the conditional branches gets > removed, and the variable changes its type? > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >