PHP Classes

PHP Deprecated Function Checker: Find deprecated functions and suggest replacements

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 73%Total: 706 This week: 1All time: 4,660 This week: 35Up
Version License PHP version Categories
depcheck 1.0.3GNU General Publi...5PHP 5, Tools, Language
Description 

Author

This class can find deprecated functions in your code and suggest replacements.

It can take a given PHP source code file and parse it to determine if it uses functions that are deprecated in newer PHP versions.

The class reports the deprecated functions that it finds and suggests replacement code to make it work in more recent PHP versions.

The list of deprecated functions this class is able to detect is read from a simple text file in CSV format that can be updated with more functions that become deprecated.

Innovation Award
PHP Programming Innovation award nominee
April 2015
Number 2


Prize: One downloadable copy of PhpED Professional
Each new major PHP version deprecates the use of certain functions and extensions. Usually, deprecated functions will be removed in future versions.

If you have legacy code using deprecated functions, you will need to fix your code to make it work in newer PHP versions.

This class can help finding and fixing legacy PHP code to make it work in newer PHP versions.

Manuel Lemos
Picture of Dave Smith
  Performance   Level  
Name: Dave Smith is available for providing paid consulting. Contact Dave Smith .
Classes: 51 packages by
Country: United States United States
Age: 59
All time rank: 608 in United States United States
Week rank: 7 Up1 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x

Example

<?PHP
include('depcheck.class.php');

$fileName = ( !empty($_REQUEST['f']) ) ? $_REQUEST['f'] : '';

$dpc = new depcheck($fileName);
$dpc->checkFile();

?>
<html>
    <head>
        <title>PHP deprecated function checker</title>
    </head>
    <body>
<?PHP
if( $dpc->errorFlag === true ){
?>
<div style="margin: 10px 0; color: red;">Error!!!<br><?PHP echo $dpc->errorMessage;?></div>
<?PHP
}
?>
<div>Running PHP version <?PHP echo PHP_VERSION;?></div>
        <div>Using deprecated csv file '<?PHP echo $dpc->depFile;?>'</div>
        <div>Checking file '<?PHP echo $dpc->fileName;?>'</div>
        <div style="margin-top: 10px;">Results:<br><?PHP echo $dpc->resultMessage;?></div>
    </body>
</html>


Details

Class: depcheck Version: 1.0.1 4/12/2015 Copyright 2015 Wagon Trader, All Rights Reserved Description: This class will parse any specified file for deprecated PHP functions and report findings. Files: depcheck.class.php - Main class depcheck.csv - CSV file containing deprecated function data depcheck.php - Simple application script all.php - example file to check multiple files in specified folder and sub folders depcheck.css - styles used in all.php file (files all.php and depcheck.css provided by Gerry Danen) /extended_sql folder contains all document check with results saved to database files provided by Tony Russo /cli_batch folder contains command line batch processing files provided by Han Velthuis Installation: Upload files to a web accessible location on your server (eg. public_html) Note: By default the class is configured to find the CSV file in the same location as the class file. Configuration: The class if configured to work with most server configurations. You can change the following settings in the class should you need to... $docRoot - You may specify your full path to the document root here, or leave blank to use the server specified path. $depFile - You may specify the CSV file containing deprecated functions here $depFileHeader - Specify true or false if the CSV file contains header info in its first line. Usage: Using included script depcheck.php This script expects the file you want to be checked to be in the URI as a key/value pair of f=[filename]. The filename must also include any folders off of the document root. For example, you would point your browser to... depcheck.php?f=folder/file.php By default, this script will limit the results up to and including your currently installed version of PHP. If you want to check the file against all deprecated functions in the CSV file then change the line... $dpc = new depcheck($fileName); to $dpc = new depcheck($fileName,true); Creating your own script Refer to class for instructions on using methods Working with the deprecated functions CSV file You can add, remove or change any row of data in this file to keep it up to date. The comma separated values are in this order... "[function]","[replacement function]",[major version],[minor version],[release version] Note that the versions are the PHP version when the function became deprecated. Changelog 1.0.2 Added all sql extension files. Provided by Tony Russo Added command line batch processing in folder cli_batch. Provided by Han Velthuis 1.0.1 included files all.php and depcheck.css - multiple file checker provided by Gerry Danen fixed bug where false postive reported when non depricated function ends with same text of depricated function name added logic to skip line if commented with // added class property depFlag which will be set to true if deprecated functions are found in checked file

  Files folder image Files (14)  
File Role Description
Files folder imagecli_batch (3 files)
Files folder imageextended_sql (5 files)
Accessible without login Plain text file all.php Example Check multiple files
Plain text file depcheck.class.php Class Main Class
Accessible without login Plain text file depcheck.css Data Style sheet for all.php
Accessible without login Plain text file depcheck.csv Data Deprecated functions data
Accessible without login Plain text file depcheck.php Example Simple application script
Accessible without login Plain text file manual.txt Doc. Documentation

  Files folder image Files (14)  /  cli_batch  
File Role Description
  Accessible without login Plain text file all_batch.php Appl. Command Line Batch Processing
  Accessible without login Plain text file exec_all_batch.bat Aux. Batch File
  Accessible without login Plain text file readme.txt Doc. Help File

  Files folder image Files (14)  /  extended_sql  
File Role Description
  Accessible without login Plain text file all_sql.php Appl. Process all files and save in database
  Plain text file db.mysqli.class.php Class Database Abstraction Layer
  Plain text file depcheck.class.extended.php Class Class Extension
  Accessible without login Plain text file depcheck.database_table.sql Data mySQL table definition
  Accessible without login Plain text file readme.txt Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:706
This week:1
All time:4,660
This week:35Up
User Ratings User Comments (1)
 All time
Utility:95%StarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:83%StarStarStarStarStar
Examples:79%StarStarStarStar
Tests:-
Videos:-
Overall:73%StarStarStarStar
Rank:128
 
Have been using it on several websites.
9 years ago (Gerry Danen)
75%StarStarStarStar