Welcome Guest, Not a member yet? Register   Sign In
working on php 8.2 compat for CI3, phpstan errors different on macos
#1

Because CI4 is such a huge leap from CI3, I am trying to expedite the work to make CI3 compatible with PHP 8.2. This is mostly about fixing dynamically assigned class properties, which were deprecated in 8.2. I'm using phpstan for static analysis and it seems quite helpful. Unfortunately, I'm getting a LOT more errors on MacOS than on Ubuntu, even when both are running PHP 8.2.3. I've provided more detail on a SO post a stack overflow post, but the basic idea is that I can perform these exact same steps on Ubuntu and MacOS and get different error reports because PHPstan fails to see the CI_DB class declaration on MacOS for some reason.

If anyone could tell me why and help me sort this out, I'd appreciate it. These are the steps:

Code:
mkdir ci3-dev
cd ci3-dev
curl -o ci.zip https://codeload.github.com/bcit-ci/CodeIgniter/zip/refs/heads/develop
unzip ci.zip
mv CodeIgniter-develop codeigniter
rm ci.zip
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
./composer.phar require --dev phpstan/phpstan
echo -e "parameters:" >> ci.neon
echo -e "\tlevel: 2" >> ci.neon
echo -e "\tpaths:" >> ci.neon
echo -e "\t\t- codeigniter" >> ci.neon
echo -e "\texcludePaths:" >> ci.neon
echo -e "\t\tanalyse:" >> ci.neon
echo -e "\t\t\t- codeigniter/tests" >> ci.neon
echo -e "\t\t\t- codeigniter/user_guide_src" >> ci.neon
vendor/bin/phpstan clear-result-cache -c ci.neon
vendor/bin/phpstan analyse -c ci.neon > phpstan.txt
Reply
#2

I have not been able to isolate why the number of errors is different on MacOS versus Ubuntu, but I made a small change to system/database/DB.php and this reduced the number of errors reported by phpstan from about 1830 to about 1000 -- it literally eliminated 800 errors, and it should be more efficient as well. It has always been weird that CI3 defined the CI_DB class inside a conditional that was inside a function.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB