Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Delegate quoteIdentifier operation to quoteIdentifierChain #233

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions src/Adapter/Platform/AbstractPlatform.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<?php

/**
* Zend Framework (http://framework.zend.com/).
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
*
* @copyright Copyright (c) 2005-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @see http://github.com/zendframework/zend-db for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Db\Adapter\Platform;
Expand All @@ -33,7 +29,7 @@ abstract class AbstractPlatform implements PlatformInterface
*/
public function quoteIdentifierInFragment($identifier, array $safeWords = [])
{
if (!$this->quoteIdentifiers) {
if (! $this->quoteIdentifiers) {
return $identifier;
}

Expand All @@ -56,8 +52,8 @@ public function quoteIdentifierInFragment($identifier, array $safeWords = [])
$identifier .= isset($safeWordsInt[strtolower($part)])
? $part
: $this->quoteIdentifier[0]
.str_replace($this->quoteIdentifier[0], $this->quoteIdentifierTo, $part)
.$this->quoteIdentifier[1];
. str_replace($this->quoteIdentifier[0], $this->quoteIdentifierTo, $part)
. $this->quoteIdentifier[1];
}

return $identifier;
Expand All @@ -80,17 +76,17 @@ public function quoteIdentifierChain($identifierChain)
$identifierChain = [$identifierChain];
}

if (!$this->quoteIdentifiers) {
if (! $this->quoteIdentifiers) {
return implode($this->getIdentifierSeparator(), $identifierChain);
}

/** @var array $identifierChain */
foreach ($identifierChain as $key => $identifier) {
$identifierChain[$key] = str_replace($this->quoteIdentifier[0], $this->quoteIdentifierTo, $identifier);
}
$chainGlue = $this->quoteIdentifier[1].$this->getIdentifierSeparator().$this->quoteIdentifier[0];
$chainGlue = $this->quoteIdentifier[1] . $this->getIdentifierSeparator() . $this->quoteIdentifier[0];

return $this->quoteIdentifier[0].implode($chainGlue, $identifierChain).$this->quoteIdentifier[1];
return $this->quoteIdentifier[0] . implode($chainGlue, $identifierChain) . $this->quoteIdentifier[1];
}

/**
Expand All @@ -115,19 +111,18 @@ public function getQuoteValueSymbol()
public function quoteValue($value)
{
trigger_error(
'Attempting to quote a value in '.get_class($this).
'Attempting to quote a value in ' . get_class($this) .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use sprintf here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can. Was not sure if you wanted it saved in variable or not. Made it into parameter. And code standard for dot at beginning of line does not seem to apply here, since no equal sign so I put it at the end.

' without extension/driver support can introduce security vulnerabilities in a production environment'
);

return '\''.addcslashes((string) $value, "\x00\n\r\\'\"\x1a").'\'';
return '\'' . addcslashes((string) $value, "\x00\n\r\\'\"\x1a") . '\'';
}

/**
* {@inheritDoc}
*/
public function quoteTrustedValue($value)
{
return '\''.addcslashes((string) $value, "\x00\n\r\\'\"\x1a").'\'';
return '\'' . addcslashes((string) $value, "\x00\n\r\\'\"\x1a") . '\'';
}

/**
Expand Down
8 changes: 3 additions & 5 deletions src/Adapter/Platform/Mysql.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @see http://github.com/zendframework/zend-db for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Db\Adapter\Platform;
Expand Down
8 changes: 3 additions & 5 deletions src/Adapter/Platform/Oracle.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @see http://github.com/zendframework/zend-db for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Db\Adapter\Platform;
Expand Down
8 changes: 3 additions & 5 deletions src/Adapter/Platform/Postgresql.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @see http://github.com/zendframework/zend-db for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Db\Adapter\Platform;
Expand Down
8 changes: 3 additions & 5 deletions src/Adapter/Platform/SqlServer.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @see http://github.com/zendframework/zend-db for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Db\Adapter\Platform;
Expand Down
8 changes: 3 additions & 5 deletions src/Sql/AbstractSql.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @see http://github.com/zendframework/zend-db for the canonical source repository
* @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://github.com/zendframework/zend-db/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Db\Sql;
Expand Down