Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!