1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link http://www.yiiframework.com/ |
4
|
|
|
* @copyright Copyright (c) 2008 Yii Software LLC |
5
|
|
|
* @license http://www.yiiframework.com/license/ |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace edgardmessias\db\firebird; |
9
|
|
|
|
10
|
|
|
use yii\db\Expression; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* |
14
|
|
|
* @author Edgard Lorraine Messias <[email protected]> |
15
|
|
|
* @since 2.0 |
16
|
|
|
*/ |
17
|
|
|
class ColumnSchema extends \yii\db\ColumnSchema |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Converts the input value according to [[phpType]] after retrieval from the database. |
22
|
|
|
* If the value is null or an [[Expression]], it will not be converted. |
23
|
|
|
* @param mixed $value input value |
24
|
|
|
* @return mixed converted value |
25
|
|
|
* @since 2.0.3 |
26
|
|
|
*/ |
27
|
98 |
|
protected function typecast($value) |
28
|
|
|
{ |
29
|
|
|
if ($value === '' |
30
|
98 |
|
&& !in_array( |
31
|
1 |
|
$this->type, |
32
|
|
|
[ |
33
|
98 |
|
Schema::TYPE_TEXT, |
34
|
94 |
|
Schema::TYPE_STRING, |
35
|
|
|
Schema::TYPE_BINARY, |
36
|
|
|
Schema::TYPE_CHAR |
37
|
87 |
|
], |
38
|
87 |
|
true) |
39
|
87 |
|
) { |
40
|
42 |
|
return null; |
41
|
|
|
} |
42
|
|
|
|
43
|
42 |
|
if ($value === null |
44
|
|
|
|| gettype($value) === $this->phpType |
45
|
2 |
|
|| $value instanceof ExpressionInterface |
|
|
|
|
46
|
|
|
|| $value instanceof Query |
|
|
|
|
47
|
42 |
|
) { |
48
|
63 |
|
return $value; |
49
|
63 |
|
} |
50
|
3 |
|
|
51
|
|
|
if (is_array($value) |
52
|
63 |
|
&& count($value) === 2 |
53
|
16 |
|
&& isset($value[1]) |
54
|
|
|
&& in_array($value[1], $this->getPdoParamTypes(), true) |
55
|
16 |
|
) { |
56
|
16 |
|
return new \yii\db\PdoValue($value[0], $value[1]); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
switch ($this->phpType) { |
60
|
|
|
case 'resource': |
61
|
|
|
case 'string': |
62
|
|
|
if (is_resource($value)) { |
63
|
|
|
return $value; |
64
|
|
|
} |
65
|
|
|
if (is_float($value)) { |
66
|
|
|
// ensure type cast always has . as decimal separator in all locales |
67
|
|
|
return str_replace(',', '.', (string) $value); |
68
|
|
|
} |
69
|
|
|
return (string) $value; |
70
|
|
|
case 'integer': |
71
|
|
|
if (is_bool($value)) { |
72
|
|
|
return ($value) ? 1 : 0; |
73
|
|
|
} |
74
|
|
|
return (int) $value; |
75
|
|
|
case 'boolean': |
76
|
|
|
return (boolean) $value; |
77
|
|
|
case 'double': |
78
|
|
|
return (double) $value; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return $value; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return int[] array of numbers that represent possible PDO parameter types |
86
|
|
|
*/ |
87
|
|
|
private function getPdoParamTypes() |
|
|
|
|
88
|
|
|
{ |
89
|
|
|
return [\PDO::PARAM_BOOL, \PDO::PARAM_INT, \PDO::PARAM_STR, \PDO::PARAM_LOB, \PDO::PARAM_NULL, \PDO::PARAM_STMT]; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.