diff --git a/.github/ISSUE_TEMPLATE/1_Bug_report.yaml b/.github/ISSUE_TEMPLATE/1_Bug_report.yaml index 275ee58..4e88b94 100644 --- a/.github/ISSUE_TEMPLATE/1_Bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/1_Bug_report.yaml @@ -3,40 +3,40 @@ description: ⚠️ NEVER report security issues, email security AT spomky-labs. labels: Bug body: - type: input - id: affected-versions - attributes: - label: Version(s) affected - placeholder: x.y.z - validations: - required: true + id: affected-versions + attributes: + label: Version(s) affected + placeholder: x.y.z + validations: + required: true - type: textarea - id: description - attributes: - label: Description - description: A clear and concise description of the problem - validations: - required: true + id: description + attributes: + label: Description + description: A clear and concise description of the problem + validations: + required: true - type: textarea - id: how-to-reproduce - attributes: - label: How to reproduce - description: | - ⚠️ This is the most important part of the report ⚠️ - Without a way to easily reproduce your issue, there is little chance we will be able to help you and work on a fix. - Please, take the time to show us some code and/or config that is needed for others to reproduce the problem easily. - Most of the time, creating a "bug reproducer" is the best way to help us and increases the chances someone - will have a look at it. - validations: - required: true + id: how-to-reproduce + attributes: + label: How to reproduce + description: | + ⚠️ This is the most important part of the report ⚠️ + Without a way to easily reproduce your issue, there is little chance we will be able to help you and work on a fix. + Please, take the time to show us some code and/or config that is needed for others to reproduce the problem easily. + Most of the time, creating a "bug reproducer" is the best way to help us and increases the chances someone + will have a look at it. + validations: + required: true - type: textarea - id: possible-solution - attributes: - label: Possible Solution - description: | - Optional: only if you have suggestions on a fix/reason for the bug - Don't hesitate to create a pull request with your solution, it helps get faster feedback. + id: possible-solution + attributes: + label: Possible Solution + description: | + Optional: only if you have suggestions on a fix/reason for the bug + Don't hesitate to create a pull request with your solution, it helps get faster feedback. - type: textarea - id: additional-context - attributes: - label: Additional Context - description: "Optional: any other context about the problem: log messages, screenshots, etc." + id: additional-context + attributes: + label: Additional Context + description: "Optional: any other context about the problem: log messages, screenshots, etc." diff --git a/.github/ISSUE_TEMPLATE/2_Feature_request.yaml b/.github/ISSUE_TEMPLATE/2_Feature_request.yaml index bd300eb..74947c5 100644 --- a/.github/ISSUE_TEMPLATE/2_Feature_request.yaml +++ b/.github/ISSUE_TEMPLATE/2_Feature_request.yaml @@ -2,16 +2,16 @@ name: 🚀 Feature Request description: RFC and ideas for new features and improvements body: - type: textarea - id: description - attributes: - label: Description - description: A clear and concise description of the new feature - validations: - required: true + id: description + attributes: + label: Description + description: A clear and concise description of the new feature + validations: + required: true - type: textarea - id: example - attributes: - label: Example - description: | - A simple example of the new feature in action (include PHP code, YAML config, etc.) - If the new feature changes an existing feature, include a simple before/after comparison. + id: example + attributes: + label: Example + description: | + A simple example of the new feature in action (include PHP code, YAML config, etc.) + If the new feature changes an existing feature, include a simple before/after comparison. diff --git a/.github/ISSUE_TEMPLATE/3_Documentation.yaml b/.github/ISSUE_TEMPLATE/3_Documentation.yaml index 7a3dc17..30d82ea 100644 --- a/.github/ISSUE_TEMPLATE/3_Documentation.yaml +++ b/.github/ISSUE_TEMPLATE/3_Documentation.yaml @@ -2,9 +2,9 @@ name: 📖 Documentation Issue description: To report typo or obsolete section in the documentation body: - type: textarea - id: description - attributes: - label: Description - description: A clear and concise description of the error you found in the documentation - validations: - required: true + id: description + attributes: + label: Description + description: A clear and concise description of the error you found in the documentation + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index c7d0e1a..d1aa0b7 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,8 +1,8 @@ blank_issues_enabled: false contact_links: - name: Support Question - url: https://spomky-labs.com/contact/ - about: | - We use GitHub issues only to discuss about bugs and new features. - For this kind of questions about using the framework or third-party bundles, - please email us contact AT spomky-labs.com for quoting + url: https://spomky-labs.com/contact/ + about: | + We use GitHub issues only to discuss about bugs and new features. + For this kind of questions about using the framework or third-party bundles, + please email us contact AT spomky-labs.com for quoting diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cc00965..ee5284b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,19 +1,19 @@ version: 2 updates: - package-ecosystem: "composer" - directory: "/" - schedule: - interval: "weekly" - day: "friday" - versioning-strategy: "widen" - open-pull-requests-limit: 20 - allow: - - dependency-type: all - labels: [ "Dependencies" ] + directory: "/" + schedule: + interval: "weekly" + day: "friday" + versioning-strategy: "widen" + open-pull-requests-limit: 20 + allow: + - dependency-type: all + labels: [ "Dependencies" ] - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "monthly" - open-pull-requests-limit: 20 - labels: [ "Dependencies" ] + directory: "/" + schedule: + interval: "monthly" + open-pull-requests-limit: 20 + labels: [ "Dependencies" ] diff --git a/Makefile b/Makefile index aa9acad..007ce04 100644 --- a/Makefile +++ b/Makefile @@ -1,50 +1,50 @@ mu: vendor ## Mutation tests - vendor/bin/infection -s --threads=$$(nproc) --min-msi=3 --min-covered-msi=58 + vendor/bin/infection -s --threads=$$(nproc) --min-msi=3 --min-covered-msi=58 tests: vendor ## Run all tests - vendor/bin/phpunit --color + vendor/bin/phpunit --color cc: vendor ## Show test coverage rates (HTML) - vendor/bin/phpunit --coverage-html ./build + vendor/bin/phpunit --coverage-html ./build cs: vendor ## Fix all files using defined ECS rules - vendor/bin/ecs check --fix + vendor/bin/ecs check --fix tu: vendor ## Run only unit tests - vendor/bin/phpunit --color --group Unit + vendor/bin/phpunit --color --group Unit ti: vendor ## Run only integration tests - vendor/bin/phpunit --color --group Integration + vendor/bin/phpunit --color --group Integration tf: vendor ## Run only functional tests - vendor/bin/phpunit --color --group Functional + vendor/bin/phpunit --color --group Functional st: vendor ## Run static analyse - vendor/bin/phpstan analyse + vendor/bin/phpstan analyse ################################################ ci-mu: vendor ## Mutation tests (for Github only) - vendor/bin/infection --logger-github -s --threads=$$(nproc) --min-msi=3 --min-covered-msi=58 + vendor/bin/infection --logger-github -s --threads=$$(nproc) --min-msi=3 --min-covered-msi=58 ci-cc: vendor ## Show test coverage rates (console) - vendor/bin/phpunit --coverage-text + vendor/bin/phpunit --coverage-text ci-cs: vendor ## Check all files using defined ECS rules - vendor/bin/ecs check + vendor/bin/ecs check ################################################ vendor: composer.json composer.lock - composer validate - composer install + composer validate + composer install rector: vendor ## Check all files using Rector - vendor/bin/rector process --ansi --dry-run --xdebug + vendor/bin/rector process --ansi --dry-run --xdebug .DEFAULT_GOAL := help help: - @grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/' + @grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/' .PHONY: help diff --git a/deptrac.yaml b/deptrac.yaml index 7573742..e3d90c6 100644 --- a/deptrac.yaml +++ b/deptrac.yaml @@ -3,12 +3,12 @@ parameters: - './src' layers: - name: 'CBOR' - collectors: + collectors: - type: 'className' - regex: '^CBO\\' + regex: '^CBO\\' - name: 'Vendors' - collectors: + collectors: - { type: className, regex: '^Brick\\' } ruleset: CBOR: - - Vendors + - Vendors diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index fc4066c..8de4af4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,36 +1,36 @@ parameters: - ignoreErrors: - - - message: "#^Instanceof between CBOR\\\\MapItem and CBOR\\\\MapItem will always evaluate to true\\.$#" - count: 1 - path: src/MapObject.php + ignoreErrors: + - + message: "#^Instanceof between CBOR\\\\MapItem and CBOR\\\\MapItem will always evaluate to true\\.$#" + count: 1 + path: src/MapObject.php - - - message: "#^Parameter \\#1 \\$value of static method CBOR\\\\Utils\\:\\:binToBigInteger\\(\\) expects string, string\\|null given\\.$#" - count: 3 - path: src/OtherObject/DoublePrecisionFloatObject.php + - + message: "#^Parameter \\#1 \\$value of static method CBOR\\\\Utils\\:\\:binToBigInteger\\(\\) expects string, string\\|null given\\.$#" + count: 3 + path: src/OtherObject/DoublePrecisionFloatObject.php - - - message: "#^Parameter \\#1 \\$value of static method CBOR\\\\Utils\\:\\:binToBigInteger\\(\\) expects string, string\\|null given\\.$#" - count: 3 - path: src/OtherObject/HalfPrecisionFloatObject.php + - + message: "#^Parameter \\#1 \\$value of static method CBOR\\\\Utils\\:\\:binToBigInteger\\(\\) expects string, string\\|null given\\.$#" + count: 3 + path: src/OtherObject/HalfPrecisionFloatObject.php - - - message: "#^PHPDoc tag @var with type CBOR\\\\OtherObject is not subtype of native type string\\.$#" - count: 1 - path: src/OtherObject/OtherObjectManager.php + - + message: "#^PHPDoc tag @var with type CBOR\\\\OtherObject is not subtype of native type string\\.$#" + count: 1 + path: src/OtherObject/OtherObjectManager.php - - - message: "#^Parameter \\#1 \\$value of static method CBOR\\\\Utils\\:\\:binToBigInteger\\(\\) expects string, string\\|null given\\.$#" - count: 3 - path: src/OtherObject/SinglePrecisionFloatObject.php + - + message: "#^Parameter \\#1 \\$value of static method CBOR\\\\Utils\\:\\:binToBigInteger\\(\\) expects string, string\\|null given\\.$#" + count: 3 + path: src/OtherObject/SinglePrecisionFloatObject.php - - - message: "#^PHPDoc tag @var with type CBOR\\\\Tag is not subtype of native type string\\.$#" - count: 1 - path: src/Tag/TagManager.php + - + message: "#^PHPDoc tag @var with type CBOR\\\\Tag is not subtype of native type string\\.$#" + count: 1 + path: src/Tag/TagManager.php - - - message: "#^Parameter \\#1 \\$value of static method CBOR\\\\Utils\\:\\:binToInt\\(\\) expects string, string\\|null given\\.$#" - count: 1 - path: src/Tag/TagManager.php + - + message: "#^Parameter \\#1 \\$value of static method CBOR\\\\Utils\\:\\:binToInt\\(\\) expects string, string\\|null given\\.$#" + count: 1 + path: src/Tag/TagManager.php diff --git a/phpstan.neon b/phpstan.neon index 5159d54..e400f30 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,8 +1,8 @@ parameters: - level: max - paths: - - src - treatPhpDocTypesAsCertain: false + level: max + paths: + - src + treatPhpDocTypesAsCertain: false includes: - - vendor/phpstan/phpstan/conf/bleedingEdge.neon - - phpstan-baseline.neon + - vendor/phpstan/phpstan/conf/bleedingEdge.neon + - phpstan-baseline.neon diff --git a/src/IndefiniteLengthByteStringObject.php b/src/IndefiniteLengthByteStringObject.php index ebe97c1..06cd1e0 100644 --- a/src/IndefiniteLengthByteStringObject.php +++ b/src/IndefiniteLengthByteStringObject.php @@ -14,8 +14,8 @@ final class IndefiniteLengthByteStringObject extends AbstractCBORObject implemen private const ADDITIONAL_INFORMATION = self::LENGTH_INDEFINITE; /** - * @var ByteStringObject[] - */ + * @var ByteStringObject[] + */ private array $chunks = []; public function __construct() diff --git a/src/IndefiniteLengthListObject.php b/src/IndefiniteLengthListObject.php index e1bef93..0a55341 100644 --- a/src/IndefiniteLengthListObject.php +++ b/src/IndefiniteLengthListObject.php @@ -23,8 +23,8 @@ class IndefiniteLengthListObject extends AbstractCBORObject implements IteratorA private const ADDITIONAL_INFORMATION = self::LENGTH_INDEFINITE; /** - * @var CBORObject[] - */ + * @var CBORObject[] + */ private array $data = []; public function __construct() @@ -48,8 +48,8 @@ public static function create(): self } /** - * @return mixed[] - */ + * @return mixed[] + */ public function normalize(): array { return array_map( @@ -102,8 +102,8 @@ public function set(int $index, CBORObject $object): self } /** - * @return Iterator - */ + * @return Iterator + */ public function getIterator(): Iterator { return new ArrayIterator($this->data); diff --git a/src/IndefiniteLengthMapObject.php b/src/IndefiniteLengthMapObject.php index ece69f2..3a5ae22 100644 --- a/src/IndefiniteLengthMapObject.php +++ b/src/IndefiniteLengthMapObject.php @@ -23,8 +23,8 @@ class IndefiniteLengthMapObject extends AbstractCBORObject implements IteratorAg private const ADDITIONAL_INFORMATION = self::LENGTH_INDEFINITE; /** - * @var MapItem[] - */ + * @var MapItem[] + */ private array $data = []; public function __construct() @@ -96,16 +96,16 @@ public function set(MapItem $object): self } /** - * @return Iterator - */ + * @return Iterator + */ public function getIterator(): Iterator { return new ArrayIterator($this->data); } /** - * @return mixed[] - */ + * @return mixed[] + */ public function normalize(): array { return array_reduce($this->data, static function (array $carry, MapItem $item): array { diff --git a/src/IndefiniteLengthTextStringObject.php b/src/IndefiniteLengthTextStringObject.php index bc3a15d..20bc6ef 100644 --- a/src/IndefiniteLengthTextStringObject.php +++ b/src/IndefiniteLengthTextStringObject.php @@ -14,8 +14,8 @@ final class IndefiniteLengthTextStringObject extends AbstractCBORObject implemen private const ADDITIONAL_INFORMATION = self::LENGTH_INDEFINITE; /** - * @var TextStringObject[] - */ + * @var TextStringObject[] + */ private array $data = []; public function __construct() diff --git a/src/LengthCalculator.php b/src/LengthCalculator.php index ec8c678..d439b2b 100644 --- a/src/LengthCalculator.php +++ b/src/LengthCalculator.php @@ -13,8 +13,8 @@ final class LengthCalculator { /** - * @return array{int, null|string} - */ + * @return array{int, null|string} + */ public static function getLengthOfString(string $data): array { $length = mb_strlen($data, '8bit'); @@ -23,10 +23,10 @@ public static function getLengthOfString(string $data): array } /** - * @param array $data - * - * @return array{int, null|string} - */ + * @param array $data + * + * @return array{int, null|string} + */ public static function getLengthOfArray(array $data): array { $length = count($data); @@ -35,8 +35,8 @@ public static function getLengthOfArray(array $data): array } /** - * @return array{int, null|string} - */ + * @return array{int, null|string} + */ private static function computeLength(int $length): array { return match (true) { diff --git a/src/ListObject.php b/src/ListObject.php index 4f8da72..6a041cf 100644 --- a/src/ListObject.php +++ b/src/ListObject.php @@ -23,15 +23,15 @@ class ListObject extends AbstractCBORObject implements Countable, IteratorAggreg private const MAJOR_TYPE = self::MAJOR_TYPE_LIST; /** - * @var CBORObject[] - */ + * @var CBORObject[] + */ private array $data; private ?string $length = null; /** - * @param CBORObject[] $data - */ + * @param CBORObject[] $data + */ public function __construct(array $data = []) { [$additionalInformation, $length] = LengthCalculator::getLengthOfArray($data); @@ -57,8 +57,8 @@ public function __toString(): string } /** - * @param CBORObject[] $data - */ + * @param CBORObject[] $data + */ public static function create(array $data = []): self { return new self($data); @@ -111,8 +111,8 @@ public function set(int $index, CBORObject $object): self } /** - * @return array - */ + * @return array + */ public function normalize(): array { return array_map( @@ -127,8 +127,8 @@ public function count(): int } /** - * @return Iterator - */ + * @return Iterator + */ public function getIterator(): Iterator { return new ArrayIterator($this->data); diff --git a/src/MapObject.php b/src/MapObject.php index 72a7431..7e60e4e 100644 --- a/src/MapObject.php +++ b/src/MapObject.php @@ -22,15 +22,15 @@ final class MapObject extends AbstractCBORObject implements Countable, IteratorA private const MAJOR_TYPE = self::MAJOR_TYPE_MAP; /** - * @var MapItem[] - */ + * @var MapItem[] + */ private array $data; private ?string $length = null; /** - * @param MapItem[] $data - */ + * @param MapItem[] $data + */ public function __construct(array $data = []) { [$additionalInformation, $length] = LengthCalculator::getLengthOfArray($data); @@ -64,8 +64,8 @@ public function __toString(): string } /** - * @param MapItem[] $data - */ + * @param MapItem[] $data + */ public static function create(array $data = []): self { return new self($data); @@ -127,16 +127,16 @@ public function count(): int } /** - * @return Iterator - */ + * @return Iterator + */ public function getIterator(): Iterator { return new ArrayIterator($this->data); } /** - * @return array - */ + * @return array + */ public function normalize(): array { return array_reduce($this->data, static function (array $carry, MapItem $item): array { diff --git a/src/Normalizable.php b/src/Normalizable.php index 7ff12bf..9db0d44 100644 --- a/src/Normalizable.php +++ b/src/Normalizable.php @@ -7,7 +7,7 @@ interface Normalizable { /** - * @return mixed|null - */ + * @return mixed|null + */ public function normalize(); } diff --git a/src/OtherObject/OtherObjectInterface.php b/src/OtherObject/OtherObjectInterface.php index 08b69e9..a116f32 100644 --- a/src/OtherObject/OtherObjectInterface.php +++ b/src/OtherObject/OtherObjectInterface.php @@ -9,8 +9,8 @@ interface OtherObjectInterface extends CBORObject { /** - * @return int[] - */ + * @return int[] + */ public static function supportedAdditionalInformation(): array; public static function createFromLoadedData(int $additionalInformation, ?string $data): self; diff --git a/src/OtherObject/OtherObjectManager.php b/src/OtherObject/OtherObjectManager.php index e691c3d..0375ee9 100644 --- a/src/OtherObject/OtherObjectManager.php +++ b/src/OtherObject/OtherObjectManager.php @@ -11,8 +11,8 @@ class OtherObjectManager implements OtherObjectManagerInterface { /** - * @var string[] - */ + * @var string[] + */ private array $classes = []; public static function create(): self diff --git a/src/StringStream.php b/src/StringStream.php index d522813..9aa3c5d 100644 --- a/src/StringStream.php +++ b/src/StringStream.php @@ -10,8 +10,8 @@ final class StringStream implements Stream { /** - * @var resource - */ + * @var resource + */ private $resource; public function __construct(string $data) diff --git a/src/Tag.php b/src/Tag.php index 556c85d..f340ea6 100644 --- a/src/Tag.php +++ b/src/Tag.php @@ -40,8 +40,8 @@ public function getValue(): CBORObject } /** - * @return array{int, null|string} - */ + * @return array{int, null|string} + */ protected static function determineComponents(int $tag): array { switch (true) { diff --git a/src/Tag/CBORTag.php b/src/Tag/CBORTag.php index 631ec7a..37d467e 100644 --- a/src/Tag/CBORTag.php +++ b/src/Tag/CBORTag.php @@ -28,8 +28,8 @@ public static function create(CBORObject $object): Tag } /** - * @return mixed|CBORObject|null - */ + * @return mixed|CBORObject|null + */ public function normalize() { return $this->object instanceof Normalizable ? $this->object->normalize() : $this->object; diff --git a/src/Tag/TagManager.php b/src/Tag/TagManager.php index 0d3eb6d..74b718c 100644 --- a/src/Tag/TagManager.php +++ b/src/Tag/TagManager.php @@ -13,8 +13,8 @@ final class TagManager implements TagManagerInterface { /** - * @var string[] - */ + * @var string[] + */ private array $classes = []; public static function create(): self diff --git a/src/Utils.php b/src/Utils.php index b75343f..f2e0550 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -49,8 +49,8 @@ public static function decode(string $data): string } /** - * @param mixed|null $data - */ + * @param mixed|null $data + */ public static function assertString($data, ?string $message = null): void { if (! is_string($data)) { diff --git a/tests/InvalidTypeTest.php b/tests/InvalidTypeTest.php index 8042002..fc8e3c1 100644 --- a/tests/InvalidTypeTest.php +++ b/tests/InvalidTypeTest.php @@ -31,8 +31,8 @@ public function invalidData(string $item, string $class, string $expectedError): } /** - * @see https://datatracker.ietf.org/doc/html/rfc8949#appendix-F.1 - */ + * @see https://datatracker.ietf.org/doc/html/rfc8949#appendix-F.1 + */ public static function getInvalidDataItems(): Iterator { yield [ diff --git a/tests/OtherObject/AllTest.php b/tests/OtherObject/AllTest.php index 4f1f8de..b445703 100644 --- a/tests/OtherObject/AllTest.php +++ b/tests/OtherObject/AllTest.php @@ -271,8 +271,8 @@ public static function getSimpleObjectWithContent(): Iterator } /** - * @see https://en.wikipedia.org/wiki/Half-precision_floating-point_format - */ + * @see https://en.wikipedia.org/wiki/Half-precision_floating-point_format + */ public static function getHalfPrecisionFloatObject(): Iterator { yield [self::bitsToByteString('0000000000000001', 2), 0.000000059604645, 0.000000000000001]; @@ -291,8 +291,8 @@ public static function getHalfPrecisionFloatObject(): Iterator } /** - * @see https://en.wikipedia.org/wiki/Single-precision_floating-point_format - */ + * @see https://en.wikipedia.org/wiki/Single-precision_floating-point_format + */ public static function getSinglePrecisionFloatObject(): Iterator { yield [self::bitsToByteString('00000000000000000000000000000001', 4), 2 ** -149, 10 ** -149]; @@ -320,8 +320,8 @@ public static function getSinglePrecisionFloatObject(): Iterator } /** - * @see https://en.wikipedia.org/wiki/Double-precision_floating-point_format - */ + * @see https://en.wikipedia.org/wiki/Double-precision_floating-point_format + */ public static function getDoublePrecisionFloatObject(): Iterator { yield [self::bitsToByteString('0011111111110000000000000000000000000000000000000000000000000000', 8), 1, 1];