This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace RDV\Bundle\MigrationBundle\Migration\Extension; |
||
4 | |||
5 | use Doctrine\DBAL\Platforms\AbstractPlatform; |
||
6 | use Doctrine\DBAL\Schema\ForeignKeyConstraint; |
||
7 | use Doctrine\DBAL\Schema\Index; |
||
8 | use Doctrine\DBAL\Schema\Schema; |
||
9 | use Doctrine\DBAL\Schema\Table; |
||
10 | use Doctrine\DBAL\Schema\TableDiff; |
||
11 | use RDV\Bundle\MigrationBundle\Migration\QueryBag; |
||
12 | use RDV\Bundle\MigrationBundle\Migration\Schema\Column; |
||
13 | use RDV\Bundle\MigrationBundle\Migration\SqlMigrationQuery; |
||
14 | use RDV\Bundle\MigrationBundle\Tools\DbIdentifierNameGenerator; |
||
15 | |||
16 | class RenameExtension implements DatabasePlatformAwareInterface, NameGeneratorAwareInterface |
||
17 | { |
||
18 | /** |
||
19 | * @var AbstractPlatform |
||
20 | */ |
||
21 | protected $platform; |
||
22 | |||
23 | /** |
||
24 | * @var DbIdentifierNameGenerator |
||
25 | */ |
||
26 | protected $nameGenerator; |
||
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | public function setDatabasePlatform(AbstractPlatform $platform) |
||
32 | { |
||
33 | $this->platform = $platform; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | public function setNameGenerator(DbIdentifierNameGenerator $nameGenerator) |
||
40 | { |
||
41 | $this->nameGenerator = $nameGenerator; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Renames a table |
||
46 | * |
||
47 | * @param Schema $schema |
||
48 | * @param QueryBag $queries |
||
49 | * @param string $oldTableName |
||
50 | * @param string $newTableName |
||
51 | */ |
||
52 | public function renameTable(Schema $schema, QueryBag $queries, $oldTableName, $newTableName) |
||
53 | { |
||
54 | $table = $schema->getTable($oldTableName); |
||
55 | $diff = new TableDiff($table->getName()); |
||
56 | $diff->newName = $newTableName; |
||
57 | |||
58 | $renameQuery = new SqlMigrationQuery( |
||
59 | $this->platform->getAlterTableSQL($diff) |
||
60 | ); |
||
61 | |||
62 | $queries->addQuery($renameQuery); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Renames a column |
||
67 | * |
||
68 | * @param Schema $schema |
||
69 | * @param QueryBag $queries |
||
70 | * @param Table $table |
||
71 | * @param string $oldColumnName |
||
72 | * @param string $newColumnName |
||
73 | */ |
||
74 | public function renameColumn(Schema $schema, QueryBag $queries, Table $table, $oldColumnName, $newColumnName) |
||
0 ignored issues
–
show
|
|||
75 | { |
||
76 | $column = new Column(['column' => $table->getColumn($oldColumnName)]); |
||
77 | $column->changeName($newColumnName); |
||
78 | $diff = new TableDiff($table->getName()); |
||
79 | $diff->renamedColumns = [$oldColumnName => $column]; |
||
0 ignored issues
–
show
It seems like
array($oldColumnName => $column) of type array<string,object<RDV\...gration\Schema\Column>> is incompatible with the declared type array<integer,object<Doc...ne\DBAL\Schema\Column>> of property $renamedColumns .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
80 | |||
81 | $renameQuery = new SqlMigrationQuery( |
||
82 | $this->platform->getAlterTableSQL($diff) |
||
83 | ); |
||
84 | |||
85 | $queries->addQuery($renameQuery); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Create an index without check of table and columns existence. |
||
90 | * This method can be helpful when you need to create an index for renamed table or column |
||
91 | * |
||
92 | * @param Schema $schema |
||
93 | * @param QueryBag $queries |
||
94 | * @param string $tableName |
||
95 | * @param string[] $columnNames |
||
96 | * @param string|null $indexName |
||
97 | */ |
||
98 | View Code Duplication | public function addIndex( |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
99 | Schema $schema, |
||
0 ignored issues
–
show
|
|||
100 | QueryBag $queries, |
||
101 | $tableName, |
||
102 | array $columnNames, |
||
103 | $indexName = null |
||
104 | ) { |
||
105 | if (!$indexName) { |
||
0 ignored issues
–
show
The expression
$indexName of type string|null is loosely compared to false ; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.
In PHP, under loose comparison (like For '' == false // true
'' == null // true
'ab' == false // false
'ab' == null // false
// It is often better to use strict comparison
'' === false // false
'' === null // false
![]() |
|||
106 | $indexName = $this->nameGenerator->generateIndexName($tableName, $columnNames); |
||
107 | } |
||
108 | $index = new Index($indexName, $columnNames); |
||
109 | $diff = new TableDiff($tableName); |
||
110 | $diff->addedIndexes = [$indexName => $index]; |
||
0 ignored issues
–
show
It seems like
array($indexName => $index) of type array<string,object<Doctrine\DBAL\Schema\Index>> is incompatible with the declared type array<integer,object<Doctrine\DBAL\Schema\Index>> of property $addedIndexes .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
111 | |||
112 | $renameQuery = new SqlMigrationQuery( |
||
113 | $this->platform->getAlterTableSQL($diff) |
||
114 | ); |
||
115 | |||
116 | $queries->addQuery($renameQuery); |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * Create an unique index without check of table and columns existence. |
||
121 | * This method can be helpful when you need to create an index for renamed table or column |
||
122 | * |
||
123 | * @param Schema $schema |
||
124 | * @param QueryBag $queries |
||
125 | * @param string $tableName |
||
126 | * @param string[] $columnNames |
||
127 | * @param string|null $indexName |
||
128 | */ |
||
129 | View Code Duplication | public function addUniqueIndex( |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
130 | Schema $schema, |
||
0 ignored issues
–
show
|
|||
131 | QueryBag $queries, |
||
132 | $tableName, |
||
133 | array $columnNames, |
||
134 | $indexName = null |
||
135 | ) { |
||
136 | if (!$indexName) { |
||
0 ignored issues
–
show
The expression
$indexName of type string|null is loosely compared to false ; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.
In PHP, under loose comparison (like For '' == false // true
'' == null // true
'ab' == false // false
'ab' == null // false
// It is often better to use strict comparison
'' === false // false
'' === null // false
![]() |
|||
137 | $indexName = $this->nameGenerator->generateIndexName($tableName, $columnNames, true); |
||
138 | } |
||
139 | $index = new Index($indexName, $columnNames, true); |
||
140 | $diff = new TableDiff($tableName); |
||
141 | $diff->addedIndexes = [$indexName => $index]; |
||
0 ignored issues
–
show
It seems like
array($indexName => $index) of type array<string,object<Doctrine\DBAL\Schema\Index>> is incompatible with the declared type array<integer,object<Doctrine\DBAL\Schema\Index>> of property $addedIndexes .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
142 | |||
143 | $renameQuery = new SqlMigrationQuery( |
||
144 | $this->platform->getAlterTableSQL($diff) |
||
145 | ); |
||
146 | |||
147 | $queries->addQuery($renameQuery); |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * Create a foreign key constraint without check of table and columns existence. |
||
152 | * This method can be helpful when you need to create a constraint for renamed table or column |
||
153 | * |
||
154 | * @param Schema $schema |
||
155 | * @param QueryBag $queries |
||
156 | * @param string $tableName |
||
157 | * @param string $foreignTable |
||
158 | * @param string[] $localColumnNames |
||
159 | * @param string[] $foreignColumnNames |
||
160 | * @param array $options |
||
161 | * @param string|null $constraintName |
||
162 | */ |
||
163 | public function addForeignKeyConstraint( |
||
164 | Schema $schema, |
||
0 ignored issues
–
show
|
|||
165 | QueryBag $queries, |
||
166 | $tableName, |
||
167 | $foreignTable, |
||
168 | array $localColumnNames, |
||
169 | array $foreignColumnNames, |
||
170 | array $options = [], |
||
171 | $constraintName = null |
||
172 | ) { |
||
173 | if (!$constraintName) { |
||
0 ignored issues
–
show
The expression
$constraintName of type string|null is loosely compared to false ; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.
In PHP, under loose comparison (like For '' == false // true
'' == null // true
'ab' == false // false
'ab' == null // false
// It is often better to use strict comparison
'' === false // false
'' === null // false
![]() |
|||
174 | $constraintName = $this->nameGenerator->generateForeignKeyConstraintName( |
||
175 | $tableName, |
||
176 | $localColumnNames |
||
177 | ); |
||
178 | } |
||
179 | $constraint = new ForeignKeyConstraint( |
||
180 | $localColumnNames, |
||
181 | $foreignTable, |
||
182 | $foreignColumnNames, |
||
183 | $constraintName, |
||
184 | $options |
||
185 | ); |
||
186 | $diff = new TableDiff($tableName); |
||
187 | $diff->addedForeignKeys = [$constraintName => $constraint]; |
||
0 ignored issues
–
show
It seems like
array($constraintName => $constraint) of type array<string,object<Doct...\ForeignKeyConstraint>> is incompatible with the declared type array<integer,object<Doc...\ForeignKeyConstraint>> of property $addedForeignKeys .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
188 | |||
189 | $renameQuery = new SqlMigrationQuery( |
||
190 | $this->platform->getAlterTableSQL($diff) |
||
191 | ); |
||
192 | |||
193 | $queries->addQuery($renameQuery); |
||
194 | } |
||
195 | } |
||
196 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.