Skip to content

Commit c3d43aa

Browse files
author
ndm2
committed
Make the wannabe fully qualified namespaces in docblock tags actually fully qualified by adding leading backslashes.
Resolves #2870
1 parent 486fb89 commit c3d43aa

30 files changed

Lines changed: 2101 additions & 71 deletions

Connection.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ public function configName() {
139139
*
140140
* @param string|Driver $driver
141141
* @param array|null $config Either config for a new driver or null.
142-
* @throws Cake\Database\Exception\MissingDriverException When a driver class is missing.
143-
* @throws Cake\Database\Exception\MissingExtensionException When a driver's PHP extension is missing.
142+
* @throws \Cake\Database\Exception\MissingDriverException When a driver class is missing.
143+
* @throws \Cake\Database\Exception\MissingExtensionException When a driver's PHP extension is missing.
144144
* @return Driver
145145
*/
146146
public function driver($driver = null, $config = null) {
@@ -162,7 +162,7 @@ public function driver($driver = null, $config = null) {
162162
/**
163163
* Connects to the configured database
164164
*
165-
* @throws Cake\Database\Exception\MissingConnectionException if credentials are invalid
165+
* @throws \Cake\Database\Exception\MissingConnectionException if credentials are invalid
166166
* @return boolean true on success or false if already connected.
167167
*/
168168
public function connect() {
@@ -195,7 +195,7 @@ public function isConnected() {
195195
/**
196196
* Prepares a sql statement to be executed
197197
*
198-
* @param string|Cake\Database\Query $sql
198+
* @param string|\Cake\Database\Query $sql
199199
* @return \Cake\Database\Statement
200200
*/
201201
public function prepare($sql) {
@@ -252,7 +252,7 @@ public function newQuery() {
252252
/**
253253
* Get a Schema\Collection object for this connection.
254254
*
255-
* @return Cake\Database\Schema\Collection
255+
* @return \Cake\Database\Schema\Collection
256256
*/
257257
public function schemaCollection() {
258258
return new \Cake\Database\Schema\Collection($this);

Dialect/MysqlDialectTrait.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* PHP Version 5.4
4+
*
5+
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
6+
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
7+
*
8+
* Licensed under The MIT License
9+
* For full copyright and license information, please see the LICENSE.txt
10+
* Redistributions of files must retain the above copyright notice.
11+
*
12+
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
13+
* @link http://cakephp.org CakePHP(tm) Project
14+
* @since CakePHP(tm) v 3.0.0
15+
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
16+
*/
17+
namespace Cake\Database\Dialect;
18+
19+
use Cake\Database\SqlDialectTrait;
20+
21+
/**
22+
* Contains functions that encapsulates the SQL dialect used by MySQL,
23+
* including query translators and schema introspection.
24+
*/
25+
trait MysqlDialectTrait {
26+
27+
use SqlDialectTrait;
28+
29+
/**
30+
* String used to start a database identifier quoting to make it safe
31+
*
32+
* @var string
33+
*/
34+
protected $_startQuote = '`';
35+
36+
/**
37+
* String used to end a database identifier quoting to make it safe
38+
*
39+
* @var string
40+
*/
41+
protected $_endQuote = '`';
42+
43+
/**
44+
* The schema dialect class for this driver
45+
*
46+
* @var \Cake\Database\Schema\MysqlSchema
47+
*/
48+
protected $_schemaDialect;
49+
50+
/**
51+
* Get the schema dialect.
52+
*
53+
* Used by Cake\Database\Schema package to reflect schema and
54+
* generate schema.
55+
*
56+
* @return \Cake\Database\Schema\MysqlSchema
57+
*/
58+
public function schemaDialect() {
59+
if (!$this->_schemaDialect) {
60+
$this->_schemaDialect = new \Cake\Database\Schema\MysqlSchema($this);
61+
}
62+
return $this->_schemaDialect;
63+
}
64+
65+
}

Dialect/PostgresDialectTrait.php

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?php
2+
/**
3+
* PHP Version 5.4
4+
*
5+
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
6+
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
7+
*
8+
* Licensed under The MIT License
9+
* For full copyright and license information, please see the LICENSE.txt
10+
* Redistributions of files must retain the above copyright notice.
11+
*
12+
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
13+
* @link http://cakephp.org CakePHP(tm) Project
14+
* @since CakePHP(tm) v 3.0.0
15+
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
16+
*/
17+
namespace Cake\Database\Dialect;
18+
19+
use Cake\Database\Expression\FunctionExpression;
20+
use Cake\Database\Expression\UnaryExpression;
21+
use Cake\Database\Query;
22+
use Cake\Database\SqlDialectTrait;
23+
24+
/**
25+
* Contains functions that encapsulates the SQL dialect used by Postgres,
26+
* including query translators and schema introspection.
27+
*/
28+
trait PostgresDialectTrait {
29+
30+
use SqlDialectTrait;
31+
32+
/**
33+
* String used to start a database identifier quoting to make it safe
34+
*
35+
* @var string
36+
*/
37+
protected $_startQuote = '"';
38+
39+
/**
40+
* String used to end a database identifier quoting to make it safe
41+
*
42+
* @var string
43+
*/
44+
protected $_endQuote = '"';
45+
46+
/**
47+
* The schema dialect class for this driver
48+
*
49+
* @var \Cake\Database\Schema\PostgresSchema
50+
*/
51+
protected $_schemaDialect;
52+
53+
/**
54+
* Distinct clause needs no transformation
55+
*
56+
* @param Query $query The query to be transformed
57+
* @return Query
58+
*/
59+
protected function _transformDistinct($query) {
60+
return $query;
61+
}
62+
63+
/**
64+
* Modifies the original insert query to append a "RETURNING *" epilogue
65+
* so that the latest insert id can be retrieved
66+
*
67+
* @param \Cake\Database\Query $query
68+
* @return \Cake\Database\Query
69+
*/
70+
protected function _insertQueryTranslator($query) {
71+
if (!$query->clause('epilog')) {
72+
$query->epilog('RETURNING *');
73+
}
74+
return $query;
75+
}
76+
77+
/**
78+
* Returns an dictionary of expressions to be transformed when compiling a Query
79+
* to SQL. Array keys are method names to be called in this class
80+
*
81+
* @return array
82+
*/
83+
protected function _expressionTranslators() {
84+
$namespace = 'Cake\Database\Expression';
85+
return [
86+
$namespace . '\FunctionExpression' => '_transformFunctionExpression'
87+
];
88+
}
89+
90+
/**
91+
* Receives a FunctionExpression and changes it so that it conforms to this
92+
* SQL dialect.
93+
*
94+
* @param \Cake\Database\Expression\FunctionExpression
95+
* @return void
96+
*/
97+
protected function _transformFunctionExpression(FunctionExpression $expression) {
98+
switch ($expression->name()) {
99+
case 'CONCAT':
100+
// CONCAT function is expressed as exp1 || exp2
101+
$expression->name('')->type(' ||');
102+
break;
103+
case 'DATEDIFF':
104+
$expression
105+
->name('')
106+
->type('-')
107+
->iterateParts(function($p) {
108+
return new FunctionExpression('DATE', [$p['value']], [$p['type']]);
109+
});
110+
break;
111+
case 'CURRENT_DATE':
112+
$time = new FunctionExpression('LOCALTIMESTAMP', [' 0 ' => 'literal']);
113+
$expression->name('CAST')->type(' AS ')->add([$time, 'date' => 'literal']);
114+
break;
115+
case 'CURRENT_TIME':
116+
$time = new FunctionExpression('LOCALTIMESTAMP', [' 0 ' => 'literal']);
117+
$expression->name('CAST')->type(' AS ')->add([$time, 'time' => 'literal']);
118+
break;
119+
case 'NOW':
120+
$expression->name('LOCALTIMESTAMP')->add([' 0 ' => 'literal']);
121+
break;
122+
}
123+
}
124+
125+
/**
126+
* Get the schema dialect.
127+
*
128+
* Used by Cake\Database\Schema package to reflect schema and
129+
* generate schema.
130+
*
131+
* @return \Cake\Database\Schema\PostgresSchema
132+
*/
133+
public function schemaDialect() {
134+
if (!$this->_schemaDialect) {
135+
$this->_schemaDialect = new \Cake\Database\Schema\PostgresSchema($this);
136+
}
137+
return $this->_schemaDialect;
138+
}
139+
}

Dialect/SqliteDialectTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function _expressionTranslators() {
7070
* Receives a FunctionExpression and changes it so that it conforms to this
7171
* SQL dialect.
7272
*
73-
* @param Cake\Database\Expression\FunctionExpression
73+
* @param \Cake\Database\Expression\FunctionExpression
7474
* @return void
7575
*/
7676
protected function _transformFunctionExpression(FunctionExpression $expression) {
@@ -103,8 +103,8 @@ protected function _transformFunctionExpression(FunctionExpression $expression)
103103
* Receives a TupleExpression and changes it so that it conforms to this
104104
* SQL dialect.
105105
*
106-
* @param Cake\Database\Expression\TupleComparison $expression
107-
* @param Cake\Database\Query $query
106+
* @param \Cake\Database\Expression\TupleComparison $expression
107+
* @param \Cake\Database\Query $query
108108
* @return void
109109
*/
110110
protected function _transformTupleComparison(TupleComparison $expression, $query) {
@@ -154,7 +154,7 @@ protected function _transformTupleComparison(TupleComparison $expression, $query
154154
* The way SQLite works with multi insert is by having multiple select statements
155155
* joined with UNION.
156156
*
157-
* @param Cake\Database\Query $query The query to translate
157+
* @param \Cake\Database\Query $query The query to translate
158158
* @return Query
159159
*/
160160
protected function _insertQueryTranslator($query) {
@@ -197,7 +197,7 @@ protected function _insertQueryTranslator($query) {
197197
* Used by Cake\Database\Schema package to reflect schema and
198198
* generate schema.
199199
*
200-
* @return Cake\Database\Schema\SqliteSchema
200+
* @return \Cake\Database\Schema\SqliteSchema
201201
*/
202202
public function schemaDialect() {
203203
if (!$this->_schemaDialect) {

Driver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ public abstract function enabled();
9393
/**
9494
* Prepares a sql statement to be executed
9595
*
96-
* @param string|Cake\Database\Query $query
97-
* @return Cake\Database\Statement
96+
* @param string|\Cake\Database\Query $query
97+
* @return \Cake\Database\Statement
9898
*/
9999
public abstract function prepare($query);
100100

@@ -166,7 +166,7 @@ public abstract function queryTranslator($type);
166166
* If all the tables that use this Driver specify their
167167
* own schemas, then this may return null.
168168
*
169-
* @return Cake\Database\Schema\BaseSchema
169+
* @return \Cake\Database\Schema\BaseSchema
170170
*/
171171
public abstract function schemaDialect();
172172

Driver/PDODriverTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public function disconnect() {
7676
/**
7777
* Prepares a sql statement to be executed
7878
*
79-
* @param string|Cake\Database\Query $query
80-
* @return Cake\Database\Statement
79+
* @param string|\Cake\Database\Query $query
80+
* @return \Cake\Database\Statement
8181
*/
8282
public function prepare($query) {
8383
$this->connect();

Driver/Sqlite.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public function enabled() {
8585
/**
8686
* Prepares a sql statement to be executed
8787
*
88-
* @param string|Cake\Database\Query $query
89-
* @return Cake\Database\Statement
88+
* @param string|\Cake\Database\Query $query
89+
* @return \Cake\Database\Statement
9090
*/
9191
public function prepare($query) {
9292
$this->connect();

Expression/Comparison.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function getValue() {
110110
/**
111111
* Convert the expression into a SQL fragment.
112112
*
113-
* @param Cake\Database\ValueBinder $generator Placeholder generator object
113+
* @param \Cake\Database\ValueBinder $generator Placeholder generator object
114114
* @return string
115115
*/
116116
public function sql(ValueBinder $generator) {

0 commit comments

Comments
 (0)