Higher Order PHP

The Higher Order PHP project has the goal of trying to elevate PHP programming to a higher standard. It provides tools and techniques for analyzing PHP projects and for managing complexity. The project's tools can be downloaded here: https://gitorious.org/higher-order-php

Defining a Contracts language for PHP

I'm trying to design a Design By Contract library for PHP5 and I have been looking at implementations in other languages. What I have noticed is that each implementation defines a contracts language. This should have been obvious to me, and I guess that it was though I overlooked this and was more interested in the meta-programming in PHP problem. So with this contracts language, we need to be able to specify the pre- and post-conditions for functions and methods, and we need to be able to specify constraints such as $x is one of (1,2,3) or $y is a string or null.

Covered in this post are:

  • Contracts and meta-programming
  • Racket contracts
  • Perl contracts
  • Java contracts - C4J
  • Java contracts - cofoja

PHP-Contracts: a design by contract library for PHP 5

Noticing that PHP 5 is adding more higher-level functionality such as closures and knowing that it's a relatively unsafe language to work, I began to think of ways to improve the safety and security of PHP code. One way to do this is to use Design By Contract and I've created a new project as part of Higher Order PHP for that: PHP-Contracts. The library is licensed under the GNU Lesser General Public License so that you can use it as part of proprietary PHP 5 projects. 

New small PHP project: CallGraphAll

I was trying to puzzle out the structure of a few PHP projects and I couldn't make much sense of them considering they had a whole bunch of classes, functions, methods, etc. So I thought to myself, "hey, a function/method call graph would help!" I didn't want to profile the code and see what kind of performance it has, all I wanted to know was what kind of functions/classes it uses. This is useful because it allows for a quick glance to evaluate how well the code is written. If a single function uses 20-30 different functions inside itself, it might need refactoring. Or when you get a stack trace from PHP, it might be helpful to see what's calling the function that failed and then to compare it to other calls made to it.

You can check out the project here or on Gitorious. I'm going to try and submit it to PEAR as well.

Subscribe to RSS - higher-order-php
© 2010 Your Name.. Drupal theme by Kiwi Themes.