for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @copyright Copyright (c) Flipbox Digital Limited
* @license https://flipboxfactory.com/software/hubspot/license
* @link https://www.flipboxfactory.com/software/hubspot/
*/
namespace flipbox\hubspot\services\resources\traits;
use flipbox\hubspot\criteria\ResourceCriteriaInterface;
use flipbox\hubspot\fields\Resources;
use flipbox\ember\helpers\ObjectHelper;
use yii\base\InvalidConfigException;
* @author Flipbox Factory <[email protected]>
* @since 1.0.0
trait ElementCriteriaTrait
{
* @param array $criteria
* @return ResourceCriteriaInterface
public abstract function getCriteria(array $criteria = []): ResourceCriteriaInterface;
* @param Resources $field
* @param null $criteria
protected function resolveCriteria(Resources $field, $criteria = null): ResourceCriteriaInterface
if ($criteria instanceof ResourceCriteriaInterface) {
return $criteria;
}
if ($criteria === null) {
return $field->createResourceCriteria();
if (!is_array($criteria)) {
$criteria = ['class' => $criteria];
try {
$criteria = ObjectHelper::create($criteria, ResourceCriteriaInterface::class);
} catch (InvalidConfigException $e) {
$criteria = $this->getCriteria($criteria);
$criteria
object<yii\base\BaseObject>
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);
/** @var ResourceCriteriaInterface $criteria */
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: