Skip to content

Commit

Permalink
Scrutinizer Auto-Fixes
Browse files Browse the repository at this point in the history
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
  • Loading branch information
scrutinizer-auto-fixer committed Sep 24, 2017
1 parent 2520321 commit 35174f3
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 79 deletions.
16 changes: 8 additions & 8 deletions src/Controllers/MetadataControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,32 @@ public function getMethodName($modelName, $crudVerb)
assert(0 < count($this->mapping), 'Mapping array must not be empty');

if (!array_key_exists($modelName, $this->mapping)) {
throw new \Exception('Metadata mapping for model '.$modelName.' not defined');
throw new \Exception('Metadata mapping for model ' . $modelName . ' not defined');
}

$this->checkCrudVerbDefined($crudVerb);
$isOptional = in_array($crudVerb, $this->optionalVerbs);

$lookup = $this->mapping[$modelName];
if (!is_array($lookup)) {
throw new \Exception('Metadata mapping for model '.$modelName.' not an array');
throw new \Exception('Metadata mapping for model ' . $modelName . ' not an array');
}

if (!array_key_exists($crudVerb, $lookup)) {
if ($isOptional) {
// optional crud verbs don't have to be defined - so we can return null
return null;
}
throw new \Exception('Metadata mapping for CRUD verb '.$crudVerb.' on model '.$modelName.' not defined');
throw new \Exception('Metadata mapping for CRUD verb ' . $crudVerb . ' on model ' . $modelName . ' not defined');
}
$result = $lookup[$crudVerb];
if (!isset($result)) {
throw new \Exception('Metadata mapping for CRUD verb '.$crudVerb.' on model '.$modelName.' null');
throw new \Exception('Metadata mapping for CRUD verb ' . $crudVerb . ' on model ' . $modelName . ' null');
}

if (!method_exists($this, $result)) {
throw new \Exception(
'Metadata target for CRUD verb '.$crudVerb.' on model '.$modelName.' does not exist'
'Metadata target for CRUD verb ' . $crudVerb . ' on model ' . $modelName . ' does not exist'
);
}

