Skip to content

Commit

Permalink
- Just code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed Nov 15, 2019
1 parent 64a5503 commit 99102c9
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 19 deletions.
26 changes: 13 additions & 13 deletions src/IPub/DoctrineCrud/DI/DoctrineCrudExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,35 +81,35 @@ public function loadConfiguration() : void
->setImplement(Crud\Create\IEntityCreator::class)
->setAutowired(FALSE)
->getResultDefinition()
->setType(Crud\Create\EntityCreator::class);
->setType(Crud\Create\EntityCreator::class);

$builder->addFactoryDefinition($this->prefix('entity.updater'))
->setImplement(Crud\Update\IEntityUpdater::class)
->setAutowired(FALSE)
->getResultDefinition()
->setFactory(Crud\Update\EntityUpdater::class);
->setFactory(Crud\Update\EntityUpdater::class);

$builder->addFactoryDefinition($this->prefix('entity.deleter'))
->setImplement(Crud\Delete\IEntityDeleter::class)
->setAutowired(FALSE)
->getResultDefinition()
->setFactory(Crud\Delete\EntityDeleter::class);
->setFactory(Crud\Delete\EntityDeleter::class);

// Syntax sugar for config
$builder->addFactoryDefinition($this->prefix('crud'))
->setImplement(Crud\IEntityCrudFactory::class)
->setParameters(['entityName'])
->getResultDefinition()
->setType(Crud\EntityCrud::class)
->setArguments([
new PhpGenerator\PhpLiteral('$entityName'),
'@' . $this->prefix('entity.mapper'),
'@' . $this->prefix('entity.creator'),
'@' . $this->prefix('entity.updater'),
'@' . $this->prefix('entity.deleter'),
]);

// NETTE 2.4+
->setType(Crud\EntityCrud::class)
->setArguments([
new PhpGenerator\PhpLiteral('$entityName'),
'@' . $this->prefix('entity.mapper'),
'@' . $this->prefix('entity.creator'),
'@' . $this->prefix('entity.updater'),
'@' . $this->prefix('entity.deleter'),
]);

// NETTE 2.4+
} else {
$builder->addDefinition($this->prefix('entity.creator'))
->setType(Crud\Create\EntityCreator::class)
Expand Down
3 changes: 2 additions & 1 deletion src/IPub/DoctrineCrud/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Helpers
{
/**
* This method was inspired same method in Nette framework
*
*
* @param \ReflectionMethod $method
* @param array $arguments
*
Expand Down Expand Up @@ -100,6 +100,7 @@ public static function getParameterType(\ReflectionParameter $param) : ?string
{
if ($param->hasType()) {
$type = PHP_VERSION_ID >= 70100 ? $param->getType()->getName() : (string) $param->getType();

return strtolower($type) === 'self' ? $param->getDeclaringClass()->getName() : $type;
}

Expand Down
8 changes: 4 additions & 4 deletions src/IPub/DoctrineCrud/StringFunctions/DateFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class DateFormat extends Query\AST\Functions\FunctionNode
public function getSql(Query\SqlWalker $sqlWalker) : string
{
return 'DATE_FORMAT(' .
$sqlWalker->walkArithmeticExpression($this->dateExpression) .
',' .
$sqlWalker->walkStringPrimary($this->formatChar) .
')';
$sqlWalker->walkArithmeticExpression($this->dateExpression) .
',' .
$sqlWalker->walkStringPrimary($this->formatChar) .
')';
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/IPubTests/DoctrineCrud/CRUDTest.phpt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* Test: IPub\DoctrineCrud\Creator
*
* @testCase
*
* @copyright More in license.md
Expand Down
1 change: 1 addition & 0 deletions tests/IPubTests/DoctrineCrud/ExtensionTest.phpt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* Test: IPub\DoctrineCrud\Extension
*
* @testCase
*
* @copyright More in license.md
Expand Down
1 change: 1 addition & 0 deletions tests/IPubTests/DoctrineCrud/models/ArticleEntity.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* Test: IPub\DoctrineCrud\Models
*
* @testCase
*
* @copyright More in license.md
Expand Down
1 change: 1 addition & 0 deletions tests/IPubTests/DoctrineCrud/models/ArticlesManager.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* Test: IPub\DoctrineCrud\Models
*
* @testCase
*
* @copyright More in license.md
Expand Down
1 change: 1 addition & 0 deletions tests/IPubTests/DoctrineCrud/models/UserEntity.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* Test: IPub\DoctrineCrud\Models
*
* @testCase
*
* @copyright More in license.md
Expand Down
1 change: 1 addition & 0 deletions tests/IPubTests/DoctrineCrud/models/UsersManager.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* Test: IPub\DoctrineCrud\Models
*
* @testCase
*
* @copyright More in license.md
Expand Down
2 changes: 1 addition & 1 deletion tests/IPubTests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
\Tracy\Debugger::$logDirectory = TEMP_DIR;

$_SERVER = array_intersect_key($_SERVER, array_flip([
'PHP_SELF', 'SCRIPT_NAME', 'SERVER_ADDR', 'SERVER_SOFTWARE', 'HTTP_HOST', 'DOCUMENT_ROOT', 'OS', 'argc', 'argv'
'PHP_SELF', 'SCRIPT_NAME', 'SERVER_ADDR', 'SERVER_SOFTWARE', 'HTTP_HOST', 'DOCUMENT_ROOT', 'OS', 'argc', 'argv',
]));
$_SERVER['REQUEST_TIME'] = 1234567890;
$_ENV = $_GET = $_POST = [];
Expand Down

0 comments on commit 99102c9

Please sign in to comment.