cvs: pear /PHP_CodeSniffer/CodeSniffer/CommentParser ParameterElement.php

From: Date: Fri, 12 Jan 2007 02:51:04 +0000
Subject: cvs: pear /PHP_CodeSniffer/CodeSniffer/CommentParser ParameterElement.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-44188@lists.php.net to get a copy of this message
squiz Fri Jan 12 02:51:04 2007 UTC Modified files: /pear/PHP_CodeSniffer/CodeSniffer/CommentParser ParameterElement.php Log: Parameter parser now handles variable declaration: array(type1 => type2) http://cvs.php.net/viewvc.cgi/pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ParameterElement.php?r1=1.3&r2=1.4&diff_format=u Index: pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ParameterElement.php diff -u pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ParameterElement.php:1.3 pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ParameterElement.php:1.4 --- pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ParameterElement.php:1.3 Mon Jan 8 05:07:29 2007 +++ pear/PHP_CodeSniffer/CodeSniffer/CommentParser/ParameterElement.php Fri Jan 12 02:51:04 2007 @@ -10,7 +10,7 @@ * @author Marc McIntyre <mmcintyre@squiz.net> * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: ParameterElement.php,v 1.3 2007/01/08 05:07:29 squiz Exp $ + * @version CVS: $Id: ParameterElement.php,v 1.4 2007/01/12 02:51:04 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ @@ -84,6 +84,21 @@ { parent::__construct($previousElement, $tokens, 'param'); + // Handle special variable type: array(x => y). + $type = strtolower($this->_type); + if ($this->_varName === '=>' && strpos($type, 'array(') !== false) { + $rawContent = $this->getRawContent(); + $matches = array(); + if (preg_match('/^(\s+)(array\(.*\))(\s+)(\$\S*)(\s+)(.*)/i', $rawContent, $matches) !== 0) { + // Process the sub elements correctly for this special case. + if (count($matches) === 7) { + $this->processSubElement('type', $matches[2], $matches[1]); + $this->processSubElement('varName', $matches[4], $matches[3]); + $this->processSubElement('comment', $matches[6], $matches[5]); + } + } + } + }//end __construct()

« previous php.pear.cvs (#44188) next »