> What are your reasons for this proposal?
>
> I can think of multiple reasons why this might not be a good idea, but the
> only reason that pops to mind for getting rid of it is to make PHP work
> like a different style of language.

I'm proposing this change because it will remove duplicate functionality
from the language.

In PHP 4, "var" was the only way to declare a class member variable.  PHP 5
introduced three new keywords for this purpose: public, protected, and
private.  "public" is functionally identical to "var".  According to the
docs:

> Class properties must be defined as public, private, or protected. If
> declared using var, the property will be defined as public.

This is great for backwards compatibility from PHP 4, but it ultimately
results in having two different keywords which do exactly the same thing.
Does PHP 7 really need two keywords for declaring public class members?

We're already removing PHP 4 style constructors in favor of the PHP 5 style
ones, so why not also remove the PHP 4 "var" keyword in favor of the PHP 5
style keywords which explicitly state the visibility?

For the small percentage of projects which still use "var", upgrading their
code would be dead simple: just replace "var" with "public" everywhere you
see it.  I'm sure somebody can easily whip up a tool to automate that
process.

Because current usage of "var" seems low and the upgrade path is so simple,
I don't think its a bad idea.

Colin

On Thu, Feb 18, 2016 at 3:25 PM Walter Parker <walt...@gmail.com> wrote:

> On Thu, Feb 18, 2016 at 11:30 AM, Sebastian Bergmann <sebast...@php.net>
> wrote:
>
> > On 02/18/2016 02:10 PM, Colin O'Dell wrote:
> >
> >> I'd like to propose an RFC to deprecate and eventually remove the "var"
> >> keyword.
> >>
> >
> >  +1
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> What are your reasons for this proposal?
>
> I can think of multiple reasons why this might not be a good idea, but the
> only reason that pops to mind for getting rid of it is to make PHP work
> like a different style of language.
>
>
> Walter
>
> --
> The greatest dangers to liberty lurk in insidious encroachment by men of
> zeal, well-meaning but without understanding.   -- Justice Louis D.
> Brandeis
>

Reply via email to