-
Couldn't load subscription status.
- Fork 6
Open
Description
I have this code in my controller:
$optionsTable = $this->fetchTable('Options');
try {
$ports = $optionsTable->get('mykey');
} catch (RecordNotFoundException) {
$ports = new Option(['alfred_key' => 'mykey', 'value' => '']);
}
but phpstan gives me the following error:
------ --------------------------------------------------------------------------------------------------
Line plugins/AlfredTools/src/Controller/ToolsController.php
------ --------------------------------------------------------------------------------------------------
620 Dead catch - Cake\Datasource\Exception\RecordNotFoundException is never thrown in the try block.
🪪 catch.neverThrown
------ --------------------------------------------------------------------------------------------------
I do have the following phpdoc at the top of my OptionsTable due to the ide helper plugin:
* @method \App\Model\Entity\Option get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
I guess phpstan doesn't understand, that this extends the already existing \Cake\ORM\Table::get() method and therefore doesn't realize, that this method can throw either \Cake\Datasource\Exception\RecordNotFoundException or \Cake\Datasource\Exception\InvalidPrimaryKeyException
Metadata
Metadata
Assignees
Labels
No labels