Похожие чаты

So like a function like this declare(strict_types=1); myfunc(): ?Array {

... database logics ...
if(!empty($db_results)) {
return $db_results;
}
}

does not require neither return []; nor return NULL; right?

3 ответов

6 просмотров

What kind of syntax is this? ?Array $results It is an error

Bryan Joshua-Pedini Автор вопроса
Mohammad
What kind of syntax is this? ?Array $results It ...

sorry, fixed I was confusing with named parameters, return type declarations don't require a named value

This asserts that return value should be either null or array. In this case, if that condition isn't satisfied, then nothing is returned and it is an error. You should add return null; after that if statement to comply with defined return type.

Похожие вопросы

Обсуждают сегодня

Комрады, хотел уточнить. Проперть в OnDestroy юнита-хозяина по-прежнему доступна? И еще уточнение: finalization юнита наступает раньше или позже OnDestroy?
Ed Doc
48
drew demin: Подскажите пожайлуста какая система лучше подходит для данного железа и можно ли завести? и с каким загрузчиком А так же если платно обращаться сколько это будет ...
drew demin
3
Здравствуйте! Есть вопросы по ПК: 1.1. Безопасно ли запускать программы, которым я не доверяю, в виртуальной машине под KVM+qemu? (x86_64) 1.2. То же самое при использовании ...
Pavel
5
А как старый хаскел с новым стыковать ? потому как тут работает https://play.haskell.org/saved/C3xpMzcd, а вот тут https://stepik.org/lesson/7602/step/9?unit=1473 нет ошибка C...
Fedor
56
Hi everyone! I have a two-folded message to share today. First: updates and news, as we are being asked for those. We still want to go like we did the last 6 years: we w...
Marten | Unibright.io
31
Вопрос, вот задание https://stepik.org/lesson/7602/step/9?unit=1473 вот код и ошибка, удивляет, что требуется еще и Semigroup так и должно быть, или я опять делаю ошибки ? htt...
Fedor
14
What happens if you have less than 5m erc lgcy, how do I swap in this case?
Wilson
17
Вообще, меня бы даже такой вариант, наверное устроил бы: try tag.Read(0); finally end; Но этот AV не ловится и программа завершается Exception EAccessViolation in module C...
notme
12
How do I unstake my T share as it will end in couple of hour? What will I get when I unstake my T share?
Eucross
16
Проблема с Windows scripting control Множество объектов получают iDispatch обертки и отдаются в скрипты. При этом скрипты могут эти обертки держать живыми очень долго, наприм...
Arioch The
16
Карта сайта