承接 humanmade/psalm-plugin-wordpress 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

humanmade/psalm-plugin-wordpress

Composer 安装命令:

composer require humanmade/psalm-plugin-wordpress

包简介

WordPress stubs and plugin for Psalm static analysis.

README 文档

README

Packagist Packagist

Write type-safe WordPress code. This plugin supports WordPress 3 and newer (4, 5, 6, currently WP 6.7) and generally also works on WordPress trunk and beta/RC versions.

This Psalm plugin provides all WordPress and WP CLI stubs, so your WordPress based project or plugin will have type information for calls to WordPress APIs. This ensures your WordPress plugin or theme has less bugs!

  • Stubs for all of WordPress Core
  • Stubs for WP CLI
  • Types for apply_filters return values.
  • Types for add_filter / add_action
  • Configuration options to use your own stubs

Installation

Please refer to the full Psalm documentation for a more detailed guide on introducing Psalm into your project.

After Psalm is installed, install this package and enable the plugin:

composer require --dev humanmade/psalm-plugin-wordpress
./vendor/bin/psalm-plugin enable humanmade/psalm-plugin-wordpress

Configuration

If you follow the installation instructions, the psalm-plugin command will add this plugin configuration to the psalm.xml configuration file.

<?xml version="1.0"?>
<psalm xmlns="https://getpsalm.org/schema/config">
	<!-- project configuration -->

	<plugins>
		<pluginClass class="PsalmWordPress\Plugin" />
	</plugins>
</psalm>

Further details about plugins can be found on Psalm's website.

Default WordPress stubs

If you do not want to use the default WordPress class/method/function stubs, which are part of this plugin, useDefaultStubs must be set to false:

<pluginClass class="PsalmWordPress\Plugin">
	<useDefaultStubs value="false" />
</pluginClass>

Default WordPress hooks

If you do not want to use the default WordPress hooks, which are part of this plugin, useDefaultHooks must be set to false:

<pluginClass class="PsalmWordPress\Plugin">
	<useDefaultHooks value="false" />
</pluginClass>

Custom hooks

You can also provide custom hooks:

<pluginClass class="PsalmWordPress\Plugin">
	<hooks>
		<directory name="some/dir/hooks" recursive="true" />
		<directory name="/absolute/other/dir/hooks" />
		<file name="my-special-hooks/actions.json" />
	</hooks>
</pluginClass>

If a directory is provided, the plugin will search for the following files:

  • actions.json
  • filters.json
  • hooks.json

The plugin expects a JSON representation of the hooks as per wp-hooks/generator.

Require passing all parameters

If you want to get an error if apply_filters and do_action do not have the same number of parameters in all cases, requireAllParams must be set to true:

<pluginClass class="PsalmWordPress\Plugin">
	<requireAllParams value="true" />
</pluginClass>

WordPress paths

To help Psalm analyze your project you might need to define some of WordPress' default global constants such as those for paths.

<?xml version="1.0"?>
<psalm autoloader="tests/bootstrap.php" xmlns="https://getpsalm.org/schema/config">
	<!-- project configuration -->
</psalm>

The following example bootstrap file is for a Bedrock installation:

<?php

require_once dirname( __DIR__ ) . '/config/application.php';

define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' );

define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );

You could require WordPress' default constants functions but that requires a lot more boilerplating to allow those functions to effectively define constants.

Interested in contributing?

Feel free to open a PR to fix bugs or add features!

In addition, have a look at Psalm's contribution guidelines.

Who made this

Created by @joehoyle, maintained by the Psalm community.

humanmade/psalm-plugin-wordpress 适用场景与选型建议

humanmade/psalm-plugin-wordpress 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 502.77k 次下载、GitHub Stars 达 82, 最近一次更新时间为 2020 年 05 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 humanmade/psalm-plugin-wordpress 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 humanmade/psalm-plugin-wordpress 我们能提供哪些服务?
定制开发 / 二次开发

基于 humanmade/psalm-plugin-wordpress 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 502.77k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 82
  • 点击次数: 29
  • 依赖项目数: 27
  • 推荐数: 0

GitHub 信息

  • Stars: 82
  • Watchers: 22
  • Forks: 18
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-14