ricardosierra /
translation
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Translation\Loaders; |
||
| 4 | |||
| 5 | use Translation\Cache\CacheRepositoryInterface as Cache; |
||
| 6 | |||
| 7 | class CacheLoader extends Loader |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * The default locale. |
||
| 11 | * |
||
| 12 | * @var string |
||
| 13 | */ |
||
| 14 | protected $defaultLocale; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * The laravel cache instance. |
||
| 18 | * |
||
| 19 | * @var \Illuminate\Config\Repository |
||
|
0 ignored issues
–
show
|
|||
| 20 | */ |
||
| 21 | protected $cache; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * The loader fallback instance in case of a cache miss. |
||
| 25 | * |
||
| 26 | * @var Loader |
||
| 27 | */ |
||
| 28 | protected $fallback; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * The cache timeout in minutes. |
||
| 32 | * |
||
| 33 | * @var string |
||
| 34 | */ |
||
| 35 | protected $cacheTimeout; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Create a new mixed loader instance. |
||
| 39 | * |
||
| 40 | * @param string $defaultLocale |
||
| 41 | * @param \Translation\Contracts\CacheRepositoryInterface $cache Cache repository. |
||
|
0 ignored issues
–
show
The type
Translation\Contracts\CacheRepositoryInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 42 | * @param \Translation\Loaders\Loader $fallback Translation loader to use on cache miss. |
||
| 43 | * @param integer $cacheTimeout In minutes. |
||
| 44 | */ |
||
| 45 | public function __construct($defaultLocale, Cache $cache, Loader $fallback, $cacheTimeout) |
||
| 46 | { |
||
| 47 | parent::__construct($defaultLocale); |
||
| 48 | $this->cache = $cache; |
||
|
0 ignored issues
–
show
It seems like
$cache of type Translation\Cache\CacheRepositoryInterface is incompatible with the declared type Illuminate\Config\Repository of property $cache.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 49 | $this->fallback = $fallback; |
||
| 50 | $this->cacheTimeout = $cacheTimeout; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Load the messages for the given locale. |
||
| 55 | * |
||
| 56 | * @param string $locale |
||
| 57 | * @param string $group |
||
| 58 | * @param string $namespace |
||
| 59 | * @return array |
||
| 60 | */ |
||
| 61 | public function loadSource($locale, $group, $namespace = '*') |
||
| 62 | { |
||
| 63 | if ($this->cache->has($locale, $group, $namespace)) { |
||
| 64 | return $this->cache->get($locale, $group, $namespace); |
||
| 65 | } else { |
||
| 66 | $source = $this->fallback->load($locale, $group, $namespace); |
||
| 67 | $this->cache->put($locale, $group, $namespace, $source, $this->cacheTimeout); |
||
| 68 | return $source; |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Add a new namespace to the loader. |
||
| 74 | * |
||
| 75 | * @param string $namespace |
||
| 76 | * @param string $hint |
||
| 77 | * @return void |
||
| 78 | */ |
||
| 79 | public function addNamespace($namespace, $hint) |
||
| 80 | { |
||
| 81 | $this->fallback->addNamespace($namespace, $hint); |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Add a new JSON path to the loader. |
||
| 86 | * |
||
| 87 | * @param string $path |
||
| 88 | * @return void |
||
| 89 | */ |
||
| 90 | public function addJsonPath($path) |
||
| 91 | { |
||
| 92 | // |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Get an array of all the registered namespaces. |
||
| 97 | * |
||
| 98 | * @return array |
||
| 99 | */ |
||
| 100 | public function namespaces() |
||
| 101 | { |
||
| 102 | return $this->fallback->namespaces(); |
||
| 103 | } |
||
| 104 | } |
||
| 105 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths