for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace App\Esa;
use Polidog\Esa\Api;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
/**
* @see https://docs.esa.io/posts/102
*/
class Proxy
{
public const CACHE_KEY_PREFIX = 'esaba.esa.proxy';
public function __construct(private Api $api, private CacheInterface $cache)
}
public function getPost(int $postId, bool $force = false): array
$cacheKey = sprintf('%s.post.%d', self::CACHE_KEY_PREFIX, $postId);
if ($force) {
$this->cache->delete($cacheKey);
$post = $this->cache->get($cacheKey, function (ItemInterface $item) use ($postId) {
$item
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
$post = $this->cache->get($cacheKey, function (/** @scrutinizer ignore-unused */ ItemInterface $item) use ($postId) {
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
return $this->api->post($postId);
});
return $post;
public function getEmojis(): array
$cacheKey = sprintf('%s.emojis', self::CACHE_KEY_PREFIX);
$emojis = $this->cache->get($cacheKey, function (ItemInterface $item) {
$emojis = $this->cache->get($cacheKey, function (/** @scrutinizer ignore-unused */ ItemInterface $item) {
return $this->api->emojis(['include' => 'all'])['emojis'];
return $emojis;
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.