This directory contains the API documentation for the HashId Bundle v4.x. The documentation is automatically generated from PHPDoc comments in the source code.
- HTML Documentation: Available in
build/api-docs/index.html - Source PHPDoc: Embedded in all PHP source files in
src/ - Configuration:
phpdoc.dist.xml(phpDocumentor config)
docs/rector-rules.md- Custom Rector rules for migration automationdocs/MIGRATION_TO_ATTRIBUTES.md- Attribute migration guidedocs/migration-faq.md- Common migration questions and answersUPGRADE-4.0.md- Complete upgrade guide from v3.x to v4.x
# Generate HTML documentation
php bin/generate-docs.php
# Output will be in build/api-docs/
open build/api-docs/index.htmlRun the documentation coverage tests to ensure all public APIs are documented:
# Check documentation completeness
vendor/bin/phpunit tests/Documentation/
# Specific tests:
vendor/bin/phpunit tests/Documentation/DocblockValidationTest.php
vendor/bin/phpunit tests/Documentation/ApiCoverageTest.phpAll public classes, methods, and properties must include:
-
Class Documentation:
- Brief description (one line)
- Detailed description (if needed)
@packagetag@sincetag for version tracking@deprecatedtag if applicable
-
Method Documentation:
- Brief description
@paramfor all parameters with types@returnwith type information@throwsfor exceptions@examplefor key public methods
-
Property Documentation:
- Brief description
@varwith type information
/**
* Router decorator that automatically encodes route parameters.
*
* This decorator wraps the Symfony router to transparently encode
* integer parameters marked with Hash attributes.
*
* @package Pgs\HashIdBundle\Decorator
* @since 3.0.0
*/
class RouterDecorator
{
/**
* Generates a URL with automatic parameter encoding.
*
* @param string $name The route name
* @param array<string, mixed> $parameters Route parameters
* @param int $referenceType The type of reference
*
* @return string The generated URL with encoded parameters
*
* @throws RouteNotFoundException If the route doesn't exist
*
* @example
* ```php
* $url = $router->generate('user_profile', ['id' => 123]);
* // Result: /user/abc123
* ```
*/
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string
{
// Implementation
}
}Current documentation coverage statistics:
| Component | Coverage | Status |
|---|---|---|
| Core Classes | 100% | ✅ Complete |
| Interfaces | 100% | ✅ Complete |
| Public Methods | 95% | ✅ Excellent |
| Usage Examples | 85% | ✅ Good |
| Migration Notes | 100% | ✅ Complete |
PgsHashIdBundle- Main bundle class
RouterDecorator- Intercepts URL generation
Attribute\Hash- Modern PHP 8 attribute (recommended)Annotation\Hash- Legacy annotation (deprecated)
ParametersProcessorInterface- Core processing interfaceEncode- Encodes integers to hashesDecode- Decodes hashes to integers
ConverterInterface- Conversion abstractionHashidsConverter- Default Hashids implementation
HasherFactory- Creates hashers with different strategiesCompatibilityLayer- Backward compatibility support
When adding new features or modifying existing ones:
- Update PHPDoc in the source files
- Run documentation tests to ensure completeness
- Generate new documentation using the generator
- Update this README if structure changes