league/construct-finder 问题修复 & 功能扩展

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

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

league/construct-finder

最新稳定版本:1.6.0

Composer 安装命令:

composer require league/construct-finder

包简介

Finds classes, interfaces, traits, and enums.

README 文档

README

This library helps you locate classes, interfaces, traits, and enums in PHP code. The construct finder locates all code constructs located in a directory.

Installation

composer require league/construct-finder

Usage

Finding constructs

You can find all constructs or use a type specific finder.

use League\ConstructFinder\ConstructFinder;

// Find all constructs
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findAll();
$constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findAllNames();

// Find all classes
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findClasses();
$constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findClassNames()

// Find all interfaces
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findInterfaces();
$constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findInterfaceNames();

// Find all enums
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findEnums();
$constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findEnumNames();

// Find all traits
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findTraits();
$constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findTraitNames();

Using a construct

Constructs are simple value objects that expose the name and the type.

use League\ConstructFinder\Construct;
use League\ConstructFinder\ConstructFinder;
// Find all constructs
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findAll();

/** @var Construct $construct */
$construct = $constructs[0];

$name = $construct->name();
$name = (string) $construct;

$type = $construct->type(); // class, trait, interface, enum

Finding in multiple directories

Provide multiple directories to search from in one go.

use League\ConstructFinder\ConstructFinder;

// Find all constructs
$constructs = ConstructFinder::locatedIn(
    __DIR__ . '/SomeDirectory',
    __DIR__ . '/AnotherDirectory',
)->findAll();

Excluding files based on exclude patterns

All patterns are match in full. You can use a wildcard (*) for fuzzy matching.

use League\ConstructFinder\ConstructFinder;

// Find all constructs
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')
    ->exclude('*Test.php', '*/Tests/*')
    ->findAll();

统计信息

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

GitHub 信息

  • Stars: 44
  • Watchers: 3
  • Forks: 5
  • 开发语言: PHP

其他信息

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