Skip to content

Commit 8fedd90

Browse files
authored
Merge pull request #15 from Nejcc/update
Update
2 parents 0be7a76 + c3c66e3 commit 8fedd90

File tree

122 files changed

+11465
-693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+11465
-693
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
fail-fast: true
1010
matrix:
1111
os: [ubuntu-latest, windows-latest]
12-
php: [8.2, 8.3]
12+
php: [8.2, 8.3, 8.4]
1313
stability: [prefer-lowest, prefer-stable]
1414

1515
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ yarn-error.log
2020
vendor
2121
vendor/
2222
composer.lock
23-
todo.txt
23+
todo.txt
24+
/build/**

.phpstorm.meta.php

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?php
2+
3+
namespace PHPSTORM_META {
4+
5+
// Helper functions for PHP Datatypes
6+
override(\int8(0), map([
7+
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int8::class,
8+
]));
9+
10+
override(\int16(0), map([
11+
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16::class,
12+
]));
13+
14+
override(\int32(0), map([
15+
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int32::class,
16+
]));
17+
18+
override(\int64(0), map([
19+
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int64::class,
20+
]));
21+
22+
override(\uint8(0), map([
23+
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt8::class,
24+
]));
25+
26+
override(\uint16(0), map([
27+
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt16::class,
28+
]));
29+
30+
override(\uint32(0), map([
31+
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt32::class,
32+
]));
33+
34+
override(\uint64(0), map([
35+
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt64::class,
36+
]));
37+
38+
override(\float32(0.0), map([
39+
'' => \Nejcc\PhpDatatypes\Scalar\FloatingPoints\Float32::class,
40+
]));
41+
42+
override(\float64(0.0), map([
43+
'' => \Nejcc\PhpDatatypes\Scalar\FloatingPoints\Float64::class,
44+
]));
45+
46+
override(\char(''), map([
47+
'' => \Nejcc\PhpDatatypes\Scalar\Char::class,
48+
]));
49+
50+
override(\byte(0), map([
51+
'' => \Nejcc\PhpDatatypes\Scalar\Byte::class,
52+
]));
53+
54+
override(\some(0), map([
55+
'' => \Nejcc\PhpDatatypes\Composite\Option::class,
56+
]));
57+
58+
override(\none(), map([
59+
'' => \Nejcc\PhpDatatypes\Composite\Option::class,
60+
]));
61+
62+
override(\option(0), map([
63+
'' => \Nejcc\PhpDatatypes\Composite\Option::class,
64+
]));
65+
66+
override(\ok(0), map([
67+
'' => \Nejcc\PhpDatatypes\Composite\Result::class,
68+
]));
69+
70+
override(\err(0), map([
71+
'' => \Nejcc\PhpDatatypes\Composite\Result::class,
72+
]));
73+
74+
override(\result(function(){}), map([
75+
'' => \Nejcc\PhpDatatypes\Composite\Result::class,
76+
]));
77+
78+
override(\stringArray([]), map([
79+
'' => \Nejcc\PhpDatatypes\Composite\Arrays\StringArray::class,
80+
]));
81+
82+
override(\intArray([]), map([
83+
'' => \Nejcc\PhpDatatypes\Composite\Arrays\IntArray::class,
84+
]));
85+
86+
override(\floatArray([]), map([
87+
'' => \Nejcc\PhpDatatypes\Composite\Arrays\FloatArray::class,
88+
]));
89+
90+
override(\byteSlice([]), map([
91+
'' => \Nejcc\PhpDatatypes\Composite\Arrays\ByteSlice::class,
92+
]));
93+
94+
override(\listData([]), map([
95+
'' => \Nejcc\PhpDatatypes\Composite\ListData::class,
96+
]));
97+
98+
override(\dictionary([]), map([
99+
'' => \Nejcc\PhpDatatypes\Composite\Dictionary::class,
100+
]));
101+
102+
override(\struct([]), map([
103+
'' => \Nejcc\PhpDatatypes\Composite\Struct\Struct::class,
104+
]));
105+
106+
override(\union([], []), map([
107+
'' => \Nejcc\PhpDatatypes\Composite\Union\UnionType::class,
108+
]));
109+
}

CHANGELOG.md

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,77 @@
11
# Changelog
22

3-
All notable changes to `php-datatypes` will be documented in this file
3+
All notable changes to `php-datatypes` will be documented in this file.
44

5-
## 1.0.0 - 201X-XX-XX
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
67

7-
- initial release
8+
## [2.0.0] - 2024-12-19
9+
10+
### Added
11+
- PHP 8.4 compatibility and CI testing
12+
- PHPStan static analysis configuration (level 9)
13+
- `Dictionary::toArray()`, `isEmpty()`, and `getAll()` methods
14+
- Benchmark suite for performance testing
15+
- `Option<T>` type for nullable values
16+
- `Result<T, E>` type for error handling
17+
- Mutation testing with Infection
18+
- Laravel integration (validation rules, service provider)
19+
- PHPStorm metadata for better IDE support
20+
- Comprehensive example demonstrating all features
21+
22+
### Changed
23+
- **BREAKING:** All concrete datatype classes are now `final` to prevent inheritance issues
24+
- **BREAKING:** All methods now have explicit return types for better type safety
25+
- **BREAKING:** All Laravel validation rules and casts are now `final`
26+
- Updated minimum PHP version requirement to ^8.4
27+
- Enhanced CI workflow to test PHP 8.4
28+
- Improved code quality with static analysis
29+
- Enhanced parameter type declarations throughout the codebase
30+
31+
### Fixed
32+
- Missing serialization methods in Dictionary class
33+
- Missing return types in various methods
34+
- Parameter type declarations for better type safety
35+
36+
### Migration Guide
37+
38+
If you were extending any datatype classes, you'll need to use composition instead:
39+
40+
**Before (v1.x):**
41+
```php
42+
class MyCustomInt8 extends Int8 {
43+
// custom implementation
44+
}
45+
```
46+
47+
**After (v2.0):**
48+
```php
49+
class MyCustomInt8 {
50+
private Int8 $int8;
51+
52+
public function __construct(int $value) {
53+
$this->int8 = new Int8($value);
54+
}
55+
56+
public function getValue(): int {
57+
return $this->int8->getValue();
58+
}
59+
60+
// delegate other methods as needed
61+
}
62+
```
63+
64+
## [1.0.0] - 2024-12-19
65+
66+
### Added
67+
- Initial release with comprehensive type system
68+
- Scalar types: Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128
69+
- Floating point types: Float32, Float64
70+
- Boolean, Char, and Byte types
71+
- Composite types: Arrays, Structs, Unions, Lists, Dictionaries
72+
- String types: AsciiString, Utf8String, EmailString, and 20+ specialized string types
73+
- Vector types: Vec2, Vec3, Vec4
74+
- Serialization support: JSON, XML, Binary
75+
- Comprehensive test suite (592 tests, 1042 assertions)
76+
- Helper functions for all types
77+
- Type-safe operations with overflow/underflow protection

0 commit comments

Comments
 (0)