Skip to content

Commit

Permalink
Fix code style (mostly spaces and linebreaks)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsavina authored and homersimpsons committed Sep 15, 2022
1 parent fbb4ab1 commit 33028b1
Show file tree
Hide file tree
Showing 113 changed files with 228 additions and 172 deletions.
15 changes: 8 additions & 7 deletions src/AbstractTDBMObject.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM;
Expand Down Expand Up @@ -285,7 +286,7 @@ protected function setRef(string $foreignKeyName, ?AbstractTDBMObject $bean, str
*
* @return AbstractTDBMObject|null
*/
protected function getRef(string $foreignKeyName, string $tableName, string $className, string $resultIteratorClass) : ?AbstractTDBMObject
protected function getRef(string $foreignKeyName, string $tableName, string $className, string $resultIteratorClass): ?AbstractTDBMObject
{
$tableName = $this->checkTableName($tableName);

Expand Down Expand Up @@ -463,7 +464,7 @@ private function setRelationship(string $pivotTableName, AbstractTDBMObject $rem
*
* @return \SplObjectStorage
*/
private function getRelationshipStorage(string $pivotTableName) : \SplObjectStorage
private function getRelationshipStorage(string $pivotTableName): \SplObjectStorage
{
return $this->relationships[$pivotTableName] ?? $this->relationships[$pivotTableName] = new \SplObjectStorage();
}
Expand All @@ -476,7 +477,7 @@ private function getRelationshipStorage(string $pivotTableName) : \SplObjectStor
*
* @return AlterableResultIterator
*/
private function getManyToOneAlterableResultIterator(string $tableName, string $foreignKeyName) : AlterableResultIterator
private function getManyToOneAlterableResultIterator(string $tableName, string $foreignKeyName): AlterableResultIterator
{
$key = $tableName.'___'.$foreignKeyName;

Expand Down Expand Up @@ -519,7 +520,7 @@ private function removeManyToOneRelationship(string $tableName, string $foreignK
*
* @return AlterableResultIterator
*/
protected function retrieveManyToOneRelationshipsStorage(string $tableName, string $foreignKeyName, array $searchFilter, ?string $orderString, string $resultIteratorClass) : AlterableResultIterator
protected function retrieveManyToOneRelationshipsStorage(string $tableName, string $foreignKeyName, array $searchFilter, ?string $orderString, string $resultIteratorClass): AlterableResultIterator
{
assert(is_a($resultIteratorClass, ResultIterator::class, true), new TDBMInvalidArgumentException('$resultIteratorClass should be a `'. ResultIterator::class. '`. `' . $resultIteratorClass . '` provided.'));
$key = $tableName.'___'.$foreignKeyName;
Expand Down Expand Up @@ -566,7 +567,7 @@ public function discardChanges(): void
*
* @return string
*/
public function _getStatus() : string
public function _getStatus(): string
{
if ($this->status === null) {
throw new TDBMException(sprintf('Your bean for class %s has no status. It is likely that you overloaded the __construct method and forgot to call parent::__construct.', get_class($this)));
Expand Down Expand Up @@ -640,12 +641,12 @@ public function _getCachedRelationships(): array
*
* @return string[]
*/
abstract protected function getUsedTables() : array;
abstract protected function getUsedTables(): array;

/**
* Method called when the bean is removed from database.
*/
protected function onDelete() : void
protected function onDelete(): void
{
}

Expand Down
1 change: 1 addition & 0 deletions src/AlterableResultIterator.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM;
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/AlteredConfiguration.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);

declare(strict_types=1);

namespace TheCodingMachine\TDBM\Commands;

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/GenerateCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM\Commands;
Expand All @@ -14,7 +15,6 @@

class GenerateCommand extends Command
{

/**
* @var ConfigurationInterface
*/
Expand Down
3 changes: 1 addition & 2 deletions src/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);

declare(strict_types=1);

namespace TheCodingMachine\TDBM;

Expand All @@ -26,7 +26,6 @@

class Configuration implements ConfigurationInterface
{

/**
* @var string
*/
Expand Down
1 change: 1 addition & 0 deletions src/ConfigurationInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM;
Expand Down
5 changes: 3 additions & 2 deletions src/DbRow.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM;
Expand Down Expand Up @@ -165,7 +166,7 @@ public function _attach(TDBMService $tdbmService): void
*
* @param string $state
*/
public function _setStatus(string $state) : void
public function _setStatus(string $state): void
{
$this->status = $state;
if ($state === TDBMObjectStateEnum::STATE_LOADED) {
Expand Down Expand Up @@ -269,7 +270,7 @@ public function setRef(string $foreignKeyName, AbstractTDBMObject $bean = null):
*
* @return AbstractTDBMObject|null
*/
public function getRef(string $foreignKeyName, string $className, string $resultIteratorClass) : ?AbstractTDBMObject
public function getRef(string $foreignKeyName, string $className, string $resultIteratorClass): ?AbstractTDBMObject
{
if (array_key_exists($foreignKeyName, $this->references)) {
return $this->references[$foreignKeyName];
Expand Down
1 change: 1 addition & 0 deletions src/DuplicateRowException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM;
Expand Down
2 changes: 0 additions & 2 deletions src/EmptyInnerResultIterator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace TheCodingMachine\TDBM;

use Iterator;
Expand All @@ -10,7 +9,6 @@
*/
class EmptyInnerResultIterator implements Iterator, InnerResultIteratorInterface
{

/**
* Return the current element
* @link https://php.net/manual/en/iterator.current.php
Expand Down
1 change: 1 addition & 0 deletions src/InnerResultArray.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM;
Expand Down
3 changes: 1 addition & 2 deletions src/InnerResultIterator.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM;
Expand Down Expand Up @@ -183,7 +184,6 @@ public function next(): void
{
$row = $this->statement->fetch(\PDO::FETCH_ASSOC);
if ($row) {

/** @var array<string, array<string, array<string, mixed>>> $beansData array<tablegroup, array<table, array<column, value>>>*/
$beansData = [];
$allNull = true;
Expand Down Expand Up @@ -216,7 +216,6 @@ public function next(): void
$firstBean = true;
/** @var array<string, array<string, mixed>> $beanData */
foreach ($beansData as $beanData) {

// Let's find the bean class name associated to the bean.

list($actualClassName, $mainBeanTableName, $tablesUsed) = $this->tdbmService->_getClassNameFromBeanData($beanData);
Expand Down
1 change: 0 additions & 1 deletion src/InnerResultIteratorInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace TheCodingMachine\TDBM;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/NativeWeakrefObjectStorage.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

/*
Expand Down Expand Up @@ -74,7 +75,7 @@ public function set(string $tableName, $id, DbRow $dbRow): void
*
* @return DbRow|null
*/
public function get(string $tableName, $id) : ?DbRow
public function get(string $tableName, $id): ?DbRow
{
if (isset($this->objects[$tableName][$id])) {
return $this->objects[$tableName][$id]->get();
Expand Down
6 changes: 3 additions & 3 deletions src/NoBeanFoundException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM;
Expand All @@ -10,7 +11,6 @@
*/
class NoBeanFoundException extends TDBMException
{

/**
* @var string
*/
Expand All @@ -33,7 +33,7 @@ class NoBeanFoundException extends TDBMException
* @param Exception $previous
* @return NoBeanFoundException
*/
public static function missPrimaryKeyRecord(string $tableName, array $primaryKeys, string $className, Exception $previous) : self
public static function missPrimaryKeyRecord(string $tableName, array $primaryKeys, string $className, Exception $previous): self
{
$primaryKeysStringified = implode(' and ', array_map(function ($key, $value) {
return "'".$key."' = ".$value;
Expand All @@ -46,7 +46,7 @@ public static function missPrimaryKeyRecord(string $tableName, array $primaryKey
return $exception;
}

public static function missFilterRecord(string $tableName) : self
public static function missFilterRecord(string $tableName): self
{
return new self("No result found for query on table '".$tableName."'");
}
Expand Down
1 change: 1 addition & 0 deletions src/ObjectStorageInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM;
Expand Down
7 changes: 4 additions & 3 deletions src/OrderByAnalyzer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM;
Expand Down Expand Up @@ -58,7 +59,7 @@ public function __construct(Cache $cache, ?string $cachePrefix = null)
*
* @return array[]
*/
public function analyzeOrderBy(string $orderBy) : array
public function analyzeOrderBy(string $orderBy): array
{
$key = $this->cachePrefix.'_order_by_analysis_'.$orderBy;
$results = $this->cache->fetch($key);
Expand All @@ -75,7 +76,7 @@ public function analyzeOrderBy(string $orderBy) : array
* @param string $orderBy
* @return array[]
*/
private function analyzeOrderByNoCache(string $orderBy) : array
private function analyzeOrderByNoCache(string $orderBy): array
{
$sqlParser = new PHPSQLParser();
$sql = 'SELECT 1 FROM a ORDER BY '.$orderBy;
Expand Down Expand Up @@ -129,7 +130,7 @@ private function analyzeOrderByNoCache(string $orderBy) : array
*
* @return string
*/
private function trimDirection(string $sql) : string
private function trimDirection(string $sql): string
{
preg_match('/^(.*)(\s+(DESC|ASC|))*$/Ui', $sql, $matches);

Expand Down
1 change: 1 addition & 0 deletions src/PageIterator.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM;
Expand Down
16 changes: 9 additions & 7 deletions src/QueryFactory/AbstractQueryFactory.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM\QueryFactory;

use function array_unique;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\Schema;
use function in_array;
use TheCodingMachine\TDBM\OrderByAnalyzer;
use TheCodingMachine\TDBM\TDBMInvalidArgumentException;
use TheCodingMachine\TDBM\TDBMService;
use TheCodingMachine\TDBM\UncheckedOrderBy;

use function array_unique;
use function in_array;

abstract class AbstractQueryFactory implements QueryFactory
{
/**
Expand Down Expand Up @@ -226,7 +228,7 @@ protected function getTableGroupName(array $relatedTables): string
return implode('_``_', $relatedTables);
}

public function getMagicSql() : string
public function getMagicSql(): string
{
if ($this->magicSql === null) {
$this->compute();
Expand All @@ -235,7 +237,7 @@ public function getMagicSql() : string
return $this->magicSql;
}

public function getMagicSqlCount() : string
public function getMagicSqlCount(): string
{
if ($this->magicSqlCount === null) {
$this->compute();
Expand All @@ -244,7 +246,7 @@ public function getMagicSqlCount() : string
return $this->magicSqlCount;
}

public function getMagicSqlSubQuery() : string
public function getMagicSqlSubQuery(): string
{
if ($this->magicSqlSubQuery === null) {
$this->compute();
Expand All @@ -253,7 +255,7 @@ public function getMagicSqlSubQuery() : string
return $this->magicSqlSubQuery;
}

public function getColumnDescriptors() : array
public function getColumnDescriptors(): array
{
if ($this->columnDescList === null) {
$this->compute();
Expand All @@ -265,7 +267,7 @@ public function getColumnDescriptors() : array
/**
* @return array<int, array{table: string, column: string}> An array of column descriptors.
*/
public function getSubQueryColumnDescriptors() : array
public function getSubQueryColumnDescriptors(): array
{
if ($this->subQueryColumnDescList === null) {
$columns = $this->tdbmService->getPrimaryKeyColumns($this->mainTable);
Expand Down
2 changes: 2 additions & 0 deletions src/QueryFactory/FindObjectsFromRawSqlQueryFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace TheCodingMachine\TDBM\QueryFactory;
Expand All @@ -9,6 +10,7 @@
use TheCodingMachine\TDBM\TDBMService;
use PHPSQLParser\PHPSQLCreator;
use PHPSQLParser\PHPSQLParser;

use function array_merge;

/**
Expand Down
Loading

0 comments on commit 33028b1

Please sign in to comment.