cvs: pear /PHP_Parser/Parser/DocBlock DefaultInlineTagLexer.php /PHP_Parser/tests PHP_Parser_DocBlock_DefaultInlineTagLexer_test.php
| From: | Greg Beaver | Date: | Sat, 13 Mar 2004 20:44:25 +0000 |
| Subject: | cvs: pear /PHP_Parser/Parser/DocBlock DefaultInlineTagLexer.php /PHP_Parser/tests PHP_Parser_DocBlock_DefaultInlineTagLexer_test.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-17373@lists.php.net to get a copy of this message | ||
cellog Sat Mar 13 15:44:25 2004 EDT
Modified files:
/pear/PHP_Parser/Parser/DocBlock DefaultInlineTagLexer.php
/pear/PHP_Parser/tests
PHP_Parser_DocBlock_DefaultInlineTagLexer_test.php
Log:
forgot about {@link mailto:blah} and {@link http://www.example.com}, added support for this and tests
http://cvs.php.net/diff.php/pear/PHP_Parser/Parser/DocBlock/DefaultInlineTagLexer.php?r1=1.2&r2=1.3&ty=u
Index: pear/PHP_Parser/Parser/DocBlock/DefaultInlineTagLexer.php
diff -u pear/PHP_Parser/Parser/DocBlock/DefaultInlineTagLexer.php:1.2
pear/PHP_Parser/Parser/DocBlock/DefaultInlineTagLexer.php:1.3
--- pear/PHP_Parser/Parser/DocBlock/DefaultInlineTagLexer.php:1.2 Sat Mar 13 15:30:14 2004
+++ pear/PHP_Parser/Parser/DocBlock/DefaultInlineTagLexer.php Sat Mar 13 15:44:24 2004
@@ -98,6 +98,13 @@
$details['link'] = $details['text'] = $word;
$details['valid'] = true;
$details['type'] = 'unknown';
+ if (strpos($word, 'mailto:') === 0 || strpos($word,
'://')) {
+ if (strpos($word, 'mailto::') === false) {
+ // just in case someone names a class "mailto"
+ $details['type'] = 'url';
+ return $details;
+ }
+ }
$save = $word;
if (strpos($word, '#')) {
$details['link'] = $word = substr($word, strpos($word, '#') + 1);
// chop off package selector
http://cvs.php.net/diff.php/pear/PHP_Parser/tests/PHP_Parser_DocBlock_DefaultInlineTagLexer_test.php?r1=1.1&r2=1.2&ty=u
Index: pear/PHP_Parser/tests/PHP_Parser_DocBlock_DefaultInlineTagLexer_test.php
diff -u pear/PHP_Parser/tests/PHP_Parser_DocBlock_DefaultInlineTagLexer_test.php:1.1
pear/PHP_Parser/tests/PHP_Parser_DocBlock_DefaultInlineTagLexer_test.php:1.2
--- pear/PHP_Parser/tests/PHP_Parser_DocBlock_DefaultInlineTagLexer_test.php:1.1 Sat Mar 13 15:30:19
2004
+++ pear/PHP_Parser/tests/PHP_Parser_DocBlock_DefaultInlineTagLexer_test.php Sat Mar 13 15:44:25
2004
@@ -3,7 +3,7 @@
/**
* API Unit tests for PHP_Parser package.
*
- * @version $Id: PHP_Parser_DocBlock_DefaultInlineTagLexer_test.php,v 1.1 2004/03/13 20:30:19
cellog Exp $
+ * @version $Id: PHP_Parser_DocBlock_DefaultInlineTagLexer_test.php,v 1.2 2004/03/13 20:44:25
cellog Exp $
* @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS
* @author Greg Beaver
* @package PHP_Parser
@@ -558,6 +558,45 @@
$this->assertFalse($this->lexer->getLink(), 2);
}
+ function test_getLink_url()
+ {
+ if (!$this->_methodExists('newTag')) {
+ return;
+ }
+ if (!$this->_methodExists('getLink')) {
+ return;
+ }
+ $this->lexer->newTag('mailto:test@example.com');
+ $this->assertEquals(
+ array(
+ 'text' => 'mailto:test@example.com',
+ 'link' => 'mailto:test@example.com',
+ 'valid' => true,
+ 'type' => 'url',
+ ),
+ $this->lexer->getLink(), 1);
+ $this->lexer->newTag('http://www.example.com');
+ $this->assertEquals(
+ array(
+ 'text' => 'http://www.example.com',
+ 'link' => 'http://www.example.com',
+ 'valid' => true,
+ 'type' => 'url',
+ ),
+ $this->lexer->getLink(), 2);
+ // very treeky :)
+ $this->lexer->newTag('mailto::sender()');
+ $this->assertEquals(
+ array(
+ 'text' => 'mailto::sender()',
+ 'link' => 'sender',
+ 'valid' => true,
+ 'type' => 'method',
+ 'class' => 'mailto',
+ ),
+ $this->lexer->getLink(), 3);
+ }
+
function test_invalid_getLink()
{
if (!$this->_methodExists('newTag')) {