title: Laravel policies : code change is ignored. Is there any policy cache to clear?
body: <p>I'm working full time on an application for 2 years. I encounter this bug regularily, let's say every couple months, but never manage to fix it in a reliable way because it just disappears and I never get to find the "why".  </p>
  
  <p>So, here it is again, and I have no clue why and how to fix it. This time, I'm writing something so I'll have a page to favorite for the next time.  </p>
  
  <p><strong>Here is the bug</strong>:<br>
  If I make any change to a policy method, for instance in app/Policies/UserPolicy, the change is not taken into account when using @can in a blade or $user->can in a php file. I can introduce a <code>die</code> in the policy, a <code>Log::debug('something')</code> or even a <code>return false</code> at the very start of the function, but nope, still returning true.  </p>
  
  <p>Here is a code sample:<br>
  File : app/Policies/UserPolicy</p>
  
  <pre><code>public function deleteUser(User $user, User $target)
  {
      return false;
      if ($user-&gt;id === $target-&gt;id) {
          return false;
      }
  // [...]
  }
  </code></pre>
  
  <p>Here is the code testing, it returns true, whatever I do in the policy code: </p>
  
  <pre><code>$me = Auth::user();
  dd($me-&gt;can('deleteUser', $me));
  </code></pre>
  
  <p>Originally this example should return false, but it's returning true and I don't know why. Modifying the code does not change a thing, it's like there is a cache that nothing can clear. I've tried all the cache clearing commands I know: </p>
  
  <ul>
  <li>php artisan cache:clear</li>
  <li>php artisan config:clear </li>
  <li>php artisan view:clear </li>
  <li>php artisan clear-compiled</li>
  <li>composer dump-autoload</li>
  </ul>
  
  <p>Even restarted apache, and so on... I checked php.ini, I don't have OPCache enabled (line commented, but I tried with OPcache.enabled=0 too, no changes).  </p>
  
  <p>Maybe the reason is elsewhere but I don't know where to look. As I said, this bug usually disappear by itself without leaving me the time to find the cause.  </p>
  
  <p><strong>Other way to reproduce the bug</strong><br>
  In a blade, if I write:</p>
  
  <pre><code>@can('deleteUser', $user)
    CAN
  @endcan
  </code></pre>
  
  <p>It always display CAN. If I rename the function in the policy file to deleteUserr for instance, nothing changes (still returns true). However, if I change the blade code to <code>@can('deleteUserr', $user)</code> then I don't have the "CAN" displayed, as this function is not found and the result for unfound rule is alwways false.  </p>
  
  <p><strong>Environment</strong><br>
  WSL (Ubuntu 18.04, apache 2.4.29, php 7.2.19), Laravel 6.0.3</p>
  
  <p>Thanks for any help !</p>
  
  <hr>
  
  <hr>
  
  <p><strong>EDIT / SOLVED</strong> : found the culprit !</p>
  
  <p>It is a bad interaction with the composer package <code>spatie/laravel-permission</code>.<br>
  I have a spatie permission that is name "deleteUser" and is granted. The package has probably overloaded the "->can" method and now checks first in its permissions mechanism before going on the policy route. So my UserPolicy@deleteUser is simply ignored.  </p>