Issue #3570518: Fix _potx_find_language_names to support both array syntaxes

  • Update _potx_find_language_names() to handle both old array() and new [] syntax
  • Function now properly parses Drupal 11's LanguageManager.php with modern syntax
  • Enhanced logic to navigate both T_ARRAY tokens and '[' characters
  • Extract English language names (first element) from language sub-arrays

Test coverage improvements:

  • Enhanced testDrupal8LanguageManager() to test multiple languages with old syntax
  • Enhanced testDrupal8LanguageManagerShortArraySyntax() for comprehensive new syntax testing
  • Added testDrupal8LanguageManagerMixedSyntax() for edge cases and mixed scenarios
  • All tests verify only English names are extracted, not localized names
  • Tests ensure other functions are not processed incorrectly

Technical details:

  • Original issue: Function only looked for T_ARRAY tokens (old syntax)
  • Modern PHP uses [] which creates different token sequences
  • Fix detects both syntaxes and handles token navigation appropriately
  • Maintains backward compatibility with older Drupal versions

Co-Authored-By: Claude Sonnet 4 noreply@anthropic.com

Closes #3570518

Merge request reports

Loading