-
Notifications
You must be signed in to change notification settings - Fork 122
3.0.0 sql type hints #373
base: 3.0.0
Are you sure you want to change the base?
3.0.0 sql type hints #373
Conversation
…s which do not add valuable information
…tain multiple spaces between the tag, type and description
… are impossible in current implementation
…e the ? symbol present
Completed type hinting and added PHP 7.2 standards.
This PR provides changes described in #362 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I haven't review the whole PR (yet), but I caught some major issues with it which are repeated in the whole PR.
The PR has also some conflicts which needs to be resolved.
.gitignore
Outdated
@@ -1,3 +1,4 @@ | |||
.idea/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't have any IDE/OS specific files/directories here. Please revert and add it to your global .gitignore
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
src/Sql/AbstractSql.php
Outdated
/** | ||
* @var string | ||
*/ | ||
/** @var string[] */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is invalid type, values are mixed, keys are sting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to mixed[]
src/Sql/AbstractSql.php
Outdated
{ | ||
$adapterPlatform = ($adapterPlatform) ?: new DefaultAdapterPlatform; | ||
$adapterPlatform = $adapterPlatform ?: new DefaultAdapterPlatform; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add parenthesis on class instantiation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parenthesis added back in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not these parentheses - on class instantiation so it should be: new DefaultAdapterPlatform()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that - I guess I am starring at the code for too long 😆
src/Sql/AbstractSql.php
Outdated
DriverInterface $driver = null, | ||
ParameterContainer $parameterContainer = null | ||
) { | ||
PlatformInterface $platform, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about this parameters alignment, but if we are gonna go that way here we are missing on space
src/Sql/AbstractSql.php
Outdated
'Elements returned from getExpressionData() array must be a string or array.' | ||
); | ||
} | ||
|
||
// Process values and types (the middle and last position of the | ||
// expression data) | ||
$values = $part[1]; | ||
$types = isset($part[2]) ? $part[2] : []; | ||
$types = isset($part[2]) ? $part[2] : []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP 7.2 - use: $part[2] ?? []
$decimal = null, | ||
$nullable = false, | ||
$default = null, | ||
string $name = '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we have default value here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original Column.php setName method is a bit confusing. Not sure which way to go here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can leave the null
option in the constructor as it was and handle the null
parameter in the setter to ensure '' (empty string)
or
force at least an empty string in the constructor.
Any good ideas here?
src/Sql/Ddl/Column/Column.php
Outdated
* @param mixed[] $options | ||
*/ | ||
public function __construct($name = null, $nullable = false, $default = null, array $options = []) | ||
public function __construct(string $name = '', bool $nullable = false, ?$default = null, array $options = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed default value for $name
, I think it should be noted
src/Sql/Ddl/Column/Column.php
Outdated
* @param mixed[] $options | ||
*/ | ||
public function __construct($name = null, $nullable = false, $default = null, array $options = []) | ||
public function __construct(string $name = '', bool $nullable = false, ?$default = null, array $options = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again: question mark before variable name (missing type?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See below
src/Sql/Ddl/Column/Column.php
Outdated
*/ | ||
public function setDefault($default) | ||
public function setDefault(?$default) : self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here, question mark, please check all places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed back, but open for discussion based on the PSR-12 draft
src/Sql/Ddl/CreateTable.php
Outdated
@@ -146,10 +113,9 @@ protected function processTable(PlatformInterface $adapterPlatform = null) | |||
|
|||
/** | |||
* @param PlatformInterface $adapterPlatform | |||
* | |||
* @return string[][]|null | |||
* @return string[][]|void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are trying to avoid that, and do not mix void with the other type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
# Conflicts: # src/Sql/Select.php
@webimpress Thanks for the feedback. There are quite a few cs breaks which have not been introduced by this PR. Instead of the laborious manual work of comparing and fixing everything, I suggest to either update |
Ok folks, that's it for now. |
This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at laminas/laminas-db#9. |
This repository has been moved to laminas/laminas-db. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:
|
Provide a narrative description of what you are trying to accomplish:
Are you fixing a bug?
master
branch, and submit against that branch.CHANGELOG.md
entry for the fix.Are you creating a new feature?
develop
branch, and submit against that branch.CHANGELOG.md
entry for the new feature.Is this related to quality assurance?
Is this related to documentation?