Formatting
This commit is contained in:
parent
167a482163
commit
bc7fd3bf4f
34 changed files with 267 additions and 299 deletions
|
|
@ -1,42 +1,2 @@
|
|||
<?php
|
||||
$finder = PhpCsFixer\Finder::create();
|
||||
|
||||
if (!defined('__PHPCS_ROOT__')) {
|
||||
define('__PHPCS_ROOT__', __DIR__);
|
||||
}
|
||||
|
||||
$directories = [
|
||||
__PHPCS_ROOT__.'/bin',
|
||||
__PHPCS_ROOT__.'/src',
|
||||
__PHPCS_ROOT__.'/test/src',
|
||||
__PHPCS_ROOT__.'/test/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' => false,
|
||||
'void_return' => true,
|
||||
'yoda_style' => false,
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
||||
return require("vendor/benzine/core/.php-cs-fixer.php");
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Abstracts;
|
||||
|
||||
abstract class AbstractCollection
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Abstracts;
|
||||
|
||||
use Benzine\ORM\Finder;
|
||||
|
|
@ -26,9 +28,7 @@ abstract class AbstractModel implements ModelInterface, \Serializable
|
|||
* Overrideable __setUp function that will allow you to hijack
|
||||
* it and create any related objects that need to be recreated.
|
||||
*/
|
||||
public function __setUp(): void
|
||||
{
|
||||
}
|
||||
public function __setUp(): void {}
|
||||
|
||||
public function __wakeup(): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Abstracts;
|
||||
|
||||
use Benzine\ORM\Interfaces\CollectionsInterface;
|
||||
|
|
@ -19,15 +21,13 @@ abstract class AbstractService
|
|||
/**
|
||||
* @param null|array|\Closure[] $wheres
|
||||
* @param null|Sql\Expression|string $order
|
||||
*
|
||||
* @return CollectionsInterface
|
||||
*/
|
||||
public function getAll(
|
||||
int $limit = null,
|
||||
int $offset = null,
|
||||
array $wheres = null,
|
||||
?int $limit = null,
|
||||
?int $offset = null,
|
||||
?array $wheres = null,
|
||||
$order = null,
|
||||
string $orderDirection = null
|
||||
?string $orderDirection = null
|
||||
): CollectionsInterface {
|
||||
/** @var AbstractTableGateway $tableGateway */
|
||||
$tableGateway = $this->getNewTableGatewayInstance();
|
||||
|
|
@ -36,7 +36,7 @@ abstract class AbstractService
|
|||
$offset,
|
||||
$wheres,
|
||||
$order,
|
||||
null !== $orderDirection ? $orderDirection : Sql\Select::ORDER_ASCENDING
|
||||
null !== $orderDirection ? $orderDirection : Select::ORDER_ASCENDING
|
||||
);
|
||||
|
||||
$collection = $this->getNewCollectionInstance();
|
||||
|
|
@ -51,12 +51,10 @@ abstract class AbstractService
|
|||
/**
|
||||
* @param null|string $distinctColumn
|
||||
* @param null|array|\Closure[] $wheres
|
||||
*
|
||||
* @return AbstractCollection
|
||||
*/
|
||||
public function getDistinct(
|
||||
string $distinctColumn,
|
||||
array $wheres = null
|
||||
?array $wheres = null
|
||||
): AbstractCollection {
|
||||
/** @var AbstractTableGateway $tableGateway */
|
||||
$tableGateway = $this->getNewTableGatewayInstance();
|
||||
|
|
@ -76,11 +74,9 @@ abstract class AbstractService
|
|||
|
||||
/**
|
||||
* @param null|array|\Closure[] $wheres
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countAll(
|
||||
array $wheres = null
|
||||
?array $wheres = null
|
||||
): int {
|
||||
/** @var AbstractTableGateway $tableGateway */
|
||||
$tableGateway = $this->getNewTableGatewayInstance();
|
||||
|
|
@ -91,7 +87,7 @@ abstract class AbstractService
|
|||
/**
|
||||
* @return Benzine\ORM\Abstracts\Model[]
|
||||
*/
|
||||
public function search(Sql\Where $where, int $limit = null, int $offset = null): \Generator
|
||||
public function search(Sql\Where $where, ?int $limit = null, ?int $offset = null): \Generator
|
||||
{
|
||||
$tableGateway = $this->getNewTableGatewayInstance();
|
||||
|
||||
|
|
@ -118,7 +114,7 @@ abstract class AbstractService
|
|||
|
||||
abstract public function getByField(string $field, $value, $orderBy = null, $orderDirection = Select::ORDER_ASCENDING): ?AbstractModel;
|
||||
|
||||
abstract public function getManyByField(string $field, $value, int $limit = null, int $offset = null, $orderBy = null, $orderDirection = Select::ORDER_ASCENDING): AbstractCollection;
|
||||
abstract public function getManyByField(string $field, $value, ?int $limit = null, ?int $offset = null, $orderBy = null, $orderDirection = Select::ORDER_ASCENDING): AbstractCollection;
|
||||
|
||||
abstract public function countByField(string $field, $value): int;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Abstracts;
|
||||
|
||||
use Benzine\Controllers\Filters\FilterCondition;
|
||||
|
|
@ -17,6 +19,7 @@ use Laminas\Db\Sql\Predicate\PredicateInterface;
|
|||
use Laminas\Db\Sql\Select;
|
||||
use Laminas\Db\Sql\Where;
|
||||
use Laminas\Db\TableGateway\TableGateway;
|
||||
use Laminas\Db\ResultSet\ResultSetInterface;
|
||||
|
||||
abstract class AbstractTableGateway extends TableGateway
|
||||
{
|
||||
|
|
@ -188,6 +191,7 @@ abstract class AbstractTableGateway extends TableGateway
|
|||
public function update($data, $where = null, $oldData = [])
|
||||
{
|
||||
$data = array_filter($data);
|
||||
|
||||
// !\Kint::dump($data, $oldData, $where);exit;
|
||||
return parent::update($data, $where);
|
||||
}
|
||||
|
|
@ -204,9 +208,9 @@ abstract class AbstractTableGateway extends TableGateway
|
|||
* @return array [ResultSet,int] Returns an array of resultSet,total_found_rows
|
||||
*/
|
||||
public function fetchAll(
|
||||
int $limit = null,
|
||||
int $offset = null,
|
||||
array $wheres = null,
|
||||
?int $limit = null,
|
||||
?int $offset = null,
|
||||
?array $wheres = null,
|
||||
$order = null,
|
||||
string $direction = Select::ORDER_ASCENDING
|
||||
) {
|
||||
|
|
@ -326,7 +330,7 @@ abstract class AbstractTableGateway extends TableGateway
|
|||
*/
|
||||
public function fetchDistinct(
|
||||
string $distinctColumn,
|
||||
array $wheres = null
|
||||
?array $wheres = null
|
||||
) {
|
||||
/** @var Select $select */
|
||||
$select = $this->getSql()->select();
|
||||
|
|
@ -403,9 +407,9 @@ abstract class AbstractTableGateway extends TableGateway
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws BenzineException
|
||||
*
|
||||
* @return null|ModelInterface
|
||||
*
|
||||
* @throws BenzineException
|
||||
*/
|
||||
public function fetchRandom()
|
||||
{
|
||||
|
|
@ -566,8 +570,6 @@ abstract class AbstractTableGateway extends TableGateway
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
*
|
||||
* @return null|AbstractModel
|
||||
*/
|
||||
public function getById($id)
|
||||
|
|
@ -576,8 +578,6 @@ abstract class AbstractTableGateway extends TableGateway
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $field
|
||||
* @param $value
|
||||
* @param $orderBy string Field to sort by
|
||||
* @param $orderDirection string Direction to sort (Select::ORDER_ASCENDING || Select::ORDER_DESCENDING)
|
||||
*
|
||||
|
|
@ -633,15 +633,11 @@ abstract class AbstractTableGateway extends TableGateway
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Where $where
|
||||
* @param null|int $limit
|
||||
* @param null|int $offset
|
||||
* @param null|Expression|string $orderBy
|
||||
* @param string $orderDirection
|
||||
*
|
||||
* @return \Laminas\Db\ResultSet\ResultSetInterface
|
||||
* @return ResultSetInterface
|
||||
*/
|
||||
public function getManyByWhere(Where $where, int $limit = null, int $offset = null, $orderBy = null, string $orderDirection = Select::ORDER_ASCENDING)
|
||||
public function getManyByWhere(Where $where, ?int $limit = null, ?int $offset = null, $orderBy = null, string $orderDirection = Select::ORDER_ASCENDING)
|
||||
{
|
||||
$select = $this->sql->select();
|
||||
|
||||
|
|
@ -671,11 +667,10 @@ abstract class AbstractTableGateway extends TableGateway
|
|||
* @param null|int $offset int
|
||||
* @param null|string $orderBy string Field to sort by
|
||||
* @param $orderDirection string Direction to sort (Select::ORDER_ASCENDING || Select::ORDER_DESCENDING)
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return AbstractCollection
|
||||
*/
|
||||
public function getManyByField(string $field, $value, int $limit = null, int $offset = null, string $orderBy = null, string $orderDirection = Select::ORDER_ASCENDING)
|
||||
public function getManyByField(string $field, $value, ?int $limit = null, ?int $offset = null, ?string $orderBy = null, string $orderDirection = Select::ORDER_ASCENDING)
|
||||
{
|
||||
if ($value instanceof \DateTime) {
|
||||
$value = $value->format('Y-m-d H:i:s');
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM;
|
||||
|
||||
use Benzine\ORM\Profiler\Profiler as BenzineProfiler;
|
||||
|
|
@ -10,7 +12,7 @@ use Laminas\Db\ResultSet;
|
|||
|
||||
class Adapter extends LaminasAdapter
|
||||
{
|
||||
public function __construct($driver, Platform\PlatformInterface $platform = null, ResultSet\ResultSetInterface $queryResultPrototype = null, Profiler\ProfilerInterface $profiler = null)
|
||||
public function __construct($driver, ?Platform\PlatformInterface $platform = null, ?ResultSet\ResultSetInterface $queryResultPrototype = null, ?Profiler\ProfilerInterface $profiler = null)
|
||||
{
|
||||
parent::__construct($driver, $platform, $queryResultPrototype, $profiler);
|
||||
// if (!defined('ZEND_PROFILER_DISABLE') || ZEND_PROFILER_DISABLE == false) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Components;
|
||||
|
||||
use Benzine\ORM\Exception\DBTypeNotTranslatedException;
|
||||
|
|
@ -97,8 +99,6 @@ class Column extends Entity
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $phpType
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setPhpType($phpType)
|
||||
|
|
@ -124,8 +124,6 @@ class Column extends Entity
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $field
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setField($field)
|
||||
|
|
@ -154,8 +152,6 @@ class Column extends Entity
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $dbField
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setDbField($dbField)
|
||||
|
|
@ -176,8 +172,6 @@ class Column extends Entity
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $maxDecimalPlaces
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setMaxDecimalPlaces($maxDecimalPlaces)
|
||||
|
|
@ -193,8 +187,6 @@ class Column extends Entity
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $defaultValue
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setDefaultValue($defaultValue)
|
||||
|
|
@ -233,8 +225,6 @@ class Column extends Entity
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $maxLength
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setMaxLength($maxLength)
|
||||
|
|
@ -250,8 +240,6 @@ class Column extends Entity
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $maxFieldLength
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setMaxFieldLength($maxFieldLength)
|
||||
|
|
@ -267,11 +255,9 @@ class Column extends Entity
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $dbType
|
||||
* @return Column
|
||||
*
|
||||
* @throws DBTypeNotTranslatedException
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setDbType($dbType)
|
||||
{
|
||||
|
|
@ -342,8 +328,6 @@ class Column extends Entity
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $permittedValues
|
||||
*
|
||||
* @return Column
|
||||
*/
|
||||
public function setPermittedValues($permittedValues)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Components;
|
||||
|
||||
use Benzine\ORM\Laminator;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Components;
|
||||
|
||||
use Benzine\Exceptions\BenzineException;
|
||||
|
|
@ -407,6 +409,7 @@ class Model extends Entity
|
|||
foreach ($this->getRelatedObjects() as $relatedObject) {
|
||||
$sharedAssets[$relatedObject->getRemoteClass()] = $relatedObject;
|
||||
}
|
||||
|
||||
// if(count($this->getRelatedObjects())) {
|
||||
// \Kint::dump($this->getRelatedObjects(), $sharedAssets);
|
||||
// exit;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Components;
|
||||
|
||||
use Benzine\ORM\Connection\Database;
|
||||
|
|
@ -179,8 +181,7 @@ class RelatedModel extends Entity
|
|||
return
|
||||
self::singulariseCamelCaseSentence($this->getLocalClass()) .
|
||||
'By' .
|
||||
$this->transCamel2Studly->transform($this->getLocalBoundColumn())
|
||||
;
|
||||
$this->transCamel2Studly->transform($this->getLocalBoundColumn());
|
||||
}
|
||||
|
||||
return $this->transCamel2Studly->transform(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Connection;
|
||||
|
||||
use Benzine\ORM\Tests\App;
|
||||
|
|
@ -26,8 +28,8 @@ class Database
|
|||
|
||||
public function __construct(
|
||||
private Logger $logger,
|
||||
string $name = null,
|
||||
array $config = null
|
||||
?string $name = null,
|
||||
?array $config = null
|
||||
) {
|
||||
if ($name) {
|
||||
$this->setName($name);
|
||||
|
|
@ -163,19 +165,11 @@ class Database
|
|||
return new Metadata($this->getAdapter());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getIgnoredTables(): array
|
||||
{
|
||||
return $this->ignoredTables;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $ignoredTables
|
||||
*
|
||||
* @return Database
|
||||
*/
|
||||
public function setIgnoredTables(array $ignoredTables): Database
|
||||
{
|
||||
$this->ignoredTables = $ignoredTables;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Connection;
|
||||
|
||||
use Benzine\Exceptions\BenzineException;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Entities;
|
||||
|
||||
abstract class AbstractEntity
|
||||
{
|
||||
}
|
||||
abstract class AbstractEntity {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Entities;
|
||||
|
||||
class Column extends AbstractEntity
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Entities;
|
||||
|
||||
class Table extends AbstractEntity
|
||||
|
|
@ -13,8 +15,6 @@ class Table extends AbstractEntity
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $tableName
|
||||
*
|
||||
* @return Table
|
||||
*/
|
||||
public function setTableName($tableName)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Exception;
|
||||
|
||||
use Benzine\Exceptions\BenzineException;
|
||||
|
||||
class BenzineOrmException extends BenzineException
|
||||
{
|
||||
}
|
||||
class BenzineOrmException extends BenzineException {}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Exception;
|
||||
|
||||
class CollectionException extends BenzineOrmException
|
||||
{
|
||||
}
|
||||
class CollectionException extends BenzineOrmException {}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Exception;
|
||||
|
||||
class DBTypeNotTranslatedException extends BenzineOrmException
|
||||
{
|
||||
}
|
||||
class DBTypeNotTranslatedException extends BenzineOrmException {}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Exception;
|
||||
|
||||
class SchemaToAdaptorException extends BenzineOrmException
|
||||
{
|
||||
}
|
||||
class SchemaToAdaptorException extends BenzineOrmException {}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM;
|
||||
|
||||
use Benzine\ORM\Exception\BenzineOrmException;
|
||||
use Laminas\Db\Sql\Where;
|
||||
|
||||
class Finder extends \Laminas\Db\Sql\Where
|
||||
class Finder extends Where
|
||||
{
|
||||
public function __construct(
|
||||
?array $predicates = null,
|
||||
|
|
@ -65,11 +68,6 @@ class Finder extends \Laminas\Db\Sql\Where
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $orderDirection
|
||||
*
|
||||
* @return Finder
|
||||
*/
|
||||
public function orderDirection(string $orderDirection): Finder
|
||||
{
|
||||
if (!in_array($orderDirection, ['desc', 'asc'], true)) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Interfaces;
|
||||
|
||||
use Laminas\Db\ResultSet\ResultSet;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Interfaces;
|
||||
|
||||
interface ModelInterface
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Interfaces;
|
||||
|
||||
interface QueryStatisticInterface
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Interfaces;
|
||||
|
||||
use Laminas\Db\Sql\Expression;
|
||||
|
|
@ -12,11 +14,11 @@ interface ServiceInterface
|
|||
* @return ModelInterface[]
|
||||
*/
|
||||
public function getAll(
|
||||
int $limit = null,
|
||||
int $offset = null,
|
||||
array $wheres = null,
|
||||
?int $limit = null,
|
||||
?int $offset = null,
|
||||
?array $wheres = null,
|
||||
$order = null,
|
||||
string $orderDirection = null
|
||||
?string $orderDirection = null
|
||||
);
|
||||
|
||||
public function getByField(string $field, $value);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Interfaces;
|
||||
|
||||
interface TableGatewayInterface extends \Laminas\Db\TableGateway\TableGatewayInterface
|
||||
{
|
||||
}
|
||||
interface TableGatewayInterface extends \Laminas\Db\TableGateway\TableGatewayInterface {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM;
|
||||
|
||||
use Benzine\App;
|
||||
|
|
@ -23,6 +25,10 @@ use Twig\Error\LoaderError;
|
|||
use Twig\Error\RuntimeError;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\Loader\FilesystemLoader as TwigFileSystemLoader;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\DebugExtension;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
class Laminator
|
||||
{
|
||||
|
|
@ -70,7 +76,7 @@ class Laminator
|
|||
|
||||
$this->defaultEnvironment = [
|
||||
'SCRIPT_NAME' => '/index.php',
|
||||
'RAND' => rand(0, 100000000),
|
||||
'RAND' => random_int(0, 100000000),
|
||||
];
|
||||
$this->defaultHeaders = [];
|
||||
}
|
||||
|
|
@ -88,9 +94,9 @@ class Laminator
|
|||
$this->setWorkPath(self::$benzineConfig->get(ConfigurationService::KEY_APP_ROOT));
|
||||
}
|
||||
|
||||
$this->loader = new \Twig\Loader\FilesystemLoader(__DIR__.'/Generator/Templates');
|
||||
$this->twig = new \Twig\Environment($this->loader, ['debug' => true]);
|
||||
$this->twig->addExtension(new \Twig\Extension\DebugExtension());
|
||||
$this->loader = new FilesystemLoader(__DIR__ . '/Generator/Templates');
|
||||
$this->twig = new Environment($this->loader, ['debug' => true]);
|
||||
$this->twig->addExtension(new DebugExtension());
|
||||
$this->twig->addExtension(new TransformExtension());
|
||||
$this->twig->addExtension(new InflectionExtension());
|
||||
|
||||
|
|
@ -98,7 +104,7 @@ class Laminator
|
|||
new ArrayUniqueTwigExtension()
|
||||
);
|
||||
|
||||
$fct = new \Twig\TwigFunction('var_export', 'var_export');
|
||||
$fct = new TwigFunction('var_export', 'var_export');
|
||||
$this->twig->addFunction($fct);
|
||||
|
||||
$this->transSnake2Studly = new CaseTransformer(new Format\SnakeCase(), new Format\StudlyCaps());
|
||||
|
|
@ -171,11 +177,9 @@ class Laminator
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $schemaName
|
||||
* @return int|string
|
||||
*
|
||||
* @throws SchemaToAdaptorException
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
public function schemaName2databaseName($schemaName)
|
||||
{
|
||||
|
|
@ -255,11 +259,11 @@ class Laminator
|
|||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*
|
||||
* @throws LoaderError
|
||||
* @throws RuntimeError
|
||||
* @throws SyntaxError
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function makeLaminator()
|
||||
{
|
||||
|
|
@ -294,7 +298,7 @@ class Laminator
|
|||
if (in_array($table->getName(), $database->getIgnoredTables(), true)) {
|
||||
continue;
|
||||
}
|
||||
$oModel = Components\Model::Factory($this)
|
||||
$oModel = Model::Factory($this)
|
||||
->setClassPrefix(self::$benzineConfig->get("databases/{$dbName}/class_prefix", null))
|
||||
->setNamespace(self::$benzineConfig->getNamespace())
|
||||
->setDatabase($database)
|
||||
|
|
@ -391,11 +395,11 @@ class Laminator
|
|||
/**
|
||||
* @param Model[] $models
|
||||
*
|
||||
* @return Laminator
|
||||
*
|
||||
* @throws LoaderError When the template cannot be found
|
||||
* @throws SyntaxError When an error occurred during compilation
|
||||
* @throws RuntimeError When an error occurred during rendering
|
||||
*
|
||||
* @return Laminator
|
||||
*/
|
||||
private function makeCoreFiles(array $models)
|
||||
{
|
||||
|
|
@ -450,7 +454,7 @@ class Laminator
|
|||
$path = $this->getWorkPath() . '/' . $path;
|
||||
|
||||
if (!(new Filesystem())->exists(dirname($path))) {
|
||||
(new Filesystem())->mkdir(dirname($path), 0777);
|
||||
(new Filesystem())->mkdir(dirname($path), 0o777);
|
||||
}
|
||||
if (!(new Filesystem())->exists($path) || $overwrite) {
|
||||
// printf(" [Done]" . PHP_EOL);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM;
|
||||
|
||||
use Laminas\Db\Adapter\AdapterInterface;
|
||||
use Laminas\Db\Sql\Sql;
|
||||
|
||||
class LaminatorSql extends \Laminas\Db\Sql\Sql
|
||||
class LaminatorSql extends Sql
|
||||
{
|
||||
public function __construct(AdapterInterface $adapter, $table = null, $sqlPlatform = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Migrations;
|
||||
|
||||
abstract class AbstractMigration extends \Phinx\Migration\AbstractMigration
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Migrations;
|
||||
|
||||
use Benzine\ORM\Tests\App;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Profiler;
|
||||
|
||||
use Benzine\ORM\Interfaces\QueryStatisticInterface;
|
||||
|
|
@ -15,11 +17,9 @@ class Profiler implements ProfilerInterface
|
|||
private array $queries = [];
|
||||
private array $queryTimes = [];
|
||||
|
||||
public function __construct(private Logger $logger)
|
||||
{
|
||||
}
|
||||
public function __construct(private Logger $logger) {}
|
||||
|
||||
public function getQueryStats(QueryStatisticInterface $queryStatisticClass = null): array
|
||||
public function getQueryStats(?QueryStatisticInterface $queryStatisticClass = null): array
|
||||
{
|
||||
return [
|
||||
'TotalQueries' => count($this->queryTimes),
|
||||
|
|
@ -59,13 +59,13 @@ class Profiler implements ProfilerInterface
|
|||
/**
|
||||
* @return QueryStatisticInterface[]
|
||||
*/
|
||||
public function getQueries(QueryStatisticInterface $queryStatisticClass = null): array
|
||||
public function getQueries(?QueryStatisticInterface $queryStatisticClass = null): array
|
||||
{
|
||||
$stats = [];
|
||||
foreach ($this->queries as $uuid => [$query, $backTrace]) {
|
||||
if ($queryStatisticClass) {
|
||||
if (is_object($queryStatisticClass)) {
|
||||
$queryStatisticClass = get_class($queryStatisticClass);
|
||||
$queryStatisticClass = $queryStatisticClass::class;
|
||||
}
|
||||
$stat = new $queryStatisticClass();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\Profiler;
|
||||
|
||||
use Benzine\ORM\Interfaces\QueryStatisticInterface;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\TabularData;
|
||||
|
||||
use Benzine\ORM\Abstracts\AbstractService;
|
||||
|
|
@ -19,7 +21,7 @@ class Table
|
|||
public function __construct(AbstractService $service)
|
||||
{
|
||||
$this->service = $service;
|
||||
$this->setName(get_class($service));
|
||||
$this->setName($service::class);
|
||||
$this->reload();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM\TabularData;
|
||||
|
||||
use Benzine\ORM\Abstracts\AbstractModel;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Benzine\ORM;
|
||||
|
||||
use Benzine\App;
|
||||
|
|
|
|||
Loading…
Reference in a new issue