Commit eb112d2
(Changed) Performance optimisations, bug fixes, and Docker-based development setup (#45)
* refactor: Change class to final and update static method calls to self
(Changed) Make StringManipulation final and update static to self references
Make `StringManipulation` class final and replace `static` with `self`.
Converted the `StringManipulation` class to `final` to prevent inheritance and replaced all occurrences of `static` with `self` for improved clarity and static binding. Additionally, updated development dependencies in `composer.json` to their latest versions for enhanced tooling support.
* refactor: improve string processing readability
- Simplify control flow in string replacement methods
- Reduce code complexity for better maintainability
* perf: optimize string replacement logic for efficiency
- Improve performance of string manipulation operations
- Reduce unnecessary iterations in replacement algorithms
* perf: cache accent replacement mappings for better performance
- Implement caching mechanism for accent transformations
- Reduce repeated computations in accent normalization
* test: add comprehensive tests for string replacement optimizations
- Add test coverage for edge cases in string replacement
- Validate performance improvements with test cases
* refactor: remove unnecessary optimizations in strReplace method
- Simplify string replacement implementation
- Remove premature optimization attempts
* docs(project): Improve documentation accuracy and consistency
- Standardise spelling to South African English throughout codebase
- Change "optimize/optimization" to "optimise/optimisation"
- Change "normalize" to "normalise"
- Change "standardize/capitalizing" to "standardise/capitalising"
- Fix README.md documentation issues
- Remove duplicate UTF-8 to ANSI conversion section
- Correct method name from validateDate() to isValidDate()
- Remove references to non-existent validateTime() method
- Fix incorrect output descriptions for utf8Ansi examples
- Fix code quality issues
- Remove duplicate PHPDoc for removeAccents() method
- Fix duplicate 'ë' character in REMOVE_ACCENTS_FROM array
- Standardise parameter naming: $valor to $value in utf8Ansi()
- Clarify UnicodeMappings trait documentation
- Update to accurately describe Unicode escape sequence decoding
- Correct misconception about ANSI conversion functionality
These changes improve code maintainability and ensure documentation
accurately reflects the actual implementation. All tests pass.
Signed-off-by: Marjo Wenzel van Lier <marjo.vanlier@gmail.com>
* style: Fix code style issues
- Add missing periods to inline comments
- Fix array alignment in ACCENTS_REPLACEMENT
- Fix spacing in method signature
- Add parentheses around null coalescing operation
- Change dynamic method calls to static in tests
These changes address Codacy and PHPStan warnings.
Signed-off-by: Marjo Wenzel van Lier <marjo.vanlier@gmail.com>
* style: Fix binary operator spacing
Laravel Pint detected incorrect spacing around the equals sign
in the method signature default parameter.
Signed-off-by: Marjo Wenzel van Lier <marjo.vanlier@gmail.com>
* refactor: Remove unreachable null check
The null check after nameFix() was unreachable since nameFix() only
returns null when its input is null, and we already check for null
input at the beginning of searchWords().
This improves code coverage by removing dead code.
Signed-off-by: Marjo Wenzel van Lier <marjo.vanlier@gmail.com>
* fix: Add type assertion for PHPStan
PHPStan cannot infer that nameFix() only returns null when its input
is null. Added an assertion to help the static analyzer understand
the code flow better.
Signed-off-by: Marjo Wenzel van Lier <marjo.vanlier@gmail.com>
* refactor: Replace assert with type cast for PHPStan
Using assert() in production code is not recommended as assertions
can be disabled. Instead, we use a type cast to string which is safe
because we've already verified the input is not null.
Signed-off-by: Marjo Wenzel van Lier <marjo.vanlier@gmail.com>
* fix: Remove unnecessary SensitiveParameter import and fix cast spacing
- Remove duplicate SensitiveParameter import that conflicts with PHP 8's built-in attribute
- Use global \SensitiveParameter attribute instead of importing it
- Fix cast spacing to comply with PER coding standards
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: MarjovanLier <marjovanlier@gmail.com>
* feat(ci): Add pre-commit hooks with containerised testing
- Add Dockerfile for PHP 8.3 with all required extensions including xdebug
- Create docker-compose.yml with individual test services
- Set up pre-commit framework with comprehensive checks
- Add custom commit-msg hook for conventional commits validation
- Create test-runner.sh for easy test execution
- Create setup-hooks.sh for automated setup
- Add .dockerignore to optimise Docker builds
- Document setup process in CONTRIBUTING.md
- Update .gitignore with Docker and pre-commit entries
All tests now run in consistent Docker containers to avoid environment-specific issues.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: MarjovanLier <marjovanlier@gmail.com>
* fix(ci): Fix test runner script and remove docker-compose version warning
- Fix missing print_info function in test-runner.sh
- Remove obsolete version attribute from docker-compose.yml
- Fix composer validation test handling in test runner
- Add missing newlines at end of files (linter fixes)
All required tests now pass successfully in containers.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: MarjovanLier <marjovanlier@gmail.com>
* fix: resolve Phan compatibility issues with typed constants
- Remove typed array constants to support Phan polyfill parser
- Update Rector config to skip type-adding rules
- Fix import path for RemoveUselessVarTagRector
- Maintain type safety through PHPDoc annotations
- Set Phan processes to 1 to avoid pcntl requirement
All critical static analysis tools now passing (Phan, PHPStan, Rector)
* fix: suppress MissingClassConstType errors in Psalm
This allows both Phan and Psalm to pass - Phan requires untyped constants
while Psalm normally requires typed constants. By suppressing this specific
error type, we maintain compatibility with both tools.
* feat: add all composer tests to pre-commit hooks via Docker
- Add phpmd, phan, rector, and infection to pre-commit hooks
- All tests now run in Docker containers for consistency
- Infection mutation testing runs on pre-push stage
- Add helper script run-tests-docker.sh for running all tests
- Fix deprecated stage names (commit -> pre-commit, push -> pre-push)
- Enable xdebug in Docker for mutation testing support
All pre-commit hooks now passing with 98% mutation coverage
* style: add periods to inline comments in test files
- Add periods to all inline comments for consistency
- Follows coding style guidelines for comment punctuation
- Addresses CodeRabbit review feedback
* feat(hooks): Implement commitlint for conventional commit validation
- Add commitlint configuration with strict rules
- Update commit-msg hook to use commitlint via npx
- Add Docker support for commitlint when npm is not available
- Update Dockerfile to include Node.js and npm
- Add package.json for npm dependencies
- Create commitlint-docker.sh wrapper script
- Update setup script to install npm dependencies
This ensures all commit messages follow the Conventional Commits
specification with proper validation and helpful error messages.
Signed-off-by: Marjo Wenzel van Lier <marjo.vanlier@gmail.com>
* fix(config): Correct Phan configuration and pre-commit setup
- Revert Phan directory_list to include full vendor directory
- Change minimum_severity back to CRITICAL for focused analysis
- Increase Phan processes from 1 to 4 for better performance
- Remove deprecated stages declaration from PHPUnit pre-commit hook
These changes fix the Phan configuration to properly analyze vendor
dependencies while excluding them from analysis, and remove the
deprecated stage warning from pre-commit.
Signed-off-by: Marjo Wenzel van Lier <marjo.vanlier@gmail.com>
* perf: optimize string manipulation methods and fix validation bugs
- Optimize strReplace for single character replacements (69% faster)
- Optimize searchWords by combining operations (15% faster)
- Fix isValidDate to properly validate month/day combinations
- Add performance benchmarking suite
- Fix PHPStan type issues and improve null safety
- Add edge case handling for empty strings
The optimizations significantly improve performance for common use cases
while maintaining full backward compatibility. All tests pass.
Signed-off-by: Marjo Wenzel van Lier <marjo.vanlier@gmail.com>
* feat: restore typed class constants with Docker AST support
- Restored PHP 8.3+ typed class constants in AccentNormalization and UnicodeMappings traits
- Fixed Dockerfile to properly install AST extension separately from xdebug
- Updated composer.json to remove --allow-polyfill-parser flag for Phan
- Removed AddTypeToConstRector skip in rector.php configuration
- Removed MissingClassConstType suppression in psalm.xml
- Reduced Phan processes from 4 to 1 to avoid memory issues
- Fixed Psalm strict type issues in benchmark file with explicit casting
- Applied code style fixes with Pint and Rector
- Added RemoveConcatAutocastRector to skip list to avoid Psalm conflicts
- Updated .gitignore to exclude temporary and Qodana files
All static analysis tools now support typed constants when running in Docker containers
with the AST extension properly installed.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: correct PHPStan and Psalm type annotations in IsValidTimePartTest
- Updated data provider return type annotations to match exact array shape
- Fixed type mismatch between data providers and test method parameters
- Ensures both PHPStan and Psalm static analysis pass without errors
* docs: update CLAUDE.md with Docker-first testing approach
- Consolidated Docker testing commands into main Build & Testing section
- Emphasized Docker as the recommended testing environment
- Removed duplicate Docker testing commands section
- Added all available Docker test services with proper naming
- Clarified that Docker provides PHP 8.3 with AST extension
* chore: update development dependencies
- laravel/pint: >=1.21.1 -> >=1.22.1
- phpstan/phpstan: >=2.1.8 -> >=2.1.17
- phpstan/phpstan-strict-rules: >=2.0.3 -> >=2.0.4
- psalm/plugin-phpunit: >=0.19.2 -> >=0.19.3
- rector/rector: >=2.0.10 -> >=2.0.16
All tests passing with updated dependencies
* feat: configure Codacy to use PER 2.0 coding standard
- Added .php-cs-fixer.php with @PER-CS2.0 rule set
- Configured Codacy to use PHP CS Fixer with PER 2.0 standard
- Disabled phpcodesniffer in Codacy to avoid style conflicts
- Simplified pint.json to use only the 'per' preset
- Added .php-cs-fixer.cache to .gitignore
This ensures both Pint and Codacy use the same PER 2.0 coding standard
* fix: improve Codacy configuration to enforce PER 2.0 standard
- Explicitly disabled all PHP style checkers except php-cs-fixer
- Added .codacyignore to exclude non-source files
- Excluded tests/Benchmark from analysis as it has different requirements
- Disabled PHPMD to avoid style conflicts
This should resolve Codacy issues by ensuring only php-cs-fixer
with PER 2.0 standard is used for style checking
* feat: add PHP_CodeSniffer configuration for Codacy
- Added phpcs.xml with PER coding standard
- Enabled PHP_CodeSniffer in Codacy configuration
- Excluded specific rules that conflict with project standards
- Kept both PHP_CodeSniffer and php-cs-fixer enabled
This provides Codacy with explicit configuration files for both
supported tools to enforce PER 2.0 coding standard
---------
Signed-off-by: Marjo Wenzel van Lier <marjo.vanlier@gmail.com>
Signed-off-by: MarjovanLier <marjovanlier@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>1 parent d24e598 commit eb112d2
41 files changed
Lines changed: 1888 additions & 43195 deletions
File tree
- .githooks
- .phan
- src
- tests
- Benchmark
- Unit
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| |||
306 | 309 | | |
307 | 310 | | |
308 | 311 | | |
309 | | - | |
| 312 | + | |
310 | 313 | | |
311 | 314 | | |
312 | 315 | | |
| |||
356 | 359 | | |
357 | 360 | | |
358 | 361 | | |
| 362 | + | |
359 | 363 | | |
360 | 364 | | |
361 | 365 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
0 commit comments