Homec4science

Warn against writing to undeclared properties

Authored by vrana <jakubv@fb.com> on Oct 3 2012, 20:07.

Description

Warn against writing to undeclared properties

Summary:
I make this error quite often: I forget to declare a property I am writing to or I make a typo in it.
PHP implicitly creates a public property which I don't like.

I would much rather see a linter warning me against this than this runtime check but writing it is very difficult:

  • We need to explore all parents of the class we are checking.
  • It is even possible that children will declare that property but it's OK to treat this as error anyway.
  • We can extend also builtin or external classes.
  • It's somewhat doable for $this but even more complex for any $obj because we don't know the class of it.

This should catch significant part of these errors and I'm fine with that.

I don't plan escalating to exception because this error is not fatal and should not stop the application from working.

Test Plan: Loaded homepage, checked log.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3601

Details

Committed
vrana <jakubv@fb.com>Oct 3 2012, 20:54
Pushed
aubortJan 31 2017, 17:16
Parents
rPH7c39c4ca7d35: Declare common Lisk properties
Branches
Unknown
Tags
Unknown

Event Timeline

vrana <jakubv@fb.com> committed rPH4682e0c104bd: Warn against writing to undeclared properties (authored by vrana <jakubv@fb.com>).Oct 3 2012, 20:54