Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
Identifying type juggling issues before PHP upgrade to PHP8

Currently, I am sitting on PHP5.6 and would be updating to PHP8 soon. I used PHPCS to check the compatibility issues and was able to fix them before upgrading to PHP8.

However, I found some issues related to type juggling in the code during testing such as:

$x = "";
$x['test'] = "xyz";
print_r($x); //Warning: Only the first byte will be assigned to the string offset in /tmp/8dw2cmkrbq0pcq/tester.php on line 4 Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /tmp/8dw2cmkrbq0pcq/tester.php:4 Stack trace: #0 {main} thrown in /tmp/8dw2cmkrbq0pcq/tester.php on line 4

This piece of code worked well in PHP5.6.

Unfortunately, the issue was not detected by PHPCS and now I am wondering if there are more issues like this in the product.

Now, I want to know if there is a way to detect such issues before I upgrade to PHP8? It would be really helpful if I could get a hint on how to find such issues before I upgrade to PHP8.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I was able to detect this type of issues using https://github.com/phan/phan. Here is the sample issue that was caught.

{
"type": "issue",
"type_id": 10030,
"check_name": "PhanTypeMismatchDimAssignment",
"description": "TypeError PhanTypeMismatchDimAssignment When appending to a value of type '', found an array access index of type 'hobbies', but expected the index to be of type int",
"severity": 5,
"location": {
    "path": "PQR/models/XYZModel.php",
    "lines": {
        "begin": 171,
        "end": 171
    }
}}

Thank you for your support guys.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda