Skip to content

Commit 9f4e0db

Browse files
author
Administrator
committed
[core] v3.0.0 – 詳見 CHANGELOG.md
2 parents 861b768 + f0ea086 commit 9f4e0db

File tree

17 files changed

+1183
-95
lines changed

17 files changed

+1183
-95
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/tests export-ignore
2+
/benchmarks export-ignore

.github/workflows/ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, v3.0.0-rc]
6+
pull_request:
7+
branches: [main, v3.0.0-rc]
8+
9+
jobs:
10+
test:
11+
strategy:
12+
matrix:
13+
php: [8.1, 8.2, 8.3, 8.4]
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up PHP
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: ${{ matrix.php }}
23+
coverage: xdebug
24+
25+
- name: Install Composer dependencies
26+
run: composer install --no-interaction --prefer-dist --no-progress
27+
28+
- name: Run PHPUnit with coverage
29+
run: vendor/bin/phpunit --configuration phpunit.xml --coverage-clover coverage.xml --coverage-text
30+
31+
- name: Upload coverage to Codecov
32+
uses: codecov/codecov-action@v4
33+
with:
34+
token: ${{ secrets.CODECOV_TOKEN }}
35+
files: coverage.xml
36+
flags: phpunit
37+
fail_ci_if_error: true
38+
39+
FOSSA:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- name: Run FOSSA scan
44+
uses: fossas/fossa-action@v1
45+
with:
46+
api-key: ${{ secrets.FOSSA_TOKEN }}
47+
48+
SONAR:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout repository
52+
uses: actions/checkout@v4
53+
54+
- name: Set up PHP
55+
uses: shivammathur/setup-php@v2
56+
with:
57+
php-version: '8.1'
58+
coverage: xdebug
59+
60+
- name: Install Composer dependencies
61+
run: composer install --no-interaction --prefer-dist --no-progress
62+
63+
- name: SonarCloud Scan
64+
uses: SonarSource/sonarcloud-github-action@v2
65+
with:
66+
projectBaseDir: .
67+
args: >
68+
-Dsonar.projectKey=ReallifeKip_ImmutableBase
69+
-Dsonar.organization=reallifekip
70+
env:
71+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
vendor/*
2+
coverage/*
3+
coverage.xml
4+
composer.lock
5+
.phpunit.result.cache

.vscode/launch.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Xdebug",
6+
"type": "php",
7+
"request": "launch",
8+
"port": 9003
9+
}
10+
]
11+
}

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
11
# CHANGELOG
22

3+
## [v3.0.0] - 2025-10-13
4+
5+
### ⚠️ 重大變更
6+
7+
- 最低 PHP 支援版本提升從 8.0 提高至 8.1
8+
9+
### 🐞 修正
10+
11+
- 修復 with 寫入 null 時 valueDecide 仍返回原始值的問題
12+
13+
### ✨ 功能改進
14+
15+
- 移除 construct Enum 檢查邏輯,移至 valueDecide
16+
- 優化 walkProperties 物件判斷條件
17+
- 新增多層繼承屬性鏈巡覽與宣告層級過濾機制
18+
- 擴展 Enum 支援度:現允許以 Enum 實例、key、value 方式傳入
19+
20+
### 📜 測試
21+
22+
- 新增 defaultBench,涵蓋 Basic、Advanced、Enum 相關性能場景
23+
- 新增 phpbench 設定檔,統一自動載入與輸出格式
24+
- 確立核心建構、序列化、巢狀結構與 with 操作效能基線
25+
- 新增 Basic、Advanced、Initialized、Enum 等測試物件
26+
- 建立完整測試(覆蓋率 100%),覆蓋所有核心行為與例外情境
27+
28+
### 🧰 開發與持續整合
29+
- 新增 phpunit 自動化測試及產出報告 #範圍涵蓋 PHP 8.1 ~ 8.4
30+
- 新增 FOSSA 相依與安全性檢測
31+
- 新增 SONAR 品質檢測
32+
33+
### 🔧 重構
34+
35+
- 簡化 toArray 代碼結構
36+
- 提升整體可讀性
37+
338
## [v2.4.5] - 2025-09-12
439

540
### 🐞 修正

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Kip (Feng-Qi, Yang.)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

100644100755
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# ImmutableBase
22

3+
![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)
4+
![PHP Version Support](https://img.shields.io/packagist/php-v/reallifekip/immutable-base.svg?style=flat-square)
5+
![Packagist Version](https://img.shields.io/packagist/v/reallifekip/immutable-base.svg?style=flat-square)
6+
7+
[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B57865%2Fgithub.com%2FReallifeKip%2FImmutableBase.svg?type=small)](https://app.fossa.com/projects/custom%2B57865%2Fgithub.com%2FReallifeKip%2FImmutableBase?ref=badge_small)
8+
![Coverage](https://img.shields.io/codecov/c/github/ReallifeKip/ImmutableBase?style=flat-square&logo=codecov&color=289e6d)
9+
10+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ReallifeKip_ImmutableBase&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=ReallifeKip_ImmutableBase)
11+
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=ReallifeKip_ImmutableBase&metric=bugs)](https://sonarcloud.io/summary/new_code?id=ReallifeKip_ImmutableBase)
12+
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=ReallifeKip_ImmutableBase&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=ReallifeKip_ImmutableBase)
13+
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=ReallifeKip_ImmutableBase&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=ReallifeKip_ImmutableBase)
14+
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=ReallifeKip_ImmutableBase&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=ReallifeKip_ImmutableBase)
15+
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=ReallifeKip_ImmutableBase&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=ReallifeKip_ImmutableBase)
16+
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=ReallifeKip_ImmutableBase&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=ReallifeKip_ImmutableBase)
17+
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=ReallifeKip_ImmutableBase&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=ReallifeKip_ImmutableBase)
18+
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=ReallifeKip_ImmutableBase&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=ReallifeKip_ImmutableBase)
19+
20+
![CI](https://img.shields.io/github/actions/workflow/status/ReallifeKip/ImmutableBase/ci.yml?style=flat-square&logo=github&color=289e6d&label=CI)
21+
![Downloads](https://img.shields.io/packagist/dt/reallifekip/immutable-base.svg?style=flat-square&color=289e6d&label=📦%20downloads&logoColor=white)
22+
323
一個專為 **不可變物件(Immutable Object)** 設計的抽象基底類別,適用於 **DTO(Data Transfer Object)****VO(Value Object)** 等需要「一次初始化、不可更改」的場景。
424

525
此類別強調資料的**不可變性(Immutability)****類型安全(Type Safety)**,並可透過建構式快速初始化、內建型別自動轉換機制、淺層複製 (`with`) 以及自動序列化支援 (`toArray`, `jsonSerialize`)。
@@ -20,6 +40,17 @@
2040

2141
---
2242

43+
## 測試
44+
45+
### 單元測試
46+
```bash
47+
vendor/bin/phpunit tests
48+
```
49+
### 效能測試
50+
```bash
51+
vendor/bin/phpbench run
52+
```
53+
2354
## 使用方式
2455

2556
### 1. 建立你的不可變物件類別
@@ -177,7 +208,7 @@ $userList = new UserListDTO([
177208
]);
178209

179210
// users 和 tags 陣列中的每個元素都會自動轉換為對應的 DTO 實例
180-
````
211+
```
181212

182213
---
183214

0 commit comments

Comments
 (0)