package and depencies

This commit is contained in:
RafficMohammed
2023-01-08 02:57:24 +05:30
parent d5332eb421
commit 1d54b8bc7f
4309 changed files with 193331 additions and 172289 deletions

View File

@@ -20,29 +20,17 @@ namespace Symfony\Component\DomCrawler\Field;
*/
class ChoiceFormField extends FormField
{
/**
* @var string
*/
private $type;
/**
* @var bool
*/
private $multiple;
/**
* @var array
*/
private $options;
/**
* @var bool
*/
private $validationDisabled = false;
private string $type;
private bool $multiple;
private array $options;
private bool $validationDisabled = false;
/**
* Returns true if the field should be included in the submitted values.
*
* @return bool true if the field should be included in the submitted values, false otherwise
*/
public function hasValue()
public function hasValue(): bool
{
// don't send a value for unchecked checkboxes
if (\in_array($this->type, ['checkbox', 'radio']) && null === $this->value) {
@@ -54,10 +42,8 @@ class ChoiceFormField extends FormField
/**
* Check if the current selected option is disabled.
*
* @return bool
*/
public function isDisabled()
public function isDisabled(): bool
{
if (parent::isDisabled() && 'select' === $this->type) {
return true;
@@ -74,10 +60,8 @@ class ChoiceFormField extends FormField
/**
* Sets the value of the field.
*
* @param string|array $value The value of the field
*/
public function select($value)
public function select(string|array|bool $value)
{
$this->setValue($value);
}
@@ -113,11 +97,9 @@ class ChoiceFormField extends FormField
/**
* Sets the value of the field.
*
* @param string|array|bool|null $value The value of the field
*
* @throws \InvalidArgumentException When value type provided is not correct
*/
public function setValue($value)
public function setValue(string|array|bool|null $value)
{
if ('checkbox' === $this->type && false === $value) {
// uncheck
@@ -175,20 +157,16 @@ class ChoiceFormField extends FormField
/**
* Returns the type of the choice field (radio, select, or checkbox).
*
* @return string
*/
public function getType()
public function getType(): string
{
return $this->type;
}
/**
* Returns true if the field accepts multiple values.
*
* @return bool
*/
public function isMultiple()
public function isMultiple(): bool
{
return $this->multiple;
}
@@ -244,7 +222,7 @@ class ChoiceFormField extends FormField
}
// if no option is selected and if it is a simple select box, take the first option as the value
if (!$found && !$this->multiple && !empty($this->options)) {
if (!$found && !$this->multiple && $this->options) {
$this->value = $this->options[0]['value'];
}
}
@@ -268,11 +246,9 @@ class ChoiceFormField extends FormField
/**
* Checks whether given value is in the existing options.
*
* @internal since Symfony 5.3
*
* @return bool
* @internal
*/
public function containsOption(string $optionValue, array $options)
public function containsOption(string $optionValue, array $options): bool
{
if ($this->validationDisabled) {
return true;
@@ -290,11 +266,9 @@ class ChoiceFormField extends FormField
/**
* Returns list of available field options.
*
* @internal since Symfony 5.3
*
* @return array
* @internal
*/
public function availableOptionValues()
public function availableOptionValues(): array
{
$values = [];
@@ -308,11 +282,11 @@ class ChoiceFormField extends FormField
/**
* Disables the internal validation of the field.
*
* @internal since Symfony 5.3
* @internal
*
* @return $this
*/
public function disableValidation()
public function disableValidation(): static
{
$this->validationDisabled = true;