Type hinting for any object

后端 未结 9 1657
梦毁少年i
梦毁少年i 2020-12-14 05:43

I\'ve been working on code that\'s intended to be used with objects, without really caring what the kind of object is. I wanted to type hint that the method being written ex

9条回答
  •  旧时难觅i
    2020-12-14 06:13

    Although there is no type hinting for objects, you can use:

    if (!is_object($arg)) {
        return;
    }
    

提交回复
热议问题