| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace SESP; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use SMW\PropertyRegistry as Registry; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use SMW\DataTypeRegistry; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use SMW\DIProperty; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use SMWDataItem as DataItem; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @ingroup SESP | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @license GNU GPL v2+ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @since 1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * @author mwjames | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 17 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  | class PropertyRegistry { | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  | 	 * @var AppFactory | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  | 	private $appFactory; | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  | 	 * @since 2.0 | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  | 	 * @param AppFactory $appFactory | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 | 6 |  | 	public function __construct( AppFactory $appFactory ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 | 6 |  | 		$this->appFactory = $appFactory; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 32 | 6 |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  | 	 * @since 1.0 | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  | 	 * @param Registry $propertyRegistry | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  | 	 * @return boolean | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 3 |  | 	public function register( Registry $propertyRegistry ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 | 3 |  | 		$propertyDefinitions = $this->appFactory->getPropertyDefinitions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 3 |  | 		$labels = $propertyDefinitions->getLabels(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 3 |  | 		foreach ( $propertyDefinitions as $key => $definition ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 2 |  | 			if ( !isset( $definition['id'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 1 |  | 				continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 1 |  | 			$this->addPropertyDefinition( $propertyRegistry, $propertyDefinitions, $definition, $labels ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 3 |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 3 |  | 		foreach ( $propertyDefinitions->safeGet( '_EXIF', [] ) as $key => $definition ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 1 |  | 			if ( !isset( $definition['id'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 				continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 1 |  | 			$this->addPropertyDefinition( $propertyRegistry, $propertyDefinitions, $definition, $labels ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 3 |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 | 3 |  | 		return true; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 65 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  | 	 * @since 2.0 | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  | 	 * @param array $customFixedProperties | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  | 	 * @param array $fixedPropertyTablePrefix | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 2 |  | 	public function registerFixedProperties( &$customFixedProperties, &$fixedPropertyTablePrefix ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 2 |  | 		if ( $this->appFactory->getOption( 'sespgUseFixedTables' ) === false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 1 |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 1 |  | 		$propertyDefinitions = $this->appFactory->getPropertyDefinitions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 | 1 |  | 		$properties = array_flip( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 | 1 |  | 			$this->appFactory->getOption( 'sespgEnabledPropertyList', [] ) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 1 |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 | 1 |  | 		foreach ( $propertyDefinitions as $key => $definition ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 | 1 |  | 			if ( !isset( $definition['id'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 				continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 | 1 |  | 			$id = $definition['id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 1 |  | 			if ( isset( $properties[$key] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 | 1 |  | 				$customFixedProperties[$id] = str_replace( [ '___', '__' ], '_', strtolower( $id ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 				// Legacy setting `smw_ftp` vs. `smw_fpt` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 | 1 |  | 				$fixedPropertyTablePrefix[$id] = 'smw_ftp_sesp'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 | 1 |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 | 1 |  | 		} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 100 | 1 |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 2 |  | 	private function addPropertyDefinition( $propertyRegistry, $propertyDefinitions, $definition, $aliases ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 | 2 |  | 		$visible = isset( $definition['show'] ) ? $definition['show'] : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 | 2 |  | 		$annotable = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 		// If someone screws up the definition format we just fail epically here | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 		// on purpose | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 2 |  | 		$propertyRegistry->registerProperty( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 | 2 |  | 			$definition['id'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 | 2 |  | 			$definition['type'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 | 2 |  | 			$definition['label'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 | 2 |  | 			$visible, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 			$annotable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 | 2 |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 | 2 |  | 		$alias = isset( $definition['alias'] ) ? $definition['alias'] : 'smw-unknown-alias'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 | 2 |  | 		$label = isset( $aliases[$definition['id']] ) ? $aliases[$definition['id']] : $propertyDefinitions->getLabel( $alias ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 | 2 |  | 		$propertyRegistry->registerPropertyAlias( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 | 2 |  | 			$definition['id'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 			$label | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 | 2 |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 | 2 |  | 		$propertyRegistry->registerPropertyAliasByMsgKey( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 | 2 |  | 			$definition['id'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 			$alias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 | 2 |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 | 2 |  | 		$desc = isset( $definition['desc'] ) ? $definition['desc'] : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 | 2 |  | 		$propertyRegistry->registerPropertyDescriptionMsgKeyById( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 | 2 |  | 			$definition['id'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 			$desc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 | 2 |  | 		); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 137 | 2 |  | 	} | 
            
                                                        
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 139 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 140 |  |  |  | 
            
                        
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: