[DomCrawler][Form] Fix PHPDoc on get & offsetGet
This commit is contained in:
parent
159ef1bf1d
commit
f8735cc47b
@ -269,7 +269,7 @@ class Form extends Link implements \ArrayAccess
|
||||
*
|
||||
* @param string $name The field name
|
||||
*
|
||||
* @return FormField The field instance
|
||||
* @return FormField|FormField[]|FormField[][] The value of the field
|
||||
*
|
||||
* @throws \InvalidArgumentException When field is not present in this form
|
||||
*/
|
||||
@ -313,7 +313,7 @@ class Form extends Link implements \ArrayAccess
|
||||
*
|
||||
* @param string $name The field name
|
||||
*
|
||||
* @return FormField The associated Field instance
|
||||
* @return FormField|FormField[]|FormField[][] The value of the field
|
||||
*
|
||||
* @throws \InvalidArgumentException if the field does not exist
|
||||
*/
|
||||
|
@ -70,7 +70,7 @@ class FormFieldRegistry
|
||||
*
|
||||
* @param string $name The fully qualified name of the field
|
||||
*
|
||||
* @return mixed The value of the field
|
||||
* @return FormField|FormField[]|FormField[][] The value of the field
|
||||
*
|
||||
* @throws \InvalidArgumentException if the field does not exist
|
||||
*/
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\DomCrawler\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DomCrawler\Field\TextareaFormField;
|
||||
use Symfony\Component\DomCrawler\Form;
|
||||
use Symfony\Component\DomCrawler\FormFieldRegistry;
|
||||
|
||||
@ -953,7 +954,7 @@ class FormTest extends TestCase
|
||||
return $dom;
|
||||
}
|
||||
|
||||
public function testgetPhpValuesWithEmptyTextarea()
|
||||
public function testGetPhpValuesWithEmptyTextarea()
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadHTML('
|
||||
@ -968,4 +969,34 @@ class FormTest extends TestCase
|
||||
$form = new Form($nodes->item(0), 'http://example.com');
|
||||
$this->assertEquals($form->getPhpValues(), ['example' => '']);
|
||||
}
|
||||
|
||||
public function testGetReturnTypes()
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadHTML('
|
||||
<html>
|
||||
<form>
|
||||
<textarea name="foo[collection][0][bar]">item 0</textarea>
|
||||
</form>
|
||||
</html>'
|
||||
);
|
||||
|
||||
$nodes = $dom->getElementsByTagName('form');
|
||||
$form = new Form($nodes->item(0), 'http://example.com');
|
||||
|
||||
// FormField
|
||||
$this->assertInstanceOf(TextareaFormField::class, $textareaFormField = $form->get('foo[collection][0][bar]'));
|
||||
|
||||
// Array of FormField
|
||||
$this->assertSame([
|
||||
'bar' => $textareaFormField,
|
||||
], $form->get('foo[collection][0]'));
|
||||
|
||||
// Array of array of FormField
|
||||
$this->assertSame([
|
||||
[
|
||||
'bar' => $textareaFormField,
|
||||
],
|
||||
], $form->get('foo[collection]'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user