Stricter php-cs-fixer rules. These remove a lot of superfluous duplicitous rubbish, mostly in docblocks.
This commit is contained in:
parent
4e4c359682
commit
524ee6e6ee
11 changed files with 54 additions and 181 deletions
42
.php_cs
42
.php_cs
|
|
@ -1,3 +1,41 @@
|
|||
<?php
|
||||
define("__PHPCS_ROOT__", __DIR__);
|
||||
return require(__PHPCS_ROOT__ . "/vendor/benzine/benzine-style/php_cs.php");
|
||||
$finder = PhpCsFixer\Finder::create();
|
||||
|
||||
if (!defined('__PHPCS_ROOT__')) {
|
||||
define('__PHPCS_ROOT__', __DIR__);
|
||||
}
|
||||
|
||||
$directories = [
|
||||
__PHPCS_ROOT__.'/src',
|
||||
__PHPCS_ROOT__.'/bin',
|
||||
__PHPCS_ROOT__.'/tests',
|
||||
];
|
||||
|
||||
if (isset($additionalDirectories)) {
|
||||
$directories = array_merge($directories, $additionalDirectories);
|
||||
}
|
||||
|
||||
foreach ($directories as $directory) {
|
||||
if (file_exists($directory) && is_dir($directory)) {
|
||||
$finder->in($directory);
|
||||
}
|
||||
}
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRiskyAllowed(true)
|
||||
->setHideProgress(false)
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'strict_param' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'@PhpCsFixer' => true,
|
||||
'@PHP73Migration' => true,
|
||||
'no_php4_constructor' => true,
|
||||
'no_unused_imports' => true,
|
||||
'no_useless_else' => true,
|
||||
'no_superfluous_phpdoc_tags' => true,
|
||||
'void_return' => true,
|
||||
'yoda_style' => false,
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ abstract class Model implements ModelInterface, \Serializable
|
|||
{
|
||||
}
|
||||
|
||||
public function __wakeup()
|
||||
public function __wakeup(): void
|
||||
{
|
||||
$this->__setUp();
|
||||
}
|
||||
|
|
@ -98,17 +98,17 @@ abstract class Model implements ModelInterface, \Serializable
|
|||
$this->__fromPublicArray($data);
|
||||
}
|
||||
|
||||
public function __pre_save()
|
||||
public function __pre_save(): void
|
||||
{
|
||||
// Stub function to be overridden.
|
||||
}
|
||||
|
||||
public function __post_save()
|
||||
public function __post_save(): void
|
||||
{
|
||||
// Stub function to be overridden.
|
||||
}
|
||||
|
||||
public function __set($name, $value)
|
||||
public function __set($name, $value): void
|
||||
{
|
||||
$this->{$name} = $value;
|
||||
}
|
||||
|
|
@ -235,7 +235,7 @@ abstract class Model implements ModelInterface, \Serializable
|
|||
return json_encode($this->__toRawArray(), JSON_PRETTY_PRINT);
|
||||
}
|
||||
|
||||
public function unserialize($serialized)
|
||||
public function unserialize($serialized): void
|
||||
{
|
||||
$unserialized = json_decode($serialized);
|
||||
foreach ($unserialized as $k => $v) {
|
||||
|
|
|
|||
|
|
@ -90,8 +90,6 @@ abstract class Service
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Sql\Where $where
|
||||
*
|
||||
* @return Benzine\ORM\Abstracts\Model[]
|
||||
*/
|
||||
public function search(Sql\Where $where): array
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ abstract class TableGateway extends \Laminas\Db\TableGateway\TableGateway
|
|||
parent::__construct($table, $adapter, $features, $resultSetPrototype, $sql);
|
||||
}
|
||||
|
||||
public function __set($property, $value)
|
||||
public function __set($property, $value): void
|
||||
{
|
||||
if (property_exists($this, $property)) {
|
||||
$this->{$property} = $value;
|
||||
|
|
@ -221,7 +221,7 @@ abstract class TableGateway extends \Laminas\Db\TableGateway\TableGateway
|
|||
if ($conditional instanceof \Closure) {
|
||||
$select->where($conditional);
|
||||
} else {
|
||||
$spec = function (Where $where) use ($conditional) {
|
||||
$spec = function (Where $where) use ($conditional): void {
|
||||
switch ($conditional['condition']) {
|
||||
case FilterCondition::CONDITION_EQUAL:
|
||||
$where->equalTo($conditional['column'], $conditional['value']);
|
||||
|
|
@ -326,7 +326,7 @@ abstract class TableGateway extends \Laminas\Db\TableGateway\TableGateway
|
|||
if ($conditional instanceof \Closure) {
|
||||
$select->where($conditional);
|
||||
} else {
|
||||
$spec = function (Where $where) use ($conditional) {
|
||||
$spec = function (Where $where) use ($conditional): void {
|
||||
switch ($conditional['condition']) {
|
||||
case FilterCondition::CONDITION_EQUAL:
|
||||
$where->equalTo($conditional['column'], $conditional['value']);
|
||||
|
|
@ -389,7 +389,7 @@ abstract class TableGateway extends \Laminas\Db\TableGateway\TableGateway
|
|||
*/
|
||||
public function fetchRandom()
|
||||
{
|
||||
$resultSet = $this->select(function (Select $select) {
|
||||
$resultSet = $this->select(function (Select $select): void {
|
||||
switch ($this->adapter->getDriver()->getDatabasePlatformName()) {
|
||||
case 'MySQL':
|
||||
$select->order(new Expression('RAND()'));
|
||||
|
|
@ -424,7 +424,7 @@ abstract class TableGateway extends \Laminas\Db\TableGateway\TableGateway
|
|||
if ($where instanceof Select) {
|
||||
$resultSet = $this->selectWith($where);
|
||||
} else {
|
||||
$resultSet = $this->select(function (Select $select) use ($where, $order, $offset) {
|
||||
$resultSet = $this->select(function (Select $select) use ($where, $order, $offset): void {
|
||||
if (!is_null($where)) {
|
||||
$select->where($where);
|
||||
}
|
||||
|
|
@ -441,10 +441,6 @@ abstract class TableGateway extends \Laminas\Db\TableGateway\TableGateway
|
|||
return (count($resultSet) > 0) ? $resultSet->current() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PredicateInterface[]|Where[] $where
|
||||
* @param mixed $wheres
|
||||
*/
|
||||
public function getCount($wheres = []): int
|
||||
{
|
||||
$select = $this->getSql()->select();
|
||||
|
|
@ -505,8 +501,6 @@ abstract class TableGateway extends \Laminas\Db\TableGateway\TableGateway
|
|||
|
||||
/**
|
||||
* Returns an array of all primary keys on the table keyed by the column.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getHighestPrimaryKey(): array
|
||||
{
|
||||
|
|
@ -529,8 +523,6 @@ abstract class TableGateway extends \Laminas\Db\TableGateway\TableGateway
|
|||
|
||||
/**
|
||||
* Returns an array of all autoincrement keys on the table keyed by the column.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getHighestAutoincrementKey(): array
|
||||
{
|
||||
|
|
@ -737,9 +729,6 @@ abstract class TableGateway extends \Laminas\Db\TableGateway\TableGateway
|
|||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Model
|
||||
*/
|
||||
public function getNewModelInstance(array $data = []): Model
|
||||
{
|
||||
$model = $this->model;
|
||||
|
|
|
|||
|
|
@ -88,17 +88,12 @@ class Column extends Entity
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPhpType()
|
||||
{
|
||||
return $this->phpType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $phpType
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setPhpType($phpType)
|
||||
|
|
@ -124,8 +119,6 @@ class Column extends Entity
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $field
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setField($field)
|
||||
|
|
@ -135,17 +128,12 @@ class Column extends Entity
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDbField()
|
||||
{
|
||||
return $this->dbField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $dbField
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setDbField($dbField)
|
||||
|
|
@ -160,17 +148,12 @@ class Column extends Entity
|
|||
return $this->transCamel2Studly->transform($this->getFieldSanitised());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMaxDecimalPlaces()
|
||||
{
|
||||
return $this->maxDecimalPlaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $maxDecimalPlaces
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setMaxDecimalPlaces($maxDecimalPlaces)
|
||||
|
|
@ -180,17 +163,12 @@ class Column extends Entity
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefaultValue()
|
||||
{
|
||||
return $this->defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $defaultValue
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setDefaultValue($defaultValue)
|
||||
|
|
@ -211,19 +189,11 @@ class Column extends Entity
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDefaultValueIsLiteral(): bool
|
||||
{
|
||||
return $this->defaultValueIsLiteral;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $defaultValueIsLiteral
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setDefaultValueIsLiteral(bool $defaultValueIsLiteral): Column
|
||||
{
|
||||
$this->defaultValueIsLiteral = $defaultValueIsLiteral;
|
||||
|
|
@ -231,17 +201,12 @@ class Column extends Entity
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMaxLength()
|
||||
{
|
||||
return $this->maxLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $maxLength
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setMaxLength($maxLength)
|
||||
|
|
@ -251,17 +216,12 @@ class Column extends Entity
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMaxFieldLength()
|
||||
{
|
||||
return $this->maxFieldLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $maxFieldLength
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setMaxFieldLength($maxFieldLength)
|
||||
|
|
@ -271,17 +231,12 @@ class Column extends Entity
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDbType()
|
||||
{
|
||||
return $this->dbType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $dbType
|
||||
*
|
||||
* @throws DBTypeNotTranslatedException
|
||||
*
|
||||
* @return Column
|
||||
|
|
@ -342,17 +297,12 @@ class Column extends Entity
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPermittedValues()
|
||||
{
|
||||
return $this->permittedValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $permittedValues
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setPermittedValues($permittedValues)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ class Model extends Entity
|
|||
|
||||
/**
|
||||
* @param Model[] $models
|
||||
* @param array $keyMap
|
||||
* @param ConstraintObject[] $zendConstraints
|
||||
*/
|
||||
public function computeConstraints(array $models, array $keyMap, array $zendConstraints): self
|
||||
|
|
@ -161,7 +160,7 @@ class Model extends Entity
|
|||
/**
|
||||
* @param Model[] $models
|
||||
*/
|
||||
public function scanForRemoteRelations(array &$models)
|
||||
public function scanForRemoteRelations(array &$models): void
|
||||
{
|
||||
//echo "Scan: {$this->getClassName()}\n";
|
||||
foreach ($this->getColumns() as $column) {
|
||||
|
|
@ -360,9 +359,6 @@ class Model extends Entity
|
|||
return $this->namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $namespace
|
||||
*/
|
||||
public function setNamespace(string $namespace): self
|
||||
{
|
||||
$this->namespace = $namespace;
|
||||
|
|
@ -450,9 +446,6 @@ class Model extends Entity
|
|||
return $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAutoIncrements()
|
||||
{
|
||||
$autoincrementKeys = [];
|
||||
|
|
@ -467,9 +460,6 @@ class Model extends Entity
|
|||
return $autoincrementKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $autoIncrements
|
||||
*/
|
||||
public function setAutoIncrements($autoIncrements): self
|
||||
{
|
||||
$this->autoIncrements = $autoIncrements;
|
||||
|
|
@ -477,9 +467,6 @@ class Model extends Entity
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getClassPrefix(): ?string
|
||||
{
|
||||
return $this->classPrefix;
|
||||
|
|
@ -487,10 +474,6 @@ class Model extends Entity
|
|||
|
||||
/**
|
||||
* When set to null, this class has no prefix.
|
||||
*
|
||||
* @param null|string $classPrefix
|
||||
*
|
||||
* @return Model
|
||||
*/
|
||||
public function setClassPrefix(?string $classPrefix): Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,19 +22,11 @@ class RelatedModel extends Entity
|
|||
|
||||
protected Model $relatedModel;
|
||||
|
||||
/**
|
||||
* @return Database
|
||||
*/
|
||||
public function getDatabase(): Database
|
||||
{
|
||||
return $this->database;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Database $database
|
||||
*
|
||||
* @return RelatedModel
|
||||
*/
|
||||
public function setDatabase(Database $database): RelatedModel
|
||||
{
|
||||
$this->database = $database;
|
||||
|
|
@ -319,19 +311,11 @@ class RelatedModel extends Entity
|
|||
return $this->getRemoteClassPrefix();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Model
|
||||
*/
|
||||
public function getLocalRelatedModel(): Model
|
||||
{
|
||||
return $this->relatedModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $localRelatedModel
|
||||
*
|
||||
* @return RelatedModel
|
||||
*/
|
||||
public function setLocalRelatedModel(Model $localRelatedModel): RelatedModel
|
||||
{
|
||||
$this->relatedModel = $localRelatedModel;
|
||||
|
|
@ -339,19 +323,11 @@ class RelatedModel extends Entity
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Model
|
||||
*/
|
||||
public function getRemoteRelatedModel(): Model
|
||||
{
|
||||
return $this->remoteRelatedModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $remoteRelatedModel
|
||||
*
|
||||
* @return RelatedModel
|
||||
*/
|
||||
public function setRemoteRelatedModel(Model $remoteRelatedModel): RelatedModel
|
||||
{
|
||||
$this->remoteRelatedModel = $remoteRelatedModel;
|
||||
|
|
|
|||
|
|
@ -42,19 +42,11 @@ class Database
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return Database
|
||||
*/
|
||||
public function setName(string $name): Database
|
||||
{
|
||||
$this->name = $name;
|
||||
|
|
@ -62,19 +54,11 @@ class Database
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*
|
||||
* @return Database
|
||||
*/
|
||||
public function setType(string $type): Database
|
||||
{
|
||||
$this->type = $type;
|
||||
|
|
@ -82,19 +66,11 @@ class Database
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHostname(): string
|
||||
{
|
||||
return $this->hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $hostname
|
||||
*
|
||||
* @return Database
|
||||
*/
|
||||
public function setHostname(string $hostname): Database
|
||||
{
|
||||
$this->hostname = $hostname;
|
||||
|
|
@ -102,19 +78,11 @@ class Database
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername(): string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
*
|
||||
* @return Database
|
||||
*/
|
||||
public function setUsername(string $username): Database
|
||||
{
|
||||
$this->username = $username;
|
||||
|
|
@ -122,19 +90,11 @@ class Database
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword(): string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $password
|
||||
*
|
||||
* @return Database
|
||||
*/
|
||||
public function setPassword(string $password): Database
|
||||
{
|
||||
$this->password = $password;
|
||||
|
|
@ -142,19 +102,11 @@ class Database
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDatabase(): string
|
||||
{
|
||||
return $this->database;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $database
|
||||
*
|
||||
* @return Database
|
||||
*/
|
||||
public function setDatabase(string $database): Database
|
||||
{
|
||||
$this->database = $database;
|
||||
|
|
@ -162,19 +114,11 @@ class Database
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCharset(): string
|
||||
{
|
||||
return $this->charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $charset
|
||||
*
|
||||
* @return Database
|
||||
*/
|
||||
public function setCharset(string $charset): Database
|
||||
{
|
||||
$this->charset = $charset;
|
||||
|
|
|
|||
|
|
@ -9,17 +9,12 @@ class Table extends Entity
|
|||
/** @var Column */
|
||||
protected $columns;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTableName()
|
||||
{
|
||||
return $this->tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $tableName
|
||||
*
|
||||
* @return Table
|
||||
*/
|
||||
public function setTableName($tableName)
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class Laminator
|
|||
return $this->workPath;
|
||||
}
|
||||
|
||||
public function exceptionHandler($exception)
|
||||
public function exceptionHandler($exception): void
|
||||
{
|
||||
// UHOH exception handler
|
||||
/** @var \Exception $exception */
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Profiler implements ProfilerInterface
|
|||
];
|
||||
}
|
||||
|
||||
public function profilerStart($target)
|
||||
public function profilerStart($target): void
|
||||
{
|
||||
if (is_string($target)) {
|
||||
$this->sql = $target;
|
||||
|
|
@ -48,7 +48,7 @@ class Profiler implements ProfilerInterface
|
|||
$this->timer = microtime(true);
|
||||
}
|
||||
|
||||
public function profilerFinish()
|
||||
public function profilerFinish(): void
|
||||
{
|
||||
$uuid = UUID::v4();
|
||||
$executionTime = microtime(true) - $this->timer;
|
||||
|
|
|
|||
Loading…
Reference in a new issue