Mos*_*atz 42 php arrays laravel-5
我有一个Laravel 5项目使用bepsvpt/secure-headers包和以下配置文件:
config/secure-headers.php
<?php
return [
'x-content-type-options' => 'nosniff',
'x-download-options' => 'noopen',
'x-frame-options' => 'sameorigin',
'x-permitted-cross-domain-policies' => 'none',
'x-xss-protection' => '1; mode=block',
/*
* Referrer-Policy
*
* Reference: https://w3c.github.io/webappsec-referrer-policy
*
* Available Value: 'no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin',
* 'same-origin', 'strict-origin', 'strict-origin-when-cross-origin', 'unsafe-url'
*/
'referrer-policy' => 'strict-origin-when-cross-origin',
'hsts' => [
'enable' => env('SECURITY_HEADER_HSTS_ENABLE', false),
'max-age' => 15552000,
'include-sub-domains' => false,
],
/*
* Content Security Policy
*
* Reference: https://developer.mozilla.org/en-US/docs/Web/Security/CSP
*
* csp will be ignored if custom-csp is not null.
*
* Note: custom-csp does not support report-only.
*/
'custom-csp' => env('SECURITY_HEADER_CUSTOM_CSP', null),
'csp' => [
'report-only' => false,
'report-uri' => env('CONTENT_SECURITY_POLICY_REPORT_URI', false),,
'upgrade-insecure-requests' => false,
'base-uri' => [
//
],
'default-src' => [
//
],
'child-src' => [
//
],
'script-src' => [
'allow' => [
//
],
'hashes' => [
// ['sha256' => 'hash-value'],
],
'nonces' => [
//
],
'self' => false,
'unsafe-inline' => false,
'unsafe-eval' => false,
],
'style-src' => [
'allow' => [
//
],
'self' => false,
'unsafe-inline' => false,
],
'img-src' => [
'allow' => [
//
],
'types' => [
//
],
'self' => false,
'data' => false,
],
/*
* The following directives are all use 'allow' and 'self' flag.
*
* Note: default value of 'self' flag is false.
*/
'font-src' => [
//
],
'connect-src' => [
//
],
'form-action' => [
//
],
'frame-ancestors' => [
//
],
'media-src' => [
//
],
'object-src' => [
//
],
/*
* plugin-types only support 'allow'.
*/
'plugin-types' => [
//
],
],
];
Run Code Online (Sandbox Code Playgroud)
当我尝试运行应用程序(Web请求或php artisan
)时,我收到以下错误:
PHP Fatal error: Cannot use empty array elements in arrays in C:\Web\myapp\config\secure-headers.php on line 4
Run Code Online (Sandbox Code Playgroud)
当然,该文件的第4行看起来完全没问题!
这是什么问题?
Mos*_*atz 190
这个错误在我可以在网上找到的任何地方都没有记录,来自连续两个逗号,它们在数组中没有任何内容.
在我的情况下,这实际上出现在文件的第42行,而不是第4行,如错误消息所示,这听起来像编译器中的错误,它识别数组中的第一项而不是"空数组的实际位置"元件".
Aye*_*Ope 24
我得到了同样的错误,同时指向第2行,错误在第6行.
我花了几个小时无助地进行故障排除,因为它是一个熟悉的代码,我不知道什么时候额外,
得到了'available' => $faker->boolean(85),
return [
'id' => $id,
'user_id' => $id,
'slug' => $slug,
'speciality' => $faker->randomElement(['Option A','Optoin B']),
'available' => $faker->boolean(85),,
'subscription_ends_at' => $faker->dateTimeBetween('-5 day', '30 day'),
'verified_at' => $faker->dateTimeBetween('-50 day', '-16 minute'),
];
Run Code Online (Sandbox Code Playgroud)
只需,,
, ,
在@Moshe Katz指出的同一行中搜索代码或两个逗号之间的空格即可.
这个帖子是救生员.