śr., 4 wrz 2019, 05:52 użytkownik Fwentish Aelondes <fwent...@gmail.com> napisał:
> Hello internals, > > Zeev's idea to bring peace to the galaxy seems like a good idea, but > impossible to implement in practice. > > But it got me thinking about how one might introduce static typing > into a dynamically typed language w/out breaking BC. > > And then I had this crazy idea: > > //int > $i = 0; > > //string > $c = 'c'; > > //float > $pi = 3.14; > > If static typing in php was *only* an opt-in kind-of-thing, would this > work? Could the parser be built to identify 3 or 4 different keywords > in comments and give warnings or fatal errors for type conversions of > variables that have the type specified in the immediately preceding > comment? > > Just a (crazy) idea. > > ---- Fwentish IMO it's crazy idea and we should not change the way comments work especially inline comments which even aren't kept in opcache. I think better approach would be to put type in front of first variable declaration like: [type] $variable = $value; BR, -- Michał Brzuchalski