PHP Classes
elePHPant
Icontem

PHP Deprecated Function Checker: Find deprecated functions and suggest replacements

Recommend this page to a friend!
  Info   View files Example   View files View files (14)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2015-10-20 (4 years ago) RSS 2.0 feedStarStarStarStar 72%Total: 665 All time: 4,756 This week: 290Up
Version License PHP version Categories
depcheck 1.0.3GNU General Publi...5PHP 5, Utilities and 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
  Performance   Level  
Name: Dave Smith <contact>
Classes: 47 packages by
Country: United States United States
Innovation award
Innovation award
Nominee: 29x

Winner: 6x

 

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  
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  /  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  /  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

 Version Control Unique User Downloads Download Rankings  
 0%
Total:665
This week:0
All time:4,756
This week:290Up
User Ratings User Comments (1)
 All time
Utility:95%StarStarStarStarStar
Consistency:90%StarStarStarStarStar
Documentation:80%StarStarStarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:72%StarStarStarStar
Rank:298
 
Have been using it on several websites.
4 years ago (Gerry Danen)
75%StarStarStarStar