1. Error in PHP 7.4: ErrorException array_key_exists() expects parameter 2 to be array, int given. See Figure 1.

2. The code implementation is as follows. The cause is that require($this->getCachePath()) returns 1, and the root cause of returning 1 is that the content of the file at the path $this->getCachePath() is empty.
if (array_key_exists($path, $this->assetEntries)) {
return $this->assetEntries[$path];
}
if (!$this->isThemeUpdated()) {
$this->assetEntries = require($this->getCachePath());
return;
}
$code = '<?php';
$code .= "\n\n";
$code .= 'return ' . var_export($assets, true) . ';';
$this->local->put($this->getCachePath(), $code, true);3. In fact, when using require, it is a statement, not a function. Therefore, require($this->getCachePath()) can be replaced with require $this->getCachePath()
4. Reference: include. The value of $bar is 1 because include executed successfully. Note the difference in the examples above. The first one uses return in the included file, while the other does not. If the file cannot be included, it returns false and issues an E_WARNING warning. See Figure 2.

5. I infer that the reason is that although the content of the included file is expected to be return Array(), it is actually not. The file content is written based on $this->local->put($this->getCachePath(), $code, true);.
6. Let’s simulate the actual execution of the code where require returns Array().
return.php
<?php
return [
'a' => 1,
'b' => 2
];
?>require.php
<?php
var_dump(require('return.php'));
?>
array(2) {
["a"]=>
int(1)
["b"]=>
int(2)
}
7. Let’s simulate the actual execution of the code where require returns 1 (scenario 1): the included file returns the integer 1.
return.php
<?php
return 1;
?>
require.php
<?php
var_dump(require('return.php'));
?>
int(1)
8. Let’s simulate the actual execution of the code where require returns 1 (scenario 2): the content inside the PHP tags in the included file is empty.
return.php
<?php
?>require.php
<?php
var_dump(require('return.php'));
?>
int(1)
9. Let’s simulate the actual execution of the code where require returns 1 (scenario 3): the content of the included file is empty, making it a blank file.
return.php
/* 此处为空 */
require.php
<?php
var_dump(require('return.php'));
?>
int(1)
10. In the production environment, the case where require($this->getCachePath()) returns 1 falls under scenario 3, where the content of the included file is empty, making it a blank file.
11. View the implementation of the put() method in Illuminate\Filesystem\Filesystem.
public function put($path, $contents, $lock = false)
{
return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
}
12. For the specific troubleshooting and analysis process, refer to: Troubleshooting empty file contents when using file_put_contents() in PHP 7.4.
