Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AllBundles] - String comparators can always be strict === #3346

Open
wants to merge 1 commit into
base: 6.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
$entityName = (string) $classMetadata->getName();

// We dynamically set the user class that was configured in the configuration
if ($entityName == 'Kunstmaan\AdminBundle\Entity\AclChangeset') {
if ($entityName === 'Kunstmaan\AdminBundle\Entity\AclChangeset') {
$mapping = [
'fieldName' => 'user',
'targetEntity' => $this->className,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function getQueryBuilder()
// Apply sorting
if (!empty($this->orderBy)) {
$orderBy = $this->orderBy;
$this->queryBuilder->orderBy($orderBy, $this->orderDirection == 'DESC' ? 'DESC' : 'ASC');
$this->queryBuilder->orderBy($orderBy, $this->orderDirection === 'DESC' ? 'DESC' : 'ASC');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function getQuery()
} elseif (!strpos($orderBy, '.')) {
$orderBy = 'b.' . $orderBy;
}
$queryBuilder->orderBy($orderBy, $this->orderDirection == 'DESC' ? 'DESC' : 'ASC');
$queryBuilder->orderBy($orderBy, $this->orderDirection === 'DESC' ? 'DESC' : 'ASC');
}

// Apply other changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private function getCookieTypes()
*/
public function getValue($item, $columnName)
{
if ($columnName == 'domain' && !$item->getDomain()) {
if ($columnName === 'domain' && !$item->getDomain()) {
return 'All domains';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function getProfileSegments()
$builtin = [];
$own = [];
foreach ($profileSegments as $segment) {
if ($segment->type == 'BUILT_IN') {
if ($segment->type === 'BUILT_IN') {
$builtin[] = [
'name' => $segment->name,
'query' => $segment->segmentId,
Expand Down
6 changes: 3 additions & 3 deletions src/Kunstmaan/FixturesBundle/Loader/Fixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public function __construct($name, $class, $specs)
$this->setClass($class);

foreach ($specs as $spec => $data) {
if ($spec != 'translations' && $spec != 'parameters') {
if ($spec !== 'translations' && $spec !== 'parameters') {
$this->addProperty($spec, $data);
} elseif ($spec == 'translations') {
} elseif ($spec === 'translations') {
$this->setTranslations($data);
} elseif ($spec == 'parameters') {
} elseif ($spec === 'parameters') {
$this->setParameters($data);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/FormBundle/Helper/FormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function handleForm(FormPageInterface $page, Request $request, RenderCont
}

$form = $formBuilder->getForm();
if ($request->getMethod() == 'POST') {
if ($request->getMethod() === 'POST') {
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$formSubmission = new FormSubmission();
Expand Down
16 changes: 8 additions & 8 deletions src/Kunstmaan/GeneratorBundle/Command/GenerateArticleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ protected function getWelcomeText()
protected function askForDummydata()
{
$dummydataOption = $this->assistant->getOption('dummydata');
if ($dummydataOption != 'y' && $dummydataOption != 'n') {
if ($dummydataOption !== 'y' && $dummydataOption !== 'n') {
$dummydataOption = $this->assistant->askConfirmation("\nDo you want to generate data fixtures to populate your database ? (y/n)\n", 'n', '?', false);
}

return $dummydataOption == 'y';
return $dummydataOption === 'y';
}

/**
Expand All @@ -264,11 +264,11 @@ protected function askForDummydata()
protected function askForCategories()
{
$categoryOption = $this->assistant->getOption('with-category');
if ($categoryOption != 'y' && $categoryOption != 'n') {
if ($categoryOption !== 'y' && $categoryOption !== 'n') {
$categoryOption = $this->assistant->askConfirmation("\nDo you want to use categories ? (y/n)\n", 'y', '?', true);
}

return $categoryOption == 'y';
return $categoryOption === 'y';
}

/**
Expand All @@ -277,11 +277,11 @@ protected function askForCategories()
protected function askForTags()
{
$tagOption = $this->assistant->getOption('with-tag');
if ($tagOption != 'y' && $tagOption != 'n') {
if ($tagOption !== 'y' && $tagOption !== 'n') {
$tagOption = $this->assistant->askConfirmation("\nDo you want to use tags ? (y/n)\n", 'y', '?', true);
}

return $tagOption == 'y';
return $tagOption === 'y';
}

/**
Expand All @@ -290,10 +290,10 @@ protected function askForTags()
protected function askForAuthor()
{
$authorOption = $this->assistant->getOption('with-author');
if ($authorOption != 'y' && $authorOption != 'n') {
if ($authorOption !== 'y' && $authorOption !== 'n') {
$authorOption = $this->assistant->askConfirmation("\nDo you want to use authors ? (y/n)\n", 'y', '?', true);
}

return $authorOption == 'y';
return $authorOption === 'y';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ function ($name) use ($generator, $bundlePath) {
$fields = $this->askEntityFields($this->bundle);
$this->fields = [];
foreach ($fields as $fieldInfo) {
if ($fieldInfo['type'] == 'image') {
if ($fieldInfo['type'] === 'image') {
$this->fields[] = $this->getEntityFields($this->bundle, $this->pagepartName, $this->prefix, $fieldInfo['name'], $fieldInfo['type'],
$fieldInfo['extra'], true, $fieldInfo['minHeight'], $fieldInfo['maxHeight'], $fieldInfo['minWidth'], $fieldInfo['maxWidth'], $fieldInfo['mimeTypes']);
} elseif ($fieldInfo['type'] == 'media') {
} elseif ($fieldInfo['type'] === 'media') {
$this->fields[] = $this->getEntityFields($this->bundle, $this->pagepartName, $this->prefix, $fieldInfo['name'], $fieldInfo['type'],
$fieldInfo['extra'], true, null, null, null, null, $fieldInfo['mimeTypes']);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ protected function askForPrefix(?array $text = null, $namespace = null)
$defaultPrefix = GeneratorUtils::cleanPrefix($this->convertNamespaceToSnakeCase($namespace));
$prefix = GeneratorUtils::cleanPrefix($this->assistant->ask('Tablename prefix', $defaultPrefix));

if ($prefix == '') {
if ($prefix === '') {
break;
}

Expand Down Expand Up @@ -430,17 +430,17 @@ function ($name) use ($generator, $container) {
}

// If image type, force image media filter
if ($typeStrings[$typeId] == 'image') {
if ($typeStrings[$typeId] === 'image') {
$extra = 'image';
}

// If media type, ask for media filter
if ($typeStrings[$typeId] == 'media') {
if ($typeStrings[$typeId] === 'media') {
$mediaTypeId = $this->assistant->askSelect('Media filter', $mediaTypeSelect);
$extra = strtolower($mediaTypeSelect[$mediaTypeId]);
}

if ($typeStrings[$typeId] == 'image' || $typeStrings[$typeId] == 'media') {
if ($typeStrings[$typeId] === 'image' || $typeStrings[$typeId] === 'media') {
// Ask the allowed mimetypes for the media ojbect
$mimeTypes = $this->assistant->ask('Do you want to limit the possible file types? Then specify a comma-seperated list of types (example: image/png,image/svg+xml), otherwise press ENTER',
null
Expand All @@ -459,7 +459,7 @@ function ($name) use ($generator, $container) {
'maxWidth' => null,
];

if ($extra == 'image') {
if ($extra === 'image') {
$minHeight = $maxHeight = $minWidth = $maxWidth = null;
if ($this->assistant->askConfirmation('Do you want to add validation of the dimensions of the media object? (y/n)',
'n',
Expand Down Expand Up @@ -634,7 +634,7 @@ protected function getEntityFields(
$fields[$type][$subField] = [
'fieldName' => lcfirst(Container::camelize($name . '_' . $subField)),
'type' => 'string',
'formType' => $subField == 'url' ? 'Kunstmaan\NodeBundle\Form\Type\URLChooserType' : TextType::class,
'formType' => $subField === 'url' ? 'Kunstmaan\NodeBundle\Form\Type\URLChooserType' : TextType::class,
'nullable' => $allNullable,
];
}
Expand Down
24 changes: 12 additions & 12 deletions src/Kunstmaan/GeneratorBundle/Generator/PagePartGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,55 +336,55 @@ private function generateBehatTest()
$attr = $field->vars['attr'];
$blocks = $field->vars['block_prefixes'];

if ($name == 'title' || $name == 'pageTitle') {
if ($name === 'title' || $name === 'pageTitle') {
continue;
}

if ($blocks[1] == 'hidden') {
if ($blocks[1] === 'hidden') {
// do nothing
} elseif ($blocks[1] == 'choice' && $blocks[1] == 'entity') {
} elseif ($blocks[1] === 'choice' && $blocks[1] === 'entity') {
// do nothing
} elseif ($blocks[1] == 'datetime') {
} elseif ($blocks[1] === 'datetime') {
$pageFields[]['datetime'] = [
'label' => $this->labelCase($name),
'date_random' => DateTime::date('d/m/Y'),
'time_random' => DateTime::time('H:i'),
];
} elseif ($blocks[1] == 'number') {
} elseif ($blocks[1] === 'number') {
$pageFields[]['decimal'] = [
'label' => $this->labelCase($name),
'random' => Base::randomFloat(2, 0, 99999),
];
} elseif ($blocks[1] == 'integer') {
} elseif ($blocks[1] === 'integer') {
$pageFields[]['integer'] = [
'label' => $this->labelCase($name),
'random' => Base::randomNumber(3000, 99999),
];
} elseif ($blocks[1] == 'checkbox') {
} elseif ($blocks[1] === 'checkbox') {
$pageFields[]['boolean'] = [
'label' => $this->labelCase($name),
];
} elseif ($blocks[1] == 'media') {
} elseif ($blocks[1] === 'media') {
$id = (count($images) > 0 ? $images[0]->getId() : 1);
$pageFields[]['media'] = [
'label' => $this->labelCase($name),
'random' => $id,
];
} elseif ($blocks[2] == 'urlchooser') {
} elseif ($blocks[2] === 'urlchooser') {
$pageFields[]['link'] = [
'label' => $this->labelCase($name),
'random' => 'http://www.' . strtolower(Lorem::word()) . '.com',
];
} elseif ($blocks[2] == 'textarea' && array_key_exists(
} elseif ($blocks[2] === 'textarea' && array_key_exists(
'class',
$attr
) && $attr['class'] == 'js-rich-editor rich-editor'
) && $attr['class'] === 'js-rich-editor rich-editor'
) {
$pageFields[]['rich_text'] = [
'label' => $this->labelCase($name),
'random' => Lorem::sentence(),
];
} elseif ($blocks[2] == 'textarea' || $blocks[1] == 'text') {
} elseif ($blocks[2] === 'textarea' || $blocks[1] === 'text') {
$pageFields[]['text'] = [
'label' => $this->labelCase($name),
'random' => Lorem::word(),
Expand Down
4 changes: 2 additions & 2 deletions src/Kunstmaan/GeneratorBundle/Helper/GeneratorUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function cleanPrefix($prefixString)

$result = preg_replace('/_*$/i', '', strtolower($prefixString)) . '_';

if ($result == '_') {
if ($result === '_') {
return null;
}

Expand Down Expand Up @@ -121,7 +121,7 @@ public static function getFullSkeletonPath($pathInSkeleton)
}

// Can't have a / at the end.
if (substr($pathInSkeleton, -1) == '/') {
if (substr($pathInSkeleton, -1) === '/') {
$pathInSkeleton = rtrim($pathInSkeleton, '/');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Kunstmaan/GeneratorBundle/Helper/InputAssistant.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function askForPrefix(?array $text = null, $namespace = null)
$this->input->setOption('prefix', $prefix);
}

if ($prefix == '') {
if ($prefix === '') {
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public function iFilterOn($filterType, $filterComparator, $filterValue, $additio
foreach ($records as $field => $value) {
//We need this check when adding additionally filters
//because the filter_columnname[] is the same for all the filter lines
if ($additionally && $field == 'filter_columnname[]') {
if ($additionally && $field === 'filter_columnname[]') {
$filterFields = $this->getSession()->getPage()->findAll('named', array('field', $this->getSession()->getSelectorsHandler()->xpathLiteral($field)));
$filterField = $filterFields[count($filterFields) - 1];
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function iFillPagePartDateTime($name, $dateValue, $timeValue)
$element = $field->getParent()->find('xpath', "//input[contains(@class, 'form_timepicker')]");
$element->setValue($timeValue);

if ($element->getValue() == '') {
if ($element->getValue() === '') {
$id = $element->getAttribute('id');
if (!empty($id)) {
$javascript = "document.getElementById('" . $id . "').value='" . $timeValue . "';";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function load(ObjectManager $manager)

$translations = array();
foreach ($languages as $lang) {
if ($lang == 'nl') {
if ($lang === 'nl') {
$title = $fakerNL->sentence;
} else {
$title = $fakerEN->sentence;
Expand Down
Loading