Skip to content

Commit

Permalink
Apply php-cs-fixer rule for array_key_exists()
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Feb 23, 2019
1 parent 7823ba2 commit bc3653d
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions ButtonBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ public function getAttributes()
*/
public function hasAttribute($name)
{
return array_key_exists($name, $this->attributes);
return \array_key_exists($name, $this->attributes);
}

/**
Expand All @@ -677,7 +677,7 @@ public function hasAttribute($name)
*/
public function getAttribute($name, $default = null)
{
return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
}

/**
Expand Down Expand Up @@ -771,7 +771,7 @@ public function getOptions()
*/
public function hasOption($name)
{
return array_key_exists($name, $this->options);
return \array_key_exists($name, $this->options);
}

/**
Expand All @@ -784,7 +784,7 @@ public function hasOption($name)
*/
public function getOption($name, $default = null)
{
return array_key_exists($name, $this->options) ? $this->options[$name] : $default;
return \array_key_exists($name, $this->options) ? $this->options[$name] : $default;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ChoiceList/ArrayChoiceList.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function getChoicesForValues(array $values)
$choices = [];

foreach ($values as $i => $givenValue) {
if (array_key_exists($givenValue, $this->choices)) {
if (\array_key_exists($givenValue, $this->choices)) {
$choices[$i] = $this->choices[$givenValue];
}
}
Expand Down
2 changes: 1 addition & 1 deletion Console/Descriptor/JsonDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected function describeOption(OptionsResolver $optionsResolver, array $optio
'allowed_values' => 'allowedValues',
];
foreach ($map as $label => $name) {
if (array_key_exists($name, $definition)) {
if (\array_key_exists($name, $definition)) {
$data[$label] = $definition[$name];

if ('default' === $name) {
Expand Down
2 changes: 1 addition & 1 deletion Console/Descriptor/TextDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected function describeOption(OptionsResolver $optionsResolver, array $optio
];
$rows = [];
foreach ($map as $label => $name) {
$value = array_key_exists($name, $definition) ? $dump($definition[$name]) : '-';
$value = \array_key_exists($name, $definition) ? $dump($definition[$name]) : '-';
if ('default' === $name && isset($definition['lazy'])) {
$value = "Value: $value\n\nClosure(s): ".$dump($definition['lazy']);
}
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/FormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);

$isDataOptionSet = array_key_exists('data', $options);
$isDataOptionSet = \array_key_exists('data', $options);

$builder
->setRequired($options['required'])
Expand Down
2 changes: 1 addition & 1 deletion Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public function submit($submittedData, $clearMissing = true)
}

foreach ($this->children as $name => $child) {
$isSubmitted = array_key_exists($name, $submittedData);
$isSubmitted = \array_key_exists($name, $submittedData);

if ($isSubmitted || $clearMissing) {
$child->submit($isSubmitted ? $submittedData[$name] : null, $clearMissing);
Expand Down
8 changes: 4 additions & 4 deletions FormConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,15 @@ public function getAttributes()
*/
public function hasAttribute($name)
{
return array_key_exists($name, $this->attributes);
return \array_key_exists($name, $this->attributes);
}

/**
* {@inheritdoc}
*/
public function getAttribute($name, $default = null)
{
return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default;
}

/**
Expand Down Expand Up @@ -526,15 +526,15 @@ public function getOptions()
*/
public function hasOption($name)
{
return array_key_exists($name, $this->options);
return \array_key_exists($name, $this->options);
}

/**
* {@inheritdoc}
*/
public function getOption($name, $default = null)
{
return array_key_exists($name, $this->options) ? $this->options[$name] : $default;
return \array_key_exists($name, $this->options) ? $this->options[$name] : $default;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion FormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function createBuilder($type = 'Symfony\Component\Form\Extension\Core\Typ
*/
public function createNamedBuilder($name, $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = [])
{
if (null !== $data && !array_key_exists('data', $options)) {
if (null !== $data && !\array_key_exists('data', $options)) {
$options['data'] = $data;
}

Expand Down
8 changes: 4 additions & 4 deletions NativeRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ public function handleRequest(FormInterface $form, $request = null)
if ('' === $name) {
$params = $_POST;
$files = $fixedFiles;
} elseif (array_key_exists($name, $_POST) || array_key_exists($name, $fixedFiles)) {
} elseif (\array_key_exists($name, $_POST) || \array_key_exists($name, $fixedFiles)) {
$default = $form->getConfig()->getCompound() ? [] : null;
$params = array_key_exists($name, $_POST) ? $_POST[$name] : $default;
$files = array_key_exists($name, $fixedFiles) ? $fixedFiles[$name] : $default;
$params = \array_key_exists($name, $_POST) ? $_POST[$name] : $default;
$files = \array_key_exists($name, $fixedFiles) ? $fixedFiles[$name] : $default;
} else {
// Don't submit the form if it is not present in the request
return;
Expand All @@ -115,7 +115,7 @@ public function handleRequest(FormInterface $form, $request = null)
return;
}

if (\is_array($data) && array_key_exists('_method', $data) && $method === $data['_method'] && !$form->has('_method')) {
if (\is_array($data) && \array_key_exists('_method', $data) && $method === $data['_method'] && !$form->has('_method')) {
unset($data['_method']);
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/CustomArrayObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(array $array = null)

public function offsetExists($offset)
{
return array_key_exists($offset, $this->array);
return \array_key_exists($offset, $this->array);
}

public function offsetGet($offset)
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/FixedDataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(array $mapping)

public function transform($value)
{
if (!array_key_exists($value, $this->mapping)) {
if (!\array_key_exists($value, $this->mapping)) {
throw new TransformationFailedException(sprintf('No mapping for value "%s"', $value));
}

Expand Down

0 comments on commit bc3653d

Please sign in to comment.