| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace SESP; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use SMW\DIProperty; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use SMW\SemanticData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use SESP\PropertyAnnotators\LocalPropertyAnnotator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use SESP\PropertyAnnotators\DispatchingPropertyAnnotator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @private | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @license GNU GPL v2+ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @since 2.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * @author mwjames | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 17 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  | class ExtraPropertyAnnotator { | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  | 	 * @var AppFactory | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  | 	private $appFactory; | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  | 	 * @var DispatchingPropertyAnnotator | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  | 	private $dispatchingPropertyAnnotator; | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  | 	 * @var LocalPropertyAnnotator | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  | 	private $localPropertyAnnotator; | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  | 	 * @since 2.0 | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  | 	 * @param AppFactory $appFactory | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 4 |  | 	public function __construct( AppFactory $appFactory ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 4 |  | 		$this->appFactory = $appFactory; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 42 | 4 |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  | 	 * @since 2.0 | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  | 	 * @param SemanticData $semanticData | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 3 |  | 	public function addAnnotation( SemanticData $semanticData ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 3 |  | 		$time = microtime( true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 3 |  | 		if ( !$this->canAnnotate( $semanticData->getSubject() ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 1 |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 2 |  | 		$propertyDefinitions = $this->appFactory->getPropertyDefinitions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 2 |  | 		foreach ( $this->appFactory->getOption( 'sespgEnabledPropertyList', [] ) as $key ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 2 |  | 			if ( !$propertyDefinitions->deepHas( $key, 'id' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 1 |  | 				continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 1 |  | 			$property = new DIProperty( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 | 1 |  | 				$propertyDefinitions->deepGet( $key, 'id' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 1 |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 1 |  | 			if ( $propertyDefinitions->isLocalDef( $key ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 				$this->localPropertyAnnotator->addAnnotation( $property, $semanticData ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 1 |  | 				$this->dispatchingPropertyAnnotator->addAnnotation( $property, $semanticData ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 2 |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 2 |  | 		$this->appFactory->getLogger()->info( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 2 |  | 			__METHOD__ . ' (procTime in sec: '. round( ( microtime( true ) - $time ), 5 ) . ')' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 2 |  | 		); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 79 | 2 |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  | 	 * @since 2.0 | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  | 	 * @param string $key | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  | 	 * @param PropertyAnnotator $propertyAnnotator | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 | 1 |  | 	public function addPropertyAnnotator( $key, PropertyAnnotator $propertyAnnotator ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 1 |  | 		if ( $this->dispatchingPropertyAnnotator === null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 | 1 |  | 			$this->initPropertyAnnotators(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 | 1 |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 1 |  | 		$this->dispatchingPropertyAnnotator->addPropertyAnnotator( $key, $propertyAnnotator ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 94 | 1 |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 | 3 |  | 	private function canAnnotate( $subject ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 | 3 |  | 		if ( $subject === null || $subject->getTitle() === null || $subject->getTitle()->isSpecialPage() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 | 1 |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 2 |  | 		if ( $this->dispatchingPropertyAnnotator === null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 1 |  | 			$this->initPropertyAnnotators(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 | 1 |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 | 2 |  | 		return true; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 107 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 | 2 |  | 	private function initPropertyAnnotators() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 | 2 |  | 		$this->localPropertyAnnotator = new LocalPropertyAnnotator( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 | 2 |  | 			$this->appFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 | 2 |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 | 2 |  | 		$this->dispatchingPropertyAnnotator = new DispatchingPropertyAnnotator( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 | 2 |  | 			$this->appFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 | 2 |  | 		); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 118 | 2 |  | 	} | 
            
                                                        
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 120 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 121 |  |  |  | 
            
                        
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: