- This topic has 8 replies, 1 voice, and was last updated 2 months, 2 weeks ago by afuiasdyfuiay.
- AuthorPosts
- November 5, 2020 at 12:12 pm #1605autopoietic_sapienParticipant
PHP 8.0 feature focus: nullsafe methods
November 5, 2020 at 12:12 pm #1606helloworderGuestI’d rather call that nullsafe method **calls**
November 5, 2020 at 12:12 pm #1607monstermudder78GuestFuckin finally.
November 5, 2020 at 12:12 pm #1608tamasmagyarhunorGuestI am a Mid PHP Developer in my job, more like an advanced junior in general and both this and last weeks article (about weak maps) were amazing and super good insight. thanks for taking the time to write and post them! <3
November 5, 2020 at 12:12 pm #1609oojacobooGuestTrying to think of where I’d use this. In general, if I’m expecting an object and don’t get it, there is a business logic issue and an exception is warranted.
What would be nice, is if I could define that exception.
November 5, 2020 at 12:12 pm #1610SavishSalaciousGuestI would love to see the C implementation for this.
November 5, 2020 at 12:12 pm #1611tomtheimpalerGuestThanks Larry. Can’t wait to use this personally, an old inherited project will be really helped by this
November 5, 2020 at 12:12 pm #1612rreynierGuestCan someone explain to me why nulls are so bad. If I have a User who can optionally have an Address, to me it makes sense that $user->get address() would return null. I’m not sure what else is should return if nulls were not a thing?
November 5, 2020 at 12:12 pm #1613afuiasdyfuiayGuest`$state = get_user($id)?->getAddress()?->state;`
​
?? sorry but this sucks. the operator is easy to miss and could make bugs harder to track down to fix the root cause.
- AuthorPosts
- You must be logged in to reply to this topic.