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 | 4 | public function __construct( AppFactory $appFactory ) { |
|
| 34 | 4 | $this->appFactory = $appFactory; |
|
| 35 | 4 | } |
|
| 36 | |||
| 37 | /** |
||
| 38 | * @since 2.0 |
||
| 39 | * |
||
| 40 | * {@inheritDoc} |
||
| 41 | */ |
||
| 42 | 1 | public function isAnnotatorFor( DIProperty $property ) { |
|
| 43 | 1 | return true; |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @since 2.0 |
||
| 48 | * |
||
| 49 | * {@inheritDoc} |
||
| 50 | */ |
||
| 51 | 2 | public function addAnnotation( DIProperty $property, SemanticData $semanticData ) { |
|
| 52 | |||
| 53 | 2 | $time = microtime( true ); |
|
| 54 | |||
| 55 | 2 | $localDefs = $this->appFactory->getOption( 'sespLocalPropertyDefinitions', array() ); |
|
|
0 ignored issues
–
show
|
|||
| 56 | |||
| 57 | 2 | foreach ( $localDefs as $key => $definition ) { |
|
| 58 | 2 | $this->callOnLocalDef( $definition, $property, $semanticData ); |
|
| 59 | 2 | } |
|
| 60 | |||
| 61 | 2 | $this->appFactory->getLogger()->info( |
|
| 62 | 2 | __METHOD__ . ' (procTime in sec: '. ( microtime( true ) - $time ) . ')' |
|
| 63 | 2 | ); |
|
| 64 | 2 | } |
|
| 65 | |||
| 66 | 2 | private function callOnLocalDef( $definition, $property, $semanticData ) { |
|
| 67 | |||
| 68 | 2 | if ( !isset( $definition['id'] ) || $definition['id'] !== $property->getKey() ) { |
|
| 69 | 1 | return; |
|
| 70 | } |
||
| 71 | |||
| 72 | 1 | $dataItem = null; |
|
| 73 | |||
| 74 | 1 | if ( isset( $definition['callback'] ) && is_callable( $definition['callback'] ) ) { |
|
| 75 | 1 | $dataItem = call_user_func_array( $definition['callback'], array( $this->appFactory, $property, $semanticData ) ); |
|
| 76 | 1 | } |
|
| 77 | |||
| 78 | 1 | if ( $dataItem instanceof DataItem ) { |
|
| 79 | 1 | $semanticData->addPropertyObjectValue( $property, $dataItem ); |
|
| 80 | 1 | } |
|
| 81 | 1 | } |
|
| 82 | |||
| 83 | } |
||
| 84 |
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: