Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d79af5f
Update README.md
Nejcc Nov 14, 2024
947ddb3
feat: add integer types and traits
May 30, 2025
d4c266d
feat: add string types and abstractions
May 30, 2025
56fbe10
feat: add array types and abstractions
May 30, 2025
85895f8
feat: add composite types (Json, Struct, Union, Dictionary, ListData)
May 30, 2025
947a9bf
test: add tests for IntArray, Json, Struct, Union, Dictionary, and Li…
May 30, 2025
0be7a76
fix: align ByteTest to expect OutOfRangeException for invalid byte va…
May 30, 2025
29978d7
Add missing exception classes: TypeMismatchException, ImmutableExcept…
May 30, 2025
7ef80d4
Implement DataTypeInterface methods in TypeSafeArray and fix setValue…
May 30, 2025
00d3fcb
Fix testIsFieldRequired by providing a default value for required field
May 30, 2025
fa35f67
Add core interfaces and exceptions for type system
May 30, 2025
ab71390
Add ImmutableStruct implementation with validation rules
May 30, 2025
20fc451
Add Vector implementation with abstract base class
May 30, 2025
aceca21
Add TypeSafeArray implementation with type constraints and update sca…
May 30, 2025
c5e02a2
Update .gitignore to exclude build directory
May 30, 2025
f4bd3af
Implement DynamicArray with capacity management, fix FixedSizeArray w…
May 30, 2025
8e4bc6d
feat: implement core features and refactoring
May 30, 2025
e8a910b
feat: update to PHP 8.4 and add CI support
Oct 20, 2025
7abc92d
feat: add static analysis and code quality tools
Oct 20, 2025
648abd1
feat: enhance Dictionary with missing methods
Oct 20, 2025
3aad116
feat: add algebraic data types for better error handling
Oct 20, 2025
2b70fb9
feat: add comprehensive Laravel integration
Oct 20, 2025
f0501c3
feat: add attribute-based validation system
Oct 20, 2025
8d7ad9c
feat: implement PHP 8.4 array functions for better performance
Oct 20, 2025
251faa4
refactor: improve type safety in abstract classes
Oct 20, 2025
afe6b54
feat: add comprehensive benchmark suite
Oct 20, 2025
ca08bc8
docs: update documentation and add comprehensive examples
Oct 20, 2025
9283f1a
chore: update composer.lock with new dependencies
Oct 20, 2025
c3c66e3
docs: update README to showcase PHP 8.4 features
Oct 20, 2025
8fedd90
Merge pull request #15 from Nejcc/update
Nejcc Oct 20, 2025
05dba1f
chore(benchmarks): wire benchmarks/ into composer autoload
Nejcc May 28, 2026
c66641c
perf(arrays): foreach validation + fromTrusted() factories
Nejcc May 28, 2026
20a8eb9
perf(integers): inline arithmetic, trusted constructor, drop dead code
Nejcc May 28, 2026
2c442de
perf(integers): add Int8::of() flyweight cache
Nejcc May 28, 2026
e456085
perf(floats): trusted constructor on AbstractFloat
Nejcc May 28, 2026
7543b37
perf(integers): add UInt8::of() and Byte::of() flyweight caches
Nejcc May 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.2, 8.3]
php: [8.2, 8.3, 8.4]
stability: [prefer-lowest, prefer-stable]

name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ yarn-error.log
/.vscode
vendor
vendor/
composer.lock
composer.lock
todo.txt
/build/**
109 changes: 109 additions & 0 deletions .phpstorm.meta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php

namespace PHPSTORM_META {

// Helper functions for PHP Datatypes
override(\int8(0), map([
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int8::class,
]));

override(\int16(0), map([
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16::class,
]));

override(\int32(0), map([
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int32::class,
]));

override(\int64(0), map([
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int64::class,
]));

override(\uint8(0), map([
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt8::class,
]));

override(\uint16(0), map([
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt16::class,
]));

override(\uint32(0), map([
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt32::class,
]));

override(\uint64(0), map([
'' => \Nejcc\PhpDatatypes\Scalar\Integers\Unsigned\UInt64::class,
]));

override(\float32(0.0), map([
'' => \Nejcc\PhpDatatypes\Scalar\FloatingPoints\Float32::class,
]));

override(\float64(0.0), map([
'' => \Nejcc\PhpDatatypes\Scalar\FloatingPoints\Float64::class,
]));

override(\char(''), map([
'' => \Nejcc\PhpDatatypes\Scalar\Char::class,
]));

override(\byte(0), map([
'' => \Nejcc\PhpDatatypes\Scalar\Byte::class,
]));

override(\some(0), map([
'' => \Nejcc\PhpDatatypes\Composite\Option::class,
]));

override(\none(), map([
'' => \Nejcc\PhpDatatypes\Composite\Option::class,
]));

override(\option(0), map([
'' => \Nejcc\PhpDatatypes\Composite\Option::class,
]));

override(\ok(0), map([
'' => \Nejcc\PhpDatatypes\Composite\Result::class,
]));

override(\err(0), map([
'' => \Nejcc\PhpDatatypes\Composite\Result::class,
]));

override(\result(function(){}), map([
'' => \Nejcc\PhpDatatypes\Composite\Result::class,
]));

override(\stringArray([]), map([
'' => \Nejcc\PhpDatatypes\Composite\Arrays\StringArray::class,
]));

override(\intArray([]), map([
'' => \Nejcc\PhpDatatypes\Composite\Arrays\IntArray::class,
]));

override(\floatArray([]), map([
'' => \Nejcc\PhpDatatypes\Composite\Arrays\FloatArray::class,
]));

override(\byteSlice([]), map([
'' => \Nejcc\PhpDatatypes\Composite\Arrays\ByteSlice::class,
]));

override(\listData([]), map([
'' => \Nejcc\PhpDatatypes\Composite\ListData::class,
]));

override(\dictionary([]), map([
'' => \Nejcc\PhpDatatypes\Composite\Dictionary::class,
]));

override(\struct([]), map([
'' => \Nejcc\PhpDatatypes\Composite\Struct\Struct::class,
]));

override(\union([], []), map([
'' => \Nejcc\PhpDatatypes\Composite\Union\UnionType::class,
]));
}
76 changes: 73 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,77 @@
# Changelog

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

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

- initial release
## [2.0.0] - 2024-12-19

### Added
- PHP 8.4 compatibility and CI testing
- PHPStan static analysis configuration (level 9)
- `Dictionary::toArray()`, `isEmpty()`, and `getAll()` methods
- Benchmark suite for performance testing
- `Option<T>` type for nullable values
- `Result<T, E>` type for error handling
- Mutation testing with Infection
- Laravel integration (validation rules, service provider)
- PHPStorm metadata for better IDE support
- Comprehensive example demonstrating all features

### Changed
- **BREAKING:** All concrete datatype classes are now `final` to prevent inheritance issues
- **BREAKING:** All methods now have explicit return types for better type safety
- **BREAKING:** All Laravel validation rules and casts are now `final`
- Updated minimum PHP version requirement to ^8.4
- Enhanced CI workflow to test PHP 8.4
- Improved code quality with static analysis
- Enhanced parameter type declarations throughout the codebase

### Fixed
- Missing serialization methods in Dictionary class
- Missing return types in various methods
- Parameter type declarations for better type safety

### Migration Guide

If you were extending any datatype classes, you'll need to use composition instead:

**Before (v1.x):**
```php
class MyCustomInt8 extends Int8 {
// custom implementation
}
```

**After (v2.0):**
```php
class MyCustomInt8 {
private Int8 $int8;

public function __construct(int $value) {
$this->int8 = new Int8($value);
}

public function getValue(): int {
return $this->int8->getValue();
}

// delegate other methods as needed
}
```

## [1.0.0] - 2024-12-19

### Added
- Initial release with comprehensive type system
- Scalar types: Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128
- Floating point types: Float32, Float64
- Boolean, Char, and Byte types
- Composite types: Arrays, Structs, Unions, Lists, Dictionaries
- String types: AsciiString, Utf8String, EmailString, and 20+ specialized string types
- Vector types: Vec2, Vec3, Vec4
- Serialization support: JSON, XML, Binary
- Comprehensive test suite (592 tests, 1042 assertions)
- Helper functions for all types
- Type-safe operations with overflow/underflow protection
Loading
Loading