This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: library/Zend/Markup/Parser/Textile.php library/Zend/Markup/Renderer/AbstractRenderer.php library/Zend/Markup/Renderer/Html.php
- Loading branch information
Showing
18 changed files
with
864 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<?php | ||
|
||
/** @namespace */ | ||
namespace Zend\File; | ||
|
||
// import SPL classes/interfaces into local scope | ||
use DirectoryIterator, | ||
FilterIterator, | ||
RecursiveIterator, | ||
RecursiveDirectoryIterator, | ||
RecursiveIteratorIterator; | ||
|
||
/** | ||
* Locate files containing PHP classes, interfaces, or abstracts | ||
* | ||
* @package Zend_File | ||
* @license New BSD {@link http://framework.zend.com/license/new-bsd} | ||
*/ | ||
class ClassFileLocater extends FilterIterator | ||
{ | ||
/** | ||
* Create an instance of the locater iterator | ||
* | ||
* Expects either a directory, or a DirectoryIterator (or its recursive variant) | ||
* instance. | ||
* | ||
* @param string|DirectoryIterator $dirOrIterator | ||
* @return void | ||
*/ | ||
public function __construct($dirOrIterator = '.') | ||
{ | ||
if (is_string($dirOrIterator)) { | ||
if (!is_dir($dirOrIterator)) { | ||
throw new Exception\InvalidArgumentException('Expected a valid directory name'); | ||
} | ||
|
||
$dirOrIterator = new RecursiveDirectoryIterator($dirOrIterator); | ||
} | ||
if (!$dirOrIterator instanceof DirectoryIterator) { | ||
throw new Exception\InvalidArgumentException('Expected a DirectoryIterator'); | ||
} | ||
|
||
if ($dirOrIterator instanceof RecursiveIterator) { | ||
$iterator = new RecursiveIteratorIterator($dirOrIterator); | ||
} else { | ||
$iterator = $dirOrIterator; | ||
} | ||
|
||
parent::__construct($iterator); | ||
$this->rewind(); | ||
} | ||
|
||
/** | ||
* Filter for files containing PHP classes, interfaces, or abstracts | ||
* | ||
* @return bool | ||
*/ | ||
public function accept() | ||
{ | ||
$file = $this->getInnerIterator()->current(); | ||
|
||
// If we somehow have something other than an SplFileInfo object, just | ||
// return false | ||
if (!$file instanceof \SplFileInfo) { | ||
return false; | ||
} | ||
|
||
// If we have a directory, it's not a file, so return false | ||
if (!$file->isFile()) { | ||
return false; | ||
} | ||
|
||
// If not a PHP file, skip | ||
if ($file->getBasename('.php') == $file->getBasename()) { | ||
return false; | ||
} | ||
|
||
$contents = file_get_contents($file->getRealPath()); | ||
$tokens = token_get_all($contents); | ||
$count = count($tokens); | ||
$i = 0; | ||
while ($i < $count) { | ||
$token = $tokens[$i]; | ||
|
||
if (!is_array($token)) { | ||
// single character token found; skip | ||
$i++; | ||
continue; | ||
} | ||
|
||
list($id, $content, $line) = $token; | ||
|
||
switch ($id) { | ||
case T_NAMESPACE: | ||
// Namespace found; grab it for later | ||
$namespace = ''; | ||
$done = false; | ||
do { | ||
++$i; | ||
$token = $tokens[$i]; | ||
if (is_string($token)) { | ||
if (';' === $token) { | ||
$done = true; | ||
} | ||
continue; | ||
} | ||
list($type, $content, $line) = $token; | ||
switch ($type) { | ||
case T_STRING: | ||
case T_NS_SEPARATOR: | ||
$namespace .= $content; | ||
break; | ||
} | ||
} while (!$done && $i < $count); | ||
|
||
// Set the namespace of this file in the object | ||
$file->namespace = $namespace; | ||
break; | ||
case T_CLASS: | ||
case T_INTERFACE: | ||
// Abstract class, class, or interface found | ||
|
||
// Get the classname | ||
$class = ''; | ||
do { | ||
++$i; | ||
$token = $tokens[$i]; | ||
if (is_string($token)) { | ||
continue; | ||
} | ||
list($type, $content, $line) = $token; | ||
switch ($type) { | ||
case T_STRING: | ||
$class = $content; | ||
break; | ||
} | ||
} while (empty($class) && $i < $count); | ||
|
||
// If a classname was found, set it in the object, and | ||
// return boolean true (found) | ||
if (!empty($class)) { | ||
$file->classname = $class; | ||
return true; | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
++$i; | ||
} | ||
|
||
// No class-type tokens found; return false | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Zend Framework | ||
* | ||
* LICENSE | ||
* | ||
* This source file is subject to the new BSD license that is bundled | ||
* with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://framework.zend.com/license/new-bsd | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@zend.com so we can send you a copy immediately. | ||
* | ||
* @category Zend | ||
* @package Zend_File | ||
* @subpackage Exception | ||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
/** @namespace */ | ||
namespace Zend\File; | ||
|
||
/** | ||
* Marker interface for exceptions found in this component | ||
* | ||
* @package Zend_File | ||
* @subpackage Exception | ||
* @license New BSD {@link http://framework.zend.com/license/new-bsd} | ||
*/ | ||
interface Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/** | ||
* Zend Framework | ||
* | ||
* LICENSE | ||
* | ||
* This source file is subject to the new BSD license that is bundled | ||
* with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://framework.zend.com/license/new-bsd | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@zend.com so we can send you a copy immediately. | ||
* | ||
* @category Zend | ||
* @package Zend_File | ||
* @subpackage Exception | ||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
/** @namespace */ | ||
namespace Zend\File\Exception; | ||
|
||
use Zend\File\Exception; | ||
|
||
/** | ||
* Exception class raised when invalid arguments are discovered | ||
* | ||
* @package Zend_File | ||
* @license New BSD {@link http://framework.zend.com/license/new-bsd} | ||
*/ | ||
class InvalidArgumentException | ||
extends \InvalidArgumentException | ||
implements Exception | ||
{ | ||
} |
Oops, something went wrong.