Expand All @@ -87,17 +87,17 @@ public function getMappings()
// check that mapping array is well formed and sane, rather than waiting to stab us with a spatula
foreach ($this->mapping as $key => $map) {
if (!is_array($map)) {
throw new \Exception('Metadata mapping for model '.$key.' not an array');
throw new \Exception('Metadata mapping for model ' . $key . ' not an array');
}
foreach ($map as $verb => $method) {
$this->checkCrudVerbDefined($verb);
if (!isset($method)) {
throw new \Exception('Metadata mapping for CRUD verb '.$verb.' on model '.$key.' null');
throw new \Exception('Metadata mapping for CRUD verb ' . $verb . ' on model ' . $key . ' null');
}

if (!method_exists($this, $method)) {
throw new \Exception(
'Metadata target for CRUD verb '.$verb.' on model '.$key.' does not exist'
'Metadata target for CRUD verb ' . $verb . ' on model ' . $key . ' does not exist'
);
}
$parmArray = $this->getParameterNames($method);
Expand Down
4 changes: 2 additions & 2 deletions src/Models/MetadataGubbinsHolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function addEntity(EntityGubbins $entity)
{
$className = $entity->getClassName();
if (array_key_exists($className, $this->relations)) {
$msg = $className.' already added';
$msg = $className . ' already added';
throw new \InvalidArgumentException($msg);
}
$this->relations[$className] = $entity;
Expand Down Expand Up @@ -70,7 +70,7 @@ public function getRelationsByClass($className)
if ($stub instanceof AssociationStubMonomorphic) {
assert(
1 >= count($others),
'Monomorphic relation stub on '. $className . ' ' . $relName
'Monomorphic relation stub on ' . $className . ' ' . $relName
. ' should point to at most 1 other stub'
);
}
Expand Down
46 changes: 23 additions & 23 deletions src/Models/MetadataTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function getEndpointName()

if (!isset($endpoint)) {
$bitter = get_class();
$name = substr($bitter, strrpos($bitter, '\\') + 1);
$name = substr($bitter, strrpos($bitter, '\\')+1);
return ($name);
}
return ($endpoint);
Expand Down Expand Up @@ -199,7 +199,7 @@ protected function getRelationshipsFromMethods($biDir = false)
$reflection = new \ReflectionMethod($model, $method);

$file = new \SplFileObject($reflection->getFileName());
$file->seek($reflection->getStartLine() - 1);
$file->seek($reflection->getStartLine()-1);
$code = '';
while ($file->key() < $reflection->getEndLine()) {
$code .= $file->current();
Expand All @@ -212,21 +212,21 @@ protected function getRelationshipsFromMethods($biDir = false)
'Function definition must have keyword \'function\''
);
$begin = strpos($code, 'function(');
$code = substr($code, $begin, strrpos($code, '}') - $begin + 1);
$lastCode = $code[strlen($code) - 1];
$code = substr($code, $begin, strrpos($code, '}')-$begin+1);
$lastCode = $code[strlen($code)-1];
assert('}' == $lastCode, 'Final character of function definition must be closing brace');
foreach ([
'hasMany',
'hasManyThrough',
'belongsToMany',
'hasOne',
'belongsTo',
'morphOne',
'morphTo',
'morphMany',
'morphToMany',
'morphedByMany'
] as $relation) {
'hasMany',
'hasManyThrough',
'belongsToMany',
'hasOne',
'belongsTo',
'morphOne',
'morphTo',
'morphMany',
'morphToMany',
'morphedByMany'
] as $relation) {
$search = '$this->' . $relation . '(';
if ($pos = stripos($code, $search)) {
//Resolve the relation's model to a Relation object.
Expand Down Expand Up @@ -485,10 +485,10 @@ private function getRelationshipsHasMany($rels, &$hooks)

$keyRaw = $isBelong ? $foo->$fkMethodName() : $foo->$fkMethodAlternate();
$keySegments = explode('.', $keyRaw);
$keyName = $keySegments[count($keySegments) - 1];
$keyName = $keySegments[count($keySegments)-1];
$localRaw = $isBelong ? $foo->$rkMethodName() : $foo->$rkMethodAlternate();
$localSegments = explode('.', $localRaw);
$localName = $localSegments[count($localSegments) - 1];
$localName = $localSegments[count($localSegments)-1];
$first = $keyName;
$last = $localName;
$this->addRelationsHook($hooks, $first, $property, $last, $mult, $targ);
Expand All @@ -514,10 +514,10 @@ private function getRelationshipsHasOne($rels, &$hooks)

$keyName = $isBelong ? $foo->$fkMethodName() : $foo->$fkMethodAlternate();
$keySegments = explode('.', $keyName);
$keyName = $keySegments[count($keySegments) - 1];
$keyName = $keySegments[count($keySegments)-1];
$localRaw = $isBelong ? $foo->$rkMethodName() : $foo->$rkMethodAlternate();
$localSegments = explode('.', $localRaw);
$localName = $localSegments[count($localSegments) - 1];
$localName = $localSegments[count($localSegments)-1];
$first = $isBelong ? $localName : $keyName;
$last = $isBelong ? $keyName : $localName;
$this->addRelationsHook($hooks, $first, $property, $last, $mult, $targ);
Expand All @@ -541,10 +541,10 @@ private function getRelationshipsKnownPolyMorph($rels, &$hooks)

$keyRaw = $isMany ? $foo->$fkMethodName() : $foo->$fkMethodAlternate();
$keySegments = explode('.', $keyRaw);
$keyName = $keySegments[count($keySegments) - 1];
$keyName = $keySegments[count($keySegments)-1];
$localRaw = $isMany ? $foo->$rkMethodName() : $foo->$rkMethodAlternate();
$localSegments = explode('.', $localRaw);
$localName = $localSegments[count($localSegments) - 1];
$localName = $localSegments[count($localSegments)-1];
$first = $isMany ? $keyName : $localName;
$last = $isMany ? $localName : $keyName;
$this->addRelationsHook($hooks, $first, $property, $last, $mult, $targ, 'unknown');
Expand All @@ -567,10 +567,10 @@ private function getRelationshipsUnknownPolyMorph($rels, &$hooks)

$keyRaw = $isMany ? $foo->$fkMethodName() : $foo->$fkMethodAlternate();
$keySegments = explode('.', $keyRaw);
$keyName = $keySegments[count($keySegments) - 1];
$keyName = $keySegments[count($keySegments)-1];
$localRaw = $isMany ? $foo->$rkMethodName() : $foo->$rkMethodAlternate();
$localSegments = explode('.', $localRaw);
$localName = $localSegments[count($localSegments) - 1];
$localName = $localSegments[count($localSegments)-1];

$first = $keyName;
$last = (isset($localName) && '' != $localName) ? $localName : $foo->getRelated()->getKeyName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function isOk()
public function getAssociationType()
{
return new AssociationType($this->first->getMultiplicity()->getValue()
| $this->last->getMultiplicity()->getValue());
| $this->last->getMultiplicity()->getValue());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function isCompatible(AssociationStubBase $otherStub)
$thisMono = $this instanceof AssociationStubMonomorphic;
$thatMono = $otherStub instanceof AssociationStubMonomorphic;

$count = ($thisPoly ? 1 : 0) + ($thatPoly ? 1 : 0) + ($thisMono ? 1 : 0) + ($thatMono ? 1 : 0);
$count = ($thisPoly ? 1 : 0)+($thatPoly ? 1 : 0)+($thisMono ? 1 : 0)+($thatMono ? 1 : 0);
assert(2 == $count);
if ($thisPoly && $thatMono) {
return false;
Expand Down
3 changes: 1 addition & 2 deletions src/Models/ObjectMap/Entities/EntityField.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ private function primitiveTypeToEdmType(EntityFieldPrimitiveType $primitiveType)
{
$value = $primitiveType->getValue();
return array_key_exists($value, self::$primitiveToEdmMapping) ?
self::$primitiveToEdmMapping[$value] :
EdmPrimitiveType::STRING;
self::$primitiveToEdmMapping[$value] : EdmPrimitiveType::STRING;
}
}
2 changes: 1 addition & 1 deletion src/Providers/MetadataControllerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function boot()
}
assert(
!$alreadyKey,
'Mapping already defined for model '.$key.' and CRUD verb '.$barrel
'Mapping already defined for model ' . $key . ' and CRUD verb ' . $barrel
);
$metamix[$key][$barrel] = $roll;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Providers/MetadataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class MetadataProvider extends MetadataBaseProvider
{
protected $multConstraints = [ '0..1' => ['1'], '1' => ['0..1', '*'], '*' => ['1', '*']];
protected $multConstraints = ['0..1' => ['1'], '1' => ['0..1', '*'], '*' => ['1', '*']];
protected static $metaNAMESPACE = 'Data';
protected static $relationCache;
protected static $isBooted = false;
Expand Down Expand Up @@ -120,7 +120,7 @@ private function implement(Map $objectModel)
}
$metaCount = count($meta->oDataEntityMap);
$entityCount = count($entities);
assert($metaCount == 2 * $entityCount + 1);
assert($metaCount == 2 * $entityCount+1);

if (null === $objectModel->getAssociations()) {
return;
Expand Down Expand Up @@ -427,7 +427,7 @@ public function getPolymorphicRelationGroups()
$knownKeys = array_keys($knownSide);
$unknownKeys = array_keys($unknownSide);
$dualKeys = array_intersect($knownKeys, $unknownKeys);
assert(count($hooks) == (count($unknownKeys) + count($knownKeys) - count($dualKeys)));
assert(count($hooks) == (count($unknownKeys)+count($knownKeys)-count($dualKeys)));
// if either list is empty, bail out - there's nothing to do
if (0 === count($knownSide) || 0 === count($unknownSide)) {
return [];
Expand Down
12 changes: 6 additions & 6 deletions src/Query/LaravelExpressionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct()
};
$this->functionDescriptionParsers[ODataConstants::STRFUN_ENDSWITH] = function ($params) {
return '(strcmp(substr('.$params[0].', strlen('.$params[0].') - strlen('.$params[1].')), '
.$params[1].') === 0)';
.$params[1].') === 0)';
};
$this->functionDescriptionParsers[ODataConstants::STRFUN_INDEXOF] = function ($params) {
return 'strpos('.$params[0].', '.$params[1].')';
Expand Down Expand Up @@ -155,7 +155,7 @@ public function getResourceType()
*/
public function setResourceType(ResourceType $resourceType)
{
$this->iteratorName = '$'.$resourceType->getName();
$this->iteratorName = '$' . $resourceType->getName();
$this->resourceType = $resourceType;
}
/**
Expand Down Expand Up @@ -280,11 +280,11 @@ public function onPropertyAccessExpression($expression)
$parent = $expression;
$variable = null;
do {
$variable = $parent->getResourceProperty()->getName().self::MEMBER_ACCESS.$variable;
$variable = $parent->getResourceProperty()->getName() . self::MEMBER_ACCESS . $variable;
$parent = $parent->getParent();
} while ($parent != null);
$variable = rtrim($variable, self::MEMBER_ACCESS);
$variable = $this->getIteratorName().self::MEMBER_ACCESS.$variable;
$variable = $this->getIteratorName() . self::MEMBER_ACCESS . $variable;
return $variable;
}
/**
Expand Down Expand Up @@ -316,7 +316,7 @@ public function onFunctionCallExpression($functionDescription, $params)
*/
private function prepareBinaryExpression($operator, $left, $right)
{
return self::OPEN_BRACKET.$left.' '.$operator.' '.$right.self::CLOSE_BRACKET;
return self::OPEN_BRACKET . $left . ' ' . $operator . ' ' . $right . self::CLOSE_BRACKET;
}
/**
* To format unary expression.
Expand All @@ -328,6 +328,6 @@ private function prepareBinaryExpression($operator, $left, $right)
*/
private function prepareUnaryExpression($operator, $child)
{
return $operator.self::OPEN_BRACKET.$child.self::CLOSE_BRACKET;
return $operator . self::OPEN_BRACKET . $child . self::CLOSE_BRACKET;
}
}
14 changes: 7 additions & 7 deletions src/Query/LaravelQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,12 @@ private function createUpdateDeleteCore($sourceEntityInstance, $data, $class, $v
$map = $raw->getMetadata();

if (!array_key_exists($class, $map)) {
throw new \POData\Common\InvalidOperationException('Controller mapping missing for class '.$class.'.');
throw new \POData\Common\InvalidOperationException('Controller mapping missing for class ' . $class . '.');
}
$goal = $raw->getMapping($class, $verb);
if (null == $goal) {
throw new \POData\Common\InvalidOperationException(
'Controller mapping missing for '.$verb.' verb on class '.$class.'.'
'Controller mapping missing for ' . $verb . ' verb on class ' . $class . '.'
);
}

Expand Down Expand Up @@ -433,7 +433,7 @@ private function createUpdateCoreWrapper(ResourceSet $sourceResourceSet, $data,
throw new ODataException($e->getMessage(), 500);
}
}
throw new ODataException('Target model not successfully '.$lastWord, 422);
throw new ODataException('Target model not successfully ' . $lastWord, 422);
}

/**
Expand Down Expand Up @@ -476,7 +476,7 @@ private function createUpdateDeleteProcessOutput($result)
}
$outData = $result->getData();
if (is_object($outData)) {
$outData = (array)$outData;
$outData = (array) $outData;
}

if (!is_array($outData)) {
Expand Down Expand Up @@ -669,7 +669,7 @@ public function unhookSingleModel(
$otherPropName = $this->getMetadataProvider()
->resolveReverseProperty($sourceEntityInstance, $targetEntityInstance, $navPropName);
if (null === $otherPropName) {
$msg = 'Bad navigation property, '.$navPropName.', on source model '.get_class($sourceEntityInstance);
$msg = 'Bad navigation property, ' . $navPropName . ', on source model ' . get_class($sourceEntityInstance);
throw new \InvalidArgumentException($msg);
}
$this->unhookSingleModel(
Expand Down Expand Up @@ -703,7 +703,7 @@ protected function isModelHookInputsOk($sourceEntityInstance, $targetEntityInsta
}
$targType = $relation->getRelated();
if (!$targetEntityInstance instanceof $targType) {
$msg = 'Target instance must be of type compatible with relation declared in method '.$navPropName;
$msg = 'Target instance must be of type compatible with relation declared in method ' . $navPropName;
throw new \InvalidArgumentException($msg);
}
return $relation;
Expand Down Expand Up @@ -743,7 +743,7 @@ protected function prepareBulkRequestInput($paramList, array $data, array $keyDe
$var = new $varType();
if ($spec['isRequest']) {
$var->setMethod($isCreate ? 'POST' : 'PUT');
$bulkData = [ 'data' => $data];
$bulkData = ['data' => $data];
if (null !== $keyDescriptors) {
$keys = [];
foreach ($keyDescriptors as $desc) {
Expand Down
Loading

0 comments on commit 35174f3

Please sign in to comment.