Skip to content

Commit

Permalink
Rename all methods to camelCase (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Aug 14, 2022
1 parent 5b3a93e commit 86ee209
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 108 deletions.
2 changes: 1 addition & 1 deletion docs/persistence/sql/queries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ Other Methods
$q->executeQuery(); // select calc_found_rows `name` from `test`
$q->mode('insert')->executeStatement(); // insert ignore into `test` (`name`) values (`name` = 'John')

.. php:method:: _set_args($what, $alias, $value)
.. php:method:: _setArgs($what, $alias, $value)
Internal method which sets value in :php:attr:`Expression::args` array.
It doesn't allow duplicate aliases and throws Exception in such case.
Expand Down
15 changes: 10 additions & 5 deletions src/Persistence/Sql/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,20 @@ function ($matches) use (&$namelessCount) {

// use rendering only with named tags
}
$fx = '_render_' . $identifier;

if (array_key_exists($identifier, $this->args['custom'])) {
$value = $this->consume($this->args['custom'][$identifier], $escapeMode);
} elseif (method_exists($this, $fx)) {
$value = $this->{$fx}();
} else {
throw (new Exception('Expression could not render tag'))
->addMoreInfo('tag', $identifier);
$renderMethodName = !is_int($identifier) ? '_render' . ucfirst($identifier) : null;
if ($renderMethodName !== null
&& method_exists($this, $renderMethodName)
&& (new \ReflectionMethod($this, $renderMethodName))->getName() === $renderMethodName
) {
$value = $this->{$renderMethodName}();
} else {
throw (new Exception('Expression could not render tag'))
->addMoreInfo('tag', $identifier);
}
}

return $value;
Expand Down
16 changes: 8 additions & 8 deletions src/Persistence/Sql/Mssql/ExpressionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ public function execute(object $connection = null, bool $fromExecuteStatement =

$expectedInsertTemplate = <<<'EOF'
begin try
insert[option] into [table_noalias] ([set_fields]) values ([set_values]);
insert[option] into [tableNoalias] ([setFields]) values ([setValues]);
end try begin catch
if ERROR_NUMBER() = 544 begin
set IDENTITY_INSERT [table_noalias] on;
set IDENTITY_INSERT [tableNoalias] on;
begin try
insert[option] into [table_noalias] ([set_fields]) values ([set_values]);
set IDENTITY_INSERT [table_noalias] off;
insert[option] into [tableNoalias] ([setFields]) values ([setValues]);
set IDENTITY_INSERT [tableNoalias] off;
end try begin catch
set IDENTITY_INSERT [table_noalias] off;
set IDENTITY_INSERT [tableNoalias] off;
throw;
end catch
end else begin
Expand All @@ -71,10 +71,10 @@ public function execute(object $connection = null, bool $fromExecuteStatement =
$eDriver = $e->getPrevious();
if ($eDriver !== null && $eDriver instanceof DriverException && $eDriver->getCode() === 544) {
try {
return $executeFx('set IDENTITY_INSERT [table_noalias] on;' . "\n"
. 'insert[option] into [table_noalias] ([set_fields]) values ([set_values]);');
return $executeFx('set IDENTITY_INSERT [tableNoalias] on;' . "\n"
. 'insert[option] into [tableNoalias] ([setFields]) values ([setValues]);');
} finally {
$executeFx('set IDENTITY_INSERT [table_noalias] off;');
$executeFx('set IDENTITY_INSERT [tableNoalias] off;');
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/Persistence/Sql/Mssql/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class Query extends BaseQuery

protected string $templateInsert = <<<'EOF'
begin try
insert[option] into [table_noalias] ([set_fields]) values ([set_values]);
insert[option] into [tableNoalias] ([setFields]) values ([setValues]);
end try begin catch
if ERROR_NUMBER() = 544 begin
set IDENTITY_INSERT [table_noalias] on;
set IDENTITY_INSERT [tableNoalias] on;
begin try
insert[option] into [table_noalias] ([set_fields]) values ([set_values]);
set IDENTITY_INSERT [table_noalias] off;
insert[option] into [tableNoalias] ([setFields]) values ([setValues]);
set IDENTITY_INSERT [tableNoalias] off;
end try begin catch
set IDENTITY_INSERT [table_noalias] off;
set IDENTITY_INSERT [tableNoalias] off;
throw;
end catch
end else begin
Expand All @@ -32,7 +32,7 @@ class Query extends BaseQuery
end catch
EOF;

public function _render_limit(): ?string
protected function _renderLimit(): ?string
{
if (!isset($this->args['limit'])) {
return null;
Expand Down
6 changes: 3 additions & 3 deletions src/Persistence/Sql/Oracle/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function render(): array
return parent::render();
}

protected function _sub_render_condition(array $row): string
protected function _subrenderCondition(array $row): string
{
if (count($row) === 2) {
[$field, $value] = $row;
Expand Down Expand Up @@ -63,10 +63,10 @@ protected function _sub_render_condition(array $row): string
}
}

return parent::_sub_render_condition($row);
return parent::_subrenderCondition($row);
}

public function _render_limit(): ?string
protected function _renderLimit(): ?string
{
if (!isset($this->args['limit'])) {
return null;
Expand Down
6 changes: 3 additions & 3 deletions src/Persistence/Sql/Postgresql/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Query extends BaseQuery
protected string $templateUpdate = 'update [table][join] set [set] [where]';
protected string $templateReplace;

protected function _sub_render_condition(array $row): string
protected function _subrenderCondition(array $row): string
{
if (count($row) >= 3) {
[$field, $cond, $value] = $row;
Expand All @@ -25,10 +25,10 @@ protected function _sub_render_condition(array $row): string
}
}

return parent::_sub_render_condition($row);
return parent::_subrenderCondition($row);
}

public function _render_limit(): ?string
protected function _renderLimit(): ?string
{
if (!isset($this->args['limit'])) {
return null;
Expand Down

0 comments on commit 86ee209

Please sign in to comment.