Skip to content

Commit

Permalink
Applied fixes from FlintCI
Browse files Browse the repository at this point in the history
  • Loading branch information
soullivaneuh authored and OskarStark committed Jan 22, 2019
1 parent 2c02013 commit 6c763f8
Show file tree
Hide file tree
Showing 24 changed files with 43 additions and 43 deletions.
16 changes: 8 additions & 8 deletions src/Admin/AbstractAdmin.php
Expand Up @@ -1039,7 +1039,7 @@ public function addSubClass($subClass)
__METHOD__
), E_USER_DEPRECATED);

if (!\in_array($subClass, $this->subClasses)) {
if (!\in_array($subClass, $this->subClasses, true)) {
$this->subClasses[] = $subClass;
}
}
Expand Down Expand Up @@ -2510,7 +2510,7 @@ public function getPagerType()
*/
public function determinedPerPageValue($perPage)
{
return \in_array($perPage, $this->perPageOptions);
return \in_array($perPage, $this->perPageOptions, true);
}

public function isAclEnabled()
Expand Down Expand Up @@ -2607,7 +2607,7 @@ public function configureActionButtons($action, $object = null)
{
$list = [];

if (\in_array($action, ['tree', 'show', 'edit', 'delete', 'list', 'batch'])
if (\in_array($action, ['tree', 'show', 'edit', 'delete', 'list', 'batch'], true)
&& $this->hasAccess('create')
&& $this->hasRoute('create')
) {
Expand All @@ -2618,7 +2618,7 @@ public function configureActionButtons($action, $object = null)
];
}

if (\in_array($action, ['show', 'delete', 'acl', 'history'])
if (\in_array($action, ['show', 'delete', 'acl', 'history'], true)
&& $this->canAccessObject('edit', $object)
&& $this->hasRoute('edit')
) {
Expand All @@ -2629,7 +2629,7 @@ public function configureActionButtons($action, $object = null)
];
}

if (\in_array($action, ['show', 'edit', 'acl'])
if (\in_array($action, ['show', 'edit', 'acl'], true)
&& $this->canAccessObject('history', $object)
&& $this->hasRoute('history')
) {
Expand All @@ -2640,7 +2640,7 @@ public function configureActionButtons($action, $object = null)
];
}

if (\in_array($action, ['edit', 'history'])
if (\in_array($action, ['edit', 'history'], true)
&& $this->isAclEnabled()
&& $this->canAccessObject('acl', $object)
&& $this->hasRoute('acl')
Expand All @@ -2652,7 +2652,7 @@ public function configureActionButtons($action, $object = null)
];
}

if (\in_array($action, ['edit', 'history', 'acl'])
if (\in_array($action, ['edit', 'history', 'acl'], true)
&& $this->canAccessObject('show', $object)
&& \count($this->getShow()) > 0
&& $this->hasRoute('show')
Expand All @@ -2664,7 +2664,7 @@ public function configureActionButtons($action, $object = null)
];
}

if (\in_array($action, ['show', 'edit', 'delete', 'acl', 'batch'])
if (\in_array($action, ['show', 'edit', 'delete', 'acl', 'batch'], true)
&& $this->hasAccess('list')
&& $this->hasRoute('list')
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/Pool.php
Expand Up @@ -272,7 +272,7 @@ public function getAdminByAdminCode($adminCode)
*/
public function getInstance($id)
{
if (!\in_array($id, $this->adminServiceIds)) {
if (!\in_array($id, $this->adminServiceIds, true)) {
$msg = sprintf('Admin service "%s" not found in admin pool.', $id);
$shortest = -1;
$closest = null;
Expand Down
2 changes: 1 addition & 1 deletion src/Block/AdminListBlockService.php
Expand Up @@ -60,7 +60,7 @@ public function execute(BlockContextInterface $blockContext, Response $response

$visibleGroups = [];
foreach ($dashboardGroups as $name => $dashboardGroup) {
if (!$settings['groups'] || \in_array($name, $settings['groups'])) {
if (!$settings['groups'] || \in_array($name, $settings['groups'], true)) {
$visibleGroups[] = $dashboardGroup;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/CRUDController.php
Expand Up @@ -78,7 +78,7 @@ class CRUDController implements ContainerAwareInterface
// BC for Symfony 3.3 where ControllerTrait exists but does not contain get() and has() methods.
public function __call($method, $arguments)
{
if (\in_array($method, ['get', 'has'])) {
if (\in_array($method, ['get', 'has'], true)) {
return \call_user_func_array([$this->container, $method], $arguments);
}

Expand Down Expand Up @@ -966,7 +966,7 @@ public function exportAction(Request $request)
$exporter = $this->get('sonata.exporter.exporter');
}

if (!\in_array($format, $allowedExportFormats)) {
if (!\in_array($format, $allowedExportFormats, true)) {
throw new \RuntimeException(
sprintf(
'Export in format `%s` is not allowed for class: `%s`. Allowed formats are: `%s`',
Expand Down
2 changes: 1 addition & 1 deletion src/Datagrid/ListMapper.php
Expand Up @@ -88,7 +88,7 @@ public function add($name, $type = null, array $fieldDescriptionOptions = [])
}

// Ensure batch and action pseudo-fields are tagged as virtual
if (\in_array($type, ['actions', 'batch', 'select'])) {
if (\in_array($type, ['actions', 'batch', 'select'], true)) {
$fieldDescriptionOptions['virtual_field'] = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/ExtensionCompilerPass.php
Expand Up @@ -201,7 +201,7 @@ protected function flattenExtensionConfiguration(array $config)
*/
protected function hasTrait(\ReflectionClass $class, $traitName)
{
if (\in_array($traitName, $class->getTraitNames())) {
if (\in_array($traitName, $class->getTraitNames(), true)) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Expand Up @@ -107,7 +107,7 @@ public function getConfigTreeBuilder()
->info('Perhaps one of the three options: show, fade, hide.')
->validate()
->ifTrue(function ($v) {
return !\in_array($v, ['show', 'fade', 'hide']);
return !\in_array($v, ['show', 'fade', 'hide'], true);
})
->thenInvalid('Configuration value of "global_search.empty_boxes" must be one of show, fade or hide.')
->end()
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/SonataAdminExtension.php
Expand Up @@ -341,7 +341,7 @@ public function prepend(ContainerBuilder $container)
foreach ($diExtraConfigs as $diExtraConfig) {
if (isset($diExtraConfig['annotation_patterns'])) {
// don't add our own pattern if user has already done so
if (false !== array_search($sonataAdminPattern, $diExtraConfig['annotation_patterns'])) {
if (false !== array_search($sonataAdminPattern, $diExtraConfig['annotation_patterns'], true)) {
return;
}
$annotationPatternsConfigured = true;
Expand Down Expand Up @@ -488,8 +488,8 @@ private function mergeArray(array $array, array $addArray, array $removeArray =
array_push($array, $toAdd);
}
foreach ($removeArray as $toRemove) {
if (\in_array($toRemove, $array)) {
array_splice($array, array_search($toRemove, $array), 1);
if (\in_array($toRemove, $array, true)) {
array_splice($array, array_search($toRemove, $array, true), 1);
}
}

Expand Down
Expand Up @@ -56,7 +56,7 @@ public function transform($collection)

foreach ($collection as $entity) {
// identify choices by their collection key
$key = array_search($entity, $availableEntities);
$key = array_search($entity, $availableEntities, true);
$array[] = $key;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Form/FormMapper.php
Expand Up @@ -199,7 +199,7 @@ public function removeGroup($group, $tab = 'default', $deleteEmptyTab = false)
unset($groups[$group]);

$tabs = $this->getTabs();
$key = array_search($group, $tabs[$tab]['groups']);
$key = array_search($group, $tabs[$tab]['groups'], true);

if (false !== $key) {
unset($tabs[$tab]['groups'][$key]);
Expand Down
2 changes: 1 addition & 1 deletion src/Mapper/BaseGroupedMapper.php
Expand Up @@ -145,7 +145,7 @@ public function with($name, array $options = [])
$tabs = $this->getTabs();
}

if ($this->currentGroup && isset($tabs[$this->currentTab]) && !\in_array($this->currentGroup, $tabs[$this->currentTab]['groups'])) {
if ($this->currentGroup && isset($tabs[$this->currentTab]) && !\in_array($this->currentGroup, $tabs[$this->currentTab]['groups'], true)) {
$tabs[$this->currentTab]['groups'][] = $this->currentGroup;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Model/AuditManager.php
Expand Up @@ -48,7 +48,7 @@ public function setReader($serviceId, array $classes)
public function hasReader($class)
{
foreach ($this->readers as $classes) {
if (\in_array($class, $classes)) {
if (\in_array($class, $classes, true)) {
return true;
}
}
Expand All @@ -59,7 +59,7 @@ public function hasReader($class)
public function getReader($class)
{
foreach ($this->readers as $readerId => $classes) {
if (\in_array($class, $classes)) {
if (\in_array($class, $classes, true)) {
return $this->container->get($readerId);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Route/DefaultRouteGenerator.php
Expand Up @@ -158,7 +158,7 @@ private function loadCache(AdminInterface $admin): void
return;
}

if (\in_array($admin->getCode(), $this->loaded)) {
if (\in_array($admin->getCode(), $this->loaded, true)) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Route/RouteCollection.php
Expand Up @@ -207,7 +207,7 @@ public function clearExcept($routeList)

$elements = $this->elements;
foreach ($elements as $key => $element) {
if (!\in_array($key, $routeCodeList)) {
if (!\in_array($key, $routeCodeList, true)) {
unset($this->elements[$key]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Security/Handler/AclSecurityHandler.php
Expand Up @@ -210,7 +210,7 @@ public function addObjectClassAces(AclInterface $acl, array $roleInformation = [

foreach ($permissions as $permission) {
// add only the object permissions
if (\in_array($permission, $this->getObjectPermissions())) {
if (\in_array($permission, $this->getObjectPermissions(), true)) {
$builder->add($permission);
$hasRole = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Show/ShowMapper.php
Expand Up @@ -129,7 +129,7 @@ public function removeGroup($group, $tab = 'default', $deleteEmptyTab = false)
unset($groups[$group]);

$tabs = $this->getTabs();
$key = array_search($group, $tabs[$tab]['groups']);
$key = array_search($group, $tabs[$tab]['groups'], true);

if (false !== $key) {
unset($tabs[$tab]['groups'][$key]);
Expand Down
2 changes: 1 addition & 1 deletion src/Twig/Extension/SonataAdminExtension.php
Expand Up @@ -475,7 +475,7 @@ final public function getCanonicalizedLocaleForMoment(array $context)
}

foreach (self::MOMENT_UNSUPPORTED_LOCALES as $language => $locales) {
if ($language === $lang && !\in_array($locale, $locales)) {
if ($language === $lang && !\in_array($locale, $locales, true)) {
$locale = $language;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Util/AdminAclManipulator.php
Expand Up @@ -81,7 +81,7 @@ public function addAdminClassAces(

foreach ($permissions as $permission) {
// add only the admin permissions
if (\in_array($permission, $securityHandler->getAdminPermissions())) {
if (\in_array($permission, $securityHandler->getAdminPermissions(), true)) {
$builder->add($permission);
$roleAdminPermissions[] = $permission;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Util/AdminObjectAclData.php
Expand Up @@ -272,7 +272,7 @@ public function getUserPermissions()

if (!$this->isOwner()) {
foreach (self::$ownerPermissions as $permission) {
$key = array_search($permission, $permissions);
$key = array_search($permission, $permissions, true);
if (false !== $key) {
unset($permissions[$key]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Util/AdminObjectAclManipulator.php
Expand Up @@ -254,7 +254,7 @@ protected function buildForm(AdminObjectAclData $data, FormBuilderInterface $for
if (
self::ACL_ROLES_FORM_NAME === $formBuilder->getName()
&& isset($securityInformation[$aclValue])
&& false !== array_search($permission, $securityInformation[$aclValue])
&& false !== array_search($permission, $securityInformation[$aclValue], true)
) {
$attr['disabled'] = 'disabled';
}
Expand Down
Expand Up @@ -186,7 +186,7 @@ public function testProcessResultingConfig(): void
$this->assertContains('sonata_post_admin', $adminGroups['sonata_group_one']['items'][0]['admin']);
$this->assertContains('sonata_news_admin', $adminGroups['sonata_group_one']['items']);
$this->assertContains('sonata_news_admin', $adminGroups['sonata_group_one']['item_adds']);
$this->assertFalse(\in_array('sonata_article_admin', $adminGroups['sonata_group_one']['items']));
$this->assertFalse(\in_array('sonata_article_admin', $adminGroups['sonata_group_one']['items'], true));
$this->assertContains('ROLE_ONE', $adminGroups['sonata_group_one']['roles']);

$this->assertArrayHasKey('sonata_group_two', $adminGroups);
Expand Down
2 changes: 1 addition & 1 deletion tests/Form/Widget/BaseWidgetTest.php
Expand Up @@ -68,7 +68,7 @@ protected function getEnvironment()
*/
protected function getRenderingEngine(\Twig_Environment $environment = null)
{
if (!\in_array($this->type, ['form', 'filter'])) {
if (!\in_array($this->type, ['form', 'filter'], true)) {
throw new \Exception('Please override $this->type in your test class specifying template to use (either form or filter)');
}

Expand Down
12 changes: 6 additions & 6 deletions tests/Security/Handler/RoleSecurityHandlerTest.php
Expand Up @@ -80,27 +80,27 @@ public function testIsGranted($expected, array $superAdminRoles, $adminCode, $op
$this->authorizationChecker->expects($this->any())
->method('isGranted')
->will($this->returnCallback(function (array $attributes, $object) {
if (\in_array('ROLE_BATMAN', $attributes)) {
if (\in_array('ROLE_BATMAN', $attributes, true)) {
return true;
}

if (\in_array('ROLE_IRONMAN', $attributes)) {
if (\in_array('ROLE_IRONMAN', $attributes, true)) {
return true;
}

if (\in_array('ROLE_AUTH_EXCEPTION', $attributes)) {
if (\in_array('ROLE_AUTH_EXCEPTION', $attributes, true)) {
throw new AuthenticationCredentialsNotFoundException();
}

if (\in_array('ROLE_FOO_BAR_ABC', $attributes)) {
if (\in_array('ROLE_FOO_BAR_ABC', $attributes, true)) {
return true;
}

if (\in_array('ROLE_FOO_BAR_DEF', $attributes) && is_a($object, 'stdClass')) {
if (\in_array('ROLE_FOO_BAR_DEF', $attributes, true) && is_a($object, 'stdClass')) {
return true;
}

if (\in_array('ROLE_FOO_BAR_BAZ_ALL', $attributes)) {
if (\in_array('ROLE_FOO_BAR_BAZ_ALL', $attributes, true)) {
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Util/AdminObjectAclDataTest.php
Expand Up @@ -169,8 +169,8 @@ public function testGetUserPermissions(): void
$this->assertInternalType('string', $permission);
}

$this->assertTrue(false !== array_search('OWNER', $adminObjectAclDataOwner->getUserPermissions()));
$this->assertTrue(false !== array_search('MASTER', $adminObjectAclDataOwner->getUserPermissions()));
$this->assertTrue(false !== array_search('OWNER', $adminObjectAclDataOwner->getUserPermissions(), true));
$this->assertTrue(false !== array_search('MASTER', $adminObjectAclDataOwner->getUserPermissions(), true));

$adminObjectAclData = $this->createAdminObjectAclData(false);
$this->assertInternalType('array', $adminObjectAclData->getUserPermissions());
Expand All @@ -179,8 +179,8 @@ public function testGetUserPermissions(): void
$this->assertInternalType('string', $permission);
}

$this->assertFalse(array_search('OWNER', $adminObjectAclData->getUserPermissions()));
$this->assertFalse(array_search('MASTER', $adminObjectAclData->getUserPermissions()));
$this->assertFalse(array_search('OWNER', $adminObjectAclData->getUserPermissions(), true));
$this->assertFalse(array_search('MASTER', $adminObjectAclData->getUserPermissions(), true));
}

public function testIsOwner(): void
Expand Down

0 comments on commit 6c763f8

Please sign in to comment.