PHPCompatibility icon indicating copy to clipboard operation
PHPCompatibility copied to clipboard

got an error when i use "new \SQLite3(xxx)"

Open snje1987 opened this issue 8 years ago • 8 comments

when i use sqlite3 in the format of "\SQLite3",php-compatibility display an error said "Extension 'sqlite' is removed since PHP 5.4".

snje1987 avatar Aug 19 '17 12:08 snje1987

Can you provide a code sample ?

wimg avatar Aug 19 '17 21:08 wimg

Regarding solution direction - maybe the sniff should check the value for being exactly the same as the deprecated extension òr the same + _ ? I'd need to check whether all deprecated extensions use an underscore as a separator to be sure whether this would be a viable solution.

jrfnl avatar Aug 19 '17 22:08 jrfnl

<?php

namespace Mynamespace;

class MyClass {

    public function __construct() {
        $db = new \SQLite3('test.db');
    }

}

and then i get an error said 8 | ERROR | Extension 'sqlite' is removed since PHP 5.4. if i change the $db = new \SQLite3('test.db'); to $db = new SQLite3('test.db');, the error will gone.

snje1987 avatar Aug 20 '17 02:08 snje1987

I'm looking into this, but it may still be a little while before I have time to finish the work needed for this.

jrfnl avatar Aug 28 '17 13:08 jrfnl

Related #209, #582

jrfnl avatar Aug 01 '18 16:08 jrfnl

Here's more code that triggers this bogus notice:


new Db\Sqlite();
new Db\Sqlite3();

so apparently it doesn't even check user classes from different namespaces.

glensc avatar May 17 '19 21:05 glensc

This sniff is far too overzealous, simply doing string matches for function names or class names that contain the name of the extension. It's annoying to have to disable it manually.

Still, to do so in a custom phpcs.xml or similar:

<!-- Ruleset includes -->
<rule ref="PHPCompatibility">
    <!-- This sniff is very overzealous and inaccurate, so we'll disable it -->
    <exclude name="PHPCompatibility.Extensions.RemovedExtensions"/>
</rule>

Looking forward to all the work in #1022 getting a release.

hexus avatar Aug 20 '20 16:08 hexus

Well, we're still working on PHPCompatibility 10.0.0, but all the prep work for #1022 has already been done. Fingers crossed we'll have a (huge) release in about a month or so.

jrfnl avatar Aug 20 '20 17:08 jrfnl