Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

242
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda