SemanticMediaWiki /
SemanticApprovedRevs
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace SMW\ApprovedRevs\PropertyAnnotators; |
||||||
| 4 | |||||||
| 5 | use SMW\DIProperty; |
||||||
| 6 | use SMW\SemanticData; |
||||||
| 7 | use SMWDITime as DITime;; |
||||||
| 8 | use SMW\ApprovedRevs\DatabaseLogReader; |
||||||
| 9 | use SMW\ApprovedRevs\PropertyRegistry; |
||||||
| 10 | use User; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 11 | |||||||
| 12 | /** |
||||||
| 13 | * @private |
||||||
| 14 | * |
||||||
| 15 | * @license GNU GPL v2+ |
||||||
| 16 | */ |
||||||
| 17 | class ApprovedDatePropertyAnnotator { |
||||||
| 18 | |||||||
| 19 | /** |
||||||
| 20 | * @var DatabaseLogReader |
||||||
| 21 | */ |
||||||
| 22 | private $databaseLogReader; |
||||||
| 23 | |||||||
| 24 | /** |
||||||
| 25 | * @var Integer|null |
||||||
| 26 | */ |
||||||
| 27 | private $approvedDate; |
||||||
| 28 | |||||||
| 29 | /** |
||||||
| 30 | * @param DatabaseLogReader $databaseLogReader |
||||||
| 31 | */ |
||||||
| 32 | 3 | public function __construct( DatabaseLogReader $databaseLogReader ) { |
|||||
| 33 | 3 | $this->databaseLogReader = $databaseLogReader; |
|||||
| 34 | 3 | } |
|||||
| 35 | |||||||
| 36 | /** |
||||||
| 37 | * @since 1.0 |
||||||
| 38 | * |
||||||
| 39 | * @param integer $approvedDate |
||||||
| 40 | */ |
||||||
| 41 | 2 | public function setApprovedDate( $approvedDate ) { |
|||||
| 42 | 2 | $this->approvedDate = $approvedDate; |
|||||
| 43 | 2 | } |
|||||
| 44 | |||||||
| 45 | /** |
||||||
| 46 | * @since 1.0 |
||||||
| 47 | * |
||||||
| 48 | * @return DIProperty |
||||||
| 49 | */ |
||||||
| 50 | 2 | public function newDIProperty() { |
|||||
| 51 | 2 | return new DIProperty( PropertyRegistry::SAR_PROP_APPROVED_DATE ); |
|||||
| 52 | } |
||||||
| 53 | |||||||
| 54 | /** |
||||||
| 55 | * @since 1.0 |
||||||
| 56 | * |
||||||
| 57 | * @param SemanticData $semanticData |
||||||
| 58 | */ |
||||||
| 59 | 2 | public function addAnnotation( SemanticData $semanticData ) { |
|||||
| 60 | |||||||
| 61 | 2 | if ( $this->approvedDate === null ) { |
|||||
| 62 | $this->approvedDate = $this->databaseLogReader->getDateOfLogEntry( |
||||||
|
0 ignored issues
–
show
It seems like
$this->databaseLogReader...getTitle(), 'approval') of type SMW\ApprovedRevs\Timestamp is incompatible with the declared type integer|null of property $approvedDate.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||||||
| 63 | $semanticData->getSubject()->getTitle(), |
||||||
| 64 | 'approval' |
||||||
| 65 | ); |
||||||
| 66 | } |
||||||
| 67 | |||||||
| 68 | 2 | $property = $this->newDIProperty(); |
|||||
| 69 | 2 | $dataItem = $this->newDITime(); |
|||||
| 70 | 2 | $semanticData->removeProperty( $property ); |
|||||
| 71 | |||||||
| 72 | 2 | if ( $dataItem ) { |
|||||
| 73 | 1 | $semanticData->addPropertyObjectValue( $property, $dataItem ); |
|||||
| 74 | } |
||||||
| 75 | 2 | } |
|||||
| 76 | |||||||
| 77 | 2 | private function newDITime() { |
|||||
| 78 | |||||||
| 79 | 2 | if ( $this->approvedDate === null || is_bool( $this->approvedDate ) ) { |
|||||
| 80 | 1 | return; |
|||||
| 81 | } |
||||||
| 82 | |||||||
| 83 | 1 | $date = $this->approvedDate; |
|||||
| 84 | |||||||
| 85 | 1 | return new DITime( |
|||||
| 86 | 1 | DITime::CM_GREGORIAN, |
|||||
| 87 | 1 | $date->format( 'Y' ), |
|||||
|
0 ignored issues
–
show
The method
format() does not exist on integer.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 88 | 1 | $date->format( 'm' ), |
|||||
| 89 | 1 | $date->format( 'd' ), |
|||||
| 90 | 1 | $date->format( 'H' ), |
|||||
| 91 | 1 | $date->format( 'i' ) |
|||||
| 92 | ); |
||||||
| 93 | } |
||||||
| 94 | |||||||
| 95 | } |
||||||
| 96 |
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