silverstripe/markdown-php-codesniffer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

silverstripe/markdown-php-codesniffer

最新稳定版本:1.0.4

Composer 安装命令:

composer require silverstripe/markdown-php-codesniffer

包简介

A wrapper around squizlabs/PHP_CodeSniffer which lets you lint PHP fenced code blocks in markdown files

README 文档

README

A wrapper around squizlabs/PHP_CodeSniffer which lets you lint PHP fenced code blocks in markdown files.

Installation

Unlike squizlabs/PHP_CodeSniffer, this isn't intended to be installed globally - you should install it as a dev dependency of your project.

composer require --dev silverstripe/markdown-php-codesniffer

Usage

To sniff markdown files, run mdphpcs from the vendor bin directory:

# sniff a directory
vendor/bin/mdphpcs /path/to/docs

# sniff a specific file
vendor/bin/mdphpcs /path/to/docs/file.md

Most of the options available with the phpcs and phpcbf commands from squizlabs/PHP_CodeSniffer are available with mdphpcs as well. See PHP_CodeSniffer usage for more details.

Fixing violations automatically

Some violations can be fixed automatically, and PHP_CodeSniffer will include information about those in the CLI output. To fix them, simply pass the --fix option to mdphpcs:

vendor/bin/mdphpcs /path/to/docs --fix

This is the equivalent of using the phpcbf command on regular PHP files.

Linting other languages

squizlabs/PHP_CodeSniffer supports linting some languages other than PHP. Theoretically that can be done with this tool as well. You'll need to pass the language (as it's written in the markdown language hint) in with the --linting-language option.

vendor/bin/mdphpcs /path/to/docs --linting-language=JS

Linting rules

If you have a default configuration file or explicitly pass in a standard using the --standard option, those rules will be used for linting - but be aware that some rules won't be appropriate for linting code blocks.

For example, the PSR12.Files.FileHeader.HeaderPosition rule will always fail linting, because we need to include empty lines prior to the content of the code block in the content we pass to squizlabs/PHP_CodeSniffer so it can correctly report the line of each violation in the original markdown file.

If you don't specify a standard and have no default configuration file, the default configuration included in this package will be used. This configuration is based on PSR12, with some exclusions that make it appropriate for use in linting code blocks.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固