for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Install GitHub App
<?php
namespace Backpack\CRUD\app\Library\Components\Attributes;
use Backpack\CRUD\app\Library\Components\AttributeCollection;
use Backpack\CRUD\app\Library\Components\Interfaces\AttributeInterface;
class MultipleAttribute extends BaseAttribute implements AttributeInterface
{
public static function getDefault(AttributeCollection $attributes)
switch ($attributes->getAttributeValue('relation_type')) {
case 'BelongsToMany':
case 'HasMany':
case 'HasManyThrough':
case 'HasOneOrMany':
case 'MorphMany':
case 'MorphOneOrMany':
case 'MorphToMany':
return true;
default:
return false;
}
return false
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.
return
die
exit
function fx() { try { doSomething(); return true; } catch (\Exception $e) { return false; } return false; }
In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.
public static function getValidationRules(): array
return ['nullable|string'];
public static function getAttributeName(): string
return 'relation_type';
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.