Showing posts with label PEAR. Show all posts
Showing posts with label PEAR. Show all posts

Sunday, 4 January 2009

Seven Things - Tagged by Sebastian and Manuel

I've been tagged for this meme by Sebastian Bergmann and Manuel Pichler, so I can hardly ignore it now!

Seven things you may not know about me:

  • I didn't even know how to code a table in HTML when I started as a web developer at Squiz.
  • I didn't pick the name PHP_CodeSniffer. It was suggested by Pierre-Alain Joye (http://blog.thepimp.net) when I submitted "Snoopy" to PEAR.
  • I'm slightly addicted to WoW, but I swear it's not my fault and my wife is addicted too, so it's not that bad.
  • I've never been to a PHP conference or user group. I just can't ever seem to find the time, especially now with a 1 year old.
  • I'm the main cook in the house, and I love it!
  • I love cats and dogs and have had 5 dogs and 4 cats as pets so far.
  • I don't have a Facebook account even though several people have tried to sign me up. One less thing to be addicted to.

And the seven lucky people I have picked to do this next are:
  • Till Klampaeckel for being a PHP_CodeSniffer early adopter
  • Pierre-Alain Joye for helping me get into the wonder that is PEAR
  • Laurent Laville for helping me get PHP_CodeSniffer working on Windows
  • Scott Kim because he codes PHP all day long and needs something to add to his blog
  • Richard Hulse for convincing me Git is a great VCS, even if I haven't done anything about it
  • Nathan de Vries because he's a smart guy with and without PHP
  • Nic Hubbard for making his first contribution to a PHP open source project just recently

And here are the rules of the game:
  • Link your original tagger(s), and list these rules on your blog.
  • Share seven facts about yourself in the post - some random, some wierd.
  • Tag seven people at the end of your post by leaving their names and the links to their blogs.
  • Let them know they've been tagged by leaving a comment on their blogs and/or Twitter.

Friday, 21 December 2007

PHP_CodeSniffer 1.0.0 released

It has been almost 16 months since PHP_CodeSniffer was accepted into PEAR and I've just released 1.0.0 stable. It's been a great year for this project and I can't thank the PHP community enough, and the PEAR community in particular, for their extensive testing and patching.

There were more changes since RC3 than I thought there were going to be; a few bugs but a couple of new important features as well, although they are mostly behind the scenes.

The biggest change is the fact that you can now specify a full path to a custom coding standard rather than having to "pear install" your standard to ensure PHP_CodeSniffer can find it. This is great if you have your own standard sitting in a SVN or CVS checkout somewhere and you want to keep it up-to-date without reinstalling it into PEAR each time.

I have to thank both Dirk Thomas and Stefan Priebsch for pushing me to get this feature in before the 1.0.0 release as I had previously scheduled it for inclusion in 1.1.0. Both are involved in the Phing project and these changes should allow a PHP_CodeSniffer Phing task to be available soon.

You can view the full changelog, and download the release, on the package download page.

Tuesday, 23 October 2007

All PEAR packages now checked with PHP_CodeSniffer

Thanks to some great work by Christian Weiske, PHP_CodeSniffer has been added to the PEAR QA framework. So now, all package developers can visit the PEAR QA overview page and see how many coding standard errors and warnings they have in their package.

Here is the full announcement:

Hello all you pear developers,

Our quality assurance suite now utilizes our great package PHP_CodeSniffer to generate reports about each package's coding standards compliance.

You can get the full overview at
http://pear.cweiske.de/overview.htm
Just click at the CS error/warning count to get a detailled listing of problems in the package.

Please also note that we're currently evaluating to extend and clarify the standards. See my last email to this list or http://wiki.pear.php.net/index.php/CodingStandardsChanges

As always, comments are very welcome.

I'm also pretty happy that someone has decided to review the PEAR coding standards, as there are a few gaps that need to be filled in and some conflicting standards that need to be clarified.

Sunday, 5 August 2007

Ignore files and folders with PHP_CodeSniffer

A feature request came through about a month ago to add a new command line argument to PHP_CodeSniffer that allows certain files and folders to be skipped. I added this feature in a couple of weeks ago and I've just finished updating the end user docs to show how it is used.

Sometimes you want PHP_CodeSniffer to run over a very large number of files, but you want some files and folders to be skipped. The --ignore command line argument can be used to tell PHP_CodeSniffer to skip files and folders that match one or more patterns.

In the following example, PHP_CodeSniffer will skip all files inside the package's tests and data directories. This is useful if you are checking a PEAR package but don't want your test or data files to conform to your coding standard.

