for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of slick/orm package
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Slick\Orm\Repository;
use Slick\Database\Sql;
use Slick\Orm\EntityInterface;
use Slick\Orm\Repository\QueryObject\QueryObject;
use Slick\Orm\Repository\QueryObject\QueryObjectInterface;
use Slick\Orm\RepositoryInterface;
* Class EntityRepository
* @package Slick\Orm\Repository
* @author Filipe Silva <[email protected]>
class EntityRepository extends AbstractRepository implements
RepositoryInterface
{
* Finds entities
* @return QueryObjectInterface
* @see Slick\Database\Sql\Select
public function find()
return new QueryObject($this);
}
* Gets an entity by its id
* @param mixed $entityId
* @return EntityInterface|null
public function get($entityId)
$entity = $this->getIdentityMap()->get($entityId, false);
if ($entity === false) {
$entity = $this->load($entityId);
return $entity;
* Loads entity from database
* @param $entityId
* @return null|EntityInterface
protected function load($entityId)
$table = $this->getEntityDescriptor()->getTableName();
$primaryKey = $this->getEntityDescriptor()
->getPrimaryKey()
->getField();
return $this->find()
->where(
[
array("{$table}.{$primar...ay(':id' => $entityId))
array<string|integer,array<string,?,{":id":"?"}>>
string
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);
"{$table}.{$primaryKey} = :id" => [
':id' => $entityId
]
)
->first();
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: