vaened /
laravel-searcher
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Created by enea dhack - 29/12/2019 12:15. |
||
| 4 | */ |
||
| 5 | |||
| 6 | namespace Vaened\Searcher\Dates; |
||
| 7 | |||
| 8 | abstract class Dateable implements BetweenDatesContract |
||
| 9 | { |
||
| 10 | public function getRange(): array |
||
| 11 | { |
||
| 12 | return [ |
||
| 13 | $this->getStartDate(), |
||
| 14 | $this->getEndDate(), |
||
| 15 | ]; |
||
| 16 | } |
||
| 17 | |||
| 18 | public function getFormattedStartDate(): string |
||
| 19 | { |
||
| 20 | return $this->getDateFormat()->apply($this->getStartDate()); |
||
| 21 | } |
||
| 22 | |||
| 23 | public function getFormattedEndDate(): string |
||
| 24 | { |
||
| 25 | return $this->getDateFormat()->apply($this->getEndDate()); |
||
| 26 | } |
||
| 27 | |||
| 28 | protected function getDateFormat(): Format |
||
|
0 ignored issues
–
show
|
|||
| 29 | { |
||
| 30 | return Format::YMD_HIS(); |
||
| 31 | } |
||
| 32 | |||
| 33 | public function toArray() |
||
| 34 | { |
||
| 35 | return [ |
||
|
0 ignored issues
–
show
The expression
return array('start' => ...getFormattedEndDate())) returns the type array<string,Carbon\Carbon|array<string,string>> which is incompatible with the return type mandated by Illuminate\Contracts\Support\Arrayable::toArray() of Illuminate\Contracts\Support\TValue[].
In the issue above, the returned value is violating the contract defined by the mentioned interface. Let's take a look at an example: interface HasName {
/** @return string */
public function getName();
}
class Name {
public $name;
}
class User implements HasName {
/** @return string|Name */
public function getName() {
return new Name('foo'); // This is a violation of the ``HasName`` interface
// which only allows a string value to be returned.
}
}
Loading history...
|
|||
| 36 | 'start' => $this->getStartDate(), |
||
| 37 | 'end' => $this->getEndDate(), |
||
| 38 | 'format' => [ |
||
| 39 | 'start' => $this->getFormattedStartDate(), |
||
| 40 | 'end' => $this->getFormattedEndDate(), |
||
| 41 | ], |
||
| 42 | ]; |
||
| 43 | } |
||
| 44 | |||
| 45 | public function toJson($options = 0) |
||
| 46 | { |
||
| 47 | return json_encode($this->toArray(), $options); |
||
| 48 | } |
||
| 49 | |||
| 50 | public function jsonSerialize() |
||
| 51 | { |
||
| 52 | return $this->toArray(); |
||
| 53 | } |
||
| 54 | } |
||
| 55 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths