PHP - fix json_decode syntax error and set dev tools version (#3824)
diff --git a/composer.json b/composer.json
index ec5d2a3..a90db7b 100644
--- a/composer.json
+++ b/composer.json
@@ -35,9 +35,9 @@
     "ext-xml": "*",
     "ext-curl": "*",
     "ext-pcntl": "*",
-    "rector/rector": "^2.2",
-    "friendsofphp/php-cs-fixer": "^3.89",
-    "phpstan/phpstan": "^2.1"
+    "rector/rector": "2.4.6",
+    "friendsofphp/php-cs-fixer": "3.95.8",
+    "phpstan/phpstan": "2.2.2"
   },
   "autoload": {
     "psr-4": {
diff --git a/lang/php/lib/Schema/AvroSchema.php b/lang/php/lib/Schema/AvroSchema.php
index 9471acd..aec3891 100644
--- a/lang/php/lib/Schema/AvroSchema.php
+++ b/lang/php/lib/Schema/AvroSchema.php
@@ -332,12 +332,17 @@
      */
     public static function parse(string $json): self
     {
-        $schemata = new AvroNamedSchemata();
-
-        return self::realParse(
-            avro: json_decode($json, true, JSON_THROW_ON_ERROR),
-            schemata: $schemata
-        );
+        try {
+            return self::realParse(
+                avro: json_decode($json, associative: true, flags: JSON_THROW_ON_ERROR),
+                schemata: new AvroNamedSchemata()
+            );
+        } catch (\JsonException $e) {
+            throw new AvroSchemaParseException(
+                message: 'Invalid JSON string for schema.',
+                previous: $e
+            );
+        }
     }
 
     /**
@@ -351,7 +356,7 @@
         array|string|null $avro,
         ?string $defaultNamespace = null,
         AvroNamedSchemata $schemata = new AvroNamedSchemata()
-    ): AvroSchema {
+    ): self {
         if (is_array($avro)) {
             $type = $avro[self::TYPE_ATTR] ?? null;