Skip to content

Commit

Permalink
Merge pull request #11512 from creative-commoners/pulls/6.0/broken-bu…
Browse files Browse the repository at this point in the history
…ilds

API Make validator param nullable
  • Loading branch information
GuySartorelli authored Dec 16, 2024
2 parents dc973c6 + bfe6f94 commit a393ce7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/Forms/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ class Form extends ModelData implements HasRequestHandler
protected $name;

/**
* @var Validator
* @var null|Validator
*/
protected $validator;
protected $validator = null;

/**
* @see setValidationResponseCallback()
Expand Down Expand Up @@ -635,7 +635,7 @@ public function transform(FormTransformation $trans)

/**
* Get the {@link Validator} attached to this form.
* @return Validator
* @return null|Validator
*/
public function getValidator()
{
Expand All @@ -644,10 +644,10 @@ public function getValidator()

/**
* Set the {@link Validator} on this form.
* @param Validator $validator
* @param null|Validator $validator
* @return $this
*/
public function setValidator(Validator $validator)
public function setValidator(?Validator $validator)
{
if ($validator) {
$this->validator = $validator;
Expand Down
6 changes: 2 additions & 4 deletions tests/php/Forms/DropdownFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ public function testEmptySourceDoesntBlockValidation()
$this->assertTrue($field->validate()->isValid());
}

public function provideGetDefaultValue(): array
public static function provideGetDefaultValue(): array
{
return [
[
Expand Down Expand Up @@ -648,9 +648,7 @@ public function provideGetDefaultValue(): array
];
}

/**
* @dataProvider provideGetDefaultValue
*/
#[DataProvider('provideGetDefaultValue')]
public function testGetDefaultValue(mixed $value, bool $hasEmptyDefault, mixed $expected): void
{
$field = new DropdownField('MyField', source: ['one' => 'one', 'two' => 'two', '3' => 'three']);
Expand Down
4 changes: 2 additions & 2 deletions tests/php/Forms/TreeDropdownFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ public function testTreeSearchUsingSubObject()
$cssPath = 'ul.tree li#selector-TestTree-' . $subObject1->ID . ' li#selector-TestTree-' . $subObject1ChildB->ID . ' a';
$firstResult = $parser->getBySelector($cssPath);
$this->assertEquals(
$subObject1ChildB->Name,
$subObject1ChildB->Title,
(string)$firstResult[0],
$subObject1ChildB->Name . ' is found, nested under ' . $subObject1->Name
$subObject1ChildB->Title . ' is found, nested under ' . $subObject1->Title
);

// other objects which don't contain the keyword 'SubObject' are not returned in search results
Expand Down

0 comments on commit a393ce7

Please sign in to comment.