Avoid using static access to class '\Illuminate\Support\Facades\Schema' in method 'down'. Open
Schema::table('consultation_user', function (Blueprint $table) {
$table->unique(['user_id', 'consultation_id'], 'consultation_user_unique');
});
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'DB' in method 'up'. Open
DB::statement('ALTER TABLE `consultation_user` DROP INDEX `consultation_user_unique`, ADD INDEX (user_id, consultation_id)');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Illuminate\Support\Facades\Schema' in method 'up'. Open
Schema::table('consultation_user', function (Blueprint $table) {
$table->dropUnique('consultation_user_unique');
});
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'DB' in method 'up'. Open
if (DB::connection() instanceof MySqlConnection) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method up uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
Schema::table('consultation_user', function (Blueprint $table) {
$table->dropUnique('consultation_user_unique');
});
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Parameter $table
has undeclared type \Illuminate\Database\Schema\Blueprint
Open
Schema::table('consultation_user', function (Blueprint $table) {
- Exclude checks
Checking instanceof against undeclared class \Illuminate\Database\MySqlConnection
Open
if (DB::connection() instanceof MySqlConnection) {
- Exclude checks
Class extends undeclared class \Illuminate\Database\Migrations\Migration
Open
class RemoveUniqueIndexInConsultaionUserTable extends Migration
- Exclude checks
Call to method statement
from undeclared class \DB
Open
DB::statement('ALTER TABLE `consultation_user` DROP INDEX `consultation_user_unique`, ADD INDEX (user_id, consultation_id)');
- Exclude checks
Call to method table
from undeclared class \Illuminate\Support\Facades\Schema
Open
Schema::table('consultation_user', function (Blueprint $table) {
- Exclude checks
Call to method table
from undeclared class \Illuminate\Support\Facades\Schema
Open
Schema::table('consultation_user', function (Blueprint $table) {
- Exclude checks
Call to method connection
from undeclared class \DB
Open
if (DB::connection() instanceof MySqlConnection) {
- Exclude checks
Call to method dropUnique
from undeclared class \Illuminate\Database\Schema\Blueprint
Open
$table->dropUnique('consultation_user_unique');
- Exclude checks
Parameter $table
has undeclared type \Illuminate\Database\Schema\Blueprint
Open
Schema::table('consultation_user', function (Blueprint $table) {
- Exclude checks
Call to method unique
from undeclared class \Illuminate\Database\Schema\Blueprint
Open
$table->unique(['user_id', 'consultation_id'], 'consultation_user_unique');
- Exclude checks
Avoid using short method names like RemoveUniqueIndexInConsultaionUserTable::up(). The configured minimum method name length is 3. Open
public function up()
{
if (DB::connection() instanceof MySqlConnection) {
DB::statement('ALTER TABLE `consultation_user` DROP INDEX `consultation_user_unique`, ADD INDEX (user_id, consultation_id)');
} else {
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class RemoveUniqueIndexInConsultaionUserTable extends Migration
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
DB::statement('ALTER TABLE `consultation_user` DROP INDEX `consultation_user_unique`, ADD INDEX (user_id, consultation_id)');
- Exclude checks