| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace SMW\ApprovedRevs; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Psr\Log\LoggerAwareTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use SMW\DIProperty; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use SMW\SemanticData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use SMW\ApprovedRevs\PropertyAnnotators\ApprovedStatusPropertyAnnotator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use SMW\ApprovedRevs\PropertyAnnotators\ApprovedByPropertyAnnotator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use SMW\ApprovedRevs\PropertyAnnotators\ApprovedDatePropertyAnnotator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use SMW\ApprovedRevs\PropertyAnnotators\ApprovedRevPropertyAnnotator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @private | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * @license GNU GPL v2+ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * @since 1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * @author mwjames | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 20 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  | class PropertyAnnotator { | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  | 	use LoggerAwareTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  | 	 * @var ServicesFactory | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  | 	private $servicesFactory; | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  | 	 * @var PropertyAnnotator[] | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  | 	private $propertyAnnotators = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  | 	 * @since 1.0 | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  | 	 * @param ServicesFactory $servicesFactory | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 2 |  | 	public function __construct( ServicesFactory $servicesFactory ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 2 |  | 		$this->servicesFactory = $servicesFactory; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 42 | 2 |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  | 	 * @since 1.0 | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  | 	 * @param SemanticData $semanticData | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 1 |  | 	public function addAnnotation( SemanticData $semanticData ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 1 |  | 		$time = microtime( true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 1 |  | 		if ( !$this->canAnnotate( $semanticData->getSubject() ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 1 |  | 		if ( $this->propertyAnnotators === [] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 1 |  | 			$this->initPropertyAnnotators(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 1 |  | 		foreach ( $this->propertyAnnotators as $propertyAnnotator ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 1 |  | 			$propertyAnnotator->addAnnotation( $semanticData ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 1 |  | 		$this->logger->info( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 | 1 |  | 			[ 'SemanticApprovedRevs', 'procTime:{procTime}' ], | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 1 |  | 			[ 'procTime' => round( ( microtime( true ) - $time ), 5 ) ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 69 | 1 |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 | 1 |  | 	private function canAnnotate( $subject ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 1 |  | 		if ( $subject === null || $subject->getTitle() === null || $subject->getTitle()->isSpecialPage() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 1 |  | 		return true; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 78 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 1 |  | 	private function initPropertyAnnotators() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 | 1 |  | 		$this->propertyAnnotators[] = $this->servicesFactory->newApprovedByPropertyAnnotator(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 | 1 |  | 		$this->propertyAnnotators[] = $this->servicesFactory->newApprovedStatusPropertyAnnotator(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 1 |  | 		$this->propertyAnnotators[] = $this->servicesFactory->newApprovedDatePropertyAnnotator(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 | 1 |  | 		$this->propertyAnnotators[] = $this->servicesFactory->newApprovedRevPropertyAnnotator(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 85 | 1 |  | 	} | 
            
                                                        
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 87 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 88 |  |  |  | 
            
                        
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: