Re: [RFC Proposal] var keyword deprecation/removal
| From: | Fleshgrinder | Date: | Thu, 18 Feb 2016 21:14:24 +0000 |
| Subject: | Re: [RFC Proposal] var keyword deprecation/removal | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91287@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On 2/18/2016 9:58 PM, Colin O'Dell wrote:
>> 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
>
+1 for Colin’s proposal. Duplicate functionality results in confusion
and this should be avoided and cleaned-up. There are already way too
many aliased functions just to ease the learning curve for people that
come from other languages (whatever that should bring to PHP).
- --
Richard "Fleshgrinder" Fussenegger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBCAAGBQJWxjQwAAoJEOKkKcqFPVVrtM4P/0KQbfYSTvRAuAUiVeQZwsUO
0W5yXlBDRkQfvrxh/xdirMIw0fX25tipsB++93pJ81ay00K2o623KmMKzM4U1rzu
Pfk+HjnGN8iAQSGI0lvHCbgQLnAScOxzllB7NdchhyCP+LwTappDlT3Il/2THTg0
8ilMjBKOdG0tvwicYk4WYc8I9Z1Ryw37JUTp15sk0rE3M6OKRD7KUCVYZ1EfDTTW
0XGwfoOYT9yPEncw/p5jN0SM612kd25/4WfURsjjVhrjHk3l4UxRIh8SKacI/lWe
Zs/WAJa/Nh8gJredgiOa7KO8VnNaeNTnJlXtnhSibdLMJ7lZPUz/4Wnum3/AHAte
2bqT+/5i6AKAi+izFl5IISBL7jh4cI9F1OFT3Z0IdKy1WXJtA37s4mHRmZLMcVvw
HIJTDiBmMqE8PZVnc/Rf5A3QsQoC7h02Rnol7a5PU9990oDKW4lqxfXJRVLZT4Zf
GlImZzdZ1dkzTJlTXLGSEthPrjR3IRsR0JCls5baYLg09OeJAOvOngKeJXZsIz7d
BgoV32wlXtaWWp0hM6RWoztXymLppN8yRWMDwNhqQO7mHAI498KJyoIa46DrUVix
sp0fBOnF+1chDn9uwEkqCZrUMhb+UGQAuyJikDyQALUNmNyi4xTjdv+pjDr3X0Qf
3iz95r9fJF3XqYUsP44r
=r05h
-----END PGP SIGNATURE-----