SemanticMediaWiki /
SemanticExtraSpecialProperties
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SESP\PropertyAnnotators; |
||
| 4 | |||
| 5 | use SMW\DIProperty; |
||
| 6 | use SMW\DIWikiPage; |
||
| 7 | use SMW\SemanticData; |
||
| 8 | use SMWDataItem as DataItem; |
||
| 9 | use SESP\PropertyAnnotator; |
||
| 10 | use SESP\AppFactory; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @private |
||
| 14 | * @ingroup SESP |
||
| 15 | * |
||
| 16 | * @license GNU GPL v2+ |
||
| 17 | * @since 2.0 |
||
| 18 | * |
||
| 19 | * @author mwjames |
||
| 20 | */ |
||
| 21 | class LocalPropertyAnnotator implements PropertyAnnotator { |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var AppFactory |
||
| 25 | */ |
||
| 26 | private $appFactory; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @since 2.0 |
||
| 30 | * |
||
| 31 | * @param AppFactory $appFactory |
||
| 32 | */ |
||
| 33 | public function __construct( AppFactory $appFactory ) { |
||
| 34 | $this->appFactory = $appFactory; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @since 2.0 |
||
| 39 | * |
||
| 40 | * {@inheritDoc} |
||
| 41 | */ |
||
| 42 | public function isAnnotatorFor( DIProperty $property ) { |
||
| 43 | return true; |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @since 2.0 |
||
| 48 | * |
||
| 49 | * {@inheritDoc} |
||
| 50 | */ |
||
| 51 | public function addAnnotation( DIProperty $property, SemanticData $semanticData ) { |
||
| 52 | |||
| 53 | $time = microtime( true ); |
||
| 54 | |||
| 55 | $localDefs = $this->appFactory->getOption( 'sespLocalPropertyDefinitions', array() ); |
||
|
0 ignored issues
–
show
|
|||
| 56 | $dataItem = null; |
||
| 57 | |||
| 58 | foreach ( $localDefs as $key => $definition ) { |
||
| 59 | |||
| 60 | if ( !isset( $definition['id'] ) || $definition['id'] !== $property->getKey() ) { |
||
| 61 | continue; |
||
| 62 | } |
||
| 63 | |||
| 64 | if ( isset( $definition['hook'] ) && is_callable( $definition['hook'] ) ) { |
||
| 65 | $dataItem = call_user_func_array( $definition['hook'], array( $this->appFactory, $property, $semanticData ) ); |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | if ( $dataItem instanceof DataItem ) { |
||
| 70 | $semanticData->addPropertyObjectValue( $property, $dataItem ); |
||
| 71 | } |
||
| 72 | |||
| 73 | $this->appFactory->getLogger()->info( |
||
| 74 | __METHOD__ . ' (procTime in sec: '. ( microtime( true ) - $time ) . ')' |
||
| 75 | ); |
||
| 76 | } |
||
| 77 | |||
| 78 | } |
||
| 79 |
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: