for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SoareCostin\BladeFormComponents\Traits;
trait GluesAttributes
{
public function glueAttributes($attributesList = null)
if (is_null($attributesList)) {
$attributesList = $this->attributesList();
}
$pairs = collect($attributesList)->filter(function ($attr, $key) {
$key
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
$pairs = collect($attributesList)->filter(function ($attr, /** @scrutinizer ignore-unused */ $key) {
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
return isset($this->{$attr});
})
->filter(function ($attr, $key) {
->filter(function ($attr, /** @scrutinizer ignore-unused */ $key) {
return ! is_bool($this->{$attr}) || $this->{$attr} == true;
->map(function ($attr, $key) {
->map(function ($attr, /** @scrutinizer ignore-unused */ $key) {
if (is_array($this->{$attr})) {
return sprintf('%s="%s"', $attr, implode(' ', $this->{$attr}));
if (is_bool($this->{$attr})) {
return $attr;
return sprintf('%s="%s"', $attr, $this->{$attr});
});
$customAttributes = $this->customAttributes();
if (! empty($customAttributes)) {
$pairs = $pairs->merge(
collect($customAttributes)->map(function ($attr, $key) {
return sprintf('%s="%s"', $key, $attr);
);
return $pairs->implode(' ');
protected function attributesList()
return [];
protected function customAttributes()
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.