On Thu, Sep 3, 2020, at 3:25 AM, Nikita Popov wrote:
> On Thu, Sep 3, 2020 at 10:19 AM Dik Takken <dik.tak...@gmail.com> wrote:
> 
> > On 03-09-2020 09:38, Brent Roose wrote:
> > > Hi all
> > >
> > > I want to point out the use-case when you're using CS tools, static
> > analysers and IDEs: they report unused variables as errors. There are ways
> > around those errors, but it's more convenient if there's language support.
> > I'd say that conceptually it's also more correct: if you're not using a
> > variable, it shouldn't be there.
> >
> > Exactly this.
> >
> > The intent of a particular language construct does not only need to be
> > clear to human readers but also to machines. More explicit intent leads
> > to stronger static code analysis tools, which helps us catch more bugs
> > earlier.
> >
> > Regards,
> > Dik Takken
> >
> 
> Static analysis tools don't need a language feature to support this. They
> can recognize the $_ pattern and not emit an unused variable warning for
> it. I'd suggest submitting a feature request.
> 
> Nikita

I agree here.  _ is already a common pattern in other languages for a 
placeholder ignored variable.  It's not a big jump for PHP static analyzers to 
start ignoring unused $_ variables, and it requires no language changes or 
formal standards.

I am skeptical of any performance difference, but from a reader-communication 
point of view a de facto convention of $_ == unused, and analyzers recognizing 
that, seems like the path of least resistance.

--Larry Garfield

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to