定制 valksor/php-functions-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

valksor/php-functions-php

Composer 安装命令:

composer require valksor/php-functions-php

包简介

A PHP library providing enhanced PHP utility functions for reflection, introspection, and general PHP programming tasks

README 文档

README

valksor BSD-3-Clause Coverage Status php

A PHP library providing enhanced PHP utility functions for reflection, introspection, and general PHP programming tasks.

Installation

Install the package via Composer:

composer require valksor/php-functions-php

Requirements

PHP 8.4 or higher

Usage

There are two ways to use this package: via the Functions class or by directly using the traits.

Using the Functions Class

The Functions class provides a wide range of PHP utility functions.

use Valksor\Component\Functions\Functions;

// Create a new Functions instance
$php = new Functions();

// Get methods of a class
$methods = $php->classMethods(SomeClass::class);

// Get methods of a class that are not inherited from a parent
$ownMethods = $php->classMethods(SomeClass::class, ParentClass::class);

// Get system information
$sysInfo = $php->systemInfo(); // Returns OS, architecture, and file extension info

// Convert an object to an array
$array = $php->array($someObject);

// Check if an attribute exists on a class or method
$hasAttribute = $php->attributeExists(SomeClass::class, SomeAttribute::class);

// Get class constants
$constants = $php->classConstants(SomeClass::class);

Using Traits Directly

Alternatively, you can use the traits directly in your own classes:

use Valksor\Functions\Php\Traits\_ClassMethods;
use Valksor\Functions\Php\Traits\_SystemInfo;
use Valksor\Functions\Php\Traits\_Array;

class MyClass
{
    // Import the traits you need
    use _ClassMethods;
    use _SystemInfo;
    use _Array;

    public function doSomething(): void
    {
        // Use the methods directly
        $methods = $this->classMethods(SomeClass::class);
        $sysInfo = $this->systemInfo();
        $array = $this->array($someObject);
    }
}

Note that some traits may depend on other helper traits. The Functions class handles these dependencies for you, but if you use the traits directly, you may need to include these helper traits as well.

Features

  • Class reflection: Get class methods with inheritance filtering
  • Attribute checking: Check for PHP 8+ attributes on classes and methods
  • System information: Get OS, architecture, and file extension details
  • Object conversion: Convert objects to arrays recursively
  • Class constants: Retrieve class constants efficiently
  • Trait-based architecture: Use individual traits for specific functionality
  • Flexible usage: Choose between Functions class or direct trait usage

For a complete list of all functions available in this package, see Features.

Contributing

Contributions are welcome!

  • Code style requirements (PSR-12)
  • Testing requirements for PRs
  • One feature per pull request
  • Development setup instructions

To contribute to Php functions:

  1. Fork repository
  2. Create a feature branch (git checkout -b feature/new-php-function)
  3. Implement your function following existing patterns
  4. Add comprehensive tests including edge cases
  5. Ensure all tests pass and code style is correct
  6. Submit a pull request

Security

If you discover any security-related issues, please email us at packages@valksor.com instead of using the issue tracker.

Support

Credits

License

This package is licensed under the BSD-3-Clause License.

About Valksor

This package is part of the valksor/php-valksor project - a comprehensive PHP library and Symfony bundle that provides a collection of utilities, components, and integrations for Symfony applications.

The main project includes:

  • Various utility functions and components
  • Doctrine ORM tools and extensions
  • Symfony bundle for easy configuration
  • And much more

If you find this PHP component useful, you might want to check out the full Valksor project for additional tools and utilities that can enhance your Symfony application development.

To install the complete package:

composer require valksor/php-valksor

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2025-10-27