Skip to content

[Phase 1] v2.0 Architecture Refactoring - Directory Structure and Core Interfaces#49

Merged
gmajor-encrypt merged 5 commits intomasterfrom
feature/v2-architecture-refactor
Mar 20, 2026
Merged

[Phase 1] v2.0 Architecture Refactoring - Directory Structure and Core Interfaces#49
gmajor-encrypt merged 5 commits intomasterfrom
feature/v2-architecture-refactor

Conversation

@gmajor-encrypt
Copy link
Copy Markdown
Owner

Summary

This PR implements the Phase 1 architecture refactoring for php-scale-codec v2.0, establishing a modern foundation for the SCALE codec library.

Changes

Directory Structure

src/
├── Bytes/          # Byte manipulation utilities
├── Encoder/        # Encoder interfaces
├── Decoder/        # Decoder interfaces
├── Types/          # Type definitions and implementations
├── Metadata/       # Metadata parsing (Phase 3)
├── Extrinsic/      # Extrinsic handling (Phase 3)
└── Exception/      # Exception classes

Core Components

  • ScaleType enum - PHP 8.2 enum for all SCALE types
  • TypeInterface - Core interface for all types
  • EncoderInterface - Interface for encoders
  • DecoderInterface - Interface for decoders
  • TypeRegistry - Type registration with freeze mechanism
  • TypeFactory - Factory for creating types from strings
  • AbstractType - Base class for type implementations
  • ScaleBytes - Refactored byte manipulation class

Exception Classes

  • ScaleEncodeException - Encoding errors
  • ScaleDecodeException - Decoding errors
  • InvalidTypeException - Type validation errors

Tests

  • ScaleBytesTest - Byte manipulation tests
  • ScaleTypeTest - Enum tests
  • TypeRegistryTest - Registry tests

Technical Details

  • PHP 8.2+ with modern features (enums, readonly properties)
  • Immutable design for ScaleBytes
  • Thread-safe TypeRegistry with freeze mechanism
  • PSR-12 code style
  • PHPUnit 10 configuration

Task List

  • Adjust directory structure
  • Define core interfaces
  • Define ScaleType enum using PHP 8.2
  • Implement TypeRegistry
  • Refactor ScaleBytes class
  • Define exception classes
  • Unit tests for core functionality

Related Issue

Closes #31

Next Steps

ck and others added 5 commits March 13, 2026 23:11
- Modern directory structure (src/Encoder, src/Decoder, src/Types, src/Bytes, src/Exception)
- Core interfaces: EncoderInterface, DecoderInterface, TypeInterface
- PHP 8.2 ScaleType enum for all SCALE types
- TypeRegistry with freeze mechanism for thread safety
- Refactored ScaleBytes with immutable design
- Exception classes: ScaleEncodeException, ScaleDecodeException, InvalidTypeException
- AbstractType base class for type implementations
- TypeFactory for parsing type strings
- Unit tests for core components
- PHPUnit 10 and PHPStan configuration

Closes #31
@gmajor-encrypt gmajor-encrypt merged commit 5a19ef1 into master Mar 20, 2026
1 check passed
@gmajor-encrypt gmajor-encrypt deleted the feature/v2-architecture-refactor branch March 20, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Phase 1] Basic Architecture Refactoring - Directory Structure and Core Interfaces

1 participant