prinsfrank/phpstan-doc-code-analyzer 问题修复 & 功能扩展

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

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

prinsfrank/phpstan-doc-code-analyzer

最新稳定版本:v0.0.3

Composer 安装命令:

composer require prinsfrank/phpstan-doc-code-analyzer

包简介

Analyze code snippets in documentation and README with PHPStan!

README 文档

README

When you have an extensive README.md or a bunch of documentation files, it is sometimes hard to keep all documentation up to date with the actual code. Why not also analyze code blocks in those files with PHPStan?

Getting started

composer require --dev prinsfrank/phpstan-doc-code-analyzer

Configuration

Configuring paths to look for Markdown files

You can configure the paths to analyze with glob patterns. By default, these are configured like this:

parameters:
    docCodeAnalyzer:
        paths:
            - docs/**.md
            - README.md

If one of the glob patterns doesn't match any files, this is likely a misconfiguration, so this will cause an error.

Auto prepend open tag when missing

When using PHP snippets in your documentation, you might not have all snippets start with the <?php open tag. So Instead of:

```php
<?php

echo 123;

You might start your code blocks without that open tag:

```php
echo 123;

In that case this extension will automatically prepend that opening tag. If you don't want that (and want php codeblocks without an open tag to fail), you can disable this:

parameters:
    docCodeAnalyzer:
        prependOpenTagWhenMissing: false

Set strict_types to true when adding missing opening tag

When the opening tag is not present, Besides automatically adding the tag, it will also enable strict_types. If you just want the automatic open tag without strict types, you can disable this:

parameters:
    docCodeAnalyzer:
        setStrictTypesWhenOpenTagMissing: false

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-15