for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Wikibase\EntityStore\MongoDB;
use Doctrine\MongoDB\Database;
use Doctrine\MongoDB\Query\Expr;
use Wikibase\DataModel\Term\Term;
use Wikibase\EntityStore\Internal\EntityIdForTermLookup;
/**
* Internal class
*
* @licence GPLv2+
* @author Thomas Pellissier Tanon
*/
class MongoDBEntityIdForTermLookup implements EntityIdForTermLookup {
* @var Database
private $database;
* @var MongoDBDocumentBuilder
private $documentBuilder;
* @param Database $database
* @param MongoDBDocumentBuilder $documentBuilder
public function __construct( Database $database, MongoDBDocumentBuilder $documentBuilder ) {
$this->database = $database;
$this->documentBuilder = $documentBuilder;
}
* @see EntityDocumentLookup::getEntityDocumentsForTerm
public function getEntityIdsForTerm( Term $term, $entityType ) {
$documents = $this->database
->selectCollection( $entityType )
->find(
$this->buildGetEntityIdForTermQuery( $term ),
$this->buildGetEntityIdForTermQuery($term)
string
array
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:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
[ '_id' => 1 ]
);
$entities = [];
foreach( $documents as $document ) {
$entities[] = $this->documentBuilder->buildEntityIdForDocument( $document );
return $entities;
private function buildGetEntityIdForTermQuery( Term $term ) {
$expr = new Expr();
$expr->field( 'sterms.' . $term->getLanguageCode() )->equals(
$this->documentBuilder->cleanTextForSearch( $term->getText() )
return $expr->getQuery();
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: