Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[CS / micro opt] [POC/WP] please ignore for now #24344

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

Closed
wants to merge 1 commit into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function dispatchEvent($eventName, EventArgs $eventArgs = null)
$initialized = isset($this->initialized[$eventName]);

foreach ($this->listeners[$eventName] as $hash => $listener) {
if (!$initialized && is_string($listener)) {
if (!$initialized && \is_string($listener)) {
$this->listeners[$eventName][$hash] = $listener = $this->container->get($listener);
}

Expand Down Expand Up @@ -100,7 +100,7 @@ public function hasListeners($event)
*/
public function addEventListener($events, $listener)
{
if (is_string($listener)) {
if (\is_string($listener)) {
if ($this->initialized) {
throw new \RuntimeException('Adding lazy-loading listeners after construction is not supported.');
}
Expand All @@ -126,7 +126,7 @@ public function addEventListener($events, $listener)
*/
public function removeEventListener($events, $listener)
{
if (is_string($listener)) {
if (\is_string($listener)) {
$hash = '_service_'.$listener;
} else {
// Picks the hash code related to that listener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ private function sanitizeQuery($connectionName, $query)
if (null === $query['params']) {
$query['params'] = array();
}
if (!is_array($query['params'])) {
if (!\is_array($query['params'])) {
$query['params'] = array($query['params']);
}
foreach ($query['params'] as $j => $param) {
if (isset($query['types'][$j])) {
// Transform the param according to the type
$type = $query['types'][$j];
if (is_string($type)) {
if (\is_string($type)) {
$type = Type::getType($type);
}
if ($type instanceof Type) {
Expand Down Expand Up @@ -158,11 +158,11 @@ private function sanitizeQuery($connectionName, $query)
*/
private function sanitizeParam($var)
{
if (is_object($var)) {
return array(sprintf('Object(%s)', get_class($var)), false);
if (\is_object($var)) {
return array(sprintf('Object(%s)', \get_class($var)), false);
}

if (is_array($var)) {
if (\is_array($var)) {
$a = array();
$original = true;
foreach ($var as $k => $v) {
Expand All @@ -174,7 +174,7 @@ private function sanitizeParam($var)
return array($a, $original);
}

if (is_resource($var)) {
if (\is_resource($var)) {
return array(sprintf('Resource(%s)', get_resource_type($var)), false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \Re
}

if (!$bundleConfig['dir']) {
if (in_array($bundleConfig['type'], array('annotation', 'staticphp'))) {
if (\in_array($bundleConfig['type'], array('annotation', 'staticphp'))) {
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingObjectDefaultName();
} else {
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingResourceConfigDirectory();
Expand Down Expand Up @@ -249,7 +249,7 @@ protected function assertValidMappingConfiguration(array $mappingConfig, $object
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
}

if (!in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) {
if (!\in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) {
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '.
'"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '.
'You can register them by adding a new driver to the '.
Expand Down Expand Up @@ -278,11 +278,11 @@ protected function detectMetadataDriver($dir, ContainerBuilder $container)
$container->addResource(new FileResource($resource));

$extension = $this->getMappingResourceExtension();
if (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) && count($files)) {
if (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) && \count($files)) {
return 'xml';
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) && count($files)) {
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) && \count($files)) {
return 'yml';
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) && count($files)) {
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) && \count($files)) {
return 'php';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private function findAndSortTags($tagName, ContainerBuilder $container)

if ($sortedTags) {
krsort($sortedTags);
$sortedTags = call_user_func_array('array_merge', $sortedTags);
$sortedTags = \call_user_func_array('array_merge', $sortedTags);
}

return $sortedTags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function __construct($driver, array $namespaces, array $managerParameters
$this->managerParameters = $managerParameters;
$this->driverPattern = $driverPattern;
$this->enabledParameter = $enabledParameter;
if (count($aliasMap) && (!$configurationPattern || !$registerAliasMethodName)) {
if (\count($aliasMap) && (!$configurationPattern || !$registerAliasMethodName)) {
throw new \InvalidArgumentException('configurationPattern and registerAliasMethodName are required to register namespace alias');
}
$this->configurationPattern = $configurationPattern;
Expand All @@ -153,7 +153,7 @@ public function process(ContainerBuilder $container)
$chainDriverDef->addMethodCall('addDriver', array($mappingDriverDef, $namespace));
}

if (!count($this->aliasMap)) {
if (!\count($this->aliasMap)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function loadValuesForChoices(array $choices, $value = null)

// Optimize performance for single-field identifiers. We already
// know that the IDs are used as values
$optimize = null === $value || is_array($value) && $value[0] === $this->idReader;
$optimize = null === $value || \is_array($value) && $value[0] === $this->idReader;

// Attention: This optimization does not check choices for existence
if ($optimize && !$this->choiceList && $this->idReader->isSingleId()) {
Expand Down Expand Up @@ -147,7 +147,7 @@ public function loadChoicesForValues(array $values, $value = null)

// Optimize performance in case we have an object loader and
// a single-field identifier
$optimize = null === $value || is_array($value) && $value[0] === $this->idReader;
$optimize = null === $value || \is_array($value) && $value[0] === $this->idReader;

if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
$unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function __construct(ObjectManager $manager, $class, $labelPath = null, E
$this->entityLoader = $entityLoader;
$this->classMetadata = $manager->getClassMetadata($class);
$this->class = $this->classMetadata->getName();
$this->loaded = is_array($entities) || $entities instanceof \Traversable;
$this->loaded = \is_array($entities) || $entities instanceof \Traversable;
$this->preferredEntities = $preferredEntities;
list(
$this->idAsIndex,
Expand Down Expand Up @@ -453,13 +453,13 @@ private function getIdentifierInfoForClass(ClassMetadata $classMetadata)

$identifiers = $classMetadata->getIdentifierFieldNames();

if (1 === count($identifiers)) {
if (1 === \count($identifiers)) {
$identifier = $identifiers[0];

if (!$classMetadata->hasAssociation($identifier)) {
$idAsValue = true;

if (in_array($classMetadata->getTypeOfField($identifier), array('integer', 'smallint', 'bigint'))) {
if (\in_array($classMetadata->getTypeOfField($identifier), array('integer', 'smallint', 'bigint'))) {
$idAsIndex = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public function __construct(ObjectManager $om, ClassMetadata $classMetadata)

$this->om = $om;
$this->classMetadata = $classMetadata;
$this->singleId = 1 === count($ids);
$this->intId = $this->singleId && in_array($idType, array('integer', 'smallint', 'bigint'));
$this->singleId = 1 === \count($ids);
$this->intId = $this->singleId && \in_array($idType, array('integer', 'smallint', 'bigint'));
$this->idField = current($ids);

// single field association are resolved, since the schema column could be an int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ public function getEntitiesByIds($identifier, array $values)
// Guess type
$entity = current($qb->getRootEntities());
$metadata = $qb->getEntityManager()->getClassMetadata($entity);
if (in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) {
if (\in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) {
$parameterType = Connection::PARAM_INT_ARRAY;

// Filter out non-integer values (e.g. ""). If we don't, some
// databases such as PostgreSQL fail.
$values = array_values(array_filter($values, function ($v) {
return (string) $v === (string) (int) $v || ctype_digit($v);
}));
} elseif (in_array($metadata->getTypeOfField($identifier), array('uuid', 'guid'))) {
} elseif (\in_array($metadata->getTypeOfField($identifier), array('uuid', 'guid'))) {
$parameterType = Connection::PARAM_STR_ARRAY;

// Like above, but we just filter out empty strings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function transform($collection)

// For cases when the collection getter returns $collection->toArray()
// in order to prevent modifications of the returned collection
if (is_array($collection)) {
if (\is_array($collection)) {
return $collection;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function guessMaxLength($class, $property)
return new ValueGuess($mapping['length'], Guess::HIGH_CONFIDENCE);
}

if (in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
if (\in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
}
}
Expand All @@ -144,7 +144,7 @@ public function guessPattern($class, $property)
{
$ret = $this->getMetadata($class);
if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) {
if (in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
if (\in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) {
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function onBind(FormEvent $event)

// If all items were removed, call clear which has a higher
// performance on persistent collections
if ($collection instanceof Collection && 0 === count($data)) {
if ($collection instanceof Collection && 0 === \count($data)) {
$collection->clear();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function configureOptions(OptionsResolver $resolver)
// for equal query builders
$queryBuilderNormalizer = function (Options $options, $queryBuilder) {
if (is_callable($queryBuilder)) {
$queryBuilder = call_user_func($queryBuilder, $options['em']->getRepository($options['class']));
$queryBuilder = \call_user_func($queryBuilder, $options['em']->getRepository($options['class']));
}

return $queryBuilder;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function configureOptions(OptionsResolver $resolver)
// for equal query builders
$queryBuilderNormalizer = function (Options $options, $queryBuilder) {
if (is_callable($queryBuilder)) {
$queryBuilder = call_user_func($queryBuilder, $options['em']->getRepository($options['class']));
$queryBuilder = \call_user_func($queryBuilder, $options['em']->getRepository($options['class']));

if (!$queryBuilder instanceof QueryBuilder) {
throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ORM\QueryBuilder');
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ private function normalizeParams(array $params)
{
foreach ($params as $index => $param) {
// normalize recursively
if (is_array($param)) {
if (\is_array($param)) {
$params[$index] = $this->normalizeParams($param);
continue;
}

if (!is_string($params[$index])) {
if (!\is_string($params[$index])) {
continue;
}

Expand All @@ -101,7 +101,7 @@ private function normalizeParams(array $params)
continue;
}
} else {
if (self::MAX_STRING_LENGTH < strlen($params[$index])) {
if (self::MAX_STRING_LENGTH < \strlen($params[$index])) {
$params[$index] = substr($params[$index], 0, self::MAX_STRING_LENGTH - 6).' [...]';
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function loadUserByUsername($username)
$user = $repository->findOneBy(array($this->property => $username));
} else {
if (!$repository instanceof UserProviderInterface) {
throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Component\Security\Core\User\UserProviderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, get_class($repository)));
throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Component\Security\Core\User\UserProviderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, \get_class($repository)));
}

$user = $repository->loadUserByUsername($username);
Expand All @@ -71,7 +71,7 @@ public function refreshUser(UserInterface $user)
{
$class = $this->getClass();
if (!$user instanceof $class) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
}

$repository = $this->getRepository();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testFixManagersAutoMappingsWithTwoAutomappings()
'SecondBundle' => 'My\SecondBundle',
);

$reflection = new \ReflectionClass(get_class($this->extension));
$reflection = new \ReflectionClass(\get_class($this->extension));
$method = $reflection->getMethod('fixManagersAutoMappings');
$method->setAccessible(true);

Expand Down Expand Up @@ -157,7 +157,7 @@ public function testFixManagersAutoMappings(array $originalEm1, array $originalE
'SecondBundle' => 'My\SecondBundle',
);

$reflection = new \ReflectionClass(get_class($this->extension));
$reflection = new \ReflectionClass(\get_class($this->extension));
$method = $reflection->getMethod('fixManagersAutoMappings');
$method->setAccessible(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function setUp()
$ids = range(1, 300);

foreach ($ids as $id) {
$name = 65 + (int) chr($id % 57);
$name = 65 + (int) \chr($id % 57);
$this->em->persist(new SingleIntIdEntity($id, $name));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function testLogUTF8LongString()
;

$testStringArray = array('é', 'á', 'ű', 'ő', 'ú', 'ö', 'ü', 'ó', 'í');
$testStringCount = count($testStringArray);
$testStringCount = \count($testStringArray);

$shortString = '';
$longString = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function testSupportProxy()
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name');

$user2 = $em->getReference('Symfony\Bridge\Doctrine\Tests\Fixtures\User', array('id1' => 1, 'id2' => 1));
$this->assertTrue($provider->supportsClass(get_class($user2)));
$this->assertTrue($provider->supportsClass(\get_class($user2)));
}

private function getManager($em, $name = null)
Expand Down
Loading