CakePHP 3 - How to do document useImmutable() method in bootstrap.php

268 Views Asked by At

We use scrutinizer to inspect our code. Here is one "bug" related to phpdoc:

<?php
 *
 * @method \Cake\Database\Type\DateTimeType[] useImmutable()
 */
Type::build('time')->useImmutable();

Error message:

The method useImmutable() does not exist on Cake\Database\Type. It seems like you code against a sub-type of Cake\Database\Type such as Cake\Database\Type\DateTimeType.

1

There are 1 best solutions below

0
ndm On BEST ANSWER

Create a variable and typehint it:

/** @var \Cake\Database\Type\DateTimeType $time */
$time = Type::build('time');
$time->useImmutable();