Skip to content

Commit

Permalink
Merge pull request #68 from localheinz/feature/no-whitespace-in-blank…
Browse files Browse the repository at this point in the history
…-line

Enhancement: Enable no_whitespace_in_blank_line fixer
  • Loading branch information
glaubinix authored Mar 3, 2020
2 parents 7262b5f + 86ebcc6 commit c83232f
Show file tree
Hide file tree
Showing 24 changed files with 163 additions and 162 deletions.
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ return PhpCsFixer\Config::create()
'array_syntax' => [
'syntax' => 'short',
],
'no_whitespace_in_blank_line' => true,
'php_unit_set_up_tear_down_visibility' => true,
])
->setFinder($finder);
18 changes: 9 additions & 9 deletions src/Provider/Doctrine/DBAL/Types/StatusArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
class StatusArrayType extends Type
{
const STATUSARRAY = 'statusarray';

/**
* @var string Validation regex
*/
protected $acceptedPattern = '#^[a-zA-Z0-9:_\.]+$#';

public function getSQLDeclaration(array $fieldDeclaration, \Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{
return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
Expand All @@ -29,7 +29,7 @@ public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\Abstract
if ($value === null) {
return null;
}

if (!is_array($value)) {
throw new ConversionException('Value must be an array');
}
Expand All @@ -39,11 +39,11 @@ public function convertToDatabaseValue($value, \Doctrine\DBAL\Platforms\Abstract
throw new ConversionException("'{$val}' does not match pattern '{$this->acceptedPattern}'");
}
}

array_walk($value, function (&$walker) {
$walker = '[' . $walker . ']';
});

return implode(';', $value);
}

Expand All @@ -53,14 +53,14 @@ public function convertToPHPValue($value, \Doctrine\DBAL\Platforms\AbstractPlatf
return null;
}


$ret = explode(';', $value);

array_walk($ret, function (&$unwashed) {
$unwashed = trim($unwashed, '[]');
});


return $ret;
}

Expand Down
10 changes: 5 additions & 5 deletions src/Provider/Doctrine/DateIntervalHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function years($years)
$this->assertIntegerish($years);

$this->modify(new \DateInterval('P'.$years.'Y'));

return $this;
}

Expand All @@ -52,7 +52,7 @@ public function months($months)
$this->assertIntegerish($months);

$this->modify(new \DateInterval('P'.$months.'M'));

return $this;
}

Expand All @@ -66,14 +66,14 @@ public function days($days)
$this->assertIntegerish($days);

$this->modify(new \DateInterval('P'.$days.'D'));

return $this;
}

private function modify(\DateInterval $interval)
{
$interval->invert = (int) $this->negative;

$this->time->add($interval);
}

Expand Down
30 changes: 15 additions & 15 deletions src/Provider/Doctrine/EntityDef.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@
class EntityDef
{
private $name;

private $entityType;

/**
* @var ClassMetadata
*/
private $metadata;

private $fieldDefs;

private $config;

public function __construct(EntityManager $em, $name, $type, array $fieldDefs, array $config)
{
$this->name = $name;
$this->entityType = $type;
$this->metadata = $em->getClassMetadata($type);
$this->fieldDefs = [];
$this->config = $config;

$this->readFieldDefs($fieldDefs);
$this->defaultDefsFromMetadata();
}

private function readFieldDefs(array $params)
{
foreach ($params as $key => $def) {
Expand All @@ -46,7 +46,7 @@ private function readFieldDefs(array $params)
}
}
}

private function defaultDefsFromMetadata()
{
$defaultEntity = $this->getEntityMetadata()->newInstance();
Expand All @@ -68,7 +68,7 @@ private function defaultDefsFromMetadata()
}
}
}

/**
* Returns the name of the entity definition.
* @return string
Expand All @@ -77,7 +77,7 @@ public function getName()
{
return $this->name;
}

/**
* Returns the fully qualified name of the entity class.
* @return string
Expand All @@ -86,15 +86,15 @@ public function getEntityType()
{
return $this->entityType;
}

/**
* Returns the fielde definition callbacks.
*/
public function getFieldDefs()
{
return $this->fieldDefs;
}

/**
* Returns the Doctrine metadata for the entity to be created.
* @return ClassMetadata
Expand All @@ -103,7 +103,7 @@ public function getEntityMetadata()
{
return $this->metadata;
}

/**
* Returns the extra configuration array of the entity definition.
* @return array
Expand All @@ -112,7 +112,7 @@ public function getConfig()
{
return $this->config;
}

private function normalizeFieldDef($def)
{
if (is_callable($def)) {
Expand All @@ -123,7 +123,7 @@ private function normalizeFieldDef($def)
return $def;
};
}

private function ensureInvokable($f)
{
if (method_exists($f, '__invoke')) {
Expand Down
4 changes: 2 additions & 2 deletions src/Provider/Doctrine/FieldDef.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function sequence($funcOrString, $firstNum = 1)
return str_replace('%d', $n, $funcOrString);
};
}

return function () use (&$n, $funcOrString) {
$n++;
return $funcOrString . $n;
Expand All @@ -61,7 +61,7 @@ public static function future()
{
return new DateIntervalHelper(new \DateTime(), false);
}

/**
* Defines a field to `get()` a named entity from the factory.
*
Expand Down
22 changes: 11 additions & 11 deletions src/Provider/Doctrine/ORM/Locking/TableLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ class TableLock
* @var Repository
*/
private $repository;

/**
* @param Repository $repository
*/
public function __construct($repository)
{
$this->repository = $repository;
}

/**
* @return Repository
*/
protected function getRepository()
{
return $this->repository;
}

/**
* Attempt to acquire a table level lock in MySQL for the duration of the
* given transaction. IS NOT IN ANY WAY GUARANTEED TO WORK. MySQL requires
Expand All @@ -50,7 +50,7 @@ public function transaction($lockMode, $transaction)
{
$lock = $this->getLockString($lockMode);
$unlock = $this->getUnlockString();

return $this->getRepository()->transaction(function (EntityManager $em, Repository $repository) use ($lock, $unlock, $transaction) {
$conn = $em->getConnection();
$conn->executeQuery($lock);
Expand All @@ -65,7 +65,7 @@ public function transaction($lockMode, $transaction)
}
});
}

/**
* Get the MySQL statement for locking the table underlying this repository
* for simple read and/or write operations given an appropriate lock mode
Expand All @@ -80,13 +80,13 @@ private function getLockString($lockMode)
if (!$lockModeString) {
throw new LockException("Invalid lock mode: $lockMode");
}

$tableName = $this->getTableName();
$aliases = $this->getTableAliasGuesstimates($tableName);

return $this->constructLockString($tableName, $aliases, $lockModeString);
}

/**
* @return string
*/
Expand All @@ -95,7 +95,7 @@ private function getTableName()
// Blatant violation of law of demeter
return $this->getRepository()->getClassMetadata()->getTableName();
}

/**
* @param string $tableName
* @param array $aliases
Expand All @@ -110,7 +110,7 @@ private function constructLockString($tableName, array $aliases, $lockModeString
}
return $lock;
}

/**
* Attempt to guess at the table name aliases used by Doctrine for a given
* table name
Expand All @@ -127,7 +127,7 @@ private function getTableAliasGuesstimates($tableName)
't0'
]);
}

/**
* The MySQL statement required to unlock tables after a transaction
*
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Doctrine/ORM/Locking/TableLockMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TableLockMode
{
const READ = 8;
const WRITE = 16;

/**
* @param int $mode
* @return null|string
Expand Down
16 changes: 8 additions & 8 deletions src/Provider/Doctrine/ORM/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class QueryBuilder extends DoctrineQueryBuilder
* @var array<string => boolean>
*/
protected $_statuses = [];

/**
* @var array<callback(Query)>
*/
protected $_queryConfigurers = [];

/**
* Entity name associated with this query builder (if any)
*
Expand All @@ -44,7 +44,7 @@ public static function create(EntityManager $em)
{
return new static($em);
}

/**
* @param EntityManager $em
* @param string $entityName
Expand All @@ -58,7 +58,7 @@ public function __construct(EntityManager $em, $entityName = null, $entityAlias
$this->entityAlias = $entityAlias;
$this->init();
}

/**
* Post-construction template method
*
Expand All @@ -71,7 +71,7 @@ public function init()
->from($this->entityName, $this->entityAlias);
}
}

/**
* Configures the created Query using the configurers added to this builder
*
Expand All @@ -85,7 +85,7 @@ public function getQuery()
}
return $query;
}

/**
* NOTE: Should be protected
*
Expand All @@ -97,7 +97,7 @@ public function _configureQuery($configurer)
$this->_queryConfigurers[] = $configurer;
return $this;
}

/**
* Ensure that a certain operation has been performed on this object.
* $status is a string that describes state the operation should affect and
Expand Down Expand Up @@ -130,7 +130,7 @@ protected function ensure($status, $operation)
}
return $this;
}

/**
* Configures the query to force result objects to be partially loaded
*
Expand Down
Loading

0 comments on commit c83232f

Please sign in to comment.