WebStorm not highlighting matching braces when using a ternary inside an array in PHP

I’m running into a strange issue with Webstorm, the Jetbrains JavaScript IDE, where it fails to highlight matching braces when I add a line of valid PHP that does not change the structure of the block. Here is the PHP block in question:

function buildTree2($pdo, $name, $percent = 100, $path = []) {
    $key = strtolower(trim($name));
    if (in_array($key, $path)) return []; // prevent cycles
    $path[] = $key;

    $nodes = [];

    // Check raw_materials_for_real children first
    $stmt = $pdo->prepare("SELECT Raw_Material_Component AS name, Component_Percentage AS pct FROM raw_materials_for_real WHERE Raw_Material = ?");
    $stmt->execute([$name]);
    $subs = $stmt->fetchAll(PDO::FETCH_ASSOC);

if ($subs) {
    if ($p != 0) { // Check if the component is listed as a raw material
        $stmt3 = $pdo->prepare("SELECT 1 FROM raw_materials_for_real WHERE Raw_Material = ? LIMIT 1");
        $stmt3->execute([$c['name']]);
        $isRawMaterial = $stmt3->fetchColumn() !== false;

        $nodes[] = [
            'name' => $c['name'],
            'is_product_or_raw_material' => $isRawMaterial ? "(RM)" : "(RM Subcomponent)",
            'pct' => $p,
            'children' => buildTree($pdo, $c['name'], $p, $path)
        ];
    }
}


     else {
        // No raw_materials_for_real children? Check product_recipes
        $stmt2 = $pdo->prepare("SELECT Component_Name AS name, PERCENT FROM product_recipes WHERE Product_Name = ?");
        $stmt2->execute([$name]);
        $subs2 = $stmt2->fetchAll(PDO::FETCH_ASSOC);
        $found = false;
        if ($subs2) {
            foreach ($subs2 as $c) {
                $p = $percent * $c['PERCENT'] / 100;
                if ($p != 0){
// Check if the component is listed as a raw material
$stmt3 = $pdo->prepare("SELECT 1 FROM raw_materials_for_real WHERE Raw_Material = ? LIMIT 1");
$stmt3->execute([$c['name']]);
$isRawMaterial = $stmt3->fetchColumn() !== false;

$nodes[] = [
    'name' => $c['name'],
    'is_product_or_raw_material' => $isRawMaterial ? "(RM)" : "(Product)",
    'pct' => $p,
    'children' => buildTree($pdo, $c['name'], $p, $path)
];

            }}
        }
    }

    return $nodes;
}

Suffice to say that this block of code works perfectly as intended. https://www.bairesdev.com/tools/phpcodechecker/ identifies no errors in the code. However, Webstorm’s feature that highlights a matching brace when the cursor is placed immediately beside a brace, doesn’t work for this section (particularly the if ($subs) block). The bizarre part, though, is that if I remove 'is_product_or_raw_material' => $isRawMaterial ? "(RM)" : "(RM Subcomponent)",, it works fine and highlights matching braces. I restarted Webstorm and the issue persists. See below images:

Without the line mentioned above:
Without above line
It correctly highlights the matching close brace to the opening brace after if ($p != 0).

With the line mentioned above:
With the above line
It does not highlight the matching close brace.

My question: Is this a Webstorm bug or is there some aspect of my code that is incorrect? This might not seem like a huge deal but, until I identified this specific issue, my debugging of this file was being greatly hindered.

(I’m using Webstorm 2025.1.2, PHP version 8.2.12, Windows 11.)