safe icon indicating copy to clipboard operation
safe copied to clipboard

TypeError: Argument 4 passed to yaml_parse_file() must be of the type array, null given

Open undefinedor opened this issue 5 years ago • 6 comments

Q A
Safe version ^0.11.12
PHP version 7.4.0
PHP Strict Type? True
Operating system MacOS

description

TypeError: Argument 4 passed to yaml_parse_file() must be of the type array, null given

undefinedor avatar Dec 23 '19 03:12 undefinedor

Are you explicitly passing null as an argument or using the default value?

Kharhamel avatar Jan 06 '20 13:01 Kharhamel

Do you still have the porblem when upgrading to v1.0?

Kharhamel avatar Jan 08 '20 09:01 Kharhamel

Do you still have the porblem when upgrading to v1.0?

Yes.

undefinedor avatar Jan 08 '20 09:01 undefinedor

Are you explicitly passing null as an argument or using the default value?

using the default value.

undefinedor avatar Jan 08 '20 09:01 undefinedor

The PHP's default value for this parameter is empty array. The Safe version has null as default value and passes it to the core function, which MUST result in a TypeError. Still broken in 1.1.3.

The workaround for this is to call it with all arguments. I.e.

$i = 0;
return \Safe\yaml_parse_file(__DIR__ . '/openapi.yml', 0, $i, []);

Pretty annoying.

josefsabl avatar Aug 03 '20 17:08 josefsabl

This issue seems to be fixed in v2.0.1

josefsabl avatar Aug 29 '22 11:08 josefsabl