Skip to content

Comments

Improve type safety and null handling#4

Merged
soymgomez merged 1 commit intomainfrom
fix/type-safety-and-null-handling
Feb 20, 2026
Merged

Improve type safety and null handling#4
soymgomez merged 1 commit intomainfrom
fix/type-safety-and-null-handling

Conversation

@soymgomez
Copy link
Member

@soymgomez soymgomez commented Feb 20, 2026

Summary

TestSEO: null checks en assertions de título

  • assertTitleContains() y assertTitleEndsWith() ahora comprueban que el título no sea null antes de las aserciones de string
  • Mensaje claro "Title tag is missing" en vez de un TypeError críptico

HTMLParser: tipo nativo en grabMultiple()

  • Parámetro $attribute tipado como string|array|null (antes sin tipo)

SimpleSerializer: check explícito en formatTagCollection()

  • Reemplazado ?: null (falsy implícito) por === [] explícito para distinguir correctamente entre colecciones vacías y colecciones con valores

ArrayPluck: validación de estructura

  • Items con claves faltantes se ignoran en vez de lanzar "undefined array key"

Test plan

  • CI passes on PHP 8.2, 8.3 and 8.4
  • PHPUnit 10 and 11 both green (32 tests, 118 assertions)
  • PHPStan passes with empty baseline
  • Pint code style passes

- Assert title is not null before string assertions in TestSEO
- Add native union type to HTMLParser::grabMultiple() parameter
- Replace implicit empty array falsy check with explicit comparison
  in SimpleSerializer::formatTagCollection()
- Skip items with missing keys in ArrayPluck instead of crashing

Changelog: fixed
@soymgomez soymgomez merged commit 9b9bb9a into main Feb 20, 2026
14 checks passed
@soymgomez soymgomez deleted the fix/type-safety-and-null-handling branch February 20, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant