# [RFC] Deprecate properties using var

- Thread: https://externals.io/message/82525
- Original archive: https://news-web.php.net/php.internals/82525
- Started by Pierre du Plessis on 2015-02-12T11:51:00+00:00
- Messages: 6
- RFC: Remove PHP 4 Constructors (Implemented (PHP 7.0)) — https://externals.io/rfc/remove_php4_constructors.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #82525 — Pierre du Plessis — 2015-02-12T11:51:00+00:00

URL: https://externals.io/message/82525#82525

Hi all

Before I create an RFC, I just want to get some feedback on a proposal, to
deprecated the use of "var" when declaring properties on a class.

This was previously deprecated in PHP 5.0.0 and the deprecation notice was
removed  in PHP 5.1.3.

My proposal is to deprecate the use of var on properties in PHP 7, and then
remove support for it in PHP 8. This compliments the [0] "Remove PHP 4
Constructors" RFC, as it is old PHP 4 behaviour, and according to the docs
is only "supported for compatibility reasons", and personally I think users
should be encourage to use proper visibility when defining properties.

[0] https://wiki.php.net/rfc/remove_php4_constructors

Regards
Pierre du Plessis

---

## #82526 — Andrea Faulds — 2015-02-12T11:57:23+00:00

URL: https://externals.io/message/82525#82526 · In reply to: #82525

Hi Pierre,

> 
> 
> Before I create an RFC, I just want to get some feedback on a proposal, to
> deprecated the use of "var" when declaring properties on a class.
> 
> This was previously deprecated in PHP 5.0.0 and the deprecation notice was
> removed  in PHP 5.1.3.
> 
> My proposal is to deprecate the use of var on properties in PHP 7, and then
> remove support for it in PHP 8. This compliments the [0] "Remove PHP 4
> Constructors" RFC, as it is old PHP 4 behaviour, and according to the docs
> is only "supported for compatibility reasons", and personally I think users
> should be encourage to use proper visibility when defining properties.

What’s the benefit here? It seems like a needless backwards-compatibility break. PHP 4 constructors have been proposed to be removed because they cause problems (Filter::filter) and it simplifies the language. What problems does var cause? Its existence doesn’t seem to hurt anyone - sure, using public/protected/private is better, but this only matters if you’re reading legacy code. I’d also be wary of removing it if we’re going to get rid of T_VAR, as that seems like a useful keyword we might reuse later. So I don’t see why we need to remove this.

It’s also worth noting that removing PHP 4 constructors is unlikely to go ahead. I think Levi is planning to simply deprecate them instead, since it solves the main problem (Filter::filter broken) without breaking BC.

Thanks.

--
Andrea Faulds
http://ajf.me/

---

## #82585 — Stanislav Malyshev — 2015-02-13T07:51:22+00:00

URL: https://externals.io/message/82525#82585 · In reply to: #82525

Hi!

> My proposal is to deprecate the use of var on properties in PHP 7, and then
> remove support for it in PHP 8. This compliments the [0] "Remove PHP 4

How the life of the PHP user would be improved by this? Except for
making more code break, I'm not sure how it's helpful, could you explain?

> Constructors" RFC, as it is old PHP 4 behaviour, and according to the docs
> is only "supported for compatibility reasons", and personally I think users
> should be encourage to use proper visibility when defining properties.

"var" is the same as "public", public is proper visibility.

-- 
Stas Malyshev
smalyshev@gmail.com

---

## #82586 — Yasuo Ohgaki — 2015-02-13T08:27:56+00:00

URL: https://externals.io/message/82525#82586 · In reply to: #82526

Hi all,



> > […]
> wrote:
> > […]
> to
> > […]
> was
> > […]
> then
> > […]
> docs
> > […]
> users
> > […]
>
> What’s the benefit here? It seems like a needless backwards-compatibility
> break. PHP 4 constructors have been proposed to be removed because they
> cause problems (Filter::filter) and it simplifies the language. What
> problems does var cause? Its existence doesn’t seem to hurt anyone - sure,
> using public/protected/private is better, but this only matters if you’re
> reading legacy code. I’d also be wary of removing it if we’re going to get
> rid of T_VAR, as that seems like a useful keyword we might reuse later. So
> I don’t see why we need to remove this.


I thought I filed this as Trait bug, but there isn't. I might forgot to
report it.

http://3v4l.org/pL3Hr

Class calls trait function that is PHP4 constructor.
This could be resolved by removing PHP4 constructor.

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net

---

## #82587 — Matteo Beccati — 2015-02-13T09:09:00+00:00

URL: https://externals.io/message/82525#82587 · In reply to: #82586

> I thought I filed this as Trait bug, but there isn't. I might forgot to
> report it.
>
> http://3v4l.org/pL3Hr
>
> Class calls trait function that is PHP4 constructor.
> This could be resolved by removing PHP4 constructor.

what does this have to do with using "var"?


Cheers
-- 
Matteo Beccati

Development & Consulting - http://www.beccati.com/

---

## #82588 — Yasuo Ohgaki — 2015-02-13T09:32:16+00:00

URL: https://externals.io/message/82525#82588 · In reply to: #82587

> what does this have to do with using "var"?


Sorry. I posted to wrong thread.

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net
