diff --git a/VERSION b/VERSION index 0bed13c..4979880 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2408.610150 +0.2408.611934 diff --git a/src/Bencode/BencodeSerialisableTrait.php b/src/Bencode/BencodeSerialisableTrait.php index 6d203b2..6c42e90 100644 --- a/src/Bencode/BencodeSerialisableTrait.php +++ b/src/Bencode/BencodeSerialisableTrait.php @@ -1,7 +1,7 @@ getMethods(ReflectionMethod::IS_PUBLIC); foreach($methodInfos as $methodInfo) { - if($methodInfo->getNumberOfRequiredParameters() > 0) - throw new RuntimeException('Methods marked with the BencodeProperty attribute must not have any required arguments.'); - $attrInfos = $methodInfo->getAttributes(BencodeProperty::class); if(count($attrInfos) < 1) continue; if(count($attrInfos) > 1) throw new RuntimeException('Methods may only carry a single instance of the BencodeProperty attribute.'); + if($methodInfo->getNumberOfRequiredParameters() > 0) + throw new RuntimeException('Methods marked with the BencodeProperty attribute must not have any required arguments.'); + $info = $attrInfos[0]->newInstance(); $name = $info->getName() ?? $methodInfo->getName(); diff --git a/src/Json/JsonSerializableTrait.php b/src/Json/JsonSerializableTrait.php index bab1a78..e65a496 100644 --- a/src/Json/JsonSerializableTrait.php +++ b/src/Json/JsonSerializableTrait.php @@ -1,7 +1,7 @@ getMethods(ReflectionMethod::IS_PUBLIC); foreach($methodInfos as $methodInfo) { - if($methodInfo->getNumberOfRequiredParameters() > 0) - throw new RuntimeException('Methods marked with the JsonProperty attribute must not have any required arguments.'); - $attrInfos = $methodInfo->getAttributes(JsonProperty::class); if(count($attrInfos) < 1) continue; if(count($attrInfos) > 1) throw new RuntimeException('Methods may only carry a single instance of the JsonProperty attribute.'); + if($methodInfo->getNumberOfRequiredParameters() > 0) + throw new RuntimeException('Methods marked with the JsonProperty attribute must not have any required arguments.'); + $info = $attrInfos[0]->newInstance(); $name = $info->getName() ?? $methodInfo->getName(); diff --git a/tests/BencodeSerialisableTest.php b/tests/BencodeSerialisableTest.php index cc2df8c..001182a 100644 --- a/tests/BencodeSerialisableTest.php +++ b/tests/BencodeSerialisableTest.php @@ -1,7 +1,7 @@ assertEquals(self::BASIC_BENCODED_ENCODED, Bencode::encode($test)); diff --git a/tests/JsonSerializableTest.php b/tests/JsonSerializableTest.php index 407b997..8988151 100644 --- a/tests/JsonSerializableTest.php +++ b/tests/JsonSerializableTest.php @@ -1,7 +1,7 @@ assertEquals(self::BASIC_JSON_ENCODED, json_encode($test));