for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Class ApiResultLoader
*/
namespace HDNET\OnpageIntegration\Loader;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use HDNET\OnpageIntegration\Service\DataService;
use HDNET\OnpageIntegration\Persister\ApiResultToCachePersister;
use TYPO3\CMS\Core\Cache\CacheManager;
class ApiResultLoader
{
* @var DataService
protected $dataService;
* @var ApiResultToCachePersister
protected $persister;
public function __construct()
$this->dataService = GeneralUtility::makeInstance(DataService::class);
$this->persister = GeneralUtility::makeInstance(ApiResultToCachePersister::class);
}
* @param string $key
* @return array
public function load($key)
$cacheId = $this->persister->getIdentifier($key);
$entry = GeneralUtility::makeInstance(CacheManager::class)->getCache('onpage_extension')->get(
$cacheId
);
if ($entry === false) {
$entry = $this->dataService->getApiResult($key);
$this->persister->persist($entry, $key);
$entry
array
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);
return json_decode($entry, true);
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: