minor #35861 [DomCrawler][Form] Fix PHPDoc on get & offsetGet (fancyweb)
This PR was merged into the 3.4 branch.
Discussion
----------
[DomCrawler][Form] Fix PHPDoc on get & offsetGet
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
`FormFieldRegistry::get()` returns mixed. For example, it can return an array when the field is a collection.
Commits
-------
f8735cc47b
[DomCrawler][Form] Fix PHPDoc on get & offsetGet
This commit is contained in:
commit
5ffb96452f
@ -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