Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing a property on null currently emits a notice, not an error or exception #1292

Open
muglug opened this issue Sep 20, 2022 · 3 comments

Comments

@muglug
Copy link

muglug commented Sep 20, 2022

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
@Wilfred
Copy link
Contributor

Wilfred commented Oct 1, 2022

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.

@muglug
Copy link
Author

muglug commented Oct 7, 2022

You're calling a method on null, not performing a property fetch on null.

@Wilfred
Copy link
Contributor

Wilfred commented Nov 17, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants