# Error with isAutorized method

**URL:** <https://discourse.cakephp.org/t/error-with-isautorized-method/3632>\
**Category:** Need Help\
**Created:** [December 11, 2017, 9:47pm UTC](https://discourse.cakephp.org/t/error-with-isautorized-method/3632 "2017-12-11T21:47:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mendru](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Mendru](https://discourse.cakephp.org/u/Mendru)\
**Post date:** [December 11, 2017, 9:47pm UTC](https://discourse.cakephp.org/t/error-with-isautorized-method/3632/1 "2017-12-11T21:47:05Z")

</div>

Hello, i’m actually trying to implement the isAutorized method in my AppController and UserController.  
First, I tried to implement it basically like :

function isAuthorized($type){  
return true;  
}

And I get an error : return type declarations must be compatible with controller-\>isauthorized : bool. I tried in my AppController, my UserController, same error. I tried too to add ($user = null) in parameter but same error.

If you have any advice or help,

Thank you in advance,

Mendru

---

<div class="post-metadata">

**Author:** ![raul338](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/raul338/32/69_2.png) [@raul338](https://discourse.cakephp.org/u/raul338)\
**Post date:** [December 12, 2017, 12:24am UTC](https://discourse.cakephp.org/t/error-with-isautorized-method/3632/2 "2017-12-12T00:24:34Z")

</div>

You have to define the [function return type](http://php.net/manual/en/migration70.new-features.php#migration70.new-features.return-type-declarations)

```auto
function isAuthorized($type): bool {
    return true;
}

```

---

<div class="post-metadata">

**Author:** ![Mendru](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Mendru](https://discourse.cakephp.org/u/Mendru)\
**Post date:** [December 12, 2017, 12:38am UTC](https://discourse.cakephp.org/t/error-with-isautorized-method/3632/3 "2017-12-12T00:38:34Z")

</div>

thank you so much.

For information : is it the same think to change the signature in top of method

- @method isAuthorized($user)

Or is it more safe to set the type of return ? ( found this solution 1 hour ago but was very annoying to change some source code )

Again thank you so much,

Mendru

---

<div class="post-metadata">

**Author:** ![raul338](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/raul338/32/69_2.png) [@raul338](https://discourse.cakephp.org/u/raul338)\
**Post date:** [December 12, 2017, 12:52am UTC](https://discourse.cakephp.org/t/error-with-isautorized-method/3632/4 "2017-12-12T00:52:33Z")

</div>

The @method is just an annotation and it is for IDE autocompletition/hinting, with it PHP would still throwing an exception.

Setting the return type, o removing it in both controller would solve the issue