$ phpcs --ignore=*/tests/*,*/data/* /path/to/code

As it turns out, this feature comes in handy for the new automated PHP_CodeSniffer report being run over PEAR CVS thanks to Brett Bieber.

PHP_CodeSniffer contains a lot of test files that violate the PEAR coding standards for the purpose of checking that violations are detected. Those files were causing thousands of errors to be reported against the PHP_CodeSniffer package, which was not an accurate reflection of its adherence to the coding standards.

Brett has now modified his script to use the new command line argument to ignore all files inside test and data directories, which matches the newly modified PhpDocumentor ignore pattern being used by PEAR.

Wednesday, 25 July 2007

Testing PHP_CodeSniffer without installing

PHP_CodeSniffer has always contained extensive unit tests for all code sniffs, but the testing structure required the package to be installed so that tests could be placed into an expected location. The tests also use PHP_CodeSniffer itself, and it requires the package to be installed so that the require statements that rely on the PEAR include path would work correctly. So basically, neither PHP_CodeSniffer or the unit tests could be run without installing the package first.

PHP_CodeSniffer is not a library, it is a development tool, so this shouldn't matter. However, PEAR has recently pushed to get repository-wide code coverage stats for unit testing. All unit tests must now run correctly when the package is checked-out from CVS and without being installed.

To solve the problem, I turned to the newly proposed PEAR2 standards, which are being hotly debated at the moment on pear-dev.

To be honest, I wasn't sure about those standards when I first read them. I could see the merit for some libraries, but it was hard to see how those changes would make PHP_CodeSniffer better. I still don't think they are going to make PHP_CodeSniffer easier to use, but they have certainly made it easier to develop and test for.

The change that I made was to remove all my require_once() statements and replace them with class_exists() and interface_exists() calls with the optional second argument for autoloading. The PHP_CodeSniffer class now has an autoload method that includes the class files from different locations depending on if the package is installed or not.

The benefit of doing this is that the AllTests.php file that starts the unit testing off only needs to find the CodeSniffer.php file and its own test files. Once CodeSniffer.php is included, all other files are included automatically. Couple this change with a few other minor tweaks to remove some hard-coded assumptions about file paths and lengths, and you've got a unit test suite that runs from CVS. As an added benefit, modifying a single include inside the phpcs script allows you to run PHP_CodeSniffer itself without installing the package.

Index: scripts/phpcs
===============================================
RCS file: /repository/pear/PHP_CodeSniffer/scripts/phpcs,v
retrieving revision 1.16
diff -r1.16 phpcs
20c20
< require_once 'PHP/CodeSniffer.php';
---
> require_once '../CodeSniffer.php';

While these changes were made primarily for the PEAR unit testing system, they have also meant that I can stop installing the package to test every change I make. That is making development easier for me, and that's a good thing.

Friday, 12 January 2007

PHP_CodeSniffer DocBook documentation

I started writing the documentation for PHP_CodeSniffer today. Before I can release a stable version, I have to make sure there is some documentation in the PEAR manual (peardoc).

The catch? The PEAR manual is written in DocBook XML and is pretty hard to get working, at least on OS X. Chapter 21 of the PEAR manual describes how to write documentation and the software you need to install to get it working. The section Required software reads:

Unfortunately, installing that software can be difficult under some circumstances. If you are unable to get it working, don't use that as an excuse for not writing documentation. There are two test servers that automatically download peardoc from CVS and build the manual. Any parsing errors your changes cause will show up in the logs the next time the build happens:

That didn't fill me with confidence.

Checking out peardoc from CVS was easy, but of course, my first attempt at trying to compile the manual failed; peardoc couldn't find my DSSSL stylesheets. I was not prepared to commit any documentation unless I could test it locally.

Luckily for me, I started playing around with peardoc 12 months ago, when work was a little less busy. Apparently, I had been successful in installing OpenJade and the DSSSL stylesheets. The one thing missing was the command to tell peardoc where those stylesheets were.

The Testing documentation section of the PEAR manual says that the following commands will build peardoc on your local machine:
peardoc$ autoconf
peardoc$ ./configure --with-lang=en
peardoc$ make html

I'll describe that as mostly right. If peardoc doesn't know where your stylesheets are, you'll need to tell it, like this:
peardoc$ autoconf
peardoc$ ./configure --with-lang=en --with-dsssl=/path/to/docbook-dsssl/
peardoc$ make html

I got the DSSSL stylesheets from a Fink package called docbook-dsssl-nwalsh, so my stylesheet path is /sw/share/sgml/dsssl/docbook-dsssl-nwalsh/.

After several minutes, the PEAR manual was finally mine.

I started by porting over the docs about PHP_CodeSniffer that I had put up on the MySource Matrix website. This was my first real attempt at writing in DocBook format. I'll post about my impressions when I've finished writing all the docs, but first impressions are pretty good.

So now my first set of docs have been committed to peardoc. Now to wait for the next test manual generation to see if I did things correctly. It's a nervous wait!

UPDATE: the docs generated correctly and are now available in the PEAR manual.

Sunday, 31 December 2006

Looking back at PEAR in 2006

Greg Beaver has posted a nice history of PEAR in 2006, entitled 2006: a PEAR retrospective. From the article:

2006 was an interesting year for PEAR, a number of exciting events happened both inside PEAR's workings and in PHP at large that affected PEAR. I will attempt to give my best shot at a 20-20 hindsight look back at PEAR in the past year.

Of course, 2006 was a big year for me in PEAR. My account was opened by Pierre in July, just a few months before he announced his retirement. The PHP_CodeSniffer proposal was submitted in July and finally approved in late August and I released the first version of PHP_CodeSniffer through PEAR in early September, a very proud moment for everyone involved at Squiz.

The first stable version of PHP_CodeSniffer is planned for release sometime in 2007, so next year should include another proud milestone for my involvement in the PEAR project.