定制 lordsimal/cakephp-psalm 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lordsimal/cakephp-psalm

最新稳定版本:2.1.0

Composer 安装命令:

composer require lordsimal/cakephp-psalm

包简介

A psalm-plugin for CakePHP

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

Overview

This plugin provides correct return types for CakePHP specific methods in psalm.

Quickstart

Please refer to the full Psalm documentation for a more detailed guide on how to use Psalm in your project.

First you need to install the psalm base package and create a psalm.xml

composer require --dev vimeo/psalm
./vendor/bin/psalm --init

Next you will need to require this package and enable it in psalm

composer require --dev lordsimal/cakephp-psalm
./vendor/bin/psalm-plugin enable lordsimal/cakephp-psalm

Finally you can try it out

./vendor/bin/psalm

How it works

Currently only the following return types are being corrected:

  • Cake\ORM\Locator\LocatorInterface::get()
  • Cake\ORM\Locator\LocatorAwareTrait::fetchTable()

The functionality for this can be found in src/Type/TableLocatorHandler.php

In there the getClassLikeNames() tells psalm on which classes it needs to change return types.

In the getMethodReturnType() we check which method is currently called and get the first argument value from that call.

With that value we get the "real" FQCN of the table which is returned in runtime and tell psalm to use that instead of the default Cake\ORM\Table.

Help needed

I would definitely appreciate help related to the following aspects of this plugin:

统计信息

  • 总下载量: 12.12k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-12-31