On Wed, 6 May 2020 at 22:48, Mike Schinkel <[email protected]> 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:
>
> 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]