Answer the question
In order to leave comments, you need to log in
@return void or @return null?
Hello! Can't figure out when to use @return void .
Let's say there is some function that explicitly returns null
/**
* @return null
*/
function a() {
// Какой-то код в этой функции и дальше return
return null;
}
/**
* @return null или void?
*/
function b() {
// Какой-то код в этой функции
}
/**
* @return null или void?
*/
function c() {
// Какой-то код в этой функции и дальше return
return;
}
Answer the question
In order to leave comments, you need to log in
Documentation is written for people, so it should tell people something.
@return void tells us that the function does not return anything, so it does not make sense to use its call, let's say in expressions.
@return null says that we intentionally return null and we have a reason for this.
on the topic - https://www.dereuromark.de/2015/10/05/return-null-...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question