Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'zf2/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 26 changed files with 350 additions and 525 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

14 changes: 0 additions & 14 deletions .travis/run-tests.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .travis/skipped-components

This file was deleted.

61 changes: 0 additions & 61 deletions .travis/tested-components

This file was deleted.

9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zendframework/zend-file",
"description": "Zend\\File component",
"description": " ",
"license": "BSD-3-Clause",
"keywords": [
"zf2",
Expand All @@ -9,11 +9,11 @@
"homepage": "https://github.com/zendframework/zend-file",
"autoload": {
"psr-4": {
"Zend\\File\\": "src/"
"Zend\\File": "src/"
}
},
"require": {
"php": ">=5.3.23",
"php": ">=5.3.3",
"zendframework/zend-stdlib": "self.version"
},
"require-dev": {
Expand All @@ -27,7 +27,8 @@
"suggest": {
"zendframework/zend-filter": "Zend\\Filter component",
"zendframework/zend-i18n": "Zend\\I18n component",
"zendframework/zend-validator": "Zend\\Validator component"
"zendframework/zend-validator": "Zend\\Validator component",
"zendframework/zend-loader": "Zend\\Loader component"
},
"extra": {
"branch-alias": {
Expand Down
80 changes: 42 additions & 38 deletions src/ClassFileLocator.php
Original file line number Diff line number Diff line change
@@ -1,48 +1,36 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* 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 [email protected] so we can send you a copy immediately.
*
* @category Zend
* @package Zend_File
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_File
*/

namespace Zend\File;

// import SPL classes/interfaces into local scope
use DirectoryIterator,
FilterIterator,
RecursiveIterator,
RecursiveDirectoryIterator,
RecursiveIteratorIterator;
use DirectoryIterator;
use FilterIterator;
use RecursiveDirectoryIterator;
use RecursiveIterator;
use RecursiveIteratorIterator;
use SplFileInfo;

/**
* Locate files containing PHP classes, interfaces, abstracts or traits
*
* @category Zend
* @package Zend_File
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class ClassFileLocator extends FilterIterator
{
/**
* Create an instance of the locator iterator
*
* Expects either a directory, or a DirectoryIterator (or its recursive variant)
*
* Expects either a directory, or a DirectoryIterator (or its recursive variant)
* instance.
*
*
* @param string|DirectoryIterator $dirOrIterator
*/
public function __construct($dirOrIterator = '.')
Expand All @@ -62,20 +50,20 @@ public function __construct($dirOrIterator = '.')
}

parent::__construct($dirOrIterator);
$this->setInfoClass('Zend\File\PhpClassFile');
}

/**
* 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
// If we somehow have something other than an SplFileInfo object, just
// return false
if (!$file instanceof \SplFileInfo) {
if (!$file instanceof SplFileInfo) {
return false;
}

Expand All @@ -95,13 +83,11 @@ public function accept()
$t_trait = defined('T_TRAIT') ? T_TRAIT : -1; // For preserve PHP 5.3 compatibility
for ($i = 0; $i < $count; $i++) {
$token = $tokens[$i];

if (!is_array($token)) {
// single character token found; skip
$i++;
continue;
}

switch ($token[0]) {
case T_NAMESPACE:
// Namespace found; grab it for later
Expand All @@ -110,6 +96,11 @@ public function accept()
$token = $tokens[$i];
if (is_string($token)) {
if (';' === $token) {
$saveNamespace = false;
break;
}
if ('{' === $token) {
$saveNamespace = true;
break;
}
continue;
Expand All @@ -122,9 +113,9 @@ public function accept()
break;
}
}

// Set the namespace of this file in the object
$file->namespace = $namespace;
if ($saveNamespace) {
$savedNamespace = $namespace;
}
break;
case $t_trait:
case T_CLASS:
Expand All @@ -141,16 +132,29 @@ public function accept()
if (T_STRING == $type) {
// If a classname was found, set it in the object, and
// return boolean true (found)
$file->classname = $content;
return true;
if (!isset($namespace) || null === $namespace) {
if (isset($saveNamespace) && $saveNamespace) {
$namespace = $savedNamespace;
} else {
$namespace = null;
}

}
$class = (null === $namespace) ? $content : $namespace . '\\' . $content;
$file->addClass($class);
$namespace = null;
break;
}
}
break;
default:
break;
}
}

$classes = $file->getClasses();
if (!empty($classes)) {
return true;
}
// No class-type tokens found; return false
return false;
}
Expand Down
24 changes: 6 additions & 18 deletions src/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* 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 [email protected] so we can send you a copy immediately.
*
* @category Zend
* @package Zend_File_Transfer
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_File
*/

namespace Zend\File\Exception;

/**
* @category Zend
* @package Zend_File_Transfer
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class BadMethodCallException extends \BadMethodCallException implements
class BadMethodCallException extends \BadMethodCallException implements
ExceptionInterface
{}
24 changes: 6 additions & 18 deletions src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* 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 [email protected] so we can send you a copy immediately.
*
* @category Zend
* @package Zend_File
* @subpackage Exception
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_File
*/

namespace Zend\File\Exception;

/**
* 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 ExceptionInterface
{
Expand Down
Loading

0 comments on commit d3f730c

Please sign in to comment.