承接 shipmonk/name-collision-detector 相关项目开发

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

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

shipmonk/name-collision-detector

Composer 安装命令:

composer require shipmonk/name-collision-detector

包简介

Simple tool to find ambiguous classes or any other name duplicates within your project.

README 文档

README

Simple tool which allows you to detect if there are no types defined multiple times within the same namespace. This means that any ambiguous class, interface, enum, trait, constant or function is reported. Non-zero exit code is returned when any duplicate is found.

Installation:

composer require --dev shipmonk/name-collision-detector

Usage:

Check duplicate types:

vendor/bin/detect-collisions dir1 dir2 dir3 # relative to cwd

Example error output:

Foo\NamespacedClass2 is defined 2 times:
 > /tests/sample-collisions/file2.php:23
 > /tests/sample-collisions/file2.php:45

GlobalInterface1 is defined 2 times:
 > /tests/sample-collisions/file1.php:8
 > /tests/sample-collisions/file2.php:11

Example success output:

OK (no name collision found)
 * analysed files: 9867
 * excluded files: 0
 * elapsed time: 1.057 s
  • Note the performance: 10 000 files takes few seconds!

Configuration:

If file named collision-detector.json is present within current working directory, its contents are taken as configuration options. Possible config options:

{
    "scanPaths": ["src", "tests"], // files/directories to scan, relative to config file directory, glob not supported
    "excludePaths": ["tests/collisions"], // files/directories to exclude, relative to config file directory, glob not supported
    "fileExtensions": ["php"], // file extensions to parse
    "ignoreParseFailures": false // skip files with parse errors or not
}

Paths provided by CLI arguments have priority over those in scanDirs.

You can provide custom path to config file by vendor/bin/detect-collisions --configuration path/to/config.json

Reasoning

Having colliding classes within project can cause crazy headaches while debugging why something works only sometimes. Typically, you have PSR-4 autoloading which often solves this problem for you, but there are cases (like PHPStan rules test files) where you want to write any code (with classmap autoloading). And in such cases, the test may work when executed in standalone run, but fail when running all the tests together (depending on which class was autoloaded first). Therefore, having a collision detector in CI might be useful.

Composer's ambiguous class resolution

Composer can also detect class duplicates and exit with non-zero, but it runs much slower and lacks function and constant detection. Using composer version >= 2.8.1, you can use:

composer dump --optimize --strict-ambiguous

Supported PHP versions

  • PHP 8.1 - PHP 8.5

shipmonk/name-collision-detector 适用场景与选型建议

shipmonk/name-collision-detector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.78M 次下载、GitHub Stars 达 34, 最近一次更新时间为 2022 年 12 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「autoload」 「autoloading」 「namespace」 「classname」 「collision」 「ambiguous」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 shipmonk/name-collision-detector 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 2.78M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 36
  • 点击次数: 30
  • 依赖项目数: 40
  • 推荐数: 0

GitHub 信息

  • Stars: 34
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-21