Skip to content

Fix deprecation error on CakePHP 5.3#359

Merged
ADmad merged 2 commits into
masterfrom
issue-358
Nov 11, 2025
Merged

Fix deprecation error on CakePHP 5.3#359
ADmad merged 2 commits into
masterfrom
issue-358

Conversation

@ADmad

@ADmad ADmad commented Nov 11, 2025

Copy link
Copy Markdown
Member

Closes #358

@dereuromark

Copy link
Copy Markdown
Member

Return type of call to method Cake\ORM\Table::getBehavior() contains unresolvable type.

Does this need cakedc phpstan extension to understand it?
cc @rochamarcelo

@rochamarcelo

Copy link
Copy Markdown

Probably won't work since it does not use the alias 'Search.Search'

@dereuromark

Copy link
Copy Markdown
Member

Well, thats not ideal now.. We need to find a way to make this a bit easier to work with.
We will have a lot of app code to migrate to 5.3 and this will annoy a lot.

@rochamarcelo

rochamarcelo commented Nov 11, 2025

Copy link
Copy Markdown

Here is another annotation.

/**
 * @var Table<array{Search: SearchBehavior}> $model
 */
var_dump($model->getBehavior('Search')->isSearch());
/**
 * @var Table<array{
 *   Search: SearchBehavior,
 *   Trashable: TrashableBehavior
 * }> $model
 */
var_dump($model->getBehavior('Trashable')->findTrashed());
var_dump($model->getBehavior('Search')->isSearch());

PHPStan test https://phpstan.org/r/8b468e40-607f-4e85-898f-42effe66fd19

PS: It will NOT require the annotation for $searchBehavior /** @var \Search\Model\Behavior\SearchBehavior $searchBehavior */

@dereuromark

Copy link
Copy Markdown
Member

Ideally we shouldnt need inline annotations, maybe for Cake5.3? :)

@rochamarcelo

Copy link
Copy Markdown

It's hard to avoid annotation when methods use keys instead of real class name

@ADmad ADmad merged commit 145a159 into master Nov 11, 2025
7 checks passed
@ADmad ADmad deleted the issue-358 branch November 11, 2025 16:40
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.

Search component deprecation

3 participants