svn: /pear/pear-core/trunk/ PEAR/PackageFile/v2/Validator.php tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_bug18218.phpt

From: Date: Sun, 27 Feb 2011 18:58:02 +0000
Subject: svn: /pear/pear-core/trunk/ PEAR/PackageFile/v2/Validator.php tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_bug18218.phpt
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-9755@lists.php.net to get a copy of this message
dufuz Sun, 27 Feb 2011 18:58:02 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=308728 Log: Fixed Bug #18218: "pear package" does not allow the use of late static binding [dufuz and Christer Edvartsen] Bug: http://pear.php.net/bugs/18218 (unknown) Changed paths: U pear/pear-core/trunk/PEAR/PackageFile/v2/Validator.php A pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_bug18218.phpt Modified: pear/pear-core/trunk/PEAR/PackageFile/v2/Validator.php =================================================================== --- pear/pear-core/trunk/PEAR/PackageFile/v2/Validator.php 2011-02-27 18:06:38 UTC (rev 308727) +++ pear/pear-core/trunk/PEAR/PackageFile/v2/Validator.php 2011-02-27 18:58:02 UTC (rev 308728) @@ -2044,7 +2044,8 @@ } continue 2; case T_DOUBLE_COLON: - if (!($tokens[$i - 1][0] == T_WHITESPACE || $tokens[$i - 1][0] == T_STRING)) { + $token = $tokens[$i - 1][0]; + if (!($token == T_WHITESPACE || $token == T_STRING || $token == T_STATIC)) { if (isset($this->_stack)) { $this->_stack->push(__FUNCTION__, 'warning', array('file' => $file), 'Parser error: invalid PHP found in file "%file%"'); Added: pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_bug18218.phpt =================================================================== --- pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_bug18218.phpt (rev 0) +++ pear/pear-core/trunk/tests/PEAR_PackageFile_v2_Validator/test_analyzeSourceCode_bug18218.phpt 2011-02-27 18:58:02 UTC (rev 308728) @@ -0,0 +1,94 @@ +--TEST-- +PEAR_PackageFile_Parser_v2_Validator->analyzeSourceCode test +--SKIPIF-- +<?php +if (!getenv('PHP_PEAR_RUNTESTS')) { + echo 'skip'; +} +if (!function_exists('token_get_all')) { + echo 'skip'; +} +?> +--FILE-- +<?php +require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc'; + +require_once 'PEAR/PackageFile/v2/Validator.php'; +$validator = new PEAR_PackageFile_v2_Validator; +$validator->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v2', false, null); + +$testdir = $statedir; +@mkdir($testdir); + + +$test6 = <<<'TEST' +<?php +class SqlDiff_Version { + /** + * The current version + * + * @var string + */ + static protected $id = '@package_version@'; + + /** + * Get the version number only + * + * @return string + */ + static public function getVersionNumber() { + if (strpos(static::$id, '@package_version') === 0) { + return 'dev'; + } + + return static::$id; + } + + /** + * Get the version string + * + * @return string + */ + static public function getVersionString() { + return 'SqlDiff-' . static::getVersionNumber() . ' by Christer Edvartsen.' . PHP_EOL; + } +} +?> +TEST; +$fp = fopen($testdir . DIRECTORY_SEPARATOR . 'test6.php', 'w'); +fwrite($fp, $test6); +fclose($fp); + +$ret = $validator->analyzeSourceCode($testdir . DIRECTORY_SEPARATOR . 'test6.php'); +unlink($testdir . DIRECTORY_SEPARATOR . 'test6.php'); + +$phpunit->assertNoErrors('1st valid PHP'); +$phpunit->showall(); +$phpunit->assertEquals(array( + "source_file" => $testdir . DIRECTORY_SEPARATOR . 'test6.php', + "declared_classes"=> array( + 0 => "SqlDiff_Version" + ), + "declared_interfaces" => array(), + "declared_methods" => array( + "SqlDiff_Version" => array( + 0 => "getVersionNumber", + 1 => "getVersionString" + ), + ), + "declared_functions" => array(), + "used_classes" => array( + 0 => "static" + ), + "inheritance" => array(), + "implements" => array(), +), $ret, 'LSB, 1st valid PHP test'); + +echo 'tests done'; +?> +--CLEAN-- +<?php +require_once dirname(__FILE__) . '/teardown.php.inc'; +?> +--EXPECT-- +tests done

« previous php.pear.core (#9755) next »