Skip to content

mysqli functions detected as mysql functions and reported as errors #7

@stevenbalthazor

Description

@stevenbalthazor

A file with the following content:

<?php
$x = mysqli_connect($dbhost, $dbuser, $dbpassword,$dbname);
$y = mysql_connect($dbhost, $dbuser, $dbpassword,$dbname);

Returns the following errors:

FOUND 2 ERROR(S) AFFECTING 2 LINE(S)
-----------------------------------------------------------------------------

 2 | ERROR | Extension 'mysql' is removed since PHP 5.0 - use mysqli instead.
 3 | ERROR | Extension 'mysql' is removed since PHP 5.0 - use mysqli instead.
-----------------------------------------------------------------------------

If I change line 186 of Sniffs/PHP/RemovedExtensionsSniff.php from:

        'mysql' => array(

To:

        'mysql_' => array(

It correctly returns:

FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
-----------------------------------------------------------------------------

 3 | ERROR | Extension 'mysql_' is removed since PHP 5.0 - use mysqli instead.
-----------------------------------------------------------------------------

I am not sure if this is the best way to fix this issue; but it appears to solve my issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions