Re: [RFC] Parameter Blocks (vs. Constructor Property Promotion and Named Parameters)

From: Date: Thu, 07 May 2020 08:47:14 +0000
Subject: Re: [RFC] Parameter Blocks (vs. Constructor Property Promotion and Named Parameters)
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-110060@lists.php.net to get a copy of this message
On Wed, 6 May 2020 at 22:48, Mike Schinkel <mike@newclarity.net> wrote: > Now, consider the following two examples. On which line would PHP report > the error? > > function foo() ( > > public $foo, > > public $ bar > > ) {} > > > vs. > > function foo { > public $foo; > public $ bar; > } {} > > This feels like an implementation detail of the parser, rather than an automatic consequence of the syntax, and the current parser seems to handle it just fine. <?php function foo( $foo, $ bar ) {} # unexpected '$', expecting variable... on line 4 # https://3v4l.org/AC9kh The same is true of arrays: both syntax and run-time errors are reported with correct line numbers, e.g. https://3v4l.org/fMp4t and https://3v4l.org/BXO8q > If you need help visualizing it I mocked up an example from actual > function that is in product that was written by someone else before I > joined the client's current team: > > À²‰Ù” > ¢ËíÝùz%�o!https://gist.github.com/mikeschinkel/faaee3fc8ccc2371c7200f3d634289c4 > Here's the single-declaration version of that with a syntax error on line 163: https://3v4l.org/mGq2f I think you're solving a non-existent problem here. Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#110060) next »