Closed (fixed)
Project:
Drupal core
Version:
8.9.x-dev
Component:
entity system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Sep 2017 at 08:12 UTC
Updated:
7 Mar 2020 at 08:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
hchonovComment #3
sam152 commentedIf a function doesn't return anything it behaves exactly the same as if it returned
NULL. See below:Comment #4
dawehnerYeah this is not a bug , maybe a task ... slightly better code?
Comment #5
vijaycs85Comment #6
vijaycs85Comment #7
mile23Rescoping because
EntityType::getHandlerClass()seems to returnNULLby not returning anything based onhasHandlerClass().This makes it an easy unit test to add to
Drupal\Tests\Core\Entity\EntityTypeTest, because we never test for this outcome.Comment #8
ivan berezhnov commentedComment #13
sivaji_ganesh_jojodae commentedNot sure if the attached test & code change is what intended. Please review.
Comment #14
hchonovInstead of creating a new test we could incorporate these 2 lines in
::testGetHandler().Comment #15
sivaji_ganesh_jojodae commentedMakes sense. Patch re-rolled to reflect the change.
Comment #16
hchonovThank you.
Comment #17
alexpottThis is not needed. It is implicit when there is no return. I do not want to encourage a spate of issues adding
return NULLeverywhere.Comment #18
hardik_patel_12 commentedfunction test()
{
return null;
}
function test()
{
return;
}
function test()
{
}
In all cases there for var_dump(test()); will be:
NULL
Kindly review a new patch.
Comment #19
hardik_patel_12 commentedComment #20
ravi.shankar commentedPatch #18 looks good to me, so making it RTBC.
Comment #21
hchonovI understand your worries, however I consider no explicit return a bad practice and I hope that there aren't that many places without explicit returns.
Comment #22
alexpott@hchonov okay I committed #15. I can buy the argument that when you have a return it's best that all returns are explicit.
Committed and pushed b6bf07b8aa to 9.0.x and a1468fef85 to 8.9.x. Thanks!