定制 eboreum/immutable-interface 二次开发

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

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

eboreum/immutable-interface

Composer 安装命令:

composer require eboreum/immutable-interface

包简介

Flag a class as being immutable by implementing the ImmutableInterface. An immutable object must never change its state; i.e. its class properties must remain unchanged after instantiation or cloning.

关键字:

README 文档

README

license pipeline status PHPStan Level

eboreum-immutable-interface

Implement Eboreum\ImmutableInterface\ImmutableInterface on any class to flag it as being immutable. An immutable object must never change its state; i.e. its class properties must remain unchanged after instantiation or cloning.

Normal inheritance applies. Meaning once a class or interface has implemented/extended Eboreum\ImmutableInterface\ImmutableInterface, every child class/interface must also be considered to be immutable.

While you are not allowed to change the state of an object (e.g. through set... methods), you may instead do so on a clone and then return said clone. This is typically done using with... methods, which should have the return type static.

An alternative

If you do not like the inheritance pattern or if you have specific cases where you do not want inheritance to apply, you may instead use these libraries in combination:

  1. php-static-analysis/attributes: Defines the @immutable annotation.
  2. php-static-analysis/phpstan-extension: A --dev package, which reacts to the annotations defined in php-static-analysis/attributes (bullet 1).

Requirements

"php": "^8.5"

Installation

Via Composer (https://packagist.org/packages/eboreum/immutable-interface):

composer require eboreum/immutable-interface

Via GitLab:

git clone git@gitlab.com:eboreum/immutable-interface.git

License & Disclaimer

See LICENSE file. Basically: Use this library at your own risk.

Contributing

We prefer that you create an issue and or a merge request at https://gitlab.com/eboreum/immutable-interface, and have a discussion about a feature or bug here.

Credits

Authors

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固