定制 poseidon/type 二次开发

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

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

poseidon/type

最新稳定版本:0.2.0

Composer 安装命令:

composer require poseidon/type

包简介

The missing PHP static analysis type contract

README 文档

README

Collection of value objects that represent the types of the PHP static analysis type system (Psalm, PHPStan).

All implementations of Type should be treated as sealed. The Type interface MUST NOT be implemented in userland. If one needs an alias for a complex compound type, implement Alias or create a builder/function instead.

This library will never have any dependencies. Once full and stable, it might be proposed as a PSR.

Installation

composer require poseidon/type

Naming

Value objects, representing native PHP types cannot be named after them, because words like Int, Strind etc. are reserved. A suffix might be introduced to fix this problem. Type suffix is too verbose, so we have chosen T: int -> IntT, float -> FloatT. Although types like non-empty-list can be safely named NonEmptyList, for now we have decided to follow the T-convention for all types.

Supported types

Scalar types

  • bool
  • int
  • positive-int
  • float
  • non-empty-string
  • string
  • literal-string
  • array-key
  • numeric-string
  • class-string
  • class-string<T>
  • interface-string
  • trait-string
  • enum-string
  • callable-string
  • numeric
  • scalar

Literals

  • null
  • true
  • false
  • -10
  • -0.34
  • 'foo'

Array types

  • list<TValue>
  • non-empty-list<TValue>
  • array<TKey, TValue>
  • non-empty-array<TKey, TValue>
  • array{foo: int, bar?: string}, array{int, string}
  • callable-array

Object types

  • object
  • Foo\MyClass<T>
  • Generator<TKey, TValue, TSend, TReturn>
  • static

Callable types

  • callable(Foo, Bar=): Baz
  • \Closure(Foo, Bar=): Baz

Constants

  • Foo\Bar::MY_SCALAR_CONST
  • key-of<Foo\Bar::ARRAY_CONST>
  • value-of<Foo\Bar::ARRAY_CONST>
  • key-of<T>, T[TKey] (example)

Other types

  • ?T
  • never
  • void
  • mixed
  • iterable<TKey, TValue>
  • resource
  • union types
  • intersection types
  • template types

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固