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 authored and scaytrase committed May 12, 2017
1 parent b9799d4 commit bbe0a2e
Show file tree
Hide file tree
Showing 23 changed files with 104 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Cache/KeyStrategyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ public function getEntityPrefix(ApiMetadata $metadata);
*
* @return string
*/
public function getEntityKey(ApiMetadata $metadata,array $identifier);
public function getEntityKey(ApiMetadata $metadata, array $identifier);
}
4 changes: 2 additions & 2 deletions Dehydration/SearchDehydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private function doTransform(array $criteria)
/** @var EntityMetadata $target */
$target = $this->manager->getClassMetadata($mapping['targetEntity']);

$converter = function ($value) use ($target) {
$converter = function($value) use ($target) {
if (!is_object($value)) {
return $value;
}
Expand All @@ -135,7 +135,7 @@ private function doTransform(array $criteria)
$values = $converter($values);
}
} else {
$caster = function ($value) use ($field) {
$caster = function($value) use ($field) {
$type = $this->manager
->getConfiguration()
->getTypeRegistry()->get($this->metadata->getTypeOfField($field));
Expand Down
2 changes: 1 addition & 1 deletion EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function persist($object)
public function remove($object)
{
$this->getUnitOfWork()->getEntityPersister(get_class($object))
->delete($object);
->delete($object);
}

/** {@inheritdoc} */
Expand Down
43 changes: 43 additions & 0 deletions Exception/MappingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@

class MappingException extends BaseMappingException implements DoctrineApiException
{
/**
* @param string $alias
*/
public static function unknownAlias($alias)
{
return new self(sprintf('Unknown namespace alias "%s"', $alias));
}

/**
* @param string $class
*/
public static function noSuchProperty($property, $class)
{
return new self(
Expand All @@ -20,6 +26,9 @@ public static function noSuchProperty($property, $class)
);
}

/**
* @param string $class
*/
public static function noClientSpecified($class)
{
return new self(sprintf('Client not specified for %s or any parent', $class));
Expand All @@ -30,6 +39,9 @@ public static function invalidClientSpecified($name, $message)
return new self(sprintf('Could not resolve client "%s": %s', $name, $message));
}

/**
* @param string $class
*/
public static function noApiSpecified($class)
{
return new self(sprintf('API factory not specified for %s or any parent', $class));
Expand All @@ -40,11 +52,18 @@ public static function invalidApiSpecified($name, $message)
return new self(sprintf('Could not resolve API factory "%s": %s', $name, $message));
}

/**
* @param string $class
*/
public static function unknownField($field, $class)
{
return new self(sprintf('No mapping for field "%s" in %s', $field, $class));
}

/**
* @param string $field
* @param string $class
*/
public static function unknownAssociation($field, $class)
{
return new self(sprintf('No mapping for association "%s" in %s', $field, $class));
Expand All @@ -65,38 +84,62 @@ public static function unknownApiFactory($alias)
return new static(sprintf('Unknown factory to create API: %s', $alias));
}

/**
* @param string $alias
*/
public static function nameIsMandatoryForDiscriminatorColumns($alias)
{
return new static(sprintf('Name is mandatory for discriminator column: %s', $alias));
}

/**
* @param string $alias
*/
public static function duplicateColumnName($alias, $column)
{
return new static(sprintf('Duplicate column name "%s": %s', $column, $alias));
}

/**
* @param string $alias
* @param string $type
*/
public static function invalidDiscriminatorColumnType($alias, $type)
{
return new static(sprintf('Invalud discriminator column type "%s": %s', $type, $alias));
}

/**
* @param string $name
* @param string $rootEntityName
*/
public static function mappedClassNotPartOfDiscriminatorMap($name, $rootEntityName)
{
return new static(sprintf('Mapped class "%s" is not a part of discriminator map: %s', $name, $rootEntityName));
}

/**
* @param string $alias
*/
public static function unknownDiscriminatorValue($value, $alias)
{
return new static(sprintf('Unknown discriminator value "%s": %s', $value, $alias));
}

/**
* @param string $name
*/
public static function duplicateDiscriminatorEntry($name, array $duplicates, array $map)
{
return new static(
sprintf('Discriminator map contains duplicate values "%s": %s', implode('", "', $duplicates), $name)
);
}

/**
* @param string $className
* @param string $name
*/
public static function invalidClassInDiscriminatorMap($className, $name)
{
return new static(
Expand Down
5 changes: 2 additions & 3 deletions Mapping/Driver/YmlMetadataDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
if (array_key_exists('entityPath', $element['client'])) {
$pathSeparator =
array_key_exists('entityPathSeparator', $element['client']) ?
$element['client']['entityPathSeparator'] :
EntityMethodProvider::DEFAULT_PATH_SEPARATOR;
$element['client']['entityPathSeparator'] : EntityMethodProvider::DEFAULT_PATH_SEPARATOR;
$methodProvider =
new EntityMethodProvider($element['client']['entityPath'], $pathSeparator, $methodProvider);
}
Expand Down Expand Up @@ -143,7 +142,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata)
*/
protected function mapAssociation(EntityMetadata $metadata, $type, $name, $association, $associationIds)
{
$mapping = $this->fieldToArray($name, $association);
$mapping = $this->fieldToArray($name, $association);
$mapping['targetEntity'] = $association['targetEntity'];
$mapping['sourceEntity'] = $metadata->getName();
if (isset($association['fetch'])) {
Expand Down
2 changes: 1 addition & 1 deletion Mapping/EntityMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ private function validateAndCompleteFieldMapping(array &$mapping)
$mapping['options'] = [];
}

$this->apiFieldNames[$mapping['field']] = $mapping['apiField'];
$this->apiFieldNames[$mapping['field']] = $mapping['apiField'];
$this->fieldNames[$mapping['apiField']] = $mapping['field'];

// if (isset($this->fieldNames[$mapping['columnName']]) || ($this->discriminatorField && $this->discriminatorField['name'] === $mapping['apiField'])) {
Expand Down
9 changes: 6 additions & 3 deletions Proxy/ApiCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ public function getSnapshot()
return $this->snapshot;
}

/**
* @param boolean $state
*/
public function setInitialized($state)
{
$this->initialized = (bool)$state;
Expand All @@ -204,7 +207,7 @@ public function getDeleteDiff()
return array_udiff_assoc(
$this->snapshot,
$this->collection->toArray(),
function ($a, $b) {
function($a, $b) {
return $a === $b ? 0 : 1;
}
);
Expand All @@ -221,7 +224,7 @@ public function getInsertDiff()
return array_udiff_assoc(
$this->collection->toArray(),
$this->snapshot,
function ($a, $b) {
function($a, $b) {
return $a === $b ? 0 : 1;
}
);
Expand Down Expand Up @@ -452,7 +455,7 @@ public function clear()
* Internal note: Tried to implement Serializable first but that did not work well
* with circular references. This solution seems simpler and works well.
*
* @return array
* @return string[]
*/
public function __sleep()
{
Expand Down
4 changes: 2 additions & 2 deletions Proxy/ProxyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private function createInitializer(ApiMetadata $classMetadata, ApiPersister $per
{
$wakeupProxy = $classMetadata->getReflectionClass()->hasMethod('__wakeup');

return function (Proxy $proxy) use ($classMetadata, $wakeupProxy, $persister) {
return function(Proxy $proxy) use ($classMetadata, $wakeupProxy, $persister) {
$initializer = $proxy->__getInitializer();
$cloner = $proxy->__getCloner();

Expand Down Expand Up @@ -128,7 +128,7 @@ private function createInitializer(ApiMetadata $classMetadata, ApiPersister $per
*/
private function createCloner(ApiMetadata $classMetadata, ApiPersister $persister)
{
return function (Proxy $proxy) use ($classMetadata, $persister) {
return function(Proxy $proxy) use ($classMetadata, $persister) {
if ($proxy->__isInitialized()) {
return;
}
Expand Down
8 changes: 3 additions & 5 deletions Tests/AbstractEntityManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
use Bankiru\Api\Doctrine\EntityManager;
use Bankiru\Api\Doctrine\EntityMetadataFactory;
use Bankiru\Api\Doctrine\Mapping\Driver\YmlMetadataDriver;
use Bankiru\Api\Doctrine\Test\TestApiFactory;
use Bankiru\Api\Doctrine\Type\BaseTypeRegistry;
use Bankiru\Api\Doctrine\Type\TypeRegistry;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
use Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator;
use PHPUnit\Framework\TestCase;
use ScayTrase\Api\Rpc\Test\RpcMockClient;
use ScayTrase\Api\Rpc\Tests\AbstractRpcTest;
use ScayTrase\Api\Rpc\Tests\RpcRequestTrait;

abstract class AbstractEntityManagerTest extends TestCase
Expand All @@ -38,7 +36,7 @@ abstract class AbstractEntityManagerTest extends TestCase
private $factoryRegistry;

/**
* @return mixed
* @return ClientRegistryInterface
*/
public function getClientRegistry()
{
Expand Down Expand Up @@ -120,14 +118,14 @@ protected function createConfiguration()
$configuration->setClientRegistry($this->clientRegistry);
$configuration->setTypeRegistry(new BaseTypeRegistry(new TypeRegistry()));
$configuration->setFactoryRegistry($this->factoryRegistry);
$configuration->setProxyDir(CACHE_DIR.'/doctrine/proxy/');
$configuration->setProxyDir(CACHE_DIR . '/doctrine/proxy/');
$configuration->setProxyNamespace('Bankiru\Api\Doctrine\Test\Proxy');
$driver = new MappingDriverChain();
$driver->addDriver(
new YmlMetadataDriver(
new SymfonyFileLocator(
[
__DIR__.'/../Test/Resources/config/api/' => 'Bankiru\Api\Doctrine\Test\Entity',
__DIR__ . '/../Test/Resources/config/api/' => 'Bankiru\Api\Doctrine\Test\Entity',
],
'.api.yml',
DIRECTORY_SEPARATOR
Expand Down
2 changes: 1 addition & 1 deletion Tests/CollectionLoadingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testFindBy()
],
]
),
function (RpcRequestInterface $request) {
function(RpcRequestInterface $request) {
self::assertEquals('test-entity/search', $request->getMethod());
self::assertEquals(
[
Expand Down
12 changes: 6 additions & 6 deletions Tests/CommitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testSimpleCommit()

$this->getClient('test-reference-client')->push(
$this->getResponseMock(true, 241),
function (RpcRequestInterface $request) {
function(RpcRequestInterface $request) {
self::assertEquals('test-reference/create', $request->getMethod());
self::assertEquals(
[
Expand All @@ -41,7 +41,7 @@ public function testExtendedIdIsSameAsSimpleCommit()

$this->getClient('test-reference-client')->push(
$this->getResponseMock(true, ['id' => 241]),
function (RpcRequestInterface $request) {
function(RpcRequestInterface $request) {
self::assertEquals('test-reference/create', $request->getMethod());
self::assertEquals(
[
Expand Down Expand Up @@ -70,7 +70,7 @@ public function testChainCommitWithRelation()

$this->getClient()->push(
$this->getResponseMock(true, (object)['id' => 42]),
function (RpcRequestInterface $request) {
function(RpcRequestInterface $request) {
self::assertEquals('test-entity/create', $request->getMethod());
self::assertEquals(
[
Expand All @@ -86,7 +86,7 @@ function (RpcRequestInterface $request) {

$this->getClient('test-reference-client')->push(
$this->getResponseMock(true, (object)['id' => 241]),
function (RpcRequestInterface $request) {
function(RpcRequestInterface $request) {
self::assertEquals('test-reference/create', $request->getMethod());
self::assertEquals(
[
Expand Down Expand Up @@ -123,7 +123,7 @@ public function testChainUpdateWithRelation()
$newParent = new TestEntity();
$this->getClient()->push(
$this->getResponseMock(true, (object)['id' => 17]),
function (RpcRequestInterface $request) {
function(RpcRequestInterface $request) {
self::assertEquals('test-entity/create', $request->getMethod());
self::assertEquals(
[
Expand All @@ -138,7 +138,7 @@ function (RpcRequestInterface $request) {
);
$this->getClient('test-reference-client')->push(
$this->getResponseMock(true, null),
function (RpcRequestInterface $request) {
function(RpcRequestInterface $request) {
self::assertEquals('test-reference/patch', $request->getMethod());
self::assertEquals(
[
Expand Down
2 changes: 1 addition & 1 deletion Tests/CountingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function testEntityCounting()
{
$this->getClient()->push(
$this->getResponseMock(true, 5),
function (RpcRequestInterface $request) {
function(RpcRequestInterface $request) {
self::assertEquals('prefixed-entity/count', $request->getMethod());
self::assertEquals(
[
Expand Down
2 changes: 1 addition & 1 deletion Tests/CustomRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testCustomRepository()
$repository = $this->getManager()->getRepository(CustomEntity::class);
$this->getClient()->push(
$this->getResponseMock(true, (object)['customField' => 'custom-response']),
function (RpcRequestInterface $request) {
function(RpcRequestInterface $request) {
self::assertEquals('custom-entity/custom', $request->getMethod());
self::assertEquals(
['param1' => 'value1'],
Expand Down
8 changes: 4 additions & 4 deletions Tests/DiscriminatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testDiscriminatorMapResolution()
],
]
),
function (RpcRequestInterface $request) {
function(RpcRequestInterface $request) {
self::assertEquals('discriminator/search', $request->getMethod());
self::assertEquals(
[
Expand Down Expand Up @@ -134,7 +134,7 @@ public function testSearchingDiscriminatedEntitiesAddsTypeFilter()
],
]
),
function (RpcRequestInterface $request) {
function(RpcRequestInterface $request) {
self::assertEquals('discriminator/search', $request->getMethod());
self::assertEquals(
[
Expand Down Expand Up @@ -177,7 +177,7 @@ public function testDiscriminatorEntitiesCommit()
{
$this->getClient()->push(
$this->getResponseMock(true, ['id_field' => 241]),
function (RpcRequestInterface $request) {
function(RpcRequestInterface $request) {
self::assertEquals('discriminator/create', $request->getMethod());
self::assertEquals(
[
Expand All @@ -199,7 +199,7 @@ function (RpcRequestInterface $request) {

$this->getClient()->push(
$this->getResponseMock(true, ['id_field' => 241]),
function (RpcRequestInterface $request) {
function(RpcRequestInterface $request) {
self::assertEquals('discriminator/patch', $request->getMethod());
self::assertEquals(
[
Expand Down
Loading

0 comments on commit bbe0a2e

Please sign in to comment.