Benefits of using Codenizer

Why to use Codenizer? - Eliminate bugs faster, increase productivity

Codenizer can save you a lot of time on debugging, allowing you to focus on more complicated aspects of the problems you are working on. Codenizer's ability to assist you in code checking allows you to do more ACTUAL work on your program than before, in the same amount of time. To illustrate Codenizer's operation let's consider this small code fragment (given with line numbers to be easier to follow):

1: <?php
2:     $num = $GET['num'];
3:     $sum = 0;
4:
5:     for ($i = 0; i < $num; $i++)
6:         $sum += $i;
7:    
8:     echo $sum;
9: ?>

As you probably noticed this script is supposed to calculate sum of first $num numbers. Running Codenizer on this small script would produce output:

test.php(2): Uninitialized variable 'GET'
test.php(5): Undefined constant 'i'
test.php(5): Suspicous loop (maybe infinite?)

Complete list of errors Codenizer can detect »

We can see there is typo on line 2 (missing _ to be $_GET), then another typo in line 5 (missing $ to be $i) produced next 2 errors - unknown constant "i" and suspicious loop. Of course this is just one oversimplified example but it should help you get picture what Codenizer can do and how it can help you.

NOTICE: If you want to try for yourself whether Codenizer can help you with your work feel free to download free demo version with limited functionality (it won't warn you about uninitialized variables and about unused variables (those to whom you assigned some value but you never used them)), but it still can do lot of useful checks for you. If you decide to give Codenizer decent shot you can purchase it from our retailer.

This is however just simple example of checks that Codenizer performs. Full set of errors that Codenizer can detect can be found here. You should note that there is one important difference between errors PHP can detect and Codenizer can detect -- PHP interpreter detects (and eventually warns about) only semantic errors it encounters during program execution. What this means? Let's again consider small code example (again with line numbers):

1: $side_of_square = 4;
2: if ($figure == 'square')
3:     $area_of_square = $side_of_square * $side_of_square;

In this case PHP will display warning message only if $figure is 'square'. If it is for, example 'circle', you won't be warned about use of uninitialized value in line 3. Codenizer on the other side doesn't execute your code to check for uninitialized values (or any other error). As you may already guess this has its own strengths and weaknesses. Major strength this approach can offer is ability to analyze all possible execution paths with single pass through code, but again this comes with a price of not being able to know almost anything about variable contents, effectively disabling Codenizer to do almost any kind of pointer validation (things like having function name inside some variable and calling it indirectly). So Codenizer won't help you with code like this:

$function = "non_existing_function";
$function($a, $b);

The other drawback (and in fact this is the biggest drawback) is Codenizer's inability to handle all kinds of include expressions that PHP can handle -- this means that you should probably use simple expressions in your requires through your script -- rather

require('include-me.php');

than

require(my_fancy_function(calculate_what_to_include_from_position(__FILE__, __LINE__)));

Codenizer is able to execute actually rather modest set of PHP functions consisting of only two functions -- "dirname" (to allow you to include files giving absolute path), and "define" (to allow you to store something in constant and to use that later through your includes), however, most of PHP operators are supported in include expressions. Strictly speaking, calculating include paths is the only place where Codenizer will attempt to execute fragments of your code.

One important thing to note is that Codenizer doesn't use the same parser as PHP interpreter but rather its own parser written from scratch especially for this purpose. What that means, and why is that important? Well, Codenizer will usually recover from almost any syntax error in your code and it will be able to report it to you and to happily continue parsing and analyzing code, although PHP interpreter would fail on first syntax error it encounters. There is one special case in which Codenizer does not report syntax error where it exists -- that is separating $ from variable name (for example '$ var'). Codenizer will silently accept this error and continue parsing without warning about it. On the other hand PHP parser will abort if you have something like this in your code no matter whether it would be within current execution flow or not.

Codenizer will also complain about lots of things that are considered completely legal in PHP language (for example, calling non-static function in class as it was static, passing wrong number of arguments to function, accessing undeclared properties of objects and so on). If you rely on some of these 'features' then you should probably just ignore some of the messages Codenizer gives you :-)