user-documentation
user-documentation copied to clipboard
Accessing a property on null currently emits a notice, not an error or exception
Please complete the information below:
Where is the problem?
4064: Accessing members on a nullable object
Accessing a property or a method on null will throw an exception.
What is the problem?
Accessing a property on null currently emits a "Notice"
Please don't change anything below this point.
- Build ID: HHVM=HHVM-4.164.0:HSL=v4.108.1:2022-09-19T20:50:52+0000:1fa47f258c6b68f8ec01899aa82fd6ffa0957109
- Page requested: /hack/silencing-errors/error-codes
- Page requested at: Tue, 20 Sep 2022 15:40:28 +0000
- Controller: GuidePageController
On my local environment:
> null->foo()
Hit a php exception : exception 'BadMethodCallException' with message 'Call to a member function foo() on a non-object (null)'
This probably depends on the HHVM settings if we aren't always throwing in this case.
You're calling a method on null, not performing a property fetch on null.
Huh, you're right.
> p null->foo
Notice: Cannot access property on non-object
Notice: Cannot access property on non-object
null
I should update the docs, although I'm surprised HHVM doesn't enforce this more strictly yet.