for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Created by PhpStorm.
* User: VITALYIEGOROV
* Date: 08.12.15
* Time: 23:11
*/
namespace samsoncms\api\query;
use samson\activerecord\dbQuery;
* Material with additional fields query.
* @package samsoncms\api
class Entity
{
/** @var string Entity identifier */
protected static $identifier;
/** @var string Entity navigation identifiers */
protected static $navigationIDs;
/** @var array Collection of entity field filter */
protected $fieldFilter;
* Set additional entity field condition.
*
* @param string $fieldName Field identifier
* @param string $fieldValue Field value
* @return self Chaining
public function where($fieldName, $fieldValue)
if (property_exists(static::$identifier, $fieldName)) {
$this->fieldFilter[$fieldName] = $fieldValue;
}
* Perform SamsonCMS query and get entities collection.
* @return mixed[] Collection of found entities
public function find()
$return = array();
/** @var array $idsByNavigation First step - filter by navigation */
if (sizeof($idsByNavigation = (new MaterialNavigation())->idsByRelationID(static::$navigationIDs))) {
// Second step filter by additional field value
if (sizeof($this->fieldFilter)) {
$return = (new MaterialField($idsByNavigation))
$idsByNavigation
boolean|object<samsonfra...rk\orm\RecordInterface>
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);
->byRelationID($this->fieldFilter[]);
} else { // Just return entities filtered by navigation
return (new Material($idsByNavigation, static::$identifier))->byIDs($idsByNavigation, 'exec');
string|array
return $return;
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: