Skip to content

Conversation

@rochamarcelo
Copy link
Contributor

For #47

I'm not 100% sure if this is the way to handle the issue reported.

@LordSimal Could you please test this.

@rochamarcelo rochamarcelo marked this pull request as draft October 29, 2025 12:58
@LordSimal
Copy link
Contributor

Sorry for the late response.
I tried this branch, but it doesn't fix my problem.
If I remove the phpstan-ignore line from

    public function batnodePorts(NginxConfigUtility $nginxConfigUtility): Response
    {
        $optionsTable = $this->fetchTable('Options');
        try {
            $ports = $optionsTable->get('BatnodePorts');
        /** @phpstan-ignore catch.neverThrown */
        } catch (RecordNotFoundException) {
            $ports = new Option(['alfred_key' => 'BatnodePorts', 'value' => '']);
        }

phpstan complaints again for me with

 ------ -------------------------------------------------------------------------------------------------- 
  Line   plugins/AlfredTools/src/Controller/ToolsController.php                                            
 ------ -------------------------------------------------------------------------------------------------- 
  616    Dead catch - Cake\Datasource\Exception\RecordNotFoundException is never thrown in the try block.  
         🪪  catch.neverThrown                                                                             
         at plugins/AlfredTools/src/Controller/ToolsController.php:616                                     
 ------ -------------------------------------------------------------------------------------------------- 

@rochamarcelo
Copy link
Contributor Author

How does your Tools table compares with MyUsersTable.php ?

@LordSimal
Copy link
Contributor

I let that auto generate via the ide helper

/**
 * Options Model
 *
 * @method \App\Model\Entity\Option newEmptyEntity()
 * @method \App\Model\Entity\Option newEntity(array $data, array $options = [])
 * @method array<\App\Model\Entity\Option> newEntities(array $data, array $options = [])
 * @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)
 * @method \App\Model\Entity\Option findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, ?callable $callback = null, array $options = [])
 * @method \App\Model\Entity\Option patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
 * @method array<\App\Model\Entity\Option> patchEntities(iterable $entities, array $data, array $options = [])
 * @method \App\Model\Entity\Option|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
 * @method \App\Model\Entity\Option saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
 * @method \Cake\Datasource\ResultSetInterface<\App\Model\Entity\Option>|false saveMany(iterable $entities, array $options = [])
 * @method \Cake\Datasource\ResultSetInterface<\App\Model\Entity\Option> saveManyOrFail(iterable $entities, array $options = [])
 * @method \Cake\Datasource\ResultSetInterface<\App\Model\Entity\Option>|false deleteMany(iterable $entities, array $options = [])
 * @method \Cake\Datasource\ResultSetInterface<\App\Model\Entity\Option> deleteManyOrFail(iterable $entities, array $options = [])
 * @mixin \Cake\ORM\Behavior\TimestampBehavior
 * @extends \Cake\ORM\Table<array{Timestamp: \Cake\ORM\Behavior\TimestampBehavior}>
 */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants