Avoid using static access to class '\Illuminate\Support\Facades\Storage' in method 'getLogotypeUrlAttribute'. Open
$logotype = Storage::url(trim($this->attributes['logotype_path'], '/'));
- 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 '\EscolaLms\Consultations\Database\Factories\ConsultationFactory' in method 'newFactory'. Open
return ConsultationFactory::new();
- 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\Storage' in method 'getImageUrlAttribute'. Open
$imagePath = Storage::url($path);
- 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
Define a constant instead of duplicating this literal "image_path" 3 times. Open
'image_path',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "logotype_path" 4 times. Open
'logotype_path',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Avoid unused local variables such as '$oa'. Open
return preg_match('/^(http|https):.*$/', $logotype, $oa) ?
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused local variables such as '$oa'. Open
return preg_match('/^(http|https):.*$/', $imagePath, $oa) ?
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Return type of author()
is undeclared type \Illuminate\Database\Eloquent\Relations\BelongsTo
Open
public function author(): BelongsTo
- Exclude checks
Return type of terms()
is undeclared type \Illuminate\Database\Eloquent\Relations\HasMany
Open
public function terms(): HasMany
- Exclude checks
Reference to undeclared property \EscolaLms\Consultations\Models\Consultation->attributes
Open
if ($this->attributes['logotype_path'] ?? null) {
- Exclude checks
Call to undeclared method \EscolaLms\Consultations\Models\Consultation::belongsToMany
Open
return $this->belongsToMany(Category::class);
- Exclude checks
Call to method url
from undeclared class \Illuminate\Support\Facades\Storage
Open
$imagePath = Storage::url($path);
- Exclude checks
Return type of proposedTerms()
is undeclared type \Illuminate\Database\Eloquent\Relations\HasMany
Open
public function proposedTerms(): HasMany
- Exclude checks
Reference to undeclared property \EscolaLms\Consultations\Models\Consultation->attributes
Open
$path = trim(trim($this->attributes['logotype_path'], '/'));
- Exclude checks
Call to method url
from undeclared class \Illuminate\Support\Facades\Storage
Open
$logotype = Storage::url(trim($this->attributes['logotype_path'], '/'));
- Exclude checks
Call to undeclared function \app()
Open
$consultationServiceContract = app(ConsultationServiceContract::class);
- Exclude checks
Call to undeclared method \EscolaLms\Consultations\Models\Consultation::belongsToMany
Open
return $this->belongsToMany(User::class, 'consultation_teachers', 'consultation_id', 'teacher_id');
- Exclude checks
Reference to constant class
from undeclared class \EscolaLms\Categories\Models\Category
Open
return $this->belongsToMany(Category::class);
- Exclude checks
Call to undeclared function \url()
Open
url($logotype);
- Exclude checks
Reference to undeclared property \EscolaLms\Consultations\Models\Consultation->attributes
Open
if ($this->attributes['image_path'] ?? null) {
- Exclude checks
Class uses undeclared trait \EscolaLms\ModelFields\Traits\ModelFields
Open
class Consultation extends Model
- Exclude checks
Return type of categories()
is undeclared type \Illuminate\Database\Eloquent\Relations\BelongsToMany
Open
public function categories(): BelongsToMany
- Exclude checks
Call to undeclared method \EscolaLms\Consultations\Models\Consultation::hasMany
Open
return $this->hasMany(ConsultationUserPivot::class);
- Exclude checks
Call to undeclared function \url()
Open
url($imagePath);
- Exclude checks
Static call to undeclared method \EscolaLms\Consultations\Database\Factories\ConsultationFactory::new
Open
return ConsultationFactory::new();
- Exclude checks
Return type of teachers()
is undeclared type \Illuminate\Database\Eloquent\Relations\BelongsToMany
Open
public function teachers(): BelongsToMany
- Exclude checks
Possibly zero references to use statement for classlike/namespace CoreUser
(\EscolaLms\Core\Models\User)
Open
use EscolaLms\Core\Models\User as CoreUser;
- Exclude checks
Class extends undeclared class \Illuminate\Database\Eloquent\Model
Open
class Consultation extends Model
- Exclude checks
Class uses undeclared trait \Illuminate\Database\Eloquent\Factories\HasFactory
Open
class Consultation extends Model
- Exclude checks
Reference to undeclared property \EscolaLms\Consultations\Models\Consultation->attributes
Open
$path = trim(trim($this->attributes['image_path'], '/'));
- Exclude checks
Call to undeclared method \EscolaLms\Consultations\Models\Consultation::belongsTo
Open
return $this->belongsTo(User::class, 'author_id');
- Exclude checks
Return type of users()
is undeclared type \Illuminate\Database\Eloquent\Relations\BelongsToMany
Open
public function users(): BelongsToMany
- Exclude checks
Call to undeclared method \EscolaLms\Consultations\Models\Consultation::belongsToMany
Open
return $this->belongsToMany(User::class, 'consultation_user');
- Exclude checks
Call to undeclared method \EscolaLms\Consultations\Models\Consultation::hasMany
Open
return $this->hasMany(ConsultationProposedTerm::class, 'consultation_id');
- Exclude checks
Reference to undeclared property \EscolaLms\Consultations\Models\Consultation->attributes
Open
$logotype = Storage::url(trim($this->attributes['logotype_path'], '/'));
- Exclude checks
Reference to undeclared property \EscolaLms\Consultations\Models\Consultation->duration
Open
return $this->duration ?? '0';
- Exclude checks
Avoid excessively long variable names like $consultationServiceContract. Keep variable name length under 20. Open
$consultationServiceContract = app(ConsultationServiceContract::class);
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid variables with short names like $oa. Configured minimum length is 3. Open
return preg_match('/^(http|https):.*$/', $logotype, $oa) ?
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $oa. Configured minimum length is 3. Open
return preg_match('/^(http|https):.*$/', $imagePath, $oa) ?
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
There must be one blank line after the last USE statement; 2 found; Open
use EscolaLms\Core\Models\User as CoreUser;
- Exclude checks