Skip to content

arrayOf, listOf defaults are always in array  #13

@MartkCz

Description

@MartkCz

Version: 1.0.0

$schema = Expect::listOf('string')->default([
	'foo',
	'bar',
]);

$processor = new Processor();

$array = $processor->process($schema, [
	'foo',
	'bar'
]);

var_dump($array);

dumps:

array(4) {
  [0]=>
  string(3) "foo"
  [1]=>
  string(3) "bar"
  [2]=>
  string(3) "foo"
  [3]=>
  string(3) "bar"
}
$schema = Expect::arrayOf('string')->default([
	'foo',
	'bar',
]);

$processor = new Processor();

$array = $processor->process($schema, [
	'foo',
	'bar'
]);

var_dump($array);

dumps:

array(4) {
  [0]=>
  string(3) "foo"
  [1]=>
  string(3) "bar"
  [2]=>
  string(3) "foo"
  [3]=>
  string(3) "bar"
}

Is it the right behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions