forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring milestones/exceptions up-to-date with zf2/master
Merge branch 'zf2/master' into milestones/exceptions Conflicts: library/Zend/Amf/Parser/TypeLoader.php library/Zend/Amf/Server.php library/Zend/Application/AbstractBootstrap.php library/Zend/File/Transfer/Adapter/AbstractAdapter.php library/Zend/Filter/Inflector.php library/Zend/Filter/InputFilter.php library/Zend/Filter/StaticFilter.php library/Zend/Form/Element.php library/Zend/Form/Element/File.php library/Zend/InfoCard/XML/Security/Transform/Exception.php library/Zend/Navigation/Page/Mvc.php library/Zend/Paginator/Paginator.php library/Zend/Search/Lucene/Document/Exception.php library/Zend/Serializer/Adapter/Amf0.php library/Zend/Serializer/Adapter/Amf3.php library/Zend/Serializer/Exception.php library/Zend/Serializer/Serializer.php library/Zend/Service/Amazon/Ec2/AbstractService.php library/Zend/Tag/Cloud.php library/Zend/Tag/Cloud/Decorator/Exception.php library/Zend/Tag/Cloud/Decorator/HtmlTag.php library/Zend/Test/PHPUnit/ControllerTestCase.php library/Zend/Validator/StaticValidator.php library/Zend/Wildfire/Protocol/Exception.php library/Zend/Wildfire/Protocol/Exception/InvalidArgumentException.php tests/Zend/Application/AbstractBootstrapTest.php tests/Zend/Filter/InputTest.php tests/Zend/Filter/StaticFilterTest.php tests/Zend/Form/ElementTest.php tests/Zend/Form/FormTest.php tests/Zend/Paginator/PaginatorTest.php tests/Zend/Serializer/SerializerTest.php tests/Zend/Tag/Cloud/CloudTest.php tests/Zend/Tag/Cloud/Decorator/HtmlTagTest.php tests/Zend/Translate/Adapter/XmlTmTest.php
- Loading branch information
Showing
3,711 changed files
with
15,664 additions
and
12,637 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
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,2 @@ | ||
nbproject | ||
|
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,16 @@ | ||
<?php | ||
require_once __DIR__ . '/../library/Zend/Loader/ClassMapAutoloader.php'; | ||
$loader = new Zend\Loader\ClassMapAutoloader(); | ||
$loader->registerAutoloadMap(__DIR__ . '/../library/Zend/Controller/_autoload.php'); | ||
$loader->register(); | ||
|
||
if (!class_exists('Zend\Controller\Action')) { | ||
echo "Could not find action class?\n"; | ||
} else { | ||
echo "Found action class!\n"; | ||
} | ||
if (!class_exists('Zend\Version')) { | ||
echo "Could not find version class!\n"; | ||
} else { | ||
echo "Found version class?\n"; | ||
} |
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,12 @@ | ||
<?php | ||
require_once __DIR__ . '/../library/Zend/_autoload.php'; | ||
if (!class_exists('Zend\Controller\Action')) { | ||
echo "Could not find action class?\n"; | ||
} else { | ||
echo "Found action class!\n"; | ||
} | ||
if (!class_exists('Zend\Version')) { | ||
echo "Could not find version class?\n"; | ||
} else { | ||
echo "Found version class!\n"; | ||
} |
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,147 @@ | ||
<?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 [email protected] so we can send you a copy immediately. | ||
* | ||
* @category Zend | ||
* @package Zend_Loader | ||
* @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 | ||
*/ | ||
|
||
/** | ||
* Generate class maps for use with autoloading. | ||
* | ||
* Usage: | ||
* --help|-h Get usage message | ||
* --library|-l [ <string> ] Library to parse; if none provided, assumes | ||
* current directory | ||
* --output|-o [ <string> ] Where to write autoload file; if not provided, | ||
* assumes ".classmap.php" in library directory | ||
* --overwrite|-w Whether or not to overwrite existing autoload | ||
* file | ||
*/ | ||
|
||
$libPath = __DIR__ . '/../library'; | ||
if (!is_dir($libPath)) { | ||
// Try to load StandardAutoloader from include_path | ||
if (false === include('Zend/Loader/StandardAutoloader.php')) { | ||
echo "Unable to locate autoloader via include_path; aborting" . PHP_EOL; | ||
exit(2); | ||
} | ||
} else { | ||
// Try to load StandardAutoloader from library | ||
if (false === include(__DIR__ . '/../library/Zend/Loader/StandardAutoloader.php')) { | ||
echo "Unable to locate autoloader via library; aborting" . PHP_EOL; | ||
exit(2); | ||
} | ||
} | ||
|
||
// Setup autoloading | ||
$loader = new Zend\Loader\StandardAutoloader(); | ||
$loader->register(); | ||
|
||
$rules = array( | ||
'help|h' => 'Get usage message', | ||
'library|l-s' => 'Library to parse; if none provided, assumes current directory', | ||
'output|o-s' => 'Where to write autoload file; if not provided, assumes ".classmap.php" in library directory', | ||
'overwrite|w' => 'Whether or not to overwrite existing autoload file', | ||
); | ||
|
||
try { | ||
$opts = new Zend\Console\Getopt($rules); | ||
$opts->parse(); | ||
} catch (Zend\Console\Getopt\Exception $e) { | ||
echo $e->getUsageMessage(); | ||
exit(2); | ||
} | ||
|
||
if ($opts->getOption('h')) { | ||
echo $opts->getUsageMessage(); | ||
exit(); | ||
} | ||
|
||
$path = $libPath; | ||
if (array_key_exists('PWD', $_SERVER)) { | ||
$path = $_SERVER['PWD']; | ||
} | ||
if (isset($opts->l)) { | ||
$path = $opts->l; | ||
if (!is_dir($path)) { | ||
echo "Invalid library directory provided" . PHP_EOL . PHP_EOL; | ||
echo $opts->getUsageMessage(); | ||
exit(2); | ||
} | ||
$path = realpath($path); | ||
} | ||
|
||
$usingStdout = false; | ||
$output = $path . DIRECTORY_SEPARATOR . '.classmap.php'; | ||
if (isset($opts->o)) { | ||
$output = $opts->o; | ||
if ('-' == $output) { | ||
$output = STDOUT; | ||
$usingStdout = true; | ||
} elseif (!is_writeable(dirname($output))) { | ||
echo "Cannot write to '$output'; aborting." . PHP_EOL | ||
. PHP_EOL | ||
. $opts->getUsageMessage(); | ||
exit(2); | ||
} elseif (file_exists($output)) { | ||
if (!$opts->getOption('w')) { | ||
echo "Autoload file already exists at '$output'," . PHP_EOL | ||
. "but 'overwrite' flag was not specified; aborting." . PHP_EOL | ||
. PHP_EOL | ||
. $opts->getUsageMessage(); | ||
exit(2); | ||
} | ||
} | ||
} | ||
|
||
$strip = $path; | ||
|
||
if (!$usingStdout) { | ||
echo "Creating class file map for library in '$path'..." . PHP_EOL; | ||
} | ||
|
||
// Get the ClassFileLocater, and pass it the library path | ||
$l = new \Zend\File\ClassFileLocater($path); | ||
|
||
// Iterate over each element in the path, and create a map of | ||
// classname => filename, where the filename is relative to the library path | ||
$map = new \stdClass; | ||
$strip .= DIRECTORY_SEPARATOR; | ||
iterator_apply($l, function() use ($l, $map, $strip){ | ||
$file = $l->current(); | ||
$namespace = empty($file->namespace) ? '' : $file->namespace . '\\'; | ||
$filename = str_replace($strip, '', $file->getRealpath()); | ||
|
||
$map->{$namespace . $file->classname} = $filename; | ||
|
||
return true; | ||
}); | ||
|
||
// Create a file with the class/file map. | ||
// Stupid syntax highlighters make separating < from PHP declaration necessary | ||
$content = '<' . "?php\n" | ||
. 'return ' . var_export((array) $map, true) . ';'; | ||
|
||
// Prefix with __DIR__; modify the generated content | ||
$content = preg_replace('#(=> )#', '$1__DIR__ . DIRECTORY_SEPARATOR . ', $content); | ||
|
||
// Write the contents to disk | ||
file_put_contents($output, $content); | ||
|
||
if (!$usingStdout) { | ||
echo "Wrote classmap file to '" . realpath($output) . "'" . PHP_EOL; | ||
} |
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,41 @@ | ||
<?php | ||
/** | ||
* createAutoloadTestClasses.php | ||
* | ||
* A script for creating a hierarchy of classes for use with testing | ||
* autoloading. Each directory has classes from a to p; additional classes are | ||
* generated 2 levels deep, giving a total of 16^3 classes to use in | ||
* autoloading tests. | ||
*/ | ||
|
||
function createClasses($depth, $namespace) | ||
{ | ||
foreach (range('a', 'p') as $letter) { | ||
// Create content for namespaced class | ||
$content =<<<EOT | ||
<?php | ||
namespace $namespace; | ||
class $letter { } | ||
EOT; | ||
|
||
// Write content to disk | ||
$dir = str_replace('\\', DIRECTORY_SEPARATOR, $namespace); | ||
file_put_contents( | ||
$dir . DIRECTORY_SEPARATOR . $letter . '.php', | ||
$content | ||
); | ||
|
||
// If we still have depth, recurse and create more classes using the | ||
// current letter as a sub-namespace. | ||
if ($depth > 0) { | ||
$childDir = $dir . DIRECTORY_SEPARATOR . $letter; | ||
mkdir($childDir); | ||
createClasses($depth - 1, $namespace . '\\' . $letter); | ||
} | ||
} | ||
} | ||
|
||
// Use 'test' as the top-level namespace, and set a depth of "2" (will provide | ||
// 3 levels of classes). | ||
mkdir('test'); | ||
createClasses(2, 'test'); |
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
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 | ||
$libPath = __DIR__ . '/../library'; | ||
if (!is_dir($libPath)) { | ||
echo "Unable to find Zend Framework library; aborting" . PHP_EOL; | ||
exit(2); | ||
} | ||
$libPath = realpath($libPath); | ||
|
||
// Add ZF to the include_path, if it isn't already | ||
$incPath = get_include_path(); | ||
if (!strstr($incPath, $libPath)) { | ||
set_include_path($libPath . PATH_SEPARATOR . $incPath); | ||
} | ||
|
||
// Setup autoloading | ||
require_once 'Zend/Loader/Autoloader.php'; | ||
Zend\Loader\Autoloader::getInstance(); | ||
|
||
$rules = array( | ||
'help|h' => 'Get usage message', | ||
'library|l-s' => 'Library to parse; if none provided, assumes current directory', | ||
'namespace|n-s' => 'Namespace in which to create map; by default, uses last segment of library directory name', | ||
'output|o-s' => 'Where to write autoload file; if not provided, assumes "_autoload.php" in library directory', | ||
'overwrite|w' => 'Whether or not to overwrite existing autoload file', | ||
'keepdepth|k-i' => 'How many additional segments of the library path to keep in the generated classfile map', | ||
'usedir|d' => 'Prepend filenames with __DIR__', | ||
); | ||
|
||
try { | ||
$opts = new Zend\Console\Getopt($rules); | ||
$opts->parse(); | ||
} catch (Zend\Console\Getopt\Exception $e) { | ||
echo $e->getUsageMessage(); | ||
exit(2); | ||
} | ||
|
||
if ($opts->getOption('h')) { | ||
echo $opts->getUsageMessage(); | ||
exit(); | ||
} | ||
|
||
$path = $libPath; | ||
if (array_key_exists('PWD', $_SERVER)) { | ||
$path = $_SERVER['PWD']; | ||
} | ||
if (isset($opts->l)) { | ||
$path = $opts->l; | ||
if (!is_dir($path)) { | ||
echo "Invalid library directory provided" . PHP_EOL . PHP_EOL; | ||
echo $opts->getUsageMessage(); | ||
exit(2); | ||
} | ||
$path = realpath($path); | ||
} | ||
|
||
$namespace = substr($path, strrpos($path, DIRECTORY_SEPARATOR) + 1); | ||
if (isset($opts->n)) { | ||
$tmp = $opts->n; | ||
if (!empty($tmp)) { | ||
if (!preg_match('#^[a-z][a-z0-9]*(\\\\[a-z][a-z[0-9_]])*#', $tmp)) { | ||
echo "Invalid namespace provided; aborting." . PHP_EOL | ||
. PHP_EOL | ||
. $opts->getUsageMessage(); | ||
exit(2); | ||
} | ||
$namespace = $tmp; | ||
} | ||
} | ||
|
||
$usingStdout = false; | ||
$output = $path . DIRECTORY_SEPARATOR . '_autoload.php'; | ||
if (isset($opts->o)) { | ||
$output = $opts->o; | ||
if ('-' == $output) { | ||
$output = STDOUT; | ||
$usingStdout = true; | ||
} elseif (!is_writeable(dirname($output))) { | ||
echo "Cannot write to '$output'; aborting." . PHP_EOL | ||
. PHP_EOL | ||
. $opts->getUsageMessage(); | ||
exit(2); | ||
} elseif (file_exists($output)) { | ||
if (!$opts->getOption('w')) { | ||
echo "Autoload file already exists at '$output'," . PHP_EOL | ||
. "but 'overwrite' flag was not specified; aborting." . PHP_EOL | ||
. PHP_EOL | ||
. $opts->getUsageMessage(); | ||
exit(2); | ||
} | ||
} | ||
} | ||
|
||
$strip = $path; | ||
$keepDepth = 0; | ||
if (isset($opts->k)) { | ||
$keepDepth = $opts->k; | ||
if ($keepDepth < 0) { | ||
$keepDepth = 0; | ||
} | ||
} | ||
if ($keepDepth > 0) { | ||
$segments = explode(DIRECTORY_SEPARATOR, $path); | ||
do { | ||
array_pop($segments); | ||
--$keepDepth; | ||
} while (count($segments) > 0 && $keepDepth > 0); | ||
$strip = implode(DIRECTORY_SEPARATOR, $segments); | ||
} | ||
|
||
$prefixWithDir = $opts->getOption('d'); | ||
|
||
if (!$usingStdout) { | ||
echo "Creating class file map for library in '$path'..." . PHP_EOL; | ||
} | ||
|
||
// Get the ClassFileLocater, and pass it the library path | ||
$l = new \Zend\File\ClassFileLocater($path); | ||
|
||
// Iterate over each element in the path, and create a map of | ||
// classname => filename, where the filename is relative to the library path | ||
$map = new \stdClass; | ||
$strip .= DIRECTORY_SEPARATOR; | ||
iterator_apply($l, function() use ($l, $map, $strip){ | ||
$file = $l->current(); | ||
$namespace = empty($file->namespace) ? '' : $file->namespace . '\\'; | ||
$filename = str_replace($strip, '', $file->getRealpath()); | ||
|
||
$map->{$namespace . $file->classname} = $filename; | ||
|
||
return true; | ||
}); | ||
|
||
// Create a file with the class/file map. | ||
// Stupid syntax highlighters make separating < from PHP declaration necessary | ||
$map = var_export((array) $map, true); | ||
$content =<<<EOT | ||
<?php | ||
namespace $namespace; | ||
\$_map = $map; | ||
spl_autoload_register(function(\$class) use (\$_map) { | ||
if (array_key_exists(\$class, \$_map)) { | ||
require_once \$_map[\$class]; | ||
} | ||
}); | ||
EOT; | ||
|
||
// If requested to prefix with __DIR__, modify the content | ||
if ($prefixWithDir) { | ||
$content = preg_replace('#(=> )#', '$1__DIR__ . DIRECTORY_SEPARATOR . ', $content); | ||
} | ||
file_put_contents($output, $content); | ||
|
||
if (!$usingStdout) { | ||
echo "Wrote autoload file to '" . realpath($output) . "'" . PHP_EOL; | ||
} |
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
Oops, something went wrong.