0

I am working with a code that was not written by me. It is a Laravel 3 application, it is giving me the following error:

PHP Warning: in_array() expects parameter 2 to be array, null given in /Users/use/Documents/project/laravel/error.php on line 87

Can you give me pointers on how to debug it? It is giving error in the file which was included in the framework. Also I using the php's inbuilt server to run the application. Does that cause problems? Any pointers are helpful.

PS: I am on a mac.

shaedrich
  • 5,457
  • 3
  • 26
  • 42
Fox
  • 9,384
  • 13
  • 42
  • 63
  • 1
    P.S.: There is an error reference: [Reference - What does this error mean in PHP?](http://stackoverflow.com/q/12769982/367456) - and I would inspect that with a step-debugger like xdebug so you can revers engineer more easily why NULL comes to there. – hakre Aug 27 '13 at 20:15
  • can you provide code for `project/laravel/error.php on line 87` it basically states that one of the parameters was NULL – Young Student Aug 27 '13 at 20:16
  • what Young Student said...you can type cast the value like in_array($string, (array)$secondVar); to fix the issue – hendr1x Aug 27 '13 at 20:17
  • @hendr1x: That removes the symptom, but it's not taking on the cause. – hakre Aug 27 '13 at 20:28
  • The fact that this is in Laravel's error system, I would suspect that it was not installed on your machine correctly. Try following an install guide (or a new one) and seeing if that clears up the error for you. – DampeS8N Aug 27 '13 at 20:30

3 Answers3

0

After looking at the source code it appears that you are getting the error from this file:

// laravel/error.php
// line 86
if (in_array($code, Config::get('error.ignore')))
{
    return static::log($exception);
}

The method appears to be looking for the error.ignore config variable:

// application/config/error.php
// line 16
'ignore' => array(),

Check the application/config/error.php file, make sure that 'ignore' is set to an array. If it already is, then you likely have an error in one of the other config files which is corrupting the array.

Hopefully this helps and shows the steps you can take in tracking down the source of an error.

Makita
  • 1,812
  • 12
  • 15
0

You can get this also if you're using composer and the required files have not been installed after a fresh checkout of the project. To resolve:

$ composer install

Or similar. To actually get a head on this information I had to throw $exception in the error.php file around line 87, then I saw the reason in the Apache error logs.

GuruBob
  • 855
  • 1
  • 10
  • 21
0

Most of this errors is about of parameters definition bug.

for example sometimes coder write

protected $guarded = 'title';

instead of

protected $guarded = ['title'];

That makes the paroblem

ganji
  • 752
  • 7
  • 17