jessegall/php-types 问题修复 & 功能扩展

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

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

jessegall/php-types

Composer 安装命令:

composer require jessegall/php-types

包简介

Named typed constants and predicates — give meaning to magic literals like '', [], '{}', 0, true and null.

README 文档

README

Named typed constants and predicates — give meaning to magic literals.

A raw '', [], '{}', 0, true, or null carries an unstated intent and gets re-checked defensively all over a codebase (if ($this->delimiter === '')). These tiny static classes give that intent a name and the check a single home.

use JesseGall\PhpTypes\T_String;

$prefix = T_String::empty();              // '' with a name
if (T_String::isEmpty($delimiter)) { … }  // reads as intent

// as a first-class callable
$nonEmpty = array_filter($parts, T_String::isNotEmpty(...));

Types

Class Constant(s) Factory Predicates
T_String EMPTY, SPACE, NEWLINE, PARAGRAPH, CARRIAGE_RETURN, CRLF, TAB, NULL_BYTE, COMMA, COMMA_SPACE, SLASH, DOT, DASH empty() isEmpty(), isNotEmpty(), isBlank(), isNotBlank()
T_Array EMPTY, MATRIX empty(), matrix() isEmpty(), isNotEmpty()
T_Json EMPTY_OBJECT, EMPTY_ARRAY emptyObject(), emptyArray() isEmptyObject(), isEmptyArray()
T_Int ZERO, ONE, MINUS_ONE zero() isZero(), isNotZero()
T_Float ZERO zero() isZero(), isNotZero()
T_Bool TRUE, FALSE isTrue(), isFalse()
T_Null isNull(), isNotNull()

T_Json predicates are semantic — isEmptyObject('{ }') and isEmptyObject("{\n}") are true (they decode to an empty object), while isEmptyObject('[]') and invalid JSON are false.

Install

composer require jessegall/php-types

Requires PHP 8.2+. Zero runtime dependencies.

Test

composer test

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固