diff -Nru zendframework-1.10.4/bin/autoload_example.php zendframework-2.2.6/bin/autoload_example.php
--- zendframework-1.10.4/bin/autoload_example.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/bin/autoload_example.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,16 @@
+registerAutoloadMap(__DIR__ . '/../library/Zend/.classmap.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";
+}
diff -Nru zendframework-1.10.4/bin/autoload_examples.php zendframework-2.2.6/bin/autoload_examples.php
--- zendframework-1.10.4/bin/autoload_examples.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/bin/autoload_examples.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,12 @@
+ ] Library to parse; if none provided, assumes
+ * current directory
+ * --output|-o [ ] Where to write autoload file; if not provided,
+ * assumes "autoload_classmap.php" in library directory
+ * --append|-a Append to autoload file if it exists
+ * --overwrite|-w Whether or not to overwrite existing autoload
+ * file
+ * --ignore|-i [ ] Comma-separated namespaces to ignore
+ * --sort|-s Alphabetically sort classes
+ */
+
+$zfLibraryPath = getenv('LIB_PATH') ? getenv('LIB_PATH') : __DIR__ . '/../library';
+if (is_dir($zfLibraryPath)) {
+ // Try to load StandardAutoloader from library
+ if (false === include($zfLibraryPath . '/Zend/Loader/StandardAutoloader.php')) {
+ echo 'Unable to locate autoloader via library; aborting' . PHP_EOL;
+ exit(2);
+ }
+} else {
+ // 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);
+ }
+}
+
+$libraryPath = getcwd();
+
+// Setup autoloading
+$loader = new StandardAutoloader(array('autoregister_zf' => true));
+$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 "autoload_classmap.php" in library directory',
+ 'append|a' => 'Append to autoload file if it exists',
+ 'overwrite|w' => 'Whether or not to overwrite existing autoload file',
+ 'ignore|i-s' => 'Comma-separated namespaces to ignore',
+ 'sort|s' => 'Alphabetically sort classes',
+);
+
+try {
+ $opts = new Console\Getopt($rules);
+ $opts->parse();
+} catch (Console\Exception\RuntimeException $e) {
+ echo $e->getUsageMessage();
+ exit(2);
+}
+
+if ($opts->getOption('h')) {
+ echo $opts->getUsageMessage();
+ exit(0);
+}
+
+$ignoreNamespaces = array();
+if (isset($opts->i)) {
+ $ignoreNamespaces = explode(',', $opts->i);
+}
+
+$relativePathForClassmap = '';
+if (isset($opts->l)) {
+ if (!is_dir($opts->l)) {
+ echo 'Invalid library directory provided' . PHP_EOL
+ . PHP_EOL;
+ echo $opts->getUsageMessage();
+ exit(2);
+ }
+ $libraryPath = $opts->l;
+}
+$libraryPath = str_replace(DIRECTORY_SEPARATOR, '/', realpath($libraryPath));
+
+$usingStdout = false;
+$appending = $opts->getOption('a');
+$output = $libraryPath . '/autoload_classmap.php';
+if (isset($opts->o)) {
+ $output = $opts->o;
+ if ('-' == $output) {
+ $output = STDOUT;
+ $usingStdout = true;
+ } elseif (is_dir($output)) {
+ echo 'Invalid output file provided' . PHP_EOL
+ . PHP_EOL;
+ echo $opts->getUsageMessage();
+ exit(2);
+ } elseif (!is_writeable(dirname($output))) {
+ echo "Cannot write to '$output'; aborting." . PHP_EOL
+ . PHP_EOL
+ . $opts->getUsageMessage();
+ exit(2);
+ } elseif (file_exists($output) && !$opts->getOption('w') && !$appending) {
+ echo "Autoload file already exists at '$output'," . PHP_EOL
+ . "but 'overwrite' or 'appending' flag was not specified; aborting." . PHP_EOL
+ . PHP_EOL
+ . $opts->getUsageMessage();
+ exit(2);
+ } else {
+ // We need to add the $libraryPath into the relative path that is created in the classmap file.
+ $classmapPath = str_replace(DIRECTORY_SEPARATOR, '/', realpath(dirname($output)));
+
+ // Simple case: $libraryPathCompare is in $classmapPathCompare
+ if (strpos($libraryPath, $classmapPath) === 0) {
+ $relativePathForClassmap = substr($libraryPath, strlen($classmapPath) + 1) . '/';
+ } else {
+ $libraryPathParts = explode('/', $libraryPath);
+ $classmapPathParts = explode('/', $classmapPath);
+
+ // Find the common part
+ $count = count($classmapPathParts);
+ for ($i = 0; $i < $count; $i++) {
+ if (!isset($libraryPathParts[$i]) || $libraryPathParts[$i] != $classmapPathParts[$i]) {
+ // Common part end
+ break;
+ }
+ }
+
+ // Add parent dirs for the subdirs of classmap
+ $relativePathForClassmap = str_repeat('../', $count - $i);
+
+ // Add library subdirs
+ $count = count($libraryPathParts);
+ for (; $i < $count; $i++) {
+ $relativePathForClassmap .= $libraryPathParts[$i] . '/';
+ }
+ }
+ }
+}
+
+if (!$usingStdout) {
+ if ($appending) {
+ echo "Appending to class file map '$output' for library in '$libraryPath'..." . PHP_EOL;
+ } else {
+ echo "Creating class file map for library in '$libraryPath'..." . PHP_EOL;
+ }
+}
+
+// Get the ClassFileLocator, and pass it the library path
+$l = new ClassFileLocator($libraryPath);
+
+// 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;
+foreach ($l as $file) {
+ $filename = str_replace($libraryPath . '/', '', str_replace(DIRECTORY_SEPARATOR, '/', $file->getPath()) . '/' . $file->getFilename());
+
+ // Add in relative path to library
+ $filename = $relativePathForClassmap . $filename;
+
+ foreach ($file->getClasses() as $class) {
+ foreach ($ignoreNamespaces as $ignoreNs) {
+ if ($ignoreNs == substr($class, 0, strlen($ignoreNs))) {
+ continue 2;
+ }
+ }
+
+ $map->{$class} = $filename;
+ }
+}
+
+$map = (array) $map;
+if ($opts->getOption('s')) {
+ ksort($map);
+}
+
+if ($appending) {
+ $content = var_export($map, true) . ';';
+
+ // Prefix with __DIR__; modify the generated content
+ $content = preg_replace("#(=> ')#", "=> __DIR__ . '/", $content);
+
+ // Fix \' strings from injected DIRECTORY_SEPARATOR usage in iterator_apply op
+ $content = str_replace("\\'", "'", $content);
+
+ // Convert to an array and remove the first "array("
+ $content = explode("\n", $content);
+ array_shift($content);
+
+ // Load existing class map file and remove the closing "bracket ");" from it
+ $existing = file($output, FILE_IGNORE_NEW_LINES);
+ array_pop($existing);
+
+ // Merge
+ $content = implode("\n", array_merge($existing, $content));
+} else {
+ // Create a file with the class/file map.
+ // Stupid syntax highlighters make separating < from PHP declaration necessary
+ $content = '<' . "?php\n"
+ . "// Generated by ZF2's ./bin/classmap_generator.php\n"
+ . 'return ' . var_export($map, true) . ';';
+
+ // Prefix with __DIR__; modify the generated content
+ $content = preg_replace("#(=> ')#", "=> __DIR__ . '/", $content);
+
+ // Fix \' strings from injected DIRECTORY_SEPARATOR usage in iterator_apply op
+ $content = str_replace("\\'", "'", $content);
+}
+
+// Remove unnecessary double-backslashes
+$content = str_replace('\\\\', '\\', $content);
+
+// Exchange "array (" width "array("
+$content = str_replace('array (', 'array(', $content);
+
+// Align "=>" operators to match coding standard
+preg_match_all('(\n\s+([^=]+)=>)', $content, $matches, PREG_SET_ORDER);
+$maxWidth = 0;
+
+foreach ($matches as $match) {
+ $maxWidth = max($maxWidth, strlen($match[1]));
+}
+
+$content = preg_replace_callback(
+ '(\n\s+([^=]+)=>)',
+ function ($match) use ($maxWidth) {
+ return "\n " . $match[1] . str_repeat(" ", $maxWidth - strlen($match[1])) . '=>';
+ },
+ $content
+);
+
+// Make the file end by EOL
+$content = rtrim($content, "\n") . "\n";
+
+// Write the contents to disk
+file_put_contents($output, $content);
+
+if (!$usingStdout) {
+ echo "Wrote classmap file to '" . realpath($output) . "'" . PHP_EOL;
+}
diff -Nru zendframework-1.10.4/bin/createAutoloadTestClasses.php zendframework-2.2.6/bin/createAutoloadTestClasses.php
--- zendframework-1.10.4/bin/createAutoloadTestClasses.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/bin/createAutoloadTestClasses.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,37 @@
+ 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');
diff -Nru zendframework-1.10.4/bin/pluginmap_generator.php zendframework-2.2.6/bin/pluginmap_generator.php
--- zendframework-1.10.4/bin/pluginmap_generator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/bin/pluginmap_generator.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,179 @@
+#!/usr/bin/env php
+ ] Library to parse; if none provided, assumes
+ * current directory
+ * --output|-o [ ] Where to write autoload file; if not provided,
+ * assumes "autoload_classmap.php" in library directory
+ * --append|-a Append to autoload file if it exists
+ * --overwrite|-w Whether or not to overwrite existing autoload
+ * file
+ */
+
+$libPath = getenv('LIB_PATH') ? getenv('LIB_PATH') : __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 $libPath . '/Zend/Loader/StandardAutoloader.php')) {
+ echo "Unable to locate autoloader via library; aborting" . PHP_EOL;
+ exit(2);
+ }
+}
+
+// Setup autoloading
+$loader = new StandardAutoloader(array('autoregister_zf' => true));
+$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 plugin map file; if not provided, assumes "plugin_classmap.php" in library directory',
+ 'append|a' => 'Append to plugin map file if it exists',
+ 'overwrite|w' => 'Whether or not to overwrite existing autoload file',
+);
+
+try {
+ $opts = new Console\Getopt($rules);
+ $opts->parse();
+} catch (Console\Exception\RuntimeException $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)) {
+ $libraryPath = $opts->l;
+ $libraryPath = rtrim($libraryPath, '/\\') . DIRECTORY_SEPARATOR;
+ if (!is_dir($libraryPath)) {
+ echo "Invalid library directory provided" . PHP_EOL . PHP_EOL;
+ echo $opts->getUsageMessage();
+ exit(2);
+ }
+ $path = realpath($libraryPath);
+}
+
+$usingStdout = false;
+$appending = $opts->getOption('a');
+$output = $path . DIRECTORY_SEPARATOR . 'plugin_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') && !$appending) {
+ echo "Plugin map file already exists at '$output'," . PHP_EOL
+ . "but 'overwrite' flag was not specified; aborting." . PHP_EOL
+ . PHP_EOL
+ . $opts->getUsageMessage();
+ exit(2);
+ }
+ }
+}
+
+if (!$usingStdout) {
+ if ($appending) {
+ echo "Appending to plugin class map '$output' for classes in '$path'..." . PHP_EOL;
+ } else {
+ echo "Creating plugin class map for classes in '$path'..." . PHP_EOL;
+ }
+}
+
+// Get the ClassFileLocator, and pass it the library path
+$l = new \Zend\File\ClassFileLocator($path);
+
+// Iterate over each element in the path, and create a map of pluginname => classname
+$map = new \stdClass;
+foreach ($l as $file) {
+ $namespaces = $file->getNamespaces();
+ $namespace = empty($file->namespace) ? '' : $file->namespace . '\\';
+
+ foreach ($file->getClasses() as $classname) {
+ $plugin = $classname;
+ foreach ($namespaces as $namespace) {
+ $namespace .= '\\';
+ if (0 === strpos($plugin, $namespace)) {
+ $plugin = str_replace($namespace, '', $plugin);
+ }
+ }
+ $plugin = strtolower($plugin);
+ $map->{$plugin} = $classname;
+ }
+}
+
+if ($appending) {
+
+ $content = var_export((array) $map, true) . ';';
+
+ // Fix \' strings from injected DIRECTORY_SEPARATOR usage in iterator_apply op
+ $content = str_replace("\\'", "'", $content);
+
+ // Convert to an array and remove the first "array ("
+ $content = explode("\n", $content);
+ array_shift($content);
+
+ // Load existing class map file and remove the closing "bracket ");" from it
+ $existing = file($output, FILE_IGNORE_NEW_LINES);
+ array_pop($existing);
+
+ // Merge
+ $content = implode("\n", $existing + $content);
+} else {
+ // Create a file with the class/file map.
+ // Stupid syntax highlighters make separating < from PHP declaration necessary
+ $content = '<' . "?php\n\n"
+ . "// plugin class map\n"
+ . "// auto-generated using "
+ . basename($_SERVER['argv'][0]) . ', ' . date('Y-m-d H:i:s') . "\n\n"
+ . 'return ' . var_export((array) $map, true) . ';';
+
+ // Fix \' strings from injected DIRECTORY_SEPARATOR usage in iterator_apply op
+ $content = str_replace("\\'", "'", $content);
+}
+
+// Make the file end by EOL
+$content = rtrim($content, "\n") . "\n";
+
+// Write the contents to disk
+file_put_contents($output, $content);
+
+if (!$usingStdout) {
+ echo "Wrote plugin classmap file to '" . realpath($output) . "'" . PHP_EOL;
+}
diff -Nru zendframework-1.10.4/bin/templatemap_generator.php zendframework-2.2.6/bin/templatemap_generator.php
--- zendframework-1.10.4/bin/templatemap_generator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/bin/templatemap_generator.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,243 @@
+#!/usr/bin/env php
+ ] Library to parse; if none provided, assumes
+ * current directory
+ * --output|-o [ ] Where to write map file; if not provided,
+ * assumes "template_map.php" in library directory
+ * --append|-a Append to map file if it exists
+ * --overwrite|-w Whether or not to overwrite existing map file
+ */
+
+$zfLibraryPath = getenv('LIB_PATH') ? getenv('LIB_PATH') : __DIR__ . '/../library';
+if (is_dir($zfLibraryPath)) {
+ // Try to load StandardAutoloader from library
+ if (false === include($zfLibraryPath . '/Zend/Loader/StandardAutoloader.php')) {
+ echo 'Unable to locate autoloader via library; aborting' . PHP_EOL;
+ exit(2);
+ }
+} else {
+ // 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);
+ }
+}
+
+$libraryPath = getcwd();
+$viewPath = getcwd() . '/view';
+
+// Setup autoloading
+$loader = new StandardAutoloader(array('autoregister_zf' => true));
+$loader->register();
+
+$rules = array(
+ 'help|h' => 'Get usage message',
+ 'library|l-s' => 'Library to parse; if none provided, assumes current directory',
+ 'view|v-s' => 'View path to parse; if none provided, assumes view as template directory',
+ 'output|o-s' => 'Where to write map file; if not provided, assumes "template_map.php" in library directory',
+ 'append|a' => 'Append to map file if it exists',
+ 'overwrite|w' => 'Whether or not to overwrite existing map file',
+);
+
+try {
+ $opts = new Console\Getopt($rules);
+ $opts->parse();
+} catch (Console\Exception\RuntimeException $e) {
+ echo $e->getUsageMessage();
+ exit(2);
+}
+
+if ($opts->getOption('h')) {
+ echo $opts->getUsageMessage();
+ exit(0);
+}
+
+$relativePathForMap = '';
+if (isset($opts->l)) {
+ if (!is_dir($opts->l)) {
+ echo 'Invalid library directory provided' . PHP_EOL
+ . PHP_EOL;
+ echo $opts->getUsageMessage();
+ exit(2);
+ }
+ $libraryPath = $opts->l;
+}
+$libraryPath = str_replace(DIRECTORY_SEPARATOR, '/', realpath($libraryPath));
+
+if (isset($opts->v)) {
+ if (!is_dir($opts->v)) {
+ echo 'Invalid view template directory provided' . PHP_EOL
+ . PHP_EOL;
+ echo $opts->getUsageMessage();
+ exit(2);
+ }
+ $viewPath = $opts->v;
+}
+
+if (!is_dir($viewPath)) {
+ printf('Invalid view path provided (%s)', $viewPath);
+ echo PHP_EOL . PHP_EOL;
+ echo $opts->getUsageMessage();
+ exit(2);
+}
+
+$viewPath = str_replace(DIRECTORY_SEPARATOR, '/', realpath($viewPath));
+
+$usingStdout = false;
+$appending = $opts->getOption('a');
+$output = $libraryPath . '/template_map.php';
+if (isset($opts->o)) {
+ $output = $opts->o;
+ if ('-' == $output) {
+ $output = STDOUT;
+ $usingStdout = true;
+ } elseif (is_dir($output)) {
+ echo 'Invalid output file provided' . PHP_EOL
+ . PHP_EOL;
+ echo $opts->getUsageMessage();
+ exit(2);
+ } elseif (!is_writeable(dirname($output))) {
+ echo "Cannot write to '$output'; aborting." . PHP_EOL
+ . PHP_EOL
+ . $opts->getUsageMessage();
+ exit(2);
+ } elseif (file_exists($output) && !$opts->getOption('w') && !$appending) {
+ echo "Template map file already exists at '$output'," . PHP_EOL
+ . "but 'overwrite' or 'appending' flag was not specified; aborting." . PHP_EOL
+ . PHP_EOL
+ . $opts->getUsageMessage();
+ exit(2);
+ } else {
+ // We need to add the $libraryPath into the relative path that is created in the template map file.
+ $mapPath = str_replace(DIRECTORY_SEPARATOR, '/', realpath(dirname($output)));
+
+ // Simple case: $libraryPathCompare is in $mapPathCompare
+ if (strpos($libraryPath, $mapPath) === 0) {
+ $relativePathForMap = substr($libraryPath, strlen($mapPath) + 1) . '/';
+ } else {
+ $libraryPathParts = explode('/', $libraryPath);
+ $mapPathParts = explode('/', $mapPath);
+
+ // Find the common part
+ $count = count($mapPathParts);
+ for ($i = 0; $i < $count; $i++) {
+ if (!isset($libraryPathParts[$i]) || $libraryPathParts[$i] != $mapPathParts[$i]) {
+ // Common part end
+ break;
+ }
+ }
+
+ // Add parent dirs for the subdirs of map
+ $relativePathForMap = str_repeat('../', $count - $i);
+
+ // Add library subdirs
+ $count = count($libraryPathParts);
+ for (; $i < $count; $i++) {
+ $relativePathForMap .= $libraryPathParts[$i] . '/';
+ }
+ }
+ }
+}
+
+if (!$usingStdout) {
+ if ($appending) {
+ echo "Appending to template file map '$output' for library in '$libraryPath'..." . PHP_EOL;
+ } else {
+ echo "Creating template file map for library in '$libraryPath'..." . PHP_EOL;
+ }
+}
+
+$dirOrIterator = new RecursiveDirectoryIterator($viewPath, RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
+$l = new RecursiveIteratorIterator($dirOrIterator);
+
+// Iterate over each element in the path, and create a map of
+// template name => filename, where the filename is relative to the view path
+$map = new stdClass;
+foreach ($l as $file) {
+ if (!$file->isFile()) {
+ continue;
+ }
+ $filename = str_replace($libraryPath . '/', '', str_replace(DIRECTORY_SEPARATOR, '/', $file->getPath()) . '/' . $file->getFilename());
+
+ // Add in relative path to library
+ $filename = $relativePathForMap . $filename;
+ $baseName = $file->getBasename('.' . pathinfo($file->getFilename(), PATHINFO_EXTENSION));
+ $mapName = str_replace(str_replace(DIRECTORY_SEPARATOR, '/', realpath($viewPath)) . '/', '', str_replace(DIRECTORY_SEPARATOR, '/', $file->getPath()) . '/' . $baseName);
+ $map->{$mapName} = $filename;
+}
+
+
+if ($appending) {
+ $content = var_export((array) $map, true) . ';';
+
+ // Prefix with __DIR__; modify the generated content
+ $content = preg_replace("#(=> ')#", "=> __DIR__ . '/", $content);
+
+ // Fix \' strings from injected DIRECTORY_SEPARATOR usage in iterator_apply op
+ $content = str_replace("\\'", "'", $content);
+
+ // Convert to an array and remove the first "array("
+ $content = explode("\n", $content);
+ array_shift($content);
+
+ // Load existing map file and remove the closing "bracket ");" from it
+ $existing = file($output, FILE_IGNORE_NEW_LINES);
+ array_pop($existing);
+
+ // Merge
+ $content = implode("\n", array_merge($existing, $content));
+} else {
+ // Create a file with the map.
+ // Stupid syntax highlighters make separating < from PHP declaration necessary
+ $content = '<' . "?php\n"
+ . "// Generated by ZF2's ./bin/templatemap_generator.php\n"
+ . 'return ' . var_export((array) $map, true) . ';';
+
+ // Prefix with __DIR__; modify the generated content
+ $content = preg_replace("#(=> ')#", "=> __DIR__ . '/", $content);
+
+ // Fix \' strings from injected DIRECTORY_SEPARATOR usage in iterator_apply op
+ $content = str_replace("\\'", "'", $content);
+}
+
+// Remove unnecessary double-backslashes
+$content = str_replace('\\\\', '\\', $content);
+
+// Exchange "array (" width "array("
+$content = str_replace('array (', 'array(', $content);
+
+// Align "=>" operators to match coding standard
+preg_match_all('(\n\s+([^=]+)=>)', $content, $matches, PREG_SET_ORDER);
+$maxWidth = 0;
+
+foreach ($matches as $match) {
+ $maxWidth = max($maxWidth, strlen($match[1]));
+}
+
+$content = preg_replace('(\n\s+([^=]+)=>)e', "'\n \\1' . str_repeat(' ', " . $maxWidth . " - strlen('\\1')) . '=>'", $content);
+
+// Make the file end by EOL
+$content = rtrim($content, "\n") . "\n";
+
+// Write the contents to disk
+file_put_contents($output, $content);
+
+if (!$usingStdout) {
+ echo "Wrote templatemap file to '" . realpath($output) . "'" . PHP_EOL;
+}
diff -Nru zendframework-1.10.4/bin/zf.bat zendframework-2.2.6/bin/zf.bat
--- zendframework-1.10.4/bin/zf.bat 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/bin/zf.bat 1970-01-01 00:00:00.000000000 +0000
@@ -1,44 +0,0 @@
-@ECHO off
-REM Zend Framework
-REM
-REM LICENSE
-REM
-REM This source file is subject to the new BSD license that is bundled
-REM with this package in the file LICENSE.txt.
-REM It is also available through the world-wide-web at this URL:
-REM http://framework.zend.com/license/new-bsd
-REM If you did not receive a copy of the license and are unable to
-REM obtain it through the world-wide-web, please send an email
-REM to license@zend.com so we can send you a copy immediately.
-REM
-REM Zend
-REM Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
-REM http://framework.zend.com/license/new-bsd New BSD License
-
-
-REM Test to see if this was installed via pear
-SET ZTMPZTMPZTMPZ=@ph
-SET TMPZTMPZTMP=%ZTMPZTMPZTMPZ%p_bin@
-REM below @php_bin@
-FOR %%x IN ("@php_bin@") DO (if %%x=="%TMPZTMPZTMP%" GOTO :NON_PEAR_INSTALLED)
-
-GOTO PEAR_INSTALLED
-
-:NON_PEAR_INSTALLED
-REM Assume php.exe is executable, and that zf.php will reside in the
-REM same file as this one
-SET PHP_BIN=php.exe
-SET PHP_DIR=%~dp0
-GOTO RUN
-
-:PEAR_INSTALLED
-REM Assume this was installed via PEAR and use replacements php_bin & php_dir
-SET PHP_BIN=@php_bin@
-SET PHP_DIR=@php_dir@
-GOTO RUN
-
-:RUN
-SET ZF_SCRIPT=%PHP_DIR%\zf.php
-"%PHP_BIN%" -d safe_mode=Off -f "%ZF_SCRIPT%" -- %*
-
-
diff -Nru zendframework-1.10.4/bin/zf.php zendframework-2.2.6/bin/zf.php
--- zendframework-1.10.4/bin/zf.php 2010-01-13 05:55:07.000000000 +0000
+++ zendframework-2.2.6/bin/zf.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,635 +0,0 @@
-bootstrap();
- $zf->run();
- }
-
- /**
- * bootstrap()
- *
- * @return ZF
- */
- public function bootstrap()
- {
- // detect settings
- $this->_mode = $this->_detectMode();
- $this->_homeDirectory = $this->_detectHomeDirectory();
- $this->_storageDirectory = $this->_detectStorageDirectory();
- $this->_configFile = $this->_detectConfigFile();
-
- // setup
- $this->_setupPHPRuntime();
- $this->_setupToolRuntime();
- }
-
- /**
- * run()
- *
- * @return ZF
- */
- public function run()
- {
- switch ($this->_mode) {
- case 'runError':
- $this->_runError();
- $this->_runInfo();
- break;
- case 'runSetup':
- if ($this->_runSetup() === false) {
- $this->_runInfo();
- }
- break;
- case 'runInfo':
- $this->_runInfo();
- break;
- case 'runTool':
- default:
- $this->_runTool();
- break;
- }
-
- return $this;
- }
-
- /**
- * _detectMode()
- *
- * @return ZF
- */
- protected function _detectMode()
- {
- $arguments = $_SERVER['argv'];
-
- $mode = 'runTool';
-
- if (!isset($arguments[0])) {
- return $mode;
- }
-
- if ($arguments[0] == $_SERVER['PHP_SELF']) {
- $this->_executable = array_shift($arguments);
- }
-
- if (!isset($arguments[0])) {
- return $mode;
- }
-
- if ($arguments[0] == '--setup') {
- $mode = 'runSetup';
- } elseif ($arguments[0] == '--info') {
- $mode = 'runInfo';
- }
-
- return $mode;
- }
-
-
- /**
- * _detectHomeDirectory() - detect the home directory in a variety of different places
- *
- * @param $mustExist Should the returned value already exist in the file system
- * @param $returnMessages Should it log messages for output later
- * @return string
- */
- protected function _detectHomeDirectory($mustExist = true, $returnMessages = true)
- {
- $homeDirectory = null;
-
- $homeDirectory = getenv('ZF_HOME'); // check env var ZF_HOME
- if ($homeDirectory) {
- $this->_logMessage('Home directory found in environment variable ZF_HOME with value ' . $homeDirectory, $returnMessages);
- if (!$mustExist || ($mustExist && file_exists($homeDirectory))) {
- return $homeDirectory;
- } else {
- $this->_logMessage('Home directory does not exist at ' . $homeDirectory, $returnMessages);
- }
- }
-
- $homeDirectory = getenv('HOME'); // HOME environment variable
-
- if ($homeDirectory) {
- $this->_logMessage('Home directory found in environment variable HOME with value ' . $homeDirectory, $returnMessages);
- if (!$mustExist || ($mustExist && file_exists($homeDirectory))) {
- return $homeDirectory;
- } else {
- $this->_logMessage('Home directory does not exist at ' . $homeDirectory, $returnMessages);
- }
-
- }
-
- $homeDirectory = getenv('HOMEPATH');
-
- if ($homeDirectory) {
- $this->_logMessage('Home directory found in environment variable HOMEPATH with value ' . $homeDirectory, $returnMessages);
- if (!$mustExist || ($mustExist && file_exists($homeDirectory))) {
- return $homeDirectory;
- } else {
- $this->_logMessage('Home directory does not exist at ' . $homeDirectory, $returnMessages);
- }
- }
-
- $homeDirectory = getenv('USERPROFILE');
-
- if ($homeDirectory) {
- $this->_logMessage('Home directory found in environment variable USERPROFILE with value ' . $homeDirectory, $returnMessages);
- if (!$mustExist || ($mustExist && file_exists($homeDirectory))) {
- return $homeDirectory;
- } else {
- $this->_logMessage('Home directory does not exist at ' . $homeDirectory, $returnMessages);
- }
- }
-
- return false;
- }
-
- /**
- * _detectStorageDirectory() - Detect where the storage directory is from a variaty of possiblities
- *
- * @param $mustExist Should the returned value already exist in the file system
- * @param $returnMessages Should it log messages for output later
- * @return string
- */
- protected function _detectStorageDirectory($mustExist = true, $returnMessages = true)
- {
- $storageDirectory = false;
-
- $storageDirectory = getenv('ZF_STORAGE_DIR');
- if ($storageDirectory) {
- $this->_logMessage('Storage directory path found in environment variable ZF_STORAGE_DIR with value ' . $storageDirectory, $returnMessages);
- if (!$mustExist || ($mustExist && file_exists($storageDirectory))) {
- return $storageDirectory;
- } else {
- $this->_logMessage('Storage directory does not exist at ' . $storageDirectory, $returnMessages);
- }
- }
-
- $homeDirectory = ($this->_homeDirectory) ? $this->_homeDirectory : $this->_detectHomeDirectory(true, false);
-
- if ($homeDirectory) {
- $storageDirectory = $homeDirectory . '/.zf/';
- $this->_logMessage('Storage directory assumed in home directory at location ' . $storageDirectory, $returnMessages);
- if (!$mustExist || ($mustExist && file_exists($storageDirectory))) {
- return $storageDirectory;
- } else {
- $this->_logMessage('Storage directory does not exist at ' . $storageDirectory, $returnMessages);
- }
- }
-
- return false;
- }
-
- /**
- * _detectConfigFile() - Detect config file location from a variety of possibilities
- *
- * @param $mustExist Should the returned value already exist in the file system
- * @param $returnMessages Should it log messages for output later
- * @return string
- */
- protected function _detectConfigFile($mustExist = true, $returnMessages = true)
- {
- $configFile = null;
-
- $configFile = getenv('ZF_CONFIG_FILE');
- if ($configFile) {
- $this->_logMessage('Config file found environment variable ZF_CONFIG_FILE at ' . $configFile, $returnMessages);
- if (!$mustExist || ($mustExist && file_exists($configFile))) {
- return $configFile;
- } else {
- $this->_logMessage('Config file does not exist at ' . $configFile, $returnMessages);
- }
- }
-
- $homeDirectory = ($this->_homeDirectory) ? $this->_homeDirectory : $this->_detectHomeDirectory(true, false);
- if ($homeDirectory) {
- $configFile = $homeDirectory . '/.zf.ini';
- $this->_logMessage('Config file assumed in home directory at location ' . $configFile, $returnMessages);
- if (!$mustExist || ($mustExist && file_exists($configFile))) {
- return $configFile;
- } else {
- $this->_logMessage('Config file does not exist at ' . $configFile, $returnMessages);
- }
- }
-
- $storageDirectory = ($this->_storageDirectory) ? $this->_storageDirectory : $this->_detectStorageDirectory(true, false);
- if ($storageDirectory) {
- $configFile = $storageDirectory . '/zf.ini';
- $this->_logMessage('Config file assumed in storage directory at location ' . $configFile, $returnMessages);
- if (!$mustExist || ($mustExist && file_exists($configFile))) {
- return $configFile;
- } else {
- $this->_logMessage('Config file does not exist at ' . $configFile, $returnMessages);
- }
- }
-
- return false;
- }
-
-
- /**
- * _setupPHPRuntime() - parse the config file if it exists for php ini values to set
- *
- * @return void
- */
- protected function _setupPHPRuntime()
- {
- // set php runtime settings
- ini_set('display_errors', true);
-
- // support the changing of the current working directory, necessary for some providers
- if (isset($_ENV['ZEND_TOOL_CURRENT_WORKING_DIRECTORY'])) {
- chdir($_ENV['ZEND_TOOL_CURRENT_WORKING_DIRECTORY']);
- }
-
- if (!$this->_configFile) {
- return;
- }
- $zfINISettings = parse_ini_file($this->_configFile);
- $phpINISettings = ini_get_all();
- foreach ($zfINISettings as $zfINIKey => $zfINIValue) {
- if (substr($zfINIKey, 0, 4) === 'php.') {
- $phpINIKey = substr($zfINIKey, 4);
- if (array_key_exists($phpINIKey, $phpINISettings)) {
- ini_set($phpINIKey, $zfINIValue);
- }
- }
- }
-
- return null;
- }
-
- /**
- * _setupToolRuntime() - setup the tools include_path and load the proper framwork parts that
- * enable Zend_Tool to work.
- *
- * @return void
- */
- protected function _setupToolRuntime()
- {
-
- $includePathPrepend = getenv('ZEND_TOOL_INCLUDE_PATH_PREPEND');
- $includePathFull = getenv('ZEND_TOOL_INCLUDE_PATH');
-
- // check if the user has not provided anything
- if (!($includePathPrepend || $includePathFull)) {
- if ($this->_tryClientLoad()) {
- return;
- }
- }
-
- // if ZF is not in the include_path, but relative to this file, put it in the include_path
- if ($includePathPrepend || $includePathFull) {
- if (isset($includePathPrepend) && ($includePathPrepend !== false)) {
- set_include_path($includePathPrepend . PATH_SEPARATOR . get_include_path());
- } elseif (isset($includePathFull) && ($includePathFull !== false)) {
- set_include_path($includePathFull);
- }
- }
-
- if ($this->_tryClientLoad()) {
- return;
- }
-
- $zfIncludePath['relativePath'] = dirname(__FILE__) . '/../library/';
- if (file_exists($zfIncludePath['relativePath'] . 'Zend/Tool/Framework/Client/Console.php')) {
- set_include_path(realpath($zfIncludePath['relativePath']) . PATH_SEPARATOR . get_include_path());
- }
-
- if (!$this->_tryClientLoad()) {
- $this->_mode = 'runError';
- return;
- }
-
- return null;
- }
-
- /**
- * _tryClientLoad() - Attempt to load the Zend_Tool_Framework_Client_Console to enable the tool to run.
- *
- * This method will return false if its not loaded to allow the consumer to alter the environment in such
- * a way that it can be called again to try loading the proper file/class.
- *
- * @return bool if the client is actuall loaded or not
- */
- protected function _tryClientLoad()
- {
- $this->_clientLoaded = false;
- $fh = @fopen('Zend/Tool/Framework/Client/Console.php', 'r', true);
- if (!$fh) {
- return $this->_clientLoaded; // false
- } else {
- fclose($fh);
- unset($fh);
- include 'Zend/Tool/Framework/Client/Console.php';
- $this->_clientLoaded = class_exists('Zend_Tool_Framework_Client_Console');
- }
-
- return $this->_clientLoaded;
- }
-
- /**
- * _runError() - Output the error screen that tells the user that the tool was not setup
- * in a sane way
- *
- * @return void
- */
- protected function _runError()
- {
-
- echo <<_messages) . PHP_EOL;
-
- echo PHP_EOL;
-
- echo 'To change the setup of this tool, run: "zf --setup"';
-
- echo PHP_EOL;
-
- }
-
- /**
- * _runSetup() - parse the request to see which setup command to run
- *
- * @return void
- */
- protected function _runSetup()
- {
- $setupCommand = (isset($_SERVER['argv'][2])) ? $_SERVER['argv'][2] : null;
-
- switch ($setupCommand) {
- case 'storage-directory':
- $this->_runSetupStorageDirectory();
- break;
- case 'config-file':
- $this->_runSetupConfigFile();
- break;
- default:
- $this->_runSetupMoreInfo();
- break;
- }
-
- return null;
- }
-
- /**
- * _runSetupStorageDirectory() - if the storage directory does not exist, create it
- *
- * @return void
- */
- protected function _runSetupStorageDirectory()
- {
- $storageDirectory = $this->_detectStorageDirectory(false, false);
-
- if (file_exists($storageDirectory)) {
- echo 'Directory already exists at ' . $storageDirectory . PHP_EOL
- . 'Cannot create storage directory.';
- return;
- }
-
- mkdir($storageDirectory);
-
- echo 'Storage directory created at ' . $storageDirectory . PHP_EOL;
- }
-
- /**
- * _runSetupConfigFile()
- *
- * @return void
- */
- protected function _runSetupConfigFile()
- {
- $configFile = $this->_detectConfigFile(false, false);
-
- if (file_exists($configFile)) {
- echo 'File already exists at ' . $configFile . PHP_EOL
- . 'Cannot write new config file.';
- return;
- }
-
- $includePath = get_include_path();
-
- $contents = 'php.include_path = "' . $includePath . '"';
-
- file_put_contents($configFile, $contents);
-
- $iniValues = ini_get_all();
- if ($iniValues['include_path']['global_value'] != $iniValues['include_path']['local_value']) {
- echo 'NOTE: the php include_path to be used with the tool has been written' . PHP_EOL
- . 'to the config file, using ZF_INCLUDE_PATH (or other include_path setters)' . PHP_EOL
- . 'is no longer necessary.' . PHP_EOL . PHP_EOL;
- }
-
- echo 'Config file written to ' . $configFile . PHP_EOL;
-
- return null;
- }
-
- /**
- * _runSetupMoreInfo() - return more information about what can be setup, and what is setup
- *
- * @return void
- */
- protected function _runSetupMoreInfo()
- {
- $homeDirectory = $this->_detectHomeDirectory(false, false);
- $storageDirectory = $this->_detectStorageDirectory(false, false);
- $configFile = $this->_detectConfigFile(false, false);
-
- echo <<_configFile) && $this->_configFile) {
- $configOptions['configOptions']['configFilepath'] = $this->_configFile;
- }
- if (isset($this->_storageDirectory) && $this->_storageDirectory) {
- $configOptions['storageOptions']['directory'] = $this->_storageDirectory;
- }
-
- // ensure that zf.php loads the Zend_Tool_Project features
- $configOptions['classesToLoad'] = 'Zend_Tool_Project_Provider_Manifest';
-
- $console = new Zend_Tool_Framework_Client_Console($configOptions);
- $console->dispatch();
- return null;
- }
-
- /**
- * _logMessage() - Internal method used to log setup and information messages.
- *
- * @param $message
- * @param $storeMessage
- * @return void
- */
- protected function _logMessage($message, $storeMessage = true)
- {
- if (!$storeMessage) {
- return;
- }
-
- $this->_messages[] = $message;
- }
-
-
-}
-
-if (!getenv('ZF_NO_MAIN')) {
- ZF::main();
-}
-
-
diff -Nru zendframework-1.10.4/bin/zf.sh zendframework-2.2.6/bin/zf.sh
--- zendframework-1.10.4/bin/zf.sh 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/bin/zf.sh 1970-01-01 00:00:00.000000000 +0000
@@ -1,45 +0,0 @@
-#!/bin/sh
-
-#############################################################################
-# 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.
-#
-# Zend
-# Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
-# http://framework.zend.com/license/new-bsd New BSD License
-#############################################################################
-
-
-# find php: pear first, command -v second, straight up php lastly
-if test "@php_bin@" != '@'php_bin'@'; then
- PHP_BIN="@php_bin@"
-elif command -v php 1>/dev/null 2>/dev/null; then
- PHP_BIN=`command -v php`
-else
- PHP_BIN=php
-fi
-
-# find zf.php: pear first, same directory 2nd,
-if test "@php_dir@" != '@'php_dir'@'; then
- PHP_DIR="@php_dir@"
-else
- SELF_LINK="$0"
- SELF_LINK_TMP="$(readlink "$SELF_LINK")"
- while test -n "$SELF_LINK_TMP"; do
- SELF_LINK="$SELF_LINK_TMP"
- SELF_LINK_TMP="$(readlink "$SELF_LINK")"
- done
- PHP_DIR="$(dirname "$SELF_LINK")"
-fi
-
-"$PHP_BIN" -d safe_mode=Off -f "$PHP_DIR/zf.php" -- "$@"
-
diff -Nru zendframework-1.10.4/CHANGELOG.md zendframework-2.2.6/CHANGELOG.md
--- zendframework-1.10.4/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/CHANGELOG.md 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,2383 @@
+# CHANGELOG
+
+## 2.2.6 (2014-03-06)
+
+- [4490: Nonvalid literal value for the boolean type, PDO](https://github.com/zendframework/zf2/pull/4490)
+- [4993: Zend\Db\TableGateway\Feature\FeatureSet::addFeature() at line 69](https://github.com/zendframework/zf2/issues/4993)
+- [5125: Method scanner fixed](https://github.com/zendframework/zf2/pull/5125)
+- [5174: SequenceFeature](https://github.com/zendframework/zf2/issues/5174)
+- [5186: Minor bugfix: Added missing composer dependency (ServiceManager) to Math package](https://github.com/zendframework/zf2/pull/5186)
+- [5221: - Create temporary table instead of create table temporary](https://github.com/zendframework/zf2/pull/5221)
+- [5314: Enable persistent connections for IbmDb2.](https://github.com/zendframework/zf2/pull/5314)
+- [5322: Fixing a bug that causes fatal error when a RowGateway's primary key wer...](https://github.com/zendframework/zf2/pull/5322)
+- [5375: Fixes default type == string](https://github.com/zendframework/zf2/pull/5375)
+- [5383: fix for #4614 breaks error handler using Zend\Log](https://github.com/zendframework/zf2/pull/5383)
+- [5385: Resolves #4708 - adding transparent background support to barcode](https://github.com/zendframework/zf2/pull/5385)
+- [5387: fixes #5062 - No longer throw Filename cannot be empty error](https://github.com/zendframework/zf2/pull/5387)
+- [5401: fixed typos](https://github.com/zendframework/zf2/pull/5401)
+- [5402: Update range of mobile](https://github.com/zendframework/zf2/pull/5402)
+- [5409: [rbac\ Typo](https://github.com/zendframework/zf2/pull/5409)
+- [5411: Update Czech validator messages ](https://github.com/zendframework/zf2/pull/5411)
+- [5412: Zend\Test needs Zend\Console as dependency](https://github.com/zendframework/zf2/pull/5412)
+- [5418: Added isset check for REMOTE_ADDR](https://github.com/zendframework/zf2/pull/5418)
+- [5421: fix typo & wording](https://github.com/zendframework/zf2/pull/5421)
+- [5422: Fix emails that contain lines that start with periods](https://github.com/zendframework/zf2/pull/5422)
+- [5423: Zend\Http\Header\SetCookie not compatible with older versions of pcre (and therefore CentOS)](https://github.com/zendframework/zf2/pull/5423)
+- [5424: Issue 3104: Form\Element "x-..." attributes](https://github.com/zendframework/zf2/pull/5424)
+- [5425: Issue 3249: FormFile does not allow "value" as an attribute](https://github.com/zendframework/zf2/pull/5425)
+- [5432: Problem with Forward Plugin](https://github.com/zendframework/zf2/pull/5432)
+- [5438: fix typo](https://github.com/zendframework/zf2/pull/5438)
+- [5444: fix indentation](https://github.com/zendframework/zf2/pull/5444)
+- [5445: Fixing issue with ModuleAutoloader on Windows](https://github.com/zendframework/zf2/pull/5445)
+- [5447: Di circular dependancies](https://github.com/zendframework/zf2/pull/5447)
+- [5451: Remove duplicate: zend-stdlib is already required](https://github.com/zendframework/zf2/pull/5451)
+- [5452: update master's resources/ja Zend_Validate.php message for 2.2](https://github.com/zendframework/zf2/pull/5452)
+- [5453: add resources/languages/ja/Zend_Captcha.php with Japanese translated](https://github.com/zendframework/zf2/pull/5453)
+- [5457: Zend\Db\Adapter\Driver\PdoResult::current patch](https://github.com/zendframework/zf2/pull/5457)
+- [5464: remove unused use](https://github.com/zendframework/zf2/pull/5464)
+- [5468: Add security disclosure info to README/CONTRIBUTING docs](https://github.com/zendframework/zf2/pull/5468)
+- [5471: Fix typehint for getServiceLocator().](https://github.com/zendframework/zf2/pull/5471)
+- [5472: remove unused use statements](https://github.com/zendframework/zf2/pull/5472)
+- [5476: Zend\Http\Header\SetCookie changed to support empty cookies](https://github.com/zendframework/zf2/pull/5476)
+- [5479: Add element input filters before form input filters](https://github.com/zendframework/zf2/pull/5479)
+- [5495: Hotfix/multiple nested collection test](https://github.com/zendframework/zf2/pull/5495)
+- [5497: fix for fprg](https://github.com/zendframework/zf2/pull/5497)
+- [5499: #5465 use strlen instead of empty](https://github.com/zendframework/zf2/pull/5499)
+- [5502: Update collection recursive extract and populating nested fieldsets](https://github.com/zendframework/zf2/pull/5502)
+- [5507: Fixed usage of imported namespace.](https://github.com/zendframework/zf2/pull/5507)
+- [5508: Specify correct return type for `Pdo\Connection::getLastGeneratedValue`](https://github.com/zendframework/zf2/pull/5508)
+- [5523: [Http\ Fixes](https://github.com/zendframework/zf2/pull/5523)
+- [5534: Added ability to set form option useInputFilterDefaults in factory via s...](https://github.com/zendframework/zf2/pull/5534)
+- [5546: Zend/Mvc/Router encoding issue (Fixes #5516)](https://github.com/zendframework/zf2/pull/5546)
+- [5551: Fix Zend\Form\Element\Number $inclusive is always true (Fix for #5549)](https://github.com/zendframework/zf2/pull/5551)
+- [5552: Add driver options to the Oci8 Db adapter](https://github.com/zendframework/zf2/pull/5552)
+- [5555: [Hotfix\ Validator\File classes behaviour with empty value](https://github.com/zendframework/zf2/pull/5555)
+- [5567: Fixes #4670](https://github.com/zendframework/zf2/pull/5567)
+- [5570: fix #5428 only read the stream contents once](https://github.com/zendframework/zf2/pull/5570)
+- [5575: Fix graphme_substr for PHP >= 5.4.18 or >=5.5.1](https://github.com/zendframework/zf2/pull/5575)
+- [5576: Enable Travis Fast finishing](https://github.com/zendframework/zf2/pull/5576)
+- [5577: Fix for #4707 pgsql getLastGeneratedValue() Problem](https://github.com/zendframework/zf2/pull/5577)
+- [5588: More lenient db detection in Logger abstract factory](https://github.com/zendframework/zf2/pull/5588)
+- [5597: Fix zend server cache](https://github.com/zendframework/zf2/pull/5597)
+- [5609: Allow RuntimeDefinition to still process explicit classes](https://github.com/zendframework/zf2/pull/5609)
+- [5613: Test rewrite for avoid test skip. Related #5592](https://github.com/zendframework/zf2/pull/5613)
+- [5614: Fixed issue with Math\Rand::getInteger() on ranges close to PHP_INT_MAX](https://github.com/zendframework/zf2/pull/5614)
+- [5623: Adding attributes to fieldsets. Legends are optional for fieldsets.](https://github.com/zendframework/zf2/pull/5623)
+- [5633: Giving a Warning namespaces to FlashMessager](https://github.com/zendframework/zf2/pull/5633)
+- [5636: Fix for the implementation of Collection Element](https://github.com/zendframework/zf2/pull/5636)
+- [5641: [Hotfix\ FilePostRedirectGet plugin and form collections](https://github.com/zendframework/zf2/pull/5641)
+- [5644: Addressing issue #5624. Implemented fix and added test case.](https://github.com/zendframework/zf2/pull/5644)
+- [5645: Update InArray.php](https://github.com/zendframework/zf2/pull/5645)
+- [5647: Adding Hungarian translations](https://github.com/zendframework/zf2/pull/5647)
+- [5659: Fix a fatal error when assert WWW-Authenticate header is sent - Hotfix/5658](https://github.com/zendframework/zf2/pull/5659)
+- [5669: Fix bug in InjectTemplateListenerTest](https://github.com/zendframework/zf2/pull/5669)
+- [5672: [cs\ cleanup master](https://github.com/zendframework/zf2/pull/5672)
+- [5677: SetCookie With expiry of over 2038 fail on 32bit systems](https://github.com/zendframework/zf2/pull/5677)
+- [5680: Update BlockCipher.php](https://github.com/zendframework/zf2/pull/5680)
+- [5691: Input Factory supports "break_on_failure" option](https://github.com/zendframework/zf2/pull/5691)
+- [5707: update userguide manual link](https://github.com/zendframework/zf2/pull/5707)
+- [5714: Change hardcoded event name by its constant.](https://github.com/zendframework/zf2/pull/5714)
+- [5718: added a submodule loading to testCanLoadMultipleModules](https://github.com/zendframework/zf2/pull/5718)
+- [5729: Fixed module loader to work with *.tar modules in IIS7.5 on Win 2008 R2](https://github.com/zendframework/zf2/pull/5729)
+- [5739: [BUGFIX\ DI fails with CompilerDefinition; solves #5738](https://github.com/zendframework/zf2/pull/5739)
+- [5746: Remove hydrator from collections](https://github.com/zendframework/zf2/pull/5746)
+- [5749: shortcircuit rendering if no messages](https://github.com/zendframework/zf2/pull/5749)
+- [5750: Change error message when no role found](https://github.com/zendframework/zf2/pull/5750)
+- [5752: Get an abstract defined service from an alias](https://github.com/zendframework/zf2/pull/5752)
+- [5754: Fixed gz decompress check for false](https://github.com/zendframework/zf2/pull/5754)
+- [5755: More explicit name for requested name](https://github.com/zendframework/zf2/pull/5755)
+- [5761: fixed typo](https://github.com/zendframework/zf2/pull/5761)
+- [5762: remove unneeded createService functions that actually do same with base class ( AbstractPluginManagerFactory )](https://github.com/zendframework/zf2/pull/5762)
+- [5768: FIX #5767 Zend\Db\Sql\Select: getRawState('order') is inconsistent](https://github.com/zendframework/zf2/pull/5768)
+- [5771: Fix escaped special chars in urlencoded parameters string incorrectly normalized](https://github.com/zendframework/zf2/pull/5771)
+- [5772: Zend\Config\Processor\Token converts boolean to string](https://github.com/zendframework/zf2/issues/5772)
+- [5773: Hotfix for #5772: token processor should not cast booleans to strings](https://github.com/zendframework/zf2/pull/5773)
+- [5775: Update Predicate.php](https://github.com/zendframework/zf2/pull/5775)
+- [5781: Support PHPUnit 3.8+ compatibility](https://github.com/zendframework/zf2/pull/5781)
+- [5782: remove unneeded key "name" under "input_filter" per-element in FormAbstractServiceFactoryTest](https://github.com/zendframework/zf2/pull/5782)
+- [5786: Correct references toPHPUnit_Runner_Version::VERSION](https://github.com/zendframework/zf2/pull/5786)
+- [5788: Zend\Filter\Compress\Bz2 and Gz should be fully PHP >= 5.4 compatible](https://github.com/zendframework/zf2/issues/5788)
+- [5796: \Zend\Form\Element\Email, with multiple=true leads to “Array to string conversion”](https://github.com/zendframework/zf2/issues/5796)
+- [5808: Fixes #5796](https://github.com/zendframework/zf2/pull/5808)
+- [5813: Fixed the classmap autoloader to work under Windows in Phar files.](https://github.com/zendframework/zf2/pull/5813)
+- [5814: Fix validate non required fields in CollectionInputFilter](https://github.com/zendframework/zf2/pull/5814)
+- [5815: Usage of a function in loops should be avoided](https://github.com/zendframework/zf2/pull/5815)
+- [5820: [Zend\InputFilter\InputFilter\ SetValidationGroup() VALIDATE_ALL not working recursively](https://github.com/zendframework/zf2/pull/5820)
+- [5824: Remove HTTP client restriction on cookies](https://github.com/zendframework/zf2/pull/5824)
+- [5830: Run Travis build also on PHP 5.6](https://github.com/zendframework/zf2/pull/5830)
+- [5831: Fixes #4926](https://github.com/zendframework/zf2/pull/5831)
+- [5833: Avoid function usage in loops](https://github.com/zendframework/zf2/pull/5833)
+- [5836: Fixes #3773](https://github.com/zendframework/zf2/pull/5836)
+- [5838: Fix Zend\Test for custom response usage](https://github.com/zendframework/zf2/pull/5838)
+- [5839: [Zend\Filter\Compress\ added PHP 5.4 support for strings in Bz2 and Gz decompress](https://github.com/zendframework/zf2/pull/5839)
+- [5846: Enabling the Request object to generate the correct scheme for SSL URI ](https://github.com/zendframework/zf2/pull/5846)
+- [5848: Test and quick fix #5847](https://github.com/zendframework/zf2/pull/5848)
+- [5861: Post/Redirect/Get should keep query parameters](https://github.com/zendframework/zf2/pull/5861)
+- [5868: Fixes #4993](https://github.com/zendframework/zf2/pull/5868)
+- [5870: SSL CA File support.](https://github.com/zendframework/zf2/pull/5870)
+- [5871: Add processor support to the Logger options.](https://github.com/zendframework/zf2/pull/5871)
+- [5874: Update NotEmpty validator to use bitmasking](https://github.com/zendframework/zf2/pull/5874)
+- [5879: Update NotEmptyTest tests to use data providers where possible](https://github.com/zendframework/zf2/pull/5879)
+- [5883: Fixes #5648](https://github.com/zendframework/zf2/pull/5883)
+- [5887: Fixed bug that didn't allow the connection to the SQLite database to be closed](https://github.com/zendframework/zf2/pull/5887)
+- [5890: Hotfix/5640 for bug in nested Zend\Form\Element\Collection::extract() recursion](https://github.com/zendframework/zf2/pull/5890)
+- [5891: Nicaraguan phone numbering plan](https://github.com/zendframework/zf2/pull/5891)
+- [5892: Case-insensitive country for the PhoneNumber validator class](https://github.com/zendframework/zf2/pull/5892)
+- [5893: Fix bug in json prettyprint](https://github.com/zendframework/zf2/pull/5893)
+- [5899: fix cs from #5613](https://github.com/zendframework/zf2/pull/5899)
+- [5900: Fix for #5894 - .il Domain checking](https://github.com/zendframework/zf2/pull/5900)
+- [5903: Re-added ConstraintKeyObject which is consumed from the AbstractSource w/ test (Fixes #3512)](https://github.com/zendframework/zf2/pull/5903)
+- [5912: clone problem in datetimeselect form element clone method](https://github.com/zendframework/zf2/issues/5912)
+- [5913: Hotfix for #5912: wrong datetime select form element cloning logic](https://github.com/zendframework/zf2/pull/5913)
+- [5916: Zend\Http: Unit tests for multi-line headers](https://github.com/zendframework/zf2/pull/5916)
+
+### SECURITY UPDATES
+
+- **ZF2014-01:** Potential XXE/XEE attacks using PHP functions:
+ `simplexml_load_*`, `DOMDocument::loadXML`, and `xml_parse`. A new component,
+ `ZendXml`, was introduced to mitigate XML eXternal Entity and XML Entity
+ Expansion vectors that are present in older versions of libxml2 and/or PHP.
+ `Zend\Json\Json::fromXml()` and `Zend\XmlRpc`'s `Response` and `Fault` classes
+ were potentially vulnerable to these attacks. If you use either of these
+ components, we recommend upgrading immediately.
+
+## 2.2.5 (2013-10-31)
+
+- [4604: Zend\Json\Server\Server::addFunction instantiates new class even an object was given as callable](https://github.com/zendframework/zf2/issues/4604)
+- [4874: Skip AnnotationScanner if class name information can't be found.](https://github.com/zendframework/zf2/pull/4874)
+- [4918: [suggest\ Ignore methods without parameters from aware interfaces](https://github.com/zendframework/zf2/pull/4918)
+- [5013: ZF2-2454 HTTP 308 Resume Incomplete missing in Zend\Http\Response](https://github.com/zendframework/zf2/pull/5013)
+- [5031: Fix input annotation handler in Zend/Form/Annotation/ElementAnnotationsListener](https://github.com/zendframework/zf2/pull/5031)
+- [5035: updated Zend_Validate_Hostname translation message IDs and translations](https://github.com/zendframework/zf2/pull/5035)
+- [5037: Slovenian translations updated](https://github.com/zendframework/zf2/pull/5037)
+- [5040: Correct namespace name DockBlock to DocBlock](https://github.com/zendframework/zf2/pull/5040)
+- [5044: Reflection ThrowsTag to handle types correctly](https://github.com/zendframework/zf2/pull/5044)
+- [5050: #4996 broke File filters management](https://github.com/zendframework/zf2/pull/5050)
+- [5053: add test case for Zend\Validator\IsInstanceOf to pass Traversable to constructor](https://github.com/zendframework/zf2/pull/5053)
+- [5054: is bin/pluginmap_generator.php broken ?](https://github.com/zendframework/zf2/pull/5054)
+- [5065: [Zend\Http\Client\ dupplicate header keys in prepareHeaders](https://github.com/zendframework/zf2/pull/5065)
+- [5066: __invoke parameter should be null by default](https://github.com/zendframework/zf2/pull/5066)
+- [5068: using injected response object](https://github.com/zendframework/zf2/pull/5068)
+- [5071: Increase readability, fix indentation](https://github.com/zendframework/zf2/pull/5071)
+- [5078: hotfix/4508 and make Zend\Http\Header\SetCookie RFC conform](https://github.com/zendframework/zf2/pull/5078)
+- [5083: [Barcode\ removed some unused variables](https://github.com/zendframework/zf2/pull/5083)
+- [5093: Extract and populate values for nested fieldsets in Collection elements](https://github.com/zendframework/zf2/pull/5093)
+- [5100: [ServiceManager\ Implemented circular alias reference detection](https://github.com/zendframework/zf2/pull/5100)
+- [5111: Fix test suite when ext/intl isn't available](https://github.com/zendframework/zf2/pull/5111)
+- [5121: Add inline comments](https://github.com/zendframework/zf2/pull/5121)
+- [5140: Fix not allowed encoding of content-transfer-encoding and content-type headers in single part encoded mails](https://github.com/zendframework/zf2/pull/5140)
+- [5146: Adds an alias for ModuleManager and removes the duplicate service defini...](https://github.com/zendframework/zf2/pull/5146)
+- [5150: Fix Validator\PhoneNumber with E.123/E.164 international numbers.](https://github.com/zendframework/zf2/pull/5150)
+- [5152: Issue #4669 - Class generator should return uses from file generator](https://github.com/zendframework/zf2/pull/5152)
+- [5161: Fix calling View\Helper\BasePath from CLI results in fatal error.](https://github.com/zendframework/zf2/pull/5161)
+- [5175: fix delegators to allow usage in plugin managers](https://github.com/zendframework/zf2/pull/5175)
+- [5180: Ensure DiAbstractServiceFactory takes lowest possible priority](https://github.com/zendframework/zf2/pull/5180)
+- [5183: Fix for CamelCase filter when string contains multiple uppercase letters and Unicode is off](https://github.com/zendframework/zf2/pull/5183)
+- [5193: Fix returned NamespaceType for Parameters from Reflection](https://github.com/zendframework/zf2/pull/5193)
+- [5196: Fix JsonRpc service name](https://github.com/zendframework/zf2/pull/5196)
+- [5212: assertQueryContentContains searching through all nodes found](https://github.com/zendframework/zf2/pull/5212)
+- [5216: added missing I18n\Validator\DateTime translations](https://github.com/zendframework/zf2/pull/5216)
+- [5220: Bug fix for Zend\Form\Element\Collection::extract()](https://github.com/zendframework/zf2/pull/5220)
+- [5223: Cannot use Zend\Stdlib\ResponseInterface as Response because the name is already in use in Zend\Stdlib\DispatchableInterface](https://github.com/zendframework/zf2/issues/5223)
+- [5234: added zendframework/zend-session as suggest dependency at Zend\ProgressBar](https://github.com/zendframework/zf2/pull/5234)
+- [5239: added zendframework/zend-cache as suggest dependency at Zend\Paginator](https://github.com/zendframework/zf2/pull/5239)
+- [5240: fix Debug::getEscaper() never called at Debug::dump() when xdebug is loaded](https://github.com/zendframework/zf2/pull/5240)
+- [5246: move zendframework/zend-escaper from require to suggest dependency at Zend\Debug](https://github.com/zendframework/zf2/pull/5246)
+- [5250: explode should be made only by colon (:) and not colon+space (: )](https://github.com/zendframework/zf2/pull/5250)
+- [5252: Improvements Zend\Form\View\Helper\FormElement](https://github.com/zendframework/zf2/pull/5252)
+- [5254: Zend\Log\Writer\Db via config throws exception](https://github.com/zendframework/zf2/pull/5254)
+- [5259: Modified PhpArray config writer to generate better readable array format.](https://github.com/zendframework/zf2/pull/5259)
+- [5271: fixes #5270](https://github.com/zendframework/zf2/pull/5271)
+- [5274: add regression testing for fieldset input filter](https://github.com/zendframework/zf2/pull/5274)
+- [5279: Polish translation for Zend\Captcha](https://github.com/zendframework/zf2/pull/5279)
+- [5280: Polish translation and fixes in Zend\Validate](https://github.com/zendframework/zf2/pull/5280)
+- [5286: Hotfix/5118](https://github.com/zendframework/zf2/pull/5286)
+- [5287: Add Not Like Predicate](https://github.com/zendframework/zf2/pull/5287)
+- [5291: [mail\ Fixes, criteria unification and optimization.](https://github.com/zendframework/zf2/pull/5291)
+- [5293: Fix #5289 (abstract factories return type)](https://github.com/zendframework/zf2/pull/5293)
+- [5295: Update DateFormat.php to fix deprecated method call: PHP >= 5.5.0.](https://github.com/zendframework/zf2/pull/5295)
+- [5301: [http\ Adapt header field name validation to RFC definition](https://github.com/zendframework/zf2/pull/5301)
+- [5302: [http\ Parse headerline](https://github.com/zendframework/zf2/pull/5302)
+- [5311: [http\ Unify criteria for split name](https://github.com/zendframework/zf2/pull/5311)
+- [5317: IbmDb2 Commitment Control](https://github.com/zendframework/zf2/pull/5317)
+- [5318: [#5013\ Remove custom code response tests](https://github.com/zendframework/zf2/pull/5318)
+- [5319: Class not found instead of exception in RedisOptions](https://github.com/zendframework/zf2/pull/5319)
+- [5325: fixed typo](https://github.com/zendframework/zf2/pull/5325)
+- [5333: Zend\ServiceManager - CS fixes for master](https://github.com/zendframework/zf2/pull/5333)
+- [5336: fix typo](https://github.com/zendframework/zf2/pull/5336)
+- [5343: Remove date filtering on date elements](https://github.com/zendframework/zf2/pull/5343)
+- [5350: fixed typos](https://github.com/zendframework/zf2/pull/5350)
+- [5351: fixes #5310](https://github.com/zendframework/zf2/pull/5351)
+- [5360: fixed typo](https://github.com/zendframework/zf2/pull/5360)
+- [5368: Avoid SOAP constant error in PHPUnit](https://github.com/zendframework/zf2/pull/5368)
+- [5369: Php unit windows](https://github.com/zendframework/zf2/pull/5369)
+- [5370: fixed typos](https://github.com/zendframework/zf2/pull/5370)
+- [5374: Potential security vulnerability ](https://github.com/zendframework/zf2/issues/5374)
+- [5378: Exception as one of the possible exception for Soap\Server::registerFaultException](https://github.com/zendframework/zf2/pull/5378)
+- [5379: fixes #4604](https://github.com/zendframework/zf2/pull/5379)
+- [5382: #4954 Mongodb small changes](https://github.com/zendframework/zf2/pull/5382)
+
+### SECURITY UPDATES
+
+An issue with `Zend\Http\PhpEnvironment\RemoteAddress` was reported in
+[#5374](https://github.com/zendframework/zf2/pull/5374). Essentially, the class
+was not checking if `$_SERVER['REMOTE_ADDR']` was one of the trusted proxies
+configured, and as a result, `getIpAddressFromProxy()` could return an untrusted
+IP address.
+
+The class was updated to check if `$_SERVER['REMOTE_ADDR']` is in the list of
+trusted proxies, and, if so, will return that value immediately before
+consulting the values in the `X-Forwarded-For` header.
+
+If you use the `RemoteAddr` `Zend\Session` validator, and are configuring
+trusted proxies, we recommend updating to 2.2.5 or later immediately.
+
+### Potential Breakage
+
+- [#5343](https://github.com/zendframework/zf2/pull/5343) removed the
+ DateTimeFormatter filter from DateTime form elements. This was done
+ due to the fact that it led to unexpected behavior when non-date inputs were
+ provided. However, since the DateTime element already incorporates a
+ DateValidator that accepts a date format, validation can still work as
+ expected.
+
+## 2.2.4 (2013-08-26)
+
+- [5008: deprecated feature in classmap generator](https://github.com/zendframework/zf2/issues/5008)
+- [5015: Allow set Form::setPreferFormInputFilter via options](https://github.com/zendframework/zf2/issues/5015)
+- [5028: Fix forms regression introduced in 2.2.3](https://github.com/zendframework/zf2/issues/5028)
+
+## 2.2.3 (2013-08-21):
+
+- [4851: allow usage of validator and filter plugin managers in input filter factory if form manager injected](https://github.com/zendframework/zf2/issues/4851)
+- [4868: Tests for issue with unexpected injection.](https://github.com/zendframework/zf2/issues/4868)
+- [4877: Validator\File tests throwing errors in custom PHP 5.3.10 distributions](https://github.com/zendframework/zf2/issues/4877)
+- [4878: Form element title attribute test](https://github.com/zendframework/zf2/issues/4878)
+- [4881: Update Validator translations](https://github.com/zendframework/zf2/issues/4881)
+- [4883: Update Zend_Validate.php](https://github.com/zendframework/zf2/issues/4883)
+- [4893: Resolves warning raised when version is not matched.](https://github.com/zendframework/zf2/issues/4893)
+- [4895: Small fix for ZendTest\Form\FormTest method name](https://github.com/zendframework/zf2/issues/4895)
+- [4897: Support file stream](https://github.com/zendframework/zf2/issues/4897)
+- [4905: Update Statement.php](https://github.com/zendframework/zf2/issues/4905)
+- [4909: renamed test class according to psr-0](https://github.com/zendframework/zf2/issues/4909)
+- [4915: Dependency suggest for MVC plugins](https://github.com/zendframework/zf2/issues/4915)
+- [4919: Notices being triggered when hydrating classes with no properties with the reflection hydrator](https://github.com/zendframework/zf2/issues/4919)
+- [4920: Redundant conditional](https://github.com/zendframework/zf2/issues/4920)
+- [4922: remove unused $typeFormats property at Zend/Code/Generator/DocBlock/Tag.php](https://github.com/zendframework/zf2/issues/4922)
+- [4925: HttpClient: adapter always reachable through getter if specified on contructor](https://github.com/zendframework/zf2/issues/4925)
+- [4929: Add Zend\Uri as a suggest because it is required by the Uri & Sitemap\Loc validator](https://github.com/zendframework/zf2/issues/4929)
+- [4934: Mime\Message: createFromString: decode transfer encoding](https://github.com/zendframework/zf2/issues/4934)
+- [4957: Undefined variable: class in Zend/ModuleManager/Listener/ServiceListener.php](https://github.com/zendframework/zf2/issues/4957)
+- [4966: Fix issue #4952](https://github.com/zendframework/zf2/issues/4966)
+- [4976: Applied trim and strtolower to Gravatar email per Gravatar docs: https://en.gravatar.com/site/implement/hash/](https://github.com/zendframework/zf2/issues/4976)
+- [4978: added missing docblock for "@link", "@copyright", and "@license" and fix wrong namespace according PSR-0](https://github.com/zendframework/zf2/issues/4978)
+- [4981: Revise docblocks in Zend\Session\ContainerAbstractServiceFactory](https://github.com/zendframework/zf2/issues/4981)
+- [4988: [Zend-Code\ Fix Code Generation for non namespace classes](https://github.com/zendframework/zf2/issues/4988)
+- [4990: [Zend-Code\ Make sure that a use is only added once in ClassGenerator](https://github.com/zendframework/zf2/issues/4990)
+- [4996: BaseInputFilter->add deasn't work (Form Validation breaks since 2.2)](https://github.com/zendframework/zf2/issues/4996)
+
+## 2.2.2 (2013-07-24):
+
+- [4105: Method "headLink" does not exist](https://github.com/zendframework/zf2/issues/4105)
+- [4555: Zend\Http\Response::getBody() tries to decode gzip that has already been decoded by cURL](https://github.com/zendframework/zf2/issues/4555)
+- [4564: [Navigation\ Allow non-string permissions](https://github.com/zendframework/zf2/issues/4564)
+- [4567: [InputFilter\[Hotfix\ Missing check for allowEmpty()](https://github.com/zendframework/zf2/issues/4567)
+- [4612: Templatemap generator: keys of templatemap not correct?](https://github.com/zendframework/zf2/issues/4612)
+- [4631: remove redundance @copyright and @license docblock because of already written](https://github.com/zendframework/zf2/issues/4631)
+- [4640: Split multiple implements into multiple lines](https://github.com/zendframework/zf2/issues/4640)
+- [4643: Add use statements](https://github.com/zendframework/zf2/issues/4643)
+- [4644: Make ValidatorPluginManager aware of PhoneNumber validator](https://github.com/zendframework/zf2/issues/4644)
+- [4646: Docblock subject misspelling](https://github.com/zendframework/zf2/issues/4646)
+- [4649: [code\ Implement logic for include a file in FileReflection if this exists and is not already included](https://github.com/zendframework/zf2/issues/4649)
+- [4650: Some doc block fixes](https://github.com/zendframework/zf2/issues/4650)
+- [4652: router defaults not being set properly in console](https://github.com/zendframework/zf2/issues/4652)
+- [4654: Make AbstractRestController rest methods non-abstract #4209](https://github.com/zendframework/zf2/issues/4654)
+- [4665: Make ValidatorPluginManager aware of DateTime validator](https://github.com/zendframework/zf2/issues/4665)
+- [4676: Fix file post redirect get redirection with ModuleRouteListener](https://github.com/zendframework/zf2/issues/4676)
+- [4688: Add @todo docblock](https://github.com/zendframework/zf2/issues/4688)
+- [4690: Zend\Mail\Protocol\Smtp does not reset protected $auth after disconnect](https://github.com/zendframework/zf2/issues/4690)
+- [4692: added zendframework/zend-resources to the global composer.json](https://github.com/zendframework/zf2/issues/4692)
+- [4696: [WIP\ Enforcing composer version in travis builds](https://github.com/zendframework/zf2/issues/4696)
+- [4699: Add use statements](https://github.com/zendframework/zf2/issues/4699)
+- [4700: PHP 5.5 can't fail anymore](https://github.com/zendframework/zf2/issues/4700)
+- [4702: DocBlock and CS fixes](https://github.com/zendframework/zf2/issues/4702)
+- [4705: add zendframework/zend-json to Zend\ProgressBar\composer.json as suggest](https://github.com/zendframework/zf2/issues/4705)
+- [4722: remove bloated LICENSE description at header for consistency ](https://github.com/zendframework/zf2/issues/4722)
+- [4725: Add sorting to classmap generator](https://github.com/zendframework/zf2/issues/4725)
+- [4729: Provide ability to configure ReCaptcha Service public and private keys via options](https://github.com/zendframework/zf2/issues/4729)
+- [4734: Fix for #4727](https://github.com/zendframework/zf2/issues/4734)
+- [4738: remove unnecessary space after function name](https://github.com/zendframework/zf2/issues/4738)
+- [4741: Hotfix/4740](https://github.com/zendframework/zf2/issues/4741)
+- [4743: Update PluginManager.php](https://github.com/zendframework/zf2/issues/4743)
+- [4744: Remove ZendTest from Composer](https://github.com/zendframework/zf2/issues/4744)
+- [4746: Bumping supported ProxyManager version](https://github.com/zendframework/zf2/issues/4746)
+- [4754: Update SimpleStreamResponseSenderTest.php](https://github.com/zendframework/zf2/issues/4754)
+- [4759: Added pluginmap_generator + templatemap_generator to BIN directory](https://github.com/zendframework/zf2/issues/4759)
+- [4761: Remove exceptions from #4734](https://github.com/zendframework/zf2/issues/4761)
+- [4762: [Hotfix\ Fix conflicting use statement](https://github.com/zendframework/zf2/issues/4762)
+- [4771: Form\View\Helper\FormRow label position gets overwritten by __invoke()](https://github.com/zendframework/zf2/issues/4771)
+- [4776: Zend\Http\Header\SetCookie Allow unsetting cookie attibutes by resetting to null](https://github.com/zendframework/zf2/issues/4776)
+- [4777: Change file mode from 644 to 755 templatemap_generator.php](https://github.com/zendframework/zf2/issues/4777)
+- [4778: Zend\Validator depends on Zend\Filter](https://github.com/zendframework/zf2/issues/4778)
+- [4783: Make methods setUp and tearDown protected](https://github.com/zendframework/zf2/issues/4783)
+- [4787: Update Zend_Validate.php](https://github.com/zendframework/zf2/issues/4787)
+- [4788: set factory in CollectionInputFilter](https://github.com/zendframework/zf2/issues/4788)
+- [4790: Add check to DI to see if we have a class to instantiate](https://github.com/zendframework/zf2/issues/4790)
+- [4793: [validator\ Validate quoted local part of email addresses](https://github.com/zendframework/zf2/issues/4793)
+- [4798: Default mode variables HeadScript and InlineScript](https://github.com/zendframework/zf2/issues/4798)
+- [4804: Possible Typo in Zend / Cache / Storage / Adapter / RedisResourceManager](https://github.com/zendframework/zf2/issues/4804)
+- [4805: Zend\I18n\View\Helper\CurrencyFormat | showDecimals parameter overrides the default value](https://github.com/zendframework/zf2/issues/4805)
+- [4808: Unimplemented REST methods should set a 405 status](https://github.com/zendframework/zf2/issues/4808)
+- [4818: Issue4817](https://github.com/zendframework/zf2/issues/4818)
+- [4830: Correct spelling of function getMajorVersion](https://github.com/zendframework/zf2/issues/4830)
+- [4835: Update templatemap_generator.php](https://github.com/zendframework/zf2/issues/4835)
+- [4838: Little fix in InputFilter/Factory](https://github.com/zendframework/zf2/issues/4838)
+- [4847: Fix Version::getLatest docblock](https://github.com/zendframework/zf2/issues/4847)
+- [4850: Allow form elements created via Annotations to have same default InputFilter as created via array specification](https://github.com/zendframework/zf2/issues/4850)
+- [4854: Allow FormElementErrors view helper to translate messages](https://github.com/zendframework/zf2/issues/4854)
+- [4856: Zend\Validator\File\MimeType warning with no params](https://github.com/zendframework/zf2/issues/4856)
+- [4857: `fault` property must be an instance of \Zend\XmlRpc\Fault](https://github.com/zendframework/zf2/issues/4857)
+- [4858: Removed @category, @package and @subpackage docblock tags in ZendTest\Config](https://github.com/zendframework/zf2/issues/4858)
+- [4859: doc block changes in head view helpers](https://github.com/zendframework/zf2/issues/4859)
+- [4866: update tests/ZendTest/Mvc/ApplicationTest.php](https://github.com/zendframework/zf2/issues/4866)
+- [4870: Use MvcTranslator to inject view helpers](https://github.com/zendframework/zf2/issues/4870)
+
+## 2.2.1 (2013-06-12):
+
+- [3647: Problems in the way Zend\Paginator\Adapter\DbSelect count()s](https://github.com/zendframework/zf2/issues/3647)
+- [3853: Log formatters shouldn't override referenced values](https://github.com/zendframework/zf2/issues/3853)
+- [4421: fix docblocks : `Zend_` should be `Zend\\` and some typos](https://github.com/zendframework/zf2/issues/4421)
+- [4452: Zend\Authentication\Result custom result codes not possible](https://github.com/zendframework/zf2/issues/4452)
+- [4456: can't override Zend\Log\Logger::registerExceptionHandler](https://github.com/zendframework/zf2/issues/4456)
+- [4457: Zend\Code\Scanner\ClassScanner don't parse constants with docblock](https://github.com/zendframework/zf2/issues/4457)
+- [4458: Fix for PHP 5.5 unit tests (and XDebug >= 2.2.0)](https://github.com/zendframework/zf2/issues/4458)
+- [4465: Add ConstantScanner to Zend\Code\Scanner](https://github.com/zendframework/zf2/issues/4465)
+- [4470: sync ZF1 svn r24807 - ZF-12128: File Upload validator should display file na...](https://github.com/zendframework/zf2/issues/4470)
+- [4474: Suggest some dependencies in Zend\Mvc](https://github.com/zendframework/zf2/issues/4474)
+- [4480: fixed Cache\StorageFactory::factory()](https://github.com/zendframework/zf2/issues/4480)
+- [4494: Add build.xml to .gitattributes/export-ignore](https://github.com/zendframework/zf2/issues/4494)
+- [4496: Class methods hydrator skips getters with optional parameters](https://github.com/zendframework/zf2/issues/4496)
+- [4497: Fix name of LoggerAbstractServiceFactory test](https://github.com/zendframework/zf2/issues/4497)
+- [4498: Update the method level comment to reflect change in signature](https://github.com/zendframework/zf2/issues/4498)
+- [4499: Add service definition for DateTimeFormatter (related to #3632)](https://github.com/zendframework/zf2/issues/4499)
+- [4503: Zend\Session\Storage\AbstractSessionArrayStorage::fromArray() can receive a string causing a fatal error on shutdown](https://github.com/zendframework/zf2/issues/4503)
+- [4509: `DateTimeFormatter` Format DateTime values correctly](https://github.com/zendframework/zf2/issues/4509)
+- [4516: CollectionInputFilter should respect the keys of collectionData](https://github.com/zendframework/zf2/issues/4516)
+- [4518: Update PhpDoc comment](https://github.com/zendframework/zf2/issues/4518)
+- [4522: Remove unknown invokables from FilterPluginManager](https://github.com/zendframework/zf2/issues/4522)
+- [4524: Add zend-json as a required dependency](https://github.com/zendframework/zf2/issues/4524)
+- [4526: Fill SharedEventManager events with identifiers](https://github.com/zendframework/zf2/issues/4526)
+- [4528: Fix priority not handled in AggregateHydrator](https://github.com/zendframework/zf2/issues/4528)
+- [4529: Allow Zend\Form\Element\Checkbox to return real value instead of always a boolean](https://github.com/zendframework/zf2/issues/4529)
+- [4530: Fix for unmatched routes in navigation](https://github.com/zendframework/zf2/issues/4530)
+- [4535: Update RoleInterface.php](https://github.com/zendframework/zf2/issues/4535)
+- [4538: Zend\Crypt\Password\Bcrypt does not report inability to generate hash](https://github.com/zendframework/zf2/issues/4538)
+- [4539: Update StrategyInterface.php](https://github.com/zendframework/zf2/issues/4539)
+- [4542: Adds ability to specify a template for exceptions retrieved from Exception::getPrevious](https://github.com/zendframework/zf2/issues/4542)
+- [4543: soapVersion key is not reachable](https://github.com/zendframework/zf2/issues/4543)
+- [4546: View: correctly validate input in PartialLoop](https://github.com/zendframework/zf2/issues/4546)
+- [4552: Wincache unexpected return value on internalGetItem](https://github.com/zendframework/zf2/issues/4552)
+- [4553: Remove private variables from AbstractControllerTestCase.](https://github.com/zendframework/zf2/issues/4553)
+- [4561: Fix the controller plugin PostRedirectGet wrong redirection (in MVC)](https://github.com/zendframework/zf2/issues/4561)
+- [4562: Validator Messages Tests](https://github.com/zendframework/zf2/issues/4562)
+- [4566: Fix generating array with unsorted keys](https://github.com/zendframework/zf2/issues/4566)
+- [4568: Cast Parameters](https://github.com/zendframework/zf2/issues/4568)
+- [4571: INI reader breaks when mbstring function overloading is in place](https://github.com/zendframework/zf2/issues/4571)
+- [4572: Zend\Form Should throw exception if try to get() an element that does not exist](https://github.com/zendframework/zf2/issues/4572)
+- [4576: Redis Cache Adapter Config - setLibOptions is broken](https://github.com/zendframework/zf2/issues/4576)
+- [4577: Fix issue with Redis Cache adapter whereby setOption was being called before connecting to Redis server](https://github.com/zendframework/zf2/issues/4577)
+- [4581: Hostname route ignore `HTTP_HOST` and give `SERVER_NAME` precedence](https://github.com/zendframework/zf2/issues/4581)
+- [4582: Fix Nested form element wrapping (relative: #4383)](https://github.com/zendframework/zf2/issues/4582)
+- [4588: set 0 as header value (issue #4583)](https://github.com/zendframework/zf2/issues/4588)
+- [4590: Zend paginator dbselect count](https://github.com/zendframework/zf2/issues/4590)
+- [4595: Missing invokable fo Redis Cache Storage, problem with setting password](https://github.com/zendframework/zf2/issues/4595)
+- [4596: Missing french translations, and wrong class name](https://github.com/zendframework/zf2/issues/4596)
+- [4597: Zend\Validate\Hostname doesn't handle IDN for .UA](https://github.com/zendframework/zf2/issues/4597)
+- [4599: `InputFilter` Input merge should copy over the `continue_if_empty` flag](https://github.com/zendframework/zf2/issues/4599)
+- [4602: Remove needless check](https://github.com/zendframework/zf2/issues/4602)
+- [4603: Redis Storage won't behave correctly after libOptions were set](https://github.com/zendframework/zf2/issues/4603)
+- [4605: Possibility to use camelCase for all soap client options](https://github.com/zendframework/zf2/issues/4605)
+- [4608: Allow the `gc_probability` option to be set to zero.](https://github.com/zendframework/zf2/issues/4608)
+- [4609: Logger: Error/Exception Handler: fixed 3853 & 4456](https://github.com/zendframework/zf2/issues/4609)
+- [4615: Fix #4579 `day_attributes` could not be passed in construct](https://github.com/zendframework/zf2/issues/4615)
+- [4616: fixed 4614: infinite loop in Zend\Log\Formatter::normalize](https://github.com/zendframework/zf2/issues/4616)
+- [4617: Zend\Code: Docblock generates empty line under @tags if docblock was read from existing code](https://github.com/zendframework/zf2/issues/4617)
+- [4618: Missed method findRealpathInIncludePath() in Zend\Code\Reflection\FileReflection](https://github.com/zendframework/zf2/issues/4618)
+- [4621: Update 'Missing captcha fields' translation](https://github.com/zendframework/zf2/issues/4621)
+- [4622: Ensure router factory is used by SM factory](https://github.com/zendframework/zf2/issues/4622)
+- [4624: Notification thrown in Zend\Mvc\Service\ViewHelperManagerFactory](https://github.com/zendframework/zf2/issues/4624)
+- [4628: Fix misstake detect is active Page\Mvc in IndexController](https://github.com/zendframework/zf2/issues/4628)
+- [4629: Zend\Cache\Pattern\CallbackCache doesn't work with NULL](https://github.com/zendframework/zf2/issues/4629)
+- [4630: Allow selecting the TranslatorAwareTreeRouteStack via configuration](https://github.com/zendframework/zf2/issues/4630)
+- [4632: fixed #4552: Wincache::getItem() have to return NULL in cases of missing items](https://github.com/zendframework/zf2/issues/4632)
+- [4633: removed checks of not existing class Zend\Math\BigInteger](https://github.com/zendframework/zf2/issues/4633)
+- [4634: Navigation\Page\Mvc Can't return false whithout call parent::isActive](https://github.com/zendframework/zf2/issues/4634)
+- [4636: Punycode decoding fails if encoded string has not hyphen](https://github.com/zendframework/zf2/issues/4636)
+- [4641: Zend\Paginator\Adapter\DbSelect alternative solution to count, with subselect](https://github.com/zendframework/zf2/issues/4641)
+
+## 2.2.0 (2013-05-15):
+
+- [2865: (Enhancement) Add an easier way to use i18n view helpers.](https://github.com/zendframework/zf2/issues/2865)
+- [2903: add AdapterManager in to Zend\Db\Adapter namespace](https://github.com/zendframework/zf2/issues/2903)
+- [2984: Add full stop at end of validator messages (fixes #2966)](https://github.com/zendframework/zf2/issues/2984)
+- [3490: Added support for callable credential validator](https://github.com/zendframework/zf2/issues/3490)
+- [3580: Feature/context aware hydrator strategies](https://github.com/zendframework/zf2/issues/3580)
+- [3632: New DateTimeFormatter Filter (#3617)](https://github.com/zendframework/zf2/issues/3632)
+- [3646: Zend\I18n\View\Helper\NumberFormat param to set the number of decimals](https://github.com/zendframework/zf2/issues/3646)
+- [3693: Add RBAC support for navigation helper.](https://github.com/zendframework/zf2/issues/3693)
+- [3709: Redis cache storage](https://github.com/zendframework/zf2/issues/3709)
+- [3710: Allow to remove delimiters for DateSelect and fix bugs with some locales](https://github.com/zendframework/zf2/issues/3710)
+- [3747: Add getFilename() to Zend\Cache\Pattern\CaptureCache](https://github.com/zendframework/zf2/issues/3747)
+- [3754: Update library/Zend/Stdlib/Hydrator/ClassMethods.php](https://github.com/zendframework/zf2/issues/3754)
+- [3792: Sets specific attributes (as class,title...) to "Zend\Form\Select" options](https://github.com/zendframework/zf2/issues/3792)
+- [3812: Zend\Form\FormInterface causes Di to attempt to instantiate Interface](https://github.com/zendframework/zf2/issues/3812)
+- [3814: Improve module manager to accept instance](https://github.com/zendframework/zf2/issues/3814)
+- [3818: Invalid instantiator of type “NULL” for “Zend\Form\FormInterface”](https://github.com/zendframework/zf2/issues/3818)
+- [3844: Added new option to fix a little issue originated from last PR](https://github.com/zendframework/zf2/issues/3844)
+- [3876: Implementing and re-utilizing an abstract aggregate listener](https://github.com/zendframework/zf2/issues/3876)
+- [3877: HeadTitle renderTitle returns rendered title without title tags](https://github.com/zendframework/zf2/issues/3877)
+- [3878: Created an adapter Zend Paginator instance using TableGateway](https://github.com/zendframework/zf2/issues/3878)
+- [3879: Feature CollectionInputFilter](https://github.com/zendframework/zf2/issues/3879)
+- [3896: Added ability to ignore namespaces to classmap generator](https://github.com/zendframework/zf2/issues/3896)
+- [3919: WSDL Generation rewrite (with new tests also) as a base for future changes.](https://github.com/zendframework/zf2/issues/3919)
+- [3922: Added the ability to disable the getValidator input specification on Select Elements](https://github.com/zendframework/zf2/issues/3922)
+- [3930: Added abstract service factory for logger component to provide several loggers for application.](https://github.com/zendframework/zf2/issues/3930)
+- [3931: Added ability to configure MvcEvent listeners.](https://github.com/zendframework/zf2/issues/3931)
+- [3933: Added database adapter abstract service factory.](https://github.com/zendframework/zf2/issues/3933)
+- [3942: Feature/zend test load module](https://github.com/zendframework/zf2/issues/3942)
+- [3944: Enable ExceptionStrategy to return json](https://github.com/zendframework/zf2/issues/3944)
+- [3949: Invalid argument supplied for foreach()](https://github.com/zendframework/zf2/issues/3949)
+- [3951: Deprecate Zend\Stdlib\DateTime and use \DateTime constructor internally instead](https://github.com/zendframework/zf2/issues/3951)
+- [3958: Oci8 Driver generating "Fetch out of sequence warning"](https://github.com/zendframework/zf2/issues/3958)
+- [3965: Add removeMethod method in ClassGenerator](https://github.com/zendframework/zf2/issues/3965)
+- [3979: Fixes #3978](https://github.com/zendframework/zf2/issues/3979)
+- [3990: Zend\Filter\File\RenameUpload - Added possibility to maintain original file extension](https://github.com/zendframework/zf2/issues/3990)
+- [3999: Chain route](https://github.com/zendframework/zf2/issues/3999)
+- [4011: extend HeadMeta view helper to allow microdata #3751](https://github.com/zendframework/zf2/issues/4011)
+- [4016: Hydrator aware interface](https://github.com/zendframework/zf2/issues/4016)
+- [4032: Class was supporting limit + offset or limit, but only offset does not support](https://github.com/zendframework/zf2/issues/4032)
+- [4048: Moved ext-intl to suggest instead of require to avoid silent fallback.](https://github.com/zendframework/zf2/issues/4048)
+- [4050: Translable routing segments](https://github.com/zendframework/zf2/issues/4050)
+- [4073: Fixed issue #3064](https://github.com/zendframework/zf2/issues/4073)
+- [4098: fix php docblock : boolean should be bool](https://github.com/zendframework/zf2/issues/4098)
+- [4099: fix (bool) casting : add space and use (bool) instead of (boolean) to cast](https://github.com/zendframework/zf2/issues/4099)
+- [4104: Allow to change option creations for plugin manager](https://github.com/zendframework/zf2/issues/4104)
+- [4120: (Validator) Only return unique messages](https://github.com/zendframework/zf2/issues/4120)
+- [4127: Added I18n PhoneNumber validator based off of country](https://github.com/zendframework/zf2/issues/4127)
+- [4137: View helpers cleanup](https://github.com/zendframework/zf2/issues/4137)
+- [4139: Service manager performance optimized](https://github.com/zendframework/zf2/issues/4139)
+- [4145: Delegate factories](https://github.com/zendframework/zf2/issues/4145)
+- [4146: Lazy services](https://github.com/zendframework/zf2/issues/4146)
+- [4155: Move Identity closure to separate factory](https://github.com/zendframework/zf2/issues/4155)
+- [4165: Validate empty with context](https://github.com/zendframework/zf2/issues/4165)
+- [4169: Fixed error in adapter paginator DbTableGateway](https://github.com/zendframework/zf2/issues/4169)
+- [4170: Hydrator aware interface](https://github.com/zendframework/zf2/issues/4170)
+- [4175: AbstractRestfulController uses wrong action for id=0](https://github.com/zendframework/zf2/issues/4175)
+- [4178: Allow passing objects to the url helper](https://github.com/zendframework/zf2/issues/4178)
+- [4181: Make identifier name configurable for AbstractRestfulController](https://github.com/zendframework/zf2/issues/4181)
+- [4187: Add event manager as soft dependency to translator](https://github.com/zendframework/zf2/issues/4187)
+- [4202: Zend\Log has dependency on Zend\ServiceManager](https://github.com/zendframework/zf2/issues/4202)
+- [4204: Hotfix for #4202](https://github.com/zendframework/zf2/issues/4204)
+- [4206: Added sequence name for PostgreSQL](https://github.com/zendframework/zf2/issues/4206)
+- [4215: Bugfix for redirection handling in Zend\Http\Client](https://github.com/zendframework/zf2/issues/4215)
+- [4219: Custom validators registered through ValidatorProviderInterface not found](https://github.com/zendframework/zf2/issues/4219)
+- [4231: (Form) Get Elements for Collection](https://github.com/zendframework/zf2/issues/4231)
+- [4238: ValueGenerator constant detection](https://github.com/zendframework/zf2/issues/4238)
+- [4247: Added Brazilian IBAN format to IBAN validation](https://github.com/zendframework/zf2/issues/4247)
+- [4250: (#4249) Override 'ServiceManager::has' to do not use peering service managers](https://github.com/zendframework/zf2/issues/4250)
+- [4251: Create factories for selected view collaborators](https://github.com/zendframework/zf2/issues/4251)
+- [4252: Auto-upgrading and then displaying composer version](https://github.com/zendframework/zf2/issues/4252)
+- [4253: Create AbstractFactory for Cache](https://github.com/zendframework/zf2/issues/4253)
+- [4254: Use prefix in Logger abstract factory](https://github.com/zendframework/zf2/issues/4254)
+- [4259: Hotfix: Changed array\_walk to foreach in Zend\Stdlib\Hydrator\ArraySerializable](https://github.com/zendframework/zf2/issues/4259)
+- [4260: Validator\Explode can take option validator as array](https://github.com/zendframework/zf2/issues/4260)
+- [4262: Fixed console routes when using same name for group and parameter](https://github.com/zendframework/zf2/issues/4262)
+- [4263: Remove superfluous indentation from one line of code](https://github.com/zendframework/zf2/issues/4263)
+- [4268: Session service factories](https://github.com/zendframework/zf2/issues/4268)
+- [4269: Hotfix: cs fixer check](https://github.com/zendframework/zf2/issues/4269)
+- [4276: allow default http responses to be sent in mvc stack](https://github.com/zendframework/zf2/issues/4276)
+- [4279: Remove needless is\_object check](https://github.com/zendframework/zf2/issues/4279)
+- [4282: fix getHref strategy in PageMvc](https://github.com/zendframework/zf2/issues/4282)
+- [4284: Main framework composer.json is incorrectly configured](https://github.com/zendframework/zf2/issues/4284)
+- [4285: Fix for a problem with Service Manager and Abstract Factories](https://github.com/zendframework/zf2/issues/4285)
+- [4288: Reset URI parts before parse](https://github.com/zendframework/zf2/issues/4288)
+- [4289: Minor CS fix](https://github.com/zendframework/zf2/issues/4289)
+- [4293: Better fix for #4284](https://github.com/zendframework/zf2/issues/4293)
+- [4294: BaseInputFilter not populating InputFilters of Element\Collection](https://github.com/zendframework/zf2/issues/4294)
+- [4295: Console route defaults should be overridden by entered values](https://github.com/zendframework/zf2/issues/4295)
+- [4296: illegal usage of array\_walk in ObjectProperty, ClassMapAutoloader](https://github.com/zendframework/zf2/issues/4296)
+- [4298: View\Helper\Navigation\Menu: add flag to set page class to <li>](https://github.com/zendframework/zf2/issues/4298)
+- [4299: Suggestion: Don't render empty module console information](https://github.com/zendframework/zf2/issues/4299)
+- [4300: Maestro detection improvements in Zend\Validator\CreditCard](https://github.com/zendframework/zf2/issues/4300)
+- [4301: remove extra semicolon](https://github.com/zendframework/zf2/issues/4301)
+- [4303: Method annotations of Zend\Validator\Hostname constructor](https://github.com/zendframework/zf2/issues/4303)
+- [4311: DDL support for Zend\Db](https://github.com/zendframework/zf2/issues/4311)
+- [4312: POP3 protocol "return;" is needed after APOP request](https://github.com/zendframework/zf2/issues/4312)
+- [4313: update docblock for ZendTest : /Db/, /Code/ , /Di/, /Log/, Mvc/](https://github.com/zendframework/zf2/issues/4313)
+- [4317: Fix #4315 - Console routes with dashes are not understood.](https://github.com/zendframework/zf2/issues/4317)
+- [4319: Add various plugin manager](https://github.com/zendframework/zf2/issues/4319)
+- [4321: Hotfix/cs fixer installation](https://github.com/zendframework/zf2/issues/4321)
+- [4326: Add zh\_TW translations ](https://github.com/zendframework/zf2/issues/4326)
+- [4328: Fix 4294](https://github.com/zendframework/zf2/issues/4328)
+- [4330: Remove SM-Aware requirement from Forward plugin](https://github.com/zendframework/zf2/issues/4330)
+- [4331: Changed default version service to Zend.](https://github.com/zendframework/zf2/issues/4331)
+- [4336: Use is\_int() instead of is\_integer()](https://github.com/zendframework/zf2/issues/4336)
+- [4337: Fix alignment of values, add trailing comma](https://github.com/zendframework/zf2/issues/4337)
+- [4339: Remove @return annotation from constructor doc-block](https://github.com/zendframework/zf2/issues/4339)
+- [4341: Docblocks do not match](https://github.com/zendframework/zf2/issues/4341)
+- [4344: Add missing file level doc-block](https://github.com/zendframework/zf2/issues/4344)
+- [4347: Add empty line after namespace declaration](https://github.com/zendframework/zf2/issues/4347)
+- [4349: Alphabetically order use statements (related to #4338)](https://github.com/zendframework/zf2/issues/4349)
+- [4350: Remove comma before value in array initialization](https://github.com/zendframework/zf2/issues/4350)
+- [4351: fix the constructor's type-autodetection accepts wrong parameters](https://github.com/zendframework/zf2/issues/4351)
+- [4352: Fix doc blocks consistency and coding standards PSR2](https://github.com/zendframework/zf2/issues/4352)
+- [4353: Glob::glob() should throw an exception on error](https://github.com/zendframework/zf2/issues/4353)
+- [4354: Corrected wrong year](https://github.com/zendframework/zf2/issues/4354)
+- [4355: fix docblock : @throw should be @throws](https://github.com/zendframework/zf2/issues/4355)
+- [4356: FormSelect translate optgroup label fix](https://github.com/zendframework/zf2/issues/4356)
+- [4358: Form abstract factory](https://github.com/zendframework/zf2/issues/4358)
+- [4361: Ldap Ldif Decoder bug fix](https://github.com/zendframework/zf2/issues/4361)
+- [4364: AbstractFactory consistency](https://github.com/zendframework/zf2/issues/4364)
+- [4365: Use InputFilterPluginManager in InputFilter\Factory](https://github.com/zendframework/zf2/issues/4365)
+- [4366: Fix for issue #3945, and fix for PUT with request content](https://github.com/zendframework/zf2/issues/4366)
+- [4367: Remove reference to root namespace (fixes #4363)](https://github.com/zendframework/zf2/issues/4367)
+- [4372: Ability to load custom form classes from FormElementManager in Mvc.](https://github.com/zendframework/zf2/issues/4372)
+- [4373: PHP Warning: call\_user\_func() expects…when Weakref enabled](https://github.com/zendframework/zf2/issues/4373)
+- [4374: CollectionInputFilter returns always valid for empty collections](https://github.com/zendframework/zf2/issues/4374)
+- [4376: Fix get with body in ClientStatic](https://github.com/zendframework/zf2/issues/4376)
+- [4378: Add patchList method to AbstractRestfulController](https://github.com/zendframework/zf2/issues/4378)
+- [4379: Fix for #4175](https://github.com/zendframework/zf2/issues/4379)
+- [4380: Decouple I18n\View\Helper\AbstractTranslatorHelper from ext\intl](https://github.com/zendframework/zf2/issues/4380)
+- [4382: Fix conflict InputFilter::type with Input::name in InputFilter factory](https://github.com/zendframework/zf2/issues/4382)
+- [4383: ensure the wrapElements option in Zend\Form\Form::prepareElement](https://github.com/zendframework/zf2/issues/4383)
+- [4389: Remove cache and log abstract factories from MVC](https://github.com/zendframework/zf2/issues/4389)
+- [4391: Segregated interfaces for Translator dependency of Validator component](https://github.com/zendframework/zf2/issues/4391)
+- [4392: Remove Version dependency from Feed component](https://github.com/zendframework/zf2/issues/4392)
+- [4393: 2.2RC1 BC Break: DateTimeFormatter sets blank data to today's date](https://github.com/zendframework/zf2/issues/4393)
+- [4394: Ensure that DateTimeFormatter doesn't format an empty string](https://github.com/zendframework/zf2/issues/4394)
+- [4396: Make ServiceManager dependency optional in Feed component](https://github.com/zendframework/zf2/issues/4396)
+- [4398: Allow DateTimeFormatter to format zero.](https://github.com/zendframework/zf2/issues/4398)
+- [4405: 2.2.0RC1 Form\View\Helper\FormRow "partial view" messed up](https://github.com/zendframework/zf2/issues/4405)
+- [4408: Optimize MutableCreationOptionsInterface capability](https://github.com/zendframework/zf2/issues/4408)
+- [4410: Fix conflict between translator service in ZF2 and skeleton app](https://github.com/zendframework/zf2/issues/4410)
+- [4411: Fix BC break in HTTP client resetParameters signature](https://github.com/zendframework/zf2/issues/4411)
+- [4412: FormRow: enable partial rendering](https://github.com/zendframework/zf2/issues/4412)
+- [4415: Remove URI dependency and make HTTP dependency optional in Feed](https://github.com/zendframework/zf2/issues/4415)
+- [4417: add docblock to I18n\Validator\PhoneNumber\{Code\}.php](https://github.com/zendframework/zf2/issues/4417)
+- [4418: remove @package docblock from demos files](https://github.com/zendframework/zf2/issues/4418)
+- [4420: sync svn r23693 - (ZF-11002) ehancement implemented as proposed](https://github.com/zendframework/zf2/issues/4420)
+- [4423: Minor param overflow](https://github.com/zendframework/zf2/issues/4423)
+- [4424: Edit config composer.json](https://github.com/zendframework/zf2/issues/4424)
+- [4425: Fix FormElementManagerFactory breaks csrf validation (in Mvc)](https://github.com/zendframework/zf2/issues/4425)
+- [4431: sync svn r24702 - support application/x-zip in Validator\File\IsCompressed](https://github.com/zendframework/zf2/issues/4431)
+- [4432: code concistency : update Zend\Mvc\Application::bootstrap](https://github.com/zendframework/zf2/issues/4432)
+- [4435: Di compatibility (#4434)](https://github.com/zendframework/zf2/issues/4435)
+- [4437: I18n currencyFormat helper: add the currencyPattern attribute and extend the unittest](https://github.com/zendframework/zf2/issues/4437)
+- [4441: Fixed unnecessary error rendering in form row helper.](https://github.com/zendframework/zf2/issues/4441)
+- [4444: Issues found by hphp static analysis](https://github.com/zendframework/zf2/issues/4444)
+- [4447: typo fixes](https://github.com/zendframework/zf2/issues/4447)
+- [4448: Aggregate hydrator ](https://github.com/zendframework/zf2/issues/4448)
+- [4450: Fix iterating over empty result set with buffering enabled](https://github.com/zendframework/zf2/issues/4450)
+- [4451: Form InputFilterSpecification: incorrect propagation](https://github.com/zendframework/zf2/issues/4451)
+- [4454: Fix for expiration value](https://github.com/zendframework/zf2/issues/4454)
+
+### Potential Breakage
+
+`Zend\Validator` was altered to remove the dependency on `Zend\I18n` by creating
+[Segregated Interfaces](http://en.wikipedia.org/wiki/Interface_segregation_principle).
+The practical upshot is that `Zend\Validator\AbstractValidator` no longer
+implements `Zend\I18n\Translator\TranslatorAwareInterface`, but rather
+`Zend\Validator\Translator\TranslatorAwareInterface`, which now typehints on
+`Zend\Validator\Translator\TranslatorInterface` instead of
+`Zend\I18n\Translator\Translator`. This means you cannot pass a
+`Zend\I18n\Translator\Translator` instance directly to a validator any longer.
+
+However, we have included a new class, `Zend\Mvc\I18n\Translator`, that extends
+the i18n Translator class and implements the Validator TranslatorInterface. This
+class may be used as a drop-in replacement. In fact, by default,
+`Zend\Validator\ValidatorPluginManager` is now using the `MvcTranslator`
+service, which utilizes this new class, making the change seamless for most
+users.
+
+The above change will only affect you if you were manually injecting a
+translator instance into your validators.
+
+## 2.1.6 (06 Mar 2014):
+
+### SECURITY UPDATES
+
+- **ZF2014-01:** Potential XXE/XEE attacks using PHP functions:
+ `simplexml_load_*`, `DOMDocument::loadXML`, and `xml_parse`. A new component,
+ `ZendXml`, was introduced to mitigate XML eXternal Entity and XML Entity
+ Expansion vectors that are present in older versions of libxml2 and/or PHP.
+ `Zend\Json\Json::fromXml()` and `Zend\XmlRpc`'s `Response` and `Fault` classes
+ were potentially vulnerable to these attacks. If you use either of these
+ components, we recommend upgrading immediately.
+
+## 2.1.5 (17 Apr 2013):
+
+- 2536: `Zend\Validate` translations out of date
+ (https://github.com/zendframework/zf2/issues/2536)
+- 2898: `ConstructedNavigationFactory` does not inject components
+ (https://github.com/zendframework/zf2/issues/2898)
+- 3373: `Collection` in `Form` not binds values when form has no object and hydrator set
+ (https://github.com/zendframework/zf2/issues/3373)
+- 3534: ZF2 2.0.6 Authentication and postgres database
+ (https://github.com/zendframework/zf2/issues/3534)
+- 3626: `Zend\Form\View\Helper\FormRow`: labels are appended by default
+ (https://github.com/zendframework/zf2/issues/3626)
+- 3685: Problem on appending new identifier on `EventManager`
+ (https://github.com/zendframework/zf2/issues/3685)
+- 3695: Adapter name and sequence problems
+ (https://github.com/zendframework/zf2/issues/3695)
+- 3719: `Zend\Db\Metadata\Source\AbstractSource` Notice: Undefined index
+ (https://github.com/zendframework/zf2/issues/3719)
+- 3731: Console banners are all shown consecutively
+ (https://github.com/zendframework/zf2/issues/3731)
+- 3882: `EventManager` or `Stdlib\CallbackHandler` can't handle `WeakRef` enough.
+ (https://github.com/zendframework/zf2/issues/3882)
+- 3898: `Zend\Navigation\Service\ConstructedNavigationFactory` not inject
+ dependences (router, action and etc)
+ (https://github.com/zendframework/zf2/issues/3898)
+- 3912: Ajustment `SequenceFeature` generic drivers
+ (https://github.com/zendframework/zf2/issues/3912)
+- 3934: `Acl` allow role access on all resources not honoured if added after resources
+ (https://github.com/zendframework/zf2/issues/3934)
+- 3983: Update `BaseInputFilter`
+ (https://github.com/zendframework/zf2/issues/3983)
+- 4002: Update `DocBlockScanner`
+ (https://github.com/zendframework/zf2/issues/4002)
+- 4013: Fix PHP Notice in `Translator` class
+ (https://github.com/zendframework/zf2/issues/4013)
+- 4014: update to `FlashMessenger` view helper to allow for classes on separator
+ (https://github.com/zendframework/zf2/issues/4014)
+- 4020: Add parent roles with traversable object
+ (https://github.com/zendframework/zf2/issues/4020)
+- 4026: `Zend\Validator` Test Suite Fix
+ (https://github.com/zendframework/zf2/issues/4026)
+- 4027: Move deprecation notice inside constructor of `Query` class
+ (https://github.com/zendframework/zf2/issues/4027)
+- 4035: [Router] non existent child route during assembly doesn't throw exception
+ (https://github.com/zendframework/zf2/issues/4035)
+- 4037: Remove unnecessary `autoload.php` from composer config.
+ (https://github.com/zendframework/zf2/issues/4037)
+- 4047: Update `InArray.php`
+ (https://github.com/zendframework/zf2/issues/4047)
+- 4049: removed unused cache test assets from test suite
+ (https://github.com/zendframework/zf2/issues/4049)
+- 4051: `writeLine()` with console is (literally) breaking when the string is "too long"?
+ (https://github.com/zendframework/zf2/issues/4051)
+- 4053: Implement better text domain merging support
+ (https://github.com/zendframework/zf2/issues/4053)
+- 4054: 2.1.4: `Zend/Stdlib/composer.json` requires "Zend/Stdlib/compatibility/autoload.php"
+ (https://github.com/zendframework/zf2/issues/4054)
+- 4055: Fix #4051 `console::writeLine()`
+ (https://github.com/zendframework/zf2/issues/4055)
+- 4061: Normalize console usage
+ (https://github.com/zendframework/zf2/issues/4061)
+- 4063: Resolved Issue #2898
+ (https://github.com/zendframework/zf2/issues/4063)
+- 4064: Fixed issue with invalid `@cover` annotations, pointed to not existed class
+ (https://github.com/zendframework/zf2/issues/4064)
+- 4066: `HttpControllerTestCase` gives wrong messages for `assertRedirect`/`assertNotRedirect`
+ (https://github.com/zendframework/zf2/issues/4066)
+- 4070: Hotfix for issue #4069
+ (https://github.com/zendframework/zf2/issues/4070)
+- 4074: fix typos
+ (https://github.com/zendframework/zf2/issues/4074)
+- 4075: `Form\Collection`: allow create new objects
+ (https://github.com/zendframework/zf2/issues/4075)
+- 4077: Fix `Collection` form element replacing bound objects with dummies upon form validation
+ (https://github.com/zendframework/zf2/issues/4077)
+- 4079: Some fixes for phpDoc in `Zend\Mvc`
+ (https://github.com/zendframework/zf2/issues/4079)
+- 4084: Introduce query parameter for `Navigation\Page\Mvc`
+ (https://github.com/zendframework/zf2/issues/4084)
+- 4085: Fix loading of a text domain from different sources, fixes issue #4045
+ (https://github.com/zendframework/zf2/issues/4085)
+- 4089: Zend\Test - set the request's `requestUri` to the dispatched url
+ (https://github.com/zendframework/zf2/issues/4089)
+- 4095: `Zend\Navigation\Page\Mvc::getHref` does not use `RouteMatch` parameters
+ (https://github.com/zendframework/zf2/issues/4095)
+- 4102: simplify constant usage. `FILEINFO_MIME_TYPE` is available since PHP 5.3.0
+ (https://github.com/zendframework/zf2/issues/4102)
+- 4103: `FormDateTimeSelect` - minutes delimiter always shown
+ (https://github.com/zendframework/zf2/issues/4103)
+- 4111: Updated translations
+ (https://github.com/zendframework/zf2/issues/4111)
+- 4117: [InputFilter] Allow specification of error message via `Factory`
+ (https://github.com/zendframework/zf2/issues/4117)
+- 4118: Fix name of variable used for capturing output when executing shell command
+ (https://github.com/zendframework/zf2/issues/4118)
+- 4119: Fix weird verbalization
+ (https://github.com/zendframework/zf2/issues/4119)
+- 4123: Fix#3373
+ (https://github.com/zendframework/zf2/issues/4123)
+- 4129: Update to `ServiceManager` to provide more precise error messages
+ (https://github.com/zendframework/zf2/issues/4129)
+- 4133: Fix#4103
+ (https://github.com/zendframework/zf2/issues/4133)
+- 4134: Zend\Mvc\Router\Console\Simple not compatible with older versions of pcre (and therefore CentOS)
+ (https://github.com/zendframework/zf2/issues/4134)
+- 4135: Update Czech validator messages
+ (https://github.com/zendframework/zf2/issues/4135)
+- 4138: Modified Router to use backwards compatible regex expression Issue: 4134
+ (https://github.com/zendframework/zf2/issues/4138)
+- 4140: When displaying navigations three times last navigation has data of prev...
+ (https://github.com/zendframework/zf2/issues/4140)
+- 4143: Fixed issue #3626
+ (https://github.com/zendframework/zf2/issues/4143)
+- 4144: feature / `quoteTrustedValueList`
+ (https://github.com/zendframework/zf2/issues/4144)
+- 4147: Reset stop-propagation flag when triggering event
+ (https://github.com/zendframework/zf2/issues/4147)
+- 4148: Filters priority setting when populating filters in inputfilter factory and not losing it when merging filter chains
+ (https://github.com/zendframework/zf2/issues/4148)
+- 4150: Hotfix - `callable` type introspection for method parameters
+ (https://github.com/zendframework/zf2/issues/4150)
+- 4152: Fixed some EMail Validation Strings - German
+ (https://github.com/zendframework/zf2/issues/4152)
+- 4153: [Feed] sync svn r24842 - Fix ZF-4491
+ (https://github.com/zendframework/zf2/issues/4153)
+- 4154: Catch `LogicException` for Rewind and fix CP errors
+ (https://github.com/zendframework/zf2/issues/4154)
+- 4157: end autoload classmap generated file with EOL
+ (https://github.com/zendframework/zf2/issues/4157)
+- 4161: servicemanager is a requirement
+ (https://github.com/zendframework/zf2/issues/4161)
+- 4164: Fetch model from event parameter
+ (https://github.com/zendframework/zf2/issues/4164)
+- 4167: `Console` posix adapter `writeLine()` background color bleeding through to the next line.
+ (https://github.com/zendframework/zf2/issues/4167)
+- 4168: Fix #4167 - Console posix adapter `writeLine()` background color bleeding through to the next line.
+ (https://github.com/zendframework/zf2/issues/4168)
+- 4171: Fix BC break in 2.1.5dev - Revert to previous `isRequired` behavior for file upload inputs
+ (https://github.com/zendframework/zf2/issues/4171)
+- 4172: [Form] Remove after Add doesn't restore initial state
+ (https://github.com/zendframework/zf2/issues/4172)
+- 4180: Radio & Multicheckbox Problem with selected & disabled attributes
+ (https://github.com/zendframework/zf2/issues/4180)
+- 4182: Issue #3358 - Fix for console router not accepting controller word as part of a route
+ (https://github.com/zendframework/zf2/issues/4182)
+- 4183: Update `Zend_Validate.php` resource
+ (https://github.com/zendframework/zf2/issues/4183)
+- 4184: Updated `Page\Mvc::getHref` to grab correct controller name from `routeMatch`
+ (https://github.com/zendframework/zf2/issues/4184)
+- 4191: `Zend\Stdlib\Hydrator\ClassMethods::hydrate()` - support for `__call()` magic method
+ (https://github.com/zendframework/zf2/issues/4191)
+- 4198: fixed typo in french `Zend_Validator_StringLength`
+ (https://github.com/zendframework/zf2/issues/4198)
+- 4199: Issue #4172 - Fixed empty priority queue state
+ (https://github.com/zendframework/zf2/issues/4199)
+- 4201: Issue #4172 - Added tests for add/remove sequence in `Zend\Form`
+ (https://github.com/zendframework/zf2/issues/4201)
+- 4203: Allow an instance of `Zend\Stdlib\AbstractOptions` to set configuration properties of the same class
+ (https://github.com/zendframework/zf2/issues/4203)
+- 4207: Fixed default plural rule.
+ (https://github.com/zendframework/zf2/issues/4207)
+- 4210: Fixed failure when implementing custom rbac roles
+ (https://github.com/zendframework/zf2/issues/4210)
+- 4213: [Curl] `setOptions` should merge config items that can be arrays
+ (https://github.com/zendframework/zf2/issues/4213)
+- 4216: Require `Zend\Config` in `Zend\Mvc`
+ (https://github.com/zendframework/zf2/issues/4216)
+- 4224: `Mail\Headers.php`: Adjust regex for field name to RFC 5322
+ (https://github.com/zendframework/zf2/issues/4224)
+- 4225: change variable naming
+ (https://github.com/zendframework/zf2/issues/4225)
+- 4226: ZF2 ACL full access
+ (https://github.com/zendframework/zf2/issues/4226)
+- 4227: Updated `Zend_Captcha` and `Zend_Validate` for catalan language
+ (https://github.com/zendframework/zf2/issues/4227)
+- 4232: Correct tests for group multicheckbox & radio attributes
+ (https://github.com/zendframework/zf2/issues/4232)
+- 4233: remove mistake doc for `Zend\Http\PhpEnvironment\Request::detectBaseUrl()`
+ (https://github.com/zendframework/zf2/issues/4233)
+- 4235: fixed `setEventManager`
+ (https://github.com/zendframework/zf2/issues/4235)
+- 4236: Update `ProvidesEvents.php`
+ (https://github.com/zendframework/zf2/issues/4236)
+- 4237: Update `ModuleManager.php`
+ (https://github.com/zendframework/zf2/issues/4237)
+- 4239: Remove annotation in `Zend\Db\Adapter\AdapterAwareTrait`
+ (https://github.com/zendframework/zf2/issues/4239)
+- 4240: A Better fix for #3912
+ (https://github.com/zendframework/zf2/issues/4240)
+- 4241: `Zend\Db\Metadata` - remove quoting of known scalars, use `quoteTrustedValue()` for provided values
+ (https://github.com/zendframework/zf2/issues/4241)
+- 4242: fix `Zend\Json` doc and little typo
+ (https://github.com/zendframework/zf2/issues/4242)
+- 4243: remove `if` `else` for same return
+ (https://github.com/zendframework/zf2/issues/4243)
+- 4244: remove unused `require_once __DIR__ . '/SplAutoloader.php';`
+ (https://github.com/zendframework/zf2/issues/4244)
+- 4246: replaced `get_called_class()` with `get_class($this)` in non-static context
+ (https://github.com/zendframework/zf2/issues/4246)
+
+## 2.1.4 (13 Mar 2013):
+
+- ZF2013-01: Query route (http://framework.zend.com/security/ZF2013-01)
+- ZF2013-02: RNG support (http://framework.zend.com/security/ZF2013-02)
+- ZF2013-03: DB platform quoting (http://framework.zend.com/security/ZF2013-03)
+- 2752: `Zend_Json_Server` to accept null parameters
+ (https://github.com/zendframework/zf2/issues/2752)
+- 3696: `Zend\Json\Server\Server` should allow parameters with NULL values
+ (https://github.com/zendframework/zf2/issues/3696)
+- 3767: Allow NULL parameter values in `Zend/Json/Server`
+ (https://github.com/zendframework/zf2/issues/3767)
+- 3827: Fix mismatches between the PHPDoc and the method signatures
+ (https://github.com/zendframework/zf2/issues/3827)
+- 3840: allow a null page in pages array, to compensate for ZF issue #3823
+ (https://github.com/zendframework/zf2/issues/3840)
+- 3842: Hotfix/zend test improve console usage
+ (https://github.com/zendframework/zf2/issues/3842)
+- 3849: Check if values are set in `Zend\Db\Sql\Insert.php` for prepared
+ statement
+ (https://github.com/zendframework/zf2/issues/3849)
+- 3867: `FileGenerator::setUses()` MUST can take arguments from
+ `FileGenerator::getUses()`
+ (https://github.com/zendframework/zf2/issues/3867)
+- 3868: `ClassGenerator::fromReflection` not generate class properties
+ (https://github.com/zendframework/zf2/issues/3868)
+- 3869: Remove BC break in `Identical` validator
+ (https://github.com/zendframework/zf2/issues/3869)
+- 3871: The method delete on the `RowGateway` now returns the affected rows
+ (https://github.com/zendframework/zf2/issues/3871)
+- 3873: Fixes an issue when binding a model to a form collection element
+ (https://github.com/zendframework/zf2/issues/3873)
+- 3885: Hotfix/add tests console adapter
+ (https://github.com/zendframework/zf2/issues/3885)
+- 3886: Add tests console prompt
+ (https://github.com/zendframework/zf2/issues/3886)
+- 3888: `DefinitionList` `hasMethod` fix
+ (https://github.com/zendframework/zf2/issues/3888)
+- 3907: Add tests console request response
+ (https://github.com/zendframework/zf2/issues/3907)
+- 3916: Fix PUT HTTP method usage with params
+ (https://github.com/zendframework/zf2/issues/3916)
+- 3917: Clean the Console abstract adapter
+ (https://github.com/zendframework/zf2/issues/3917)
+- 3921: [+BUGFIX] Fixed column names bug `Zend\Db\Sql\Select`
+ (https://github.com/zendframework/zf2/issues/3921)
+- 3925: Added view and validator dependency
+ (https://github.com/zendframework/zf2/issues/3925)
+- 3936: Improve the remove of `SendResponseListener`
+ (https://github.com/zendframework/zf2/issues/3936)
+- 3946: Adding config to `openssl_pkey_export()`
+ (https://github.com/zendframework/zf2/issues/3946)
+- 3947: fix exception %s passed variable of 'A service by the name or alias %s' should be $name
+ (https://github.com/zendframework/zf2/issues/3947)
+- 3948: Bug/merging translator textdomains
+ (https://github.com/zendframework/zf2/issues/3948)
+- 3950: Fix zero value in argument
+ (https://github.com/zendframework/zf2/issues/3950)
+- 3957: [Hotfix] Fixed incorrect `PDO_Oci` platform recognition
+ (https://github.com/zendframework/zf2/issues/3957)
+- 3960: Update toString() to use late static binding for encoding methods
+ (https://github.com/zendframework/zf2/issues/3960)
+- 3964: Fix fluent interface
+ (https://github.com/zendframework/zf2/issues/3964)
+- 3966: Better polyfill support for `Stdlib` and `Session`
+ (https://github.com/zendframework/zf2/issues/3966)
+- 3968: fixed `Exception\InvalidArgumentException` messages in `Zend\Log`
+ (https://github.com/zendframework/zf2/issues/3968)
+- 3971: SessionArrayStorage doesn't preserve `_REQUEST_ACCESS_TIME`
+ (https://github.com/zendframework/zf2/issues/3971)
+- 3973: Documentation improvement `Zend\View\Stream`
+ (https://github.com/zendframework/zf2/issues/3973)
+- 3980: change `HOST_DNS_OR_IPV4_OR_IPV6` to `0x13` for `$validHostTypes`
+ (https://github.com/zendframework/zf2/issues/3980)
+- 3981: Improve exception messages
+ (https://github.com/zendframework/zf2/issues/3981)
+- 3982: Fix `\Zend\Soap\AutoDiscover` constructor
+ (https://github.com/zendframework/zf2/issues/3982)
+- 3984: Update `ArrayStack.php`
+ (https://github.com/zendframework/zf2/issues/3984)
+- 3987: Fix ChromePhp logger interface and debug level
+ (https://github.com/zendframework/zf2/issues/3987)
+- 3988: Fix & Unit test for `preparestatement` notices
+ (https://github.com/zendframework/zf2/issues/3988)
+- 3991: Hotfix/3858 - `findHelper` problem in Navigation Helper
+ (https://github.com/zendframework/zf2/issues/3991)
+- 3993: `SessionArrayStorage` Request Access Time and Storage Initialization
+ (https://github.com/zendframework/zf2/issues/3993)
+- 3997: Allow https on scheme without a hostname
+ (https://github.com/zendframework/zf2/issues/3997)
+- 4001: Fix `ViewFeedStrategyFactory` comment
+ (https://github.com/zendframework/zf2/issues/4001)
+- 4005: Hotfix/case sensitive console
+ (https://github.com/zendframework/zf2/issues/4005)
+- 4007: Pass `ClassGenerator` instance instead of boolean
+ (https://github.com/zendframework/zf2/issues/4007)
+- 4009: Minor if to else if improvement
+ (https://github.com/zendframework/zf2/issues/4009)
+- 4010: Hotfix/zend test with console route
+ (https://github.com/zendframework/zf2/issues/4010)
+
+## 2.1.3 (21 Feb 2013):
+
+- 3714: Zend\Stdlib\ArrayObject::offsetExists() returning by reference
+ (https://github.com/zendframework/zf2/issues/3714)
+- 3855: Fix #3852
+ (https://github.com/zendframework/zf2/issues/3855)
+- 3856: Simple route case insensitive
+ (https://github.com/zendframework/zf2/issues/3856)
+
+## 2.1.2 (20 Feb 2013):
+
+- 3085: create controller via Zend\Mvc\Controller\ControllerManager
+ (https://github.com/zendframework/zf2/issues/3085)
+- 3469: ConnectionInterface docblock is wrong or implementation is wrong..
+ (https://github.com/zendframework/zf2/issues/3469)
+- 3506: [WIP] [#3113] Fix spelling in error validation messages
+ (https://github.com/zendframework/zf2/issues/3506)
+- 3636: If route has child routes and in URL has arbitrary query like "?lang=de"
+ it does not work
+ (https://github.com/zendframework/zf2/issues/3636)
+- 3652: Query parameter ?action=somevalue will get 404 error
+ (https://github.com/zendframework/zf2/issues/3652)
+- 3683: Fix to make sure NotEmpty validator is not already set
+ (https://github.com/zendframework/zf2/issues/3683)
+- 3691: Fix for GitHub issue 3469
+ (https://github.com/zendframework/zf2/issues/3691)
+- 3698: Openssl error string
+ (https://github.com/zendframework/zf2/issues/3698)
+- 3699: Certain servers may not set a whitespace after a colon
+ (Set-Cookie: header)
+ (https://github.com/zendframework/zf2/issues/3699)
+- 3701: Synced pt\_BR\Zend\_Validate.php with en\Zend\_Validate.php
+ (https://github.com/zendframework/zf2/issues/3701)
+- 3702: added new file: resources\languages\pt\_BR\Zend\_Captcha.php
+ (https://github.com/zendframework/zf2/issues/3702)
+- 3703: [WIP] Adding parallel testing ANT build configuration and related files
+ (https://github.com/zendframework/zf2/issues/3703)
+- 3705: Recent composer.json update of stdlib package
+ (https://github.com/zendframework/zf2/issues/3705)
+- 3706: clear joins and create without columns
+ (https://github.com/zendframework/zf2/issues/3706)
+- 3707: quoteIdentifier problem in sequence
+ (https://github.com/zendframework/zf2/issues/3707)
+- 3708: Filter\File\RenameUpload: wrap move\_uploaded\_file to be easly mocked
+ (https://github.com/zendframework/zf2/issues/3708)
+- 3712: Fix for URIs with a query string not matching
+ (https://github.com/zendframework/zf2/issues/3712)
+- 3713: Session Container Mismatch & Version Compare fixes for 5.3.3
+ (https://github.com/zendframework/zf2/issues/3713)
+- 3715: [#3705] Fix autoload.files setting in composer.json
+ (https://github.com/zendframework/zf2/issues/3715)
+- 3716: Added the Zend\Form decepence in composer.json for Zend\Mvc
+ (https://github.com/zendframework/zf2/issues/3716)
+- 3721: Created README.md files for each component
+ (https://github.com/zendframework/zf2/issues/3721)
+- 3722: [Form] [DateTimeSelect] Filter, manager, and view helper fixes
+ (https://github.com/zendframework/zf2/issues/3722)
+- 3725: Use built-in php constants
+ (https://github.com/zendframework/zf2/issues/3725)
+- 3729: Zend\Barcode (Fixes #2862)
+ (https://github.com/zendframework/zf2/issues/3729)
+- 3732: Fix for #2531 - Multiplie navigation don't work
+ (https://github.com/zendframework/zf2/issues/3732)
+- 3733: Fix/select where
+ (https://github.com/zendframework/zf2/issues/3733)
+- 3735: [Form] [FormElementManager] don't overwrite form factory if already set
+ (https://github.com/zendframework/zf2/issues/3735)
+- 3742: Object+hydrator element annotation fix
+ (https://github.com/zendframework/zf2/issues/3742)
+- 3743: [#3739 & #3740] Using version-compare in accept header handler params.
+ (https://github.com/zendframework/zf2/issues/3743)
+- 3746: Fix bugs for some locales!
+ (https://github.com/zendframework/zf2/issues/3746)
+- 3757: Fixed a bug where mail messages were malformed when using the Sendmail
+ (https://github.com/zendframework/zf2/issues/3757)
+- 3764: Validator File MimeType (IsImage & IsCompressed)
+ (https://github.com/zendframework/zf2/issues/3764)
+- 3771: Zend\File\Transfer\Adapter\Http on receive : error "File was not found" in ZF 2.1
+ (https://github.com/zendframework/zf2/issues/3771)
+- 3778: [#3711] Fix regression in query string matching
+ (https://github.com/zendframework/zf2/issues/3778)
+- 3782: [WIP] Zend\Di\Di::get() with call parameters ignored shared instances.
+ (https://github.com/zendframework/zf2/issues/3782)
+- 3783: Provide branch-alias entries for each component composer.json
+ (https://github.com/zendframework/zf2/issues/3783)
+- 3785: Zend\Db\Sql\Literal Fix when % is used in string
+ (https://github.com/zendframework/zf2/issues/3785)
+- 3786: Inject shared event manager in initializer
+ (https://github.com/zendframework/zf2/issues/3786)
+- 3789: Update library/Zend/Mail/Header/AbstractAddressList.php
+ (https://github.com/zendframework/zf2/issues/3789)
+- 3793: Resolved Issue: #3748 - offsetGet and __get should do a direct proxy to
+ $_SESSION
+ (https://github.com/zendframework/zf2/issues/3793)
+- 3794: Implement query and fragment assembling into the HTTP router itself
+ (https://github.com/zendframework/zf2/issues/3794)
+- 3797: remove @category, @package, and @subpackage docblocks
+ (https://github.com/zendframework/zf2/issues/3797)
+- 3798: Remove extra semicolons
+ (https://github.com/zendframework/zf2/issues/3798)
+- 3803: Fix identical validator
+ (https://github.com/zendframework/zf2/issues/3803)
+- 3806: Remove obsolete catch statement
+ (https://github.com/zendframework/zf2/issues/3806)
+- 3807: Resolve undefined classes in phpDoc
+ (https://github.com/zendframework/zf2/issues/3807)
+- 3808: Add missing @return annotations
+ (https://github.com/zendframework/zf2/issues/3808)
+- 3813: Bug fix for GlobIterator extending service
+ (https://github.com/zendframework/zf2/issues/3813)
+- 3817: Add failing tests for Simple console route
+ (https://github.com/zendframework/zf2/issues/3817)
+- 3819: Allow form element filter to convert a string to array
+ (https://github.com/zendframework/zf2/issues/3819)
+- 3828: Cannot validate form when keys of collection in data are non consecutive
+ (https://github.com/zendframework/zf2/issues/3828)
+- 3831: Non-matching argument type for ArrayObject
+ (https://github.com/zendframework/zf2/issues/3831)
+- 3832: Zend\Db\Sql\Predicate\Predicate->literal() does not work with integer 0
+ as $expressionParameters
+ (https://github.com/zendframework/zf2/issues/3832)
+- 3836: Zend\Db\Sql\Predicate\Predicate Fix for literal() usage
+ (https://github.com/zendframework/zf2/issues/3836)
+- 3837: Fix for legacy Transfer usage of File Validators
+ (https://github.com/zendframework/zf2/issues/3837)
+- 3838: Stdlib\ArrayObject & Zend\Session\Container Compatibility with ArrayObject
+ (https://github.com/zendframework/zf2/issues/3838)
+- 3839: Fixes #2477 - Implemented optional subdomains using regex
+ (https://github.com/zendframework/zf2/issues/3839)
+
+## 2.1.1 (06 Feb 2013):
+
+- 2510: Zend\Session\Container does not allow modification by reference
+ (https://github.com/zendframework/zf2/issues/2510)
+- 2899: Can't inherit abstract function
+ Zend\Console\Prompt\PromptInterface::show()
+ (https://github.com/zendframework/zf2/issues/2899)
+- 3455: Added DISTINCT on Zend\Db\Sql\Select
+ (https://github.com/zendframework/zf2/issues/3455)
+- 3456: Connection creation added in Pgsql.php createStatement method
+ (https://github.com/zendframework/zf2/issues/3456)
+- 3608: Fix validate data contains arrays as values
+ (https://github.com/zendframework/zf2/issues/3608)
+- 3610: Form: rely on specific setter
+ (https://github.com/zendframework/zf2/issues/3610)
+- 3618: Fix bug when $indent have some string
+ (https://github.com/zendframework/zf2/issues/3618)
+- 3622: Updated Changelog with BC notes for 2.1 and 2.0.7
+ (https://github.com/zendframework/zf2/issues/3622)
+- 3623: Authentication using DbTable Adapter doesn't work for 2.1.0
+ (https://github.com/zendframework/zf2/issues/3623)
+- 3625: Missing instance/object for parameter route upgrading to 2.1.\*
+ (https://github.com/zendframework/zf2/issues/3625)
+- 3627: Making relative links in Markdown files
+ (https://github.com/zendframework/zf2/issues/3627)
+- 3629: Zend\Db\Select using alias in joins can results in wrong SQL
+ (https://github.com/zendframework/zf2/issues/3629)
+- 3638: Fixed method that removed part from parts in Mime\Message
+ (https://github.com/zendframework/zf2/issues/3638)
+- 3639: Session Metadata and SessionArrayStorage requestaccesstime fixes.
+ (https://github.com/zendframework/zf2/issues/3639)
+- 3640: [#3625] Do not query abstract factories for registered invokables
+ (https://github.com/zendframework/zf2/issues/3640)
+- 3641: Zend\Db\Sql\Select Fix for #3629
+ (https://github.com/zendframework/zf2/issues/3641)
+- 3645: Exception on destructing the SMTP Transport instance
+ (https://github.com/zendframework/zf2/issues/3645)
+- 3648: Ensure run() always returns Application instance
+ (https://github.com/zendframework/zf2/issues/3648)
+- 3649: Created script to aggregate return status
+ (https://github.com/zendframework/zf2/issues/3649)
+- 3650: InjectControllerDependencies initializer overriding an previously
+ defined EventManager
+ (https://github.com/zendframework/zf2/issues/3650)
+- 3651: Hotfix/3650
+ (https://github.com/zendframework/zf2/issues/3651)
+- 3656: Zend\Validator\Db\AbstractDb.php and mysqli
+ (https://github.com/zendframework/zf2/issues/3656)
+- 3658: Zend\Validator\Db\AbstractDb.php and mysqli (issue: 3656)
+ (https://github.com/zendframework/zf2/issues/3658)
+- 3661: ZF HTTP Status Code overwritten
+ (https://github.com/zendframework/zf2/issues/3661)
+- 3662: Remove double injection in Plugin Controller Manager
+ (https://github.com/zendframework/zf2/issues/3662)
+- 3663: Remove useless shared in ServiceManager
+ (https://github.com/zendframework/zf2/issues/3663)
+- 3671: Hotfix/restful head identifier
+ (https://github.com/zendframework/zf2/issues/3671)
+- 3673: Add translations for Zend\Validator\File\UploadFile
+ (https://github.com/zendframework/zf2/issues/3673)
+- 3679: remove '\' character from Traversable
+ (https://github.com/zendframework/zf2/issues/3679)
+- 3680: Zend\Validator\Db Hotfix (supersedes #3658)
+ (https://github.com/zendframework/zf2/issues/3680)
+- 3681: [#2899] Remove redundant method declaration
+ (https://github.com/zendframework/zf2/issues/3681)
+- 3682: Zend\Db\Sql\Select Quantifier (DISTINCT, ALL, + Expression) support -
+ supersedes #3455
+ (https://github.com/zendframework/zf2/issues/3682)
+- 3684: Remove the conditional class declaration of ArrayObject
+ (https://github.com/zendframework/zf2/issues/3684)
+- 3687: fix invalid docblock
+ (https://github.com/zendframework/zf2/issues/3687)
+- 3689: [#3684] Polyfill support for version-dependent classes
+ (https://github.com/zendframework/zf2/issues/3689)
+- 3690: oracle transaction support
+ (https://github.com/zendframework/zf2/issues/3690)
+- 3692: Hotfix/db parametercontainer mixed use
+ (https://github.com/zendframework/zf2/issues/3692)
+
+## 2.1.0 (29 Jan 2013):
+
+- 2378: ZF2-417 Form Annotation Hydrator options support
+ (https://github.com/zendframework/zf2/issues/2378)
+- 2390: Expose formally protected method in ConfigListener
+ (https://github.com/zendframework/zf2/issues/2390)
+- 2405: [WIP] Feature/accepted model controller plugin
+ (https://github.com/zendframework/zf2/issues/2405)
+- 2424: Decorator plugin manager was pointing to an inexistent class
+ (https://github.com/zendframework/zf2/issues/2424)
+- 2428: Form develop/allow date time
+ (https://github.com/zendframework/zf2/issues/2428)
+- 2430: [2.1] Added the scrypt key derivation algorithm in Zend\Crypt
+ (https://github.com/zendframework/zf2/issues/2430)
+- 2439: [2.1] Form File Upload refactor
+ (https://github.com/zendframework/zf2/issues/2439)
+- 2486: The Upload validator might be broken
+ (https://github.com/zendframework/zf2/issues/2486)
+- 2506: Throwing exception in template (and/or layout) doesnt fails gracefully
+ (https://github.com/zendframework/zf2/issues/2506)
+- 2524: Throws exception when trying to generate bcrypt
+ (https://github.com/zendframework/zf2/issues/2524)
+- 2537: Create a NotIn predicate
+ (https://github.com/zendframework/zf2/issues/2537)
+- 2616: Initial ZF2 RBAC Component
+ (https://github.com/zendframework/zf2/issues/2616)
+- 2629: JsonStrategy should set response charset
+ (https://github.com/zendframework/zf2/issues/2629)
+- 2647: Fix/bcrypt: added the set/get BackwardCompatibility
+ (https://github.com/zendframework/zf2/issues/2647)
+- 2668: Implement XCache storage adapter (fixes #2581)
+ (https://github.com/zendframework/zf2/issues/2668)
+- 2671: Added fluent inteface to prepend and set method. Zend\View\Container\AbstractContainer
+ (https://github.com/zendframework/zf2/issues/2671)
+- 2725: Feature/logger factory
+ (https://github.com/zendframework/zf2/issues/2725)
+- 2726: Zend\Validator\Explode does not handle NULL
+ (https://github.com/zendframework/zf2/issues/2726)
+- 2727: Added ability to add additional information to the logs via processors.
+ (https://github.com/zendframework/zf2/issues/2727)
+- 2772: Adding cookie route. Going to open PR for comments.
+ (https://github.com/zendframework/zf2/issues/2772)
+- 2815: Fix fro GitHub issue 2600 (Cannot check if a table is read only)
+ (https://github.com/zendframework/zf2/issues/2815)
+- 2819: Support for ListenerAggregates in SharedEventManager
+ (https://github.com/zendframework/zf2/issues/2819)
+- 2820: Form plugin manager
+ (https://github.com/zendframework/zf2/issues/2820)
+- 2863: Handle postgres sequences
+ (https://github.com/zendframework/zf2/issues/2863)
+- 2876: memcached changes
+ (https://github.com/zendframework/zf2/issues/2876)
+- 2884: Allow select object to pass on select->join
+ (https://github.com/zendframework/zf2/issues/2884)
+- 2888: Bugfix dateformat helper
+ (https://github.com/zendframework/zf2/issues/2888)
+- 2918: \Zend\Mime\Mime::LINEEND causes problems with some SMTP-Servers
+ (https://github.com/zendframework/zf2/issues/2918)
+- 2945: SOAP 1.2 support for WSDL generation
+ (https://github.com/zendframework/zf2/issues/2945)
+- 2947: Add DateTimeSelect element to form
+ (https://github.com/zendframework/zf2/issues/2947)
+- 2950: Abstract row gatewayset from array
+ (https://github.com/zendframework/zf2/issues/2950)
+- 2968: Zend\Feed\Reader\Extension\Atom\Entry::getAuthors and Feed::getAuthors
+ should return Collection\Author
+ (https://github.com/zendframework/zf2/issues/2968)
+- 2973: Zend\Db\Sql : Create NotIn predicate
+ (https://github.com/zendframework/zf2/issues/2973)
+- 2977: Method signature of merge() in Zend\Config\Config prevents mocking
+ (https://github.com/zendframework/zf2/issues/2977)
+- 2988: Cache: Added storage adapter using a session container
+ (https://github.com/zendframework/zf2/issues/2988)
+- 2990: Added note of new xcache storage adapter
+ (https://github.com/zendframework/zf2/issues/2990)
+- 3010: [2.1][File Uploads] Multi-File input filtering and FilePRG plugin update
+ (https://github.com/zendframework/zf2/issues/3010)
+- 3011: Response Json Client
+ (https://github.com/zendframework/zf2/issues/3011)
+- 3016: [develop] PRG Plugin fixes: Incorrect use of session hops expiration
+ (https://github.com/zendframework/zf2/issues/3016)
+- 3019: [2.1][develop] PRG Plugins fix
+ (https://github.com/zendframework/zf2/issues/3019)
+- 3055: Zend Validators complain of array to string conversion for nested array
+ values that do not pass validation when using E\_NOTICE
+ (https://github.com/zendframework/zf2/issues/3055)
+- 3058: [2.1][File Upload] Session Progress fixes
+ (https://github.com/zendframework/zf2/issues/3058)
+- 3059: [2.1] Add reference to ChromePhp LoggerWriter in WriterPluginManager
+ (https://github.com/zendframework/zf2/issues/3059)
+- 3069: Hotfix/xcache empty namespace
+ (https://github.com/zendframework/zf2/issues/3069)
+- 3073: Documentation and code mismatch
+ (https://github.com/zendframework/zf2/issues/3073)
+- 3084: Basic support for aggregates in SharedEventManager according to feedback...
+ (https://github.com/zendframework/zf2/issues/3084)
+- 3086: Updated constructors to accept options array according to AbstractWriter...
+ (https://github.com/zendframework/zf2/issues/3086)
+- 3088: Zend\Permissions\Rbac roles should inherit parent permissions, not child
+ permissions
+ (https://github.com/zendframework/zf2/issues/3088)
+- 3093: Feature/cookies refactor
+ (https://github.com/zendframework/zf2/issues/3093)
+- 3105: RFC Send Response Workflow
+ (https://github.com/zendframework/zf2/issues/3105)
+- 3110: Stdlib\StringUtils
+ (https://github.com/zendframework/zf2/issues/3110)
+- 3140: Tests for Zend\Cache\Storage\Adapter\MemcachedResourceManager
+ (https://github.com/zendframework/zf2/issues/3140)
+- 3195: Date element formats not respected in validators.
+ (https://github.com/zendframework/zf2/issues/3195)
+- 3199: [2.1][FileUploads] FileInput AJAX Post fix
+ (https://github.com/zendframework/zf2/issues/3199)
+- 3212: Cache: Now an empty namespace means disabling namespace support
+ (https://github.com/zendframework/zf2/issues/3212)
+- 3215: Check $exception type before throw
+ (https://github.com/zendframework/zf2/issues/3215)
+- 3219: Fix hook in plugin manager
+ (https://github.com/zendframework/zf2/issues/3219)
+- 3224: Zend\Db\Sql\Select::getSqlString(Zend\Db\Adapter\Platform\Mysql) doesn't
+ work properly with limit param
+ (https://github.com/zendframework/zf2/issues/3224)
+- 3243: [2.1] Added the support of Apache's passwords
+ (https://github.com/zendframework/zf2/issues/3243)
+- 3246: [2.1][File Upload] Change file upload filtering to preserve the $\_FILES
+ array
+ (https://github.com/zendframework/zf2/issues/3246)
+- 3247: Fix zend test with the new sendresponselistener
+ (https://github.com/zendframework/zf2/issues/3247)
+- 3257: Support nested error handler
+ (https://github.com/zendframework/zf2/issues/3257)
+- 3259: [2.1][File Upload] RenameUpload filter rewrite w/option to use uploaded
+ 'name'
+ (https://github.com/zendframework/zf2/issues/3259)
+- 3263: correcting ConsoleResponseSender's __invoke
+ (https://github.com/zendframework/zf2/issues/3263)
+- 3276: DateElement now support a string
+ (https://github.com/zendframework/zf2/issues/3276)
+- 3283: fix Undefined function DocBlockReflection::factory error
+ (https://github.com/zendframework/zf2/issues/3283)
+- 3287: Added missing constructor parameter
+ (https://github.com/zendframework/zf2/issues/3287)
+- 3308: Update library/Zend/Validator/File/MimeType.php
+ (https://github.com/zendframework/zf2/issues/3308)
+- 3314: add ContentTransferEncoding Headers
+ (https://github.com/zendframework/zf2/issues/3314)
+- 3316: Update library/Zend/Mvc/ResponseSender/ConsoleResponseSender.php
+ (https://github.com/zendframework/zf2/issues/3316)
+- 3334: [2.1][develop] Added missing Exception namespace to Sha1 validator
+ (https://github.com/zendframework/zf2/issues/3334)
+- 3339: Xterm's 256 colors integration for Console.
+ (https://github.com/zendframework/zf2/issues/3339)
+- 3343: add SimpleStreamResponseSender + Tests
+ (https://github.com/zendframework/zf2/issues/3343)
+- 3349: Provide support for more HTTP methods in the AbstractRestfulController
+ (https://github.com/zendframework/zf2/issues/3349)
+- 3350: Add little more fun to console
+ (https://github.com/zendframework/zf2/issues/3350)
+- 3357: Add default prototype tags in reflection
+ (https://github.com/zendframework/zf2/issues/3357)
+- 3359: Added filter possibility
+ (https://github.com/zendframework/zf2/issues/3359)
+- 3363: Fix minor doc block errors
+ (https://github.com/zendframework/zf2/issues/3363)
+- 3365: Fix trailing spaces CS error causing all travis builds to fail
+ (https://github.com/zendframework/zf2/issues/3365)
+- 3366: Zend\Log\Logger::registerErrorHandler() should accept a parameter to set
+ the return value of the error_handler callback
+ (https://github.com/zendframework/zf2/issues/3366)
+- 3370: [2.1] File PRG plugin issue when merging POST data with nested keys
+ (https://github.com/zendframework/zf2/issues/3370)
+- 3376: Remove use of deprecated /e-modifier of preg_replace
+ (https://github.com/zendframework/zf2/issues/3376)
+- 3377: removed test failing since PHP>=5.4
+ (https://github.com/zendframework/zf2/issues/3377)
+- 3378: Improve code generators consistency
+ (https://github.com/zendframework/zf2/issues/3378)
+- 3385: render view one last time in case exception thrown from inside view
+ (https://github.com/zendframework/zf2/issues/3385)
+- 3389: FileExtension validor error in Form context
+ (https://github.com/zendframework/zf2/issues/3389)
+- 3392: Development branch of AbstractRestfulController->processPostData()
+ doesn't handle Content-Type application/x-www-form-urlencoded correctly
+ (https://github.com/zendframework/zf2/issues/3392)
+- 3404: Provide default $_SESSION array superglobal proxy storage adapter
+ (https://github.com/zendframework/zf2/issues/3404)
+- 3405: fix dispatcher to catch legitimate exceptions
+ (https://github.com/zendframework/zf2/issues/3405)
+- 3414: Zend\Mvc\Controller\AbstractRestfulController: various fixes to Json
+ handling
+ (https://github.com/zendframework/zf2/issues/3414)
+- 3418: [2.1] Additional code comments for FileInput
+ (https://github.com/zendframework/zf2/issues/3418)
+- 3420: Authentication Validator
+ (https://github.com/zendframework/zf2/issues/3420)
+- 3421: Allow to set arbitrary status code for Exception strategy
+ (https://github.com/zendframework/zf2/issues/3421)
+- 3426: Zend\Form\View\Helper\FormSelect
+ (https://github.com/zendframework/zf2/issues/3426)
+- 3427: `Zend\ModuleManager\Feature\ProvidesDependencyModulesInterface`
+ (https://github.com/zendframework/zf2/issues/3427)
+- 3440: [#3376] Better fix
+ (https://github.com/zendframework/zf2/issues/3440)
+- 3442: Better content-type negotiation
+ (https://github.com/zendframework/zf2/issues/3442)
+- 3446: Zend\Form\Captcha setOptions don't follow interface contract
+ (https://github.com/zendframework/zf2/issues/3446)
+- 3450: [Session][Auth] Since the recent BC changes to Sessions,
+ Zend\Authentication\Storage\Session does not work
+ (https://github.com/zendframework/zf2/issues/3450)
+- 3454: ACL permissions are not correctly inherited.
+ (https://github.com/zendframework/zf2/issues/3454)
+- 3458: Session data is empty in Session SaveHandler's write function
+ (https://github.com/zendframework/zf2/issues/3458)
+- 3461: fix for zendframework/zf2#3458
+ (https://github.com/zendframework/zf2/issues/3461)
+- 3470: Session not working in current development?
+ (https://github.com/zendframework/zf2/issues/3470)
+- 3479: Fixed #3454.
+ (https://github.com/zendframework/zf2/issues/3479)
+- 3482: Feature/rest delete replace collection
+ (https://github.com/zendframework/zf2/issues/3482)
+- 3483: [#2629] Add charset to Content-Type header
+ (https://github.com/zendframework/zf2/issues/3483)
+- 3485: Zend\Db Oracle Driver
+ (https://github.com/zendframework/zf2/issues/3485)
+- 3491: Update library/Zend/Code/Generator/PropertyGenerator.php
+ (https://github.com/zendframework/zf2/issues/3491)
+- 3493: [Log] fixes #3366: Now Logger::registerErrorHandler() accepts continue
+ (https://github.com/zendframework/zf2/issues/3493)
+- 3494: [2.1] Zend\Filter\Word\* no longer extends Zend\Filter\PregReplace
+ (https://github.com/zendframework/zf2/issues/3494)
+- 3495: [2.1] Added Zend\Stdlib\StringUtils::hasPcreUnicodeSupport()
+ (https://github.com/zendframework/zf2/issues/3495)
+- 3496: [2.1] fixed tons of missing/wrong use statements
+ (https://github.com/zendframework/zf2/issues/3496)
+- 3498: add method to Zend\Http\Response\Stream
+ (https://github.com/zendframework/zf2/issues/3498)
+- 3499: removed "self" typehints in Zend\Config and Zend\Mvc
+ (https://github.com/zendframework/zf2/issues/3499)
+- 3501: Exception while createing RuntimeException in Pdo Connection class
+ (https://github.com/zendframework/zf2/issues/3501)
+- 3507: hasAcl dosn't cheks $defaultAcl Member Variable
+ (https://github.com/zendframework/zf2/issues/3507)
+- 3508: Removed all @category, @package, and @subpackage annotations
+ (https://github.com/zendframework/zf2/issues/3508)
+- 3509: Zend\Form\View\Helper\FormSelect
+ (https://github.com/zendframework/zf2/issues/3509)
+- 3510: FilePRG: replace array_merge with ArrayUtils::merge
+ (https://github.com/zendframework/zf2/issues/3510)
+- 3511: Revert PR #3088 as discussed in #3265.
+ (https://github.com/zendframework/zf2/issues/3511)
+- 3519: Allow to pull route manager from sl
+ (https://github.com/zendframework/zf2/issues/3519)
+- 3523: Components dependent on Zend\Stdlib but it's not marked in composer.json
+ (https://github.com/zendframework/zf2/issues/3523)
+- 3531: [2.1] Fix variable Name and Resource on Oracle Driver Test
+ (https://github.com/zendframework/zf2/issues/3531)
+- 3532: Add legend translation support into formCollection view helper
+ (https://github.com/zendframework/zf2/issues/3532)
+- 3538: ElementPrepareAwareInterface should use FormInterface
+ (https://github.com/zendframework/zf2/issues/3538)
+- 3541: \Zend\Filter\Encrypt and \Zend\Filter\Decrypt not working together?
+ (https://github.com/zendframework/zf2/issues/3541)
+- 3543: Hotfix: Undeprecate PhpEnvironement Response methods
+ (https://github.com/zendframework/zf2/issues/3543)
+- 3545: Removing service initializer as of zendframework/zf2#3537
+ (https://github.com/zendframework/zf2/issues/3545)
+- 3546: Add RoleInterface
+ (https://github.com/zendframework/zf2/issues/3546)
+- 3555: [2.1] [Forms] [Bug] Factory instantiates Elements directly but should be
+ using the FormElementManager
+ (https://github.com/zendframework/zf2/issues/3555)
+- 3556: fix for zendframework/zf2#3555
+ (https://github.com/zendframework/zf2/issues/3556)
+- 3557: [2.1] Fixes for FilePRG when using nested form elements
+ (https://github.com/zendframework/zf2/issues/3557)
+- 3559: Feature/translate flash message
+ (https://github.com/zendframework/zf2/issues/3559)
+- 3561: Zend\Mail SMTP Fix Connection Handling
+ (https://github.com/zendframework/zf2/issues/3561)
+- 3566: Flash Messenger fixes for PHP < 5.4, and fix for default namespacing
+ (https://github.com/zendframework/zf2/issues/3566)
+- 3567: Zend\Db: Adapter construction features + IbmDb2 & Oracle Platform
+ features
+ (https://github.com/zendframework/zf2/issues/3567)
+- 3572: Allow to add serializers through config
+ (https://github.com/zendframework/zf2/issues/3572)
+- 3576: BC Break in Controller Loader, controllers no more present in controller
+ loader.
+ (https://github.com/zendframework/zf2/issues/3576)
+- 3583: [2.1] Fixed an issue on salt check in Apache Password
+ (https://github.com/zendframework/zf2/issues/3583)
+- 3584: Zend\Db Fix for #3290
+ (https://github.com/zendframework/zf2/issues/3584)
+- 3585: [2.1] Added the Apache htpasswd support for HTTP Authentication
+ (https://github.com/zendframework/zf2/issues/3585)
+- 3586: Zend\Db Fix for #2563
+ (https://github.com/zendframework/zf2/issues/3586)
+- 3587: Zend\Db Fix/Feature for #3294
+ (https://github.com/zendframework/zf2/issues/3587)
+- 3597: Zend\Db\TableGateway hotfix for MasterSlaveFeature
+ (https://github.com/zendframework/zf2/issues/3597)
+- 3598: Feature Zend\Db\Adapter\Profiler
+ (https://github.com/zendframework/zf2/issues/3598)
+- 3599: [WIP] Zend\Db\Sql Literal Objects
+ (https://github.com/zendframework/zf2/issues/3599)
+- 3600: Fixed the unit test for Zend\Filter\File\Encrypt and Decrypt
+ (https://github.com/zendframework/zf2/issues/3600)
+- 3605: Restore Zend\File\Transfer
+ (https://github.com/zendframework/zf2/issues/3605)
+- 3606: Zend\Db\Sql\Select Add Support For SubSelect in Join Table - #2881 &
+ #2884
+ (https://github.com/zendframework/zf2/issues/3606)
+
+### Potential Breakage
+
+Includes a fix to the classes `Zend\Filter\Encrypt`
+and `Zend\Filter\Decrypt` which may pose a small break for end-users. Each
+requires an encryption key be passed to either the constructor or the
+setKey() method now; this was done to improve the security of each
+class.
+
+`Zend\Session` includes a new `Zend\Session\Storage\SessionArrayStorage`
+class, which acts as a direct proxy to the $_SESSION superglobal. The
+SessionManager class now uses this new storage class by default, in
+order to fix an error that occurs when directly manipulating nested
+arrays of $_SESSION in third-party code. For most users, the change will
+be seamless. Those affected will be those (a) directly accessing the
+storage instance, and (b) using object notation to access session
+members:
+
+ $foo = null;
+ /** @var $storage Zend\Session\Storage\SessionStorage */
+ if (isset($storage->foo)) {
+ $foo = $storage->foo;
+ }
+
+If you are using array notation, as in the following example, your code
+remains forwards compatible:
+
+ $foo = null;
+
+ /** @var $storage Zend\Session\Storage\SessionStorage */
+ if (isset($storage['foo'])) {
+ $foo = $storage['foo'];
+ }
+
+If you are not working directly with the storage instance, you will be
+unaffected.
+
+For those affected, the following courses of action are possible:
+
+ * Update your code to replace object property notation with array
+ notation, OR
+ * Initialize and register a Zend\Session\Storage\SessionStorage object
+ explicitly with the session manager instance.
+
+## 2.0.8 (13 Mar 2013):
+
+- ZF2013-01: Query route (http://framework.zend.com/security/ZF2013-01)
+- ZF2013-02: RNG support (http://framework.zend.com/security/ZF2013-02)
+- ZF2013-03: DB platform quoting (http://framework.zend.com/security/ZF2013-03)
+
+## 2.0.7 (29 Jan 2013):
+
+- 1992: [2.1] Adding simple Zend/I18n/Loader/Tmx
+ (https://github.com/zendframework/zf2/issues/1992)
+- 2024: Add HydratingResultSet::toEntityArray()
+ (https://github.com/zendframework/zf2/issues/2024)
+- 2031: [2.1] Added MongoDB session save handler
+ (https://github.com/zendframework/zf2/issues/2031)
+- 2080: [2.1] Added a ChromePhp logger
+ (https://github.com/zendframework/zf2/issues/2080)
+- 2086: [2.1] Module class map cache
+ (https://github.com/zendframework/zf2/issues/2086)
+- 2100: [2.1] refresh() method in Redirect plugin
+ (https://github.com/zendframework/zf2/issues/2100)
+- 2105: [2.1] Feature/unidecoder
+ (https://github.com/zendframework/zf2/issues/2105)
+- 2106: [2.1] Class annotation scanner
+ (https://github.com/zendframework/zf2/issues/2106)
+- 2125: [2.1] Add hydrator wildcard and new hydrator strategy
+ (https://github.com/zendframework/zf2/issues/2125)
+- 2129: [2.1] Feature/overrideable di factories
+ (https://github.com/zendframework/zf2/issues/2129)
+- 2152: [2.1] [WIP] adding basic table view helper
+ (https://github.com/zendframework/zf2/issues/2152)
+- 2175: [2.1] Add DateSelect and MonthSelect elements
+ (https://github.com/zendframework/zf2/issues/2175)
+- 2189: [2.1] Added msgpack serializer
+ (https://github.com/zendframework/zf2/issues/2189)
+- 2190: [2.1] [WIP] Zend\I18n\Filter\SlugUrl - Made a filter to convert text to
+ slugs
+ (https://github.com/zendframework/zf2/issues/2190)
+- 2208: [2.1] Update library/Zend/View/Helper/HeadScript.php
+ (https://github.com/zendframework/zf2/issues/2208)
+- 2212: [2.1] Feature/uri normalize filter
+ (https://github.com/zendframework/zf2/issues/2212)
+- 2225: Zend\Db\Sql : Create NotIn predicate
+ (https://github.com/zendframework/zf2/issues/2225)
+- 2232: [2.1] Load Messages from other than file
+ (https://github.com/zendframework/zf2/issues/2232)
+- 2271: [2.1] Ported FingersCrossed handler from monolog to ZF2
+ (https://github.com/zendframework/zf2/issues/2271)
+- 2288: Allow to create empty option in Select
+ (https://github.com/zendframework/zf2/issues/2288)
+- 2305: Add support for prev and next link relationships
+ (https://github.com/zendframework/zf2/issues/2305)
+- 2315: Add MVC service factories for Filters and Validators
+ (https://github.com/zendframework/zf2/issues/2315)
+- 2316: Add paginator factory & adapter plugin manager
+ (https://github.com/zendframework/zf2/issues/2316)
+- 2333: Restore mail message from string
+ (https://github.com/zendframework/zf2/issues/2333)
+- 2339: ZF2-530 Implement PropertyScanner
+ (https://github.com/zendframework/zf2/issues/2339)
+- 2343: Create Zend Server Monitor Event
+ (https://github.com/zendframework/zf2/issues/2343)
+- 2367: Convert abstract classes that are only offering static methods
+ (https://github.com/zendframework/zf2/issues/2367)
+- 2374: Modified Acl/Navigation to be extendable
+ (https://github.com/zendframework/zf2/issues/2374)
+- 2381: Method Select::from can accept instance of Select as subselect
+ (https://github.com/zendframework/zf2/issues/2381)
+- 2389: Add plural view helper
+ (https://github.com/zendframework/zf2/issues/2389)
+- 2396: Rbac component for ZF2
+ (https://github.com/zendframework/zf2/issues/2396)
+- 2399: Feature/unidecoder new
+ (https://github.com/zendframework/zf2/issues/2399)
+- 2411: Allow to specify custom pattern for date
+ (https://github.com/zendframework/zf2/issues/2411)
+- 2414: Added a new validator to check if input is instance of certain class
+ (https://github.com/zendframework/zf2/issues/2414)
+- 2415: Add plural helper to I18n
+ (https://github.com/zendframework/zf2/issues/2415)
+- 2417: Allow to render template separately
+ (https://github.com/zendframework/zf2/issues/2417)
+- 2648: AbstractPluginManager should not respond to...
+ (https://github.com/zendframework/zf2/issues/2648)
+- 2650: Add view helper and controller plugin to pull the current identity from ...
+ (https://github.com/zendframework/zf2/issues/2650)
+- 2670: quoteIdentifier() & quoteIdentifierChain() bug
+ (https://github.com/zendframework/zf2/issues/2670)
+- 2702: Added addUse method in ClassGenerator
+ (https://github.com/zendframework/zf2/issues/2702)
+- 2704: Functionality/writer plugin manager
+ (https://github.com/zendframework/zf2/issues/2704)
+- 2706: Feature ini adapter translate
+ (https://github.com/zendframework/zf2/issues/2706)
+- 2718: Chain authentication storage
+ (https://github.com/zendframework/zf2/issues/2718)
+- 2774: Fixes #2745 (generate proper query strings).
+ (https://github.com/zendframework/zf2/issues/2774)
+- 2783: Added methods to allow access to the routes of the SimpleRouteStack.
+ (https://github.com/zendframework/zf2/issues/2783)
+- 2794: Feature test phpunit lib
+ (https://github.com/zendframework/zf2/issues/2794)
+- 2801: Improve Zend\Code\Scanner\TokenArrayScanner
+ (https://github.com/zendframework/zf2/issues/2801)
+- 2807: Add buffer handling to HydratingResultSet
+ (https://github.com/zendframework/zf2/issues/2807)
+- 2809: Allow Zend\Db\Sql\TableIdentifier in Zend\Db\Sql\Insert, Update & Delete
+ (https://github.com/zendframework/zf2/issues/2809)
+- 2812: Catch exceptions thrown during rendering
+ (https://github.com/zendframework/zf2/issues/2812)
+- 2821: Added loadModule.post event to loadModule().
+ (https://github.com/zendframework/zf2/issues/2821)
+- 2822: Added the ability for FirePhp to understand 'extras' passed to \Zend\Log
+ (https://github.com/zendframework/zf2/issues/2822)
+- 2841: Allow to remove attribute in form element
+ (https://github.com/zendframework/zf2/issues/2841)
+- 2844: [Server] & [Soap] Typos and docblocks
+ (https://github.com/zendframework/zf2/issues/2844)
+- 2848: fixing extract behavior of Zend\Form\Element\Collection and added
+ ability to use own fieldset helper within FormCollection-helper
+ (https://github.com/zendframework/zf2/issues/2848)
+- 2855: add a view event
+ (https://github.com/zendframework/zf2/issues/2855)
+- 2868: [WIP][Server] Rewrite Reflection API to reuse code from
+ Zend\Code\Reflection API
+ (https://github.com/zendframework/zf2/issues/2868)
+- 2870: [Code] Add support for @throws, multiple types and typed arrays
+ (https://github.com/zendframework/zf2/issues/2870)
+- 2875: [InputFilter] Adding hasUnknown and getUnknown methods to detect and get
+ unknown inputs
+ (https://github.com/zendframework/zf2/issues/2875)
+- 2919: Select::where should accept PredicateInterface
+ (https://github.com/zendframework/zf2/issues/2919)
+- 2927: Add a bunch of traits to ZF2
+ (https://github.com/zendframework/zf2/issues/2927)
+- 2931: Cache: Now an empty namespace means disabling namespace support
+ (https://github.com/zendframework/zf2/issues/2931)
+- 2953: [WIP] #2743 fix docblock @category/@package/@subpackage
+ (https://github.com/zendframework/zf2/issues/2953)
+- 2989: Decouple Zend\Db\Sql from concrete Zend\Db\Adapter implementations
+ (https://github.com/zendframework/zf2/issues/2989)
+- 2995: service proxies / lazy services
+ (https://github.com/zendframework/zf2/issues/2995)
+- 3017: Fixing the problem with order and \Zend\Db\Sql\Expression
+ (https://github.com/zendframework/zf2/issues/3017)
+- 3028: Added Json support for POST and PUT operations in restful controller.
+ (https://github.com/zendframework/zf2/issues/3028)
+- 3056: Add pattern & storage cache factory
+ (https://github.com/zendframework/zf2/issues/3056)
+- 3057: Pull zend filter compress snappy
+ (https://github.com/zendframework/zf2/issues/3057)
+- 3078: Allow NodeList to be accessed via array like syntax.
+ (https://github.com/zendframework/zf2/issues/3078)
+- 3081: Fix for Collection extract method updates targetElement object
+ (https://github.com/zendframework/zf2/issues/3081)
+- 3106: Added template map generator
+ (https://github.com/zendframework/zf2/issues/3106)
+- 3189: Added xterm's 256 colors
+ (https://github.com/zendframework/zf2/issues/3189)
+- 3200: Added ValidatorChain::attach() and ValidatorChain::attachByName() to
+ keep consistent with FilterChain
+ (https://github.com/zendframework/zf2/issues/3200)
+- 3202: Added NTLM authentication support to Zend\Soap\Client\DotNet.
+ (https://github.com/zendframework/zf2/issues/3202)
+- 3218: Zend-Form: Allow Input Filter Preference Over Element Defaults
+ (https://github.com/zendframework/zf2/issues/3218)
+- 3230: Add Zend\Stdlib\Hydrator\Strategy\ClosureStrategy
+ (https://github.com/zendframework/zf2/issues/3230)
+- 3241: Reflection parameter type check
+ (https://github.com/zendframework/zf2/issues/3241)
+- 3260: Zend/Di, retriving same shared instance for different extra parameters
+ (https://github.com/zendframework/zf2/issues/3260)
+- 3261: Fix sendmail key
+ (https://github.com/zendframework/zf2/issues/3261)
+- 3262: Allows several translation files for same domain / locale
+ (https://github.com/zendframework/zf2/issues/3262)
+- 3269: A fix for issue #3195. Date formats are now used during validation.
+ (https://github.com/zendframework/zf2/issues/3269)
+- 3272: Support for internationalized .IT domain names
+ (https://github.com/zendframework/zf2/issues/3272)
+- 3273: Parse docblock indented with tabs
+ (https://github.com/zendframework/zf2/issues/3273)
+- 3285: Fixed wrong return usage and added @throws docblock
+ (https://github.com/zendframework/zf2/issues/3285)
+- 3286: remove else in already return early
+ (https://github.com/zendframework/zf2/issues/3286)
+- 3288: Removed unused variable
+ (https://github.com/zendframework/zf2/issues/3288)
+- 3292: Added Zend Monitor custom event support
+ (https://github.com/zendframework/zf2/issues/3292)
+- 3295: Proposing removal of subscription record upon unsubscribe
+ (https://github.com/zendframework/zf2/issues/3295)
+- 3296: Hotfix #3046 - set /dev/urandom as entropy file for Session
+ (https://github.com/zendframework/zf2/issues/3296)
+- 3298: Add PROPFIND Method to Zend/HTTP/Request
+ (https://github.com/zendframework/zf2/issues/3298)
+- 3300: Zend\Config - Fix count after merge
+ (https://github.com/zendframework/zf2/issues/3300)
+- 3302: Fixed #3282
+ (https://github.com/zendframework/zf2/issues/3302)
+- 3303: Fix indentation, add trailing ',' to last element in array
+ (https://github.com/zendframework/zf2/issues/3303)
+- 3304: Missed the Zend\Text dependency for Zend\Mvc in composer.json
+ (https://github.com/zendframework/zf2/issues/3304)
+- 3307: Fix an issue with inheritance of placeholder registry
+ (https://github.com/zendframework/zf2/issues/3307)
+- 3313: Fix buffering getTotalSpace
+ (https://github.com/zendframework/zf2/issues/3313)
+- 3317: Fixed FileGenerator::setUse() to ignore already added uses.
+ (https://github.com/zendframework/zf2/issues/3317)
+- 3318: Fixed FileGenerator::setUses() to allow passing in array of strings.
+ (https://github.com/zendframework/zf2/issues/3318)
+- 3320: Change @copyright Year : 2012 with 2013
+ (https://github.com/zendframework/zf2/issues/3320)
+- 3321: remove relative link in CONTRIBUTING.md
+ (https://github.com/zendframework/zf2/issues/3321)
+- 3322: remove copy variable for no reason
+ (https://github.com/zendframework/zf2/issues/3322)
+- 3324: enhance strlen to improve performance
+ (https://github.com/zendframework/zf2/issues/3324)
+- 3326: Minor loop improvements
+ (https://github.com/zendframework/zf2/issues/3326)
+- 3327: Fix indentation
+ (https://github.com/zendframework/zf2/issues/3327)
+- 3328: pass on the configured format to the DateValidator instead of hardcoding it
+ (https://github.com/zendframework/zf2/issues/3328)
+- 3329: Fixed DefinitionList::hasMethod()
+ (https://github.com/zendframework/zf2/issues/3329)
+- 3331: no chaining in form class' bind method
+ (https://github.com/zendframework/zf2/issues/3331)
+- 3333: Fixed Zend/Mvc/Router/Http/Segment
+ (https://github.com/zendframework/zf2/issues/3333)
+- 3340: Add root namespace character
+ (https://github.com/zendframework/zf2/issues/3340)
+- 3342: change boolean to bool for consistency
+ (https://github.com/zendframework/zf2/issues/3342)
+- 3345: Update library/Zend/Form/View/Helper/FormRow.php
+ (https://github.com/zendframework/zf2/issues/3345)
+- 3352: ClassMethods hydrator and wrong method definition
+ (https://github.com/zendframework/zf2/issues/3352)
+- 3355: Fix for GitHub issue 2511
+ (https://github.com/zendframework/zf2/issues/3355)
+- 3356: ZF session validators
+ (https://github.com/zendframework/zf2/issues/3356)
+- 3362: Use CamelCase for naming
+ (https://github.com/zendframework/zf2/issues/3362)
+- 3369: Removed unused variable in Zend\Json\Decoder.php
+ (https://github.com/zendframework/zf2/issues/3369)
+- 3386: Adding attributes for a lightweight export
+ (https://github.com/zendframework/zf2/issues/3386)
+- 3393: [Router] no need to correct ~ in the path encoding
+ (https://github.com/zendframework/zf2/issues/3393)
+- 3396: change minimal verson of PHPUnit
+ (https://github.com/zendframework/zf2/issues/3396)
+- 3403: [ZF-8825] Lower-case lookup for "authorization" header
+ (https://github.com/zendframework/zf2/issues/3403)
+- 3409: Fix for broken handling of
+ Zend\ServiceManager\ServiceManager::shareByDefault = false (Issue #3408)
+ (https://github.com/zendframework/zf2/issues/3409)
+- 3410: [composer] Sync replace package list
+ (https://github.com/zendframework/zf2/issues/3410)
+- 3415: Remove import of Zend root namespace
+ (https://github.com/zendframework/zf2/issues/3415)
+- 3423: Issue #3348 fix
+ (https://github.com/zendframework/zf2/issues/3423)
+- 3425: German Resources Zend\_Validate.php updated.
+ (https://github.com/zendframework/zf2/issues/3425)
+- 3429: Add __destruct to SessionManager
+ (https://github.com/zendframework/zf2/issues/3429)
+- 3430: SessionManager: Throw exception when attempting to setId after the
+ session has been started
+ (https://github.com/zendframework/zf2/issues/3430)
+- 3437: Feature/datetime factory format
+ (https://github.com/zendframework/zf2/issues/3437)
+- 3438: Add @method tags to the AbstractController
+ (https://github.com/zendframework/zf2/issues/3438)
+- 3439: Individual shared setting does not override the shareByDefault setting
+ of the ServiceManager
+ (https://github.com/zendframework/zf2/issues/3439)
+- 3443: Adding logic to check module dependencies at module loading time
+ (https://github.com/zendframework/zf2/issues/3443)
+- 3445: Update library/Zend/Validator/Hostname.php
+ (https://github.com/zendframework/zf2/issues/3445)
+- 3452: Hotfix/session mutability
+ (https://github.com/zendframework/zf2/issues/3452)
+- 3473: remove surplus call deep namespace
+ (https://github.com/zendframework/zf2/issues/3473)
+- 3477: The display_exceptions config-option is not passed to 404 views.
+ (https://github.com/zendframework/zf2/issues/3477)
+- 3480: [Validator][#2538] hostname validator overwrite
+ (https://github.com/zendframework/zf2/issues/3480)
+- 3484: [#3055] Remove array to string conversion notice
+ (https://github.com/zendframework/zf2/issues/3484)
+- 3486: [#3073] Define filter() in Decompress filter
+ (https://github.com/zendframework/zf2/issues/3486)
+- 3487: [#3446] Allow generic traversable configuration to Captcha element
+ (https://github.com/zendframework/zf2/issues/3487)
+- 3492: Hotfix/random crypt test fail
+ (https://github.com/zendframework/zf2/issues/3492)
+- 3502: Features/port supermessenger
+ (https://github.com/zendframework/zf2/issues/3502)
+- 3513: Fixed bug in acl introduced by acca10b6abe74b3ab51890d5cbe0ab8da4fdf7e0
+ (https://github.com/zendframework/zf2/issues/3513)
+- 3520: Replace all is_null($value) calls with null === $value
+ (https://github.com/zendframework/zf2/issues/3520)
+- 3527: Explode validator: allow any value type to be validated
+ (https://github.com/zendframework/zf2/issues/3527)
+- 3530: The hasACL and hasRole don't check their default member variables
+ (https://github.com/zendframework/zf2/issues/3530)
+- 3550: Fix for the issue #3541 - salt size for Encrypt/Decrypt Filter
+ (https://github.com/zendframework/zf2/issues/3550)
+- 3562: Fix: Calling count() results in infinite loop
+ (https://github.com/zendframework/zf2/issues/3562)
+- 3563: Zend\Db: Fix for #3523 changeset - composer.json and stdlib
+ (https://github.com/zendframework/zf2/issues/3563)
+- 3571: Correctly parse empty Subject header
+ (https://github.com/zendframework/zf2/issues/3571)
+- 3575: Fix name of plugin referred to in exception message
+ (https://github.com/zendframework/zf2/issues/3575)
+- 3579: Some minor fixes in \Zend\View\Helper\HeadScript() class
+ (https://github.com/zendframework/zf2/issues/3579)
+- 3593: \Zend\Json\Server Fix _getDefaultParams if request-params are an
+ associative array
+ (https://github.com/zendframework/zf2/issues/3593)
+- 3594: Added contstructor to suppressfilter
+ (https://github.com/zendframework/zf2/issues/3594)
+- 3601: Update Travis to start running tests on PHP 5.5
+ (https://github.com/zendframework/zf2/issues/3601)
+- 3604: fixed Zend\Log\Logger::registerErrorHandler() doesn't log previous
+ exceptions
+ (https://github.com/zendframework/zf2/issues/3604)
+
+### Potential Breakage
+
+Includes a fix to the classes `Zend\Filter\Encrypt`
+and `Zend\Filter\Decrypt` which may pose a small break for end-users. Each
+requires an encryption key be passed to either the constructor or the
+setKey() method now; this was done to improve the security of each
+class.
+
+## 2.0.6 (19 Dec 2012):
+
+- 2885: Zend\Db\TableGateway\AbstractTableGateway won't work with Sqlsrv
+ db adapter (https://github.com/zendframework/zf2/issues/2885)
+- 2922: Fix #2902 (https://github.com/zendframework/zf2/issues/2922)
+- 2961: Revert PR #2943 for 5.3.3 fix
+ (https://github.com/zendframework/zf2/issues/2961)
+- 2962: Allow Accept-Encoding header to be set explicitly by http
+ request (https://github.com/zendframework/zf2/issues/2962)
+- 3033: Fix error checking on Zend\Http\Client\Adapter\Socket->write().
+ (https://github.com/zendframework/zf2/issues/3033)
+- 3040: remove unused 'use DOMXPath' and property $count and $xpath
+ (https://github.com/zendframework/zf2/issues/3040)
+- 3043: improve conditional : reduce file size
+ (https://github.com/zendframework/zf2/issues/3043)
+- 3044: Extending Zend\Mvc\Router\Http\Segment causes error
+ (https://github.com/zendframework/zf2/issues/3044)
+- 3047: Fix Zend\Console\Getopt::getUsageMessage()
+ (https://github.com/zendframework/zf2/issues/3047)
+- 3049: Hotfix/issue #3033
+ (https://github.com/zendframework/zf2/issues/3049)
+- 3050: Fix : The annotation @\Zend\Form\Annotation\AllowEmpty declared
+ on does not accept any values
+ (https://github.com/zendframework/zf2/issues/3050)
+- 3052: Fixed #3051 (https://github.com/zendframework/zf2/issues/3052)
+- 3061: changed it back 'consist' => the 'must' should be applied to all
+ parts of the sentence
+ (https://github.com/zendframework/zf2/issues/3061)
+- 3063: hotfix: change sha382 to sha384 in
+ Zend\Crypt\Key\Derivation\SaltedS2k
+ (https://github.com/zendframework/zf2/issues/3063)
+- 3070: Fix default value unavailable exception for in-build php classes
+ (https://github.com/zendframework/zf2/issues/3070)
+- 3074: Hotfix/issue #2451 (https://github.com/zendframework/zf2/issues/3074)
+- 3091: console exception strategy displays previous exception message
+ (https://github.com/zendframework/zf2/issues/3091)
+- 3114: Fixed Client to allow also empty passwords in HTTP
+ Authentication. (https://github.com/zendframework/zf2/issues/3114)
+- 3125: #2607 - Fixing how headers are accessed
+ (https://github.com/zendframework/zf2/issues/3125)
+- 3126: Fix for GitHub issue 2605
+ (https://github.com/zendframework/zf2/issues/3126)
+- 3127: fix cs: add space after casting
+ (https://github.com/zendframework/zf2/issues/3127)
+- 3130: Obey PSR-2 (https://github.com/zendframework/zf2/issues/3130)
+- 3144: Zend\Form\View\Helper\Captcha\AbstractWord input and hidden
+ attributes (https://github.com/zendframework/zf2/issues/3144)
+- 3148: Fixing obsolete method of checking headers, made it use the new
+ method. (https://github.com/zendframework/zf2/issues/3148)
+- 3149: Zf2634 - Adding missing method Client::encodeAuthHeader
+ (https://github.com/zendframework/zf2/issues/3149)
+- 3151: Rename variable to what it probably should be
+ (https://github.com/zendframework/zf2/issues/3151)
+- 3155: strip duplicated semicolon
+ (https://github.com/zendframework/zf2/issues/3155)
+- 3156: fix typos in docblocks
+ (https://github.com/zendframework/zf2/issues/3156)
+- 3162: Allow Forms to have an InputFilterSpecification
+ (https://github.com/zendframework/zf2/issues/3162)
+- 3163: Added support of driver\_options to Mysqli DB Driver
+ (https://github.com/zendframework/zf2/issues/3163)
+- 3164: Cast $step to float in \Zend\Validator\Step
+ (https://github.com/zendframework/zf2/issues/3164)
+- 3166: [#2678] Sqlsrv driver incorrectly throwing exception when
+ $sqlOrResource... (https://github.com/zendframework/zf2/issues/3166)
+- 3167: Fix #3161 by checking if the server port already exists in the
+ host (https://github.com/zendframework/zf2/issues/3167)
+- 3169: Fixing issue #3036 (https://github.com/zendframework/zf2/issues/3169)
+- 3170: Fixing issue #2554 (https://github.com/zendframework/zf2/issues/3170)
+- 3171: hotfix : add '$argName' as 'argument %s' in sprintf ( at 1st
+ parameter ) (https://github.com/zendframework/zf2/issues/3171)
+- 3178: Maintain priority flag when cloning a Fieldset
+ (https://github.com/zendframework/zf2/issues/3178)
+- 3184: fix misspelled getCacheStorge()
+ (https://github.com/zendframework/zf2/issues/3184)
+- 3186: Dispatching to a good controller but wrong action triggers a
+ Fatal Error (https://github.com/zendframework/zf2/issues/3186)
+- 3187: Fixing ansiColorMap by removing extra m's showed in the console
+ (https://github.com/zendframework/zf2/issues/3187)
+- 3194: Write clean new line for writeLine method (no background color)
+ (https://github.com/zendframework/zf2/issues/3194)
+- 3197: Fix spelling error (https://github.com/zendframework/zf2/issues/3197)
+- 3201: Session storage set save path
+ (https://github.com/zendframework/zf2/issues/3201)
+- 3204: [wip] Zend\Http\Client makes 2 requests to url if
+ setStream(true) is called
+ (https://github.com/zendframework/zf2/issues/3204)
+- 3207: dead code clean up.
+ (https://github.com/zendframework/zf2/issues/3207)
+- 3208: Zend\Mime\Part: Added EOL paramter to getEncodedStream()
+ (https://github.com/zendframework/zf2/issues/3208)
+- 3213: [#3173] Incorrect creating instance
+ Zend/Code/Generator/ClassGenerator.php by fromArray
+ (https://github.com/zendframework/zf2/issues/3213)
+- 3214: Fix passing of tags to constructor of docblock generator class
+ (https://github.com/zendframework/zf2/issues/3214)
+- 3217: Cache: Optimized Filesystem::setItem with locking enabled by
+ writing the... (https://github.com/zendframework/zf2/issues/3217)
+- 3220: [2.0] Log Writer support for MongoClient driver class
+ (https://github.com/zendframework/zf2/issues/3220)
+- 3226: Licence is not accessable via web
+ (https://github.com/zendframework/zf2/issues/3226)
+- 3229: fixed bug in DefinitionList::hasMethod()
+ (https://github.com/zendframework/zf2/issues/3229)
+- 3234: Removed old Form TODO since all items are complete
+ (https://github.com/zendframework/zf2/issues/3234)
+- 3236: Issue #3222 - Added suport for multi-level nested ini config
+ variables (https://github.com/zendframework/zf2/issues/3236)
+- 3237: [BUG] Service Manager Not Shared Duplicate new Instance with
+ multiple Abstract Factories
+ (https://github.com/zendframework/zf2/issues/3237)
+- 3238: Added French translation for captcha
+ (https://github.com/zendframework/zf2/issues/3238)
+- 3250: Issue #2912 - Fix for LicenseTag generation
+ (https://github.com/zendframework/zf2/issues/3250)
+- 3252: subject prepend text in options for Log\Writer\Mail
+ (https://github.com/zendframework/zf2/issues/3252)
+- 3254: Better capabilities surrounding console notFoundAction
+ (https://github.com/zendframework/zf2/issues/3254)
+
+
+## 2.0.5 (29 Nov 2012):
+
+- 3004: Zend\Db unit tests fail with code coverage enabled
+ (https://github.com/zendframework/zf2/issues/3004)
+- 3039: combine double if into single conditional
+ (https://github.com/zendframework/zf2/issues/3039)
+- 3042: fix typo 'consist of' should be 'consists of' in singular
+ (https://github.com/zendframework/zf2/issues/3042)
+- 3045: Reduced the #calls of rawurlencode() using a cache mechanism
+ (https://github.com/zendframework/zf2/issues/3045)
+- 3048: Applying quickfix for zendframework/zf2#3004
+ (https://github.com/zendframework/zf2/issues/3048)
+- 3095: Process X-Forwarded-For header in correct order
+ (https://github.com/zendframework/zf2/issues/3095)
+
+## 2.0.4 (20 Nov 2012):
+
+- 2808: Add serializer better inheritance and extension
+ (https://github.com/zendframework/zf2/issues/2808)
+- 2813: Add test on canonical name with the ServiceManager
+ (https://github.com/zendframework/zf2/issues/2813)
+- 2832: bugfix: The helper DateFormat does not cache correctly when a pattern is
+ set. (https://github.com/zendframework/zf2/issues/2832)
+- 2837: Add empty option before empty check
+ (https://github.com/zendframework/zf2/issues/2837)
+- 2843: change self:: with static:: in call-ing static property/method
+ (https://github.com/zendframework/zf2/issues/2843)
+- 2857: Unnecessary path assembly on return in
+ Zend\Mvc\Router\Http\TreeRouteStack->assemble() line 236
+ (https://github.com/zendframework/zf2/issues/2857)
+- 2867: Enable view sub-directories when using ModuleRouteListener
+ (https://github.com/zendframework/zf2/issues/2867)
+- 2872: Resolve naming conflicts in foreach statements
+ (https://github.com/zendframework/zf2/issues/2872)
+- 2878: Fix : change self:: with static:: in call-ing static property/method()
+ in other components ( all ) (https://github.com/zendframework/zf2/issues/2878)
+- 2879: remove unused const in Zend\Barcode\Barcode.php
+ (https://github.com/zendframework/zf2/issues/2879)
+- 2896: Constraints in Zend\Db\Metadata\Source\AbstractSource::getTable not
+ initalised (https://github.com/zendframework/zf2/issues/2896)
+- 2907: Fixed proxy adapter keys being incorrectly set due Zend\Http\Client
+ (https://github.com/zendframework/zf2/issues/2907)
+- 2909: Change format of Form element DateTime and DateTimeLocal
+ (https://github.com/zendframework/zf2/issues/2909)
+- 2921: Added Chinese translations for zf2 validate/captcha resources
+ (https://github.com/zendframework/zf2/issues/2921)
+- 2924: small speed-up of Zend\EventManager\EventManager::triggerListeners()
+ (https://github.com/zendframework/zf2/issues/2924)
+- 2929: SetCookie::getFieldValue() always uses urlencode() for cookie values,
+ even in case they are already encoded
+ (https://github.com/zendframework/zf2/issues/2929)
+- 2930: Add minor test coverage to MvcEvent
+ (https://github.com/zendframework/zf2/issues/2930)
+- 2932: Sessions: SessionConfig does not allow setting non-directory save path
+ (https://github.com/zendframework/zf2/issues/2932)
+- 2937: preserve matched route name within route match instance while
+ forwarding... (https://github.com/zendframework/zf2/issues/2937)
+- 2940: change 'Cloud\Decorator\Tag' to 'Cloud\Decorator\AbstractTag'
+ (https://github.com/zendframework/zf2/issues/2940)
+- 2941: Logical operator fix : 'or' change to '||' and 'and' change to '&&'
+ (https://github.com/zendframework/zf2/issues/2941)
+- 2952: Various Zend\Mvc\Router\Http routers turn + into a space in path
+ segments (https://github.com/zendframework/zf2/issues/2952)
+- 2957: Make Partial proxy to view render function
+ (https://github.com/zendframework/zf2/issues/2957)
+- 2971: Zend\Http\Cookie undefined self::CONTEXT_REQUEST
+ (https://github.com/zendframework/zf2/issues/2971)
+- 2976: Fix for #2541 (https://github.com/zendframework/zf2/issues/2976)
+- 2981: Controller action HttpResponse is not used by SendResponseListener
+ (https://github.com/zendframework/zf2/issues/2981)
+- 2983: replaced all calls to $this->xpath with $this->getXpath() to always
+ have... (https://github.com/zendframework/zf2/issues/2983)
+- 2986: Add class to file missing a class (fixes #2789)
+ (https://github.com/zendframework/zf2/issues/2986)
+- 2987: fixed Zend\Session\Container::exchangeArray
+ (https://github.com/zendframework/zf2/issues/2987)
+- 2994: Fixes #2993 - Add missing asterisk to method docblock
+ (https://github.com/zendframework/zf2/issues/2994)
+- 2997: Fixing abstract factory instantiation time
+ (https://github.com/zendframework/zf2/issues/2997)
+- 2999: Fix for GitHub issue 2579
+ (https://github.com/zendframework/zf2/issues/2999)
+- 3002: update master's resources/ja Zend_Validate.php message
+ (https://github.com/zendframework/zf2/issues/3002)
+- 3003: Adding tests for zendframework/zf2#2593
+ (https://github.com/zendframework/zf2/issues/3003)
+- 3006: Hotfix for #2497 (https://github.com/zendframework/zf2/issues/3006)
+- 3007: Fix for issue 3001 Zend\Db\Sql\Predicate\Between fails with min and max
+ ... (https://github.com/zendframework/zf2/issues/3007)
+- 3008: Hotfix for #2482 (https://github.com/zendframework/zf2/issues/3008)
+- 3009: Hotfix for #2451 (https://github.com/zendframework/zf2/issues/3009)
+- 3013: Solved Issue 2857 (https://github.com/zendframework/zf2/issues/3013)
+- 3025: Removing the separator between the hidden and the visible inputs. As
+ the... (https://github.com/zendframework/zf2/issues/3025)
+- 3027: Reduced #calls of plugin() in PhpRenderer using a cache mechanism
+ (https://github.com/zendframework/zf2/issues/3027)
+- 3029: Fixed the pre-commit script, missed the fix command
+ (https://github.com/zendframework/zf2/issues/3029)
+- 3030: Mark module as loaded before trigginer EVENT_LOAD_MODULE
+ (https://github.com/zendframework/zf2/issues/3030)
+- 3031: Zend\Db\Sql Fix for Insert's Merge and Set capabilities with simlar keys
+ (https://github.com/zendframework/zf2/issues/3031)
+
+
+## 2.0.3 (17 Oct 2012):
+
+- 2244: Fix for issue ZF2-503 (https://github.com/zendframework/zf2/issues/2244)
+- 2318: Allow to remove decimals in CurrencyFormat
+ (https://github.com/zendframework/zf2/issues/2318)
+- 2363: Hotfix db features with eventfeature
+ (https://github.com/zendframework/zf2/issues/2363)
+- 2380: ZF2-482 Attempt to fix the buffer. Also added extra unit tests.
+ (https://github.com/zendframework/zf2/issues/2380)
+- 2392: Update library/Zend/Db/Adapter/Platform/Mysql.php
+ (https://github.com/zendframework/zf2/issues/2392)
+- 2395: Fix for http://framework.zend.com/issues/browse/ZF2-571
+ (https://github.com/zendframework/zf2/issues/2395)
+- 2397: Memcached option merge issuse
+ (https://github.com/zendframework/zf2/issues/2397)
+- 2402: Adding missing dependencies
+ (https://github.com/zendframework/zf2/issues/2402)
+- 2404: Fix to comments (https://github.com/zendframework/zf2/issues/2404)
+- 2416: Fix expressionParamIndex for AbstractSql
+ (https://github.com/zendframework/zf2/issues/2416)
+- 2420: Zend\Db\Sql\Select: Fixed issue with join expression named parameters
+ overlapping. (https://github.com/zendframework/zf2/issues/2420)
+- 2421: Update library/Zend/Http/Header/SetCookie.php
+ (https://github.com/zendframework/zf2/issues/2421)
+- 2422: fix add 2 space after @param in Zend\Loader
+ (https://github.com/zendframework/zf2/issues/2422)
+- 2423: ManagerInterface must be interface, remove 'interface' description
+ (https://github.com/zendframework/zf2/issues/2423)
+- 2425: Use built-in Travis composer
+ (https://github.com/zendframework/zf2/issues/2425)
+- 2426: Remove need of setter in ClassMethods hydrator
+ (https://github.com/zendframework/zf2/issues/2426)
+- 2432: Prevent space before end of tag with HTML5 doctype
+ (https://github.com/zendframework/zf2/issues/2432)
+- 2433: fix for setJsonpCallback not called when recieved JsonModel + test
+ (https://github.com/zendframework/zf2/issues/2433)
+- 2434: added phpdoc in Zend\Db
+ (https://github.com/zendframework/zf2/issues/2434)
+- 2437: Hotfix/console 404 reporting
+ (https://github.com/zendframework/zf2/issues/2437)
+- 2438: Improved previous fix for ZF2-558.
+ (https://github.com/zendframework/zf2/issues/2438)
+- 2440: Turkish Translations for Captcha and Validate
+ (https://github.com/zendframework/zf2/issues/2440)
+- 2441: Allow form collection to have any helper
+ (https://github.com/zendframework/zf2/issues/2441)
+- 2516: limit(20) -> generates LIMIT '20' and throws an IllegalQueryException
+ (https://github.com/zendframework/zf2/issues/2516)
+- 2545: getSqlStringForSqlObject() returns an invalid SQL statement with LIMIT
+ and OFFSET clauses (https://github.com/zendframework/zf2/issues/2545)
+- 2595: Pgsql adapater has codes related to MySQL
+ (https://github.com/zendframework/zf2/issues/2595)
+- 2613: Prevent password to be rendered if form validation fails
+ (https://github.com/zendframework/zf2/issues/2613)
+- 2617: Fixed Zend\Validator\Iban class name
+ (https://github.com/zendframework/zf2/issues/2617)
+- 2619: Form enctype fix when File elements are within a collection
+ (https://github.com/zendframework/zf2/issues/2619)
+- 2620: InputFilter/Input when merging was not using raw value
+ (https://github.com/zendframework/zf2/issues/2620)
+- 2622: Added ability to specify port
+ (https://github.com/zendframework/zf2/issues/2622)
+- 2624: Form's default input filters added multiple times
+ (https://github.com/zendframework/zf2/issues/2624)
+- 2630: fix relative link ( remove the relative links ) in README.md
+ (https://github.com/zendframework/zf2/issues/2630)
+- 2631: Update library/Zend/Loader/AutoloaderFactory.php
+ (https://github.com/zendframework/zf2/issues/2631)
+- 2633: fix redundance errors "The input does not appear to be a valid date"
+ show twice (https://github.com/zendframework/zf2/issues/2633)
+- 2635: Fix potential issue with Sitemap test
+ (https://github.com/zendframework/zf2/issues/2635)
+- 2636: add isset checks around timeout and maxredirects
+ (https://github.com/zendframework/zf2/issues/2636)
+- 2641: hotfix : formRow() element error multi-checkbox and radio renderError
+ not shown (https://github.com/zendframework/zf2/issues/2641)
+- 2642: Fix Travis build for CS issue
+ (https://github.com/zendframework/zf2/issues/2642)
+- 2643: fix for setJsonpCallback not called when recieved JsonModel + test
+ (https://github.com/zendframework/zf2/issues/2643)
+- 2644: Add fluidity to the prepare() function for a form
+ (https://github.com/zendframework/zf2/issues/2644)
+- 2652: Zucchi/filter tweaks (https://github.com/zendframework/zf2/issues/2652)
+- 2665: pdftest fix (https://github.com/zendframework/zf2/issues/2665)
+- 2666: fixed url change (https://github.com/zendframework/zf2/issues/2666)
+- 2667: Possible fix for rartests
+ (https://github.com/zendframework/zf2/issues/2667)
+- 2669: skip whem gmp is loaded
+ (https://github.com/zendframework/zf2/issues/2669)
+- 2673: Input fallback value option
+ (https://github.com/zendframework/zf2/issues/2673)
+- 2676: mysqli::close() never called
+ (https://github.com/zendframework/zf2/issues/2676)
+- 2677: added phpdoc to Zend\Stdlib
+ (https://github.com/zendframework/zf2/issues/2677)
+- 2678: Zend\Db\Adapter\Sqlsrv\Sqlsrv never calls Statement\initialize() (fix
+ within) (https://github.com/zendframework/zf2/issues/2678)
+- 2679: Zend/Log/Logger.php using incorrect php errorLevel
+ (https://github.com/zendframework/zf2/issues/2679)
+- 2680: Cache: fixed bug on getTotalSpace of filesystem and dba adapter
+ (https://github.com/zendframework/zf2/issues/2680)
+- 2681: Cache/Dba: fixed notices on tearDown db4 tests
+ (https://github.com/zendframework/zf2/issues/2681)
+- 2682: Replace 'Configuration' with 'Config' when retrieving configuration
+ (https://github.com/zendframework/zf2/issues/2682)
+- 2683: Hotfix: Allow items from Abstract Factories to have setShared() called
+ (https://github.com/zendframework/zf2/issues/2683)
+- 2685: Remove unused Uses (https://github.com/zendframework/zf2/issues/2685)
+- 2686: Adding code to allow EventManager trigger listeners using wildcard
+ identifier (https://github.com/zendframework/zf2/issues/2686)
+- 2687: Hotfix/db sql nested expressions
+ (https://github.com/zendframework/zf2/issues/2687)
+- 2688: Hotfix/tablegateway event feature
+ (https://github.com/zendframework/zf2/issues/2688)
+- 2689: Hotfix/composer phpunit
+ (https://github.com/zendframework/zf2/issues/2689)
+- 2690: Use RFC-3339 full-date format (Y-m-d) in Date element
+ (https://github.com/zendframework/zf2/issues/2690)
+- 2691: join on conditions don't accept alternatives to columns
+ (https://github.com/zendframework/zf2/issues/2691)
+- 2693: Update library/Zend/Db/Adapter/Driver/Mysqli/Connection.php
+ (https://github.com/zendframework/zf2/issues/2693)
+- 2694: Bring fluid interface to Feed Writer
+ (https://github.com/zendframework/zf2/issues/2694)
+- 2698: fix typo in # should be :: in exception
+ (https://github.com/zendframework/zf2/issues/2698)
+- 2699: fix elseif in javascript Upload Demo
+ (https://github.com/zendframework/zf2/issues/2699)
+- 2700: fix cs in casting variable
+ (https://github.com/zendframework/zf2/issues/2700)
+- 2705: Fix french translation
+ (https://github.com/zendframework/zf2/issues/2705)
+- 2707: Improved error message when ServiceManager does not find an invokable
+ class (https://github.com/zendframework/zf2/issues/2707)
+- 2710: #2461 - correcting the url encoding of path segments
+ (https://github.com/zendframework/zf2/issues/2710)
+- 2711: Fix/demos ProgressBar/ZendForm.php : Object of class Zend\Form\Form
+ could not be converted to string
+ (https://github.com/zendframework/zf2/issues/2711)
+- 2712: fix cs casting variable for (array)
+ (https://github.com/zendframework/zf2/issues/2712)
+- 2713: Update library/Zend/Mvc/Service/ViewHelperManagerFactory.php
+ (https://github.com/zendframework/zf2/issues/2713)
+- 2714: Don't add separator if not prefixing columns
+ (https://github.com/zendframework/zf2/issues/2714)
+- 2717: Extends when it can : Validator\DateStep extends Validator\Date to
+ reduce code redundancy (https://github.com/zendframework/zf2/issues/2717)
+- 2719: Fixing the Cache Storage Factory Adapter Factory
+ (https://github.com/zendframework/zf2/issues/2719)
+- 2728: Bad Regex for Content Type header
+ (https://github.com/zendframework/zf2/issues/2728)
+- 2731: Reset the Order part when resetting Select
+ (https://github.com/zendframework/zf2/issues/2731)
+- 2732: Removed references to Mysqli in Zend\Db\Adapter\Driver\Pgsql
+ (https://github.com/zendframework/zf2/issues/2732)
+- 2733: fix @package Zend\_Validate should be Zend\_Validator
+ (https://github.com/zendframework/zf2/issues/2733)
+- 2734: fix i18n @package and @subpackage value
+ (https://github.com/zendframework/zf2/issues/2734)
+- 2736: fix captcha helper test.
+ (https://github.com/zendframework/zf2/issues/2736)
+- 2737: Issue #2728 - Bad Regex for Content Type header
+ (https://github.com/zendframework/zf2/issues/2737)
+- 2738: fix link 'quickstart' to version 2.0
+ (https://github.com/zendframework/zf2/issues/2738)
+- 2739: remove '@subpackage' because Zend\Math is not in subpackage
+ (https://github.com/zendframework/zf2/issues/2739)
+- 2742: remove () in echo-ing (https://github.com/zendframework/zf2/issues/2742)
+- 2749: Fix for #2678 (Zend\Db's Sqlsrv Driver)
+ (https://github.com/zendframework/zf2/issues/2749)
+- 2750: Adds the ability to instanciate by factory to AbstractPluginManager
+ (https://github.com/zendframework/zf2/issues/2750)
+- 2754: add the support to register module paths over namespace
+ (https://github.com/zendframework/zf2/issues/2754)
+- 2755: remove Zend\Mvc\Controller\PluginBroker from aliases in
+ "$defaultServiceConfig" (https://github.com/zendframework/zf2/issues/2755)
+- 2759: Fix Zend\Code\Scanner\TokenArrayScanner
+ (https://github.com/zendframework/zf2/issues/2759)
+- 2764: Fixed Zend\Math\Rand::getString() to pass the parameter $strong to
+ ::getBytes() (https://github.com/zendframework/zf2/issues/2764)
+- 2765: Csrf: always use dedicated setter
+ (https://github.com/zendframework/zf2/issues/2765)
+- 2766: Session\Storage: always preserve REQUEST\_ACCESS\_TIME
+ (https://github.com/zendframework/zf2/issues/2766)
+- 2768: Zend\Validator dependency is missed in Zend\Cache composer.json
+ (https://github.com/zendframework/zf2/issues/2768)
+- 2769: change valueToLDAP to valueToLdap and valueFromLDAP to valueFromLdap
+ (https://github.com/zendframework/zf2/issues/2769)
+- 2770: Memcached (https://github.com/zendframework/zf2/issues/2770)
+- 2775: Zend\Db\Sql: Fix for Mysql quoting during limit and offset
+ (https://github.com/zendframework/zf2/issues/2775)
+- 2776: Allow whitespace in Iban
+ (https://github.com/zendframework/zf2/issues/2776)
+- 2777: Fix issue when PREG\_BAD\_UTF8__OFFSET_ERROR is defined but Unicode support
+ is not enabled on PCRE (https://github.com/zendframework/zf2/issues/2777)
+- 2778: Undefined Index fix in ViewHelperManagerFactory
+ (https://github.com/zendframework/zf2/issues/2778)
+- 2779: Allow forms that have been added as fieldsets to bind values to bound
+ ob... (https://github.com/zendframework/zf2/issues/2779)
+- 2782: Issue 2781 (https://github.com/zendframework/zf2/issues/2782)
+
+
+## 2.0.2 (21 Sep 2012):
+
+- 2383: Changed unreserved char definition in Zend\Uri (ZF2-533) and added shell
+ escaping to the test runner (https://github.com/zendframework/zf2/pull/2383)
+- 2393: Trying to solve issue ZF2-558
+ (https://github.com/zendframework/zf2/pull/2393)
+- 2398: Segment route: add fix for optional groups within optional groups
+ (https://github.com/zendframework/zf2/pull/2398)
+- 2400: Use 'Router' in http env and 'HttpRouter' in cli
+ (https://github.com/zendframework/zf2/pull/2400)
+- 2401: Better precision for userland fmod algorithm
+ (https://github.com/zendframework/zf2/pull/2401)
+
+
+## 2.0.1 (20 Sep 2012):
+
+- 2285: Seed RouteMatch params as long as params is set. This permits setting an
+ empty array. (https://github.com/zendframework/zf2/pull/2285)
+- 2286: prepareNotFoundViewModel listner - eventResult as ViewModel if set
+ (https://github.com/zendframework/zf2/pull/2286)
+- 2290: $label only when filled
+ (https://github.com/zendframework/zf2/pull/2290)
+- 2292: Allow (int)0 in coomments count in entry feed
+ (https://github.com/zendframework/zf2/pull/2292)
+- 2295: force to check className parameters
+ (https://github.com/zendframework/zf2/pull/2295)
+- 2296: mini-fix in controller plugin manager
+ (https://github.com/zendframework/zf2/pull/2296)
+- 2297: fixed phpdoc in Zend\Mvc\ApplicationInterface
+ (https://github.com/zendframework/zf2/pull/2297)
+- 2298: Update to Date element use statements to make it clearer which DateTime
+ (https://github.com/zendframework/zf2/pull/2298)
+- 2300: FormRow translate label fix (#ZF2-516)
+ (https://github.com/zendframework/zf2/pull/2300)
+- 2302: Notifications now to #zftalk.dev
+ (https://github.com/zendframework/zf2/pull/2302)
+- 2306: Fix several cs (https://github.com/zendframework/zf2/pull/2306)
+- 2307: Removed comment about non existent Zend\_Tool
+ (https://github.com/zendframework/zf2/pull/2307)
+- 2308: Fix pluginmanager get method error
+ (https://github.com/zendframework/zf2/pull/2308)
+- 2309: Add consistency with event name
+ (https://github.com/zendframework/zf2/pull/2309)
+- 2310: Update library/Zend/Db/Sql/Select.php
+ (https://github.com/zendframework/zf2/pull/2310)
+- 2311: Version update (https://github.com/zendframework/zf2/pull/2311)
+- 2312: Validator Translations (https://github.com/zendframework/zf2/pull/2312)
+- 2313: ZF2-336: Zend\Form adds enctype attribute as multipart/form-data
+ (https://github.com/zendframework/zf2/pull/2313)
+- 2317: Make Fieldset constructor consistent with parent Element class
+ (https://github.com/zendframework/zf2/pull/2317)
+- 2321: ZF2-534 Zend\Log\Writer\Syslog prevents setting application name
+ (https://github.com/zendframework/zf2/pull/2321)
+- 2322: Jump to cache-storing instead of returning
+ (https://github.com/zendframework/zf2/pull/2322)
+- 2323: Conditional statements improved(minor changes).
+ (https://github.com/zendframework/zf2/pull/2323)
+- 2324: Fix for ZF2-517: Zend\Mail\Header\GenericHeader fails to parse empty
+ header (https://github.com/zendframework/zf2/pull/2324)
+- 2328: Wrong \_\_clone method (https://github.com/zendframework/zf2/pull/2328)
+- 2331: added validation support for optgroups
+ (https://github.com/zendframework/zf2/pull/2331)
+- 2332: README-GIT update with optional pre-commit hook
+ (https://github.com/zendframework/zf2/pull/2332)
+- 2334: Mail\Message::getSubject() should return value the way it was set
+ (https://github.com/zendframework/zf2/pull/2334)
+- 2335: ZF2-511 Updated refactored names and other fixes
+ (https://github.com/zendframework/zf2/pull/2335)
+- 2336: ZF-546 Remove duplicate check for time
+ (https://github.com/zendframework/zf2/pull/2336)
+- 2337: ZF2-539 Input type of image should not have attribute value
+ (https://github.com/zendframework/zf2/pull/2337)
+- 2338: ZF2-543: removed linked but not implemented cache adapters
+ (https://github.com/zendframework/zf2/pull/2338)
+- 2341: Updated Zend_Validate.php pt_BR translation to 25.Jul.2011 EN Revision
+ (https://github.com/zendframework/zf2/pull/2341)
+- 2342: ZF2-549 Zend\Log\Formatter\ErrorHandler does not handle complex events
+ (https://github.com/zendframework/zf2/pull/2342)
+- 2346: updated Page\Mvc::isActive to check if the controller param was
+ tinkered (https://github.com/zendframework/zf2/pull/2346)
+- 2349: Zend\Feed Added unittests for more code coverage
+ (https://github.com/zendframework/zf2/pull/2349)
+- 2350: Bug in Zend\ModuleManager\Listener\LocatorRegistrationListener
+ (https://github.com/zendframework/zf2/pull/2350)
+- 2351: ModuleManagerInterface is never used
+ (https://github.com/zendframework/zf2/pull/2351)
+- 2352: Hotfix for AbstractDb and Csrf Validators
+ (https://github.com/zendframework/zf2/pull/2352)
+- 2354: Update library/Zend/Feed/Writer/AbstractFeed.php
+ (https://github.com/zendframework/zf2/pull/2354)
+- 2355: Allow setting CsrfValidatorOptions in constructor
+ (https://github.com/zendframework/zf2/pull/2355)
+- 2356: Update library/Zend/Http/Cookies.php
+ (https://github.com/zendframework/zf2/pull/2356)
+- 2357: Update library/Zend/Barcode/Object/AbstractObject.php
+ (https://github.com/zendframework/zf2/pull/2357)
+- 2358: Update library/Zend/ServiceManager/AbstractPluginManager.php
+ (https://github.com/zendframework/zf2/pull/2358)
+- 2359: Update library/Zend/Server/Method/Parameter.php
+ (https://github.com/zendframework/zf2/pull/2359)
+- 2361: Zend\Form Added extra unit tests and some code improvements
+ (https://github.com/zendframework/zf2/pull/2361)
+- 2364: Remove unused use statements
+ (https://github.com/zendframework/zf2/pull/2364)
+- 2365: Resolve undefined classes and constants
+ (https://github.com/zendframework/zf2/pull/2365)
+- 2366: fixed typo in Zend\View\HelperPluginManager
+ (https://github.com/zendframework/zf2/pull/2366)
+- 2370: Error handling in AbstractWriter::write using Zend\Stdlib\ErrorHandler
+ (https://github.com/zendframework/zf2/pull/2370)
+- 2372: Update library/Zend/ServiceManager/Config.php
+ (https://github.com/zendframework/zf2/pull/2372)
+- 2375: zend-inputfilter already requires
+ (https://github.com/zendframework/zf2/pull/2375)
+- 2376: Activate the new GitHub feature: Contributing Guidelines
+ (https://github.com/zendframework/zf2/pull/2376)
+- 2377: Update library/Zend/Mvc/Controller/AbstractController.php
+ (https://github.com/zendframework/zf2/pull/2377)
+- 2379: Typo in property name in Zend/Db/Metadata/Object/AbstractTableObject.php
+ (https://github.com/zendframework/zf2/pull/2379)
+- 2382: PHPDoc params in AbstractTableGateway.php
+ (https://github.com/zendframework/zf2/pull/2382)
+- 2384: Replace Router with Http router in url view helper
+ (https://github.com/zendframework/zf2/pull/2384)
+- 2387: Replace PHP internal fmod function because it gives false negatives
+ (https://github.com/zendframework/zf2/pull/2387)
+- 2388: Proposed fix for ZF2-569 validating float with trailing 0's (10.0,
+ 10.10) (https://github.com/zendframework/zf2/pull/2388)
+- 2391: clone in Filter\FilterChain
+ (https://github.com/zendframework/zf2/pull/2391)
+- Security fix: a number of classes were not using the Escaper component in
+ order to perform URL, HTML, and/or HTML attribute escaping. Please see
+ http://framework.zend.com/security/advisory/ZF2012-03 for more details.
diff -Nru zendframework-1.10.4/composer.json zendframework-2.2.6/composer.json
--- zendframework-1.10.4/composer.json 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/composer.json 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,100 @@
+{
+ "name": "zendframework/zendframework",
+ "description": "Zend Framework 2",
+ "type": "library",
+ "keywords": [
+ "framework",
+ "zf2"
+ ],
+ "homepage": "http://framework.zend.com/",
+ "license": "BSD-3-Clause",
+ "require": {
+ "php": ">=5.3.3",
+ "zendframework/zendxml": "~1.0-dev"
+ },
+ "require-dev": {
+ "doctrine/annotations": ">=1.0",
+ "ircmaxell/random-lib": "dev-master",
+ "ircmaxell/security-lib": "dev-master",
+ "ocramius/proxy-manager": "0.4.*",
+ "fabpot/php-cs-fixer": "*@dev",
+ "phpunit/PHPUnit": "3.7.*"
+ },
+ "suggest": {
+ "ext-intl": "ext/intl for i18n features (included in default builds of PHP)",
+ "doctrine/annotations": "Doctrine Annotations >=1.0 for annotation features",
+ "ircmaxell/random-lib": "Fallback random byte generator for Zend\\Math\\Rand if OpenSSL/Mcrypt extensions are unavailable",
+ "ocramius/proxy-manager": "ProxyManager to handle lazy initialization of services",
+ "zendframework/zendpdf": "ZendPdf for creating PDF representations of barcodes",
+ "zendframework/zendservice-recaptcha": "ZendService\\ReCaptcha for rendering ReCaptchas in Zend\\Captcha and/or Zend\\Form"
+ },
+ "autoload": {
+ "psr-0": {
+ "Zend\\": "library/"
+ }
+ },
+ "bin": [
+ "bin/classmap_generator.php",
+ "bin/pluginmap_generator.php",
+ "bin/templatemap_generator.php"
+ ],
+ "replace": {
+ "zendframework/zend-authentication": "self.version",
+ "zendframework/zend-barcode": "self.version",
+ "zendframework/zend-cache": "self.version",
+ "zendframework/zend-captcha": "self.version",
+ "zendframework/zend-code": "self.version",
+ "zendframework/zend-config": "self.version",
+ "zendframework/zend-console": "self.version",
+ "zendframework/zend-crypt": "self.version",
+ "zendframework/zend-db": "self.version",
+ "zendframework/zend-debug": "self.version",
+ "zendframework/zend-di": "self.version",
+ "zendframework/zend-dom": "self.version",
+ "zendframework/zend-escaper": "self.version",
+ "zendframework/zend-eventmanager": "self.version",
+ "zendframework/zend-feed": "self.version",
+ "zendframework/zend-file": "self.version",
+ "zendframework/zend-filter": "self.version",
+ "zendframework/zend-form": "self.version",
+ "zendframework/zend-http": "self.version",
+ "zendframework/zend-i18n": "self.version",
+ "zendframework/zend-inputfilter": "self.version",
+ "zendframework/zend-json": "self.version",
+ "zendframework/zend-ldap": "self.version",
+ "zendframework/zend-loader": "self.version",
+ "zendframework/zend-log": "self.version",
+ "zendframework/zend-mail": "self.version",
+ "zendframework/zend-math": "self.version",
+ "zendframework/zend-memory": "self.version",
+ "zendframework/zend-mime": "self.version",
+ "zendframework/zend-modulemanager": "self.version",
+ "zendframework/zend-mvc": "self.version",
+ "zendframework/zend-navigation": "self.version",
+ "zendframework/zend-paginator": "self.version",
+ "zendframework/zend-permissions-acl": "self.version",
+ "zendframework/zend-permissions-rbac": "self.version",
+ "zendframework/zend-progressbar": "self.version",
+ "zendframework/zend-resources": "self.version",
+ "zendframework/zend-serializer": "self.version",
+ "zendframework/zend-server": "self.version",
+ "zendframework/zend-servicemanager": "self.version",
+ "zendframework/zend-session": "self.version",
+ "zendframework/zend-soap": "self.version",
+ "zendframework/zend-stdlib": "self.version",
+ "zendframework/zend-tag": "self.version",
+ "zendframework/zend-test": "self.version",
+ "zendframework/zend-text": "self.version",
+ "zendframework/zend-uri": "self.version",
+ "zendframework/zend-validator": "self.version",
+ "zendframework/zend-version": "self.version",
+ "zendframework/zend-view": "self.version",
+ "zendframework/zend-xmlrpc": "self.version"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev",
+ "dev-develop": "2.3-dev"
+ }
+ }
+}
diff -Nru zendframework-1.10.4/CONTRIBUTING.md zendframework-2.2.6/CONTRIBUTING.md
--- zendframework-1.10.4/CONTRIBUTING.md 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/CONTRIBUTING.md 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,91 @@
+# CONTRIBUTING
+
+## RESOURCES
+
+If you wish to contribute to Zend Framework, please be sure to
+read/subscribe to the following resources:
+
+ - Coding Standards:
+ http://framework.zend.com/wiki/display/ZFDEV2/Coding+Standards
+ - ZF Git Guide:
+ [README-GIT.md](README-GIT.md)
+ - Contributor's Guide:
+ http://framework.zend.com/participate/contributor-guide
+ - ZF Contributor's mailing list:
+ Archives: http://zend-framework-community.634137.n4.nabble.com/ZF-Contributor-f680267.html
+ Subscribe: zf-contributors-subscribe@lists.zend.com
+ - ZF Contributor's IRC channel:
+ #zftalk.dev on Freenode.net
+
+If you are working on new features, or refactoring an existing
+component, please create a proposal. You can do this in on the RFC's
+page, http://framework.zend.com/wiki/display/ZFDEV2/RFC%27s.
+
+## Reporting Potential Security Issues
+
+If you have encountered a potential security vulnerability in Zend Framework, please report it to us at [zf-security@zend.com](mailto:zf-security@zend.com). We will work with you to verify the vulnerability and patch it.
+
+When reporting issues, please provide the following information:
+
+- Component(s) affected
+- A description indicating how to reproduce the issue
+- A summary of the security vulnerability and impact
+
+We request that you contact us via the email address above and give the project contributors a chance to resolve the vulnerability and issue a new release prior to any public exposure; this helps protect Zend Framework users and provides them with a chance to upgrade and/or update in order to protect their applications.
+
+For sensitive email communications, please use [our PGP key](http://framework.zend.com/zf-security-pgp-key.asc).
+
+## RUNNING TESTS
+
+To run tests:
+
+- Make sure you have a recent version of PHPUnit installed; 3.7.0
+ minimally.
+- Enter the `tests/` subdirectory.
+- Execute PHPUnit, providing a path to a component directory for which
+ you wish to run tests, or a specific test class file.
+
+ ```sh
+ % phpunit ZendTest/Http
+ % phpunit ZendTest/Http/Header/EtagTest.php
+ ```
+
+- You may also provide the `--group` switch; in such cases, provide the
+ top-level component name:
+
+ ```sh
+ % phpunit --group Zend_Http
+ ```
+
+ This will likely lead to errors, so it's usually best to specify a
+ specific component in which to run test:
+
+ ```sh
+ % phpunit --group ZF-XYZ Zend/Http
+ ```
+- Alternately, use the `run-tests.php` script. This can be executed with no
+ arguments to run all tests:
+
+ ```sh
+ % php run-tests.php
+ ```
+
+ You can also provide top-level component names to run tests for individual
+ components or several components at a time. The component name is the the
+ component namespace, without the `Zend\` prefix:
+
+ ```sh
+ % php run-tests.php Mvc
+ ```
+
+ ```sh
+ % php run-tests.php ModuleManager Mvc View Navigation
+ ```
+
+You can turn on conditional tests with the TestConfiguration.php file.
+To do so:
+
+ - Enter the `tests/` subdirectory.
+ - Copy `TestConfiguration.php.dist` file to `TestConfiguration.php`
+ - Edit `TestConfiguration.php` to enable any specific functionality you
+ want to test, as well as to provide test values to utilize.
diff -Nru zendframework-1.10.4/debian/changelog zendframework-2.2.6/debian/changelog
--- zendframework-1.10.4/debian/changelog 2014-03-08 03:36:14.000000000 +0000
+++ zendframework-2.2.6/debian/changelog 2014-03-08 01:30:46.000000000 +0000
@@ -1,95 +1,8 @@
-zendframework (1.10.4-1) unstable; urgency=low
+zendframework (2.2.6-0ubuntu1) saucy; urgency=low
- * new upstream release
+ * new upstream bugfix release
+
+ A complete list of bugfixes you can find here:
+ http://framework.zend.com/changelog/2.2.6/
- -- Frank Habermann Wed, 28 Apr 2010 20:10:00 +0200
-
-zendframework (1.10.3-1) unstable; urgency=low
-
- * new upstream release
- * set debian source format
-
- -- Frank Habermann Mon, 5 Apr 2010 18:55:00 +0200
-
-zendframework (1.10.2-1) unstable; urgency=low
-
- * new upstream release
-
- -- Frank Habermann Sun, 28 Feb 2010 20:00:00 +0200
-
-zendframework (1.10.1-2) unstable; urgency=low
-
- * added manpage for zf command
- * changed Standards-Version to 3.8.4
-
- -- Frank Habermann Tue, 16 Feb 2010 21:00:00 +0200
-
-zendframework (1.10.1-1) unstable; urgency=low
-
- * new upstream release
-
- -- Frank Habermann Fri, 12 Feb 2010 21:40:00 +0200
-
-zendframework (1.10.0-1) unstable; urgency=low
-
- * new upstream release
-
- -- Frank Habermann Wed, 27 Jan 2010 20:50:00 +0200
-
-zendframework (1.9.7-1) unstable; urgency=low
-
- * new upstream release
-
- -- Frank Habermann Tue, 12 Jan 2010 22:00:00 +0200
-
-zendframework (1.9.6-2) unstable; urgency=low
-
- * use quillt to set paths for shell scripts
-
- -- Frank Habermann Mon, 28 Dec 2009 22:00:00 +0200
-
-zendframework (1.9.6-1) unstable; urgency=low
-
- * new upstream release
-
- -- Frank Habermann Sun, 06 Dec 2009 20:40:00 +0200
-
-zendframework (1.9.5-1) unstable; urgency=low
-
- * new upstream release
-
- -- Frank Habermann Sun, 28 Oct 2009 10:02:00 +0200
-
-zendframework (1.9.4-1) unstable; urgency=low
-
- * new upstream release
-
- -- Frank Habermann Sun, 17 Oct 2009 14:40:00 +0200
-
-zendframework (1.9.3pl1-1) unstable; urgency=low
-
- * new upstream release
- - corrects a BC break found in the 1.9.3 release
-
- -- Frank Habermann Sun, 27 Sep 2009 20:20:00 +0200
-
-zendframework (1.9.3-1) unstable; urgency=low
-
- * new upstream release
- - fixed more than 100 bugs in over 40 components
-
- -- Frank Habermann Tue, 22 Sep 2009 21:10:00 +0200
-
-zendframework (1.9.2-2) unstable; urgency=low
-
- * Fixed spelling (Closes: #547125)
- * Created bin package with that you can creat a default
- MVC environment (Closes: #544793)
-
- -- Frank Habermann Sun, 20 Sep 2009 13:45:00 +0200
-
-zendframework (1.9.2-1) unstable; urgency=low
-
- * Initial release.
-
- -- Frank Habermann Wed, 26 Aug 2009 21:15:00 +0200
+ -- Maurício Meneghini Fauth Fri, 07 Mar 2014 22:15:57 -0300
diff -Nru zendframework-1.10.4/debian/compat zendframework-2.2.6/debian/compat
--- zendframework-1.10.4/debian/compat 2014-03-08 03:36:14.000000000 +0000
+++ zendframework-2.2.6/debian/compat 2014-03-08 01:16:08.000000000 +0000
@@ -1 +1 @@
-7
+8
diff -Nru zendframework-1.10.4/debian/control zendframework-2.2.6/debian/control
--- zendframework-1.10.4/debian/control 2014-03-08 03:36:14.000000000 +0000
+++ zendframework-2.2.6/debian/control 2014-03-08 01:48:23.000000000 +0000
@@ -1,30 +1,886 @@
Source: zendframework
-Section: web
Priority: optional
-Maintainer: Frank Habermann
-Build-Depends: debhelper (>= 7.0.50~), quilt (>= 0.46-7)
-Standards-Version: 3.8.4
-Homepage: http://framework.zend.com
+Maintainer: Maurício Meneghini Fauth
+Build-Depends: debhelper (>= 8.0.0)
+Standards-Version: 3.9.4
+Section: php
+Homepage: http://framework.zend.com/
+Vcs-Git: https://github.com/zendframework/zf2.git
+Vcs-Browser: https://github.com/zendframework/zf2
Package: zendframework
+Section: php
Architecture: all
-Depends: ${misc:Depends}, php5
-Suggests: php5-curl, php5-gd, php5-imap, php5-ldap, php5-mysql, php5-pgsql, php5-json, php5-sqlite, php5-sqlite3
-Description: powerful PHP framework
- Extending the art & spirit of PHP, Zend Framework is based on simplicity,
- object-oriented best practices, corporate friendly licensing, and a rigorously
- tested agile codebase. Zend Framework is focused on building more secure,
- reliable, and modern Web 2.0 applications & web services, and consuming widely
- available APIs from leading vendors like Google, Amazon, Yahoo!, Flickr, as
- well as API providers and cataloguers like StrikeIron and ProgrammableWeb.
-
-Package: zendframework-bin
-Architecture: all
-Depends: ${misc:Depends}, zendframework, php5-cli
-Description: binary scripts for zendframework
- Extending the art & spirit of PHP, Zend Framework is based on simplicity,
- object-oriented best practices, corporate friendly licensing, and a rigorously
- tested agile codebase. Zend Framework is focused on building more secure,
- reliable, and modern Web 2.0 applications & web services, and consuming widely
- available APIs from leading vendors like Google, Amazon, Yahoo!, Flickr, as
- well as API providers and cataloguers like StrikeIron and ProgrammableWeb.
+Depends: ${misc:Depends}, libphp-zf
+Description: transitional dummy package for libphp-zf
+ This is a transitional dummy package. It can safely be removed.
+
+Package: zend-framework
+Section: php
+Architecture: all
+Depends: ${misc:Depends}, libphp-zf
+Description: transitional dummy package for libphp-zf
+ This is a transitional dummy package. It can safely be removed.
+
+Package: libzend-framework-php
+Section: php
+Architecture: all
+Depends: ${misc:Depends}, libphp-zf
+Description: transitional dummy package for libphp-zf
+ This is a transitional dummy package. It can safely be removed.
+
+Package: libphp-zf
+Section: php
+Architecture: all
+Depends: ${misc:Depends}, libphp-zf2.2
+Description: open source PHP framework
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+ .
+ This metapackage depends on the latest version of the Zend Framework.
+
+Package: libphp-zf2.2
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libphp-zf2.2-resources,
+ libphp-zf2.2-mod-authentication,
+ libphp-zf2.2-mod-barcode,
+ libphp-zf2.2-mod-cache,
+ libphp-zf2.2-mod-captcha,
+ libphp-zf2.2-mod-code,
+ libphp-zf2.2-mod-config,
+ libphp-zf2.2-mod-console,
+ libphp-zf2.2-mod-crypt,
+ libphp-zf2.2-mod-db,
+ libphp-zf2.2-mod-debug,
+ libphp-zf2.2-mod-di,
+ libphp-zf2.2-mod-dom,
+ libphp-zf2.2-mod-escaper,
+ libphp-zf2.2-mod-eventmanager,
+ libphp-zf2.2-mod-feed,
+ libphp-zf2.2-mod-file,
+ libphp-zf2.2-mod-filter,
+ libphp-zf2.2-mod-form,
+ libphp-zf2.2-mod-http,
+ libphp-zf2.2-mod-i18n,
+ libphp-zf2.2-mod-inputfilter,
+ libphp-zf2.2-mod-json,
+ libphp-zf2.2-mod-ldap,
+ libphp-zf2.2-mod-loader,
+ libphp-zf2.2-mod-log,
+ libphp-zf2.2-mod-mail,
+ libphp-zf2.2-mod-math,
+ libphp-zf2.2-mod-memory,
+ libphp-zf2.2-mod-mime,
+ libphp-zf2.2-mod-modulemanager,
+ libphp-zf2.2-mod-mvc,
+ libphp-zf2.2-mod-navigation,
+ libphp-zf2.2-mod-paginator,
+ libphp-zf2.2-mod-permissions-acl,
+ libphp-zf2.2-mod-permissions-rbac,
+ libphp-zf2.2-mod-progressbar,
+ libphp-zf2.2-mod-serializer,
+ libphp-zf2.2-mod-server,
+ libphp-zf2.2-mod-servicemanager,
+ libphp-zf2.2-mod-session,
+ libphp-zf2.2-mod-soap,
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-tag,
+ libphp-zf2.2-mod-test,
+ libphp-zf2.2-mod-text,
+ libphp-zf2.2-mod-uri,
+ libphp-zf2.2-mod-validator,
+ libphp-zf2.2-mod-version,
+ libphp-zf2.2-mod-view,
+ libphp-zf2.2-mod-xml,
+ libphp-zf2.2-mod-xmlrpc
+Recommends:
+Suggests:
+Conflicts: zendframework
+Replaces: zendframework
+Description: open source PHP framework
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+ .
+ This metapackage installs all components of Zend Framework.
+
+Package: libphp-zf2.2-resources
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3)
+Recommends:
+Suggests:
+Description: open source PHP framework, resources module
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-authentication
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests: libphp-zf2.2-mod-db, libphp-zf2.2-mod-crypt, libphp-zf2.2-mod-uri, libphp-zf2.2-mod-session
+Description: open source PHP framework, Zend-Authentication component
+ Provides an API for authentication and includes concrete authentication
+ adapters for common use case scenarios.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-barcode
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests: libphp-zf2.2-mod-validator
+Description: open source PHP framework, Zend-Barcode component
+ Provides a generic way to generate barcodes.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-cache
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-servicemanager,
+ libphp-zf2.2-mod-eventmanager
+Recommends: libphp-zf2.2-mod-serializer
+Suggests: libphp-zf2.2-mod-session,
+ php-apc (>= 3.1.6) | php-apcu,
+ php5-memcached (>= 1.0.0)
+Description: open source PHP framework, Zend-Cache component
+ Provides a generic way to cache any data.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-captcha
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-math
+Recommends:
+Suggests: libphp-zf2.2-resources
+Description: open source PHP framework, Zend-Captcha component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-code
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-eventmanager
+Recommends: doctrine
+Suggests:
+Description: open source PHP framework, Zend-Code component
+ Provides facilities to generate arbitrary code using an object oriented
+ interface.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-config
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests: libphp-zf2.2-mod-json, libphp-zf2.2-mod-servicemanager
+Description: open source PHP framework, Zend-Config component
+ Provides a nested object property based user interface for accessing
+ this configuration data within application code.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-console
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Console component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-crypt
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-math,
+ libphp-zf2.2-mod-servicemanager
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Crypt component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-db
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3)
+Recommends:
+Suggests: libphp-zf2.2-mod-stdlib
+Description: open source PHP framework, Zend-Db component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-debug
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-escaper
+Recommends:
+Suggests: php5-xdebug
+Description: open source PHP framework, Zend-Debug component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-di
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-code
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Di component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-dom
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Dom component
+ Provides tools for working with DOM documents and structures.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-escaper
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3)
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Escaper component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-eventmanager
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-EventManager component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-feed
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-escaper
+Recommends:
+Suggests: libphp-zf2.2-mod-http, libphp-zf2.2-mod-servicemanager, libphp-zf2.2-mod-validator
+Description: open source PHP framework, Zend-Feed component
+ Provides functionality for consuming RSS and Atom feeds.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-file
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-File component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-filter
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends: libphp-zf2.2-mod-crypt
+Suggests: libphp-zf2.2-mod-i18n, libphp-zf2.2-mod-uri, libphp-zf2.2-mod-validator
+Description: open source PHP framework, Zend-Filter component
+ Provides a set of commonly needed data filters.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-form
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-inputfilter
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Form component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-http
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-loader,
+ libphp-zf2.2-mod-uri,
+ libphp-zf2.2-mod-validator
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Http component
+ Provides an easy interface for performing Hyper-Text Transfer
+ Protocol (HTTP) requests.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-i18n
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests: libphp-zf2.2-mod-eventmanager, libphp-zf2.2-mod-filter, libphp-zf2.2-mod-validator, libphp-zf2.2-mod-view, libphp-zf2.2-resources, php5-intl
+Description: open source PHP framework, Zend-I18n component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-inputfilter
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-filter,
+ libphp-zf2.2-mod-validator
+Recommends:
+Suggests: libphp-zf2.2-mod-servicemanager
+Description: open source PHP framework, Zend-InputFilter component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-json
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests: libphp-zf2.2-mod-server
+Description: open source PHP framework, Zend-Json component
+ Provides convenience methods for serializing native PHP to JSON and decoding
+ JSON to native PHP.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-ldap
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Ldap component
+ Provides support for LDAP operations including but not limited to binding,
+ searching and modifying entries in an LDAP directory.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-loader
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3)
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Loader component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-log
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-servicemanager
+Recommends:
+Suggests: libphp-zf2.2-mod-db, libphp-zf2.2-mod-escaper, libphp-zf2.2-mod-mail, libphp-zf2.2-mod-validator, php5-mongo
+Description: open source PHP framework, Zend-Log component
+ Component for general purpose logging.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-mail
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-crypt,
+ libphp-zf2.2-mod-loader,
+ libphp-zf2.2-mod-mime
+Recommends:
+Suggests: libphp-zf2.2-mod-validator, libphp-zf2.2-mod-servicemanager
+Description: open source PHP framework, Zend-Mail component
+ Provides generalized functionality to compose and send both text and
+ MIME-compliant multipart e-mail messages.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-math
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3)
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Math component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-memory
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3)
+Recommends:
+Suggests: libphp-zf2.2-mod-cache
+Description: open source PHP framework, Zend-Memory component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-mime
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Mime component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-modulemanager
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-eventmanager
+Recommends:
+Suggests: libphp-zf2.2-mod-config, libphp-zf2.2-mod-loader, libphp-zf2.2-mod-servicemanager
+Description: open source PHP framework, Zend-ModuleManager component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-mvc
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-eventmanager,
+ libphp-zf2.2-mod-servicemanager
+Recommends:
+Suggests: libphp-zf2.2-mod-authentication,
+ libphp-zf2.2-mod-config,
+ libphp-zf2.2-mod-console,
+ libphp-zf2.2-mod-di,
+ libphp-zf2.2-mod-filter,
+ libphp-zf2.2-mod-http,
+ libphp-zf2.2-mod-form,
+ libphp-zf2.2-mod-i18n,
+ libphp-zf2.2-mod-inputfilter,
+ libphp-zf2.2-mod-modulemanager,
+ libphp-zf2.2-mod-serializer,
+ libphp-zf2.2-mod-session,
+ libphp-zf2.2-mod-text,
+ libphp-zf2.2-mod-uri,
+ libphp-zf2.2-mod-validator,
+ libphp-zf2.2-mod-view
+Description: open source PHP framework, Zend-Mvc component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-navigation
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests: libphp-zf2.2-mod-config, libphp-zf2.2-mod-mvc, libphp-zf2.2-mod-view
+Description: open source PHP framework, Zend-Navigation component
+ Provides support for managing trees of pointers to web pages.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-paginator
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Paginator component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-permissions-acl
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3)
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Permissions-Acl component
+ Provides a lightweight and flexible access control list (ACL) implementation
+ for privileges management.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-permissions-rbac
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3)
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Permissions-Rbac component
+ Provides a role-based access control management.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-progressbar
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests: libphp-zf2.2-mod-json
+Description: open source PHP framework, Zend-ProgressBar component
+ Component to create and update progressbars in different environments.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-serializer
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-json,
+ libphp-zf2.2-mod-math
+Recommends:
+Suggests: libphp-zf2.2-mod-servicemanager
+Description: open source PHP framework, Zend-Serializer component
+ Provides an adapter based interface to simply generate storable
+ representation of PHP types by different facilities, and recover.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-server
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-code
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Server component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-servicemanager
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3)
+Recommends:
+Suggests: libphp-zf2.2-mod-di
+Description: open source PHP framework, Zend-ServiceManager component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-session
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends:
+Suggests: libphp-zf2.2-mod-eventmanager, libphp-zf2.2-mod-servicemanager, libphp-zf2.2-mod-validator
+Description: open source PHP framework, Zend-Session component
+ Manage and preserve session data, a logical complement of cookie data,
+ across multiple page requests by the same client.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-soap
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-server,
+ libphp-zf2.2-mod-uri
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Soap component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-stdlib
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3)
+Recommends:
+Suggests: libphp-zf2.2-mod-eventmanager, libphp-zf2.2-mod-servicemanager
+Description: open source PHP framework, Zend-Stdlib component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-tag
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-escaper
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Tag component
+ A component suite which provides a facility to work with taggable Items.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-test
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ phpunit,
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-dom,
+ libphp-zf2.2-mod-eventmanager,
+ libphp-zf2.2-mod-http,
+ libphp-zf2.2-mod-mvc,
+ libphp-zf2.2-mod-servicemanager,
+ libphp-zf2.2-mod-uri,
+ libphp-zf2.2-mod-view
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Test component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-text
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-servicemanager
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Text component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-uri
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-escaper,
+ libphp-zf2.2-mod-validator
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-Uri component
+ A component that aids in manipulating and validating Uniform Resource
+ Identifiers (URIs).
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-validator
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib
+Recommends: libphp-zf2.2-mod-filter, libphp-zf2.2-mod-i18n, libphp-zf2.2-mod-math, libphp-zf2.2-mod-servicemanager, libphp-zf2.2-resources
+Suggests: libphp-zf2.2-mod-db, libphp-zf2.2-mod-uri
+Description: open source PHP framework, Zend-Validator component
+ Provides a set of commonly needed validators.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-version
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3)
+Recommends:
+Suggests: libphp-zf2.2-mod-json
+Description: open source PHP framework, Zend-Version component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-view
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-eventmanager,
+ libphp-zf2.2-mod-loader
+Recommends:
+Suggests: libphp-zf2.2-mod-filter, libphp-zf2.2-mod-servicemanager
+Description: open source PHP framework, Zend-View component
+ Provides a system of helpers, output filters, and variable escaping.
+ .
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-xml
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+Recommends: phpunit
+Suggests:
+Description: open source PHP framework, Zend-XmlRpc component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
+Package: libphp-zf2.2-mod-xmlrpc
+Section: php
+Architecture: all
+Depends: ${misc:Depends},
+ libapache2-mod-php5 (>= 5.3.3) | libapache2-mod-php5filter (>= 5.3.3) | php5-cgi (>= 5.3.3) | php5-fpm (>= 5.3.3) | php5 (>= 5.3.3),
+ php5-cli (>= 5.3.3),
+ libphp-zf2.2-mod-stdlib,
+ libphp-zf2.2-mod-http,
+ libphp-zf2.2-mod-math,
+ libphp-zf2.2-mod-server
+Recommends:
+Suggests:
+Description: open source PHP framework, Zend-XmlRpc component
+ Zend Framework is an open source, object-oriented web
+ application framework implemented in PHP 5.
+
diff -Nru zendframework-1.10.4/debian/copyright zendframework-2.2.6/debian/copyright
--- zendframework-1.10.4/debian/copyright 2014-03-08 03:36:14.000000000 +0000
+++ zendframework-2.2.6/debian/copyright 2014-03-08 01:34:47.000000000 +0000
@@ -1,32 +1,65 @@
-This package was debianized by Frank Habermann on
-Sun, 23 Aug 2009 20:48:00 +0200.
-
-It was downloaded from .
-
-Copyright (c) 2005-2009, Zend Technologies USA, Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- * Neither the name of Zend Technologies USA, Inc. nor the names of its
- contributors may be used to endorse or promote products derived from this
- software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: zendframework
+Source: http://framework.zend.com/
+
+Files: *
+Copyright: Copyright (c) 2005-2013, Zend Technologies USA, Inc.
+License: BSD-3-Clause~Zend
+
+Files: debian/*
+Copyright: 2013 Maurício Meneghini Fauth
+License: BSD-3-Clause
+
+License: BSD-3-Clause~Zend
+ Copyright (c) 2005-2013, Zend Technologies USA, Inc.
+ All rights reserved.
+ .
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+ .
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ .
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ .
+ * Neither the name of Zend Technologies USA, Inc. nor the names of its
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+License: BSD-3-Clause
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE HOLDERS OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff -Nru zendframework-1.10.4/debian/docs zendframework-2.2.6/debian/docs
--- zendframework-1.10.4/debian/docs 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/docs 2014-03-08 01:16:08.000000000 +0000
@@ -0,0 +1,3 @@
+LICENSE.txt
+README-GIT.md
+README.md
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-authentication.install zendframework-2.2.6/debian/libphp-zf2.2-mod-authentication.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-authentication.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-authentication.install 2013-11-23 04:23:47.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Authentication usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-barcode.install zendframework-2.2.6/debian/libphp-zf2.2-mod-barcode.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-barcode.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-barcode.install 2013-11-23 05:18:04.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Barcode usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-cache.install zendframework-2.2.6/debian/libphp-zf2.2-mod-cache.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-cache.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-cache.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Cache usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-captcha.install zendframework-2.2.6/debian/libphp-zf2.2-mod-captcha.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-captcha.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-captcha.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Captcha usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-code.install zendframework-2.2.6/debian/libphp-zf2.2-mod-code.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-code.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-code.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Code usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-config.install zendframework-2.2.6/debian/libphp-zf2.2-mod-config.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-config.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-config.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Config usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-console.install zendframework-2.2.6/debian/libphp-zf2.2-mod-console.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-console.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-console.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Console usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-crypt.install zendframework-2.2.6/debian/libphp-zf2.2-mod-crypt.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-crypt.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-crypt.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Crypt usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-db.install zendframework-2.2.6/debian/libphp-zf2.2-mod-db.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-db.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-db.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Db usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-debug.install zendframework-2.2.6/debian/libphp-zf2.2-mod-debug.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-debug.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-debug.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Debug usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-di.install zendframework-2.2.6/debian/libphp-zf2.2-mod-di.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-di.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-di.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Di usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-dom.install zendframework-2.2.6/debian/libphp-zf2.2-mod-dom.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-dom.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-dom.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Dom usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-escaper.install zendframework-2.2.6/debian/libphp-zf2.2-mod-escaper.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-escaper.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-escaper.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Escaper usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-eventmanager.install zendframework-2.2.6/debian/libphp-zf2.2-mod-eventmanager.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-eventmanager.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-eventmanager.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/EventManager usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-feed.install zendframework-2.2.6/debian/libphp-zf2.2-mod-feed.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-feed.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-feed.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Feed usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-file.install zendframework-2.2.6/debian/libphp-zf2.2-mod-file.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-file.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-file.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/File usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-filter.install zendframework-2.2.6/debian/libphp-zf2.2-mod-filter.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-filter.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-filter.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Filter usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-form.install zendframework-2.2.6/debian/libphp-zf2.2-mod-form.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-form.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-form.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Form usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-http.install zendframework-2.2.6/debian/libphp-zf2.2-mod-http.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-http.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-http.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Http usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-i18n.install zendframework-2.2.6/debian/libphp-zf2.2-mod-i18n.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-i18n.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-i18n.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/I18n usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-inputfilter.install zendframework-2.2.6/debian/libphp-zf2.2-mod-inputfilter.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-inputfilter.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-inputfilter.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/InputFilter usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-json.install zendframework-2.2.6/debian/libphp-zf2.2-mod-json.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-json.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-json.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Json usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-ldap.install zendframework-2.2.6/debian/libphp-zf2.2-mod-ldap.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-ldap.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-ldap.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Ldap usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-loader.install zendframework-2.2.6/debian/libphp-zf2.2-mod-loader.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-loader.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-loader.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Loader usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-log.install zendframework-2.2.6/debian/libphp-zf2.2-mod-log.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-log.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-log.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Log usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-mail.install zendframework-2.2.6/debian/libphp-zf2.2-mod-mail.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-mail.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-mail.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Mail usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-math.install zendframework-2.2.6/debian/libphp-zf2.2-mod-math.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-math.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-math.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Math usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-memory.install zendframework-2.2.6/debian/libphp-zf2.2-mod-memory.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-memory.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-memory.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Memory usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-mime.install zendframework-2.2.6/debian/libphp-zf2.2-mod-mime.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-mime.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-mime.install 2013-11-23 05:42:48.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Mime usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-modulemanager.install zendframework-2.2.6/debian/libphp-zf2.2-mod-modulemanager.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-modulemanager.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-modulemanager.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/ModuleManager usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-mvc.install zendframework-2.2.6/debian/libphp-zf2.2-mod-mvc.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-mvc.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-mvc.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Mvc usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-navigation.install zendframework-2.2.6/debian/libphp-zf2.2-mod-navigation.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-navigation.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-navigation.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Navigation usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-paginator.install zendframework-2.2.6/debian/libphp-zf2.2-mod-paginator.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-paginator.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-paginator.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Paginator usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-permissions-acl.install zendframework-2.2.6/debian/libphp-zf2.2-mod-permissions-acl.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-permissions-acl.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-permissions-acl.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Permissions/Acl usr/share/php/ZendFramework-2.2/library/Zend/Permissions
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-permissions-rbac.install zendframework-2.2.6/debian/libphp-zf2.2-mod-permissions-rbac.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-permissions-rbac.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-permissions-rbac.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Permissions/Rbac usr/share/php/ZendFramework-2.2/library/Zend/Permissions
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-progressbar.install zendframework-2.2.6/debian/libphp-zf2.2-mod-progressbar.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-progressbar.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-progressbar.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/ProgressBar usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-serializer.install zendframework-2.2.6/debian/libphp-zf2.2-mod-serializer.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-serializer.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-serializer.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Serializer usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-server.install zendframework-2.2.6/debian/libphp-zf2.2-mod-server.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-server.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-server.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Server usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-servicemanager.install zendframework-2.2.6/debian/libphp-zf2.2-mod-servicemanager.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-servicemanager.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-servicemanager.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/ServiceManager usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-session.install zendframework-2.2.6/debian/libphp-zf2.2-mod-session.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-session.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-session.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Session usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-soap.install zendframework-2.2.6/debian/libphp-zf2.2-mod-soap.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-soap.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-soap.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Soap usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-stdlib.install zendframework-2.2.6/debian/libphp-zf2.2-mod-stdlib.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-stdlib.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-stdlib.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Stdlib usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-tag.install zendframework-2.2.6/debian/libphp-zf2.2-mod-tag.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-tag.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-tag.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Tag usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-test.install zendframework-2.2.6/debian/libphp-zf2.2-mod-test.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-test.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-test.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Test usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-text.install zendframework-2.2.6/debian/libphp-zf2.2-mod-text.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-text.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-text.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Text usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-uri.install zendframework-2.2.6/debian/libphp-zf2.2-mod-uri.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-uri.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-uri.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Uri usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-validator.install zendframework-2.2.6/debian/libphp-zf2.2-mod-validator.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-validator.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-validator.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Validator usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-version.install zendframework-2.2.6/debian/libphp-zf2.2-mod-version.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-version.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-version.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/Version usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-view.install zendframework-2.2.6/debian/libphp-zf2.2-mod-view.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-view.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-view.install 2013-11-23 05:42:49.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/View usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-xml.install zendframework-2.2.6/debian/libphp-zf2.2-mod-xml.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-xml.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-xml.install 2014-03-08 01:45:01.000000000 +0000
@@ -0,0 +1 @@
+library/ZendXml usr/share/php/ZendFramework-2.2/library
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-mod-xmlrpc.install zendframework-2.2.6/debian/libphp-zf2.2-mod-xmlrpc.install
--- zendframework-1.10.4/debian/libphp-zf2.2-mod-xmlrpc.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-mod-xmlrpc.install 2013-11-23 05:42:58.000000000 +0000
@@ -0,0 +1 @@
+library/Zend/XmlRpc usr/share/php/ZendFramework-2.2/library/Zend
diff -Nru zendframework-1.10.4/debian/libphp-zf2.2-resources.install zendframework-2.2.6/debian/libphp-zf2.2-resources.install
--- zendframework-1.10.4/debian/libphp-zf2.2-resources.install 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/libphp-zf2.2-resources.install 2013-11-23 08:47:03.000000000 +0000
@@ -0,0 +1 @@
+resources usr/share/php/ZendFramework-2.2
diff -Nru zendframework-1.10.4/debian/manpage/zf.8 zendframework-2.2.6/debian/manpage/zf.8
--- zendframework-1.10.4/debian/manpage/zf.8 2014-03-08 03:36:14.000000000 +0000
+++ zendframework-2.2.6/debian/manpage/zf.8 1970-01-01 00:00:00.000000000 +0000
@@ -1,46 +0,0 @@
-.TH ZF 8 "2010-02-12" "1.10.1" "zendframework tool"
-
-.SH NAME
-zf \- command line tool for zendframework
-
-.SH SYNOPSIS
-\fBzf\fR [--global-opts] \fBaction-name\fR [--action-opts] \fBprovider-name\fR [--provider-opts] [provider parameters ...]
-
-.SH DESCRIPTION
-zf is a command line tool to create and manage zendframework projects.
-.PP
-The CLI, or command line tool (internally known as the console tool), is currently the primary interface for dispatching Zend_Tool requests. With the CLI tool, developers can issue tooling requests inside the "command line window", also commonly known as a "terminal" window.
-
-.SH OPTIONS
-.IP "zf show version mode[=mini] name-included[=1]" 4
-This will show the current version number of the copy of Zend Framework the zf.php tool is using.
-.IP "zf show manifest" 4
-This will show what information is in the tooling systems manifest. This is more important for provider developers than casual users of the tooling system.
-.IP "zf create project MyProjectName" 4
-The project provider is the first command you might want to run. This will setup the basic structure of your application. This is required before any of the other providers can be executed.
-.IP "zf create module Blog" 4
-This will create a module named Blog at application/modules/Blog, and all of the artifacts that a module will need.
-.IP "zf create controller Auth" 4
-This will create a controller named Auth, specifically it will create a file at application/controllers/AuthController.php with the AuthController inside.
-.IP "zf create action login Auth" 4
-This will create an action in an existing controller.
-.IP "zf create view Auth my-script-name" 4
-This will create a view script in the controller folder of Auth.
-.IP "zf create model User" 4
-This will create a model User.
-.IP "zf create form Auth" 4
-This will create a form Auth.
-.IP "zf configure dbadapter adapter=Pdo_Mysql&username=test&password=test&dbname=test" 4
-This will configure your database connection and is saved in your application.ini.
-.IP "zf create dbtable User user" 4
-This creates a Zend_Db_Table model/data file.
-.IP "zf enable layout" 4
-This enable layout in your application and creates necessary files and store this to your application.ini.
-
-.SH HOMEPAGE
-More information about zendframework project can be found at <\fIhttp://framework.zend.com/\fR>.
-
-.SH AUTHOR
-The development is currently coordinated by Zend Technologies Ltd. <\fIhttp://framework.zend.com\fR>.
-.PP
-This manual page was written by Frank Habermann <\fIlordlamer@lordlamer.de\fR>, for the Debian project (but may be used by others).
diff -Nru zendframework-1.10.4/debian/patches/01-zf-shell.patch zendframework-2.2.6/debian/patches/01-zf-shell.patch
--- zendframework-1.10.4/debian/patches/01-zf-shell.patch 2014-03-08 03:36:14.000000000 +0000
+++ zendframework-2.2.6/debian/patches/01-zf-shell.patch 1970-01-01 00:00:00.000000000 +0000
@@ -1,21 +0,0 @@
-Author: Frank Habermann
-Description: add shebang and set absolut path to php file
-
-diff -Naurp zendframework-1.9.6.orig/bin/zf.php zendframework-1.9.6/bin/zf.php
---- zendframework-1.9.6.orig/bin/zf.php 2009-09-07 21:48:34.000000000 +0000
-+++ zendframework-1.9.6/bin/zf.php 2009-12-06 19:40:47.000000000 +0000
-@@ -1,3 +1,4 @@
-+#!/usr/bin/php5
- Sun, 23 Aug 2008 20:48:00 +0200
diff -Nru zendframework-1.10.4/debian/README.source zendframework-2.2.6/debian/README.source
--- zendframework-1.10.4/debian/README.source 2014-03-08 03:36:14.000000000 +0000
+++ zendframework-2.2.6/debian/README.source 1970-01-01 00:00:00.000000000 +0000
@@ -1,17 +0,0 @@
-Source Access
--------------
-
-You can obtain the sources of this package with:
-
- $ apt-get source ${PACKAGE}
-
-whereas '${PACKAGE}' has to be replaced with the actual name of the package.
-
-This package may use the Quilt patch system to manage all modifications to the
-upstream source. Changes, if any, are stored in the source package as diffs in
-debian/diff and are applied during the build. Current modifications can be
-applied to the source tree with:
-
- $ quilt push -a
-
-More information about Quilt can be found in the quilt package.
diff -Nru zendframework-1.10.4/debian/rules zendframework-2.2.6/debian/rules
--- zendframework-1.10.4/debian/rules 2014-03-08 03:36:14.000000000 +0000
+++ zendframework-2.2.6/debian/rules 2014-03-08 01:16:08.000000000 +0000
@@ -1,16 +1,13 @@
#!/usr/bin/make -f
-%:
- dh ${@} --with quilt
-
-override_dh_auto_install:
- dh_auto_install
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
- install -D -m 0755 bin/zf.sh debian/zendframework-bin/usr/bin/zf
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
-override_dh_fixperms:
- dh_fixperms
-
- # setting rights
- find debian/zendframework/usr/share/php/Zend -type f | xargs chmod 0644
- chmod 755 debian/zendframework-bin/usr/share/zendframework/bin/zf.php
- chmod 755 debian/zendframework-bin/usr/bin/zf
+%:
+ dh $@
diff -Nru zendframework-1.10.4/debian/source/format zendframework-2.2.6/debian/source/format
--- zendframework-1.10.4/debian/source/format 2014-03-08 03:36:14.000000000 +0000
+++ zendframework-2.2.6/debian/source/format 2014-03-08 01:16:08.000000000 +0000
@@ -1 +1 @@
-1.0
+3.0 (quilt)
diff -Nru zendframework-1.10.4/debian/watch zendframework-2.2.6/debian/watch
--- zendframework-1.10.4/debian/watch 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/debian/watch 2013-11-23 02:37:40.000000000 +0000
@@ -0,0 +1,3 @@
+version = 3
+http://framework.zend.com/downloads/archives .*/ZendFramework-(\d[\d\.]*)\.(?:zip|tgz|tbz|txz|tar\.(?:gz|xz|bz2))
+# Vasudev Kamath 2012-12-21
diff -Nru zendframework-1.10.4/debian/zendframework-bin.install zendframework-2.2.6/debian/zendframework-bin.install
--- zendframework-1.10.4/debian/zendframework-bin.install 2014-03-08 03:36:14.000000000 +0000
+++ zendframework-2.2.6/debian/zendframework-bin.install 1970-01-01 00:00:00.000000000 +0000
@@ -1 +0,0 @@
-bin/zf.php /usr/share/zendframework/bin
diff -Nru zendframework-1.10.4/debian/zendframework-bin.manpages zendframework-2.2.6/debian/zendframework-bin.manpages
--- zendframework-1.10.4/debian/zendframework-bin.manpages 2014-03-08 03:36:14.000000000 +0000
+++ zendframework-2.2.6/debian/zendframework-bin.manpages 1970-01-01 00:00:00.000000000 +0000
@@ -1 +0,0 @@
-debian/manpage/*
diff -Nru zendframework-1.10.4/debian/zendframework.install zendframework-2.2.6/debian/zendframework.install
--- zendframework-1.10.4/debian/zendframework.install 2014-03-08 03:36:14.000000000 +0000
+++ zendframework-2.2.6/debian/zendframework.install 1970-01-01 00:00:00.000000000 +0000
@@ -1 +0,0 @@
-library/Zend /usr/share/php
diff -Nru zendframework-1.10.4/INSTALL.md zendframework-2.2.6/INSTALL.md
--- zendframework-1.10.4/INSTALL.md 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/INSTALL.md 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,63 @@
+# INSTALLATION
+
+Zend Framework requires no special installation steps. Simply download
+the framework, extract it to the folder you would like to keep it in,
+and add the library directory to your PHP `include_path`.
+
+
+## SYSTEM REQUIREMENTS
+-------------------
+
+Zend Framework 2 requires PHP 5.3.3 or later.
+
+## DEVELOPMENT VERSIONS
+
+If you would like to preview enhancements or bug fixes that have not yet
+been released, you can obtain the current development version of Zend
+Framework using one of the following methods:
+
+ - Using a Git client. Zend Framework is open source software, and the
+ Git repository used for its development is publicly available.
+ Consider using Git to get Zend Framework if you already use Git for
+ your application development, want to contribute back to the
+ framework, or need to upgrade your framework version very often.
+
+ - Checking out a working copy is necessary if you would like to directly
+ contribute to Zend Framework; a working copy can be updated any time
+ using git pull.
+
+To clone the git repository, use the following URL:
+
+git://git.zendframework.com/zf.git
+
+For more information about Git, please see the official website:
+
+http://www.git-scm.org
+
+## CONFIGURING THE INCLUDE PATH
+
+Once you have a copy of Zend Framework available, your application will
+need to access the framework classes. Though there are several ways to
+achieve this, your PHP `include_path` needs to contain the path to the
+Zend Framework classes under the `/library` directory in this
+distribution. You can find out more about the PHP `include_path`
+configuration directive here:
+
+http://www.php.net/manual/en/ini.core.php#ini.include-path
+
+Instructions on how to change PHP configuration directives can be found
+here:
+
+http://www.php.net/manual/en/configuration.changes.php
+
+## GETTING STARTED
+
+A great place to get up-to-speed quickly is the Zend Framework
+QuickStart:
+
+http://framework.zend.com/manual/2.2/en/user-guide/overview.html
+
+The QuickStart covers some of the most commonly used components of ZF.
+Since Zend Framework is designed with a use-at-will architecture and
+components are loosely coupled, you can select and use only those
+components that are needed for your project.
diff -Nru zendframework-1.10.4/INSTALL.txt zendframework-2.2.6/INSTALL.txt
--- zendframework-1.10.4/INSTALL.txt 2009-04-07 18:21:00.000000000 +0000
+++ zendframework-2.2.6/INSTALL.txt 1970-01-01 00:00:00.000000000 +0000
@@ -1,83 +0,0 @@
-INSTALLATION
-------------
-
-Zend Framework requires no special installation steps. Simply download the framework,
-extract it to the folder you would like to keep it in, and add the library directory
-to your PHP include_path. To use components in the extras library, add the extras/library
-directory to your PHP include_path, as well.
-If you would like to use Zend_Tool, simply add bin/zf.bat (for Windows) or
-bin/zf.sh (for anything else) to your system executable path.
-
-SYSTEM REQUIREMENTS
--------------------
-
-Zend Framework requires PHP 5.2.4 or later. Please see the system requirements
-appendix for more detailed information:
-
-http://framework.zend.com/manual/en/requirements.html
-
-DEVELOPMENT VERSIONS
---------------------
-
-If you would like to preview enhancements or bug fixes that have not yet been
-released, you can obtain the current development version of Zend Framework using one
-of the following methods:
-
-* Download the latest nightly snapshot. For those who care to brave the cutting
- (often bleeding) edge, the nightly snapshots represent the latest single-
- download development version of Zend Framework development. Snapshots are bundled
- with documentation in English only or in all available languages. If you anticipate
- updating to the latest development version of Zend Framework often, consider using
- Subversion as described below.
-
- http://framework.zend.com/download/snapshot
-
-* Using a Subversion (SVN) client. Zend Framework is open source software, and
- the Subversion repository used for its development is publicly available. Consider
- using SVN to get Zend Framework if you already use SVN for your application
- development, want to contribute back to the framework, or need to upgrade your
- framework version very often.
-
- Exporting is useful if you want to get a particular framework revision without the
- .svn directories as created in a working copy.
-
- Checking out a working copy is necessary if you would like to directly contribute
- to Zend Framework; a working copy can be updated any time with svn update.
-
- An externals definition is highly convenient for developers already using SVN to
- manage their application working copies.
-
- The URL for the trunk of the Zend Framework SVN repository is:
-
- http://framework.zend.com/svn/framework/trunk
-
- For more information about Subversion, please see the official website:
-
- http://subversion.tigris.org
-
-CONFIGURING THE INCLUDE PATH
-----------------------------
-
-Once you have a copy of Zend Framework available, your application will need to
-access the framework classes. Though there are several ways to achieve this, your
-PHP include_path needs to contain the path to the Zend Framework classes under the
-/library directory in this distribution. You can find out more about the PHP
-include_path configuration directive here:
-
-http://www.php.net/manual/en/ini.core.php#ini.include-path
-
-Instructions on how to change PHP configuration directives can be found here:
-
-http://www.php.net/manual/en/configuration.changes.php
-
-GETTING STARTED
----------------
-
-A great place to get up-to-speed quickly is the Zend Framework QuickStart:
-
-http://framework.zend.com/docs/quickstart
-
-The QuickStart covers some of the most commonly used components of ZF. Since
-Zend Framework is designed with a use-at-will architecture and components are
-loosely coupled, you can select and use only those components that are needed for
-your project.
diff -Nru zendframework-1.10.4/library/Zend/Acl/Assert/Interface.php zendframework-2.2.6/library/Zend/Acl/Assert/Interface.php
--- zendframework-1.10.4/library/Zend/Acl/Assert/Interface.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Acl/Assert/Interface.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,64 +0,0 @@
-_resourceId = (string) $resourceId;
- }
-
- /**
- * Defined by Zend_Acl_Resource_Interface; returns the Resource identifier
- *
- * @return string
- */
- public function getResourceId()
- {
- return $this->_resourceId;
- }
-
- /**
- * Defined by Zend_Acl_Resource_Interface; returns the Resource identifier
- * Proxies to getResourceId()
- *
- * @return string
- */
- public function __toString()
- {
- return $this->getResourceId();
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Acl/Role/Interface.php zendframework-2.2.6/library/Zend/Acl/Role/Interface.php
--- zendframework-1.10.4/library/Zend/Acl/Role/Interface.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Acl/Role/Interface.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,37 +0,0 @@
-getRoleId();
-
- if ($this->has($roleId)) {
- /**
- * @see Zend_Acl_Role_Registry_Exception
- */
- require_once 'Zend/Acl/Role/Registry/Exception.php';
- throw new Zend_Acl_Role_Registry_Exception("Role id '$roleId' already exists in the registry");
- }
-
- $roleParents = array();
-
- if (null !== $parents) {
- if (!is_array($parents)) {
- $parents = array($parents);
- }
- /**
- * @see Zend_Acl_Role_Registry_Exception
- */
- require_once 'Zend/Acl/Role/Registry/Exception.php';
- foreach ($parents as $parent) {
- try {
- if ($parent instanceof Zend_Acl_Role_Interface) {
- $roleParentId = $parent->getRoleId();
- } else {
- $roleParentId = $parent;
- }
- $roleParent = $this->get($roleParentId);
- } catch (Zend_Acl_Role_Registry_Exception $e) {
- throw new Zend_Acl_Role_Registry_Exception("Parent Role id '$roleParentId' does not exist", 0, $e);
- }
- $roleParents[$roleParentId] = $roleParent;
- $this->_roles[$roleParentId]['children'][$roleId] = $role;
- }
- }
-
- $this->_roles[$roleId] = array(
- 'instance' => $role,
- 'parents' => $roleParents,
- 'children' => array()
- );
-
- return $this;
- }
-
- /**
- * Returns the identified Role
- *
- * The $role parameter can either be a Role or a Role identifier.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @throws Zend_Acl_Role_Registry_Exception
- * @return Zend_Acl_Role_Interface
- */
- public function get($role)
- {
- if ($role instanceof Zend_Acl_Role_Interface) {
- $roleId = $role->getRoleId();
- } else {
- $roleId = (string) $role;
- }
-
- if (!$this->has($role)) {
- /**
- * @see Zend_Acl_Role_Registry_Exception
- */
- require_once 'Zend/Acl/Role/Registry/Exception.php';
- throw new Zend_Acl_Role_Registry_Exception("Role '$roleId' not found");
- }
-
- return $this->_roles[$roleId]['instance'];
- }
-
- /**
- * Returns true if and only if the Role exists in the registry
- *
- * The $role parameter can either be a Role or a Role identifier.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @return boolean
- */
- public function has($role)
- {
- if ($role instanceof Zend_Acl_Role_Interface) {
- $roleId = $role->getRoleId();
- } else {
- $roleId = (string) $role;
- }
-
- return isset($this->_roles[$roleId]);
- }
-
- /**
- * Returns an array of an existing Role's parents
- *
- * The array keys are the identifiers of the parent Roles, and the values are
- * the parent Role instances. The parent Roles are ordered in this array by
- * ascending priority. The highest priority parent Role, last in the array,
- * corresponds with the parent Role most recently added.
- *
- * If the Role does not have any parents, then an empty array is returned.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @uses Zend_Acl_Role_Registry::get()
- * @return array
- */
- public function getParents($role)
- {
- $roleId = $this->get($role)->getRoleId();
-
- return $this->_roles[$roleId]['parents'];
- }
-
- /**
- * Returns true if and only if $role inherits from $inherit
- *
- * Both parameters may be either a Role or a Role identifier. If
- * $onlyParents is true, then $role must inherit directly from
- * $inherit in order to return true. By default, this method looks
- * through the entire inheritance DAG to determine whether $role
- * inherits from $inherit through its ancestor Roles.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @param Zend_Acl_Role_Interface|string $inherit
- * @param boolean $onlyParents
- * @throws Zend_Acl_Role_Registry_Exception
- * @return boolean
- */
- public function inherits($role, $inherit, $onlyParents = false)
- {
- /**
- * @see Zend_Acl_Role_Registry_Exception
- */
- require_once 'Zend/Acl/Role/Registry/Exception.php';
- try {
- $roleId = $this->get($role)->getRoleId();
- $inheritId = $this->get($inherit)->getRoleId();
- } catch (Zend_Acl_Role_Registry_Exception $e) {
- throw new Zend_Acl_Role_Registry_Exception($e->getMessage(), $e->getCode(), $e);
- }
-
- $inherits = isset($this->_roles[$roleId]['parents'][$inheritId]);
-
- if ($inherits || $onlyParents) {
- return $inherits;
- }
-
- foreach ($this->_roles[$roleId]['parents'] as $parentId => $parent) {
- if ($this->inherits($parentId, $inheritId)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Removes the Role from the registry
- *
- * The $role parameter can either be a Role or a Role identifier.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @throws Zend_Acl_Role_Registry_Exception
- * @return Zend_Acl_Role_Registry Provides a fluent interface
- */
- public function remove($role)
- {
- /**
- * @see Zend_Acl_Role_Registry_Exception
- */
- require_once 'Zend/Acl/Role/Registry/Exception.php';
- try {
- $roleId = $this->get($role)->getRoleId();
- } catch (Zend_Acl_Role_Registry_Exception $e) {
- throw new Zend_Acl_Role_Registry_Exception($e->getMessage(), $e->getCode(), $e);
- }
-
- foreach ($this->_roles[$roleId]['children'] as $childId => $child) {
- unset($this->_roles[$childId]['parents'][$roleId]);
- }
- foreach ($this->_roles[$roleId]['parents'] as $parentId => $parent) {
- unset($this->_roles[$parentId]['children'][$roleId]);
- }
-
- unset($this->_roles[$roleId]);
-
- return $this;
- }
-
- /**
- * Removes all Roles from the registry
- *
- * @return Zend_Acl_Role_Registry Provides a fluent interface
- */
- public function removeAll()
- {
- $this->_roles = array();
-
- return $this;
- }
-
- public function getRoles()
- {
- return $this->_roles;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Acl/Role.php zendframework-2.2.6/library/Zend/Acl/Role.php
--- zendframework-1.10.4/library/Zend/Acl/Role.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Acl/Role.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,75 +0,0 @@
-_roleId = (string) $roleId;
- }
-
- /**
- * Defined by Zend_Acl_Role_Interface; returns the Role identifier
- *
- * @return string
- */
- public function getRoleId()
- {
- return $this->_roleId;
- }
-
- /**
- * Defined by Zend_Acl_Role_Interface; returns the Role identifier
- * Proxies to getRoleId()
- *
- * @return string
- */
- public function __toString()
- {
- return $this->getRoleId();
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Acl.php zendframework-2.2.6/library/Zend/Acl.php
--- zendframework-1.10.4/library/Zend/Acl.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Acl.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,1164 +0,0 @@
- array(
- 'allRoles' => array(
- 'allPrivileges' => array(
- 'type' => self::TYPE_DENY,
- 'assert' => null
- ),
- 'byPrivilegeId' => array()
- ),
- 'byRoleId' => array()
- ),
- 'byResourceId' => array()
- );
-
- /**
- * Adds a Role having an identifier unique to the registry
- *
- * The $parents parameter may be a reference to, or the string identifier for,
- * a Role existing in the registry, or $parents may be passed as an array of
- * these - mixing string identifiers and objects is ok - to indicate the Roles
- * from which the newly added Role will directly inherit.
- *
- * In order to resolve potential ambiguities with conflicting rules inherited
- * from different parents, the most recently added parent takes precedence over
- * parents that were previously added. In other words, the first parent added
- * will have the least priority, and the last parent added will have the
- * highest priority.
- *
- * @param Zend_Acl_Role_Interface $role
- * @param Zend_Acl_Role_Interface|string|array $parents
- * @uses Zend_Acl_Role_Registry::add()
- * @return Zend_Acl Provides a fluent interface
- */
- public function addRole($role, $parents = null)
- {
- if (is_string($role)) {
- $role = new Zend_Acl_Role($role);
- }
-
- if (!$role instanceof Zend_Acl_Role_Interface) {
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception('addRole() expects $role to be of type Zend_Acl_Role_Interface');
- }
-
-
- $this->_getRoleRegistry()->add($role, $parents);
-
- return $this;
- }
-
- /**
- * Returns the identified Role
- *
- * The $role parameter can either be a Role or Role identifier.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @uses Zend_Acl_Role_Registry::get()
- * @return Zend_Acl_Role_Interface
- */
- public function getRole($role)
- {
- return $this->_getRoleRegistry()->get($role);
- }
-
- /**
- * Returns true if and only if the Role exists in the registry
- *
- * The $role parameter can either be a Role or a Role identifier.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @uses Zend_Acl_Role_Registry::has()
- * @return boolean
- */
- public function hasRole($role)
- {
- return $this->_getRoleRegistry()->has($role);
- }
-
- /**
- * Returns true if and only if $role inherits from $inherit
- *
- * Both parameters may be either a Role or a Role identifier. If
- * $onlyParents is true, then $role must inherit directly from
- * $inherit in order to return true. By default, this method looks
- * through the entire inheritance DAG to determine whether $role
- * inherits from $inherit through its ancestor Roles.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @param Zend_Acl_Role_Interface|string $inherit
- * @param boolean $onlyParents
- * @uses Zend_Acl_Role_Registry::inherits()
- * @return boolean
- */
- public function inheritsRole($role, $inherit, $onlyParents = false)
- {
- return $this->_getRoleRegistry()->inherits($role, $inherit, $onlyParents);
- }
-
- /**
- * Removes the Role from the registry
- *
- * The $role parameter can either be a Role or a Role identifier.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @uses Zend_Acl_Role_Registry::remove()
- * @return Zend_Acl Provides a fluent interface
- */
- public function removeRole($role)
- {
- $this->_getRoleRegistry()->remove($role);
-
- if ($role instanceof Zend_Acl_Role_Interface) {
- $roleId = $role->getRoleId();
- } else {
- $roleId = $role;
- }
-
- foreach ($this->_rules['allResources']['byRoleId'] as $roleIdCurrent => $rules) {
- if ($roleId === $roleIdCurrent) {
- unset($this->_rules['allResources']['byRoleId'][$roleIdCurrent]);
- }
- }
- foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $visitor) {
- if (array_key_exists('byRoleId', $visitor)) {
- foreach ($visitor['byRoleId'] as $roleIdCurrent => $rules) {
- if ($roleId === $roleIdCurrent) {
- unset($this->_rules['byResourceId'][$resourceIdCurrent]['byRoleId'][$roleIdCurrent]);
- }
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Removes all Roles from the registry
- *
- * @uses Zend_Acl_Role_Registry::removeAll()
- * @return Zend_Acl Provides a fluent interface
- */
- public function removeRoleAll()
- {
- $this->_getRoleRegistry()->removeAll();
-
- foreach ($this->_rules['allResources']['byRoleId'] as $roleIdCurrent => $rules) {
- unset($this->_rules['allResources']['byRoleId'][$roleIdCurrent]);
- }
- foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $visitor) {
- foreach ($visitor['byRoleId'] as $roleIdCurrent => $rules) {
- unset($this->_rules['byResourceId'][$resourceIdCurrent]['byRoleId'][$roleIdCurrent]);
- }
- }
-
- return $this;
- }
-
- /**
- * Adds a Resource having an identifier unique to the ACL
- *
- * The $parent parameter may be a reference to, or the string identifier for,
- * the existing Resource from which the newly added Resource will inherit.
- *
- * @param Zend_Acl_Resource_Interface|string $resource
- * @param Zend_Acl_Resource_Interface|string $parent
- * @throws Zend_Acl_Exception
- * @return Zend_Acl Provides a fluent interface
- */
- public function addResource($resource, $parent = null)
- {
- if (is_string($resource)) {
- $resource = new Zend_Acl_Resource($resource);
- }
-
- if (!$resource instanceof Zend_Acl_Resource_Interface) {
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception('addResource() expects $resource to be of type Zend_Acl_Resource_Interface');
- }
-
- $resourceId = $resource->getResourceId();
-
- if ($this->has($resourceId)) {
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception("Resource id '$resourceId' already exists in the ACL");
- }
-
- $resourceParent = null;
-
- if (null !== $parent) {
- try {
- if ($parent instanceof Zend_Acl_Resource_Interface) {
- $resourceParentId = $parent->getResourceId();
- } else {
- $resourceParentId = $parent;
- }
- $resourceParent = $this->get($resourceParentId);
- } catch (Zend_Acl_Exception $e) {
- throw new Zend_Acl_Exception("Parent Resource id '$resourceParentId' does not exist", 0, $e);
- }
- $this->_resources[$resourceParentId]['children'][$resourceId] = $resource;
- }
-
- $this->_resources[$resourceId] = array(
- 'instance' => $resource,
- 'parent' => $resourceParent,
- 'children' => array()
- );
-
- return $this;
- }
-
- /**
- * Adds a Resource having an identifier unique to the ACL
- *
- * The $parent parameter may be a reference to, or the string identifier for,
- * the existing Resource from which the newly added Resource will inherit.
- *
- * @deprecated in version 1.9.1 and will be available till 2.0. New code
- * should use addResource() instead.
- *
- * @param Zend_Acl_Resource_Interface $resource
- * @param Zend_Acl_Resource_Interface|string $parent
- * @throws Zend_Acl_Exception
- * @return Zend_Acl Provides a fluent interface
- */
- public function add(Zend_Acl_Resource_Interface $resource, $parent = null)
- {
- return $this->addResource($resource, $parent);
- }
-
- /**
- * Returns the identified Resource
- *
- * The $resource parameter can either be a Resource or a Resource identifier.
- *
- * @param Zend_Acl_Resource_Interface|string $resource
- * @throws Zend_Acl_Exception
- * @return Zend_Acl_Resource_Interface
- */
- public function get($resource)
- {
- if ($resource instanceof Zend_Acl_Resource_Interface) {
- $resourceId = $resource->getResourceId();
- } else {
- $resourceId = (string) $resource;
- }
-
- if (!$this->has($resource)) {
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception("Resource '$resourceId' not found");
- }
-
- return $this->_resources[$resourceId]['instance'];
- }
-
- /**
- * Returns true if and only if the Resource exists in the ACL
- *
- * The $resource parameter can either be a Resource or a Resource identifier.
- *
- * @param Zend_Acl_Resource_Interface|string $resource
- * @return boolean
- */
- public function has($resource)
- {
- if ($resource instanceof Zend_Acl_Resource_Interface) {
- $resourceId = $resource->getResourceId();
- } else {
- $resourceId = (string) $resource;
- }
-
- return isset($this->_resources[$resourceId]);
- }
-
- /**
- * Returns true if and only if $resource inherits from $inherit
- *
- * Both parameters may be either a Resource or a Resource identifier. If
- * $onlyParent is true, then $resource must inherit directly from
- * $inherit in order to return true. By default, this method looks
- * through the entire inheritance tree to determine whether $resource
- * inherits from $inherit through its ancestor Resources.
- *
- * @param Zend_Acl_Resource_Interface|string $resource
- * @param Zend_Acl_Resource_Interface|string $inherit
- * @param boolean $onlyParent
- * @throws Zend_Acl_Resource_Registry_Exception
- * @return boolean
- */
- public function inherits($resource, $inherit, $onlyParent = false)
- {
- try {
- $resourceId = $this->get($resource)->getResourceId();
- $inheritId = $this->get($inherit)->getResourceId();
- } catch (Zend_Acl_Exception $e) {
- throw new Zend_Acl_Exception($e->getMessage(), $e->getCode(), $e);
- }
-
- if (null !== $this->_resources[$resourceId]['parent']) {
- $parentId = $this->_resources[$resourceId]['parent']->getResourceId();
- if ($inheritId === $parentId) {
- return true;
- } else if ($onlyParent) {
- return false;
- }
- } else {
- return false;
- }
-
- while (null !== $this->_resources[$parentId]['parent']) {
- $parentId = $this->_resources[$parentId]['parent']->getResourceId();
- if ($inheritId === $parentId) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Removes a Resource and all of its children
- *
- * The $resource parameter can either be a Resource or a Resource identifier.
- *
- * @param Zend_Acl_Resource_Interface|string $resource
- * @throws Zend_Acl_Exception
- * @return Zend_Acl Provides a fluent interface
- */
- public function remove($resource)
- {
- try {
- $resourceId = $this->get($resource)->getResourceId();
- } catch (Zend_Acl_Exception $e) {
- throw new Zend_Acl_Exception($e->getMessage(), $e->getCode(), $e);
- }
-
- $resourcesRemoved = array($resourceId);
- if (null !== ($resourceParent = $this->_resources[$resourceId]['parent'])) {
- unset($this->_resources[$resourceParent->getResourceId()]['children'][$resourceId]);
- }
- foreach ($this->_resources[$resourceId]['children'] as $childId => $child) {
- $this->remove($childId);
- $resourcesRemoved[] = $childId;
- }
-
- foreach ($resourcesRemoved as $resourceIdRemoved) {
- foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $rules) {
- if ($resourceIdRemoved === $resourceIdCurrent) {
- unset($this->_rules['byResourceId'][$resourceIdCurrent]);
- }
- }
- }
-
- unset($this->_resources[$resourceId]);
-
- return $this;
- }
-
- /**
- * Removes all Resources
- *
- * @return Zend_Acl Provides a fluent interface
- */
- public function removeAll()
- {
- foreach ($this->_resources as $resourceId => $resource) {
- foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $rules) {
- if ($resourceId === $resourceIdCurrent) {
- unset($this->_rules['byResourceId'][$resourceIdCurrent]);
- }
- }
- }
-
- $this->_resources = array();
-
- return $this;
- }
-
- /**
- * Adds an "allow" rule to the ACL
- *
- * @param Zend_Acl_Role_Interface|string|array $roles
- * @param Zend_Acl_Resource_Interface|string|array $resources
- * @param string|array $privileges
- * @param Zend_Acl_Assert_Interface $assert
- * @uses Zend_Acl::setRule()
- * @return Zend_Acl Provides a fluent interface
- */
- public function allow($roles = null, $resources = null, $privileges = null, Zend_Acl_Assert_Interface $assert = null)
- {
- return $this->setRule(self::OP_ADD, self::TYPE_ALLOW, $roles, $resources, $privileges, $assert);
- }
-
- /**
- * Adds a "deny" rule to the ACL
- *
- * @param Zend_Acl_Role_Interface|string|array $roles
- * @param Zend_Acl_Resource_Interface|string|array $resources
- * @param string|array $privileges
- * @param Zend_Acl_Assert_Interface $assert
- * @uses Zend_Acl::setRule()
- * @return Zend_Acl Provides a fluent interface
- */
- public function deny($roles = null, $resources = null, $privileges = null, Zend_Acl_Assert_Interface $assert = null)
- {
- return $this->setRule(self::OP_ADD, self::TYPE_DENY, $roles, $resources, $privileges, $assert);
- }
-
- /**
- * Removes "allow" permissions from the ACL
- *
- * @param Zend_Acl_Role_Interface|string|array $roles
- * @param Zend_Acl_Resource_Interface|string|array $resources
- * @param string|array $privileges
- * @uses Zend_Acl::setRule()
- * @return Zend_Acl Provides a fluent interface
- */
- public function removeAllow($roles = null, $resources = null, $privileges = null)
- {
- return $this->setRule(self::OP_REMOVE, self::TYPE_ALLOW, $roles, $resources, $privileges);
- }
-
- /**
- * Removes "deny" restrictions from the ACL
- *
- * @param Zend_Acl_Role_Interface|string|array $roles
- * @param Zend_Acl_Resource_Interface|string|array $resources
- * @param string|array $privileges
- * @uses Zend_Acl::setRule()
- * @return Zend_Acl Provides a fluent interface
- */
- public function removeDeny($roles = null, $resources = null, $privileges = null)
- {
- return $this->setRule(self::OP_REMOVE, self::TYPE_DENY, $roles, $resources, $privileges);
- }
-
- /**
- * Performs operations on ACL rules
- *
- * The $operation parameter may be either OP_ADD or OP_REMOVE, depending on whether the
- * user wants to add or remove a rule, respectively:
- *
- * OP_ADD specifics:
- *
- * A rule is added that would allow one or more Roles access to [certain $privileges
- * upon] the specified Resource(s).
- *
- * OP_REMOVE specifics:
- *
- * The rule is removed only in the context of the given Roles, Resources, and privileges.
- * Existing rules to which the remove operation does not apply would remain in the
- * ACL.
- *
- * The $type parameter may be either TYPE_ALLOW or TYPE_DENY, depending on whether the
- * rule is intended to allow or deny permission, respectively.
- *
- * The $roles and $resources parameters may be references to, or the string identifiers for,
- * existing Resources/Roles, or they may be passed as arrays of these - mixing string identifiers
- * and objects is ok - to indicate the Resources and Roles to which the rule applies. If either
- * $roles or $resources is null, then the rule applies to all Roles or all Resources, respectively.
- * Both may be null in order to work with the default rule of the ACL.
- *
- * The $privileges parameter may be used to further specify that the rule applies only
- * to certain privileges upon the Resource(s) in question. This may be specified to be a single
- * privilege with a string, and multiple privileges may be specified as an array of strings.
- *
- * If $assert is provided, then its assert() method must return true in order for
- * the rule to apply. If $assert is provided with $roles, $resources, and $privileges all
- * equal to null, then a rule having a type of:
- *
- * TYPE_ALLOW will imply a type of TYPE_DENY, and
- *
- * TYPE_DENY will imply a type of TYPE_ALLOW
- *
- * when the rule's assertion fails. This is because the ACL needs to provide expected
- * behavior when an assertion upon the default ACL rule fails.
- *
- * @param string $operation
- * @param string $type
- * @param Zend_Acl_Role_Interface|string|array $roles
- * @param Zend_Acl_Resource_Interface|string|array $resources
- * @param string|array $privileges
- * @param Zend_Acl_Assert_Interface $assert
- * @throws Zend_Acl_Exception
- * @uses Zend_Acl_Role_Registry::get()
- * @uses Zend_Acl::get()
- * @return Zend_Acl Provides a fluent interface
- */
- public function setRule($operation, $type, $roles = null, $resources = null, $privileges = null,
- Zend_Acl_Assert_Interface $assert = null)
- {
- // ensure that the rule type is valid; normalize input to uppercase
- $type = strtoupper($type);
- if (self::TYPE_ALLOW !== $type && self::TYPE_DENY !== $type) {
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception("Unsupported rule type; must be either '" . self::TYPE_ALLOW . "' or '"
- . self::TYPE_DENY . "'");
- }
-
- // ensure that all specified Roles exist; normalize input to array of Role objects or null
- if (!is_array($roles)) {
- $roles = array($roles);
- } else if (0 === count($roles)) {
- $roles = array(null);
- }
- $rolesTemp = $roles;
- $roles = array();
- foreach ($rolesTemp as $role) {
- if (null !== $role) {
- $roles[] = $this->_getRoleRegistry()->get($role);
- } else {
- $roles[] = null;
- }
- }
- unset($rolesTemp);
-
- // ensure that all specified Resources exist; normalize input to array of Resource objects or null
- if (!is_array($resources)) {
- $resources = array($resources);
- } else if (0 === count($resources)) {
- $resources = array(null);
- }
- $resourcesTemp = $resources;
- $resources = array();
- foreach ($resourcesTemp as $resource) {
- if (null !== $resource) {
- $resources[] = $this->get($resource);
- } else {
- $resources[] = null;
- }
- }
- unset($resourcesTemp);
-
- // normalize privileges to array
- if (null === $privileges) {
- $privileges = array();
- } else if (!is_array($privileges)) {
- $privileges = array($privileges);
- }
-
- switch ($operation) {
-
- // add to the rules
- case self::OP_ADD:
- foreach ($resources as $resource) {
- foreach ($roles as $role) {
- $rules =& $this->_getRules($resource, $role, true);
- if (0 === count($privileges)) {
- $rules['allPrivileges']['type'] = $type;
- $rules['allPrivileges']['assert'] = $assert;
- if (!isset($rules['byPrivilegeId'])) {
- $rules['byPrivilegeId'] = array();
- }
- } else {
- foreach ($privileges as $privilege) {
- $rules['byPrivilegeId'][$privilege]['type'] = $type;
- $rules['byPrivilegeId'][$privilege]['assert'] = $assert;
- }
- }
- }
- }
- break;
-
- // remove from the rules
- case self::OP_REMOVE:
- foreach ($resources as $resource) {
- foreach ($roles as $role) {
- $rules =& $this->_getRules($resource, $role);
- if (null === $rules) {
- continue;
- }
- if (0 === count($privileges)) {
- if (null === $resource && null === $role) {
- if ($type === $rules['allPrivileges']['type']) {
- $rules = array(
- 'allPrivileges' => array(
- 'type' => self::TYPE_DENY,
- 'assert' => null
- ),
- 'byPrivilegeId' => array()
- );
- }
- continue;
- }
-
- if (isset($rules['allPrivileges']['type']) &&
- $type === $rules['allPrivileges']['type'])
- {
- unset($rules['allPrivileges']);
- }
- } else {
- foreach ($privileges as $privilege) {
- if (isset($rules['byPrivilegeId'][$privilege]) &&
- $type === $rules['byPrivilegeId'][$privilege]['type'])
- {
- unset($rules['byPrivilegeId'][$privilege]);
- }
- }
- }
- }
- }
- break;
-
- default:
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception("Unsupported operation; must be either '" . self::OP_ADD . "' or '"
- . self::OP_REMOVE . "'");
- }
-
- return $this;
- }
-
- /**
- * Returns true if and only if the Role has access to the Resource
- *
- * The $role and $resource parameters may be references to, or the string identifiers for,
- * an existing Resource and Role combination.
- *
- * If either $role or $resource is null, then the query applies to all Roles or all Resources,
- * respectively. Both may be null to query whether the ACL has a "blacklist" rule
- * (allow everything to all). By default, Zend_Acl creates a "whitelist" rule (deny
- * everything to all), and this method would return false unless this default has
- * been overridden (i.e., by executing $acl->allow()).
- *
- * If a $privilege is not provided, then this method returns false if and only if the
- * Role is denied access to at least one privilege upon the Resource. In other words, this
- * method returns true if and only if the Role is allowed all privileges on the Resource.
- *
- * This method checks Role inheritance using a depth-first traversal of the Role registry.
- * The highest priority parent (i.e., the parent most recently added) is checked first,
- * and its respective parents are checked similarly before the lower-priority parents of
- * the Role are checked.
- *
- * @param Zend_Acl_Role_Interface|string $role
- * @param Zend_Acl_Resource_Interface|string $resource
- * @param string $privilege
- * @uses Zend_Acl::get()
- * @uses Zend_Acl_Role_Registry::get()
- * @return boolean
- */
- public function isAllowed($role = null, $resource = null, $privilege = null)
- {
- // reset role & resource to null
- $this->_isAllowedRole = null;
- $this->_isAllowedResource = null;
- $this->_isAllowedPrivilege = null;
-
- if (null !== $role) {
- // keep track of originally called role
- $this->_isAllowedRole = $role;
- $role = $this->_getRoleRegistry()->get($role);
- if (!$this->_isAllowedRole instanceof Zend_Acl_Role_Interface) {
- $this->_isAllowedRole = $role;
- }
- }
-
- if (null !== $resource) {
- // keep track of originally called resource
- $this->_isAllowedResource = $resource;
- $resource = $this->get($resource);
- if (!$this->_isAllowedResource instanceof Zend_Acl_Resource_Interface) {
- $this->_isAllowedResource = $resource;
- }
- }
-
- if (null === $privilege) {
- // query on all privileges
- do {
- // depth-first search on $role if it is not 'allRoles' pseudo-parent
- if (null !== $role && null !== ($result = $this->_roleDFSAllPrivileges($role, $resource, $privilege))) {
- return $result;
- }
-
- // look for rule on 'allRoles' psuedo-parent
- if (null !== ($rules = $this->_getRules($resource, null))) {
- foreach ($rules['byPrivilegeId'] as $privilege => $rule) {
- if (self::TYPE_DENY === ($ruleTypeOnePrivilege = $this->_getRuleType($resource, null, $privilege))) {
- return false;
- }
- }
- if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, null, null))) {
- return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
- }
- }
-
- // try next Resource
- $resource = $this->_resources[$resource->getResourceId()]['parent'];
-
- } while (true); // loop terminates at 'allResources' pseudo-parent
- } else {
- $this->_isAllowedPrivilege = $privilege;
- // query on one privilege
- do {
- // depth-first search on $role if it is not 'allRoles' pseudo-parent
- if (null !== $role && null !== ($result = $this->_roleDFSOnePrivilege($role, $resource, $privilege))) {
- return $result;
- }
-
- // look for rule on 'allRoles' pseudo-parent
- if (null !== ($ruleType = $this->_getRuleType($resource, null, $privilege))) {
- return self::TYPE_ALLOW === $ruleType;
- } else if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, null, null))) {
- return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
- }
-
- // try next Resource
- $resource = $this->_resources[$resource->getResourceId()]['parent'];
-
- } while (true); // loop terminates at 'allResources' pseudo-parent
- }
- }
-
- /**
- * Returns the Role registry for this ACL
- *
- * If no Role registry has been created yet, a new default Role registry
- * is created and returned.
- *
- * @return Zend_Acl_Role_Registry
- */
- protected function _getRoleRegistry()
- {
- if (null === $this->_roleRegistry) {
- $this->_roleRegistry = new Zend_Acl_Role_Registry();
- }
- return $this->_roleRegistry;
- }
-
- /**
- * Performs a depth-first search of the Role DAG, starting at $role, in order to find a rule
- * allowing/denying $role access to all privileges upon $resource
- *
- * This method returns true if a rule is found and allows access. If a rule exists and denies access,
- * then this method returns false. If no applicable rule is found, then this method returns null.
- *
- * @param Zend_Acl_Role_Interface $role
- * @param Zend_Acl_Resource_Interface $resource
- * @return boolean|null
- */
- protected function _roleDFSAllPrivileges(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null)
- {
- $dfs = array(
- 'visited' => array(),
- 'stack' => array()
- );
-
- if (null !== ($result = $this->_roleDFSVisitAllPrivileges($role, $resource, $dfs))) {
- return $result;
- }
-
- while (null !== ($role = array_pop($dfs['stack']))) {
- if (!isset($dfs['visited'][$role->getRoleId()])) {
- if (null !== ($result = $this->_roleDFSVisitAllPrivileges($role, $resource, $dfs))) {
- return $result;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Visits an $role in order to look for a rule allowing/denying $role access to all privileges upon $resource
- *
- * This method returns true if a rule is found and allows access. If a rule exists and denies access,
- * then this method returns false. If no applicable rule is found, then this method returns null.
- *
- * This method is used by the internal depth-first search algorithm and may modify the DFS data structure.
- *
- * @param Zend_Acl_Role_Interface $role
- * @param Zend_Acl_Resource_Interface $resource
- * @param array $dfs
- * @return boolean|null
- * @throws Zend_Acl_Exception
- */
- protected function _roleDFSVisitAllPrivileges(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null,
- &$dfs = null)
- {
- if (null === $dfs) {
- /**
- * @see Zend_Acl_Exception
- */
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception('$dfs parameter may not be null');
- }
-
- if (null !== ($rules = $this->_getRules($resource, $role))) {
- foreach ($rules['byPrivilegeId'] as $privilege => $rule) {
- if (self::TYPE_DENY === ($ruleTypeOnePrivilege = $this->_getRuleType($resource, $role, $privilege))) {
- return false;
- }
- }
- if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, $role, null))) {
- return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
- }
- }
-
- $dfs['visited'][$role->getRoleId()] = true;
- foreach ($this->_getRoleRegistry()->getParents($role) as $roleParentId => $roleParent) {
- $dfs['stack'][] = $roleParent;
- }
-
- return null;
- }
-
- /**
- * Performs a depth-first search of the Role DAG, starting at $role, in order to find a rule
- * allowing/denying $role access to a $privilege upon $resource
- *
- * This method returns true if a rule is found and allows access. If a rule exists and denies access,
- * then this method returns false. If no applicable rule is found, then this method returns null.
- *
- * @param Zend_Acl_Role_Interface $role
- * @param Zend_Acl_Resource_Interface $resource
- * @param string $privilege
- * @return boolean|null
- * @throws Zend_Acl_Exception
- */
- protected function _roleDFSOnePrivilege(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null,
- $privilege = null)
- {
- if (null === $privilege) {
- /**
- * @see Zend_Acl_Exception
- */
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception('$privilege parameter may not be null');
- }
-
- $dfs = array(
- 'visited' => array(),
- 'stack' => array()
- );
-
- if (null !== ($result = $this->_roleDFSVisitOnePrivilege($role, $resource, $privilege, $dfs))) {
- return $result;
- }
-
- while (null !== ($role = array_pop($dfs['stack']))) {
- if (!isset($dfs['visited'][$role->getRoleId()])) {
- if (null !== ($result = $this->_roleDFSVisitOnePrivilege($role, $resource, $privilege, $dfs))) {
- return $result;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Visits an $role in order to look for a rule allowing/denying $role access to a $privilege upon $resource
- *
- * This method returns true if a rule is found and allows access. If a rule exists and denies access,
- * then this method returns false. If no applicable rule is found, then this method returns null.
- *
- * This method is used by the internal depth-first search algorithm and may modify the DFS data structure.
- *
- * @param Zend_Acl_Role_Interface $role
- * @param Zend_Acl_Resource_Interface $resource
- * @param string $privilege
- * @param array $dfs
- * @return boolean|null
- * @throws Zend_Acl_Exception
- */
- protected function _roleDFSVisitOnePrivilege(Zend_Acl_Role_Interface $role, Zend_Acl_Resource_Interface $resource = null,
- $privilege = null, &$dfs = null)
- {
- if (null === $privilege) {
- /**
- * @see Zend_Acl_Exception
- */
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception('$privilege parameter may not be null');
- }
-
- if (null === $dfs) {
- /**
- * @see Zend_Acl_Exception
- */
- require_once 'Zend/Acl/Exception.php';
- throw new Zend_Acl_Exception('$dfs parameter may not be null');
- }
-
- if (null !== ($ruleTypeOnePrivilege = $this->_getRuleType($resource, $role, $privilege))) {
- return self::TYPE_ALLOW === $ruleTypeOnePrivilege;
- } else if (null !== ($ruleTypeAllPrivileges = $this->_getRuleType($resource, $role, null))) {
- return self::TYPE_ALLOW === $ruleTypeAllPrivileges;
- }
-
- $dfs['visited'][$role->getRoleId()] = true;
- foreach ($this->_getRoleRegistry()->getParents($role) as $roleParentId => $roleParent) {
- $dfs['stack'][] = $roleParent;
- }
-
- return null;
- }
-
- /**
- * Returns the rule type associated with the specified Resource, Role, and privilege
- * combination.
- *
- * If a rule does not exist or its attached assertion fails, which means that
- * the rule is not applicable, then this method returns null. Otherwise, the
- * rule type applies and is returned as either TYPE_ALLOW or TYPE_DENY.
- *
- * If $resource or $role is null, then this means that the rule must apply to
- * all Resources or Roles, respectively.
- *
- * If $privilege is null, then the rule must apply to all privileges.
- *
- * If all three parameters are null, then the default ACL rule type is returned,
- * based on whether its assertion method passes.
- *
- * @param Zend_Acl_Resource_Interface $resource
- * @param Zend_Acl_Role_Interface $role
- * @param string $privilege
- * @return string|null
- */
- protected function _getRuleType(Zend_Acl_Resource_Interface $resource = null, Zend_Acl_Role_Interface $role = null,
- $privilege = null)
- {
- // get the rules for the $resource and $role
- if (null === ($rules = $this->_getRules($resource, $role))) {
- return null;
- }
-
- // follow $privilege
- if (null === $privilege) {
- if (isset($rules['allPrivileges'])) {
- $rule = $rules['allPrivileges'];
- } else {
- return null;
- }
- } else if (!isset($rules['byPrivilegeId'][$privilege])) {
- return null;
- } else {
- $rule = $rules['byPrivilegeId'][$privilege];
- }
-
- // check assertion first
- if ($rule['assert']) {
- $assertion = $rule['assert'];
- $assertionValue = $assertion->assert(
- $this,
- ($this->_isAllowedRole instanceof Zend_Acl_Role_Interface) ? $this->_isAllowedRole : $role,
- ($this->_isAllowedResource instanceof Zend_Acl_Resource_Interface) ? $this->_isAllowedResource : $resource,
- $this->_isAllowedPrivilege
- );
- }
-
- if (null === $rule['assert'] || $assertionValue) {
- return $rule['type'];
- } else if (null !== $resource || null !== $role || null !== $privilege) {
- return null;
- } else if (self::TYPE_ALLOW === $rule['type']) {
- return self::TYPE_DENY;
- } else {
- return self::TYPE_ALLOW;
- }
- }
-
- /**
- * Returns the rules associated with a Resource and a Role, or null if no such rules exist
- *
- * If either $resource or $role is null, this means that the rules returned are for all Resources or all Roles,
- * respectively. Both can be null to return the default rule set for all Resources and all Roles.
- *
- * If the $create parameter is true, then a rule set is first created and then returned to the caller.
- *
- * @param Zend_Acl_Resource_Interface $resource
- * @param Zend_Acl_Role_Interface $role
- * @param boolean $create
- * @return array|null
- */
- protected function &_getRules(Zend_Acl_Resource_Interface $resource = null, Zend_Acl_Role_Interface $role = null,
- $create = false)
- {
- // create a reference to null
- $null = null;
- $nullRef =& $null;
-
- // follow $resource
- do {
- if (null === $resource) {
- $visitor =& $this->_rules['allResources'];
- break;
- }
- $resourceId = $resource->getResourceId();
- if (!isset($this->_rules['byResourceId'][$resourceId])) {
- if (!$create) {
- return $nullRef;
- }
- $this->_rules['byResourceId'][$resourceId] = array();
- }
- $visitor =& $this->_rules['byResourceId'][$resourceId];
- } while (false);
-
-
- // follow $role
- if (null === $role) {
- if (!isset($visitor['allRoles'])) {
- if (!$create) {
- return $nullRef;
- }
- $visitor['allRoles']['byPrivilegeId'] = array();
- }
- return $visitor['allRoles'];
- }
- $roleId = $role->getRoleId();
- if (!isset($visitor['byRoleId'][$roleId])) {
- if (!$create) {
- return $nullRef;
- }
- $visitor['byRoleId'][$roleId]['byPrivilegeId'] = array();
- }
- return $visitor['byRoleId'][$roleId];
- }
-
-
- /**
- * @return array of registered roles (Deprecated)
- * @deprecated Deprecated since version 1.10 (December 2009)
- */
- public function getRegisteredRoles()
- {
- trigger_error('The method getRegisteredRoles() was deprecated as of '
- . 'version 1.0, and may be removed. You\'re encouraged '
- . 'to use getRoles() instead.');
-
- return $this->_getRoleRegistry()->getRoles();
- }
-
- /**
- * @return array of registered roles
- */
- public function getRoles()
- {
- return array_keys($this->_getRoleRegistry()->getRoles());
- }
-
- /**
- * @return array of registered resources
- */
- public function getResources()
- {
- return array_keys($this->_resources);
- }
-
-}
-
diff -Nru zendframework-1.10.4/library/Zend/Amf/Adobe/Auth.php zendframework-2.2.6/library/Zend/Amf/Adobe/Auth.php
--- zendframework-1.10.4/library/Zend/Amf/Adobe/Auth.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Adobe/Auth.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,133 +0,0 @@
-_acl = new Zend_Acl();
- $xml = simplexml_load_file($rolefile);
-/*
-Roles file format:
-
-
-
-
-
-
-
-
-*/
- foreach($xml->role as $role) {
- $this->_acl->addRole(new Zend_Acl_Role((string)$role["id"]));
- foreach($role->user as $user) {
- $this->_users[(string)$user["name"]] = array("password" => (string)$user["password"],
- "role" => (string)$role["id"]);
- }
- }
- }
-
- /**
- * Get ACL with roles from XML file
- *
- * @return Zend_Acl
- */
- public function getAcl()
- {
- return $this->_acl;
- }
-
- /**
- * Perform authentication
- *
- * @throws Zend_Auth_Adapter_Exception
- * @return Zend_Auth_Result
- * @see Zend_Auth_Adapter_Interface#authenticate()
- */
- public function authenticate()
- {
- if (empty($this->_username) ||
- empty($this->_password)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Username/password should be set');
- }
-
- if(!isset($this->_users[$this->_username])) {
- return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND,
- null,
- array('Username not found')
- );
- }
-
- $user = $this->_users[$this->_username];
- if($user["password"] != $this->_password) {
- return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
- null,
- array('Authentication failed')
- );
- }
-
- $id = new stdClass();
- $id->role = $user["role"];
- $id->name = $this->_username;
- return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $id);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Adobe/DbInspector.php zendframework-2.2.6/library/Zend/Amf/Adobe/DbInspector.php
--- zendframework-1.10.4/library/Zend/Amf/Adobe/DbInspector.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Adobe/DbInspector.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,103 +0,0 @@
-describeTable('Pdo_Mysql',
- * array(
- * 'host' => '127.0.0.1',
- * 'username' => 'webuser',
- * 'password' => 'xxxxxxxx',
- * 'dbname' => 'test'
- * ),
- * 'mytable'
- * );
- *
- * @param string $dbType Database adapter type for Zend_Db
- * @param array|object $dbDescription Adapter-specific connection settings
- * @param string $tableName Table name
- * @return array Table description
- * @see Zend_Db::describeTable()
- * @see Zend_Db::factory()
- */
- public function describeTable($dbType, $dbDescription, $tableName)
- {
- $db = $this->_connect($dbType, $dbDescription);
- return $db->describeTable($tableName);
- }
-
- /**
- * Test database connection
- *
- * @param string $dbType Database adapter type for Zend_Db
- * @param array|object $dbDescription Adapter-specific connection settings
- * @return bool
- * @see Zend_Db::factory()
- */
- public function connect($dbType, $dbDescription)
- {
- $db = $this->_connect($dbType, $dbDescription);
- $db->listTables();
- return true;
- }
-
- /**
- * Get the list of database tables
- *
- * @param string $dbType Database adapter type for Zend_Db
- * @param array|object $dbDescription Adapter-specific connection settings
- * @return array List of the tables
- */
- public function getTables($dbType, $dbDescription)
- {
- $db = $this->_connect($dbType, $dbDescription);
- return $db->listTables();
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Adobe/Introspector.php zendframework-2.2.6/library/Zend/Amf/Adobe/Introspector.php
--- zendframework-1.10.4/library/Zend/Amf/Adobe/Introspector.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Adobe/Introspector.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,313 +0,0 @@
-_xml = new DOMDocument('1.0', 'utf-8');
- }
-
- /**
- * Create XML definition on an AMF service class
- *
- * @param string $serviceClass Service class name
- * @param array $options invocation options
- * @return string XML with service class introspection
- */
- public function introspect($serviceClass, $options = array())
- {
- $this->_options = $options;
-
- if (strpbrk($serviceClass, '\\/<>')) {
- return $this->_returnError('Invalid service name');
- }
-
- // Transform com.foo.Bar into com_foo_Bar
- $serviceClass = str_replace('.' , '_', $serviceClass);
-
- // Introspect!
- if (!class_exists($serviceClass)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($serviceClass, $this->_getServicePath());
- }
-
- $serv = $this->_xml->createElement('service-description');
- $serv->setAttribute('xmlns', 'http://ns.adobe.com/flex/service-description/2008');
-
- $this->_types = $this->_xml->createElement('types');
- $this->_ops = $this->_xml->createElement('operations');
-
- $r = Zend_Server_Reflection::reflectClass($serviceClass);
- $this->_addService($r, $this->_ops);
-
- $serv->appendChild($this->_types);
- $serv->appendChild($this->_ops);
- $this->_xml->appendChild($serv);
-
- return $this->_xml->saveXML();
- }
-
- /**
- * Authentication handler
- *
- * @param Zend_Acl $acl
- * @return unknown_type
- */
- public function initAcl(Zend_Acl $acl)
- {
- return false; // we do not need auth for this class
- }
-
- /**
- * Generate map of public class attributes
- *
- * @param string $typename type name
- * @param DOMElement $typexml target XML element
- * @return void
- */
- protected function _addClassAttributes($typename, DOMElement $typexml)
- {
- // Do not try to autoload here because _phpTypeToAS should
- // have already attempted to load this class
- if (!class_exists($typename, false)) {
- return;
- }
-
- $rc = new Zend_Reflection_Class($typename);
- foreach ($rc->getProperties() as $prop) {
- if (!$prop->isPublic()) {
- continue;
- }
-
- $propxml = $this->_xml->createElement('property');
- $propxml->setAttribute('name', $prop->getName());
-
- $type = $this->_registerType($this->_getPropertyType($prop));
- $propxml->setAttribute('type', $type);
-
- $typexml->appendChild($propxml);
- }
- }
-
- /**
- * Build XML service description from reflection class
- *
- * @param Zend_Server_Reflection_Class $refclass
- * @param DOMElement $target target XML element
- * @return void
- */
- protected function _addService(Zend_Server_Reflection_Class $refclass, DOMElement $target)
- {
- foreach ($refclass->getMethods() as $method) {
- if (!$method->isPublic()
- || $method->isConstructor()
- || ('__' == substr($method->name, 0, 2))
- ) {
- continue;
- }
-
- foreach ($method->getPrototypes() as $proto) {
- $op = $this->_xml->createElement('operation');
- $op->setAttribute('name', $method->getName());
-
- $rettype = $this->_registerType($proto->getReturnType());
- $op->setAttribute('returnType', $rettype);
-
- foreach ($proto->getParameters() as $param) {
- $arg = $this->_xml->createElement('argument');
- $arg->setAttribute('name', $param->getName());
-
- $type = $param->getType();
- if ($type == 'mixed' && ($pclass = $param->getClass())) {
- $type = $pclass->getName();
- }
-
- $ptype = $this->_registerType($type);
- $arg->setAttribute('type', $ptype);
-
- if($param->isDefaultValueAvailable()) {
- $arg->setAttribute('defaultvalue', $param->getDefaultValue());
- }
-
- $op->appendChild($arg);
- }
-
- $target->appendChild($op);
- }
- }
- }
-
- /**
- * Extract type of the property from DocBlock
- *
- * @param Zend_Reflection_Property $prop reflection property object
- * @return string Property type
- */
- protected function _getPropertyType(Zend_Reflection_Property $prop)
- {
- $docBlock = $prop->getDocComment();
-
- if (!$docBlock) {
- return 'Unknown';
- }
-
- if (!$docBlock->hasTag('var')) {
- return 'Unknown';
- }
-
- $tag = $docBlock->getTag('var');
- return trim($tag->getDescription());
- }
-
- /**
- * Get the array of service directories
- *
- * @return array Service class directories
- */
- protected function _getServicePath()
- {
- if (isset($this->_options['server'])) {
- return $this->_options['server']->getDirectory();
- }
-
- if (isset($this->_options['directories'])) {
- return $this->_options['directories'];
- }
-
- return array();
- }
-
- /**
- * Map from PHP type name to AS type name
- *
- * @param string $typename PHP type name
- * @return string AS type name
- */
- protected function _phpTypeToAS($typename)
- {
- if (class_exists($typename)) {
- $vars = get_class_vars($typename);
-
- if (isset($vars['_explicitType'])) {
- return $vars['_explicitType'];
- }
- }
-
- if (false !== ($asname = Zend_Amf_Parse_TypeLoader::getMappedClassName($typename))) {
- return $asname;
- }
-
- return $typename;
- }
-
- /**
- * Register new type on the system
- *
- * @param string $typename type name
- * @return string New type name
- */
- protected function _registerType($typename)
- {
- // Known type - return its AS name
- if (isset($this->_typesMap[$typename])) {
- return $this->_typesMap[$typename];
- }
-
- // Standard types
- if (in_array($typename, array('void', 'null', 'mixed', 'unknown_type'))) {
- return 'Unknown';
- }
-
- if (in_array($typename, array('int', 'integer', 'bool', 'boolean', 'float', 'string', 'object', 'Unknown', 'stdClass', 'array'))) {
- return $typename;
- }
-
- // Resolve and store AS name
- $asTypeName = $this->_phpTypeToAS($typename);
- $this->_typesMap[$typename] = $asTypeName;
-
- // Create element for the name
- $typeEl = $this->_xml->createElement('type');
- $typeEl->setAttribute('name', $asTypeName);
- $this->_addClassAttributes($typename, $typeEl);
- $this->_types->appendChild($typeEl);
-
- return $asTypeName;
- }
-
- /**
- * Return error with error message
- *
- * @param string $msg Error message
- * @return string
- */
- protected function _returnError($msg)
- {
- return 'ERROR: $msg';
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Auth/Abstract.php zendframework-2.2.6/library/Zend/Amf/Auth/Abstract.php
--- zendframework-1.10.4/library/Zend/Amf/Auth/Abstract.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Auth/Abstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,42 +0,0 @@
-_username = $username;
- $this->_password = $password;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Constants.php zendframework-2.2.6/library/Zend/Amf/Constants.php
--- zendframework-1.10.4/library/Zend/Amf/Constants.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Constants.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,87 +0,0 @@
-_stream->readByte();
- }
-
- switch($typeMarker) {
- // number
- case Zend_Amf_Constants::AMF0_NUMBER:
- return $this->_stream->readDouble();
-
- // boolean
- case Zend_Amf_Constants::AMF0_BOOLEAN:
- return (boolean) $this->_stream->readByte();
-
- // string
- case Zend_Amf_Constants::AMF0_STRING:
- return $this->_stream->readUTF();
-
- // object
- case Zend_Amf_Constants::AMF0_OBJECT:
- return $this->readObject();
-
- // null
- case Zend_Amf_Constants::AMF0_NULL:
- return null;
-
- // undefined
- case Zend_Amf_Constants::AMF0_UNDEFINED:
- return null;
-
- // Circular references are returned here
- case Zend_Amf_Constants::AMF0_REFERENCE:
- return $this->readReference();
-
- // mixed array with numeric and string keys
- case Zend_Amf_Constants::AMF0_MIXEDARRAY:
- return $this->readMixedArray();
-
- // array
- case Zend_Amf_Constants::AMF0_ARRAY:
- return $this->readArray();
-
- // date
- case Zend_Amf_Constants::AMF0_DATE:
- return $this->readDate();
-
- // longString strlen(string) > 2^16
- case Zend_Amf_Constants::AMF0_LONGSTRING:
- return $this->_stream->readLongUTF();
-
- //internal AS object, not supported
- case Zend_Amf_Constants::AMF0_UNSUPPORTED:
- return null;
-
- // XML
- case Zend_Amf_Constants::AMF0_XML:
- return $this->readXmlString();
-
- // typed object ie Custom Class
- case Zend_Amf_Constants::AMF0_TYPEDOBJECT:
- return $this->readTypedObject();
-
- //AMF3-specific
- case Zend_Amf_Constants::AMF0_AMF3:
- return $this->readAmf3TypeMarker();
-
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unsupported marker type: ' . $typeMarker);
- }
- }
-
- /**
- * Read AMF objects and convert to PHP objects
- *
- * Read the name value pair objects form the php message and convert them to
- * a php object class.
- *
- * Called when the marker type is 3.
- *
- * @param array|null $object
- * @return object
- */
- public function readObject($object = null)
- {
- if ($object === null) {
- $object = array();
- }
-
- while (true) {
- $key = $this->_stream->readUTF();
- $typeMarker = $this->_stream->readByte();
- if ($typeMarker != Zend_Amf_Constants::AMF0_OBJECTTERM ){
- //Recursivly call readTypeMarker to get the types of properties in the object
- $object[$key] = $this->readTypeMarker($typeMarker);
- } else {
- //encountered AMF object terminator
- break;
- }
- }
- $this->_reference[] = $object;
- return (object) $object;
- }
-
- /**
- * Read reference objects
- *
- * Used to gain access to the private array of reference objects.
- * Called when marker type is 7.
- *
- * @return object
- * @throws Zend_Amf_Exception for invalid reference keys
- */
- public function readReference()
- {
- $key = $this->_stream->readInt();
- if (!array_key_exists($key, $this->_reference)) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Invalid reference key: '. $key);
- }
- return $this->_reference[$key];
- }
-
- /**
- * Reads an array with numeric and string indexes.
- *
- * Called when marker type is 8
- *
- * @todo As of Flash Player 9 there is not support for mixed typed arrays
- * so we handle this as an object. With the introduction of vectors
- * in Flash Player 10 this may need to be reconsidered.
- * @return array
- */
- public function readMixedArray()
- {
- $length = $this->_stream->readLong();
- return $this->readObject();
- }
-
- /**
- * Converts numerically indexed actiosncript arrays into php arrays.
- *
- * Called when marker type is 10
- *
- * @return array
- */
- public function readArray()
- {
- $length = $this->_stream->readLong();
- $array = array();
- while ($length--) {
- $array[] = $this->readTypeMarker();
- }
- return $array;
- }
-
- /**
- * Convert AS Date to Zend_Date
- *
- * @return Zend_Date
- */
- public function readDate()
- {
- // get the unix time stamp. Not sure why ActionScript does not use
- // milliseconds
- $timestamp = floor($this->_stream->readDouble() / 1000);
-
- // The timezone offset is never returned to the server; it is always 0,
- // so read and ignore.
- $offset = $this->_stream->readInt();
-
- require_once 'Zend/Date.php';
- $date = new Zend_Date($timestamp);
- return $date;
- }
-
- /**
- * Convert XML to SimpleXml
- * If user wants DomDocument they can use dom_import_simplexml
- *
- * @return SimpleXml Object
- */
- public function readXmlString()
- {
- $string = $this->_stream->readLongUTF();
- return simplexml_load_string($string);
- }
-
- /**
- * Read Class that is to be mapped to a server class.
- *
- * Commonly used for Value Objects on the server
- *
- * @todo implement Typed Class mapping
- * @return object|array
- * @throws Zend_Amf_Exception if unable to load type
- */
- public function readTypedObject()
- {
- require_once 'Zend/Amf/Parse/TypeLoader.php';
- // get the remote class name
- $className = $this->_stream->readUTF();
- $loader = Zend_Amf_Parse_TypeLoader::loadType($className);
- $returnObject = new $loader();
- $properties = get_object_vars($this->readObject());
- foreach($properties as $key=>$value) {
- if($key) {
- $returnObject->$key = $value;
- }
- }
- if($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
- $returnObject = get_object_vars($returnObject);
- }
- return $returnObject;
- }
-
- /**
- * AMF3 data type encountered load AMF3 Deserializer to handle
- * type markers.
- *
- * @return string
- */
- public function readAmf3TypeMarker()
- {
- require_once 'Zend/Amf/Parse/Amf3/Deserializer.php';
- $deserializer = new Zend_Amf_Parse_Amf3_Deserializer($this->_stream);
- $this->_objectEncoding = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
- return $deserializer->readTypeMarker();
- }
-
- /**
- * Return the object encoding to check if an AMF3 object
- * is going to be return.
- *
- * @return int
- */
- public function getObjectEncoding()
- {
- return $this->_objectEncoding;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Parse/Amf0/Serializer.php zendframework-2.2.6/library/Zend/Amf/Parse/Amf0/Serializer.php
--- zendframework-1.10.4/library/Zend/Amf/Parse/Amf0/Serializer.php 2010-04-22 03:54:59.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Parse/Amf0/Serializer.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,362 +0,0 @@
-writeObjectReference($data, $markerType)) {
- // Write the Type Marker to denote the following action script data type
- $this->_stream->writeByte($markerType);
- switch($markerType) {
- case Zend_Amf_Constants::AMF0_NUMBER:
- $this->_stream->writeDouble($data);
- break;
- case Zend_Amf_Constants::AMF0_BOOLEAN:
- $this->_stream->writeByte($data);
- break;
- case Zend_Amf_Constants::AMF0_STRING:
- $this->_stream->writeUTF($data);
- break;
- case Zend_Amf_Constants::AMF0_OBJECT:
- $this->writeObject($data);
- break;
- case Zend_Amf_Constants::AMF0_NULL:
- break;
- case Zend_Amf_Constants::AMF0_REFERENCE:
- $this->_stream->writeInt($data);
- break;
- case Zend_Amf_Constants::AMF0_MIXEDARRAY:
- // Write length of numeric keys as zero.
- $this->_stream->writeLong(0);
- $this->writeObject($data);
- break;
- case Zend_Amf_Constants::AMF0_ARRAY:
- $this->writeArray($data);
- break;
- case Zend_Amf_Constants::AMF0_DATE:
- $this->writeDate($data);
- break;
- case Zend_Amf_Constants::AMF0_LONGSTRING:
- $this->_stream->writeLongUTF($data);
- break;
- case Zend_Amf_Constants::AMF0_TYPEDOBJECT:
- $this->writeTypedObject($data);
- break;
- case Zend_Amf_Constants::AMF0_AMF3:
- $this->writeAmf3TypeMarker($data);
- break;
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception("Unknown Type Marker: " . $markerType);
- }
- }
- } else {
- if (is_resource($data)) {
- $data = Zend_Amf_Parse_TypeLoader::handleResource($data);
- }
- switch (true) {
- case (is_int($data) || is_float($data)):
- $markerType = Zend_Amf_Constants::AMF0_NUMBER;
- break;
- case (is_bool($data)):
- $markerType = Zend_Amf_Constants::AMF0_BOOLEAN;
- break;
- case (is_string($data) && (strlen($data) > 65536)):
- $markerType = Zend_Amf_Constants::AMF0_LONGSTRING;
- break;
- case (is_string($data)):
- $markerType = Zend_Amf_Constants::AMF0_STRING;
- break;
- case (is_object($data)):
- if (($data instanceof DateTime) || ($data instanceof Zend_Date)) {
- $markerType = Zend_Amf_Constants::AMF0_DATE;
- } else {
-
- if($className = $this->getClassName($data)){
- //Object is a Typed object set classname
- $markerType = Zend_Amf_Constants::AMF0_TYPEDOBJECT;
- $this->_className = $className;
- } else {
- // Object is a generic classname
- $markerType = Zend_Amf_Constants::AMF0_OBJECT;
- }
- break;
- }
- break;
- case (null === $data):
- $markerType = Zend_Amf_Constants::AMF0_NULL;
- break;
- case (is_array($data)):
- // check if it is an associative array
- $i = 0;
- foreach (array_keys($data) as $key) {
- // check if it contains non-integer keys
- if (!is_numeric($key) || intval($key) != $key) {
- $markerType = Zend_Amf_Constants::AMF0_OBJECT;
- break;
- // check if it is a sparse indexed array
- } else if ($key != $i) {
- $markerType = Zend_Amf_Constants::AMF0_MIXEDARRAY;
- break;
- }
- $i++;
- }
- // Dealing with a standard numeric array
- if(!$markerType){
- $markerType = Zend_Amf_Constants::AMF0_ARRAY;
- break;
- }
- break;
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unsupported data type: ' . gettype($data));
- }
-
- $this->writeTypeMarker($data, $markerType);
- }
- return $this;
- }
-
- /**
- * Check if the given object is in the reference table, write the reference if it exists,
- * otherwise add the object to the reference table
- *
- * @param mixed $object object reference to check for reference
- * @param $markerType AMF type of the object to write
- * @param mixed $objectByVal object to check for reference
- * @return Boolean true, if the reference was written, false otherwise
- */
- protected function writeObjectReference(&$object, $markerType, $objectByVal = false)
- {
- // Workaround for PHP5 with E_STRICT enabled complaining about "Only
- // variables should be passed by reference"
- if ((null === $object) && ($objectByVal !== false)) {
- $object = &$objectByVal;
- }
-
- if ($markerType == Zend_Amf_Constants::AMF0_OBJECT
- || $markerType == Zend_Amf_Constants::AMF0_MIXEDARRAY
- || $markerType == Zend_Amf_Constants::AMF0_ARRAY
- || $markerType == Zend_Amf_Constants::AMF0_TYPEDOBJECT
- ) {
- $ref = array_search($object, $this->_referenceObjects, true);
- //handle object reference
- if($ref !== false){
- $this->writeTypeMarker($ref,Zend_Amf_Constants::AMF0_REFERENCE);
- return true;
- }
-
- $this->_referenceObjects[] = $object;
- }
-
- return false;
- }
-
- /**
- * Write a PHP array with string or mixed keys.
- *
- * @param object $data
- * @return Zend_Amf_Parse_Amf0_Serializer
- */
- public function writeObject($object)
- {
- // Loop each element and write the name of the property.
- foreach ($object as $key => &$value) {
- // skip variables starting with an _ private transient
- if( $key[0] == "_") continue;
- $this->_stream->writeUTF($key);
- $this->writeTypeMarker($value);
- }
-
- // Write the end object flag
- $this->_stream->writeInt(0);
- $this->_stream->writeByte(Zend_Amf_Constants::AMF0_OBJECTTERM);
- return $this;
- }
-
- /**
- * Write a standard numeric array to the output stream. If a mixed array
- * is encountered call writeTypeMarker with mixed array.
- *
- * @param array $array
- * @return Zend_Amf_Parse_Amf0_Serializer
- */
- public function writeArray(&$array)
- {
- $length = count($array);
- if (!$length < 0) {
- // write the length of the array
- $this->_stream->writeLong(0);
- } else {
- // Write the length of the numeric array
- $this->_stream->writeLong($length);
- for ($i=0; $i<$length; $i++) {
- $value = isset($array[$i]) ? $array[$i] : null;
- $this->writeTypeMarker($value);
- }
- }
- return $this;
- }
-
- /**
- * Convert the DateTime into an AMF Date
- *
- * @param DateTime|Zend_Date $data
- * @return Zend_Amf_Parse_Amf0_Serializer
- */
- public function writeDate($data)
- {
- if ($data instanceof DateTime) {
- $dateString = $data->format('U');
- } elseif ($data instanceof Zend_Date) {
- $dateString = $data->toString('U');
- } else {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Invalid date specified; must be a DateTime or Zend_Date object');
- }
- $dateString *= 1000;
-
- // Make the conversion and remove milliseconds.
- $this->_stream->writeDouble($dateString);
-
- // Flash does not respect timezone but requires it.
- $this->_stream->writeInt(0);
-
- return $this;
- }
-
- /**
- * Write a class mapped object to the output stream.
- *
- * @param object $data
- * @return Zend_Amf_Parse_Amf0_Serializer
- */
- public function writeTypedObject($data)
- {
- $this->_stream->writeUTF($this->_className);
- $this->writeObject($data);
- return $this;
- }
-
- /**
- * Encountered and AMF3 Type Marker use AMF3 serializer. Once AMF3 is
- * encountered it will not return to AMf0.
- *
- * @param string $data
- * @return Zend_Amf_Parse_Amf0_Serializer
- */
- public function writeAmf3TypeMarker(&$data)
- {
- require_once 'Zend/Amf/Parse/Amf3/Serializer.php';
- $serializer = new Zend_Amf_Parse_Amf3_Serializer($this->_stream);
- $serializer->writeTypeMarker($data);
- return $this;
- }
-
- /**
- * Find if the class name is a class mapped name and return the
- * respective classname if it is.
- *
- * @param object $object
- * @return false|string $className
- */
- protected function getClassName($object)
- {
- require_once 'Zend/Amf/Parse/TypeLoader.php';
- //Check to see if the object is a typed object and we need to change
- $className = '';
- switch (true) {
- // the return class mapped name back to actionscript class name.
- case Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object)):
- $className = Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object));
- break;
- // Check to see if the user has defined an explicit Action Script type.
- case isset($object->_explicitType):
- $className = $object->_explicitType;
- break;
- // Check if user has defined a method for accessing the Action Script type
- case method_exists($object, 'getASClassName'):
- $className = $object->getASClassName();
- break;
- // No return class name is set make it a generic object
- case ($object instanceof stdClass):
- $className = '';
- break;
- // By default, use object's class name
- default:
- $className = get_class($object);
- break;
- }
- if(!$className == '') {
- return $className;
- } else {
- return false;
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Parse/Amf3/Deserializer.php zendframework-2.2.6/library/Zend/Amf/Parse/Amf3/Deserializer.php
--- zendframework-1.10.4/library/Zend/Amf/Parse/Amf3/Deserializer.php 2010-04-22 03:54:59.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Parse/Amf3/Deserializer.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,421 +0,0 @@
-_stream->readByte();
- }
-
- switch($typeMarker) {
- case Zend_Amf_Constants::AMF3_UNDEFINED:
- return null;
- case Zend_Amf_Constants::AMF3_NULL:
- return null;
- case Zend_Amf_Constants::AMF3_BOOLEAN_FALSE:
- return false;
- case Zend_Amf_Constants::AMF3_BOOLEAN_TRUE:
- return true;
- case Zend_Amf_Constants::AMF3_INTEGER:
- return $this->readInteger();
- case Zend_Amf_Constants::AMF3_NUMBER:
- return $this->_stream->readDouble();
- case Zend_Amf_Constants::AMF3_STRING:
- return $this->readString();
- case Zend_Amf_Constants::AMF3_DATE:
- return $this->readDate();
- case Zend_Amf_Constants::AMF3_ARRAY:
- return $this->readArray();
- case Zend_Amf_Constants::AMF3_OBJECT:
- return $this->readObject();
- case Zend_Amf_Constants::AMF3_XML:
- case Zend_Amf_Constants::AMF3_XMLSTRING:
- return $this->readXmlString();
- case Zend_Amf_Constants::AMF3_BYTEARRAY:
- return $this->readString();
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unsupported type marker: ' . $typeMarker);
- }
- }
-
- /**
- * Read and deserialize an integer
- *
- * AMF 3 represents smaller integers with fewer bytes using the most
- * significant bit of each byte. The worst case uses 32-bits
- * to represent a 29-bit number, which is what we would have
- * done with no compression.
- * - 0x00000000 - 0x0000007F : 0xxxxxxx
- * - 0x00000080 - 0x00003FFF : 1xxxxxxx 0xxxxxxx
- * - 0x00004000 - 0x001FFFFF : 1xxxxxxx 1xxxxxxx 0xxxxxxx
- * - 0x00200000 - 0x3FFFFFFF : 1xxxxxxx 1xxxxxxx 1xxxxxxx xxxxxxxx
- * - 0x40000000 - 0xFFFFFFFF : throw range exception
- *
- * 0x04 -> integer type code, followed by up to 4 bytes of data.
- *
- * Parsing integers on OSFlash for the AMF3 integer data format:
- * @link http://osflash.org/amf3/parsing_integers
- * @return int|float
- */
- public function readInteger()
- {
- $count = 1;
- $intReference = $this->_stream->readByte();
- $result = 0;
- while ((($intReference & 0x80) != 0) && $count < 4) {
- $result <<= 7;
- $result |= ($intReference & 0x7f);
- $intReference = $this->_stream->readByte();
- $count++;
- }
- if ($count < 4) {
- $result <<= 7;
- $result |= $intReference;
- } else {
- // Use all 8 bits from the 4th byte
- $result <<= 8;
- $result |= $intReference;
-
- // Check if the integer should be negative
- if (($result & 0x10000000) != 0) {
- //and extend the sign bit
- $result |= ~0xFFFFFFF;
- }
- }
- return $result;
- }
-
- /**
- * Read and deserialize a string
- *
- * Strings can be sent as a reference to a previously
- * occurring String by using an index to the implicit string reference table.
- * Strings are encoding using UTF-8 - however the header may either
- * describe a string literal or a string reference.
- *
- * - string = 0x06 string-data
- * - string-data = integer-data [ modified-utf-8 ]
- * - modified-utf-8 = *OCTET
- *
- * @return String
- */
- public function readString()
- {
- $stringReference = $this->readInteger();
-
- //Check if this is a reference string
- if (($stringReference & 0x01) == 0) {
- // reference string
- $stringReference = $stringReference >> 1;
- if ($stringReference >= count($this->_referenceStrings)) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Undefined string reference: ' . $stringReference);
- }
- // reference string found
- return $this->_referenceStrings[$stringReference];
- }
-
- $length = $stringReference >> 1;
- if ($length) {
- $string = $this->_stream->readBytes($length);
- $this->_referenceStrings[] = $string;
- } else {
- $string = "";
- }
- return $string;
- }
-
- /**
- * Read and deserialize a date
- *
- * Data is the number of milliseconds elapsed since the epoch
- * of midnight, 1st Jan 1970 in the UTC time zone.
- * Local time zone information is not sent to flash.
- *
- * - date = 0x08 integer-data [ number-data ]
- *
- * @return Zend_Date
- */
- public function readDate()
- {
- $dateReference = $this->readInteger();
- if (($dateReference & 0x01) == 0) {
- $dateReference = $dateReference >> 1;
- if ($dateReference>=count($this->_referenceObjects)) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Undefined date reference: ' . $dateReference);
- }
- return $this->_referenceObjects[$dateReference];
- }
-
- $timestamp = floor($this->_stream->readDouble() / 1000);
-
- require_once 'Zend/Date.php';
- $dateTime = new Zend_Date((int) $timestamp);
- $this->_referenceObjects[] = $dateTime;
- return $dateTime;
- }
-
- /**
- * Read amf array to PHP array
- *
- * - array = 0x09 integer-data ( [ 1OCTET *amf3-data ] | [OCTET *amf3-data 1] | [ OCTET *amf-data ] )
- *
- * @return array
- */
- public function readArray()
- {
- $arrayReference = $this->readInteger();
- if (($arrayReference & 0x01)==0){
- $arrayReference = $arrayReference >> 1;
- if ($arrayReference>=count($this->_referenceObjects)) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unknow array reference: ' . $arrayReference);
- }
- return $this->_referenceObjects[$arrayReference];
- }
-
- // Create a holder for the array in the reference list
- $data = array();
- $this->_referenceObjects[] =& $data;
- $key = $this->readString();
-
- // Iterating for string based keys.
- while ($key != '') {
- $data[$key] = $this->readTypeMarker();
- $key = $this->readString();
- }
-
- $arrayReference = $arrayReference >>1;
-
- //We have a dense array
- for ($i=0; $i < $arrayReference; $i++) {
- $data[] = $this->readTypeMarker();
- }
-
- return $data;
- }
-
- /**
- * Read an object from the AMF stream and convert it into a PHP object
- *
- * @todo Rather than using an array of traitsInfo create Zend_Amf_Value_TraitsInfo
- * @return object|array
- */
- public function readObject()
- {
- $traitsInfo = $this->readInteger();
- $storedObject = ($traitsInfo & 0x01)==0;
- $traitsInfo = $traitsInfo >> 1;
-
- // Check if the Object is in the stored Objects reference table
- if ($storedObject) {
- $ref = $traitsInfo;
- if (!isset($this->_referenceObjects[$ref])) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unknown Object reference: ' . $ref);
- }
- $returnObject = $this->_referenceObjects[$ref];
- } else {
- // Check if the Object is in the stored Definitions reference table
- $storedClass = ($traitsInfo & 0x01) == 0;
- $traitsInfo = $traitsInfo >> 1;
- if ($storedClass) {
- $ref = $traitsInfo;
- if (!isset($this->_referenceDefinitions[$ref])) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unknows Definition reference: '. $ref);
- }
- // Populate the reference attributes
- $className = $this->_referenceDefinitions[$ref]['className'];
- $encoding = $this->_referenceDefinitions[$ref]['encoding'];
- $propertyNames = $this->_referenceDefinitions[$ref]['propertyNames'];
- } else {
- // The class was not in the reference tables. Start reading rawdata to build traits.
- // Create a traits table. Zend_Amf_Value_TraitsInfo would be ideal
- $className = $this->readString();
- $encoding = $traitsInfo & 0x03;
- $propertyNames = array();
- $traitsInfo = $traitsInfo >> 2;
- }
-
- // We now have the object traits defined in variables. Time to go to work:
- if (!$className) {
- // No class name generic object
- $returnObject = new stdClass();
- } else {
- // Defined object
- // Typed object lookup against registered classname maps
- if ($loader = Zend_Amf_Parse_TypeLoader::loadType($className)) {
- $returnObject = new $loader();
- } else {
- //user defined typed object
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Typed object not found: '. $className . ' ');
- }
- }
-
- // Add the Object to the reference table
- $this->_referenceObjects[] = $returnObject;
-
- $properties = array(); // clear value
- // Check encoding types for additional processing.
- switch ($encoding) {
- case (Zend_Amf_Constants::ET_EXTERNAL):
- // Externalizable object such as {ArrayCollection} and {ObjectProxy}
- if (!$storedClass) {
- $this->_referenceDefinitions[] = array(
- 'className' => $className,
- 'encoding' => $encoding,
- 'propertyNames' => $propertyNames,
- );
- }
- $returnObject->externalizedData = $this->readTypeMarker();
- break;
- case (Zend_Amf_Constants::ET_DYNAMIC):
- // used for Name-value encoding
- if (!$storedClass) {
- $this->_referenceDefinitions[] = array(
- 'className' => $className,
- 'encoding' => $encoding,
- 'propertyNames' => $propertyNames,
- );
- }
- // not a reference object read name value properties from byte stream
- do {
- $property = $this->readString();
- if ($property != "") {
- $propertyNames[] = $property;
- $properties[$property] = $this->readTypeMarker();
- }
- } while ($property !="");
- break;
- default:
- // basic property list object.
- if (!$storedClass) {
- $count = $traitsInfo; // Number of properties in the list
- for($i=0; $i< $count; $i++) {
- $propertyNames[] = $this->readString();
- }
- // Add a reference to the class.
- $this->_referenceDefinitions[] = array(
- 'className' => $className,
- 'encoding' => $encoding,
- 'propertyNames' => $propertyNames,
- );
- }
- foreach ($propertyNames as $property) {
- $properties[$property] = $this->readTypeMarker();
- }
- break;
- }
-
- // Add properties back to the return object.
- foreach($properties as $key=>$value) {
- if($key) {
- $returnObject->$key = $value;
- }
- }
-
-
- }
-
- if ($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) {
- if (isset($returnObject->externalizedData)) {
- $returnObject = $returnObject->externalizedData;
- } else {
- $returnObject = get_object_vars($returnObject);
- }
- }
-
- return $returnObject;
- }
-
- /**
- * Convert XML to SimpleXml
- * If user wants DomDocument they can use dom_import_simplexml
- *
- * @return SimpleXml Object
- */
- public function readXmlString()
- {
- $xmlReference = $this->readInteger();
- $length = $xmlReference >> 1;
- $string = $this->_stream->readBytes($length);
- return simplexml_load_string($string);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Parse/Amf3/Serializer.php zendframework-2.2.6/library/Zend/Amf/Parse/Amf3/Serializer.php
--- zendframework-1.10.4/library/Zend/Amf/Parse/Amf3/Serializer.php 2010-04-22 03:54:59.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Parse/Amf3/Serializer.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,529 +0,0 @@
-_stream->writeByte($markerType);
-
- switch ($markerType) {
- case Zend_Amf_Constants::AMF3_NULL:
- break;
- case Zend_Amf_Constants::AMF3_BOOLEAN_FALSE:
- break;
- case Zend_Amf_Constants::AMF3_BOOLEAN_TRUE:
- break;
- case Zend_Amf_Constants::AMF3_INTEGER:
- $this->writeInteger($data);
- break;
- case Zend_Amf_Constants::AMF3_NUMBER:
- $this->_stream->writeDouble($data);
- break;
- case Zend_Amf_Constants::AMF3_STRING:
- $this->writeString($data);
- break;
- case Zend_Amf_Constants::AMF3_DATE:
- $this->writeDate($data);
- break;
- case Zend_Amf_Constants::AMF3_ARRAY:
- $this->writeArray($data);
- break;
- case Zend_Amf_Constants::AMF3_OBJECT:
- $this->writeObject($data);
- break;
- case Zend_Amf_Constants::AMF3_BYTEARRAY:
- $this->writeByteArray($data);
- break;
- case Zend_Amf_Constants::AMF3_XMLSTRING;
- $this->writeXml($data);
- break;
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unknown Type Marker: ' . $markerType);
- }
- } else {
- // Detect Type Marker
- if (is_resource($data)) {
- $data = Zend_Amf_Parse_TypeLoader::handleResource($data);
- }
- switch (true) {
- case (null === $data):
- $markerType = Zend_Amf_Constants::AMF3_NULL;
- break;
- case (is_bool($data)):
- if ($data){
- $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_TRUE;
- } else {
- $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_FALSE;
- }
- break;
- case (is_int($data)):
- if (($data > 0xFFFFFFF) || ($data < -268435456)) {
- $markerType = Zend_Amf_Constants::AMF3_NUMBER;
- } else {
- $markerType = Zend_Amf_Constants::AMF3_INTEGER;
- }
- break;
- case (is_float($data)):
- $markerType = Zend_Amf_Constants::AMF3_NUMBER;
- break;
- case (is_string($data)):
- $markerType = Zend_Amf_Constants::AMF3_STRING;
- break;
- case (is_array($data)):
- $markerType = Zend_Amf_Constants::AMF3_ARRAY;
- break;
- case (is_object($data)):
- // Handle object types.
- if (($data instanceof DateTime) || ($data instanceof Zend_Date)) {
- $markerType = Zend_Amf_Constants::AMF3_DATE;
- } else if ($data instanceof Zend_Amf_Value_ByteArray) {
- $markerType = Zend_Amf_Constants::AMF3_BYTEARRAY;
- } else if (($data instanceof DOMDocument) || ($data instanceof SimpleXMLElement)) {
- $markerType = Zend_Amf_Constants::AMF3_XMLSTRING;
- } else {
- $markerType = Zend_Amf_Constants::AMF3_OBJECT;
- }
- break;
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unsupported data type: ' . gettype($data));
- }
- $this->writeTypeMarker($data, $markerType);
- }
- }
-
- /**
- * Write an AMF3 integer
- *
- * @param int|float $data
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeInteger($int)
- {
- if (($int & 0xffffff80) == 0) {
- $this->_stream->writeByte($int & 0x7f);
- return $this;
- }
-
- if (($int & 0xffffc000) == 0 ) {
- $this->_stream->writeByte(($int >> 7 ) | 0x80);
- $this->_stream->writeByte($int & 0x7f);
- return $this;
- }
-
- if (($int & 0xffe00000) == 0) {
- $this->_stream->writeByte(($int >> 14 ) | 0x80);
- $this->_stream->writeByte(($int >> 7 ) | 0x80);
- $this->_stream->writeByte($int & 0x7f);
- return $this;
- }
-
- $this->_stream->writeByte(($int >> 22 ) | 0x80);
- $this->_stream->writeByte(($int >> 15 ) | 0x80);
- $this->_stream->writeByte(($int >> 8 ) | 0x80);
- $this->_stream->writeByte($int & 0xff);
- return $this;
- }
-
- /**
- * Send string to output stream, without trying to reference it.
- * The string is prepended with strlen($string) << 1 | 0x01
- *
- * @param string $string
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- protected function writeBinaryString(&$string){
- $ref = strlen($string) << 1 | 0x01;
- $this->writeInteger($ref);
- $this->_stream->writeBytes($string);
-
- return $this;
- }
-
- /**
- * Send string to output stream
- *
- * @param string $string
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeString(&$string)
- {
- $len = strlen($string);
- if(!$len){
- $this->writeInteger(0x01);
- return $this;
- }
-
- $ref = array_search($string, $this->_referenceStrings, true);
- if($ref === false){
- $this->_referenceStrings[] = $string;
- $this->writeBinaryString($string);
- } else {
- $ref <<= 1;
- $this->writeInteger($ref);
- }
-
- return $this;
- }
-
- /**
- * Send ByteArray to output stream
- *
- * @param string|Zend_Amf_Value_ByteArray $data
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeByteArray(&$data)
- {
- if ($this->writeObjectReference($data)) {
- return $this;
- }
-
- if (is_string($data)) {
- //nothing to do
- } else if ($data instanceof Zend_Amf_Value_ByteArray) {
- $data = $data->getData();
- } else {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Invalid ByteArray specified; must be a string or Zend_Amf_Value_ByteArray');
- }
-
- $this->writeBinaryString($data);
-
- return $this;
- }
-
- /**
- * Send xml to output stream
- *
- * @param DOMDocument|SimpleXMLElement $xml
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeXml($xml)
- {
- if ($this->writeObjectReference($xml)) {
- return $this;
- }
-
- if(is_string($xml)) {
- //nothing to do
- } else if ($xml instanceof DOMDocument) {
- $xml = $xml->saveXml();
- } else if ($xml instanceof SimpleXMLElement) {
- $xml = $xml->asXML();
- } else {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Invalid xml specified; must be a DOMDocument or SimpleXMLElement');
- }
-
- $this->writeBinaryString($xml);
-
- return $this;
- }
-
- /**
- * Convert DateTime/Zend_Date to AMF date
- *
- * @param DateTime|Zend_Date $date
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeDate($date)
- {
- if ($this->writeObjectReference($date)) {
- return $this;
- }
-
- if ($date instanceof DateTime) {
- $dateString = $date->format('U') * 1000;
- } elseif ($date instanceof Zend_Date) {
- $dateString = $date->toString('U') * 1000;
- } else {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Invalid date specified; must be a string DateTime or Zend_Date object');
- }
-
- $this->writeInteger(0x01);
- // write time to stream minus milliseconds
- $this->_stream->writeDouble($dateString);
- return $this;
- }
-
- /**
- * Write a PHP array back to the amf output stream
- *
- * @param array $array
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeArray(&$array)
- {
- // arrays aren't reference here but still counted
- $this->_referenceObjects[] = $array;
-
- // have to seperate mixed from numberic keys.
- $numeric = array();
- $string = array();
- foreach ($array as $key => &$value) {
- if (is_int($key)) {
- $numeric[] = $value;
- } else {
- $string[$key] = $value;
- }
- }
-
- // write the preamble id of the array
- $length = count($numeric);
- $id = ($length << 1) | 0x01;
- $this->writeInteger($id);
-
- //Write the mixed type array to the output stream
- foreach($string as $key => &$value) {
- $this->writeString($key)
- ->writeTypeMarker($value);
- }
- $this->writeString($this->_strEmpty);
-
- // Write the numeric array to ouput stream
- foreach($numeric as &$value) {
- $this->writeTypeMarker($value);
- }
- return $this;
- }
-
- /**
- * Check if the given object is in the reference table, write the reference if it exists,
- * otherwise add the object to the reference table
- *
- * @param mixed $object object reference to check for reference
- * @param mixed $objectByVal object to check for reference
- * @return Boolean true, if the reference was written, false otherwise
- */
- protected function writeObjectReference(&$object, $objectByVal = false)
- {
- // Workaround for PHP5 with E_STRICT enabled complaining about "Only
- // variables should be passed by reference"
- if ((null === $object) && ($objectByVal !== false)) {
- $object = &$objectByVal;
- }
-
- $ref = array_search($object, $this->_referenceObjects,true);
-
- // quickly handle object references
- if ($ref !== false){
- $ref <<= 1;
- $this->writeInteger($ref);
- return true;
- }
- $this->_referenceObjects[] = $object;
- return false;
- }
-
- /**
- * Write object to ouput stream
- *
- * @param mixed $data
- * @return Zend_Amf_Parse_Amf3_Serializer
- */
- public function writeObject($object)
- {
- if($this->writeObjectReference($object)){
- return $this;
- }
-
- $className = '';
-
- //Check to see if the object is a typed object and we need to change
- switch (true) {
- // the return class mapped name back to actionscript class name.
- case ($className = Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object))):
- break;
-
- // Check to see if the user has defined an explicit Action Script type.
- case isset($object->_explicitType):
- $className = $object->_explicitType;
- break;
-
- // Check if user has defined a method for accessing the Action Script type
- case method_exists($object, 'getASClassName'):
- $className = $object->getASClassName();
- break;
-
- // No return class name is set make it a generic object
- case ($object instanceof stdClass):
- $className = '';
- break;
-
- // By default, use object's class name
- default:
- $className = get_class($object);
- break;
- }
-
- $writeTraits = true;
-
- //check to see, if we have a corresponding definition
- if(array_key_exists($className, $this->_referenceDefinitions)){
- $traitsInfo = $this->_referenceDefinitions[$className]['id'];
- $encoding = $this->_referenceDefinitions[$className]['encoding'];
- $propertyNames = $this->_referenceDefinitions[$className]['propertyNames'];
-
- $traitsInfo = ($traitsInfo << 2) | 0x01;
-
- $writeTraits = false;
- } else {
- $propertyNames = array();
-
- if($className == ''){
- //if there is no className, we interpret the class as dynamic without any sealed members
- $encoding = Zend_Amf_Constants::ET_DYNAMIC;
- } else {
- $encoding = Zend_Amf_Constants::ET_PROPLIST;
-
- foreach($object as $key => $value) {
- if( $key[0] != "_") {
- $propertyNames[] = $key;
- }
- }
- }
-
- $this->_referenceDefinitions[$className] = array(
- 'id' => count($this->_referenceDefinitions),
- 'encoding' => $encoding,
- 'propertyNames' => $propertyNames,
- );
-
- $traitsInfo = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
- $traitsInfo |= $encoding << 2;
- $traitsInfo |= (count($propertyNames) << 4);
- }
-
- $this->writeInteger($traitsInfo);
-
- if($writeTraits){
- $this->writeString($className);
- foreach ($propertyNames as $value) {
- $this->writeString($value);
- }
- }
-
- try {
- switch($encoding) {
- case Zend_Amf_Constants::ET_PROPLIST:
- //Write the sealed values to the output stream.
- foreach ($propertyNames as $key) {
- $this->writeTypeMarker($object->$key);
- }
- break;
- case Zend_Amf_Constants::ET_DYNAMIC:
- //Write the sealed values to the output stream.
- foreach ($propertyNames as $key) {
- $this->writeTypeMarker($object->$key);
- }
-
- //Write remaining properties
- foreach($object as $key => $value){
- if(!in_array($key,$propertyNames) && $key[0] != "_"){
- $this->writeString($key);
- $this->writeTypeMarker($value);
- }
- }
-
- //Write an empty string to end the dynamic part
- $this->writeString($this->_strEmpty);
- break;
- case Zend_Amf_Constants::ET_EXTERNAL:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('External Object Encoding not implemented');
- break;
- default:
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unknown Object Encoding type: ' . $encoding);
- }
- } catch (Exception $e) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unable to writeObject output: ' . $e->getMessage(), 0, $e);
- }
-
- return $this;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Parse/Deserializer.php zendframework-2.2.6/library/Zend/Amf/Parse/Deserializer.php
--- zendframework-1.10.4/library/Zend/Amf/Parse/Deserializer.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Parse/Deserializer.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,65 +0,0 @@
-_stream = $stream;
- }
-
- /**
- * Checks for AMF marker types and calls the appropriate methods
- * for deserializing those marker types. Markers are the data type of
- * the following value.
- *
- * @param int $typeMarker
- * @return mixed Whatever the data type is of the marker in php
- */
- public abstract function readTypeMarker($markerType = null);
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Parse/InputStream.php zendframework-2.2.6/library/Zend/Amf/Parse/InputStream.php
--- zendframework-1.10.4/library/Zend/Amf/Parse/InputStream.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Parse/InputStream.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,39 +0,0 @@
- "MYSQLI_TYPE_DECIMAL",
- 1 => "MYSQLI_TYPE_TINYINT",
- 2 => "MYSQLI_TYPE_SMALLINT",
- 3 => "MYSQLI_TYPE_INTEGER",
- 4 => "MYSQLI_TYPE_FLOAT",
- 5 => "MYSQLI_TYPE_DOUBLE",
- 7 => "MYSQLI_TYPE_TIMESTAMP",
- 8 => "MYSQLI_TYPE_BIGINT",
- 9 => "MYSQLI_TYPE_MEDIUMINT",
- 10 => "MYSQLI_TYPE_DATE",
- 11 => "MYSQLI_TYPE_TIME",
- 12 => "MYSQLI_TYPE_DATETIME",
- 13 => "MYSQLI_TYPE_YEAR",
- 14 => "MYSQLI_TYPE_DATE",
- 16 => "MYSQLI_TYPE_BIT",
- 246 => "MYSQLI_TYPE_DECIMAL",
- 247 => "MYSQLI_TYPE_ENUM",
- 248 => "MYSQLI_TYPE_SET",
- 249 => "MYSQLI_TYPE_TINYBLOB",
- 250 => "MYSQLI_TYPE_MEDIUMBLOB",
- 251 => "MYSQLI_TYPE_LONGBLOB",
- 252 => "MYSQLI_TYPE_BLOB",
- 253 => "MYSQLI_TYPE_VARCHAR",
- 254 => "MYSQLI_TYPE_CHAR",
- 255 => "MYSQLI_TYPE_GEOMETRY",
- );
-
- // Build an associative array for a type look up
- static $mysqli_to_php = array(
- "MYSQLI_TYPE_DECIMAL" => 'float',
- "MYSQLI_TYPE_NEWDECIMAL" => 'float',
- "MYSQLI_TYPE_BIT" => 'integer',
- "MYSQLI_TYPE_TINYINT" => 'integer',
- "MYSQLI_TYPE_SMALLINT" => 'integer',
- "MYSQLI_TYPE_MEDIUMINT" => 'integer',
- "MYSQLI_TYPE_BIGINT" => 'integer',
- "MYSQLI_TYPE_INTEGER" => 'integer',
- "MYSQLI_TYPE_FLOAT" => 'float',
- "MYSQLI_TYPE_DOUBLE" => 'float',
- "MYSQLI_TYPE_NULL" => 'null',
- "MYSQLI_TYPE_TIMESTAMP" => 'string',
- "MYSQLI_TYPE_INT24" => 'integer',
- "MYSQLI_TYPE_DATE" => 'string',
- "MYSQLI_TYPE_TIME" => 'string',
- "MYSQLI_TYPE_DATETIME" => 'string',
- "MYSQLI_TYPE_YEAR" => 'string',
- "MYSQLI_TYPE_NEWDATE" => 'string',
- "MYSQLI_TYPE_ENUM" => 'string',
- "MYSQLI_TYPE_SET" => 'string',
- "MYSQLI_TYPE_TINYBLOB" => 'object',
- "MYSQLI_TYPE_MEDIUMBLOB" => 'object',
- "MYSQLI_TYPE_LONGBLOB" => 'object',
- "MYSQLI_TYPE_BLOB" => 'object',
- "MYSQLI_TYPE_CHAR" => 'string',
- "MYSQLI_TYPE_VARCHAR" => 'string',
- "MYSQLI_TYPE_GEOMETRY" => 'object',
- "MYSQLI_TYPE_BIT" => 'integer',
- );
-
- /**
- * Parse resource into array
- *
- * @param resource $resource
- * @return array
- */
- public function parse($resource) {
-
- $result = array();
- $fieldcnt = mysqli_num_fields($resource);
-
-
- $fields_transform = array();
-
- for($i=0;$i<$fieldcnt;$i++) {
- $finfo = mysqli_fetch_field_direct($resource, $i);
-
- if(isset(self::$mysqli_type[$finfo->type])) {
- $fields_transform[$finfo->name] = self::$mysqli_to_php[self::$mysqli_type[$finfo->type]];
- }
- }
-
- while($row = mysqli_fetch_assoc($resource)) {
- foreach($fields_transform as $fieldname => $fieldtype) {
- settype($row[$fieldname], $fieldtype);
- }
- $result[] = $row;
- }
- return $result;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Parse/Resource/MysqlResult.php zendframework-2.2.6/library/Zend/Amf/Parse/Resource/MysqlResult.php
--- zendframework-1.10.4/library/Zend/Amf/Parse/Resource/MysqlResult.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Parse/Resource/MysqlResult.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,70 +0,0 @@
- Value is Mysql type (exact string) => PHP type
- */
- static public $fieldTypes = array(
- "int" => "int",
- "timestamp" => "int",
- "year" => "int",
- "real" => "float",
- );
- /**
- * Parse resource into array
- *
- * @param resource $resource
- * @return array
- */
- public function parse($resource) {
- $result = array();
- $fieldcnt = mysql_num_fields($resource);
- $fields_transform = array();
- for($i=0;$i<$fieldcnt;$i++) {
- $type = mysql_field_type($resource, $i);
- if(isset(self::$fieldTypes[$type])) {
- $fields_transform[mysql_field_name($resource, $i)] = self::$fieldTypes[$type];
- }
- }
-
- while($row = mysql_fetch_object($resource)) {
- foreach($fields_transform as $fieldname => $fieldtype) {
- settype($row->$fieldname, $fieldtype);
- }
- $result[] = $row;
- }
- return $result;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Parse/Resource/Stream.php zendframework-2.2.6/library/Zend/Amf/Parse/Resource/Stream.php
--- zendframework-1.10.4/library/Zend/Amf/Parse/Resource/Stream.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Parse/Resource/Stream.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,42 +0,0 @@
-_stream = $stream;
- }
-
- /**
- * Find the PHP object type and convert it into an AMF object type
- *
- * @param mixed $content
- * @param int $markerType
- * @param mixed $contentByVal
- * @return void
- */
- public abstract function writeTypeMarker(&$content, $markerType = null, $contentByVal = false);
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Parse/TypeLoader.php zendframework-2.2.6/library/Zend/Amf/Parse/TypeLoader.php
--- zendframework-1.10.4/library/Zend/Amf/Parse/TypeLoader.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Parse/TypeLoader.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,231 +0,0 @@
- 'Zend_Amf_Value_Messaging_AcknowledgeMessage',
- 'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_AsyncMessage',
- 'flex.messaging.messages.CommandMessage' => 'Zend_Amf_Value_Messaging_CommandMessage',
- 'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_ErrorMessage',
- 'flex.messaging.messages.RemotingMessage' => 'Zend_Amf_Value_Messaging_RemotingMessage',
- 'flex.messaging.io.ArrayCollection' => 'Zend_Amf_Value_Messaging_ArrayCollection',
- );
-
- /**
- * @var array Default class map
- */
- protected static $_defaultClassMap = array(
- 'flex.messaging.messages.AcknowledgeMessage' => 'Zend_Amf_Value_Messaging_AcknowledgeMessage',
- 'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_AsyncMessage',
- 'flex.messaging.messages.CommandMessage' => 'Zend_Amf_Value_Messaging_CommandMessage',
- 'flex.messaging.messages.ErrorMessage' => 'Zend_Amf_Value_Messaging_ErrorMessage',
- 'flex.messaging.messages.RemotingMessage' => 'Zend_Amf_Value_Messaging_RemotingMessage',
- 'flex.messaging.io.ArrayCollection' => 'Zend_Amf_Value_Messaging_ArrayCollection',
- );
-
- /**
- * @var Zend_Loader_PluginLoader_Interface
- */
- protected static $_resourceLoader = null;
-
-
- /**
- * Load the mapped class type into a callback.
- *
- * @param string $className
- * @return object|false
- */
- public static function loadType($className)
- {
- $class = self::getMappedClassName($className);
- if(!$class) {
- $class = str_replace('.', '_', $className);
- }
- if (!class_exists($class)) {
- return "stdClass";
- }
- return $class;
- }
-
- /**
- * Looks up the supplied call name to its mapped class name
- *
- * @param string $className
- * @return string
- */
- public static function getMappedClassName($className)
- {
- $mappedName = array_search($className, self::$classMap);
-
- if ($mappedName) {
- return $mappedName;
- }
-
- $mappedName = array_search($className, array_flip(self::$classMap));
-
- if ($mappedName) {
- return $mappedName;
- }
-
- return false;
- }
-
- /**
- * Map PHP class names to ActionScript class names
- *
- * Allows users to map the class names of there action script classes
- * to the equivelent php class name. Used in deserialization to load a class
- * and serialiation to set the class name of the returned object.
- *
- * @param string $asClassName
- * @param string $phpClassName
- * @return void
- */
- public static function setMapping($asClassName, $phpClassName)
- {
- self::$classMap[$asClassName] = $phpClassName;
- }
-
- /**
- * Reset type map
- *
- * @return void
- */
- public static function resetMap()
- {
- self::$classMap = self::$_defaultClassMap;
- }
-
- /**
- * Set loader for resource type handlers
- *
- * @param Zend_Loader_PluginLoader_Interface $loader
- */
- public static function setResourceLoader(Zend_Loader_PluginLoader_Interface $loader)
- {
- self::$_resourceLoader = $loader;
- }
-
- /**
- * Add directory to the list of places where to look for resource handlers
- *
- * @param string $prefix
- * @param string $dir
- */
- public static function addResourceDirectory($prefix, $dir)
- {
- if(self::$_resourceLoader) {
- self::$_resourceLoader->addPrefixPath($prefix, $dir);
- }
- }
-
- /**
- * Get plugin class that handles this resource
- *
- * @param resource $resource Resource type
- * @return string Class name
- */
- public static function getResourceParser($resource)
- {
- if(self::$_resourceLoader) {
- $type = preg_replace("/[^A-Za-z0-9_]/", " ", get_resource_type($resource));
- $type = str_replace(" ","", ucwords($type));
- return self::$_resourceLoader->load($type);
- }
- return false;
- }
-
- /**
- * Convert resource to a serializable object
- *
- * @param resource $resource
- * @return mixed
- */
- public static function handleResource($resource)
- {
- if(!self::$_resourceLoader) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unable to handle resources - resource plugin loader not set');
- }
- try {
- while(is_resource($resource)) {
- $resclass = self::getResourceParser($resource);
- if(!$resclass) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource));
- }
- $parser = new $resclass();
- if(is_callable(array($parser, 'parse'))) {
- $resource = $parser->parse($resource);
- } else {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception("Could not call parse() method on class $resclass");
- }
- }
- return $resource;
- } catch(Zend_Amf_Exception $e) {
- throw new Zend_Amf_Exception($e->getMessage(), $e->getCode(), $e);
- } catch(Exception $e) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Can not serialize resource type: '. get_resource_type($resource), 0, $e);
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Request/Http.php zendframework-2.2.6/library/Zend/Amf/Request/Http.php
--- zendframework-1.10.4/library/Zend/Amf/Request/Http.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Request/Http.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,80 +0,0 @@
-_rawRequest = $amfRequest;
- $this->initialize($amfRequest);
- } else {
- echo 'Zend Amf Endpoint
' ;
- }
- }
-
- /**
- * Retrieve raw AMF Request
- *
- * @return string
- */
- public function getRawRequest()
- {
- return $this->_rawRequest;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Request.php zendframework-2.2.6/library/Zend/Amf/Request.php
--- zendframework-1.10.4/library/Zend/Amf/Request.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Request.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,251 +0,0 @@
-_inputStream = new Zend_Amf_Parse_InputStream($request);
- $this->_deserializer = new Zend_Amf_Parse_Amf0_Deserializer($this->_inputStream);
- $this->readMessage($this->_inputStream);
- return $this;
- }
-
- /**
- * Takes the raw AMF input stream and converts it into valid PHP objects
- *
- * @param Zend_Amf_Parse_InputStream
- * @return Zend_Amf_Request
- */
- public function readMessage(Zend_Amf_Parse_InputStream $stream)
- {
- $clientVersion = $stream->readUnsignedShort();
- if (($clientVersion != Zend_Amf_Constants::AMF0_OBJECT_ENCODING)
- && ($clientVersion != Zend_Amf_Constants::AMF3_OBJECT_ENCODING)
- && ($clientVersion != Zend_Amf_Constants::FMS_OBJECT_ENCODING)
- ) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unknown Player Version ' . $clientVersion);
- }
-
- $this->_bodies = array();
- $this->_headers = array();
- $headerCount = $stream->readInt();
-
- // Iterate through the AMF envelope header
- while ($headerCount--) {
- $this->_headers[] = $this->readHeader();
- }
-
- // Iterate through the AMF envelope body
- $bodyCount = $stream->readInt();
- while ($bodyCount--) {
- $this->_bodies[] = $this->readBody();
- }
-
- return $this;
- }
-
- /**
- * Deserialize a message header from the input stream.
- *
- * A message header is structured as:
- * - NAME String
- * - MUST UNDERSTAND Boolean
- * - LENGTH Int
- * - DATA Object
- *
- * @return Zend_Amf_Value_MessageHeader
- */
- public function readHeader()
- {
- $name = $this->_inputStream->readUTF();
- $mustRead = (bool)$this->_inputStream->readByte();
- $length = $this->_inputStream->readLong();
-
- try {
- $data = $this->_deserializer->readTypeMarker();
- } catch (Exception $e) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unable to parse ' . $name . ' header data: ' . $e->getMessage() . ' '. $e->getLine(), 0, $e);
- }
-
- $header = new Zend_Amf_Value_MessageHeader($name, $mustRead, $data, $length);
- return $header;
- }
-
- /**
- * Deserialize a message body from the input stream
- *
- * @return Zend_Amf_Value_MessageBody
- */
- public function readBody()
- {
- $targetURI = $this->_inputStream->readUTF();
- $responseURI = $this->_inputStream->readUTF();
- $length = $this->_inputStream->readLong();
-
- try {
- $data = $this->_deserializer->readTypeMarker();
- } catch (Exception $e) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Unable to parse ' . $targetURI . ' body data ' . $e->getMessage(), 0, $e);
- }
-
- // Check for AMF3 objectEncoding
- if ($this->_deserializer->getObjectEncoding() == Zend_Amf_Constants::AMF3_OBJECT_ENCODING) {
- /*
- * When and AMF3 message is sent to the server it is nested inside
- * an AMF0 array called Content. The following code gets the object
- * out of the content array and sets it as the message data.
- */
- if(is_array($data) && $data[0] instanceof Zend_Amf_Value_Messaging_AbstractMessage){
- $data = $data[0];
- }
-
- // set the encoding so we return our message in AMF3
- $this->_objectEncoding = Zend_Amf_Constants::AMF3_OBJECT_ENCODING;
- }
-
- $body = new Zend_Amf_Value_MessageBody($targetURI, $responseURI, $data);
- return $body;
- }
-
- /**
- * Return an array of the body objects that were found in the amf request.
- *
- * @return array {target, response, length, content}
- */
- public function getAmfBodies()
- {
- return $this->_bodies;
- }
-
- /**
- * Accessor to private array of message bodies.
- *
- * @param Zend_Amf_Value_MessageBody $message
- * @return Zend_Amf_Request
- */
- public function addAmfBody(Zend_Amf_Value_MessageBody $message)
- {
- $this->_bodies[] = $message;
- return $this;
- }
-
- /**
- * Return an array of headers that were found in the amf request.
- *
- * @return array {operation, mustUnderstand, length, param}
- */
- public function getAmfHeaders()
- {
- return $this->_headers;
- }
-
- /**
- * Return the either 0 or 3 for respect AMF version
- *
- * @return int
- */
- public function getObjectEncoding()
- {
- return $this->_objectEncoding;
- }
-
- /**
- * Set the object response encoding
- *
- * @param mixed $int
- * @return Zend_Amf_Request
- */
- public function setObjectEncoding($int)
- {
- $this->_objectEncoding = $int;
- return $this;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Response/Http.php zendframework-2.2.6/library/Zend/Amf/Response/Http.php
--- zendframework-1.10.4/library/Zend/Amf/Response/Http.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Response/Http.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,50 +0,0 @@
-_outputStream = new Zend_Amf_Parse_OutputStream();
- $this->writeMessage($this->_outputStream);
- return $this;
- }
-
- /**
- * Serialize the PHP data types back into Actionscript and
- * create and AMF stream.
- *
- * @param Zend_Amf_Parse_OutputStream $stream
- * @return Zend_Amf_Response
- */
- public function writeMessage(Zend_Amf_Parse_OutputStream $stream)
- {
- $objectEncoding = $this->_objectEncoding;
-
- //Write encoding to start of stream. Preamble byte is written of two byte Unsigned Short
- $stream->writeByte(0x00);
- $stream->writeByte($objectEncoding);
-
- // Loop through the AMF Headers that need to be returned.
- $headerCount = count($this->_headers);
- $stream->writeInt($headerCount);
- foreach ($this->getAmfHeaders() as $header) {
- $serializer = new Zend_Amf_Parse_Amf0_Serializer($stream);
- $stream->writeUTF($header->name);
- $stream->writeByte($header->mustRead);
- $stream->writeLong(Zend_Amf_Constants::UNKNOWN_CONTENT_LENGTH);
- if (is_object($header->data)) {
- // Workaround for PHP5 with E_STRICT enabled complaining about
- // "Only variables should be passed by reference"
- $placeholder = null;
- $serializer->writeTypeMarker($placeholder, null, $header->data);
- } else {
- $serializer->writeTypeMarker($header->data);
- }
- }
-
- // loop through the AMF bodies that need to be returned.
- $bodyCount = count($this->_bodies);
- $stream->writeInt($bodyCount);
- foreach ($this->_bodies as $body) {
- $serializer = new Zend_Amf_Parse_Amf0_Serializer($stream);
- $stream->writeUTF($body->getTargetURI());
- $stream->writeUTF($body->getResponseURI());
- $stream->writeLong(Zend_Amf_Constants::UNKNOWN_CONTENT_LENGTH);
- $bodyData = $body->getData();
- $markerType = ($this->_objectEncoding == Zend_Amf_Constants::AMF0_OBJECT_ENCODING) ? null : Zend_Amf_Constants::AMF0_AMF3;
- if (is_object($bodyData)) {
- // Workaround for PHP5 with E_STRICT enabled complaining about
- // "Only variables should be passed by reference"
- $placeholder = null;
- $serializer->writeTypeMarker($placeholder, $markerType, $bodyData);
- } else {
- $serializer->writeTypeMarker($bodyData, $markerType);
- }
- }
-
- return $this;
- }
-
- /**
- * Return the output stream content
- *
- * @return string The contents of the output stream
- */
- public function getResponse()
- {
- return $this->_outputStream->getStream();
- }
-
- /**
- * Return the output stream content
- *
- * @return string
- */
- public function __toString()
- {
- return $this->getResponse();
- }
-
- /**
- * Add an AMF body to be sent to the Flash Player
- *
- * @param Zend_Amf_Value_MessageBody $body
- * @return Zend_Amf_Response
- */
- public function addAmfBody(Zend_Amf_Value_MessageBody $body)
- {
- $this->_bodies[] = $body;
- return $this;
- }
-
- /**
- * Return an array of AMF bodies to be serialized
- *
- * @return array
- */
- public function getAmfBodies()
- {
- return $this->_bodies;
- }
-
- /**
- * Add an AMF Header to be sent back to the flash player
- *
- * @param Zend_Amf_Value_MessageHeader $header
- * @return Zend_Amf_Response
- */
- public function addAmfHeader(Zend_Amf_Value_MessageHeader $header)
- {
- $this->_headers[] = $header;
- return $this;
- }
-
- /**
- * Retrieve attached AMF message headers
- *
- * @return array Array of Zend_Amf_Value_MessageHeader objects
- */
- public function getAmfHeaders()
- {
- return $this->_headers;
- }
-
- /**
- * Set the AMF encoding that will be used for serialization
- *
- * @param int $encoding
- * @return Zend_Amf_Response
- */
- public function setObjectEncoding($encoding)
- {
- $this->_objectEncoding = $encoding;
- return $this;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Server/Exception.php zendframework-2.2.6/library/Zend/Amf/Server/Exception.php
--- zendframework-1.10.4/library/Zend/Amf/Server/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Server/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,37 +0,0 @@
- method pairs
- * @var array
- */
- protected $_table = array();
-
- /**
- *
- * @var bool session flag; whether or not to add a session to each response.
- */
- protected $_session = false;
-
- /**
- * Namespace allows all AMF calls to not clobber other php session variables
- * @var Zend_Session_NameSpace default session namespace zend_amf
- */
- protected $_sesionNamespace = 'zend_amf';
-
- /**
- * Set the default session.name if php_
- * @var string
- */
- protected $_sessionName = 'PHPSESSID';
-
- /**
- * Authentication handler object
- *
- * @var Zend_Amf_Auth_Abstract
- */
- protected $_auth;
- /**
- * ACL handler object
- *
- * @var Zend_Acl
- */
- protected $_acl;
- /**
- * The server constructor
- */
- public function __construct()
- {
- Zend_Amf_Parse_TypeLoader::setResourceLoader(new Zend_Loader_PluginLoader(array("Zend_Amf_Parse_Resource" => "Zend/Amf/Parse/Resource")));
- }
-
- /**
- * Set authentication adapter
- *
- * @param Zend_Amf_Auth_Abstract $auth
- * @return Zend_Amf_Server
- */
- public function setAuth(Zend_Amf_Auth_Abstract $auth)
- {
- $this->_auth = $auth;
- return $this;
- }
- /**
- * Get authentication adapter
- *
- * @return Zend_Amf_Auth_Abstract
- */
- public function getAuth()
- {
- return $this->_auth;
- }
-
- /**
- * Set ACL adapter
- *
- * @param Zend_Acl $acl
- * @return Zend_Amf_Server
- */
- public function setAcl(Zend_Acl $acl)
- {
- $this->_acl = $acl;
- return $this;
- }
- /**
- * Get ACL adapter
- *
- * @return Zend_Acl
- */
- public function getAcl()
- {
- return $this->_acl;
- }
-
- /**
- * Set production flag
- *
- * @param bool $flag
- * @return Zend_Amf_Server
- */
- public function setProduction($flag)
- {
- $this->_production = (bool) $flag;
- return $this;
- }
-
- /**
- * Whether or not the server is in production
- *
- * @return bool
- */
- public function isProduction()
- {
- return $this->_production;
- }
-
- /**
- * @param namespace of all incoming sessions defaults to Zend_Amf
- * @return Zend_Amf_Server
- */
- public function setSession($namespace = 'Zend_Amf')
- {
- require_once 'Zend/Session.php';
- $this->_session = true;
- $this->_sesionNamespace = new Zend_Session_Namespace($namespace);
- return $this;
- }
-
- /**
- * Whether of not the server is using sessions
- * @return bool
- */
- public function isSession()
- {
- return $this->_session;
- }
-
- /**
- * Check if the ACL allows accessing the function or method
- *
- * @param string|object $object Object or class being accessed
- * @param string $function Function or method being accessed
- * @return unknown_type
- */
- protected function _checkAcl($object, $function)
- {
- if(!$this->_acl) {
- return true;
- }
- if($object) {
- $class = is_object($object)?get_class($object):$object;
- if(!$this->_acl->has($class)) {
- require_once 'Zend/Acl/Resource.php';
- $this->_acl->add(new Zend_Acl_Resource($class));
- }
- $call = array($object, "initAcl");
- if(is_callable($call) && !call_user_func($call, $this->_acl)) {
- // if initAcl returns false, no ACL check
- return true;
- }
- } else {
- $class = null;
- }
-
- $auth = Zend_Auth::getInstance();
- if($auth->hasIdentity()) {
- $role = $auth->getIdentity()->role;
- } else {
- if($this->_acl->hasRole(Zend_Amf_Constants::GUEST_ROLE)) {
- $role = Zend_Amf_Constants::GUEST_ROLE;
- } else {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception("Unauthenticated access not allowed");
- }
- }
- if($this->_acl->isAllowed($role, $class, $function)) {
- return true;
- } else {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception("Access not allowed");
- }
- }
-
- /**
- * Get PluginLoader for the Server
- *
- * @return Zend_Loader_PluginLoader
- */
- protected function getLoader()
- {
- if(empty($this->_loader)) {
- require_once 'Zend/Loader/PluginLoader.php';
- $this->_loader = new Zend_Loader_PluginLoader();
- }
- return $this->_loader;
- }
-
- /**
- * Loads a remote class or method and executes the function and returns
- * the result
- *
- * @param string $method Is the method to execute
- * @param mixed $param values for the method
- * @return mixed $response the result of executing the method
- * @throws Zend_Amf_Server_Exception
- */
- protected function _dispatch($method, $params = null, $source = null)
- {
- if($source) {
- if(($mapped = Zend_Amf_Parse_TypeLoader::getMappedClassName($source)) !== false) {
- $source = $mapped;
- }
- }
- $qualifiedName = empty($source) ? $method : $source.".".$method;
-
- if (!isset($this->_table[$qualifiedName])) {
- // if source is null a method that was not defined was called.
- if ($source) {
- $className = str_replace(".", "_", $source);
- if(class_exists($className, false) && !isset($this->_classAllowed[$className])) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Can not call "' . $className . '" - use setClass()');
- }
- try {
- $this->getLoader()->load($className);
- } catch (Exception $e) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Class "' . $className . '" does not exist: '.$e->getMessage(), 0, $e);
- }
- // Add the new loaded class to the server.
- $this->setClass($className, $source);
- } else {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Method "' . $method . '" does not exist');
- }
- }
-
- $info = $this->_table[$qualifiedName];
- $argv = $info->getInvokeArguments();
-
- if (0 < count($argv)) {
- $params = array_merge($params, $argv);
- }
-
- if ($info instanceof Zend_Server_Reflection_Function) {
- $func = $info->getName();
- $this->_checkAcl(null, $func);
- $return = call_user_func_array($func, $params);
- } elseif ($info instanceof Zend_Server_Reflection_Method) {
- // Get class
- $class = $info->getDeclaringClass()->getName();
- if ('static' == $info->isStatic()) {
- // for some reason, invokeArgs() does not work the same as
- // invoke(), and expects the first argument to be an object.
- // So, using a callback if the method is static.
- $this->_checkAcl($class, $info->getName());
- $return = call_user_func_array(array($class, $info->getName()), $params);
- } else {
- // Object methods
- try {
- $object = $info->getDeclaringClass()->newInstance();
- } catch (Exception $e) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Error instantiating class ' . $class . ' to invoke method ' . $info->getName() . ': '.$e->getMessage(), 621, $e);
- }
- $this->_checkAcl($object, $info->getName());
- $return = $info->invokeArgs($object, $params);
- }
- } else {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Method missing implementation ' . get_class($info));
- }
-
- return $return;
- }
-
- /**
- * Handles each of the 11 different command message types.
- *
- * A command message is a flex.messaging.messages.CommandMessage
- *
- * @see Zend_Amf_Value_Messaging_CommandMessage
- * @param Zend_Amf_Value_Messaging_CommandMessage $message
- * @return Zend_Amf_Value_Messaging_AcknowledgeMessage
- */
- protected function _loadCommandMessage(Zend_Amf_Value_Messaging_CommandMessage $message)
- {
- require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
- switch($message->operation) {
- case Zend_Amf_Value_Messaging_CommandMessage::DISCONNECT_OPERATION :
- case Zend_Amf_Value_Messaging_CommandMessage::CLIENT_PING_OPERATION :
- $return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
- break;
- case Zend_Amf_Value_Messaging_CommandMessage::LOGIN_OPERATION :
- $data = explode(':', base64_decode($message->body));
- $userid = $data[0];
- $password = isset($data[1])?$data[1]:"";
- if(empty($userid)) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Login failed: username not supplied');
- }
- if(!$this->_handleAuth($userid, $password)) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Authentication failed');
- }
- $return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
- break;
- case Zend_Amf_Value_Messaging_CommandMessage::LOGOUT_OPERATION :
- if($this->_auth) {
- Zend_Auth::getInstance()->clearIdentity();
- }
- $return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
- break;
- default :
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('CommandMessage::' . $message->operation . ' not implemented');
- break;
- }
- return $return;
- }
-
- /**
- * Create appropriate error message
- *
- * @param int $objectEncoding Current AMF encoding
- * @param string $message Message that was being processed when error happened
- * @param string $description Error description
- * @param mixed $detail Detailed data about the error
- * @param int $code Error code
- * @param int $line Error line
- * @return Zend_Amf_Value_Messaging_ErrorMessage|array
- */
- protected function _errorMessage($objectEncoding, $message, $description, $detail, $code, $line)
- {
- $return = null;
- switch ($objectEncoding) {
- case Zend_Amf_Constants::AMF0_OBJECT_ENCODING :
- return array (
- 'description' => ($this->isProduction ()) ? '' : $description,
- 'detail' => ($this->isProduction ()) ? '' : $detail,
- 'line' => ($this->isProduction ()) ? 0 : $line,
- 'code' => $code
- );
- case Zend_Amf_Constants::AMF3_OBJECT_ENCODING :
- require_once 'Zend/Amf/Value/Messaging/ErrorMessage.php';
- $return = new Zend_Amf_Value_Messaging_ErrorMessage ( $message );
- $return->faultString = $this->isProduction () ? '' : $description;
- $return->faultCode = $code;
- $return->faultDetail = $this->isProduction () ? '' : $detail;
- break;
- }
- return $return;
- }
-
- /**
- * Handle AMF authentication
- *
- * @param string $userid
- * @param string $password
- * @return boolean
- */
- protected function _handleAuth( $userid, $password)
- {
- if (!$this->_auth) {
- return true;
- }
- $this->_auth->setCredentials($userid, $password);
- $auth = Zend_Auth::getInstance();
- $result = $auth->authenticate($this->_auth);
- if ($result->isValid()) {
- if (!$this->isSession()) {
- $this->setSession();
- }
- return true;
- } else {
- // authentication failed, good bye
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception(
- "Authentication failed: " . join("\n",
- $result->getMessages()), $result->getCode());
- }
-
- }
-
- /**
- * Takes the deserialized AMF request and performs any operations.
- *
- * @todo should implement and SPL observer pattern for custom AMF headers
- * @todo DescribeService support
- * @param Zend_Amf_Request $request
- * @return Zend_Amf_Response
- * @throws Zend_Amf_server_Exception|Exception
- */
- protected function _handle(Zend_Amf_Request $request)
- {
- // Get the object encoding of the request.
- $objectEncoding = $request->getObjectEncoding();
-
- // create a response object to place the output from the services.
- $response = $this->getResponse();
-
- // set response encoding
- $response->setObjectEncoding($objectEncoding);
-
- $responseBody = $request->getAmfBodies();
-
- $handleAuth = false;
- if ($this->_auth) {
- $headers = $request->getAmfHeaders();
- if (isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER]) &&
- isset($headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->userid)) {
- $handleAuth = true;
- }
- }
-
- // Iterate through each of the service calls in the AMF request
- foreach($responseBody as $body)
- {
- try {
- if ($handleAuth) {
- if ($this->_handleAuth(
- $headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->userid,
- $headers[Zend_Amf_Constants::CREDENTIALS_HEADER]->password)) {
- // use RequestPersistentHeader to clear credentials
- $response->addAmfHeader(
- new Zend_Amf_Value_MessageHeader(
- Zend_Amf_Constants::PERSISTENT_HEADER,
- false,
- new Zend_Amf_Value_MessageHeader(
- Zend_Amf_Constants::CREDENTIALS_HEADER,
- false, null)));
- $handleAuth = false;
- }
- }
-
- if ($objectEncoding == Zend_Amf_Constants::AMF0_OBJECT_ENCODING) {
- // AMF0 Object Encoding
- $targetURI = $body->getTargetURI();
- $message = '';
-
- // Split the target string into its values.
- $source = substr($targetURI, 0, strrpos($targetURI, '.'));
-
- if ($source) {
- // Break off method name from namespace into source
- $method = substr(strrchr($targetURI, '.'), 1);
- $return = $this->_dispatch($method, $body->getData(), $source);
- } else {
- // Just have a method name.
- $return = $this->_dispatch($targetURI, $body->getData());
- }
- } else {
- // AMF3 read message type
- $message = $body->getData();
- if ($message instanceof Zend_Amf_Value_Messaging_CommandMessage) {
- // async call with command message
- $return = $this->_loadCommandMessage($message);
- } elseif ($message instanceof Zend_Amf_Value_Messaging_RemotingMessage) {
- require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
- $return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
- $return->body = $this->_dispatch($message->operation, $message->body, $message->source);
- } else {
- // Amf3 message sent with netConnection
- $targetURI = $body->getTargetURI();
-
- // Split the target string into its values.
- $source = substr($targetURI, 0, strrpos($targetURI, '.'));
-
- if ($source) {
- // Break off method name from namespace into source
- $method = substr(strrchr($targetURI, '.'), 1);
- $return = $this->_dispatch($method, $body->getData(), $source);
- } else {
- // Just have a method name.
- $return = $this->_dispatch($targetURI, $body->getData());
- }
- }
- }
- $responseType = Zend_AMF_Constants::RESULT_METHOD;
- } catch (Exception $e) {
- $return = $this->_errorMessage($objectEncoding, $message,
- $e->getMessage(), $e->getTraceAsString(),$e->getCode(), $e->getLine());
- $responseType = Zend_AMF_Constants::STATUS_METHOD;
- }
-
- $responseURI = $body->getResponseURI() . $responseType;
- $newBody = new Zend_Amf_Value_MessageBody($responseURI, null, $return);
- $response->addAmfBody($newBody);
- }
- // Add a session header to the body if session is requested.
- if($this->isSession()) {
- $currentID = session_id();
- $joint = "?";
- if(isset($_SERVER['QUERY_STRING'])) {
- if(!strpos($_SERVER['QUERY_STRING'], $currentID) !== FALSE) {
- if(strrpos($_SERVER['QUERY_STRING'], "?") !== FALSE) {
- $joint = "&";
- }
- }
- }
-
- // create a new AMF message header with the session id as a variable.
- $sessionValue = $joint . $this->_sessionName . "=" . $currentID;
- $sessionHeader = new Zend_Amf_Value_MessageHeader(Zend_Amf_Constants::URL_APPEND_HEADER, false, $sessionValue);
- $response->addAmfHeader($sessionHeader);
- }
-
- // serialize the response and return serialized body.
- $response->finalize();
- }
-
- /**
- * Handle an AMF call from the gateway.
- *
- * @param null|Zend_Amf_Request $request Optional
- * @return Zend_Amf_Response
- */
- public function handle($request = null)
- {
- // Check if request was passed otherwise get it from the server
- if (is_null($request) || !$request instanceof Zend_Amf_Request) {
- $request = $this->getRequest();
- } else {
- $this->setRequest($request);
- }
- if ($this->isSession()) {
- // Check if a session is being sent from the amf call
- if (isset($_COOKIE[$this->_sessionName])) {
- session_id($_COOKIE[$this->_sessionName]);
- }
- }
-
- // Check for errors that may have happend in deserialization of Request.
- try {
- // Take converted PHP objects and handle service call.
- // Serialize to Zend_Amf_response for output stream
- $this->_handle($request);
- $response = $this->getResponse();
- } catch (Exception $e) {
- // Handle any errors in the serialization and service calls.
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Handle error: ' . $e->getMessage() . ' ' . $e->getLine(), 0, $e);
- }
-
- // Return the Amf serialized output string
- return $response;
- }
-
- /**
- * Set request object
- *
- * @param string|Zend_Amf_Request $request
- * @return Zend_Amf_Server
- */
- public function setRequest($request)
- {
- if (is_string($request) && class_exists($request)) {
- $request = new $request();
- if (!$request instanceof Zend_Amf_Request) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Invalid request class');
- }
- } elseif (!$request instanceof Zend_Amf_Request) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Invalid request object');
- }
- $this->_request = $request;
- return $this;
- }
-
- /**
- * Return currently registered request object
- *
- * @return null|Zend_Amf_Request
- */
- public function getRequest()
- {
- if (null === $this->_request) {
- require_once 'Zend/Amf/Request/Http.php';
- $this->setRequest(new Zend_Amf_Request_Http());
- }
-
- return $this->_request;
- }
-
- /**
- * Public access method to private Zend_Amf_Server_Response reference
- *
- * @param string|Zend_Amf_Server_Response $response
- * @return Zend_Amf_Server
- */
- public function setResponse($response)
- {
- if (is_string($response) && class_exists($response)) {
- $response = new $response();
- if (!$response instanceof Zend_Amf_Response) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Invalid response class');
- }
- } elseif (!$response instanceof Zend_Amf_Response) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Invalid response object');
- }
- $this->_response = $response;
- return $this;
- }
-
- /**
- * get a reference to the Zend_Amf_response instance
- *
- * @return Zend_Amf_Server_Response
- */
- public function getResponse()
- {
- if (null === ($response = $this->_response)) {
- require_once 'Zend/Amf/Response/Http.php';
- $this->setResponse(new Zend_Amf_Response_Http());
- }
- return $this->_response;
- }
-
- /**
- * Attach a class or object to the server
- *
- * Class may be either a class name or an instantiated object. Reflection
- * is done on the class or object to determine the available public
- * methods, and each is attached to the server as and available method. If
- * a $namespace has been provided, that namespace is used to prefix
- * AMF service call.
- *
- * @param string|object $class
- * @param string $namespace Optional
- * @param mixed $arg Optional arguments to pass to a method
- * @return Zend_Amf_Server
- * @throws Zend_Amf_Server_Exception on invalid input
- */
- public function setClass($class, $namespace = '', $argv = null)
- {
- if (is_string($class) && !class_exists($class)){
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Invalid method or class');
- } elseif (!is_string($class) && !is_object($class)) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Invalid method or class; must be a classname or object');
- }
-
- $argv = null;
- if (2 < func_num_args()) {
- $argv = array_slice(func_get_args(), 2);
- }
-
- // Use the class name as the name space by default.
-
- if ($namespace == '') {
- $namespace = is_object($class) ? get_class($class) : $class;
- }
-
- $this->_classAllowed[is_object($class) ? get_class($class) : $class] = true;
-
- $this->_methods[] = Zend_Server_Reflection::reflectClass($class, $argv, $namespace);
- $this->_buildDispatchTable();
-
- return $this;
- }
-
- /**
- * Attach a function to the server
- *
- * Additional arguments to pass to the function at dispatch may be passed;
- * any arguments following the namespace will be aggregated and passed at
- * dispatch time.
- *
- * @param string|array $function Valid callback
- * @param string $namespace Optional namespace prefix
- * @return Zend_Amf_Server
- * @throws Zend_Amf_Server_Exception
- */
- public function addFunction($function, $namespace = '')
- {
- if (!is_string($function) && !is_array($function)) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Unable to attach function');
- }
-
- $argv = null;
- if (2 < func_num_args()) {
- $argv = array_slice(func_get_args(), 2);
- }
-
- $function = (array) $function;
- foreach ($function as $func) {
- if (!is_string($func) || !function_exists($func)) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Unable to attach function');
- }
- $this->_methods[] = Zend_Server_Reflection::reflectFunction($func, $argv, $namespace);
- }
-
- $this->_buildDispatchTable();
- return $this;
- }
-
-
- /**
- * Creates an array of directories in which services can reside.
- * TODO: add support for prefixes?
- *
- * @param string $dir
- */
- public function addDirectory($dir)
- {
- $this->getLoader()->addPrefixPath("", $dir);
- }
-
- /**
- * Returns an array of directories that can hold services.
- *
- * @return array
- */
- public function getDirectory()
- {
- return $this->getLoader()->getPaths("");
- }
-
- /**
- * (Re)Build the dispatch table
- *
- * The dispatch table consists of a an array of method name =>
- * Zend_Server_Reflection_Function_Abstract pairs
- *
- * @return void
- */
- protected function _buildDispatchTable()
- {
- $table = array();
- foreach ($this->_methods as $key => $dispatchable) {
- if ($dispatchable instanceof Zend_Server_Reflection_Function_Abstract) {
- $ns = $dispatchable->getNamespace();
- $name = $dispatchable->getName();
- $name = empty($ns) ? $name : $ns . '.' . $name;
-
- if (isset($table[$name])) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Duplicate method registered: ' . $name);
- }
- $table[$name] = $dispatchable;
- continue;
- }
-
- if ($dispatchable instanceof Zend_Server_Reflection_Class) {
- foreach ($dispatchable->getMethods() as $method) {
- $ns = $method->getNamespace();
- $name = $method->getName();
- $name = empty($ns) ? $name : $ns . '.' . $name;
-
- if (isset($table[$name])) {
- require_once 'Zend/Amf/Server/Exception.php';
- throw new Zend_Amf_Server_Exception('Duplicate method registered: ' . $name);
- }
- $table[$name] = $method;
- continue;
- }
- }
- }
- $this->_table = $table;
- }
-
-
-
- /**
- * Raise a server fault
- *
- * Unimplemented
- *
- * @param string|Exception $fault
- * @return void
- */
- public function fault($fault = null, $code = 404)
- {
- }
-
- /**
- * Returns a list of registered methods
- *
- * Returns an array of dispatchables (Zend_Server_Reflection_Function,
- * _Method, and _Class items).
- *
- * @return array
- */
- public function getFunctions()
- {
- return $this->_table;
- }
-
- /**
- * Set server persistence
- *
- * Unimplemented
- *
- * @param mixed $mode
- * @return void
- */
- public function setPersistence($mode)
- {
- }
-
- /**
- * Load server definition
- *
- * Unimplemented
- *
- * @param array $definition
- * @return void
- */
- public function loadFunctions($definition)
- {
- }
-
- /**
- * Map ActionScript classes to PHP classes
- *
- * @param string $asClass
- * @param string $phpClass
- * @return Zend_Amf_Server
- */
- public function setClassMap($asClass, $phpClass)
- {
- require_once 'Zend/Amf/Parse/TypeLoader.php';
- Zend_Amf_Parse_TypeLoader::setMapping($asClass, $phpClass);
- return $this;
- }
-
- /**
- * List all available methods
- *
- * Returns an array of method names.
- *
- * @return array
- */
- public function listMethods()
- {
- return array_keys($this->_table);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Util/BinaryStream.php zendframework-2.2.6/library/Zend/Amf/Util/BinaryStream.php
--- zendframework-1.10.4/library/Zend/Amf/Util/BinaryStream.php 2010-02-27 10:37:39.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Util/BinaryStream.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,285 +0,0 @@
-_stream = $stream;
- $this->_needle = 0;
- $this->_streamLength = strlen($stream);
- $this->_bigEndian = (pack('l', 1) === "\x00\x00\x00\x01");
- }
-
- /**
- * Returns the current stream
- *
- * @return string
- */
- public function getStream()
- {
- return $this->_stream;
- }
-
- /**
- * Read the number of bytes in a row for the length supplied.
- *
- * @todo Should check that there are enough bytes left in the stream we are about to read.
- * @param int $length
- * @return string
- * @throws Zend_Amf_Exception for buffer underrun
- */
- public function readBytes($length)
- {
- if (($length + $this->_needle) > $this->_streamLength) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Buffer underrun at needle position: ' . $this->_needle . ' while requesting length: ' . $length);
- }
- $bytes = substr($this->_stream, $this->_needle, $length);
- $this->_needle+= $length;
- return $bytes;
- }
-
- /**
- * Write any length of bytes to the stream
- *
- * Usually a string.
- *
- * @param string $bytes
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeBytes($bytes)
- {
- $this->_stream.= $bytes;
- return $this;
- }
-
- /**
- * Reads a signed byte
- *
- * @return int Value is in the range of -128 to 127.
- */
- public function readByte()
- {
- if (($this->_needle + 1) > $this->_streamLength) {
- require_once 'Zend/Amf/Exception.php';
- throw new Zend_Amf_Exception('Buffer underrun at needle position: ' . $this->_needle . ' while requesting length: ' . $length);
- }
-
- return ord($this->_stream{$this->_needle++});
- }
-
- /**
- * Writes the passed string into a signed byte on the stream.
- *
- * @param string $stream
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeByte($stream)
- {
- $this->_stream.= pack('c', $stream);
- return $this;
- }
-
- /**
- * Reads a signed 32-bit integer from the data stream.
- *
- * @return int Value is in the range of -2147483648 to 2147483647
- */
- public function readInt()
- {
- return ($this->readByte() << 8) + $this->readByte();
- }
-
- /**
- * Write an the integer to the output stream as a 32 bit signed integer
- *
- * @param int $stream
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeInt($stream)
- {
- $this->_stream.= pack('n', $stream);
- return $this;
- }
-
- /**
- * Reads a UTF-8 string from the data stream
- *
- * @return string A UTF-8 string produced by the byte representation of characters
- */
- public function readUtf()
- {
- $length = $this->readInt();
- return $this->readBytes($length);
- }
-
- /**
- * Wite a UTF-8 string to the outputstream
- *
- * @param string $stream
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeUtf($stream)
- {
- $this->writeInt(strlen($stream));
- $this->_stream.= $stream;
- return $this;
- }
-
-
- /**
- * Read a long UTF string
- *
- * @return string
- */
- public function readLongUtf()
- {
- $length = $this->readLong();
- return $this->readBytes($length);
- }
-
- /**
- * Write a long UTF string to the buffer
- *
- * @param string $stream
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeLongUtf($stream)
- {
- $this->writeLong(strlen($stream));
- $this->_stream.= $stream;
- }
-
- /**
- * Read a long numeric value
- *
- * @return double
- */
- public function readLong()
- {
- return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
- }
-
- /**
- * Write long numeric value to output stream
- *
- * @param int|string $stream
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeLong($stream)
- {
- $this->_stream.= pack('N', $stream);
- return $this;
- }
-
- /**
- * Read a 16 bit unsigned short.
- *
- * @todo This could use the unpack() w/ S,n, or v
- * @return double
- */
- public function readUnsignedShort()
- {
- $byte1 = $this->readByte();
- $byte2 = $this->readByte();
- return (($byte1 << 8) | $byte2);
- }
-
- /**
- * Reads an IEEE 754 double-precision floating point number from the data stream.
- *
- * @return double Floating point number
- */
- public function readDouble()
- {
- $bytes = substr($this->_stream, $this->_needle, 8);
- $this->_needle+= 8;
-
- if (!$this->_bigEndian) {
- $bytes = strrev($bytes);
- }
-
- $double = unpack('dflt', $bytes);
- return $double['flt'];
- }
-
- /**
- * Writes an IEEE 754 double-precision floating point number from the data stream.
- *
- * @param string|double $stream
- * @return Zend_Amf_Util_BinaryStream
- */
- public function writeDouble($stream)
- {
- $stream = pack('d', $stream);
- if (!$this->_bigEndian) {
- $stream = strrev($stream);
- }
- $this->_stream.= $stream;
- return $this;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Value/ByteArray.php zendframework-2.2.6/library/Zend/Amf/Value/ByteArray.php
--- zendframework-1.10.4/library/Zend/Amf/Value/ByteArray.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Value/ByteArray.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,58 +0,0 @@
-_data = $data;
- }
-
- /**
- * Return the byte stream
- *
- * @return string
- */
- public function getData()
- {
- return $this->_data;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Value/MessageBody.php zendframework-2.2.6/library/Zend/Amf/Value/MessageBody.php
--- zendframework-1.10.4/library/Zend/Amf/Value/MessageBody.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Value/MessageBody.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,182 +0,0 @@
-
- * This Message structure defines how a local client would
- * invoke a method/operation on a remote server. Additionally,
- * the response from the Server is structured identically.
- *
- * @package Zend_Amf
- * @subpackage Value
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_Amf_Value_MessageBody
-{
- /**
- * A string describing which operation, function, or method
- * is to be remotley invoked.
- * @var string
- */
- protected $_targetUri = "";
-
- /**
- * Universal Resource Identifier that uniquely targets the originator's
- * Object that should receive the server's response. The server will
- * use this path specification to target the "OnResult()" or "onStatus()"
- * handlers within the client. For Flash, it specifies an ActionScript
- * Object path only. The NetResponse object pointed to by the Response Uri
- * contains the connection state information. Passing/specifying this
- * provides a convenient mechanism for the client/server to share access
- * to an object that is managing the state of the shared connection.
- *
- * Since the server will use this field in the event of an error,
- * this field is required even if a successful server request would
- * not be expected to return a value to the client.
- *
- * @var string
- */
- protected $_responseUri = "";
-
- /**
- * Contains the actual data associated with the operation. It contains
- * the client's parameter data that is passed to the server's operation/method.
- * When serializing a root level data type or a parameter list array, no
- * name field is included. That is, the data is anonomously represented
- * as "Type Marker"/"Value" pairs. When serializing member data, the data is
- * represented as a series of "Name"/"Type"/"Value" combinations.
- *
- * For server generated responses, it may contain any ActionScript
- * data/objects that the server was expected to provide.
- *
- * @var string
- */
- protected $_data;
-
- /**
- * Constructor
- *
- * @param string $targetUri
- * @param string $responseUri
- * @param string $data
- * @return void
- */
- public function __construct($targetUri, $responseUri, $data)
- {
- $this->setTargetUri($targetUri);
- $this->setResponseUri($responseUri);
- $this->setData($data);
- }
-
- /**
- * Retrieve target Uri
- *
- * @return string
- */
- public function getTargetUri()
- {
- return $this->_targetUri;
- }
-
- /**
- * Set target Uri
- *
- * @param string $targetUri
- * @return Zend_Amf_Value_MessageBody
- */
- public function setTargetUri($targetUri)
- {
- if (null === $targetUri) {
- $targetUri = '';
- }
- $this->_targetUri = (string) $targetUri;
- return $this;
- }
-
- /**
- * Get target Uri
- *
- * @return string
- */
- public function getResponseUri()
- {
- return $this->_responseUri;
- }
-
- /**
- * Set response Uri
- *
- * @param string $responseUri
- * @return Zend_Amf_Value_MessageBody
- */
- public function setResponseUri($responseUri)
- {
- if (null === $responseUri) {
- $responseUri = '';
- }
- $this->_responseUri = $responseUri;
- return $this;
- }
-
- /**
- * Retrieve response data
- *
- * @return string
- */
- public function getData()
- {
- return $this->_data;
- }
-
- /**
- * Set response data
- *
- * @param mixed $data
- * @return Zend_Amf_Value_MessageBody
- */
- public function setData($data)
- {
- $this->_data = $data;
- return $this;
- }
-
- /**
- * Set reply method
- *
- * @param string $methodName
- * @return Zend_Amf_Value_MessageBody
- */
- public function setReplyMethod($methodName)
- {
- if (!preg_match('#^[/?]#', $methodName)) {
- $this->_targetUri = rtrim($this->_targetUri, '/') . '/';
- }
- $this->_targetUri = $this->_targetUri . $methodName;
- return $this;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Value/MessageHeader.php zendframework-2.2.6/library/Zend/Amf/Value/MessageHeader.php
--- zendframework-1.10.4/library/Zend/Amf/Value/MessageHeader.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Value/MessageHeader.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,81 +0,0 @@
-name = $name;
- $this->mustRead = (bool) $mustRead;
- $this->data = $data;
- if (null !== $length) {
- $this->length = (int) $length;
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Value/Messaging/AbstractMessage.php zendframework-2.2.6/library/Zend/Amf/Value/Messaging/AbstractMessage.php
--- zendframework-1.10.4/library/Zend/Amf/Value/Messaging/AbstractMessage.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Value/Messaging/AbstractMessage.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,92 +0,0 @@
-clientId = $this->generateId();
- $this->destination = null;
- $this->messageId = $this->generateId();
- $this->timestamp = time().'00';
- $this->timeToLive = 0;
- $this->headers = new STDClass();
- $this->body = null;
-
- // correleate the two messages
- if ($message && isset($message->messageId)) {
- $this->correlationId = $message->messageId;
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Value/Messaging/ArrayCollection.php zendframework-2.2.6/library/Zend/Amf/Value/Messaging/ArrayCollection.php
--- zendframework-1.10.4/library/Zend/Amf/Value/Messaging/ArrayCollection.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Value/Messaging/ArrayCollection.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,35 +0,0 @@
-body
- * of the message.
- */
- const LOGIN_OPERATION = 8;
-
- /**
- * This operation is used to log the user out of the current channel, and
- * will invalidate the server session if the channel is HTTP based.
- */
- const LOGOUT_OPERATION = 9;
-
- /**
- * This operation is used to indicate that the client's subscription to a
- * remote destination has been invalidated.
- */
- const SESSION_INVALIDATE_OPERATION = 10;
-
- /**
- * This operation is used by the MultiTopicConsumer to subscribe/unsubscribe
- * from multiple subtopics/selectors in the same message.
- */
- const MULTI_SUBSCRIBE_OPERATION = 11;
-
- /**
- * This operation is used to indicate that a channel has disconnected
- */
- const DISCONNECT_OPERATION = 12;
-
- /**
- * This is the default operation for new CommandMessage instances.
- */
- const UNKNOWN_OPERATION = 10000;
-
- /**
- * The operation to execute for messages of this type
- * @var int
- */
- public $operation = self::UNKNOWN_OPERATION;
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Value/Messaging/ErrorMessage.php zendframework-2.2.6/library/Zend/Amf/Value/Messaging/ErrorMessage.php
--- zendframework-1.10.4/library/Zend/Amf/Value/Messaging/ErrorMessage.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Value/Messaging/ErrorMessage.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,67 +0,0 @@
-clientId = $this->generateId();
- $this->destination = null;
- $this->messageId = $this->generateId();
- $this->timestamp = time().'00';
- $this->timeToLive = 0;
- $this->headers = new stdClass();
- $this->body = null;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Amf/Value/TraitsInfo.php zendframework-2.2.6/library/Zend/Amf/Value/TraitsInfo.php
--- zendframework-1.10.4/library/Zend/Amf/Value/TraitsInfo.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Amf/Value/TraitsInfo.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,154 +0,0 @@
-_className = $className;
- $this->_dynamic = $dynamic;
- $this->_externalizable = $externalizable;
- $this->_properties = $properties;
- }
-
- /**
- * Test if the class is a dynamic class
- *
- * @return boolean
- */
- public function isDynamic()
- {
- return $this->_dynamic;
- }
-
- /**
- * Test if class is externalizable
- *
- * @return boolean
- */
- public function isExternalizable()
- {
- return $this->_externalizable;
- }
-
- /**
- * Return the number of properties in the class
- *
- * @return int
- */
- public function length()
- {
- return count($this->_properties);
- }
-
- /**
- * Return the class name
- *
- * @return string
- */
- public function getClassName()
- {
- return $this->_className;
- }
-
- /**
- * Add an additional property
- *
- * @param string $name
- * @return Zend_Amf_Value_TraitsInfo
- */
- public function addProperty($name)
- {
- $this->_properties[] = $name;
- return $this;
- }
-
- /**
- * Add all properties of the class.
- *
- * @param array $props
- * @return Zend_Amf_Value_TraitsInfo
- */
- public function addAllProperties(array $props)
- {
- $this->_properties = $props;
- return $this;
- }
-
- /**
- * Get the property at a given index
- *
- * @param int $index
- * @return string
- */
- public function getProperty($index)
- {
- return $this->_properties[(int) $index];
- }
-
- /**
- * Return all properties of the class.
- *
- * @return array
- */
- public function getAllProperties()
- {
- return $this->_properties;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Bootstrap/BootstrapAbstract.php zendframework-2.2.6/library/Zend/Application/Bootstrap/BootstrapAbstract.php
--- zendframework-1.10.4/library/Zend/Application/Bootstrap/BootstrapAbstract.php 2010-02-08 16:44:44.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Bootstrap/BootstrapAbstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,768 +0,0 @@
-setApplication($application);
- $options = $application->getOptions();
- $this->setOptions($options);
- }
-
- /**
- * Set class state
- *
- * @param array $options
- * @return Zend_Application_Bootstrap_BootstrapAbstract
- */
- public function setOptions(array $options)
- {
- $this->_options = $this->mergeOptions($this->_options, $options);
-
- $options = array_change_key_case($options, CASE_LOWER);
- $this->_optionKeys = array_merge($this->_optionKeys, array_keys($options));
-
- $methods = get_class_methods($this);
- foreach ($methods as $key => $method) {
- $methods[$key] = strtolower($method);
- }
-
- if (array_key_exists('pluginpaths', $options)) {
- $pluginLoader = $this->getPluginLoader();
-
- foreach ($options['pluginpaths'] as $prefix => $path) {
- $pluginLoader->addPrefixPath($prefix, $path);
- }
- unset($options['pluginpaths']);
- }
-
- foreach ($options as $key => $value) {
- $method = 'set' . strtolower($key);
-
- if (in_array($method, $methods)) {
- $this->$method($value);
- } elseif ('resources' == $key) {
- foreach ($value as $resource => $resourceOptions) {
- $this->registerPluginResource($resource, $resourceOptions);
- }
- }
- }
- return $this;
- }
-
- /**
- * Get current options from bootstrap
- *
- * @return array
- */
- public function getOptions()
- {
- return $this->_options;
- }
-
- /**
- * Is an option present?
- *
- * @param string $key
- * @return bool
- */
- public function hasOption($key)
- {
- return in_array($key, $this->_optionKeys);
- }
-
- /**
- * Retrieve a single option
- *
- * @param string $key
- * @return mixed
- */
- public function getOption($key)
- {
- if ($this->hasOption($key)) {
- $options = $this->getOptions();
- $options = array_change_key_case($options, CASE_LOWER);
- return $options[strtolower($key)];
- }
- return null;
- }
-
- /**
- * Merge options recursively
- *
- * @param array $array1
- * @param mixed $array2
- * @return array
- */
- public function mergeOptions(array $array1, $array2 = null)
- {
- if (is_array($array2)) {
- foreach ($array2 as $key => $val) {
- if (is_array($array2[$key])) {
- $array1[$key] = (array_key_exists($key, $array1) && is_array($array1[$key]))
- ? $this->mergeOptions($array1[$key], $array2[$key])
- : $array2[$key];
- } else {
- $array1[$key] = $val;
- }
- }
- }
- return $array1;
- }
-
- /**
- * Get class resources (as resource/method pairs)
- *
- * Uses get_class_methods() by default, reflection on prior to 5.2.6,
- * as a bug prevents the usage of get_class_methods() there.
- *
- * @return array
- */
- public function getClassResources()
- {
- if (null === $this->_classResources) {
- if (version_compare(PHP_VERSION, '5.2.6') === -1) {
- $class = new ReflectionObject($this);
- $classMethods = $class->getMethods();
- $methodNames = array();
-
- foreach ($classMethods as $method) {
- $methodNames[] = $method->getName();
- }
- } else {
- $methodNames = get_class_methods($this);
- }
-
- $this->_classResources = array();
- foreach ($methodNames as $method) {
- if (5 < strlen($method) && '_init' === substr($method, 0, 5)) {
- $this->_classResources[strtolower(substr($method, 5))] = $method;
- }
- }
- }
-
- return $this->_classResources;
- }
-
- /**
- * Get class resource names
- *
- * @return array
- */
- public function getClassResourceNames()
- {
- $resources = $this->getClassResources();
- return array_keys($resources);
- }
-
- /**
- * Register a new resource plugin
- *
- * @param string|Zend_Application_Resource_Resource $resource
- * @param mixed $options
- * @return Zend_Application_Bootstrap_BootstrapAbstract
- * @throws Zend_Application_Bootstrap_Exception When invalid resource is provided
- */
- public function registerPluginResource($resource, $options = null)
- {
- if ($resource instanceof Zend_Application_Resource_Resource) {
- $resource->setBootstrap($this);
- $pluginName = $this->_resolvePluginResourceName($resource);
- $this->_pluginResources[$pluginName] = $resource;
- return $this;
- }
-
- if (!is_string($resource)) {
- throw new Zend_Application_Bootstrap_Exception('Invalid resource provided to ' . __METHOD__);
- }
-
- $this->_pluginResources[$resource] = $options;
- return $this;
- }
-
- /**
- * Unregister a resource from the bootstrap
- *
- * @param string|Zend_Application_Resource_Resource $resource
- * @return Zend_Application_Bootstrap_BootstrapAbstract
- * @throws Zend_Application_Bootstrap_Exception When unknown resource type is provided
- */
- public function unregisterPluginResource($resource)
- {
- if ($resource instanceof Zend_Application_Resource_Resource) {
- if ($index = array_search($resource, $this->_pluginResources, true)) {
- unset($this->_pluginResources[$index]);
- }
- return $this;
- }
-
- if (!is_string($resource)) {
- throw new Zend_Application_Bootstrap_Exception('Unknown resource type provided to ' . __METHOD__);
- }
-
- $resource = strtolower($resource);
- if (array_key_exists($resource, $this->_pluginResources)) {
- unset($this->_pluginResources[$resource]);
- }
-
- return $this;
- }
-
- /**
- * Is the requested plugin resource registered?
- *
- * @param string $resource
- * @return bool
- */
- public function hasPluginResource($resource)
- {
- return (null !== $this->getPluginResource($resource));
- }
-
- /**
- * Get a registered plugin resource
- *
- * @param string $resourceName
- * @return Zend_Application_Resource_Resource
- */
- public function getPluginResource($resource)
- {
- if (array_key_exists(strtolower($resource), $this->_pluginResources)) {
- $resource = strtolower($resource);
- if (!$this->_pluginResources[$resource] instanceof Zend_Application_Resource_Resource) {
- $resourceName = $this->_loadPluginResource($resource, $this->_pluginResources[$resource]);
- if (!$resourceName) {
- throw new Zend_Application_Bootstrap_Exception(sprintf('Unable to resolve plugin "%s"; no corresponding plugin with that name', $resource));
- }
- $resource = $resourceName;
- }
- return $this->_pluginResources[$resource];
- }
-
- foreach ($this->_pluginResources as $plugin => $spec) {
- if ($spec instanceof Zend_Application_Resource_Resource) {
- $pluginName = $this->_resolvePluginResourceName($spec);
- if (0 === strcasecmp($resource, $pluginName)) {
- unset($this->_pluginResources[$plugin]);
- $this->_pluginResources[$pluginName] = $spec;
- return $spec;
- }
- continue;
- }
-
- if (false !== $pluginName = $this->_loadPluginResource($plugin, $spec)) {
- if (0 === strcasecmp($resource, $pluginName)) {
- return $this->_pluginResources[$pluginName];
- }
- }
-
- if (class_exists($plugin)) { //@SEE ZF-7550
- $spec = (array) $spec;
- $spec['bootstrap'] = $this;
- $instance = new $plugin($spec);
- $pluginName = $this->_resolvePluginResourceName($instance);
- unset($this->_pluginResources[$plugin]);
- $this->_pluginResources[$pluginName] = $instance;
-
- if (0 === strcasecmp($resource, $pluginName)) {
- return $instance;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Retrieve all plugin resources
- *
- * @return array
- */
- public function getPluginResources()
- {
- foreach (array_keys($this->_pluginResources) as $resource) {
- $this->getPluginResource($resource);
- }
- return $this->_pluginResources;
- }
-
- /**
- * Retrieve plugin resource names
- *
- * @return array
- */
- public function getPluginResourceNames()
- {
- $this->getPluginResources();
- return array_keys($this->_pluginResources);
- }
-
- /**
- * Set plugin loader for loading resources
- *
- * @param Zend_Loader_PluginLoader_Interface $loader
- * @return Zend_Application_Bootstrap_BootstrapAbstract
- */
- public function setPluginLoader(Zend_Loader_PluginLoader_Interface $loader)
- {
- $this->_pluginLoader = $loader;
- return $this;
- }
-
- /**
- * Get the plugin loader for resources
- *
- * @return Zend_Loader_PluginLoader_Interface
- */
- public function getPluginLoader()
- {
- if ($this->_pluginLoader === null) {
- $options = array(
- 'Zend_Application_Resource' => 'Zend/Application/Resource'
- );
-
- $this->_pluginLoader = new Zend_Loader_PluginLoader($options);
- }
-
- return $this->_pluginLoader;
- }
-
- /**
- * Set application/parent bootstrap
- *
- * @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
- * @return Zend_Application_Bootstrap_BootstrapAbstract
- */
- public function setApplication($application)
- {
- if (($application instanceof Zend_Application)
- || ($application instanceof Zend_Application_Bootstrap_Bootstrapper)
- ) {
- if ($application === $this) {
- throw new Zend_Application_Bootstrap_Exception('Cannot set application to same object; creates recursion');
- }
- $this->_application = $application;
- } else {
- throw new Zend_Application_Bootstrap_Exception('Invalid application provided to bootstrap constructor (received "' . get_class($application) . '" instance)');
- }
- return $this;
- }
-
- /**
- * Retrieve parent application instance
- *
- * @return Zend_Application|Zend_Application_Bootstrap_Bootstrapper
- */
- public function getApplication()
- {
- return $this->_application;
- }
-
- /**
- * Retrieve application environment
- *
- * @return string
- */
- public function getEnvironment()
- {
- if (null === $this->_environment) {
- $this->_environment = $this->getApplication()->getEnvironment();
- }
- return $this->_environment;
- }
-
- /**
- * Set resource container
- *
- * By default, if a resource callback has a non-null return value, this
- * value will be stored in a container using the resource name as the
- * key.
- *
- * Containers must be objects, and must allow setting public properties.
- *
- * @param object $container
- * @return Zend_Application_Bootstrap_BootstrapAbstract
- */
- public function setContainer($container)
- {
- if (!is_object($container)) {
- throw new Zend_Application_Bootstrap_Exception('Resource containers must be objects');
- }
- $this->_container = $container;
- return $this;
- }
-
- /**
- * Retrieve resource container
- *
- * @return object
- */
- public function getContainer()
- {
- if (null === $this->_container) {
- $this->setContainer(new Zend_Registry());
- }
- return $this->_container;
- }
-
- /**
- * Determine if a resource has been stored in the container
- *
- * During bootstrap resource initialization, you may return a value. If
- * you do, it will be stored in the {@link setContainer() container}.
- * You can use this method to determine if a value was stored.
- *
- * @param string $name
- * @return bool
- */
- public function hasResource($name)
- {
- $resource = strtolower($name);
- $container = $this->getContainer();
- return isset($container->{$resource});
- }
-
- /**
- * Retrieve a resource from the container
- *
- * During bootstrap resource initialization, you may return a value. If
- * you do, it will be stored in the {@link setContainer() container}.
- * You can use this method to retrieve that value.
- *
- * If no value was returned, this will return a null value.
- *
- * @param string $name
- * @return null|mixed
- */
- public function getResource($name)
- {
- $resource = strtolower($name);
- $container = $this->getContainer();
- if ($this->hasResource($resource)) {
- return $container->{$resource};
- }
- return null;
- }
-
- /**
- * Implement PHP's magic to retrieve a ressource
- * in the bootstrap
- *
- * @param string $prop
- * @return null|mixed
- */
- public function __get($prop)
- {
- return $this->getResource($prop);
- }
-
- /**
- * Implement PHP's magic to ask for the
- * existence of a ressource in the bootstrap
- *
- * @param string $prop
- * @return bool
- */
- public function __isset($prop)
- {
- return $this->hasResource($prop);
- }
-
- /**
- * Bootstrap individual, all, or multiple resources
- *
- * Marked as final to prevent issues when subclassing and naming the
- * child class 'Bootstrap' (in which case, overriding this method
- * would result in it being treated as a constructor).
- *
- * If you need to override this functionality, override the
- * {@link _bootstrap()} method.
- *
- * @param null|string|array $resource
- * @return Zend_Application_Bootstrap_BootstrapAbstract
- * @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
- */
- final public function bootstrap($resource = null)
- {
- $this->_bootstrap($resource);
- return $this;
- }
-
- /**
- * Overloading: intercept calls to bootstrap() methods
- *
- * @param string $method
- * @param array $args
- * @return void
- * @throws Zend_Application_Bootstrap_Exception On invalid method name
- */
- public function __call($method, $args)
- {
- if (9 < strlen($method) && 'bootstrap' === substr($method, 0, 9)) {
- $resource = substr($method, 9);
- return $this->bootstrap($resource);
- }
-
- throw new Zend_Application_Bootstrap_Exception('Invalid method "' . $method . '"');
- }
-
- /**
- * Bootstrap implementation
- *
- * This method may be overridden to provide custom bootstrapping logic.
- * It is the sole method called by {@link bootstrap()}.
- *
- * @param null|string|array $resource
- * @return void
- * @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
- */
- protected function _bootstrap($resource = null)
- {
- if (null === $resource) {
- foreach ($this->getClassResourceNames() as $resource) {
- $this->_executeResource($resource);
- }
-
- foreach ($this->getPluginResourceNames() as $resource) {
- $this->_executeResource($resource);
- }
- } elseif (is_string($resource)) {
- $this->_executeResource($resource);
- } elseif (is_array($resource)) {
- foreach ($resource as $r) {
- $this->_executeResource($r);
- }
- } else {
- throw new Zend_Application_Bootstrap_Exception('Invalid argument passed to ' . __METHOD__);
- }
- }
-
- /**
- * Execute a resource
- *
- * Checks to see if the resource has already been run. If not, it searches
- * first to see if a local method matches the resource, and executes that.
- * If not, it checks to see if a plugin resource matches, and executes that
- * if found.
- *
- * Finally, if not found, it throws an exception.
- *
- * @param string $resource
- * @return void
- * @throws Zend_Application_Bootstrap_Exception When resource not found
- */
- protected function _executeResource($resource)
- {
- $resourceName = strtolower($resource);
-
- if (in_array($resourceName, $this->_run)) {
- return;
- }
-
- if (isset($this->_started[$resourceName]) && $this->_started[$resourceName]) {
- throw new Zend_Application_Bootstrap_Exception('Circular resource dependency detected');
- }
-
- $classResources = $this->getClassResources();
- if (array_key_exists($resourceName, $classResources)) {
- $this->_started[$resourceName] = true;
- $method = $classResources[$resourceName];
- $return = $this->$method();
- unset($this->_started[$resourceName]);
- $this->_markRun($resourceName);
-
- if (null !== $return) {
- $this->getContainer()->{$resourceName} = $return;
- }
-
- return;
- }
-
- if ($this->hasPluginResource($resource)) {
- $this->_started[$resourceName] = true;
- $plugin = $this->getPluginResource($resource);
- $return = $plugin->init();
- unset($this->_started[$resourceName]);
- $this->_markRun($resourceName);
-
- if (null !== $return) {
- $this->getContainer()->{$resourceName} = $return;
- }
-
- return;
- }
-
- throw new Zend_Application_Bootstrap_Exception('Resource matching "' . $resource . '" not found');
- }
-
- /**
- * Load a plugin resource
- *
- * @param string $resource
- * @param array|object|null $options
- * @return string|false
- */
- protected function _loadPluginResource($resource, $options)
- {
- $options = (array) $options;
- $options['bootstrap'] = $this;
- $className = $this->getPluginLoader()->load(strtolower($resource), false);
-
- if (!$className) {
- return false;
- }
-
- $instance = new $className($options);
-
- unset($this->_pluginResources[$resource]);
-
- if (isset($instance->_explicitType)) {
- $resource = $instance->_explicitType;
- }
- $resource = strtolower($resource);
- $this->_pluginResources[$resource] = $instance;
-
- return $resource;
- }
-
- /**
- * Mark a resource as having run
- *
- * @param string $resource
- * @return void
- */
- protected function _markRun($resource)
- {
- if (!in_array($resource, $this->_run)) {
- $this->_run[] = $resource;
- }
- }
-
- /**
- * Resolve a plugin resource name
- *
- * Uses, in order of preference
- * - $_explicitType property of resource
- * - Short name of resource (if a matching prefix path is found)
- * - class name (if none of the above are true)
- *
- * The name is then cast to lowercase.
- *
- * @param Zend_Application_Resource_Resource $resource
- * @return string
- */
- protected function _resolvePluginResourceName($resource)
- {
- if (isset($resource->_explicitType)) {
- $pluginName = $resource->_explicitType;
- } else {
- $className = get_class($resource);
- $pluginName = $className;
- $loader = $this->getPluginLoader();
- foreach ($loader->getPaths() as $prefix => $paths) {
- if (0 === strpos($className, $prefix)) {
- $pluginName = substr($className, strlen($prefix));
- $pluginName = trim($pluginName, '_');
- break;
- }
- }
- }
- $pluginName = strtolower($pluginName);
- return $pluginName;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Bootstrap/Bootstrapper.php zendframework-2.2.6/library/Zend/Application/Bootstrap/Bootstrapper.php
--- zendframework-1.10.4/library/Zend/Application/Bootstrap/Bootstrapper.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Bootstrap/Bootstrapper.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,94 +0,0 @@
-hasOption('resourceloader')) {
- $this->setOptions(array(
- 'resourceloader' => $application->getOption('resourceloader')
- ));
- }
- $this->getResourceLoader();
-
- if (!$this->hasPluginResource('FrontController')) {
- $this->registerPluginResource('FrontController');
- }
- }
-
- /**
- * Run the application
- *
- * Checks to see that we have a default controller directory. If not, an
- * exception is thrown.
- *
- * If so, it registers the bootstrap with the 'bootstrap' parameter of
- * the front controller, and dispatches the front controller.
- *
- * @return mixed
- * @throws Zend_Application_Bootstrap_Exception
- */
- public function run()
- {
- $front = $this->getResource('FrontController');
- $default = $front->getDefaultModule();
- if (null === $front->getControllerDirectory($default)) {
- throw new Zend_Application_Bootstrap_Exception(
- 'No default controller directory registered with front controller'
- );
- }
-
- $front->setParam('bootstrap', $this);
- $response = $front->dispatch();
- if ($front->returnResponse()) {
- return $response;
- }
- }
-
- /**
- * Set module resource loader
- *
- * @param Zend_Loader_Autoloader_Resource $loader
- * @return Zend_Application_Module_Bootstrap
- */
- public function setResourceLoader(Zend_Loader_Autoloader_Resource $loader)
- {
- $this->_resourceLoader = $loader;
- return $this;
- }
-
- /**
- * Retrieve module resource loader
- *
- * @return Zend_Loader_Autoloader_Resource
- */
- public function getResourceLoader()
- {
- if ((null === $this->_resourceLoader)
- && (false !== ($namespace = $this->getAppNamespace()))
- ) {
- $r = new ReflectionClass($this);
- $path = $r->getFileName();
- $this->setResourceLoader(new Zend_Application_Module_Autoloader(array(
- 'namespace' => $namespace,
- 'basePath' => dirname($path),
- )));
- }
- return $this->_resourceLoader;
- }
-
- /**
- * Get application namespace (used for module autoloading)
- *
- * @return string
- */
- public function getAppNamespace()
- {
- return $this->_appNamespace;
- }
-
- /**
- * Set application namespace (for module autoloading)
- *
- * @param string
- * @return Zend_Application_Bootstrap_Bootstrap
- */
- public function setAppNamespace($value)
- {
- $this->_appNamespace = (string) $value;
- return $this;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Bootstrap/Exception.php zendframework-2.2.6/library/Zend/Application/Bootstrap/Exception.php
--- zendframework-1.10.4/library/Zend/Application/Bootstrap/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Bootstrap/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,38 +0,0 @@
-initDefaultResourceTypes();
- }
-
- /**
- * Initialize default resource types for module resource classes
- *
- * @return void
- */
- public function initDefaultResourceTypes()
- {
- $basePath = $this->getBasePath();
- $this->addResourceTypes(array(
- 'dbtable' => array(
- 'namespace' => 'Model_DbTable',
- 'path' => 'models/DbTable',
- ),
- 'mappers' => array(
- 'namespace' => 'Model_Mapper',
- 'path' => 'models/mappers',
- ),
- 'form' => array(
- 'namespace' => 'Form',
- 'path' => 'forms',
- ),
- 'model' => array(
- 'namespace' => 'Model',
- 'path' => 'models',
- ),
- 'plugin' => array(
- 'namespace' => 'Plugin',
- 'path' => 'plugins',
- ),
- 'service' => array(
- 'namespace' => 'Service',
- 'path' => 'services',
- ),
- 'viewhelper' => array(
- 'namespace' => 'View_Helper',
- 'path' => 'views/helpers',
- ),
- 'viewfilter' => array(
- 'namespace' => 'View_Filter',
- 'path' => 'views/filters',
- ),
- ));
- $this->setDefaultResourceType('model');
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Module/Bootstrap.php zendframework-2.2.6/library/Zend/Application/Module/Bootstrap.php
--- zendframework-1.10.4/library/Zend/Application/Module/Bootstrap.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Module/Bootstrap.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,128 +0,0 @@
-setApplication($application);
-
- // Use same plugin loader as parent bootstrap
- if ($application instanceof Zend_Application_Bootstrap_ResourceBootstrapper) {
- $this->setPluginLoader($application->getPluginLoader());
- }
-
- $key = strtolower($this->getModuleName());
- if ($application->hasOption($key)) {
- // Don't run via setOptions() to prevent duplicate initialization
- $this->setOptions($application->getOption($key));
- }
-
- if ($application->hasOption('resourceloader')) {
- $this->setOptions(array(
- 'resourceloader' => $application->getOption('resourceloader')
- ));
- }
- $this->initResourceLoader();
-
- // ZF-6545: ensure front controller resource is loaded
- if (!$this->hasPluginResource('FrontController')) {
- $this->registerPluginResource('FrontController');
- }
-
- // ZF-6545: prevent recursive registration of modules
- if ($this->hasPluginResource('modules')) {
- $this->unregisterPluginResource('modules');
- }
- }
-
- /**
- * Ensure resource loader is loaded
- *
- * @return void
- */
- public function initResourceLoader()
- {
- $this->getResourceLoader();
- }
-
- /**
- * Get default application namespace
- *
- * Proxies to {@link getModuleName()}, and returns the current module
- * name
- *
- * @return string
- */
- public function getAppNamespace()
- {
- return $this->getModuleName();
- }
-
- /**
- * Retrieve module name
- *
- * @return string
- */
- public function getModuleName()
- {
- if (empty($this->_moduleName)) {
- $class = get_class($this);
- if (preg_match('/^([a-z][a-z0-9]*)_/i', $class, $matches)) {
- $prefix = $matches[1];
- } else {
- $prefix = $class;
- }
- $this->_moduleName = $prefix;
- }
- return $this->_moduleName;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Cachemanager.php zendframework-2.2.6/library/Zend/Application/Resource/Cachemanager.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Cachemanager.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Cachemanager.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,73 +0,0 @@
-getCacheManager();
- }
-
- /**
- * Retrieve Zend_Cache_Manager instance
- *
- * @return Zend_Cache_Manager
- */
- public function getCacheManager()
- {
- if (null === $this->_manager) {
- $this->_manager = new Zend_Cache_Manager;
-
- $options = $this->getOptions();
- foreach ($options as $key => $value) {
- if ($this->_manager->hasCacheTemplate($key)) {
- $this->_manager->setTemplateOptions($key, $value);
- } else {
- $this->_manager->setCacheTemplate($key, $value);
- }
- }
- }
-
- return $this->_manager;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Db.php zendframework-2.2.6/library/Zend/Application/Resource/Db.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Db.php 2010-02-01 21:13:54.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Db.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,161 +0,0 @@
-_adapter = $adapter;
- return $this;
- }
-
- /**
- * Adapter type to use
- *
- * @return string
- */
- public function getAdapter()
- {
- return $this->_adapter;
- }
-
- /**
- * Set the adapter params
- *
- * @param $adapter string
- * @return Zend_Application_Resource_Db
- */
- public function setParams(array $params)
- {
- $this->_params = $params;
- return $this;
- }
-
- /**
- * Adapter parameters
- *
- * @return array
- */
- public function getParams()
- {
- return $this->_params;
- }
-
- /**
- * Set whether to use this as default table adapter
- *
- * @param boolean $defaultTableAdapter
- * @return Zend_Application_Resource_Db
- */
- public function setIsDefaultTableAdapter($isDefaultTableAdapter)
- {
- $this->_isDefaultTableAdapter = $isDefaultTableAdapter;
- return $this;
- }
-
- /**
- * Is this adapter the default table adapter?
- *
- * @return void
- */
- public function isDefaultTableAdapter()
- {
- return $this->_isDefaultTableAdapter;
- }
-
- /**
- * Retrieve initialized DB connection
- *
- * @return null|Zend_Db_Adapter_Interface
- */
- public function getDbAdapter()
- {
- if ((null === $this->_db)
- && (null !== ($adapter = $this->getAdapter()))
- ) {
- $this->_db = Zend_Db::factory($adapter, $this->getParams());
- }
- return $this->_db;
- }
-
- /**
- * Defined by Zend_Application_Resource_Resource
- *
- * @return Zend_Db_Adapter_Abstract|null
- */
- public function init()
- {
- if (null !== ($db = $this->getDbAdapter())) {
- if ($this->isDefaultTableAdapter()) {
- Zend_Db_Table::setDefaultAdapter($db);
- }
- return $db;
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Dojo.php zendframework-2.2.6/library/Zend/Application/Resource/Dojo.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Dojo.php 2010-02-01 21:13:54.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Dojo.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,76 +0,0 @@
-getDojo();
- }
-
- /**
- * Retrieve Dojo View Helper
- *
- * @return Zend_Dojo_View_Dojo_Container
- */
- public function getDojo()
- {
- if (null === $this->_dojo) {
- $this->getBootstrap()->bootstrap('view');
- $view = $this->getBootstrap()->view;
-
- Zend_Dojo::enableView($view);
- $view->dojo()->setOptions($this->getOptions());
-
- $this->_dojo = $view->dojo();
- }
-
- return $this->_dojo;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Exception.php zendframework-2.2.6/library/Zend/Application/Resource/Exception.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,35 +0,0 @@
-getFrontController();
-
- foreach ($this->getOptions() as $key => $value) {
- switch (strtolower($key)) {
- case 'controllerdirectory':
- if (is_string($value)) {
- $front->setControllerDirectory($value);
- } elseif (is_array($value)) {
- foreach ($value as $module => $directory) {
- $front->addControllerDirectory($directory, $module);
- }
- }
- break;
-
- case 'modulecontrollerdirectoryname':
- $front->setModuleControllerDirectoryName($value);
- break;
-
- case 'moduledirectory':
- $front->addModuleDirectory($value);
- break;
-
- case 'defaultcontrollername':
- $front->setDefaultControllerName($value);
- break;
-
- case 'defaultaction':
- $front->setDefaultAction($value);
- break;
-
- case 'defaultmodule':
- $front->setDefaultModule($value);
- break;
-
- case 'baseurl':
- if (!empty($value)) {
- $front->setBaseUrl($value);
- }
- break;
-
- case 'params':
- $front->setParams($value);
- break;
-
- case 'plugins':
- foreach ((array) $value as $pluginClass) {
- $stackIndex = null;
- if(is_array($pluginClass)) {
- $pluginClass = array_change_key_case($pluginClass, CASE_LOWER);
- if(isset($pluginClass['class']))
- {
- if(isset($pluginClass['stackindex'])) {
- $stackIndex = $pluginClass['stackindex'];
- }
-
- $pluginClass = $pluginClass['class'];
- }
- }
-
- $plugin = new $pluginClass();
- $front->registerPlugin($plugin, $stackIndex);
- }
- break;
-
- case 'returnresponse':
- $front->returnResponse((bool) $value);
- break;
-
- case 'throwexceptions':
- $front->throwExceptions((bool) $value);
- break;
-
- case 'actionhelperpaths':
- if (is_array($value)) {
- foreach ($value as $helperPrefix => $helperPath) {
- Zend_Controller_Action_HelperBroker::addPath($helperPath, $helperPrefix);
- }
- }
- break;
-
- default:
- $front->setParam($key, $value);
- break;
- }
- }
-
- if (null !== ($bootstrap = $this->getBootstrap())) {
- $this->getBootstrap()->frontController = $front;
- }
-
- return $front;
- }
-
- /**
- * Retrieve front controller instance
- *
- * @return Zend_Controller_Front
- */
- public function getFrontController()
- {
- if (null === $this->_front) {
- $this->_front = Zend_Controller_Front::getInstance();
- }
- return $this->_front;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Layout.php zendframework-2.2.6/library/Zend/Application/Resource/Layout.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Layout.php 2010-02-01 21:13:54.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Layout.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,70 +0,0 @@
-getBootstrap()->bootstrap('FrontController');
- return $this->getLayout();
- }
-
- /**
- * Retrieve layout object
- *
- * @return Zend_Layout
- */
- public function getLayout()
- {
- if (null === $this->_layout) {
- $this->_layout = Zend_Layout::startMvc($this->getOptions());
- }
- return $this->_layout;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Locale.php zendframework-2.2.6/library/Zend/Application/Resource/Locale.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Locale.php 2010-02-01 21:13:54.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Locale.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,89 +0,0 @@
-getLocale();
- }
-
-
- /**
- * Retrieve locale object
- *
- * @return Zend_Locale
- */
- public function getLocale()
- {
- if (null === $this->_locale) {
- $options = $this->getOptions();
- if(!isset($options['default'])) {
- $this->_locale = new Zend_Locale();
- } elseif(!isset($options['force']) ||
- (bool) $options['force'] == false)
- {
- // Don't force any locale, just go for auto detection
- Zend_Locale::setDefault($options['default']);
- $this->_locale = new Zend_Locale();
- } else {
- $this->_locale = new Zend_Locale($options['default']);
- }
-
- $key = (isset($options['registry_key']) && !is_numeric($options['registry_key']))
- ? $options['registry_key']
- : self::DEFAULT_REGISTRY_KEY;
- Zend_Registry::set($key, $this->_locale);
- }
-
- return $this->_locale;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Log.php zendframework-2.2.6/library/Zend/Application/Resource/Log.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Log.php 2010-02-01 21:13:54.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Log.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,78 +0,0 @@
-getLog();
- }
-
- /**
- * Attach logger
- *
- * @param Zend_Log $log
- * @return Zend_Application_Resource_Log
- */
- public function setLog(Zend_Log $log)
- {
- $this->_log = $log;
- return $this;
- }
-
- public function getLog()
- {
- if (null === $this->_log) {
- $options = $this->getOptions();
- $log = Zend_Log::factory($options);
- $this->setLog($log);
- }
- return $this->_log;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Mail.php zendframework-2.2.6/library/Zend/Application/Resource/Mail.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Mail.php 2010-02-12 01:00:31.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Mail.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,146 +0,0 @@
-getMail();
- }
-
- /**
- *
- * @return Zend_Mail_Transport_Abstract|null
- */
- public function getMail()
- {
- if (null === $this->_transport) {
- $options = $this->getOptions();
- foreach($options as $key => $option) {
- $options[strtolower($key)] = $option;
- }
- $this->setOptions($options);
-
- if(isset($options['transport']) &&
- !is_numeric($options['transport']))
- {
- $this->_transport = $this->_setupTransport($options['transport']);
- if(!isset($options['transport']['register']) ||
- $options['transport']['register'] == '1' ||
- (isset($options['transport']['register']) &&
- !is_numeric($options['transport']['register']) &&
- (bool) $options['transport']['register'] == true))
- {
- Zend_Mail::setDefaultTransport($this->_transport);
- }
- }
-
- $this->_setDefaults('from');
- $this->_setDefaults('replyTo');
- }
-
- return $this->_transport;
- }
-
- protected function _setDefaults($type) {
- $key = strtolower('default' . $type);
- $options = $this->getOptions();
-
- if(isset($options[$key]['email']) &&
- !is_numeric($options[$key]['email']))
- {
- $method = array('Zend_Mail', 'setDefault' . ucfirst($type));
- if(isset($options[$key]['name']) &&
- !is_numeric($options[$key]['name']))
- {
- call_user_func($method, $options[$key]['email'],
- $options[$key]['name']);
- } else {
- call_user_func($method, $options[$key]['email']);
- }
- }
- }
-
- protected function _setupTransport($options)
- {
- if(!isset($options['type'])) {
- $options['type'] = 'sendmail';
- }
-
- $transportName = $options['type'];
- if(!Zend_Loader_Autoloader::autoload($transportName))
- {
- $transportName = ucfirst(strtolower($transportName));
-
- if(!Zend_Loader_Autoloader::autoload($transportName))
- {
- $transportName = 'Zend_Mail_Transport_' . $transportName;
- if(!Zend_Loader_Autoloader::autoload($transportName)) {
- throw new Zend_Application_Resource_Exception(
- "Specified Mail Transport '{$transportName}'"
- . 'could not be found'
- );
- }
- }
- }
-
- unset($options['type']);
-
- switch($transportName) {
- case 'Zend_Mail_Transport_Smtp':
- if(!isset($options['host'])) {
- throw new Zend_Application_Resource_Exception(
- 'A host is necessary for smtp transport,'
- .' but none was given');
- }
-
- $transport = new $transportName($options['host'], $options);
- break;
- case 'Zend_Mail_Transport_Sendmail':
- default:
- $transport = new $transportName($options);
- break;
- }
-
- return $transport;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Modules.php zendframework-2.2.6/library/Zend/Application/Resource/Modules.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Modules.php 2010-02-01 21:13:54.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Modules.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,138 +0,0 @@
-_bootstraps = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
- parent::__construct($options);
- }
-
- /**
- * Initialize modules
- *
- * @return array
- * @throws Zend_Application_Resource_Exception When bootstrap class was not found
- */
- public function init()
- {
- $bootstrap = $this->getBootstrap();
- $bootstrap->bootstrap('FrontController');
- $front = $bootstrap->getResource('FrontController');
-
- $modules = $front->getControllerDirectory();
- $default = $front->getDefaultModule();
- $curBootstrapClass = get_class($bootstrap);
- foreach ($modules as $module => $moduleDirectory) {
- $bootstrapClass = $this->_formatModuleName($module) . '_Bootstrap';
- if (!class_exists($bootstrapClass, false)) {
- $bootstrapPath = dirname($moduleDirectory) . '/Bootstrap.php';
- if (file_exists($bootstrapPath)) {
- $eMsgTpl = 'Bootstrap file found for module "%s" but bootstrap class "%s" not found';
- include_once $bootstrapPath;
- if (($default != $module)
- && !class_exists($bootstrapClass, false)
- ) {
- throw new Zend_Application_Resource_Exception(sprintf(
- $eMsgTpl, $module, $bootstrapClass
- ));
- } elseif ($default == $module) {
- if (!class_exists($bootstrapClass, false)) {
- $bootstrapClass = 'Bootstrap';
- if (!class_exists($bootstrapClass, false)) {
- throw new Zend_Application_Resource_Exception(sprintf(
- $eMsgTpl, $module, $bootstrapClass
- ));
- }
- }
- }
- } else {
- continue;
- }
- }
-
- if ($bootstrapClass == $curBootstrapClass) {
- // If the found bootstrap class matches the one calling this
- // resource, don't re-execute.
- continue;
- }
-
- $moduleBootstrap = new $bootstrapClass($bootstrap);
- $moduleBootstrap->bootstrap();
- $this->_bootstraps[$module] = $moduleBootstrap;
- }
-
- return $this->_bootstraps;
- }
-
- /**
- * Get bootstraps that have been run
- *
- * @return ArrayObject
- */
- public function getExecutedBootstraps()
- {
- return $this->_bootstraps;
- }
-
- /**
- * Format a module name to the module class prefix
- *
- * @param string $name
- * @return string
- */
- protected function _formatModuleName($name)
- {
- $name = strtolower($name);
- $name = str_replace(array('-', '.'), ' ', $name);
- $name = ucwords($name);
- $name = str_replace(' ', '', $name);
- return $name;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Multidb.php zendframework-2.2.6/library/Zend/Application/Resource/Multidb.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Multidb.php 2010-02-11 00:50:47.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Multidb.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,168 +0,0 @@
-
- * resources.multidb.db1.adapter = "pdo_mysql"
- * resources.multidb.db1.host = "localhost"
- * resources.multidb.db1.username = "webuser"
- * resources.multidb.db1.password = "XXXX"
- * resources.multidb.db1.dbname = "db1"
- * resources.multidb.db1.default = true
- *
- * resources.multidb.db2.adapter = "pdo_pgsql"
- * resources.multidb.db2.host = "example.com"
- * resources.multidb.db2.username = "dba"
- * resources.multidb.db2.password = "notthatpublic"
- * resources.multidb.db2.dbname = "db2"
- *
- *
- * @category Zend
- * @package Zend_Application
- * @subpackage Resource
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_Application_Resource_Multidb extends Zend_Application_Resource_ResourceAbstract
-{
- /**
- * Associative array containing all configured db's
- *
- * @var array
- */
- protected $_dbs = array();
-
- /**
- * An instance of the default db, if set
- *
- * @var null|Zend_Db_Adapter_Abstract
- */
- protected $_defaultDb;
-
- /**
- * Initialize the Database Connections (instances of Zend_Db_Table_Abstract)
- *
- * @return Zend_Application_Resource_Multidb
- */
- public function init()
- {
- $options = $this->getOptions();
-
- foreach ($options as $id => $params) {
- $adapter = $params['adapter'];
- $default = isset($params['default'])?(int)$params['default']:false;
- unset($params['adapter'], $params['default']);
-
- $this->_dbs[$id] = Zend_Db::factory($adapter, $params);
-
- if ($default
- // For consistency with the Db Resource Plugin
- || (isset($params['isDefaultTableAdapter'])
- && $params['isDefaultTableAdapter'] == true)
- ) {
- $this->_setDefault($this->_dbs[$id]);
- }
- }
-
- return $this;
- }
-
- /**
- * Determine if the given db(identifier) is the default db.
- *
- * @param string|Zend_Db_Adapter_Abstract $db The db to determine whether it's set as default
- * @return boolean True if the given parameter is configured as default. False otherwise
- */
- public function isDefault($db)
- {
- if(!$db instanceof Zend_Db_Adapter_Abstract) {
- $db = $this->getDb($db);
- }
-
- return $db === $this->_defaultDb;
- }
-
- /**
- * Retrieve the specified database connection
- *
- * @param null|string|Zend_Db_Adapter_Abstract $db The adapter to retrieve.
- * Null to retrieve the default connection
- * @return Zend_Db_Adapter_Abstract
- * @throws Zend_Application_Resource_Exception if the given parameter could not be found
- */
- public function getDb($db = null)
- {
- if ($db === null) {
- return $this->getDefaultDb();
- }
-
- if (isset($this->_dbs[$db])) {
- return $this->_dbs[$db];
- }
-
- throw new Zend_Application_Resource_Exception(
- 'A DB adapter was tried to retrieve, but was not configured'
- );
- }
-
- /**
- * Get the default db connection
- *
- * @param boolean $justPickOne If true, a random (the first one in the stack)
- * connection is returned if no default was set.
- * If false, null is returned if no default was set.
- * @return null|Zend_Db_Adapter_Abstract
- */
- public function getDefaultDb($justPickOne = true)
- {
- if ($this->_defaultDb !== null) {
- return $this->_defaultDb;
- }
-
- if ($justPickOne) {
- return reset($this->_dbs); // Return first db in db pool
- }
-
- return null;
- }
-
- /**
- * Set the default db adapter
- *
- * @var Zend_Db_Adapter_Abstract $adapter Adapter to set as default
- */
- protected function _setDefault(Zend_Db_Adapter_Abstract $adapter)
- {
- Zend_Db_Table::setDefaultAdapter($adapter);
- $this->_defaultDb = $adapter;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Navigation.php zendframework-2.2.6/library/Zend/Application/Resource/Navigation.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Navigation.php 2010-02-01 21:13:54.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Navigation.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,123 +0,0 @@
-_container) {
- $options = $this->getOptions();
- $pages = isset($options['pages']) ? $options['pages'] : array();
- $this->_container = new Zend_Navigation($pages);
- }
-
- $this->store();
- return $this->_container;
- }
-
- /**
- * Stores navigation container in registry or Navigation view helper
- *
- * @return void
- */
- public function store()
- {
- $options = $this->getOptions();
- if (isset($options['storage']['registry']) &&
- $options['storage']['registry'] == true) {
- $this->_storeRegistry();
- } else {
- $this->_storeHelper();
- }
- }
-
- /**
- * Stores navigation container in the registry
- *
- * @return void
- */
- protected function _storeRegistry()
- {
- $options = $this->getOptions();
- if(isset($options['storage']['registry']['key']) &&
- !is_numeric($options['storage']['registry']['key'])) // see ZF-7461
- {
- $key = $options['storage']['registry']['key'];
- } else {
- $key = self::DEFAULT_REGISTRY_KEY;
- }
-
- Zend_Registry::set($key,$this->getContainer());
- }
-
- /**
- * Stores navigation container in the Navigation helper
- *
- * @return void
- */
- protected function _storeHelper()
- {
- $this->getBootstrap()->bootstrap('view');
- $view = $this->getBootstrap()->view;
- $view->getHelper('navigation')->navigation($this->getContainer());
- }
-
- /**
- * Returns navigation container
- *
- * @return Zend_Navigation
- */
- public function getContainer()
- {
- return $this->_container;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/ResourceAbstract.php zendframework-2.2.6/library/Zend/Application/Resource/ResourceAbstract.php
--- zendframework-1.10.4/library/Zend/Application/Resource/ResourceAbstract.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/ResourceAbstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,159 +0,0 @@
-setOptions($options);
- } else if ($options instanceof Zend_Config) {
- $this->setOptions($options->toArray());
- }
- }
-
- /**
- * Set options from array
- *
- * @param array $options Configuration for resource
- * @return Zend_Application_Resource_ResourceAbstract
- */
- public function setOptions(array $options)
- {
- foreach ($options as $key => $value) {
- if (in_array(strtolower($key), $this->_skipOptions)) {
- continue;
- }
-
- $method = 'set' . strtolower($key);
- if (method_exists($this, $method)) {
- $this->$method($value);
- }
- if ('bootstrap' === $key) {
- unset($options[$key]);
- }
- }
-
- $this->_options = $this->mergeOptions($this->_options, $options);
-
- return $this;
- }
-
- /**
- * Retrieve resource options
- *
- * @return array
- */
- public function getOptions()
- {
- return $this->_options;
- }
-
- /**
- * Merge options recursively
- *
- * @param array $array1
- * @param mixed $array2
- * @return array
- */
- public function mergeOptions(array $array1, $array2 = null)
- {
- if (is_array($array2)) {
- foreach ($array2 as $key => $val) {
- if (is_array($array2[$key])) {
- $array1[$key] = (array_key_exists($key, $array1) && is_array($array1[$key]))
- ? $this->mergeOptions($array1[$key], $array2[$key])
- : $array2[$key];
- } else {
- $array1[$key] = $val;
- }
- }
- }
- return $array1;
- }
-
- /**
- * Set the bootstrap to which the resource is attached
- *
- * @param Zend_Application_Bootstrap_Bootstrapper $bootstrap
- * @return Zend_Application_Resource_Resource
- */
- public function setBootstrap(Zend_Application_Bootstrap_Bootstrapper $bootstrap)
- {
- $this->_bootstrap = $bootstrap;
- return $this;
- }
-
- /**
- * Retrieve the bootstrap to which the resource is attached
- *
- * @return null|Zend_Application_Bootstrap_Bootstrapper
- */
- public function getBootstrap()
- {
- return $this->_bootstrap;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Resource.php zendframework-2.2.6/library/Zend/Application/Resource/Resource.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Resource.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Resource.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,80 +0,0 @@
-getRouter();
- }
-
- /**
- * Retrieve router object
- *
- * @return Zend_Controller_Router_Rewrite
- */
- public function getRouter()
- {
- if (null === $this->_router) {
- $bootstrap = $this->getBootstrap();
- $bootstrap->bootstrap('FrontController');
- $this->_router = $bootstrap->getContainer()->frontcontroller->getRouter();
-
- $options = $this->getOptions();
- if (!isset($options['routes'])) {
- $options['routes'] = array();
- }
-
- if (isset($options['chainNameSeparator'])) {
- $this->_router->setChainNameSeparator($options['chainNameSeparator']);
- }
-
- if (isset($options['useRequestParametersAsGlobal'])) {
- $this->_router->useRequestParametersAsGlobal($options['useRequestParametersAsGlobal']);
- }
-
- $this->_router->addConfig(new Zend_Config($options['routes']));
- }
-
- return $this->_router;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Session.php zendframework-2.2.6/library/Zend/Application/Resource/Session.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Session.php 2010-02-01 21:13:54.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Session.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,118 +0,0 @@
-_saveHandler = $saveHandler;
- return $this;
- }
-
- /**
- * Get session save handler
- *
- * @return Zend_Session_SaveHandler_Interface
- */
- public function getSaveHandler()
- {
- if (!$this->_saveHandler instanceof Zend_Session_SaveHandler_Interface) {
- if (is_array($this->_saveHandler)) {
- if (!array_key_exists('class', $this->_saveHandler)) {
- throw new Zend_Application_Resource_Exception('Session save handler class not provided in options');
- }
- $options = array();
- if (array_key_exists('options', $this->_saveHandler)) {
- $options = $this->_saveHandler['options'];
- }
- $this->_saveHandler = $this->_saveHandler['class'];
- $this->_saveHandler = new $this->_saveHandler($options);
- } elseif (is_string($this->_saveHandler)) {
- $this->_saveHandler = new $this->_saveHandler();
- }
-
- if (!$this->_saveHandler instanceof Zend_Session_SaveHandler_Interface) {
- throw new Zend_Application_Resource_Exception('Invalid session save handler');
- }
- }
- return $this->_saveHandler;
- }
-
- /**
- * @return bool
- */
- protected function _hasSaveHandler()
- {
- return ($this->_saveHandler !== null);
- }
-
- /**
- * Defined by Zend_Application_Resource_Resource
- *
- * @return void
- */
- public function init()
- {
- $options = array_change_key_case($this->getOptions(), CASE_LOWER);
- if (isset($options['savehandler'])) {
- unset($options['savehandler']);
- }
-
- if (count($options) > 0) {
- Zend_Session::setOptions($options);
- }
-
- if ($this->_hasSaveHandler()) {
- Zend_Session::setSaveHandler($this->getSaveHandler());
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/Translate.php zendframework-2.2.6/library/Zend/Application/Resource/Translate.php
--- zendframework-1.10.4/library/Zend/Application/Resource/Translate.php 2010-04-05 20:16:08.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/Translate.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,114 +0,0 @@
-getTranslate();
- }
-
- /**
- * Retrieve translate object
- *
- * @return Zend_Translate
- * @throws Zend_Application_Resource_Exception if registry key was used
- * already but is no instance of Zend_Translate
- */
- public function getTranslate()
- {
- if (null === $this->_translate) {
- $options = $this->getOptions();
-
- if (!isset($options['data'])) {
- require_once 'Zend/Application/Resource/Exception.php';
- throw new Zend_Application_Resource_Exception('No translation source data provided.');
- }
-
- if (empty($options['adapter'])) {
- $options['adapter'] = Zend_Translate::AN_ARRAY;
- }
-
- if (!empty($options['data'])) {
- $options['content'] = $options['data'];
- unset($options['data']);
- }
-
- if (isset($options['options'])) {
- foreach($options['options'] as $key => $value) {
- $options[$key] = $value;
- }
- }
-
- $key = (isset($options['registry_key']) && !is_numeric($options['registry_key']))
- ? $options['registry_key']
- : self::DEFAULT_REGISTRY_KEY;
- unset($options['registry_key']);
-
- if(Zend_Registry::isRegistered($key)) {
- $translate = Zend_Registry::get($key);
- if(!$translate instanceof Zend_Translate) {
- require_once 'Zend/Application/Resource/Exception.php';
- throw new Zend_Application_Resource_Exception($key
- . ' already registered in registry but is '
- . 'no instance of Zend_Translate');
- }
-
- $translate->addTranslation($options);
- $this->_translate = $translate;
- } else {
- $this->_translate = new Zend_Translate($options);
- Zend_Registry::set($key, $this->_translate);
- }
- }
-
- return $this->_translate;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application/Resource/View.php zendframework-2.2.6/library/Zend/Application/Resource/View.php
--- zendframework-1.10.4/library/Zend/Application/Resource/View.php 2010-02-01 21:13:54.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application/Resource/View.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,78 +0,0 @@
-getView();
-
- $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
- $viewRenderer->setView($view);
- Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
- return $view;
- }
-
- /**
- * Retrieve view object
- *
- * @return Zend_View
- */
- public function getView()
- {
- if (null === $this->_view) {
- $options = $this->getOptions();
- $this->_view = new Zend_View($options);
-
- if(isset($options['doctype'])) {
- $this->_view->doctype()->setDoctype(strtoupper($options['doctype']));
- }
- }
- return $this->_view;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Application.php zendframework-2.2.6/library/Zend/Application.php
--- zendframework-1.10.4/library/Zend/Application.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Application.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,405 +0,0 @@
-_environment = (string) $environment;
-
- require_once 'Zend/Loader/Autoloader.php';
- $this->_autoloader = Zend_Loader_Autoloader::getInstance();
-
- if (null !== $options) {
- if (is_string($options)) {
- $options = $this->_loadConfig($options);
- } elseif ($options instanceof Zend_Config) {
- $options = $options->toArray();
- } elseif (!is_array($options)) {
- throw new Zend_Application_Exception('Invalid options provided; must be location of config file, a config object, or an array');
- }
-
- $this->setOptions($options);
- }
- }
-
- /**
- * Retrieve current environment
- *
- * @return string
- */
- public function getEnvironment()
- {
- return $this->_environment;
- }
-
- /**
- * Retrieve autoloader instance
- *
- * @return Zend_Loader_Autoloader
- */
- public function getAutoloader()
- {
- return $this->_autoloader;
- }
-
- /**
- * Set application options
- *
- * @param array $options
- * @throws Zend_Application_Exception When no bootstrap path is provided
- * @throws Zend_Application_Exception When invalid bootstrap information are provided
- * @return Zend_Application
- */
- public function setOptions(array $options)
- {
- if (!empty($options['config'])) {
- if (is_array($options['config'])) {
- $_options = array();
- foreach ($options['config'] as $tmp) {
- $_options = $this->mergeOptions($_options, $this->_loadConfig($tmp));
- }
- $options = $this->mergeOptions($_options, $options);
- } else {
- $options = $this->mergeOptions($this->_loadConfig($options['config']), $options);
- }
- }
-
- $this->_options = $options;
-
- $options = array_change_key_case($options, CASE_LOWER);
-
- $this->_optionKeys = array_keys($options);
-
- if (!empty($options['phpsettings'])) {
- $this->setPhpSettings($options['phpsettings']);
- }
-
- if (!empty($options['includepaths'])) {
- $this->setIncludePaths($options['includepaths']);
- }
-
- if (!empty($options['autoloadernamespaces'])) {
- $this->setAutoloaderNamespaces($options['autoloadernamespaces']);
- }
-
- if (!empty($options['autoloaderzfpath'])) {
- $autoloader = $this->getAutoloader();
- if (method_exists($autoloader, 'setZfPath')) {
- $zfPath = $options['autoloaderzfpath'];
- $zfVersion = !empty($options['autoloaderzfversion'])
- ? $options['autoloaderzfversion']
- : 'latest';
- $autoloader->setZfPath($zfPath, $zfVersion);
- }
- }
-
- if (!empty($options['bootstrap'])) {
- $bootstrap = $options['bootstrap'];
-
- if (is_string($bootstrap)) {
- $this->setBootstrap($bootstrap);
- } elseif (is_array($bootstrap)) {
- if (empty($bootstrap['path'])) {
- throw new Zend_Application_Exception('No bootstrap path provided');
- }
-
- $path = $bootstrap['path'];
- $class = null;
-
- if (!empty($bootstrap['class'])) {
- $class = $bootstrap['class'];
- }
-
- $this->setBootstrap($path, $class);
- } else {
- throw new Zend_Application_Exception('Invalid bootstrap information provided');
- }
- }
-
- return $this;
- }
-
- /**
- * Retrieve application options (for caching)
- *
- * @return array
- */
- public function getOptions()
- {
- return $this->_options;
- }
-
- /**
- * Is an option present?
- *
- * @param string $key
- * @return bool
- */
- public function hasOption($key)
- {
- return in_array(strtolower($key), $this->_optionKeys);
- }
-
- /**
- * Retrieve a single option
- *
- * @param string $key
- * @return mixed
- */
- public function getOption($key)
- {
- if ($this->hasOption($key)) {
- $options = $this->getOptions();
- $options = array_change_key_case($options, CASE_LOWER);
- return $options[strtolower($key)];
- }
- return null;
- }
-
- /**
- * Merge options recursively
- *
- * @param array $array1
- * @param mixed $array2
- * @return array
- */
- public function mergeOptions(array $array1, $array2 = null)
- {
- if (is_array($array2)) {
- foreach ($array2 as $key => $val) {
- if (is_array($array2[$key])) {
- $array1[$key] = (array_key_exists($key, $array1) && is_array($array1[$key]))
- ? $this->mergeOptions($array1[$key], $array2[$key])
- : $array2[$key];
- } else {
- $array1[$key] = $val;
- }
- }
- }
- return $array1;
- }
-
- /**
- * Set PHP configuration settings
- *
- * @param array $settings
- * @param string $prefix Key prefix to prepend to array values (used to map . separated INI values)
- * @return Zend_Application
- */
- public function setPhpSettings(array $settings, $prefix = '')
- {
- foreach ($settings as $key => $value) {
- $key = empty($prefix) ? $key : $prefix . $key;
- if (is_scalar($value)) {
- ini_set($key, $value);
- } elseif (is_array($value)) {
- $this->setPhpSettings($value, $key . '.');
- }
- }
-
- return $this;
- }
-
- /**
- * Set include path
- *
- * @param array $paths
- * @return Zend_Application
- */
- public function setIncludePaths(array $paths)
- {
- $path = implode(PATH_SEPARATOR, $paths);
- set_include_path($path . PATH_SEPARATOR . get_include_path());
- return $this;
- }
-
- /**
- * Set autoloader namespaces
- *
- * @param array $namespaces
- * @return Zend_Application
- */
- public function setAutoloaderNamespaces(array $namespaces)
- {
- $autoloader = $this->getAutoloader();
-
- foreach ($namespaces as $namespace) {
- $autoloader->registerNamespace($namespace);
- }
-
- return $this;
- }
-
- /**
- * Set bootstrap path/class
- *
- * @param string $path
- * @param string $class
- * @return Zend_Application
- */
- public function setBootstrap($path, $class = null)
- {
- // setOptions() can potentially send a null value; specify default
- // here
- if (null === $class) {
- $class = 'Bootstrap';
- }
-
- if (!class_exists($class, false)) {
- require_once $path;
- if (!class_exists($class, false)) {
- throw new Zend_Application_Exception('Bootstrap class not found');
- }
- }
- $this->_bootstrap = new $class($this);
-
- if (!$this->_bootstrap instanceof Zend_Application_Bootstrap_Bootstrapper) {
- throw new Zend_Application_Exception('Bootstrap class does not implement Zend_Application_Bootstrap_Bootstrapper');
- }
-
- return $this;
- }
-
- /**
- * Get bootstrap object
- *
- * @return Zend_Application_Bootstrap_BootstrapAbstract
- */
- public function getBootstrap()
- {
- if (null === $this->_bootstrap) {
- $this->_bootstrap = new Zend_Application_Bootstrap_Bootstrap($this);
- }
- return $this->_bootstrap;
- }
-
- /**
- * Bootstrap application
- *
- * @param null|string|array $resource
- * @return Zend_Application
- */
- public function bootstrap($resource = null)
- {
- $this->getBootstrap()->bootstrap($resource);
- return $this;
- }
-
- /**
- * Run the application
- *
- * @return void
- */
- public function run()
- {
- $this->getBootstrap()->run();
- }
-
- /**
- * Load configuration file of options
- *
- * @param string $file
- * @throws Zend_Application_Exception When invalid configuration file is provided
- * @return array
- */
- protected function _loadConfig($file)
- {
- $environment = $this->getEnvironment();
- $suffix = strtolower(pathinfo($file, PATHINFO_EXTENSION));
-
- switch ($suffix) {
- case 'ini':
- $config = new Zend_Config_Ini($file, $environment);
- break;
-
- case 'xml':
- $config = new Zend_Config_Xml($file, $environment);
- break;
-
- case 'php':
- case 'inc':
- $config = include $file;
- if (!is_array($config)) {
- throw new Zend_Application_Exception('Invalid configuration file provided; PHP file does not return array value');
- }
- return $config;
- break;
-
- default:
- throw new Zend_Application_Exception('Invalid configuration file provided; unknown config type');
- }
-
- return $config->toArray();
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Auth/Adapter/DbTable.php zendframework-2.2.6/library/Zend/Auth/Adapter/DbTable.php
--- zendframework-1.10.4/library/Zend/Auth/Adapter/DbTable.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Auth/Adapter/DbTable.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,487 +0,0 @@
-_zendDb = $zendDb;
-
- if (null !== $tableName) {
- $this->setTableName($tableName);
- }
-
- if (null !== $identityColumn) {
- $this->setIdentityColumn($identityColumn);
- }
-
- if (null !== $credentialColumn) {
- $this->setCredentialColumn($credentialColumn);
- }
-
- if (null !== $credentialTreatment) {
- $this->setCredentialTreatment($credentialTreatment);
- }
- }
-
- /**
- * setTableName() - set the table name to be used in the select query
- *
- * @param string $tableName
- * @return Zend_Auth_Adapter_DbTable Provides a fluent interface
- */
- public function setTableName($tableName)
- {
- $this->_tableName = $tableName;
- return $this;
- }
-
- /**
- * setIdentityColumn() - set the column name to be used as the identity column
- *
- * @param string $identityColumn
- * @return Zend_Auth_Adapter_DbTable Provides a fluent interface
- */
- public function setIdentityColumn($identityColumn)
- {
- $this->_identityColumn = $identityColumn;
- return $this;
- }
-
- /**
- * setCredentialColumn() - set the column name to be used as the credential column
- *
- * @param string $credentialColumn
- * @return Zend_Auth_Adapter_DbTable Provides a fluent interface
- */
- public function setCredentialColumn($credentialColumn)
- {
- $this->_credentialColumn = $credentialColumn;
- return $this;
- }
-
- /**
- * setCredentialTreatment() - allows the developer to pass a parameterized string that is
- * used to transform or treat the input credential data.
- *
- * In many cases, passwords and other sensitive data are encrypted, hashed, encoded,
- * obscured, or otherwise treated through some function or algorithm. By specifying a
- * parameterized treatment string with this method, a developer may apply arbitrary SQL
- * upon input credential data.
- *
- * Examples:
- *
- * 'PASSWORD(?)'
- * 'MD5(?)'
- *
- * @param string $treatment
- * @return Zend_Auth_Adapter_DbTable Provides a fluent interface
- */
- public function setCredentialTreatment($treatment)
- {
- $this->_credentialTreatment = $treatment;
- return $this;
- }
-
- /**
- * setIdentity() - set the value to be used as the identity
- *
- * @param string $value
- * @return Zend_Auth_Adapter_DbTable Provides a fluent interface
- */
- public function setIdentity($value)
- {
- $this->_identity = $value;
- return $this;
- }
-
- /**
- * setCredential() - set the credential value to be used, optionally can specify a treatment
- * to be used, should be supplied in parameterized form, such as 'MD5(?)' or 'PASSWORD(?)'
- *
- * @param string $credential
- * @return Zend_Auth_Adapter_DbTable Provides a fluent interface
- */
- public function setCredential($credential)
- {
- $this->_credential = $credential;
- return $this;
- }
-
- /**
- * getDbSelect() - Return the preauthentication Db Select object for userland select query modification
- *
- * @return Zend_Db_Select
- */
- public function getDbSelect()
- {
- if ($this->_dbSelect == null) {
- $this->_dbSelect = $this->_zendDb->select();
- }
-
- return $this->_dbSelect;
- }
-
- /**
- * getResultRowObject() - Returns the result row as a stdClass object
- *
- * @param string|array $returnColumns
- * @param string|array $omitColumns
- * @return stdClass|boolean
- */
- public function getResultRowObject($returnColumns = null, $omitColumns = null)
- {
- if (!$this->_resultRow) {
- return false;
- }
-
- $returnObject = new stdClass();
-
- if (null !== $returnColumns) {
-
- $availableColumns = array_keys($this->_resultRow);
- foreach ( (array) $returnColumns as $returnColumn) {
- if (in_array($returnColumn, $availableColumns)) {
- $returnObject->{$returnColumn} = $this->_resultRow[$returnColumn];
- }
- }
- return $returnObject;
-
- } elseif (null !== $omitColumns) {
-
- $omitColumns = (array) $omitColumns;
- foreach ($this->_resultRow as $resultColumn => $resultValue) {
- if (!in_array($resultColumn, $omitColumns)) {
- $returnObject->{$resultColumn} = $resultValue;
- }
- }
- return $returnObject;
-
- } else {
-
- foreach ($this->_resultRow as $resultColumn => $resultValue) {
- $returnObject->{$resultColumn} = $resultValue;
- }
- return $returnObject;
-
- }
- }
-
- /**
- * authenticate() - defined by Zend_Auth_Adapter_Interface. This method is called to
- * attempt an authentication. Previous to this call, this adapter would have already
- * been configured with all necessary information to successfully connect to a database
- * table and attempt to find a record matching the provided identity.
- *
- * @throws Zend_Auth_Adapter_Exception if answering the authentication query is impossible
- * @return Zend_Auth_Result
- */
- public function authenticate()
- {
- $this->_authenticateSetup();
- $dbSelect = $this->_authenticateCreateSelect();
- $resultIdentities = $this->_authenticateQuerySelect($dbSelect);
-
- if ( ($authResult = $this->_authenticateValidateResultset($resultIdentities)) instanceof Zend_Auth_Result) {
- return $authResult;
- }
-
- $authResult = $this->_authenticateValidateResult(array_shift($resultIdentities));
- return $authResult;
- }
-
- /**
- * _authenticateSetup() - This method abstracts the steps involved with
- * making sure that this adapter was indeed setup properly with all
- * required pieces of information.
- *
- * @throws Zend_Auth_Adapter_Exception - in the event that setup was not done properly
- * @return true
- */
- protected function _authenticateSetup()
- {
- $exception = null;
-
- if ($this->_tableName == '') {
- $exception = 'A table must be supplied for the Zend_Auth_Adapter_DbTable authentication adapter.';
- } elseif ($this->_identityColumn == '') {
- $exception = 'An identity column must be supplied for the Zend_Auth_Adapter_DbTable authentication adapter.';
- } elseif ($this->_credentialColumn == '') {
- $exception = 'A credential column must be supplied for the Zend_Auth_Adapter_DbTable authentication adapter.';
- } elseif ($this->_identity == '') {
- $exception = 'A value for the identity was not provided prior to authentication with Zend_Auth_Adapter_DbTable.';
- } elseif ($this->_credential === null) {
- $exception = 'A credential value was not provided prior to authentication with Zend_Auth_Adapter_DbTable.';
- }
-
- if (null !== $exception) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception($exception);
- }
-
- $this->_authenticateResultInfo = array(
- 'code' => Zend_Auth_Result::FAILURE,
- 'identity' => $this->_identity,
- 'messages' => array()
- );
-
- return true;
- }
-
- /**
- * _authenticateCreateSelect() - This method creates a Zend_Db_Select object that
- * is completely configured to be queried against the database.
- *
- * @return Zend_Db_Select
- */
- protected function _authenticateCreateSelect()
- {
- // build credential expression
- if (empty($this->_credentialTreatment) || (strpos($this->_credentialTreatment, '?') === false)) {
- $this->_credentialTreatment = '?';
- }
-
- $credentialExpression = new Zend_Db_Expr(
- '(CASE WHEN ' .
- $this->_zendDb->quoteInto(
- $this->_zendDb->quoteIdentifier($this->_credentialColumn, true)
- . ' = ' . $this->_credentialTreatment, $this->_credential
- )
- . ' THEN 1 ELSE 0 END) AS '
- . $this->_zendDb->quoteIdentifier(
- $this->_zendDb->foldCase('zend_auth_credential_match')
- )
- );
-
- // get select
- $dbSelect = clone $this->getDbSelect();
- $dbSelect->from($this->_tableName, array('*', $credentialExpression))
- ->where($this->_zendDb->quoteIdentifier($this->_identityColumn, true) . ' = ?', $this->_identity);
-
- return $dbSelect;
- }
-
- /**
- * _authenticateQuerySelect() - This method accepts a Zend_Db_Select object and
- * performs a query against the database with that object.
- *
- * @param Zend_Db_Select $dbSelect
- * @throws Zend_Auth_Adapter_Exception - when an invalid select
- * object is encountered
- * @return array
- */
- protected function _authenticateQuerySelect(Zend_Db_Select $dbSelect)
- {
- try {
- if ($this->_zendDb->getFetchMode() != Zend_DB::FETCH_ASSOC) {
- $origDbFetchMode = $this->_zendDb->getFetchMode();
- $this->_zendDb->setFetchMode(Zend_DB::FETCH_ASSOC);
- }
- $resultIdentities = $this->_zendDb->fetchAll($dbSelect->__toString());
- if (isset($origDbFetchMode)) {
- $this->_zendDb->setFetchMode($origDbFetchMode);
- unset($origDbFetchMode);
- }
- } catch (Exception $e) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('The supplied parameters to Zend_Auth_Adapter_DbTable failed to '
- . 'produce a valid sql statement, please check table and column names '
- . 'for validity.', 0, $e);
- }
- return $resultIdentities;
- }
-
- /**
- * _authenticateValidateResultSet() - This method attempts to make
- * certain that only one record was returned in the resultset
- *
- * @param array $resultIdentities
- * @return true|Zend_Auth_Result
- */
- protected function _authenticateValidateResultSet(array $resultIdentities)
- {
-
- if (count($resultIdentities) < 1) {
- $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
- $this->_authenticateResultInfo['messages'][] = 'A record with the supplied identity could not be found.';
- return $this->_authenticateCreateAuthResult();
- } elseif (count($resultIdentities) > 1) {
- $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS;
- $this->_authenticateResultInfo['messages'][] = 'More than one record matches the supplied identity.';
- return $this->_authenticateCreateAuthResult();
- }
-
- return true;
- }
-
- /**
- * _authenticateValidateResult() - This method attempts to validate that
- * the record in the resultset is indeed a record that matched the
- * identity provided to this adapter.
- *
- * @param array $resultIdentity
- * @return Zend_Auth_Result
- */
- protected function _authenticateValidateResult($resultIdentity)
- {
- $zendAuthCredentialMatchColumn = $this->_zendDb->foldCase('zend_auth_credential_match');
-
- if ($resultIdentity[$zendAuthCredentialMatchColumn] != '1') {
- $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
- $this->_authenticateResultInfo['messages'][] = 'Supplied credential is invalid.';
- return $this->_authenticateCreateAuthResult();
- }
-
- unset($resultIdentity[$zendAuthCredentialMatchColumn]);
- $this->_resultRow = $resultIdentity;
-
- $this->_authenticateResultInfo['code'] = Zend_Auth_Result::SUCCESS;
- $this->_authenticateResultInfo['messages'][] = 'Authentication successful.';
- return $this->_authenticateCreateAuthResult();
- }
-
- /**
- * _authenticateCreateAuthResult() - Creates a Zend_Auth_Result object from
- * the information that has been collected during the authenticate() attempt.
- *
- * @return Zend_Auth_Result
- */
- protected function _authenticateCreateAuthResult()
- {
- return new Zend_Auth_Result(
- $this->_authenticateResultInfo['code'],
- $this->_authenticateResultInfo['identity'],
- $this->_authenticateResultInfo['messages']
- );
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Auth/Adapter/Digest.php zendframework-2.2.6/library/Zend/Auth/Adapter/Digest.php
--- zendframework-1.10.4/library/Zend/Auth/Adapter/Digest.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Auth/Adapter/Digest.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,230 +0,0 @@
-$methodName($$option);
- }
- }
- }
-
- /**
- * Returns the filename option value or null if it has not yet been set
- *
- * @return string|null
- */
- public function getFilename()
- {
- return $this->_filename;
- }
-
- /**
- * Sets the filename option value
- *
- * @param mixed $filename
- * @return Zend_Auth_Adapter_Digest Provides a fluent interface
- */
- public function setFilename($filename)
- {
- $this->_filename = (string) $filename;
- return $this;
- }
-
- /**
- * Returns the realm option value or null if it has not yet been set
- *
- * @return string|null
- */
- public function getRealm()
- {
- return $this->_realm;
- }
-
- /**
- * Sets the realm option value
- *
- * @param mixed $realm
- * @return Zend_Auth_Adapter_Digest Provides a fluent interface
- */
- public function setRealm($realm)
- {
- $this->_realm = (string) $realm;
- return $this;
- }
-
- /**
- * Returns the username option value or null if it has not yet been set
- *
- * @return string|null
- */
- public function getUsername()
- {
- return $this->_username;
- }
-
- /**
- * Sets the username option value
- *
- * @param mixed $username
- * @return Zend_Auth_Adapter_Digest Provides a fluent interface
- */
- public function setUsername($username)
- {
- $this->_username = (string) $username;
- return $this;
- }
-
- /**
- * Returns the password option value or null if it has not yet been set
- *
- * @return string|null
- */
- public function getPassword()
- {
- return $this->_password;
- }
-
- /**
- * Sets the password option value
- *
- * @param mixed $password
- * @return Zend_Auth_Adapter_Digest Provides a fluent interface
- */
- public function setPassword($password)
- {
- $this->_password = (string) $password;
- return $this;
- }
-
- /**
- * Defined by Zend_Auth_Adapter_Interface
- *
- * @throws Zend_Auth_Adapter_Exception
- * @return Zend_Auth_Result
- */
- public function authenticate()
- {
- $optionsRequired = array('filename', 'realm', 'username', 'password');
- foreach ($optionsRequired as $optionRequired) {
- if (null === $this->{"_$optionRequired"}) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception("Option '$optionRequired' must be set before authentication");
- }
- }
-
- if (false === ($fileHandle = @fopen($this->_filename, 'r'))) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception("Cannot open '$this->_filename' for reading");
- }
-
- $id = "$this->_username:$this->_realm";
- $idLength = strlen($id);
-
- $result = array(
- 'code' => Zend_Auth_Result::FAILURE,
- 'identity' => array(
- 'realm' => $this->_realm,
- 'username' => $this->_username,
- ),
- 'messages' => array()
- );
-
- while ($line = trim(fgets($fileHandle))) {
- if (substr($line, 0, $idLength) === $id) {
- if (substr($line, -32) === md5("$this->_username:$this->_realm:$this->_password")) {
- $result['code'] = Zend_Auth_Result::SUCCESS;
- } else {
- $result['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
- $result['messages'][] = 'Password incorrect';
- }
- return new Zend_Auth_Result($result['code'], $result['identity'], $result['messages']);
- }
- }
-
- $result['code'] = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
- $result['messages'][] = "Username '$this->_username' and realm '$this->_realm' combination not found";
- return new Zend_Auth_Result($result['code'], $result['identity'], $result['messages']);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Auth/Adapter/Exception.php zendframework-2.2.6/library/Zend/Auth/Adapter/Exception.php
--- zendframework-1.10.4/library/Zend/Auth/Adapter/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Auth/Adapter/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,38 +0,0 @@
-setFile($path);
- }
- }
-
- /**
- * Set the path to the credentials file
- *
- * @param string $path
- * @throws Zend_Auth_Adapter_Http_Resolver_Exception
- * @return Zend_Auth_Adapter_Http_Resolver_File Provides a fluent interface
- */
- public function setFile($path)
- {
- if (empty($path) || !is_readable($path)) {
- /**
- * @see Zend_Auth_Adapter_Http_Resolver_Exception
- */
- require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Path not readable: ' . $path);
- }
- $this->_file = $path;
-
- return $this;
- }
-
- /**
- * Returns the path to the credentials file
- *
- * @return string
- */
- public function getFile()
- {
- return $this->_file;
- }
-
- /**
- * Resolve credentials
- *
- * Only the first matching username/realm combination in the file is
- * returned. If the file contains credentials for Digest authentication,
- * the returned string is the password hash, or h(a1) from RFC 2617. The
- * returned string is the plain-text password for Basic authentication.
- *
- * The expected format of the file is:
- * username:realm:sharedSecret
- *
- * That is, each line consists of the user's username, the applicable
- * authentication realm, and the password or hash, each delimited by
- * colons.
- *
- * @param string $username Username
- * @param string $realm Authentication Realm
- * @throws Zend_Auth_Adapter_Http_Resolver_Exception
- * @return string|false User's shared secret, if the user is found in the
- * realm, false otherwise.
- */
- public function resolve($username, $realm)
- {
- if (empty($username)) {
- /**
- * @see Zend_Auth_Adapter_Http_Resolver_Exception
- */
- require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Username is required');
- } else if (!ctype_print($username) || strpos($username, ':') !== false) {
- /**
- * @see Zend_Auth_Adapter_Http_Resolver_Exception
- */
- require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Username must consist only of printable characters, '
- . 'excluding the colon');
- }
- if (empty($realm)) {
- /**
- * @see Zend_Auth_Adapter_Http_Resolver_Exception
- */
- require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Realm is required');
- } else if (!ctype_print($realm) || strpos($realm, ':') !== false) {
- /**
- * @see Zend_Auth_Adapter_Http_Resolver_Exception
- */
- require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Realm must consist only of printable characters, '
- . 'excluding the colon.');
- }
-
- // Open file, read through looking for matching credentials
- $fp = @fopen($this->_file, 'r');
- if (!$fp) {
- /**
- * @see Zend_Auth_Adapter_Http_Resolver_Exception
- */
- require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
- throw new Zend_Auth_Adapter_Http_Resolver_Exception('Unable to open password file: ' . $this->_file);
- }
-
- // No real validation is done on the contents of the password file. The
- // assumption is that we trust the administrators to keep it secure.
- while (($line = fgetcsv($fp, 512, ':')) !== false) {
- if ($line[0] == $username && $line[1] == $realm) {
- $password = $line[2];
- fclose($fp);
- return $password;
- }
- }
-
- fclose($fp);
- return false;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Auth/Adapter/Http/Resolver/Interface.php zendframework-2.2.6/library/Zend/Auth/Adapter/Http/Resolver/Interface.php
--- zendframework-1.10.4/library/Zend/Auth/Adapter/Http/Resolver/Interface.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Auth/Adapter/Http/Resolver/Interface.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,47 +0,0 @@
- 'basic'|'digest'|'basic digest'
- * 'realm' =>
- * 'digest_domains' => Space-delimited list of URIs
- * 'nonce_timeout' =>
- * 'use_opaque' => Whether to send the opaque value in the header
- * 'alogrithm' => See $_supportedAlgos. Default: MD5
- * 'proxy_auth' => Whether to do authentication as a Proxy
- * @throws Zend_Auth_Adapter_Exception
- * @return void
- */
- public function __construct(array $config)
- {
- if (!extension_loaded('hash')) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception(__CLASS__ . ' requires the \'hash\' extension');
- }
-
- $this->_request = null;
- $this->_response = null;
- $this->_ieNoOpaque = false;
-
-
- if (empty($config['accept_schemes'])) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Config key \'accept_schemes\' is required');
- }
-
- $schemes = explode(' ', $config['accept_schemes']);
- $this->_acceptSchemes = array_intersect($schemes, $this->_supportedSchemes);
- if (empty($this->_acceptSchemes)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('No supported schemes given in \'accept_schemes\'. Valid values: '
- . implode(', ', $this->_supportedSchemes));
- }
-
- // Double-quotes are used to delimit the realm string in the HTTP header,
- // and colons are field delimiters in the password file.
- if (empty($config['realm']) ||
- !ctype_print($config['realm']) ||
- strpos($config['realm'], ':') !== false ||
- strpos($config['realm'], '"') !== false) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Config key \'realm\' is required, and must contain only printable '
- . 'characters, excluding quotation marks and colons');
- } else {
- $this->_realm = $config['realm'];
- }
-
- if (in_array('digest', $this->_acceptSchemes)) {
- if (empty($config['digest_domains']) ||
- !ctype_print($config['digest_domains']) ||
- strpos($config['digest_domains'], '"') !== false) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Config key \'digest_domains\' is required, and must contain '
- . 'only printable characters, excluding quotation marks');
- } else {
- $this->_domains = $config['digest_domains'];
- }
-
- if (empty($config['nonce_timeout']) ||
- !is_numeric($config['nonce_timeout'])) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Config key \'nonce_timeout\' is required, and must be an '
- . 'integer');
- } else {
- $this->_nonceTimeout = (int) $config['nonce_timeout'];
- }
-
- // We use the opaque value unless explicitly told not to
- if (isset($config['use_opaque']) && false == (bool) $config['use_opaque']) {
- $this->_useOpaque = false;
- } else {
- $this->_useOpaque = true;
- }
-
- if (isset($config['algorithm']) && in_array($config['algorithm'], $this->_supportedAlgos)) {
- $this->_algo = $config['algorithm'];
- } else {
- $this->_algo = 'MD5';
- }
- }
-
- // Don't be a proxy unless explicitly told to do so
- if (isset($config['proxy_auth']) && true == (bool) $config['proxy_auth']) {
- $this->_imaProxy = true; // I'm a Proxy
- } else {
- $this->_imaProxy = false;
- }
- }
-
- /**
- * Setter for the _basicResolver property
- *
- * @param Zend_Auth_Adapter_Http_Resolver_Interface $resolver
- * @return Zend_Auth_Adapter_Http Provides a fluent interface
- */
- public function setBasicResolver(Zend_Auth_Adapter_Http_Resolver_Interface $resolver)
- {
- $this->_basicResolver = $resolver;
-
- return $this;
- }
-
- /**
- * Getter for the _basicResolver property
- *
- * @return Zend_Auth_Adapter_Http_Resolver_Interface
- */
- public function getBasicResolver()
- {
- return $this->_basicResolver;
- }
-
- /**
- * Setter for the _digestResolver property
- *
- * @param Zend_Auth_Adapter_Http_Resolver_Interface $resolver
- * @return Zend_Auth_Adapter_Http Provides a fluent interface
- */
- public function setDigestResolver(Zend_Auth_Adapter_Http_Resolver_Interface $resolver)
- {
- $this->_digestResolver = $resolver;
-
- return $this;
- }
-
- /**
- * Getter for the _digestResolver property
- *
- * @return Zend_Auth_Adapter_Http_Resolver_Interface
- */
- public function getDigestResolver()
- {
- return $this->_digestResolver;
- }
-
- /**
- * Setter for the Request object
- *
- * @param Zend_Controller_Request_Http $request
- * @return Zend_Auth_Adapter_Http Provides a fluent interface
- */
- public function setRequest(Zend_Controller_Request_Http $request)
- {
- $this->_request = $request;
-
- return $this;
- }
-
- /**
- * Getter for the Request object
- *
- * @return Zend_Controller_Request_Http
- */
- public function getRequest()
- {
- return $this->_request;
- }
-
- /**
- * Setter for the Response object
- *
- * @param Zend_Controller_Response_Http $response
- * @return Zend_Auth_Adapter_Http Provides a fluent interface
- */
- public function setResponse(Zend_Controller_Response_Http $response)
- {
- $this->_response = $response;
-
- return $this;
- }
-
- /**
- * Getter for the Response object
- *
- * @return Zend_Controller_Response_Http
- */
- public function getResponse()
- {
- return $this->_response;
- }
-
- /**
- * Authenticate
- *
- * @throws Zend_Auth_Adapter_Exception
- * @return Zend_Auth_Result
- */
- public function authenticate()
- {
- if (empty($this->_request) ||
- empty($this->_response)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Request and Response objects must be set before calling '
- . 'authenticate()');
- }
-
- if ($this->_imaProxy) {
- $getHeader = 'Proxy-Authorization';
- } else {
- $getHeader = 'Authorization';
- }
-
- $authHeader = $this->_request->getHeader($getHeader);
- if (!$authHeader) {
- return $this->_challengeClient();
- }
-
- list($clientScheme) = explode(' ', $authHeader);
- $clientScheme = strtolower($clientScheme);
-
- // The server can issue multiple challenges, but the client should
- // answer with only the selected auth scheme.
- if (!in_array($clientScheme, $this->_supportedSchemes)) {
- $this->_response->setHttpResponseCode(400);
- return new Zend_Auth_Result(
- Zend_Auth_Result::FAILURE_UNCATEGORIZED,
- array(),
- array('Client requested an incorrect or unsupported authentication scheme')
- );
- }
-
- // client sent a scheme that is not the one required
- if (!in_array($clientScheme, $this->_acceptSchemes)) {
- // challenge again the client
- return $this->_challengeClient();
- }
-
- switch ($clientScheme) {
- case 'basic':
- $result = $this->_basicAuth($authHeader);
- break;
- case 'digest':
- $result = $this->_digestAuth($authHeader);
- break;
- default:
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Unsupported authentication scheme');
- }
-
- return $result;
- }
-
- /**
- * Challenge Client
- *
- * Sets a 401 or 407 Unauthorized response code, and creates the
- * appropriate Authenticate header(s) to prompt for credentials.
- *
- * @return Zend_Auth_Result Always returns a non-identity Auth result
- */
- protected function _challengeClient()
- {
- if ($this->_imaProxy) {
- $statusCode = 407;
- $headerName = 'Proxy-Authenticate';
- } else {
- $statusCode = 401;
- $headerName = 'WWW-Authenticate';
- }
-
- $this->_response->setHttpResponseCode($statusCode);
-
- // Send a challenge in each acceptable authentication scheme
- if (in_array('basic', $this->_acceptSchemes)) {
- $this->_response->setHeader($headerName, $this->_basicHeader());
- }
- if (in_array('digest', $this->_acceptSchemes)) {
- $this->_response->setHeader($headerName, $this->_digestHeader());
- }
- return new Zend_Auth_Result(
- Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
- array(),
- array('Invalid or absent credentials; challenging client')
- );
- }
-
- /**
- * Basic Header
- *
- * Generates a Proxy- or WWW-Authenticate header value in the Basic
- * authentication scheme.
- *
- * @return string Authenticate header value
- */
- protected function _basicHeader()
- {
- return 'Basic realm="' . $this->_realm . '"';
- }
-
- /**
- * Digest Header
- *
- * Generates a Proxy- or WWW-Authenticate header value in the Digest
- * authentication scheme.
- *
- * @return string Authenticate header value
- */
- protected function _digestHeader()
- {
- $wwwauth = 'Digest realm="' . $this->_realm . '", '
- . 'domain="' . $this->_domains . '", '
- . 'nonce="' . $this->_calcNonce() . '", '
- . ($this->_useOpaque ? 'opaque="' . $this->_calcOpaque() . '", ' : '')
- . 'algorithm="' . $this->_algo . '", '
- . 'qop="' . implode(',', $this->_supportedQops) . '"';
-
- return $wwwauth;
- }
-
- /**
- * Basic Authentication
- *
- * @param string $header Client's Authorization header
- * @throws Zend_Auth_Adapter_Exception
- * @return Zend_Auth_Result
- */
- protected function _basicAuth($header)
- {
- if (empty($header)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('The value of the client Authorization header is required');
- }
- if (empty($this->_basicResolver)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('A basicResolver object must be set before doing Basic '
- . 'authentication');
- }
-
- // Decode the Authorization header
- $auth = substr($header, strlen('Basic '));
- $auth = base64_decode($auth);
- if (!$auth) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Unable to base64_decode Authorization header value');
- }
-
- // See ZF-1253. Validate the credentials the same way the digest
- // implementation does. If invalid credentials are detected,
- // re-challenge the client.
- if (!ctype_print($auth)) {
- return $this->_challengeClient();
- }
- // Fix for ZF-1515: Now re-challenges on empty username or password
- $creds = array_filter(explode(':', $auth));
- if (count($creds) != 2) {
- return $this->_challengeClient();
- }
-
- $password = $this->_basicResolver->resolve($creds[0], $this->_realm);
- if ($password && $password == $creds[1]) {
- $identity = array('username'=>$creds[0], 'realm'=>$this->_realm);
- return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
- } else {
- return $this->_challengeClient();
- }
- }
-
- /**
- * Digest Authentication
- *
- * @param string $header Client's Authorization header
- * @throws Zend_Auth_Adapter_Exception
- * @return Zend_Auth_Result Valid auth result only on successful auth
- */
- protected function _digestAuth($header)
- {
- if (empty($header)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('The value of the client Authorization header is required');
- }
- if (empty($this->_digestResolver)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('A digestResolver object must be set before doing Digest authentication');
- }
-
- $data = $this->_parseDigestAuth($header);
- if ($data === false) {
- $this->_response->setHttpResponseCode(400);
- return new Zend_Auth_Result(
- Zend_Auth_Result::FAILURE_UNCATEGORIZED,
- array(),
- array('Invalid Authorization header format')
- );
- }
-
- // See ZF-1052. This code was a bit too unforgiving of invalid
- // usernames. Now, if the username is bad, we re-challenge the client.
- if ('::invalid::' == $data['username']) {
- return $this->_challengeClient();
- }
-
- // Verify that the client sent back the same nonce
- if ($this->_calcNonce() != $data['nonce']) {
- return $this->_challengeClient();
- }
- // The opaque value is also required to match, but of course IE doesn't
- // play ball.
- if (!$this->_ieNoOpaque && $this->_calcOpaque() != $data['opaque']) {
- return $this->_challengeClient();
- }
-
- // Look up the user's password hash. If not found, deny access.
- // This makes no assumptions about how the password hash was
- // constructed beyond that it must have been built in such a way as
- // to be recreatable with the current settings of this object.
- $ha1 = $this->_digestResolver->resolve($data['username'], $data['realm']);
- if ($ha1 === false) {
- return $this->_challengeClient();
- }
-
- // If MD5-sess is used, a1 value is made of the user's password
- // hash with the server and client nonce appended, separated by
- // colons.
- if ($this->_algo == 'MD5-sess') {
- $ha1 = hash('md5', $ha1 . ':' . $data['nonce'] . ':' . $data['cnonce']);
- }
-
- // Calculate h(a2). The value of this hash depends on the qop
- // option selected by the client and the supported hash functions
- switch ($data['qop']) {
- case 'auth':
- $a2 = $this->_request->getMethod() . ':' . $data['uri'];
- break;
- case 'auth-int':
- // Should be REQUEST_METHOD . ':' . uri . ':' . hash(entity-body),
- // but this isn't supported yet, so fall through to default case
- default:
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Client requested an unsupported qop option');
- }
- // Using hash() should make parameterizing the hash algorithm
- // easier
- $ha2 = hash('md5', $a2);
-
-
- // Calculate the server's version of the request-digest. This must
- // match $data['response']. See RFC 2617, section 3.2.2.1
- $message = $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $ha2;
- $digest = hash('md5', $ha1 . ':' . $message);
-
- // If our digest matches the client's let them in, otherwise return
- // a 401 code and exit to prevent access to the protected resource.
- if ($digest == $data['response']) {
- $identity = array('username'=>$data['username'], 'realm'=>$data['realm']);
- return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
- } else {
- return $this->_challengeClient();
- }
- }
-
- /**
- * Calculate Nonce
- *
- * @return string The nonce value
- */
- protected function _calcNonce()
- {
- // Once subtle consequence of this timeout calculation is that it
- // actually divides all of time into _nonceTimeout-sized sections, such
- // that the value of timeout is the point in time of the next
- // approaching "boundary" of a section. This allows the server to
- // consistently generate the same timeout (and hence the same nonce
- // value) across requests, but only as long as one of those
- // "boundaries" is not crossed between requests. If that happens, the
- // nonce will change on its own, and effectively log the user out. This
- // would be surprising if the user just logged in.
- $timeout = ceil(time() / $this->_nonceTimeout) * $this->_nonceTimeout;
-
- $nonce = hash('md5', $timeout . ':' . $this->_request->getServer('HTTP_USER_AGENT') . ':' . __CLASS__);
- return $nonce;
- }
-
- /**
- * Calculate Opaque
- *
- * The opaque string can be anything; the client must return it exactly as
- * it was sent. It may be useful to store data in this string in some
- * applications. Ideally, a new value for this would be generated each time
- * a WWW-Authenticate header is sent (in order to reduce predictability),
- * but we would have to be able to create the same exact value across at
- * least two separate requests from the same client.
- *
- * @return string The opaque value
- */
- protected function _calcOpaque()
- {
- return hash('md5', 'Opaque Data:' . __CLASS__);
- }
-
- /**
- * Parse Digest Authorization header
- *
- * @param string $header Client's Authorization: HTTP header
- * @return array|false Data elements from header, or false if any part of
- * the header is invalid
- */
- protected function _parseDigestAuth($header)
- {
- $temp = null;
- $data = array();
-
- // See ZF-1052. Detect invalid usernames instead of just returning a
- // 400 code.
- $ret = preg_match('/username="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])
- || !ctype_print($temp[1])
- || strpos($temp[1], ':') !== false) {
- $data['username'] = '::invalid::';
- } else {
- $data['username'] = $temp[1];
- }
- $temp = null;
-
- $ret = preg_match('/realm="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- if (!ctype_print($temp[1]) || strpos($temp[1], ':') !== false) {
- return false;
- } else {
- $data['realm'] = $temp[1];
- }
- $temp = null;
-
- $ret = preg_match('/nonce="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- if (!ctype_xdigit($temp[1])) {
- return false;
- } else {
- $data['nonce'] = $temp[1];
- }
- $temp = null;
-
- $ret = preg_match('/uri="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- // Section 3.2.2.5 in RFC 2617 says the authenticating server must
- // verify that the URI field in the Authorization header is for the
- // same resource requested in the Request Line.
- $rUri = @parse_url($this->_request->getRequestUri());
- $cUri = @parse_url($temp[1]);
- if (false === $rUri || false === $cUri) {
- return false;
- } else {
- // Make sure the path portion of both URIs is the same
- if ($rUri['path'] != $cUri['path']) {
- return false;
- }
- // Section 3.2.2.5 seems to suggest that the value of the URI
- // Authorization field should be made into an absolute URI if the
- // Request URI is absolute, but it's vague, and that's a bunch of
- // code I don't want to write right now.
- $data['uri'] = $temp[1];
- }
- $temp = null;
-
- $ret = preg_match('/response="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- if (32 != strlen($temp[1]) || !ctype_xdigit($temp[1])) {
- return false;
- } else {
- $data['response'] = $temp[1];
- }
- $temp = null;
-
- // The spec says this should default to MD5 if omitted. OK, so how does
- // that square with the algo we send out in the WWW-Authenticate header,
- // if it can easily be overridden by the client?
- $ret = preg_match('/algorithm="?(' . $this->_algo . ')"?/', $header, $temp);
- if ($ret && !empty($temp[1])
- && in_array($temp[1], $this->_supportedAlgos)) {
- $data['algorithm'] = $temp[1];
- } else {
- $data['algorithm'] = 'MD5'; // = $this->_algo; ?
- }
- $temp = null;
-
- // Not optional in this implementation
- $ret = preg_match('/cnonce="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- if (!ctype_print($temp[1])) {
- return false;
- } else {
- $data['cnonce'] = $temp[1];
- }
- $temp = null;
-
- // If the server sent an opaque value, the client must send it back
- if ($this->_useOpaque) {
- $ret = preg_match('/opaque="([^"]+)"/', $header, $temp);
- if (!$ret || empty($temp[1])) {
-
- // Big surprise: IE isn't RFC 2617-compliant.
- if (false !== strpos($this->_request->getHeader('User-Agent'), 'MSIE')) {
- $temp[1] = '';
- $this->_ieNoOpaque = true;
- } else {
- return false;
- }
- }
- // This implementation only sends MD5 hex strings in the opaque value
- if (!$this->_ieNoOpaque &&
- (32 != strlen($temp[1]) || !ctype_xdigit($temp[1]))) {
- return false;
- } else {
- $data['opaque'] = $temp[1];
- }
- $temp = null;
- }
-
- // Not optional in this implementation, but must be one of the supported
- // qop types
- $ret = preg_match('/qop="?(' . implode('|', $this->_supportedQops) . ')"?/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- if (!in_array($temp[1], $this->_supportedQops)) {
- return false;
- } else {
- $data['qop'] = $temp[1];
- }
- $temp = null;
-
- // Not optional in this implementation. The spec says this value
- // shouldn't be a quoted string, but apparently some implementations
- // quote it anyway. See ZF-1544.
- $ret = preg_match('/nc="?([0-9A-Fa-f]{8})"?/', $header, $temp);
- if (!$ret || empty($temp[1])) {
- return false;
- }
- if (8 != strlen($temp[1]) || !ctype_xdigit($temp[1])) {
- return false;
- } else {
- $data['nc'] = $temp[1];
- }
- $temp = null;
-
- return $data;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Auth/Adapter/InfoCard.php zendframework-2.2.6/library/Zend/Auth/Adapter/InfoCard.php
--- zendframework-1.10.4/library/Zend/Auth/Adapter/InfoCard.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Auth/Adapter/InfoCard.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,261 +0,0 @@
-_xmlToken = $strXmlDocument;
- $this->_infoCard = new Zend_InfoCard();
- }
-
- /**
- * Sets the InfoCard component Adapter to use
- *
- * @param Zend_InfoCard_Adapter_Interface $a
- * @return Zend_Auth_Adapter_InfoCard Provides a fluent interface
- */
- public function setAdapter(Zend_InfoCard_Adapter_Interface $a)
- {
- $this->_infoCard->setAdapter($a);
- return $this;
- }
-
- /**
- * Retrieves the InfoCard component adapter being used
- *
- * @return Zend_InfoCard_Adapter_Interface
- */
- public function getAdapter()
- {
- return $this->_infoCard->getAdapter();
- }
-
- /**
- * Retrieves the InfoCard public key cipher object being used
- *
- * @return Zend_InfoCard_Cipher_PKI_Interface
- */
- public function getPKCipherObject()
- {
- return $this->_infoCard->getPKCipherObject();
- }
-
- /**
- * Sets the InfoCard public key cipher object to use
- *
- * @param Zend_InfoCard_Cipher_PKI_Interface $cipherObj
- * @return Zend_Auth_Adapter_InfoCard Provides a fluent interface
- */
- public function setPKICipherObject(Zend_InfoCard_Cipher_PKI_Interface $cipherObj)
- {
- $this->_infoCard->setPKICipherObject($cipherObj);
- return $this;
- }
-
- /**
- * Retrieves the Symmetric cipher object being used
- *
- * @return Zend_InfoCard_Cipher_Symmetric_Interface
- */
- public function getSymCipherObject()
- {
- return $this->_infoCard->getSymCipherObject();
- }
-
- /**
- * Sets the InfoCard symmetric cipher object to use
- *
- * @param Zend_InfoCard_Cipher_Symmetric_Interface $cipherObj
- * @return Zend_Auth_Adapter_InfoCard Provides a fluent interface
- */
- public function setSymCipherObject(Zend_InfoCard_Cipher_Symmetric_Interface $cipherObj)
- {
- $this->_infoCard->setSymCipherObject($cipherObj);
- return $this;
- }
-
- /**
- * Remove a Certificate Pair by Key ID from the search list
- *
- * @param string $key_id The Certificate Key ID returned from adding the certificate pair
- * @throws Zend_InfoCard_Exception
- * @return Zend_Auth_Adapter_InfoCard Provides a fluent interface
- */
- public function removeCertificatePair($key_id)
- {
- $this->_infoCard->removeCertificatePair($key_id);
- return $this;
- }
-
- /**
- * Add a Certificate Pair to the list of certificates searched by the component
- *
- * @param string $private_key_file The path to the private key file for the pair
- * @param string $public_key_file The path to the certificate / public key for the pair
- * @param string $type (optional) The URI for the type of key pair this is (default RSA with OAEP padding)
- * @param string $password (optional) The password for the private key file if necessary
- * @throws Zend_InfoCard_Exception
- * @return string A key ID representing this key pair in the component
- */
- public function addCertificatePair($private_key_file, $public_key_file, $type = Zend_InfoCard_Cipher::ENC_RSA_OAEP_MGF1P, $password = null)
- {
- return $this->_infoCard->addCertificatePair($private_key_file, $public_key_file, $type, $password);
- }
-
- /**
- * Return a Certificate Pair from a key ID
- *
- * @param string $key_id The Key ID of the certificate pair in the component
- * @throws Zend_InfoCard_Exception
- * @return array An array containing the path to the private/public key files,
- * the type URI and the password if provided
- */
- public function getCertificatePair($key_id)
- {
- return $this->_infoCard->getCertificatePair($key_id);
- }
-
- /**
- * Set the XML Token to be processed
- *
- * @param string $strXmlToken The XML token to process
- * @return Zend_Auth_Adapter_InfoCard Provides a fluent interface
- */
- public function setXmlToken($strXmlToken)
- {
- $this->_xmlToken = $strXmlToken;
- return $this;
- }
-
- /**
- * Get the XML Token being processed
- *
- * @return string The XML token to be processed
- */
- public function getXmlToken()
- {
- return $this->_xmlToken;
- }
-
- /**
- * Authenticates the XML token
- *
- * @return Zend_Auth_Result The result of the authentication
- */
- public function authenticate()
- {
- try {
- $claims = $this->_infoCard->process($this->getXmlToken());
- } catch(Exception $e) {
- return new Zend_Auth_Result(Zend_Auth_Result::FAILURE , null, array('Exception Thrown',
- $e->getMessage(),
- $e->getTraceAsString(),
- serialize($e)));
- }
-
- if(!$claims->isValid()) {
- switch($claims->getCode()) {
- case Zend_infoCard_Claims::RESULT_PROCESSING_FAILURE:
- return new Zend_Auth_Result(
- Zend_Auth_Result::FAILURE,
- $claims,
- array(
- 'Processing Failure',
- $claims->getErrorMsg()
- )
- );
- break;
- case Zend_InfoCard_Claims::RESULT_VALIDATION_FAILURE:
- return new Zend_Auth_Result(
- Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID,
- $claims,
- array(
- 'Validation Failure',
- $claims->getErrorMsg()
- )
- );
- break;
- default:
- return new Zend_Auth_Result(
- Zend_Auth_Result::FAILURE,
- $claims,
- array(
- 'Unknown Failure',
- $claims->getErrorMsg()
- )
- );
- break;
- }
- }
-
- return new Zend_Auth_Result(
- Zend_Auth_Result::SUCCESS,
- $claims
- );
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Auth/Adapter/Interface.php zendframework-2.2.6/library/Zend/Auth/Adapter/Interface.php
--- zendframework-1.10.4/library/Zend/Auth/Adapter/Interface.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Auth/Adapter/Interface.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,46 +0,0 @@
-setOptions($options);
- if ($username !== null) {
- $this->setUsername($username);
- }
- if ($password !== null) {
- $this->setPassword($password);
- }
- }
-
- /**
- * Returns the array of arrays of Zend_Ldap options of this adapter.
- *
- * @return array|null
- */
- public function getOptions()
- {
- return $this->_options;
- }
-
- /**
- * Sets the array of arrays of Zend_Ldap options to be used by
- * this adapter.
- *
- * @param array $options The array of arrays of Zend_Ldap options
- * @return Zend_Auth_Adapter_Ldap Provides a fluent interface
- */
- public function setOptions($options)
- {
- $this->_options = is_array($options) ? $options : array();
- return $this;
- }
-
- /**
- * Returns the username of the account being authenticated, or
- * NULL if none is set.
- *
- * @return string|null
- */
- public function getUsername()
- {
- return $this->_username;
- }
-
- /**
- * Sets the username for binding
- *
- * @param string $username The username for binding
- * @return Zend_Auth_Adapter_Ldap Provides a fluent interface
- */
- public function setUsername($username)
- {
- $this->_username = (string) $username;
- return $this;
- }
-
- /**
- * Returns the password of the account being authenticated, or
- * NULL if none is set.
- *
- * @return string|null
- */
- public function getPassword()
- {
- return $this->_password;
- }
-
- /**
- * Sets the passwort for the account
- *
- * @param string $password The password of the account being authenticated
- * @return Zend_Auth_Adapter_Ldap Provides a fluent interface
- */
- public function setPassword($password)
- {
- $this->_password = (string) $password;
- return $this;
- }
-
- /**
- * setIdentity() - set the identity (username) to be used
- *
- * Proxies to {@see setUsername()}
- *
- * Closes ZF-6813
- *
- * @param string $identity
- * @return Zend_Auth_Adapter_Ldap Provides a fluent interface
- */
- public function setIdentity($identity)
- {
- return $this->setUsername($identity);
- }
-
- /**
- * setCredential() - set the credential (password) value to be used
- *
- * Proxies to {@see setPassword()}
- *
- * Closes ZF-6813
- *
- * @param string $credential
- * @return Zend_Auth_Adapter_Ldap Provides a fluent interface
- */
- public function setCredential($credential)
- {
- return $this->setPassword($credential);
- }
-
- /**
- * Returns the LDAP Object
- *
- * @return Zend_Ldap The Zend_Ldap object used to authenticate the credentials
- */
- public function getLdap()
- {
- if ($this->_ldap === null) {
- /**
- * @see Zend_Ldap
- */
- require_once 'Zend/Ldap.php';
- $this->_ldap = new Zend_Ldap();
- }
-
- return $this->_ldap;
- }
-
- /**
- * Set an Ldap connection
- *
- * @param Zend_Ldap $ldap An existing Ldap object
- * @return Zend_Auth_Adapter_Ldap Provides a fluent interface
- */
- public function setLdap(Zend_Ldap $ldap)
- {
- $this->_ldap = $ldap;
-
- $this->setOptions(array($ldap->getOptions()));
-
- return $this;
- }
-
- /**
- * Returns a domain name for the current LDAP options. This is used
- * for skipping redundant operations (e.g. authentications).
- *
- * @return string
- */
- protected function _getAuthorityName()
- {
- $options = $this->getLdap()->getOptions();
- $name = $options['accountDomainName'];
- if (!$name)
- $name = $options['accountDomainNameShort'];
- return $name ? $name : '';
- }
-
- /**
- * Authenticate the user
- *
- * @throws Zend_Auth_Adapter_Exception
- * @return Zend_Auth_Result
- */
- public function authenticate()
- {
- /**
- * @see Zend_Ldap_Exception
- */
- require_once 'Zend/Ldap/Exception.php';
-
- $messages = array();
- $messages[0] = ''; // reserved
- $messages[1] = ''; // reserved
-
- $username = $this->_username;
- $password = $this->_password;
-
- if (!$username) {
- $code = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
- $messages[0] = 'A username is required';
- return new Zend_Auth_Result($code, '', $messages);
- }
- if (!$password) {
- /* A password is required because some servers will
- * treat an empty password as an anonymous bind.
- */
- $code = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
- $messages[0] = 'A password is required';
- return new Zend_Auth_Result($code, '', $messages);
- }
-
- $ldap = $this->getLdap();
-
- $code = Zend_Auth_Result::FAILURE;
- $messages[0] = "Authority not found: $username";
- $failedAuthorities = array();
-
- /* Iterate through each server and try to authenticate the supplied
- * credentials against it.
- */
- foreach ($this->_options as $name => $options) {
-
- if (!is_array($options)) {
- /**
- * @see Zend_Auth_Adapter_Exception
- */
- require_once 'Zend/Auth/Adapter/Exception.php';
- throw new Zend_Auth_Adapter_Exception('Adapter options array not an array');
- }
- $adapterOptions = $this->_prepareOptions($ldap, $options);
- $dname = '';
-
- try {
- if ($messages[1])
- $messages[] = $messages[1];
- $messages[1] = '';
- $messages[] = $this->_optionsToString($options);
-
- $dname = $this->_getAuthorityName();
- if (isset($failedAuthorities[$dname])) {
- /* If multiple sets of server options for the same domain
- * are supplied, we want to skip redundant authentications
- * where the identity or credentials where found to be
- * invalid with another server for the same domain. The
- * $failedAuthorities array tracks this condition (and also
- * serves to supply the original error message).
- * This fixes issue ZF-4093.
- */
- $messages[1] = $failedAuthorities[$dname];
- $messages[] = "Skipping previously failed authority: $dname";
- continue;
- }
-
- $canonicalName = $ldap->getCanonicalAccountName($username);
- $ldap->bind($canonicalName, $password);
- /*
- * Fixes problem when authenticated user is not allowed to retrieve
- * group-membership information or own account.
- * This requires that the user specified with "username" and optionally
- * "password" in the Zend_Ldap options is able to retrieve the required
- * information.
- */
- $requireRebind = false;
- if (isset($options['username'])) {
- $ldap->bind();
- $requireRebind = true;
- }
- $dn = $ldap->getCanonicalAccountName($canonicalName, Zend_Ldap::ACCTNAME_FORM_DN);
-
- $groupResult = $this->_checkGroupMembership($ldap, $canonicalName, $dn, $adapterOptions);
- if ($groupResult === true) {
- $this->_authenticatedDn = $dn;
- $messages[0] = '';
- $messages[1] = '';
- $messages[] = "$canonicalName authentication successful";
- if ($requireRebind === true) {
- // rebinding with authenticated user
- $ldap->bind($dn, $password);
- }
- return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $canonicalName, $messages);
- } else {
- $messages[0] = 'Account is not a member of the specified group';
- $messages[1] = $groupResult;
- $failedAuthorities[$dname] = $groupResult;
- }
- } catch (Zend_Ldap_Exception $zle) {
-
- /* LDAP based authentication is notoriously difficult to diagnose. Therefore
- * we bend over backwards to capture and record every possible bit of
- * information when something goes wrong.
- */
-
- $err = $zle->getCode();
-
- if ($err == Zend_Ldap_Exception::LDAP_X_DOMAIN_MISMATCH) {
- /* This error indicates that the domain supplied in the
- * username did not match the domains in the server options
- * and therefore we should just skip to the next set of
- * server options.
- */
- continue;
- } else if ($err == Zend_Ldap_Exception::LDAP_NO_SUCH_OBJECT) {
- $code = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
- $messages[0] = "Account not found: $username";
- $failedAuthorities[$dname] = $zle->getMessage();
- } else if ($err == Zend_Ldap_Exception::LDAP_INVALID_CREDENTIALS) {
- $code = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
- $messages[0] = 'Invalid credentials';
- $failedAuthorities[$dname] = $zle->getMessage();
- } else {
- $line = $zle->getLine();
- $messages[] = $zle->getFile() . "($line): " . $zle->getMessage();
- $messages[] = str_replace($password, '*****', $zle->getTraceAsString());
- $messages[0] = 'An unexpected failure occurred';
- }
- $messages[1] = $zle->getMessage();
- }
- }
-
- $msg = isset($messages[1]) ? $messages[1] : $messages[0];
- $messages[] = "$username authentication failed: $msg";
-
- return new Zend_Auth_Result($code, $username, $messages);
- }
-
- /**
- * Sets the LDAP specific options on the Zend_Ldap instance
- *
- * @param Zend_Ldap $ldap
- * @param array $options
- * @return array of auth-adapter specific options
- */
- protected function _prepareOptions(Zend_Ldap $ldap, array $options)
- {
- $adapterOptions = array(
- 'group' => null,
- 'groupDn' => $ldap->getBaseDn(),
- 'groupScope' => Zend_Ldap::SEARCH_SCOPE_SUB,
- 'groupAttr' => 'cn',
- 'groupFilter' => 'objectClass=groupOfUniqueNames',
- 'memberAttr' => 'uniqueMember',
- 'memberIsDn' => true
- );
- foreach ($adapterOptions as $key => $value) {
- if (array_key_exists($key, $options)) {
- $value = $options[$key];
- unset($options[$key]);
- switch ($key) {
- case 'groupScope':
- $value = (int)$value;
- if (in_array($value, array(Zend_Ldap::SEARCH_SCOPE_BASE,
- Zend_Ldap::SEARCH_SCOPE_ONE, Zend_Ldap::SEARCH_SCOPE_SUB), true)) {
- $adapterOptions[$key] = $value;
- }
- break;
- case 'memberIsDn':
- $adapterOptions[$key] = ($value === true ||
- $value === '1' || strcasecmp($value, 'true') == 0);
- break;
- default:
- $adapterOptions[$key] = trim($value);
- break;
- }
- }
- }
- $ldap->setOptions($options);
- return $adapterOptions;
- }
-
- /**
- * Checks the group membership of the bound user
- *
- * @param Zend_Ldap $ldap
- * @param string $canonicalName
- * @param string $dn
- * @param array $adapterOptions
- * @return string|true
- */
- protected function _checkGroupMembership(Zend_Ldap $ldap, $canonicalName, $dn, array $adapterOptions)
- {
- if ($adapterOptions['group'] === null) {
- return true;
- }
-
- if ($adapterOptions['memberIsDn'] === false) {
- $user = $canonicalName;
- } else {
- $user = $dn;
- }
-
- /**
- * @see Zend_Ldap_Filter
- */
- require_once 'Zend/Ldap/Filter.php';
- $groupName = Zend_Ldap_Filter::equals($adapterOptions['groupAttr'], $adapterOptions['group']);
- $membership = Zend_Ldap_Filter::equals($adapterOptions['memberAttr'], $user);
- $group = Zend_Ldap_Filter::andFilter($groupName, $membership);
- $groupFilter = $adapterOptions['groupFilter'];
- if (!empty($groupFilter)) {
- $group = $group->addAnd($groupFilter);
- }
-
- $result = $ldap->count($group, $adapterOptions['groupDn'], $adapterOptions['groupScope']);
-
- if ($result === 1) {
- return true;
- } else {
- return 'Failed to verify group membership with ' . $group->toString();
- }
- }
-
- /**
- * getAccountObject() - Returns the result entry as a stdClass object
- *
- * This resembles the feature {@see Zend_Auth_Adapter_DbTable::getResultRowObject()}.
- * Closes ZF-6813
- *
- * @param array $returnAttribs
- * @param array $omitAttribs
- * @return stdClass|boolean
- */
- public function getAccountObject(array $returnAttribs = array(), array $omitAttribs = array())
- {
- if (!$this->_authenticatedDn) {
- return false;
- }
-
- $returnObject = new stdClass();
-
- $omitAttribs = array_map('strtolower', $omitAttribs);
-
- $entry = $this->getLdap()->getEntry($this->_authenticatedDn, $returnAttribs, true);
- foreach ($entry as $attr => $value) {
- if (in_array($attr, $omitAttribs)) {
- // skip attributes marked to be omitted
- continue;
- }
- if (is_array($value)) {
- $returnObject->$attr = (count($value) > 1) ? $value : $value[0];
- } else {
- $returnObject->$attr = $value;
- }
- }
- return $returnObject;
- }
-
- /**
- * Converts options to string
- *
- * @param array $options
- * @return string
- */
- private function _optionsToString(array $options)
- {
- $str = '';
- foreach ($options as $key => $val) {
- if ($key === 'password')
- $val = '*****';
- if ($str)
- $str .= ',';
- $str .= $key . '=' . $val;
- }
- return $str;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Auth/Adapter/OpenId.php zendframework-2.2.6/library/Zend/Auth/Adapter/OpenId.php
--- zendframework-1.10.4/library/Zend/Auth/Adapter/OpenId.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Auth/Adapter/OpenId.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,284 +0,0 @@
-_id = $id;
- $this->_storage = $storage;
- $this->_returnTo = $returnTo;
- $this->_root = $root;
- $this->_extensions = $extensions;
- $this->_response = $response;
- }
-
- /**
- * Sets the value to be used as the identity
- *
- * @param string $id the identity value
- * @return Zend_Auth_Adapter_OpenId Provides a fluent interface
- */
- public function setIdentity($id)
- {
- $this->_id = $id;
- return $this;
- }
-
- /**
- * Sets the storage implementation which will be use by OpenId
- *
- * @param Zend_OpenId_Consumer_Storage $storage
- * @return Zend_Auth_Adapter_OpenId Provides a fluent interface
- */
- public function setStorage(Zend_OpenId_Consumer_Storage $storage)
- {
- $this->_storage = $storage;
- return $this;
- }
-
- /**
- * Sets the HTTP URL to redirect response from server to
- *
- * @param string $returnTo
- * @return Zend_Auth_Adapter_OpenId Provides a fluent interface
- */
- public function setReturnTo($returnTo)
- {
- $this->_returnTo = $returnTo;
- return $this;
- }
-
- /**
- * Sets HTTP URL to identify consumer on server
- *
- * @param string $root
- * @return Zend_Auth_Adapter_OpenId Provides a fluent interface
- */
- public function setRoot($root)
- {
- $this->_root = $root;
- return $this;
- }
-
- /**
- * Sets OpenID extension(s)
- *
- * @param mixed $extensions
- * @return Zend_Auth_Adapter_OpenId Provides a fluent interface
- */
- public function setExtensions($extensions)
- {
- $this->_extensions = $extensions;
- return $this;
- }
-
- /**
- * Sets an optional response object to perform HTTP or HTML form redirection
- *
- * @param string $root
- * @return Zend_Auth_Adapter_OpenId Provides a fluent interface
- */
- public function setResponse($response)
- {
- $this->_response = $response;
- return $this;
- }
-
- /**
- * Enables or disables interaction with user during authentication on
- * OpenID provider.
- *
- * @param bool $check_immediate
- * @return Zend_Auth_Adapter_OpenId Provides a fluent interface
- */
- public function setCheckImmediate($check_immediate)
- {
- $this->_check_immediate = $check_immediate;
- return $this;
- }
-
- /**
- * Sets HTTP client object to make HTTP requests
- *
- * @param Zend_Http_Client $client HTTP client object to be used
- */
- public function setHttpClient($client) {
- $this->_httpClient = $client;
- }
-
- /**
- * Authenticates the given OpenId identity.
- * Defined by Zend_Auth_Adapter_Interface.
- *
- * @throws Zend_Auth_Adapter_Exception If answering the authentication query is impossible
- * @return Zend_Auth_Result
- */
- public function authenticate() {
- $id = $this->_id;
- if (!empty($id)) {
- $consumer = new Zend_OpenId_Consumer($this->_storage);
- $consumer->setHttpClient($this->_httpClient);
- /* login() is never returns on success */
- if (!$this->_check_immediate) {
- if (!$consumer->login($id,
- $this->_returnTo,
- $this->_root,
- $this->_extensions,
- $this->_response)) {
- return new Zend_Auth_Result(
- Zend_Auth_Result::FAILURE,
- $id,
- array("Authentication failed", $consumer->getError()));
- }
- } else {
- if (!$consumer->check($id,
- $this->_returnTo,
- $this->_root,
- $this->_extensions,
- $this->_response)) {
- return new Zend_Auth_Result(
- Zend_Auth_Result::FAILURE,
- $id,
- array("Authentication failed", $consumer->getError()));
- }
- }
- } else {
- $params = (isset($_SERVER['REQUEST_METHOD']) &&
- $_SERVER['REQUEST_METHOD']=='POST') ? $_POST: $_GET;
- $consumer = new Zend_OpenId_Consumer($this->_storage);
- $consumer->setHttpClient($this->_httpClient);
- if ($consumer->verify(
- $params,
- $id,
- $this->_extensions)) {
- return new Zend_Auth_Result(
- Zend_Auth_Result::SUCCESS,
- $id,
- array("Authentication successful"));
- } else {
- return new Zend_Auth_Result(
- Zend_Auth_Result::FAILURE,
- $id,
- array("Authentication failed", $consumer->getError()));
- }
- }
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Auth/Exception.php zendframework-2.2.6/library/Zend/Auth/Exception.php
--- zendframework-1.10.4/library/Zend/Auth/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Auth/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,36 +0,0 @@
- self::SUCCESS ) {
- $code = 1;
- }
-
- $this->_code = $code;
- $this->_identity = $identity;
- $this->_messages = $messages;
- }
-
- /**
- * Returns whether the result represents a successful authentication attempt
- *
- * @return boolean
- */
- public function isValid()
- {
- return ($this->_code > 0) ? true : false;
- }
-
- /**
- * getCode() - Get the result code for this authentication attempt
- *
- * @return int
- */
- public function getCode()
- {
- return $this->_code;
- }
-
- /**
- * Returns the identity used in the authentication attempt
- *
- * @return mixed
- */
- public function getIdentity()
- {
- return $this->_identity;
- }
-
- /**
- * Returns an array of string reasons why the authentication attempt was unsuccessful
- *
- * If authentication was successful, this method returns an empty array.
- *
- * @return array
- */
- public function getMessages()
- {
- return $this->_messages;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Auth/Storage/Exception.php zendframework-2.2.6/library/Zend/Auth/Storage/Exception.php
--- zendframework-1.10.4/library/Zend/Auth/Storage/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Auth/Storage/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,38 +0,0 @@
-_data);
- }
-
- /**
- * Returns the contents of storage
- * Behavior is undefined when storage is empty.
- *
- * @throws Zend_Auth_Storage_Exception If reading contents from storage is impossible
- * @return mixed
- */
- public function read()
- {
- return $this->_data;
- }
-
- /**
- * Writes $contents to storage
- *
- * @param mixed $contents
- * @throws Zend_Auth_Storage_Exception If writing $contents to storage is impossible
- * @return void
- */
- public function write($contents)
- {
- $this->_data = $contents;
- }
-
- /**
- * Clears contents from storage
- *
- * @throws Zend_Auth_Storage_Exception If clearing contents from storage is impossible
- * @return void
- */
- public function clear()
- {
- $this->_data = null;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Auth/Storage/Session.php zendframework-2.2.6/library/Zend/Auth/Storage/Session.php
--- zendframework-1.10.4/library/Zend/Auth/Storage/Session.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Auth/Storage/Session.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,150 +0,0 @@
-_namespace = $namespace;
- $this->_member = $member;
- $this->_session = new Zend_Session_Namespace($this->_namespace);
- }
-
- /**
- * Returns the session namespace
- *
- * @return string
- */
- public function getNamespace()
- {
- return $this->_namespace;
- }
-
- /**
- * Returns the name of the session object member
- *
- * @return string
- */
- public function getMember()
- {
- return $this->_member;
- }
-
- /**
- * Defined by Zend_Auth_Storage_Interface
- *
- * @return boolean
- */
- public function isEmpty()
- {
- return !isset($this->_session->{$this->_member});
- }
-
- /**
- * Defined by Zend_Auth_Storage_Interface
- *
- * @return mixed
- */
- public function read()
- {
- return $this->_session->{$this->_member};
- }
-
- /**
- * Defined by Zend_Auth_Storage_Interface
- *
- * @param mixed $contents
- * @return void
- */
- public function write($contents)
- {
- $this->_session->{$this->_member} = $contents;
- }
-
- /**
- * Defined by Zend_Auth_Storage_Interface
- *
- * @return void
- */
- public function clear()
- {
- unset($this->_session->{$this->_member});
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Adapter/AbstractAdapter.php zendframework-2.2.6/library/Zend/Authentication/Adapter/AbstractAdapter.php
--- zendframework-1.10.4/library/Zend/Authentication/Adapter/AbstractAdapter.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Adapter/AbstractAdapter.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,72 @@
+credential;
+ }
+
+ /**
+ * Sets the credential for binding
+ *
+ * @param mixed $credential
+ * @return AbstractAdapter
+ */
+ public function setCredential($credential)
+ {
+ $this->credential = $credential;
+
+ return $this;
+ }
+
+ /**
+ * Returns the identity of the account being authenticated, or
+ * NULL if none is set.
+ *
+ * @return mixed
+ */
+ public function getIdentity()
+ {
+ return $this->identity;
+ }
+
+ /**
+ * Sets the identity for binding
+ *
+ * @param mixed $identity
+ * @return AbstractAdapter
+ */
+ public function setIdentity($identity)
+ {
+ $this->identity = $identity;
+
+ return $this;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Adapter/AdapterInterface.php zendframework-2.2.6/library/Zend/Authentication/Adapter/AdapterInterface.php
--- zendframework-1.10.4/library/Zend/Authentication/Adapter/AdapterInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Adapter/AdapterInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,21 @@
+zendDb = $zendDb;
+
+ if (null !== $tableName) {
+ $this->setTableName($tableName);
+ }
+
+ if (null !== $identityColumn) {
+ $this->setIdentityColumn($identityColumn);
+ }
+
+ if (null !== $credentialColumn) {
+ $this->setCredentialColumn($credentialColumn);
+ }
+ }
+
+ /**
+ * setTableName() - set the table name to be used in the select query
+ *
+ * @param string $tableName
+ * @return DbTable Provides a fluent interface
+ */
+ public function setTableName($tableName)
+ {
+ $this->tableName = $tableName;
+ return $this;
+ }
+
+ /**
+ * setIdentityColumn() - set the column name to be used as the identity column
+ *
+ * @param string $identityColumn
+ * @return DbTable Provides a fluent interface
+ */
+ public function setIdentityColumn($identityColumn)
+ {
+ $this->identityColumn = $identityColumn;
+ return $this;
+ }
+
+ /**
+ * setCredentialColumn() - set the column name to be used as the credential column
+ *
+ * @param string $credentialColumn
+ * @return DbTable Provides a fluent interface
+ */
+ public function setCredentialColumn($credentialColumn)
+ {
+ $this->credentialColumn = $credentialColumn;
+ return $this;
+ }
+
+ /**
+ * setAmbiguityIdentity() - sets a flag for usage of identical identities
+ * with unique credentials. It accepts integers (0, 1) or boolean (true,
+ * false) parameters. Default is false.
+ *
+ * @param int|bool $flag
+ * @return DbTable Provides a fluent interface
+ */
+ public function setAmbiguityIdentity($flag)
+ {
+ if (is_int($flag)) {
+ $this->ambiguityIdentity = (1 === $flag ? true : false);
+ } elseif (is_bool($flag)) {
+ $this->ambiguityIdentity = $flag;
+ }
+ return $this;
+ }
+
+ /**
+ * getAmbiguityIdentity() - returns TRUE for usage of multiple identical
+ * identities with different credentials, FALSE if not used.
+ *
+ * @return bool
+ */
+ public function getAmbiguityIdentity()
+ {
+ return $this->ambiguityIdentity;
+ }
+
+ /**
+ * getDbSelect() - Return the preauthentication Db Select object for userland select query modification
+ *
+ * @return Sql\Select
+ */
+ public function getDbSelect()
+ {
+ if ($this->dbSelect == null) {
+ $this->dbSelect = new Sql\Select();
+ }
+ return $this->dbSelect;
+ }
+
+ /**
+ * getResultRowObject() - Returns the result row as a stdClass object
+ *
+ * @param string|array $returnColumns
+ * @param string|array $omitColumns
+ * @return stdClass|bool
+ */
+ public function getResultRowObject($returnColumns = null, $omitColumns = null)
+ {
+ if (!$this->resultRow) {
+ return false;
+ }
+
+ $returnObject = new stdClass();
+
+ if (null !== $returnColumns) {
+
+ $availableColumns = array_keys($this->resultRow);
+ foreach ((array) $returnColumns as $returnColumn) {
+ if (in_array($returnColumn, $availableColumns)) {
+ $returnObject->{$returnColumn} = $this->resultRow[$returnColumn];
+ }
+ }
+ return $returnObject;
+
+ } elseif (null !== $omitColumns) {
+
+ $omitColumns = (array) $omitColumns;
+ foreach ($this->resultRow as $resultColumn => $resultValue) {
+ if (!in_array($resultColumn, $omitColumns)) {
+ $returnObject->{$resultColumn} = $resultValue;
+ }
+ }
+ return $returnObject;
+
+ }
+
+ foreach ($this->resultRow as $resultColumn => $resultValue) {
+ $returnObject->{$resultColumn} = $resultValue;
+ }
+ return $returnObject;
+ }
+
+ /**
+ * This method is called to attempt an authentication. Previous to this
+ * call, this adapter would have already been configured with all
+ * necessary information to successfully connect to a database table and
+ * attempt to find a record matching the provided identity.
+ *
+ * @throws Exception\RuntimeException if answering the authentication query is impossible
+ * @return AuthenticationResult
+ */
+ public function authenticate()
+ {
+ $this->authenticateSetup();
+ $dbSelect = $this->authenticateCreateSelect();
+ $resultIdentities = $this->authenticateQuerySelect($dbSelect);
+
+ if (($authResult = $this->authenticateValidateResultSet($resultIdentities)) instanceof AuthenticationResult) {
+ return $authResult;
+ }
+
+ // At this point, ambiguity is already done. Loop, check and break on success.
+ foreach ($resultIdentities as $identity) {
+ $authResult = $this->authenticateValidateResult($identity);
+ if ($authResult->isValid()) {
+ break;
+ }
+ }
+
+ return $authResult;
+ }
+
+ /**
+ * _authenticateValidateResult() - This method attempts to validate that
+ * the record in the resultset is indeed a record that matched the
+ * identity provided to this adapter.
+ *
+ * @param array $resultIdentity
+ * @return AuthenticationResult
+ */
+ abstract protected function authenticateValidateResult($resultIdentity);
+
+ /**
+ * _authenticateCreateSelect() - This method creates a Zend\Db\Sql\Select object that
+ * is completely configured to be queried against the database.
+ *
+ * @return Sql\Select
+ */
+ abstract protected function authenticateCreateSelect();
+
+ /**
+ * _authenticateSetup() - This method abstracts the steps involved with
+ * making sure that this adapter was indeed setup properly with all
+ * required pieces of information.
+ *
+ * @throws Exception\RuntimeException in the event that setup was not done properly
+ * @return bool
+ */
+ protected function authenticateSetup()
+ {
+ $exception = null;
+
+ if ($this->tableName == '') {
+ $exception = 'A table must be supplied for the DbTable authentication adapter.';
+ } elseif ($this->identityColumn == '') {
+ $exception = 'An identity column must be supplied for the DbTable authentication adapter.';
+ } elseif ($this->credentialColumn == '') {
+ $exception = 'A credential column must be supplied for the DbTable authentication adapter.';
+ } elseif ($this->identity == '') {
+ $exception = 'A value for the identity was not provided prior to authentication with DbTable.';
+ } elseif ($this->credential === null) {
+ $exception = 'A credential value was not provided prior to authentication with DbTable.';
+ }
+
+ if (null !== $exception) {
+ throw new Exception\RuntimeException($exception);
+ }
+
+ $this->authenticateResultInfo = array(
+ 'code' => AuthenticationResult::FAILURE,
+ 'identity' => $this->identity,
+ 'messages' => array()
+ );
+
+ return true;
+ }
+
+ /**
+ * _authenticateQuerySelect() - This method accepts a Zend\Db\Sql\Select object and
+ * performs a query against the database with that object.
+ *
+ * @param Sql\Select $dbSelect
+ * @throws Exception\RuntimeException when an invalid select object is encountered
+ * @return array
+ */
+ protected function authenticateQuerySelect(Sql\Select $dbSelect)
+ {
+ $sql = new Sql\Sql($this->zendDb);
+ $statement = $sql->prepareStatementForSqlObject($dbSelect);
+ try {
+ $result = $statement->execute();
+ $resultIdentities = array();
+ // iterate result, most cross platform way
+ foreach ($result as $row) {
+ $resultIdentities[] = $row;
+ }
+ } catch (\Exception $e) {
+ throw new Exception\RuntimeException(
+ 'The supplied parameters to DbTable failed to '
+ . 'produce a valid sql statement, please check table and column names '
+ . 'for validity.', 0, $e
+ );
+ }
+ return $resultIdentities;
+ }
+
+ /**
+ * _authenticateValidateResultSet() - This method attempts to make
+ * certain that only one record was returned in the resultset
+ *
+ * @param array $resultIdentities
+ * @return bool|\Zend\Authentication\Result
+ */
+ protected function authenticateValidateResultSet(array $resultIdentities)
+ {
+
+ if (count($resultIdentities) < 1) {
+ $this->authenticateResultInfo['code'] = AuthenticationResult::FAILURE_IDENTITY_NOT_FOUND;
+ $this->authenticateResultInfo['messages'][] = 'A record with the supplied identity could not be found.';
+ return $this->authenticateCreateAuthResult();
+ } elseif (count($resultIdentities) > 1 && false === $this->getAmbiguityIdentity()) {
+ $this->authenticateResultInfo['code'] = AuthenticationResult::FAILURE_IDENTITY_AMBIGUOUS;
+ $this->authenticateResultInfo['messages'][] = 'More than one record matches the supplied identity.';
+ return $this->authenticateCreateAuthResult();
+ }
+
+ return true;
+ }
+
+ /**
+ * Creates a Zend\Authentication\Result object from the information that
+ * has been collected during the authenticate() attempt.
+ *
+ * @return AuthenticationResult
+ */
+ protected function authenticateCreateAuthResult()
+ {
+ return new AuthenticationResult(
+ $this->authenticateResultInfo['code'],
+ $this->authenticateResultInfo['identity'],
+ $this->authenticateResultInfo['messages']
+ );
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Adapter/DbTable/CallbackCheckAdapter.php zendframework-2.2.6/library/Zend/Authentication/Adapter/DbTable/CallbackCheckAdapter.php
--- zendframework-1.10.4/library/Zend/Authentication/Adapter/DbTable/CallbackCheckAdapter.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Adapter/DbTable/CallbackCheckAdapter.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,117 @@
+setCredentialValidationCallback($credentialValidationCallback);
+ } else {
+ $this->setCredentialValidationCallback(function ($a, $b) {
+ return $a === $b;
+ });
+ }
+ }
+
+ /**
+ * setCredentialValidationCallback() - allows the developer to use a callback as a way of checking the
+ * credential.
+ *
+ * @param callable $validationCallback
+ * @return DbTable
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setCredentialValidationCallback($validationCallback)
+ {
+ if (!is_callable($validationCallback)) {
+ throw new Exception\InvalidArgumentException('Invalid callback provided');
+ }
+ $this->credentialValidationCallback = $validationCallback;
+ return $this;
+ }
+
+ /**
+ * _authenticateCreateSelect() - This method creates a Zend\Db\Sql\Select object that
+ * is completely configured to be queried against the database.
+ *
+ * @return Sql\Select
+ */
+ protected function authenticateCreateSelect()
+ {
+ // get select
+ $dbSelect = clone $this->getDbSelect();
+ $dbSelect->from($this->tableName)
+ ->columns(array(Sql\Select::SQL_STAR))
+ ->where(new SqlOp($this->identityColumn, '=', $this->identity));
+
+ return $dbSelect;
+ }
+
+ /**
+ * _authenticateValidateResult() - This method attempts to validate that
+ * the record in the resultset is indeed a record that matched the
+ * identity provided to this adapter.
+ *
+ * @param array $resultIdentity
+ * @return AuthenticationResult
+ */
+ protected function authenticateValidateResult($resultIdentity)
+ {
+ try {
+ $callbackResult = call_user_func($this->credentialValidationCallback, $resultIdentity[$this->credentialColumn], $this->credential);
+ } catch (\Exception $e) {
+ $this->authenticateResultInfo['code'] = AuthenticationResult::FAILURE_UNCATEGORIZED;
+ $this->authenticateResultInfo['messages'][] = $e->getMessage();
+ return $this->authenticateCreateAuthResult();
+ }
+ if ($callbackResult !== true) {
+ $this->authenticateResultInfo['code'] = AuthenticationResult::FAILURE_CREDENTIAL_INVALID;
+ $this->authenticateResultInfo['messages'][] = 'Supplied credential is invalid.';
+ return $this->authenticateCreateAuthResult();
+ }
+
+ $this->resultRow = $resultIdentity;
+
+ $this->authenticateResultInfo['code'] = AuthenticationResult::SUCCESS;
+ $this->authenticateResultInfo['messages'][] = 'Authentication successful.';
+ return $this->authenticateCreateAuthResult();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Adapter/DbTable/CredentialTreatmentAdapter.php zendframework-2.2.6/library/Zend/Authentication/Adapter/DbTable/CredentialTreatmentAdapter.php
--- zendframework-1.10.4/library/Zend/Authentication/Adapter/DbTable/CredentialTreatmentAdapter.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Adapter/DbTable/CredentialTreatmentAdapter.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,124 @@
+setCredentialTreatment($credentialTreatment);
+ }
+ }
+
+ /**
+ * setCredentialTreatment() - allows the developer to pass a parametrized string that is
+ * used to transform or treat the input credential data.
+ *
+ * In many cases, passwords and other sensitive data are encrypted, hashed, encoded,
+ * obscured, or otherwise treated through some function or algorithm. By specifying a
+ * parametrized treatment string with this method, a developer may apply arbitrary SQL
+ * upon input credential data.
+ *
+ * Examples:
+ *
+ * 'PASSWORD(?)'
+ * 'MD5(?)'
+ *
+ * @param string $treatment
+ * @return DbTable Provides a fluent interface
+ */
+ public function setCredentialTreatment($treatment)
+ {
+ $this->credentialTreatment = $treatment;
+ return $this;
+ }
+
+ /**
+ * _authenticateCreateSelect() - This method creates a Zend\Db\Sql\Select object that
+ * is completely configured to be queried against the database.
+ *
+ * @return Sql\Select
+ */
+ protected function authenticateCreateSelect()
+ {
+ // build credential expression
+ if (empty($this->credentialTreatment) || (strpos($this->credentialTreatment, '?') === false)) {
+ $this->credentialTreatment = '?';
+ }
+
+ $credentialExpression = new SqlExpr(
+ '(CASE WHEN ?' . ' = ' . $this->credentialTreatment . ' THEN 1 ELSE 0 END) AS ?',
+ array($this->credentialColumn, $this->credential, 'zend_auth_credential_match'),
+ array(SqlExpr::TYPE_IDENTIFIER, SqlExpr::TYPE_VALUE, SqlExpr::TYPE_IDENTIFIER)
+ );
+
+ // get select
+ $dbSelect = clone $this->getDbSelect();
+ $dbSelect->from($this->tableName)
+ ->columns(array('*', $credentialExpression))
+ ->where(new SqlOp($this->identityColumn, '=', $this->identity));
+
+ return $dbSelect;
+ }
+
+ /**
+ * _authenticateValidateResult() - This method attempts to validate that
+ * the record in the resultset is indeed a record that matched the
+ * identity provided to this adapter.
+ *
+ * @param array $resultIdentity
+ * @return AuthenticationResult
+ */
+ protected function authenticateValidateResult($resultIdentity)
+ {
+ if ($resultIdentity['zend_auth_credential_match'] != '1') {
+ $this->authenticateResultInfo['code'] = AuthenticationResult::FAILURE_CREDENTIAL_INVALID;
+ $this->authenticateResultInfo['messages'][] = 'Supplied credential is invalid.';
+ return $this->authenticateCreateAuthResult();
+ }
+
+ unset($resultIdentity['zend_auth_credential_match']);
+ $this->resultRow = $resultIdentity;
+
+ $this->authenticateResultInfo['code'] = AuthenticationResult::SUCCESS;
+ $this->authenticateResultInfo['messages'][] = 'Authentication successful.';
+ return $this->authenticateCreateAuthResult();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Adapter/DbTable/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Authentication/Adapter/DbTable/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Authentication/Adapter/DbTable/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Adapter/DbTable/Exception/ExceptionInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,15 @@
+setFilename($filename);
+ }
+ if ($realm !== null) {
+ $this->setRealm($realm);
+ }
+ if ($identity !== null) {
+ $this->setIdentity($identity);
+ }
+ if ($credential !== null) {
+ $this->setCredential($credential);
+ }
+ }
+
+ /**
+ * Returns the filename option value or null if it has not yet been set
+ *
+ * @return string|null
+ */
+ public function getFilename()
+ {
+ return $this->filename;
+ }
+
+ /**
+ * Sets the filename option value
+ *
+ * @param mixed $filename
+ * @return Digest Provides a fluent interface
+ */
+ public function setFilename($filename)
+ {
+ $this->filename = (string) $filename;
+ return $this;
+ }
+
+ /**
+ * Returns the realm option value or null if it has not yet been set
+ *
+ * @return string|null
+ */
+ public function getRealm()
+ {
+ return $this->realm;
+ }
+
+ /**
+ * Sets the realm option value
+ *
+ * @param mixed $realm
+ * @return Digest Provides a fluent interface
+ */
+ public function setRealm($realm)
+ {
+ $this->realm = (string) $realm;
+ return $this;
+ }
+
+ /**
+ * Returns the username option value or null if it has not yet been set
+ *
+ * @return string|null
+ */
+ public function getUsername()
+ {
+ return $this->getIdentity();
+ }
+
+ /**
+ * Sets the username option value
+ *
+ * @param mixed $username
+ * @return Digest Provides a fluent interface
+ */
+ public function setUsername($username)
+ {
+ return $this->setIdentity($username);
+ }
+
+ /**
+ * Returns the password option value or null if it has not yet been set
+ *
+ * @return string|null
+ */
+ public function getPassword()
+ {
+ return $this->getCredential();
+ }
+
+ /**
+ * Sets the password option value
+ *
+ * @param mixed $password
+ * @return Digest Provides a fluent interface
+ */
+ public function setPassword($password)
+ {
+ return $this->setCredential($password);
+ }
+
+ /**
+ * Defined by Zend\Authentication\Adapter\AdapterInterface
+ *
+ * @throws Exception\ExceptionInterface
+ * @return AuthenticationResult
+ */
+ public function authenticate()
+ {
+ $optionsRequired = array('filename', 'realm', 'identity', 'credential');
+ foreach ($optionsRequired as $optionRequired) {
+ if (null === $this->$optionRequired) {
+ throw new Exception\RuntimeException("Option '$optionRequired' must be set before authentication");
+ }
+ }
+
+ ErrorHandler::start(E_WARNING);
+ $fileHandle = fopen($this->filename, 'r');
+ $error = ErrorHandler::stop();
+ if (false === $fileHandle) {
+ throw new Exception\UnexpectedValueException("Cannot open '$this->filename' for reading", 0, $error);
+ }
+
+ $id = "$this->identity:$this->realm";
+ $idLength = strlen($id);
+
+ $result = array(
+ 'code' => AuthenticationResult::FAILURE,
+ 'identity' => array(
+ 'realm' => $this->realm,
+ 'username' => $this->identity,
+ ),
+ 'messages' => array()
+ );
+
+ while (($line = fgets($fileHandle)) !== false) {
+ $line = trim($line);
+ if (empty($line)) {
+ break;
+ }
+ if (substr($line, 0, $idLength) === $id) {
+ if (CryptUtils::compareStrings(substr($line, -32), md5("$this->identity:$this->realm:$this->credential"))) {
+ $result['code'] = AuthenticationResult::SUCCESS;
+ } else {
+ $result['code'] = AuthenticationResult::FAILURE_CREDENTIAL_INVALID;
+ $result['messages'][] = 'Password incorrect';
+ }
+ return new AuthenticationResult($result['code'], $result['identity'], $result['messages']);
+ }
+ }
+
+ $result['code'] = AuthenticationResult::FAILURE_IDENTITY_NOT_FOUND;
+ $result['messages'][] = "Username '$this->identity' and realm '$this->realm' combination not found";
+ return new AuthenticationResult($result['code'], $result['identity'], $result['messages']);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Adapter/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Authentication/Adapter/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Authentication/Adapter/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Adapter/Exception/ExceptionInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,15 @@
+setFile($path);
+ }
+ }
+
+ /**
+ * Set the path to the credentials file
+ *
+ * @param string $path
+ * @return FileResolver Provides a fluent interface
+ * @throws Exception\InvalidArgumentException if path is not readable
+ */
+ public function setFile($path)
+ {
+ if (empty($path) || !is_readable($path)) {
+ throw new Exception\InvalidArgumentException('Path not readable: ' . $path);
+ }
+ $this->file = $path;
+
+ return $this;
+ }
+
+ /**
+ * Returns the path to the credentials file
+ *
+ * @return string
+ */
+ public function getFile()
+ {
+ return $this->file;
+ }
+
+ /**
+ * Returns the Apache Password object
+ *
+ * @return ApachePassword
+ */
+ protected function getApachePassword()
+ {
+ if (empty($this->apachePassword)) {
+ $this->apachePassword = new ApachePassword();
+ }
+ return $this->apachePassword;
+ }
+
+ /**
+ * Resolve credentials
+ *
+ *
+ *
+ * @param string $username Username
+ * @param string $realm Authentication Realm
+ * @param string $password The password to authenticate
+ * @return AuthResult
+ * @throws Exception\ExceptionInterface
+ */
+ public function resolve($username, $realm, $password = null)
+ {
+ if (empty($username)) {
+ throw new Exception\InvalidArgumentException('Username is required');
+ }
+
+ if (!ctype_print($username) || strpos($username, ':') !== false) {
+ throw new Exception\InvalidArgumentException(
+ 'Username must consist only of printable characters, excluding the colon'
+ );
+ }
+
+ if (!empty($realm) && (!ctype_print($realm) || strpos($realm, ':') !== false)) {
+ throw new Exception\InvalidArgumentException(
+ 'Realm must consist only of printable characters, excluding the colon'
+ );
+ }
+
+ if (empty($password)) {
+ throw new Exception\InvalidArgumentException('Password is required');
+ }
+
+ // Open file, read through looking for matching credentials
+ ErrorHandler::start(E_WARNING);
+ $fp = fopen($this->file, 'r');
+ $error = ErrorHandler::stop();
+ if (!$fp) {
+ throw new Exception\RuntimeException('Unable to open password file: ' . $this->file, 0, $error);
+ }
+
+ // No real validation is done on the contents of the password file. The
+ // assumption is that we trust the administrators to keep it secure.
+ while (($line = fgetcsv($fp, 512, ':')) !== false) {
+ if ($line[0] != $username) {
+ continue;
+ }
+
+ if (isset($line[2])) {
+ if ($line[1] == $realm) {
+ $matchedHash = $line[2];
+ break;
+ }
+ continue;
+ }
+
+ $matchedHash = $line[1];
+ break;
+ }
+ fclose($fp);
+
+ if (!isset($matchedHash)) {
+ return new AuthResult(AuthResult::FAILURE_IDENTITY_NOT_FOUND, null, array('Username not found in provided htpasswd file'));
+ }
+
+ // Plaintext password
+ if ($matchedHash === $password) {
+ return new AuthResult(AuthResult::SUCCESS, $username);
+ }
+
+ $apache = $this->getApachePassword();
+ $apache->setUserName($username);
+ if (!empty($realm)) {
+ $apache->setAuthName($realm);
+ }
+
+ if ($apache->verify($password, $matchedHash)) {
+ return new AuthResult(AuthResult::SUCCESS, $username);
+ }
+
+ return new AuthResult(AuthResult::FAILURE_CREDENTIAL_INVALID, null, array('Passwords did not match.'));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Adapter/Http/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Authentication/Adapter/Http/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Authentication/Adapter/Http/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Adapter/Http/Exception/ExceptionInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,18 @@
+setFile($path);
+ }
+ }
+
+ /**
+ * Set the path to the credentials file
+ *
+ * @param string $path
+ * @return FileResolver Provides a fluent interface
+ * @throws Exception\InvalidArgumentException if path is not readable
+ */
+ public function setFile($path)
+ {
+ if (empty($path) || !is_readable($path)) {
+ throw new Exception\InvalidArgumentException('Path not readable: ' . $path);
+ }
+ $this->file = $path;
+
+ return $this;
+ }
+
+ /**
+ * Returns the path to the credentials file
+ *
+ * @return string
+ */
+ public function getFile()
+ {
+ return $this->file;
+ }
+
+ /**
+ * Resolve credentials
+ *
+ * Only the first matching username/realm combination in the file is
+ * returned. If the file contains credentials for Digest authentication,
+ * the returned string is the password hash, or h(a1) from RFC 2617. The
+ * returned string is the plain-text password for Basic authentication.
+ *
+ * The expected format of the file is:
+ * username:realm:sharedSecret
+ *
+ * That is, each line consists of the user's username, the applicable
+ * authentication realm, and the password or hash, each delimited by
+ * colons.
+ *
+ * @param string $username Username
+ * @param string $realm Authentication Realm
+ * @return string|false User's shared secret, if the user is found in the
+ * realm, false otherwise.
+ * @throws Exception\ExceptionInterface
+ */
+ public function resolve($username, $realm, $password = null)
+ {
+ if (empty($username)) {
+ throw new Exception\InvalidArgumentException('Username is required');
+ } elseif (!ctype_print($username) || strpos($username, ':') !== false) {
+ throw new Exception\InvalidArgumentException('Username must consist only of printable characters, '
+ . 'excluding the colon');
+ }
+ if (empty($realm)) {
+ throw new Exception\InvalidArgumentException('Realm is required');
+ } elseif (!ctype_print($realm) || strpos($realm, ':') !== false) {
+ throw new Exception\InvalidArgumentException('Realm must consist only of printable characters, '
+ . 'excluding the colon.');
+ }
+
+ // Open file, read through looking for matching credentials
+ ErrorHandler::start(E_WARNING);
+ $fp = fopen($this->file, 'r');
+ $error = ErrorHandler::stop();
+ if (!$fp) {
+ throw new Exception\RuntimeException('Unable to open password file: ' . $this->file, 0, $error);
+ }
+
+ // No real validation is done on the contents of the password file. The
+ // assumption is that we trust the administrators to keep it secure.
+ while (($line = fgetcsv($fp, 512, ':')) !== false) {
+ if ($line[0] == $username && $line[1] == $realm) {
+ $password = $line[2];
+ fclose($fp);
+ return $password;
+ }
+ }
+
+ fclose($fp);
+ return false;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Adapter/Http/ResolverInterface.php zendframework-2.2.6/library/Zend/Authentication/Adapter/Http/ResolverInterface.php
--- zendframework-1.10.4/library/Zend/Authentication/Adapter/Http/ResolverInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Adapter/Http/ResolverInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,30 @@
+ 'basic'|'digest'|'basic digest'
+ * 'realm' =>
+ * 'digest_domains' => Space-delimited list of URIs
+ * 'nonce_timeout' =>
+ * 'use_opaque' => Whether to send the opaque value in the header
+ * 'algorithm' => See $supportedAlgos. Default: MD5
+ * 'proxy_auth' => Whether to do authentication as a Proxy
+ * @throws Exception\InvalidArgumentException
+ */
+ public function __construct(array $config)
+ {
+ $this->request = null;
+ $this->response = null;
+ $this->ieNoOpaque = false;
+
+ if (empty($config['accept_schemes'])) {
+ throw new Exception\InvalidArgumentException('Config key "accept_schemes" is required');
+ }
+
+ $schemes = explode(' ', $config['accept_schemes']);
+ $this->acceptSchemes = array_intersect($schemes, $this->supportedSchemes);
+ if (empty($this->acceptSchemes)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'No supported schemes given in "accept_schemes". Valid values: %s',
+ implode(', ', $this->supportedSchemes)
+ ));
+ }
+
+ // Double-quotes are used to delimit the realm string in the HTTP header,
+ // and colons are field delimiters in the password file.
+ if (empty($config['realm']) ||
+ !ctype_print($config['realm']) ||
+ strpos($config['realm'], ':') !== false ||
+ strpos($config['realm'], '"') !== false) {
+ throw new Exception\InvalidArgumentException(
+ 'Config key \'realm\' is required, and must contain only printable characters,'
+ . 'excluding quotation marks and colons'
+ );
+ } else {
+ $this->realm = $config['realm'];
+ }
+
+ if (in_array('digest', $this->acceptSchemes)) {
+ if (empty($config['digest_domains']) ||
+ !ctype_print($config['digest_domains']) ||
+ strpos($config['digest_domains'], '"') !== false) {
+ throw new Exception\InvalidArgumentException(
+ 'Config key \'digest_domains\' is required, and must contain '
+ . 'only printable characters, excluding quotation marks'
+ );
+ } else {
+ $this->domains = $config['digest_domains'];
+ }
+
+ if (empty($config['nonce_timeout']) ||
+ !is_numeric($config['nonce_timeout'])) {
+ throw new Exception\InvalidArgumentException(
+ 'Config key \'nonce_timeout\' is required, and must be an integer'
+ );
+ } else {
+ $this->nonceTimeout = (int) $config['nonce_timeout'];
+ }
+
+ // We use the opaque value unless explicitly told not to
+ if (isset($config['use_opaque']) && false == (bool) $config['use_opaque']) {
+ $this->useOpaque = false;
+ } else {
+ $this->useOpaque = true;
+ }
+
+ if (isset($config['algorithm']) && in_array($config['algorithm'], $this->supportedAlgos)) {
+ $this->algo = $config['algorithm'];
+ } else {
+ $this->algo = 'MD5';
+ }
+ }
+
+ // Don't be a proxy unless explicitly told to do so
+ if (isset($config['proxy_auth']) && true == (bool) $config['proxy_auth']) {
+ $this->imaProxy = true; // I'm a Proxy
+ } else {
+ $this->imaProxy = false;
+ }
+ }
+
+ /**
+ * Setter for the basicResolver property
+ *
+ * @param Http\ResolverInterface $resolver
+ * @return Http Provides a fluent interface
+ */
+ public function setBasicResolver(Http\ResolverInterface $resolver)
+ {
+ $this->basicResolver = $resolver;
+
+ return $this;
+ }
+
+ /**
+ * Getter for the basicResolver property
+ *
+ * @return Http\ResolverInterface
+ */
+ public function getBasicResolver()
+ {
+ return $this->basicResolver;
+ }
+
+ /**
+ * Setter for the digestResolver property
+ *
+ * @param Http\ResolverInterface $resolver
+ * @return Http Provides a fluent interface
+ */
+ public function setDigestResolver(Http\ResolverInterface $resolver)
+ {
+ $this->digestResolver = $resolver;
+
+ return $this;
+ }
+
+ /**
+ * Getter for the digestResolver property
+ *
+ * @return Http\ResolverInterface
+ */
+ public function getDigestResolver()
+ {
+ return $this->digestResolver;
+ }
+
+ /**
+ * Setter for the Request object
+ *
+ * @param HTTPRequest $request
+ * @return Http Provides a fluent interface
+ */
+ public function setRequest(HTTPRequest $request)
+ {
+ $this->request = $request;
+
+ return $this;
+ }
+
+ /**
+ * Getter for the Request object
+ *
+ * @return HTTPRequest
+ */
+ public function getRequest()
+ {
+ return $this->request;
+ }
+
+ /**
+ * Setter for the Response object
+ *
+ * @param HTTPResponse $response
+ * @return Http Provides a fluent interface
+ */
+ public function setResponse(HTTPResponse $response)
+ {
+ $this->response = $response;
+
+ return $this;
+ }
+
+ /**
+ * Getter for the Response object
+ *
+ * @return HTTPResponse
+ */
+ public function getResponse()
+ {
+ return $this->response;
+ }
+
+ /**
+ * Authenticate
+ *
+ * @throws Exception\RuntimeException
+ * @return Authentication\Result
+ */
+ public function authenticate()
+ {
+ if (empty($this->request) || empty($this->response)) {
+ throw new Exception\RuntimeException('Request and Response objects must be set before calling '
+ . 'authenticate()');
+ }
+
+ if ($this->imaProxy) {
+ $getHeader = 'Proxy-Authorization';
+ } else {
+ $getHeader = 'Authorization';
+ }
+
+ $headers = $this->request->getHeaders();
+ if (!$headers->has($getHeader)) {
+ return $this->_challengeClient();
+ }
+ $authHeader = $headers->get($getHeader)->getFieldValue();
+ if (!$authHeader) {
+ return $this->_challengeClient();
+ }
+
+ list($clientScheme) = explode(' ', $authHeader);
+ $clientScheme = strtolower($clientScheme);
+
+ // The server can issue multiple challenges, but the client should
+ // answer with only the selected auth scheme.
+ if (!in_array($clientScheme, $this->supportedSchemes)) {
+ $this->response->setStatusCode(400);
+ return new Authentication\Result(
+ Authentication\Result::FAILURE_UNCATEGORIZED,
+ array(),
+ array('Client requested an incorrect or unsupported authentication scheme')
+ );
+ }
+
+ // client sent a scheme that is not the one required
+ if (!in_array($clientScheme, $this->acceptSchemes)) {
+ // challenge again the client
+ return $this->_challengeClient();
+ }
+
+ switch ($clientScheme) {
+ case 'basic':
+ $result = $this->_basicAuth($authHeader);
+ break;
+ case 'digest':
+ $result = $this->_digestAuth($authHeader);
+ break;
+ default:
+ throw new Exception\RuntimeException('Unsupported authentication scheme: ' . $clientScheme);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Challenge Client
+ *
+ * Sets a 401 or 407 Unauthorized response code, and creates the
+ * appropriate Authenticate header(s) to prompt for credentials.
+ *
+ * @return Authentication\Result Always returns a non-identity Auth result
+ */
+ protected function _challengeClient()
+ {
+ if ($this->imaProxy) {
+ $statusCode = 407;
+ $headerName = 'Proxy-Authenticate';
+ } else {
+ $statusCode = 401;
+ $headerName = 'WWW-Authenticate';
+ }
+
+ $this->response->setStatusCode($statusCode);
+
+ // Send a challenge in each acceptable authentication scheme
+ $headers = $this->response->getHeaders();
+ if (in_array('basic', $this->acceptSchemes)) {
+ $headers->addHeaderLine($headerName, $this->_basicHeader());
+ }
+ if (in_array('digest', $this->acceptSchemes)) {
+ $headers->addHeaderLine($headerName, $this->_digestHeader());
+ }
+ return new Authentication\Result(
+ Authentication\Result::FAILURE_CREDENTIAL_INVALID,
+ array(),
+ array('Invalid or absent credentials; challenging client')
+ );
+ }
+
+ /**
+ * Basic Header
+ *
+ * Generates a Proxy- or WWW-Authenticate header value in the Basic
+ * authentication scheme.
+ *
+ * @return string Authenticate header value
+ */
+ protected function _basicHeader()
+ {
+ return 'Basic realm="' . $this->realm . '"';
+ }
+
+ /**
+ * Digest Header
+ *
+ * Generates a Proxy- or WWW-Authenticate header value in the Digest
+ * authentication scheme.
+ *
+ * @return string Authenticate header value
+ */
+ protected function _digestHeader()
+ {
+ $wwwauth = 'Digest realm="' . $this->realm . '", '
+ . 'domain="' . $this->domains . '", '
+ . 'nonce="' . $this->_calcNonce() . '", '
+ . ($this->useOpaque ? 'opaque="' . $this->_calcOpaque() . '", ' : '')
+ . 'algorithm="' . $this->algo . '", '
+ . 'qop="' . implode(',', $this->supportedQops) . '"';
+
+ return $wwwauth;
+ }
+
+ /**
+ * Basic Authentication
+ *
+ * @param string $header Client's Authorization header
+ * @throws Exception\ExceptionInterface
+ * @return Authentication\Result
+ */
+ protected function _basicAuth($header)
+ {
+ if (empty($header)) {
+ throw new Exception\RuntimeException('The value of the client Authorization header is required');
+ }
+ if (empty($this->basicResolver)) {
+ throw new Exception\RuntimeException(
+ 'A basicResolver object must be set before doing Basic '
+ . 'authentication');
+ }
+
+ // Decode the Authorization header
+ $auth = substr($header, strlen('Basic '));
+ $auth = base64_decode($auth);
+ if (!$auth) {
+ throw new Exception\RuntimeException('Unable to base64_decode Authorization header value');
+ }
+
+ // See ZF-1253. Validate the credentials the same way the digest
+ // implementation does. If invalid credentials are detected,
+ // re-challenge the client.
+ if (!ctype_print($auth)) {
+ return $this->_challengeClient();
+ }
+ // Fix for ZF-1515: Now re-challenges on empty username or password
+ $creds = array_filter(explode(':', $auth));
+ if (count($creds) != 2) {
+ return $this->_challengeClient();
+ }
+
+ $result = $this->basicResolver->resolve($creds[0], $this->realm, $creds[1]);
+
+ if ($result instanceof Authentication\Result && $result->isValid()) {
+ return $result;
+ }
+
+ if (!$result instanceof Authentication\Result
+ && !is_array($result)
+ && CryptUtils::compareStrings($result, $creds[1])
+ ) {
+ $identity = array('username' => $creds[0], 'realm' => $this->realm);
+ return new Authentication\Result(Authentication\Result::SUCCESS, $identity);
+ } elseif (is_array($result)) {
+ return new Authentication\Result(Authentication\Result::SUCCESS, $result);
+ }
+
+ return $this->_challengeClient();
+ }
+
+ /**
+ * Digest Authentication
+ *
+ * @param string $header Client's Authorization header
+ * @throws Exception\ExceptionInterface
+ * @return Authentication\Result Valid auth result only on successful auth
+ */
+ protected function _digestAuth($header)
+ {
+ if (empty($header)) {
+ throw new Exception\RuntimeException('The value of the client Authorization header is required');
+ }
+ if (empty($this->digestResolver)) {
+ throw new Exception\RuntimeException('A digestResolver object must be set before doing Digest authentication');
+ }
+
+ $data = $this->_parseDigestAuth($header);
+ if ($data === false) {
+ $this->response->setStatusCode(400);
+ return new Authentication\Result(
+ Authentication\Result::FAILURE_UNCATEGORIZED,
+ array(),
+ array('Invalid Authorization header format')
+ );
+ }
+
+ // See ZF-1052. This code was a bit too unforgiving of invalid
+ // usernames. Now, if the username is bad, we re-challenge the client.
+ if ('::invalid::' == $data['username']) {
+ return $this->_challengeClient();
+ }
+
+ // Verify that the client sent back the same nonce
+ if ($this->_calcNonce() != $data['nonce']) {
+ return $this->_challengeClient();
+ }
+ // The opaque value is also required to match, but of course IE doesn't
+ // play ball.
+ if (!$this->ieNoOpaque && $this->_calcOpaque() != $data['opaque']) {
+ return $this->_challengeClient();
+ }
+
+ // Look up the user's password hash. If not found, deny access.
+ // This makes no assumptions about how the password hash was
+ // constructed beyond that it must have been built in such a way as
+ // to be recreatable with the current settings of this object.
+ $ha1 = $this->digestResolver->resolve($data['username'], $data['realm']);
+ if ($ha1 === false) {
+ return $this->_challengeClient();
+ }
+
+ // If MD5-sess is used, a1 value is made of the user's password
+ // hash with the server and client nonce appended, separated by
+ // colons.
+ if ($this->algo == 'MD5-sess') {
+ $ha1 = hash('md5', $ha1 . ':' . $data['nonce'] . ':' . $data['cnonce']);
+ }
+
+ // Calculate h(a2). The value of this hash depends on the qop
+ // option selected by the client and the supported hash functions
+ switch ($data['qop']) {
+ case 'auth':
+ $a2 = $this->request->getMethod() . ':' . $data['uri'];
+ break;
+ case 'auth-int':
+ // Should be REQUEST_METHOD . ':' . uri . ':' . hash(entity-body),
+ // but this isn't supported yet, so fall through to default case
+ default:
+ throw new Exception\RuntimeException('Client requested an unsupported qop option');
+ }
+ // Using hash() should make parameterizing the hash algorithm
+ // easier
+ $ha2 = hash('md5', $a2);
+
+
+ // Calculate the server's version of the request-digest. This must
+ // match $data['response']. See RFC 2617, section 3.2.2.1
+ $message = $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $ha2;
+ $digest = hash('md5', $ha1 . ':' . $message);
+
+ // If our digest matches the client's let them in, otherwise return
+ // a 401 code and exit to prevent access to the protected resource.
+ if (CryptUtils::compareStrings($digest, $data['response'])) {
+ $identity = array('username' => $data['username'], 'realm' => $data['realm']);
+ return new Authentication\Result(Authentication\Result::SUCCESS, $identity);
+ }
+
+ return $this->_challengeClient();
+ }
+
+ /**
+ * Calculate Nonce
+ *
+ * @return string The nonce value
+ */
+ protected function _calcNonce()
+ {
+ // Once subtle consequence of this timeout calculation is that it
+ // actually divides all of time into nonceTimeout-sized sections, such
+ // that the value of timeout is the point in time of the next
+ // approaching "boundary" of a section. This allows the server to
+ // consistently generate the same timeout (and hence the same nonce
+ // value) across requests, but only as long as one of those
+ // "boundaries" is not crossed between requests. If that happens, the
+ // nonce will change on its own, and effectively log the user out. This
+ // would be surprising if the user just logged in.
+ $timeout = ceil(time() / $this->nonceTimeout) * $this->nonceTimeout;
+
+ $userAgentHeader = $this->request->getHeaders()->get('User-Agent');
+ if ($userAgentHeader) {
+ $userAgent = $userAgentHeader->getFieldValue();
+ } elseif (isset($_SERVER['HTTP_USER_AGENT'])) {
+ $userAgent = $_SERVER['HTTP_USER_AGENT'];
+ } else {
+ $userAgent = 'Zend_Authenticaion';
+ }
+ $nonce = hash('md5', $timeout . ':' . $userAgent . ':' . __CLASS__);
+ return $nonce;
+ }
+
+ /**
+ * Calculate Opaque
+ *
+ * The opaque string can be anything; the client must return it exactly as
+ * it was sent. It may be useful to store data in this string in some
+ * applications. Ideally, a new value for this would be generated each time
+ * a WWW-Authenticate header is sent (in order to reduce predictability),
+ * but we would have to be able to create the same exact value across at
+ * least two separate requests from the same client.
+ *
+ * @return string The opaque value
+ */
+ protected function _calcOpaque()
+ {
+ return hash('md5', 'Opaque Data:' . __CLASS__);
+ }
+
+ /**
+ * Parse Digest Authorization header
+ *
+ * @param string $header Client's Authorization: HTTP header
+ * @return array|bool Data elements from header, or false if any part of
+ * the header is invalid
+ */
+ protected function _parseDigestAuth($header)
+ {
+ $temp = null;
+ $data = array();
+
+ // See ZF-1052. Detect invalid usernames instead of just returning a
+ // 400 code.
+ $ret = preg_match('/username="([^"]+)"/', $header, $temp);
+ if (!$ret || empty($temp[1])
+ || !ctype_print($temp[1])
+ || strpos($temp[1], ':') !== false) {
+ $data['username'] = '::invalid::';
+ } else {
+ $data['username'] = $temp[1];
+ }
+ $temp = null;
+
+ $ret = preg_match('/realm="([^"]+)"/', $header, $temp);
+ if (!$ret || empty($temp[1])) {
+ return false;
+ }
+ if (!ctype_print($temp[1]) || strpos($temp[1], ':') !== false) {
+ return false;
+ } else {
+ $data['realm'] = $temp[1];
+ }
+ $temp = null;
+
+ $ret = preg_match('/nonce="([^"]+)"/', $header, $temp);
+ if (!$ret || empty($temp[1])) {
+ return false;
+ }
+ if (!ctype_xdigit($temp[1])) {
+ return false;
+ }
+
+ $data['nonce'] = $temp[1];
+ $temp = null;
+
+ $ret = preg_match('/uri="([^"]+)"/', $header, $temp);
+ if (!$ret || empty($temp[1])) {
+ return false;
+ }
+ // Section 3.2.2.5 in RFC 2617 says the authenticating server must
+ // verify that the URI field in the Authorization header is for the
+ // same resource requested in the Request Line.
+ $rUri = $this->request->getUri();
+ $cUri = UriFactory::factory($temp[1]);
+
+ // Make sure the path portion of both URIs is the same
+ if ($rUri->getPath() != $cUri->getPath()) {
+ return false;
+ }
+
+ // Section 3.2.2.5 seems to suggest that the value of the URI
+ // Authorization field should be made into an absolute URI if the
+ // Request URI is absolute, but it's vague, and that's a bunch of
+ // code I don't want to write right now.
+ $data['uri'] = $temp[1];
+ $temp = null;
+
+ $ret = preg_match('/response="([^"]+)"/', $header, $temp);
+ if (!$ret || empty($temp[1])) {
+ return false;
+ }
+ if (32 != strlen($temp[1]) || !ctype_xdigit($temp[1])) {
+ return false;
+ }
+
+ $data['response'] = $temp[1];
+ $temp = null;
+
+ // The spec says this should default to MD5 if omitted. OK, so how does
+ // that square with the algo we send out in the WWW-Authenticate header,
+ // if it can easily be overridden by the client?
+ $ret = preg_match('/algorithm="?(' . $this->algo . ')"?/', $header, $temp);
+ if ($ret && !empty($temp[1])
+ && in_array($temp[1], $this->supportedAlgos)) {
+ $data['algorithm'] = $temp[1];
+ } else {
+ $data['algorithm'] = 'MD5'; // = $this->algo; ?
+ }
+ $temp = null;
+
+ // Not optional in this implementation
+ $ret = preg_match('/cnonce="([^"]+)"/', $header, $temp);
+ if (!$ret || empty($temp[1])) {
+ return false;
+ }
+ if (!ctype_print($temp[1])) {
+ return false;
+ }
+
+ $data['cnonce'] = $temp[1];
+ $temp = null;
+
+ // If the server sent an opaque value, the client must send it back
+ if ($this->useOpaque) {
+ $ret = preg_match('/opaque="([^"]+)"/', $header, $temp);
+ if (!$ret || empty($temp[1])) {
+
+ // Big surprise: IE isn't RFC 2617-compliant.
+ $headers = $this->request->getHeaders();
+ if (!$headers->has('User-Agent')) {
+ return false;
+ }
+ $userAgent = $headers->get('User-Agent')->getFieldValue();
+ if (false === strpos($userAgent, 'MSIE')) {
+ return false;
+ }
+
+ $temp[1] = '';
+ $this->ieNoOpaque = true;
+ }
+
+ // This implementation only sends MD5 hex strings in the opaque value
+ if (!$this->ieNoOpaque &&
+ (32 != strlen($temp[1]) || !ctype_xdigit($temp[1]))) {
+ return false;
+ }
+
+ $data['opaque'] = $temp[1];
+ $temp = null;
+ }
+
+ // Not optional in this implementation, but must be one of the supported
+ // qop types
+ $ret = preg_match('/qop="?(' . implode('|', $this->supportedQops) . ')"?/', $header, $temp);
+ if (!$ret || empty($temp[1])) {
+ return false;
+ }
+ if (!in_array($temp[1], $this->supportedQops)) {
+ return false;
+ }
+
+ $data['qop'] = $temp[1];
+ $temp = null;
+
+ // Not optional in this implementation. The spec says this value
+ // shouldn't be a quoted string, but apparently some implementations
+ // quote it anyway. See ZF-1544.
+ $ret = preg_match('/nc="?([0-9A-Fa-f]{8})"?/', $header, $temp);
+ if (!$ret || empty($temp[1])) {
+ return false;
+ }
+ if (8 != strlen($temp[1]) || !ctype_xdigit($temp[1])) {
+ return false;
+ }
+
+ $data['nc'] = $temp[1];
+ $temp = null;
+
+ return $data;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Adapter/Ldap.php zendframework-2.2.6/library/Zend/Authentication/Adapter/Ldap.php
--- zendframework-1.10.4/library/Zend/Authentication/Adapter/Ldap.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Adapter/Ldap.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,458 @@
+setOptions($options);
+ if ($identity !== null) {
+ $this->setIdentity($identity);
+ }
+ if ($credential !== null) {
+ $this->setCredential($credential);
+ }
+ }
+
+ /**
+ * Returns the array of arrays of Zend\Ldap\Ldap options of this adapter.
+ *
+ * @return array|null
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * Sets the array of arrays of Zend\Ldap\Ldap options to be used by
+ * this adapter.
+ *
+ * @param array $options The array of arrays of Zend\Ldap\Ldap options
+ * @return Ldap Provides a fluent interface
+ */
+ public function setOptions($options)
+ {
+ $this->options = is_array($options) ? $options : array();
+ if (array_key_exists('identity', $this->options)) {
+ $this->options['username'] = $this->options['identity'];
+ }
+ if (array_key_exists('credential', $this->options)) {
+ $this->options['password'] = $this->options['credential'];
+ }
+ return $this;
+ }
+
+ /**
+ * Returns the username of the account being authenticated, or
+ * NULL if none is set.
+ *
+ * @return string|null
+ */
+ public function getUsername()
+ {
+ return $this->getIdentity();
+ }
+
+ /**
+ * Sets the username for binding
+ *
+ * @param string $username The username for binding
+ * @return Ldap Provides a fluent interface
+ */
+ public function setUsername($username)
+ {
+ return $this->setIdentity($username);
+ }
+
+ /**
+ * Returns the password of the account being authenticated, or
+ * NULL if none is set.
+ *
+ * @return string|null
+ */
+ public function getPassword()
+ {
+ return $this->getCredential();
+ }
+
+ /**
+ * Sets the password for the account
+ *
+ * @param string $password The password of the account being authenticated
+ * @return Ldap Provides a fluent interface
+ */
+ public function setPassword($password)
+ {
+ return $this->setCredential($password);
+ }
+
+ /**
+ * Returns the LDAP Object
+ *
+ * @return ZendLdap\Ldap The Zend\Ldap\Ldap object used to authenticate the credentials
+ */
+ public function getLdap()
+ {
+ if ($this->ldap === null) {
+ $this->ldap = new ZendLdap\Ldap();
+ }
+
+ return $this->ldap;
+ }
+
+ /**
+ * Set an Ldap connection
+ *
+ * @param ZendLdap\Ldap $ldap An existing Ldap object
+ * @return Ldap Provides a fluent interface
+ */
+ public function setLdap(ZendLdap\Ldap $ldap)
+ {
+ $this->ldap = $ldap;
+
+ $this->setOptions(array($ldap->getOptions()));
+
+ return $this;
+ }
+
+ /**
+ * Returns a domain name for the current LDAP options. This is used
+ * for skipping redundant operations (e.g. authentications).
+ *
+ * @return string
+ */
+ protected function getAuthorityName()
+ {
+ $options = $this->getLdap()->getOptions();
+ $name = $options['accountDomainName'];
+ if (!$name)
+ $name = $options['accountDomainNameShort'];
+ return $name ? $name : '';
+ }
+
+ /**
+ * Authenticate the user
+ *
+ * @return AuthenticationResult
+ * @throws Exception\ExceptionInterface
+ */
+ public function authenticate()
+ {
+ $messages = array();
+ $messages[0] = ''; // reserved
+ $messages[1] = ''; // reserved
+
+ $username = $this->identity;
+ $password = $this->credential;
+
+ if (!$username) {
+ $code = AuthenticationResult::FAILURE_IDENTITY_NOT_FOUND;
+ $messages[0] = 'A username is required';
+ return new AuthenticationResult($code, '', $messages);
+ }
+ if (!$password) {
+ /* A password is required because some servers will
+ * treat an empty password as an anonymous bind.
+ */
+ $code = AuthenticationResult::FAILURE_CREDENTIAL_INVALID;
+ $messages[0] = 'A password is required';
+ return new AuthenticationResult($code, '', $messages);
+ }
+
+ $ldap = $this->getLdap();
+
+ $code = AuthenticationResult::FAILURE;
+ $messages[0] = "Authority not found: $username";
+ $failedAuthorities = array();
+
+ /* Iterate through each server and try to authenticate the supplied
+ * credentials against it.
+ */
+ foreach ($this->options as $options) {
+
+ if (!is_array($options)) {
+ throw new Exception\InvalidArgumentException('Adapter options array not an array');
+ }
+ $adapterOptions = $this->prepareOptions($ldap, $options);
+ $dname = '';
+
+ try {
+ if ($messages[1])
+ $messages[] = $messages[1];
+ $messages[1] = '';
+ $messages[] = $this->optionsToString($options);
+
+ $dname = $this->getAuthorityName();
+ if (isset($failedAuthorities[$dname])) {
+ /* If multiple sets of server options for the same domain
+ * are supplied, we want to skip redundant authentications
+ * where the identity or credentials where found to be
+ * invalid with another server for the same domain. The
+ * $failedAuthorities array tracks this condition (and also
+ * serves to supply the original error message).
+ * This fixes issue ZF-4093.
+ */
+ $messages[1] = $failedAuthorities[$dname];
+ $messages[] = "Skipping previously failed authority: $dname";
+ continue;
+ }
+
+ $canonicalName = $ldap->getCanonicalAccountName($username);
+ $ldap->bind($canonicalName, $password);
+ /*
+ * Fixes problem when authenticated user is not allowed to retrieve
+ * group-membership information or own account.
+ * This requires that the user specified with "username" and optionally
+ * "password" in the Zend\Ldap\Ldap options is able to retrieve the required
+ * information.
+ */
+ $requireRebind = false;
+ if (isset($options['username'])) {
+ $ldap->bind();
+ $requireRebind = true;
+ }
+ $dn = $ldap->getCanonicalAccountName($canonicalName, ZendLdap\Ldap::ACCTNAME_FORM_DN);
+
+ $groupResult = $this->checkGroupMembership($ldap, $canonicalName, $dn, $adapterOptions);
+ if ($groupResult === true) {
+ $this->authenticatedDn = $dn;
+ $messages[0] = '';
+ $messages[1] = '';
+ $messages[] = "$canonicalName authentication successful";
+ if ($requireRebind === true) {
+ // rebinding with authenticated user
+ $ldap->bind($dn, $password);
+ }
+ return new AuthenticationResult(AuthenticationResult::SUCCESS, $canonicalName, $messages);
+ } else {
+ $messages[0] = 'Account is not a member of the specified group';
+ $messages[1] = $groupResult;
+ $failedAuthorities[$dname] = $groupResult;
+ }
+ } catch (LdapException $zle) {
+
+ /* LDAP based authentication is notoriously difficult to diagnose. Therefore
+ * we bend over backwards to capture and record every possible bit of
+ * information when something goes wrong.
+ */
+
+ $err = $zle->getCode();
+
+ if ($err == LdapException::LDAP_X_DOMAIN_MISMATCH) {
+ /* This error indicates that the domain supplied in the
+ * username did not match the domains in the server options
+ * and therefore we should just skip to the next set of
+ * server options.
+ */
+ continue;
+ } elseif ($err == LdapException::LDAP_NO_SUCH_OBJECT) {
+ $code = AuthenticationResult::FAILURE_IDENTITY_NOT_FOUND;
+ $messages[0] = "Account not found: $username";
+ $failedAuthorities[$dname] = $zle->getMessage();
+ } elseif ($err == LdapException::LDAP_INVALID_CREDENTIALS) {
+ $code = AuthenticationResult::FAILURE_CREDENTIAL_INVALID;
+ $messages[0] = 'Invalid credentials';
+ $failedAuthorities[$dname] = $zle->getMessage();
+ } else {
+ $line = $zle->getLine();
+ $messages[] = $zle->getFile() . "($line): " . $zle->getMessage();
+ $messages[] = preg_replace(
+ '/\b'.preg_quote(substr($password, 0, 15), '/').'\b/',
+ '*****',
+ $zle->getTraceAsString()
+ );
+ $messages[0] = 'An unexpected failure occurred';
+ }
+ $messages[1] = $zle->getMessage();
+ }
+ }
+
+ $msg = isset($messages[1]) ? $messages[1] : $messages[0];
+ $messages[] = "$username authentication failed: $msg";
+
+ return new AuthenticationResult($code, $username, $messages);
+ }
+
+ /**
+ * Sets the LDAP specific options on the Zend\Ldap\Ldap instance
+ *
+ * @param ZendLdap\Ldap $ldap
+ * @param array $options
+ * @return array of auth-adapter specific options
+ */
+ protected function prepareOptions(ZendLdap\Ldap $ldap, array $options)
+ {
+ $adapterOptions = array(
+ 'group' => null,
+ 'groupDn' => $ldap->getBaseDn(),
+ 'groupScope' => ZendLdap\Ldap::SEARCH_SCOPE_SUB,
+ 'groupAttr' => 'cn',
+ 'groupFilter' => 'objectClass=groupOfUniqueNames',
+ 'memberAttr' => 'uniqueMember',
+ 'memberIsDn' => true
+ );
+ foreach ($adapterOptions as $key => $value) {
+ if (array_key_exists($key, $options)) {
+ $value = $options[$key];
+ unset($options[$key]);
+ switch ($key) {
+ case 'groupScope':
+ $value = (int) $value;
+ if (in_array($value, array(ZendLdap\Ldap::SEARCH_SCOPE_BASE,
+ ZendLdap\Ldap::SEARCH_SCOPE_ONE, ZendLdap\Ldap::SEARCH_SCOPE_SUB), true)) {
+ $adapterOptions[$key] = $value;
+ }
+ break;
+ case 'memberIsDn':
+ $adapterOptions[$key] = ($value === true ||
+ $value === '1' || strcasecmp($value, 'true') == 0);
+ break;
+ default:
+ $adapterOptions[$key] = trim($value);
+ break;
+ }
+ }
+ }
+ $ldap->setOptions($options);
+ return $adapterOptions;
+ }
+
+ /**
+ * Checks the group membership of the bound user
+ *
+ * @param ZendLdap\Ldap $ldap
+ * @param string $canonicalName
+ * @param string $dn
+ * @param array $adapterOptions
+ * @return string|true
+ */
+ protected function checkGroupMembership(ZendLdap\Ldap $ldap, $canonicalName, $dn, array $adapterOptions)
+ {
+ if ($adapterOptions['group'] === null) {
+ return true;
+ }
+
+ if ($adapterOptions['memberIsDn'] === false) {
+ $user = $canonicalName;
+ } else {
+ $user = $dn;
+ }
+
+ $groupName = ZendLdap\Filter::equals($adapterOptions['groupAttr'], $adapterOptions['group']);
+ $membership = ZendLdap\Filter::equals($adapterOptions['memberAttr'], $user);
+ $group = ZendLdap\Filter::andFilter($groupName, $membership);
+ $groupFilter = $adapterOptions['groupFilter'];
+ if (!empty($groupFilter)) {
+ $group = $group->addAnd($groupFilter);
+ }
+
+ $result = $ldap->count($group, $adapterOptions['groupDn'], $adapterOptions['groupScope']);
+
+ if ($result === 1) {
+ return true;
+ }
+
+ return 'Failed to verify group membership with ' . $group->toString();
+ }
+
+ /**
+ * getAccountObject() - Returns the result entry as a stdClass object
+ *
+ * This resembles the feature {@see Zend\Authentication\Adapter\DbTable::getResultRowObject()}.
+ * Closes ZF-6813
+ *
+ * @param array $returnAttribs
+ * @param array $omitAttribs
+ * @return stdClass|bool
+ */
+ public function getAccountObject(array $returnAttribs = array(), array $omitAttribs = array())
+ {
+ if (!$this->authenticatedDn) {
+ return false;
+ }
+
+ $returnObject = new stdClass();
+
+ $returnAttribs = array_map('strtolower', $returnAttribs);
+ $omitAttribs = array_map('strtolower', $omitAttribs);
+ $returnAttribs = array_diff($returnAttribs, $omitAttribs);
+
+ $entry = $this->getLdap()->getEntry($this->authenticatedDn, $returnAttribs, true);
+ foreach ($entry as $attr => $value) {
+ if (in_array($attr, $omitAttribs)) {
+ // skip attributes marked to be omitted
+ continue;
+ }
+ if (is_array($value)) {
+ $returnObject->$attr = (count($value) > 1) ? $value : $value[0];
+ } else {
+ $returnObject->$attr = $value;
+ }
+ }
+ return $returnObject;
+ }
+
+ /**
+ * Converts options to string
+ *
+ * @param array $options
+ * @return string
+ */
+ private function optionsToString(array $options)
+ {
+ $str = '';
+ foreach ($options as $key => $val) {
+ if ($key === 'password' || $key === 'credential') {
+ $val = '*****';
+ }
+ if ($str) {
+ $str .= ',';
+ }
+ $str .= $key . '=' . $val;
+ }
+ return $str;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Adapter/ValidatableAdapterInterface.php zendframework-2.2.6/library/Zend/Authentication/Adapter/ValidatableAdapterInterface.php
--- zendframework-1.10.4/library/Zend/Authentication/Adapter/ValidatableAdapterInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Adapter/ValidatableAdapterInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,45 @@
+setStorage($storage);
+ }
+ if (null !== $adapter) {
+ $this->setAdapter($adapter);
+ }
+ }
+
+ /**
+ * Returns the authentication adapter
+ *
+ * The adapter does not have a default if the storage adapter has not been set.
+ *
+ * @return Adapter\AdapterInterface|null
+ */
+ public function getAdapter()
+ {
+ return $this->adapter;
+ }
+
+ /**
+ * Sets the authentication adapter
+ *
+ * @param Adapter\AdapterInterface $adapter
+ * @return AuthenticationService Provides a fluent interface
+ */
+ public function setAdapter(Adapter\AdapterInterface $adapter)
+ {
+ $this->adapter = $adapter;
+ return $this;
+ }
+
+ /**
+ * Returns the persistent storage handler
+ *
+ * Session storage is used by default unless a different storage adapter has been set.
+ *
+ * @return Storage\StorageInterface
+ */
+ public function getStorage()
+ {
+ if (null === $this->storage) {
+ $this->setStorage(new Storage\Session());
+ }
+
+ return $this->storage;
+ }
+
+ /**
+ * Sets the persistent storage handler
+ *
+ * @param Storage\StorageInterface $storage
+ * @return AuthenticationService Provides a fluent interface
+ */
+ public function setStorage(Storage\StorageInterface $storage)
+ {
+ $this->storage = $storage;
+ return $this;
+ }
+
+ /**
+ * Authenticates against the supplied adapter
+ *
+ * @param Adapter\AdapterInterface $adapter
+ * @return Result
+ * @throws Exception\RuntimeException
+ */
+ public function authenticate(Adapter\AdapterInterface $adapter = null)
+ {
+ if (!$adapter) {
+ if (!$adapter = $this->getAdapter()) {
+ throw new Exception\RuntimeException('An adapter must be set or passed prior to calling authenticate()');
+ }
+ }
+ $result = $adapter->authenticate();
+
+ /**
+ * ZF-7546 - prevent multiple successive calls from storing inconsistent results
+ * Ensure storage has clean state
+ */
+ if ($this->hasIdentity()) {
+ $this->clearIdentity();
+ }
+
+ if ($result->isValid()) {
+ $this->getStorage()->write($result->getIdentity());
+ }
+
+ return $result;
+ }
+
+ /**
+ * Returns true if and only if an identity is available from storage
+ *
+ * @return bool
+ */
+ public function hasIdentity()
+ {
+ return !$this->getStorage()->isEmpty();
+ }
+
+ /**
+ * Returns the identity from storage or null if no identity is available
+ *
+ * @return mixed|null
+ */
+ public function getIdentity()
+ {
+ $storage = $this->getStorage();
+
+ if ($storage->isEmpty()) {
+ return null;
+ }
+
+ return $storage->read();
+ }
+
+ /**
+ * Clears the identity from persistent storage
+ *
+ * @return void
+ */
+ public function clearIdentity()
+ {
+ $this->getStorage()->clear();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/composer.json zendframework-2.2.6/library/Zend/Authentication/composer.json
--- zendframework-1.10.4/library/Zend/Authentication/composer.json 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/composer.json 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,31 @@
+{
+ "name": "zendframework/zend-authentication",
+ "description": "provides an API for authentication and includes concrete authentication adapters for common use case scenarios",
+ "license": "BSD-3-Clause",
+ "keywords": [
+ "zf2",
+ "authentication"
+ ],
+ "autoload": {
+ "psr-0": {
+ "Zend\\Authentication\\": ""
+ }
+ },
+ "target-dir": "Zend/Authentication",
+ "require": {
+ "php": ">=5.3.3",
+ "zendframework/zend-stdlib": "self.version"
+ },
+ "suggest": {
+ "zendframework/zend-db": "Zend\\Db component",
+ "zendframework/zend-crypt": "Zend\\Crypt component",
+ "zendframework/zend-uri": "Zend\\Uri component",
+ "zendframework/zend-session": "Zend\\Session component"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev",
+ "dev-develop": "2.3-dev"
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Authentication/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Authentication/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Exception/ExceptionInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,13 @@
+code = (int) $code;
+ $this->identity = $identity;
+ $this->messages = $messages;
+ }
+
+ /**
+ * Returns whether the result represents a successful authentication attempt
+ *
+ * @return bool
+ */
+ public function isValid()
+ {
+ return ($this->code > 0) ? true : false;
+ }
+
+ /**
+ * getCode() - Get the result code for this authentication attempt
+ *
+ * @return int
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Returns the identity used in the authentication attempt
+ *
+ * @return mixed
+ */
+ public function getIdentity()
+ {
+ return $this->identity;
+ }
+
+ /**
+ * Returns an array of string reasons why the authentication attempt was unsuccessful
+ *
+ * If authentication was successful, this method returns an empty array.
+ *
+ * @return array
+ */
+ public function getMessages()
+ {
+ return $this->messages;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Storage/Chain.php zendframework-2.2.6/library/Zend/Authentication/Storage/Chain.php
--- zendframework-1.10.4/library/Zend/Authentication/Storage/Chain.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Storage/Chain.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,109 @@
+storageChain = new PriorityQueue();
+ }
+
+ /**
+ * @param StorageInterface $storage
+ * @param int $priority
+ */
+ public function add(StorageInterface $storage, $priority = 1)
+ {
+ $this->storageChain->insert($storage, $priority);
+ }
+
+ /**
+ * Loop over the queue of storage until a storage is found that is non-empty. If such
+ * storage is not found, then this chain storage itself is empty.
+ *
+ * In case a non-empty storage is found then this chain storage is also non-empty. Report
+ * that, but also make sure that all storage with higher priorty that are empty
+ * are filled.
+ *
+ * @see StorageInterface::isEmpty()
+ */
+ public function isEmpty()
+ {
+ $storageWithHigherPriority = array();
+
+ // Loop invariant: $storageWithHigherPriority contains all storage with higher priorty
+ // than the current one.
+ foreach ($this->storageChain as $storage) {
+ if ($storage->isEmpty()) {
+ $storageWithHigherPriority[] = $storage;
+ continue;
+ }
+
+ $storageValue = $storage->read();
+ foreach ($storageWithHigherPriority as $higherPriorityStorage) {
+ $higherPriorityStorage->write($storageValue);
+ }
+
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * If the chain is non-empty then the storage with the top priority is guaranteed to be
+ * filled. Return its value.
+ *
+ * @see StorageInterface::read()
+ */
+ public function read()
+ {
+ return $this->storageChain->top()->read();
+ }
+
+ /**
+ * Write the new $contents to all storage in the chain.
+ *
+ * @see StorageInterface::write()
+ */
+ public function write($contents)
+ {
+ foreach ($this->storageChain as $storage) {
+ $storage->write($contents);
+ }
+ }
+
+ /**
+ * Clear all storage in the chain.
+ *
+ * @see StorageInterface::clear()
+ */
+ public function clear()
+ {
+ foreach ($this->storageChain as $storage) {
+ $storage->clear();
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Storage/NonPersistent.php zendframework-2.2.6/library/Zend/Authentication/Storage/NonPersistent.php
--- zendframework-1.10.4/library/Zend/Authentication/Storage/NonPersistent.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Storage/NonPersistent.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,67 @@
+data);
+ }
+
+ /**
+ * Returns the contents of storage
+ * Behavior is undefined when storage is empty.
+ *
+ * @return mixed
+ */
+ public function read()
+ {
+ return $this->data;
+ }
+
+ /**
+ * Writes $contents to storage
+ *
+ * @param mixed $contents
+ * @return void
+ */
+ public function write($contents)
+ {
+ $this->data = $contents;
+ }
+
+ /**
+ * Clears contents from storage
+ *
+ * @return void
+ */
+ public function clear()
+ {
+ $this->data = null;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Storage/Session.php zendframework-2.2.6/library/Zend/Authentication/Storage/Session.php
--- zendframework-1.10.4/library/Zend/Authentication/Storage/Session.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Storage/Session.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,126 @@
+namespace = $namespace;
+ }
+ if ($member !== null) {
+ $this->member = $member;
+ }
+ $this->session = new SessionContainer($this->namespace, $manager);
+ }
+
+ /**
+ * Returns the session namespace
+ *
+ * @return string
+ */
+ public function getNamespace()
+ {
+ return $this->namespace;
+ }
+
+ /**
+ * Returns the name of the session object member
+ *
+ * @return string
+ */
+ public function getMember()
+ {
+ return $this->member;
+ }
+
+ /**
+ * Defined by Zend\Authentication\Storage\StorageInterface
+ *
+ * @return bool
+ */
+ public function isEmpty()
+ {
+ return !isset($this->session->{$this->member});
+ }
+
+ /**
+ * Defined by Zend\Authentication\Storage\StorageInterface
+ *
+ * @return mixed
+ */
+ public function read()
+ {
+ return $this->session->{$this->member};
+ }
+
+ /**
+ * Defined by Zend\Authentication\Storage\StorageInterface
+ *
+ * @param mixed $contents
+ * @return void
+ */
+ public function write($contents)
+ {
+ $this->session->{$this->member} = $contents;
+ }
+
+ /**
+ * Defined by Zend\Authentication\Storage\StorageInterface
+ *
+ * @return void
+ */
+ public function clear()
+ {
+ unset($this->session->{$this->member});
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Authentication/Storage/StorageInterface.php zendframework-2.2.6/library/Zend/Authentication/Storage/StorageInterface.php
--- zendframework-1.10.4/library/Zend/Authentication/Storage/StorageInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Authentication/Storage/StorageInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,48 @@
+ 'Invalid identity',
+ self::IDENTITY_AMBIGUOUS => 'Identity is ambiguous',
+ self::CREDENTIAL_INVALID => 'Invalid password',
+ self::UNCATEGORIZED => 'Authentication failed',
+ self::GENERAL => 'Authentication failed',
+ );
+
+ /**
+ * Authentication Adapter
+ * @var ValidatableAdapterInterface
+ */
+ protected $adapter;
+
+ /**
+ * Identity (or field)
+ * @var string
+ */
+ protected $identity;
+
+ /**
+ * Credential (or field)
+ * @var string
+ */
+ protected $credential;
+
+ /**
+ * Authentication Service
+ * @var AuthenticationService
+ */
+ protected $service;
+
+ /**
+ * Sets validator options
+ *
+ * @param mixed $options
+ */
+ public function __construct($options = null)
+ {
+ if ($options instanceof Traversable) {
+ $options = ArrayUtils::iteratorToArray($options);
+ }
+
+ if (is_array($options)) {
+ if (array_key_exists('adapter', $options)) {
+ $this->setAdapter($options['adapter']);
+ }
+ if (array_key_exists('identity', $options)) {
+ $this->setIdentity($options['identity']);
+ }
+ if (array_key_exists('credential', $options)) {
+ $this->setCredential($options['credential']);
+ }
+ if (array_key_exists('service', $options)) {
+ $this->setService($options['service']);
+ }
+ }
+ parent::__construct($options);
+ }
+
+ /**
+ * Get Adapter
+ *
+ * @return ValidatableAdapterInterface
+ */
+ public function getAdapter()
+ {
+ return $this->adapter;
+ }
+
+ /**
+ * Set Adapter
+ *
+ * @param ValidatableAdapterInterface $adapter
+ * @return Authentication
+ */
+ public function setAdapter(ValidatableAdapterInterface $adapter)
+ {
+ $this->adapter = $adapter;
+
+ return $this;
+ }
+
+ /**
+ * Get Identity
+ *
+ * @return mixed
+ */
+ public function getIdentity()
+ {
+ return $this->identity;
+ }
+
+ /**
+ * Set Identity
+ *
+ * @param mixed $identity
+ * @return Authentication
+ */
+ public function setIdentity($identity)
+ {
+ $this->identity = $identity;
+
+ return $this;
+ }
+
+ /**
+ * Get Credential
+ *
+ * @return mixed
+ */
+ public function getCredential()
+ {
+ return $this->credential;
+ }
+
+ /**
+ * Set Credential
+ *
+ * @param mixed $credential
+ * @return Authentication
+ */
+ public function setCredential($credential)
+ {
+ $this->credential = $credential;
+
+ return $this;
+ }
+
+ /**
+ * Get Service
+ *
+ * @return AuthenticationService
+ */
+ public function getService()
+ {
+ return $this->service;
+ }
+
+ /**
+ * Set Service
+ *
+ * @param AuthenticationService $service
+ * @return Authentication
+ */
+ public function setService(AuthenticationService $service)
+ {
+ $this->service = $service;
+
+ return $this;
+ }
+
+ /**
+ * Is Valid
+ *
+ * @param mixed $value
+ * @param array $context
+ * @return bool
+ */
+ public function isValid($value = null, $context = null)
+ {
+ if ($value !== null) {
+ $this->setCredential($value);
+ }
+
+ if (($context !== null) && array_key_exists($this->identity, $context)) {
+ $identity = $context[$this->identity];
+ } else {
+ $identity = $this->identity;
+ }
+ if (!$this->identity) {
+ throw new Exception\RuntimeException('Identity must be set prior to validation');
+ }
+
+ if (($context !== null) && array_key_exists($this->credential, $context)) {
+ $credential = $context[$this->credential];
+ } else {
+ $credential = $this->credential;
+ }
+
+ if (!$this->adapter) {
+ throw new Exception\RuntimeException('Adapter must be set prior to validation');
+ }
+ $this->adapter->setIdentity($identity);
+ $this->adapter->setCredential($credential);
+
+ if (!$this->service) {
+ throw new Exception\RuntimeException('AuthenticationService must be set prior to validation');
+ }
+ $result = $this->service->authenticate($this->adapter);
+
+ if ($result->getCode() != Result::SUCCESS) {
+ switch ($result->getCode()) {
+ case Result::FAILURE_IDENTITY_NOT_FOUND:
+ $this->error(self::IDENTITY_NOT_FOUND);
+ break;
+ case Result::FAILURE_CREDENTIAL_INVALID:
+ $this->error(self::CREDENTIAL_INVALID);
+ break;
+ case Result::FAILURE_IDENTITY_AMBIGUOUS:
+ $this->error(self::IDENTITY_AMBIGUOUS);
+ break;
+ case Result::FAILURE_UNCATEGORIZED:
+ $this->error(self::UNCATEGORIZED);
+ break;
+ default:
+ $this->error(self::GENERAL);
+ }
+
+ return false;
+ }
+
+ return true;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Auth.php zendframework-2.2.6/library/Zend/Auth.php
--- zendframework-1.10.4/library/Zend/Auth.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Auth.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,169 +0,0 @@
-_storage) {
- /**
- * @see Zend_Auth_Storage_Session
- */
- require_once 'Zend/Auth/Storage/Session.php';
- $this->setStorage(new Zend_Auth_Storage_Session());
- }
-
- return $this->_storage;
- }
-
- /**
- * Sets the persistent storage handler
- *
- * @param Zend_Auth_Storage_Interface $storage
- * @return Zend_Auth Provides a fluent interface
- */
- public function setStorage(Zend_Auth_Storage_Interface $storage)
- {
- $this->_storage = $storage;
- return $this;
- }
-
- /**
- * Authenticates against the supplied adapter
- *
- * @param Zend_Auth_Adapter_Interface $adapter
- * @return Zend_Auth_Result
- */
- public function authenticate(Zend_Auth_Adapter_Interface $adapter)
- {
- $result = $adapter->authenticate();
-
- /**
- * ZF-7546 - prevent multiple succesive calls from storing inconsistent results
- * Ensure storage has clean state
- */
- if ($this->hasIdentity()) {
- $this->clearIdentity();
- }
-
- if ($result->isValid()) {
- $this->getStorage()->write($result->getIdentity());
- }
-
- return $result;
- }
-
- /**
- * Returns true if and only if an identity is available from storage
- *
- * @return boolean
- */
- public function hasIdentity()
- {
- return !$this->getStorage()->isEmpty();
- }
-
- /**
- * Returns the identity from storage or null if no identity is available
- *
- * @return mixed|null
- */
- public function getIdentity()
- {
- $storage = $this->getStorage();
-
- if ($storage->isEmpty()) {
- return null;
- }
-
- return $storage->read();
- }
-
- /**
- * Clears the identity from persistent storage
- *
- * @return void
- */
- public function clearIdentity()
- {
- $this->getStorage()->clear();
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Barcode.php zendframework-2.2.6/library/Zend/Barcode/Barcode.php
--- zendframework-1.10.4/library/Zend/Barcode/Barcode.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Barcode.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,301 @@
+ $e->getMessage()));
+ $renderer = static::makeRenderer($renderer, array());
+ } else {
+ throw $e;
+ }
+ }
+
+ $renderer->setAutomaticRenderError($automaticRenderError);
+ return $renderer->setBarcode($barcode);
+ }
+
+ /**
+ * Barcode Constructor
+ *
+ * @param mixed $barcode String name of barcode class, or Traversable object, or barcode object.
+ * @param mixed $barcodeConfig OPTIONAL; an array or Traversable object with barcode parameters.
+ * @throws Exception\InvalidArgumentException
+ * @return Object
+ */
+ public static function makeBarcode($barcode, $barcodeConfig = array())
+ {
+ if ($barcode instanceof Object\ObjectInterface) {
+ return $barcode;
+ }
+
+ /*
+ * Convert Traversable argument to plain string
+ * barcode name and separate configuration.
+ */
+ if ($barcode instanceof Traversable) {
+ $barcode = ArrayUtils::iteratorToArray($barcode);
+ if (isset($barcode['barcodeParams']) && is_array($barcode['barcodeParams'])) {
+ $barcodeConfig = $barcode['barcodeParams'];
+ }
+ if (isset($barcode['barcode'])) {
+ $barcode = (string) $barcode['barcode'];
+ } else {
+ $barcode = null;
+ }
+ }
+ if ($barcodeConfig instanceof Traversable) {
+ $barcodeConfig = ArrayUtils::iteratorToArray($barcodeConfig);
+ }
+
+ /*
+ * Verify that barcode parameters are in an array.
+ */
+ if (!is_array($barcodeConfig)) {
+ throw new Exception\InvalidArgumentException(
+ 'Barcode parameters must be in an array or a Traversable object'
+ );
+ }
+
+ /*
+ * Verify that an barcode name has been specified.
+ */
+ if (!is_string($barcode) || empty($barcode)) {
+ throw new Exception\InvalidArgumentException(
+ 'Barcode name must be specified in a string'
+ );
+ }
+
+ return static::getObjectPluginManager()->get($barcode, $barcodeConfig);
+ }
+
+ /**
+ * Renderer Constructor
+ *
+ * @param mixed $renderer String name of renderer class, or Traversable object.
+ * @param mixed $rendererConfig OPTIONAL; an array or Traversable object with renderer parameters.
+ * @throws Exception\RendererCreationException
+ * @return Renderer\RendererInterface
+ */
+ public static function makeRenderer($renderer = 'image', $rendererConfig = array())
+ {
+ if ($renderer instanceof Renderer\RendererInterface) {
+ return $renderer;
+ }
+
+ /*
+ * Convert Traversable argument to plain string
+ * barcode name and separate config object.
+ */
+ if ($renderer instanceof Traversable) {
+ $renderer = ArrayUtils::iteratorToArray($renderer);
+ if (isset($renderer['rendererParams'])) {
+ $rendererConfig = $renderer['rendererParams'];
+ }
+ if (isset($renderer['renderer'])) {
+ $renderer = (string) $renderer['renderer'];
+ }
+ }
+ if ($rendererConfig instanceof Traversable) {
+ $rendererConfig = ArrayUtils::iteratorToArray($rendererConfig);
+ }
+
+ /*
+ * Verify that barcode parameters are in an array.
+ */
+ if (!is_array($rendererConfig)) {
+ throw new Exception\RendererCreationException(
+ 'Barcode parameters must be in an array or a Traversable object'
+ );
+ }
+
+ /*
+ * Verify that an barcode name has been specified.
+ */
+ if (!is_string($renderer) || empty($renderer)) {
+ throw new Exception\RendererCreationException(
+ 'Renderer name must be specified in a string'
+ );
+ }
+
+ return static::getRendererPluginManager()->get($renderer, $rendererConfig);
+ }
+
+ /**
+ * Proxy to renderer render() method
+ *
+ * @param string | Object\ObjectInterface | array | Traversable $barcode
+ * @param string | Renderer\RendererInterface $renderer
+ * @param array | Traversable $barcodeConfig
+ * @param array | Traversable $rendererConfig
+ */
+ public static function render($barcode,
+ $renderer,
+ $barcodeConfig = array(),
+ $rendererConfig = array())
+ {
+ static::factory($barcode, $renderer, $barcodeConfig, $rendererConfig)->render();
+ }
+
+ /**
+ * Proxy to renderer draw() method
+ *
+ * @param string | Object\ObjectInterface | array | Traversable $barcode
+ * @param string | Renderer\RendererInterface $renderer
+ * @param array | Traversable $barcodeConfig
+ * @param array | Traversable $rendererConfig
+ * @return mixed
+ */
+ public static function draw($barcode,
+ $renderer,
+ $barcodeConfig = array(),
+ $rendererConfig = array())
+ {
+ return static::factory($barcode, $renderer, $barcodeConfig, $rendererConfig)->draw();
+ }
+
+ /**
+ * Set the default font for new instances of barcode
+ *
+ * @param string $font
+ * @return void
+ */
+ public static function setBarcodeFont($font)
+ {
+ static::$staticFont = $font;
+ }
+
+ /**
+ * Get current default font
+ *
+ * @return string
+ */
+ public static function getBarcodeFont()
+ {
+ return static::$staticFont;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/composer.json zendframework-2.2.6/library/Zend/Barcode/composer.json
--- zendframework-1.10.4/library/Zend/Barcode/composer.json 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/composer.json 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,32 @@
+{
+ "name": "zendframework/zend-barcode",
+ "description": "provides a generic way to generate barcodes",
+ "license": "BSD-3-Clause",
+ "keywords": [
+ "zf2",
+ "barcode"
+ ],
+ "autoload": {
+ "psr-0": {
+ "Zend\\Barcode\\": ""
+ }
+ },
+ "target-dir": "Zend/Barcode",
+ "require": {
+ "php": ">=5.3.3",
+ "zendframework/zend-stdlib": "self.version"
+ },
+ "require-dev": {
+ "zendframework/zendpdf": "*"
+ },
+ "suggest": {
+ "zendframework/zend-validator": "Zend\\Validator component",
+ "zendframework/zendpdf": "ZendPdf component"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev",
+ "dev-develop": "2.3-dev"
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Barcode/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Barcode/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Exception/ExceptionInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,17 @@
+_isRenderable = (bool) $flag;
- return $this;
- }
-
- /**
- * Retrieve renderable flag
- *
- * @return bool
- */
- public function isRenderable()
- {
- return $this->_isRenderable;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/AbstractObject.php zendframework-2.2.6/library/Zend/Barcode/Object/AbstractObject.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/AbstractObject.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/AbstractObject.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,1261 @@
+getDefaultOptions();
+ $this->font = Barcode\Barcode::getBarcodeFont();
+ if ($options instanceof Traversable) {
+ $options = ArrayUtils::iteratorToArray($options);
+ }
+ if (is_array($options)) {
+ $this->setOptions($options);
+ }
+ $this->type = strtolower(substr(get_class($this), strlen($this->barcodeNamespace) + 1));
+ if ($this->mandatoryChecksum) {
+ $this->withChecksum = true;
+ $this->withChecksumInText = true;
+ }
+ }
+
+ /**
+ * Set default options for particular object
+ * @return void
+ */
+ protected function getDefaultOptions()
+ {
+ }
+
+ /**
+ * Set barcode state from options array
+ * @param array $options
+ * @return \Zend\Barcode\Object\ObjectInterface
+ */
+ public function setOptions($options)
+ {
+ foreach ($options as $key => $value) {
+ $method = 'set' . $key;
+ if (method_exists($this, $method)) {
+ $this->$method($value);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Set barcode namespace for autoloading
+ *
+ * @param string $namespace
+ * @return \Zend\Barcode\Object\ObjectInterface
+ */
+ public function setBarcodeNamespace($namespace)
+ {
+ $this->barcodeNamespace = $namespace;
+ return $this;
+ }
+
+ /**
+ * Retrieve barcode namespace
+ *
+ * @return string
+ */
+ public function getBarcodeNamespace()
+ {
+ return $this->barcodeNamespace;
+ }
+
+ /**
+ * Retrieve type of barcode
+ * @return string
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * Set height of the barcode bar
+ * @param int $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ public function setBarHeight($value)
+ {
+ if (intval($value) <= 0) {
+ throw new Exception\OutOfRangeException(
+ 'Bar height must be greater than 0'
+ );
+ }
+ $this->barHeight = intval($value);
+ return $this;
+ }
+
+ /**
+ * Get height of the barcode bar
+ * @return int
+ */
+ public function getBarHeight()
+ {
+ return $this->barHeight;
+ }
+
+ /**
+ * Set thickness of thin bar
+ * @param int $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ public function setBarThinWidth($value)
+ {
+ if (intval($value) <= 0) {
+ throw new Exception\OutOfRangeException(
+ 'Bar width must be greater than 0'
+ );
+ }
+ $this->barThinWidth = intval($value);
+ return $this;
+ }
+
+ /**
+ * Get thickness of thin bar
+ * @return int
+ */
+ public function getBarThinWidth()
+ {
+ return $this->barThinWidth;
+ }
+
+ /**
+ * Set thickness of thick bar
+ * @param int $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ public function setBarThickWidth($value)
+ {
+ if (intval($value) <= 0) {
+ throw new Exception\OutOfRangeException(
+ 'Bar width must be greater than 0'
+ );
+ }
+ $this->barThickWidth = intval($value);
+ return $this;
+ }
+
+ /**
+ * Get thickness of thick bar
+ * @return int
+ */
+ public function getBarThickWidth()
+ {
+ return $this->barThickWidth;
+ }
+
+ /**
+ * Set factor applying to
+ * thinBarWidth - thickBarWidth - barHeight - fontSize
+ * @param float $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ public function setFactor($value)
+ {
+ if (floatval($value) <= 0) {
+ throw new Exception\OutOfRangeException(
+ 'Factor must be greater than 0'
+ );
+ }
+ $this->factor = floatval($value);
+ return $this;
+ }
+
+ /**
+ * Get factor applying to
+ * thinBarWidth - thickBarWidth - barHeight - fontSize
+ * @return int
+ */
+ public function getFactor()
+ {
+ return $this->factor;
+ }
+
+ /**
+ * Set color of the barcode and text
+ * @param string $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ public function setForeColor($value)
+ {
+ if (preg_match('`\#[0-9A-F]{6}`', $value)) {
+ $this->foreColor = hexdec($value);
+ } elseif (is_numeric($value) && $value >= 0 && $value <= 16777125) {
+ $this->foreColor = intval($value);
+ } else {
+ throw new Exception\InvalidArgumentException(
+ 'Text color must be set as #[0-9A-F]{6}'
+ );
+ }
+ return $this;
+ }
+
+ /**
+ * Retrieve color of the barcode and text
+ * @return int
+ */
+ public function getForeColor()
+ {
+ return $this->foreColor;
+ }
+
+ /**
+ * Set the color of the background
+ * @param int $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ public function setBackgroundColor($value)
+ {
+ if (preg_match('`\#[0-9A-F]{6}`', $value)) {
+ $this->backgroundColor = hexdec($value);
+ } elseif (is_numeric($value) && $value >= 0 && $value <= 16777125) {
+ $this->backgroundColor = intval($value);
+ } else {
+ throw new Exception\InvalidArgumentException(
+ 'Background color must be set as #[0-9A-F]{6}'
+ );
+ }
+ return $this;
+ }
+
+ /**
+ * Retrieve background color of the image
+ * @return int
+ */
+ public function getBackgroundColor()
+ {
+ return $this->backgroundColor;
+ }
+
+ /**
+ * Activate/deactivate drawing of the bar
+ * @param bool $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ */
+ public function setWithBorder($value)
+ {
+ $this->withBorder = (bool) $value;
+ return $this;
+ }
+
+ /**
+ * Retrieve if border are draw or not
+ * @return bool
+ */
+ public function getWithBorder()
+ {
+ return $this->withBorder;
+ }
+
+ /**
+ * Activate/deactivate drawing of the quiet zones
+ * @param bool $value
+ * @return AbstractObject
+ */
+ public function setWithQuietZones($value)
+ {
+ $this->withQuietZones = (bool) $value;
+ return $this;
+ }
+
+ /**
+ * Retrieve if quiet zones are draw or not
+ * @return bool
+ */
+ public function getWithQuietZones()
+ {
+ return $this->withQuietZones;
+ }
+
+ /**
+ * Allow fast inversion of font/bars color and background color
+ * @return \Zend\Barcode\Object\ObjectInterface
+ */
+ public function setReverseColor()
+ {
+ $tmp = $this->foreColor;
+ $this->foreColor = $this->backgroundColor;
+ $this->backgroundColor = $tmp;
+ return $this;
+ }
+
+ /**
+ * Set orientation of barcode and text
+ * @param float $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ public function setOrientation($value)
+ {
+ $this->orientation = floatval($value) - floor(floatval($value) / 360) * 360;
+ return $this;
+ }
+
+ /**
+ * Retrieve orientation of barcode and text
+ * @return float
+ */
+ public function getOrientation()
+ {
+ return $this->orientation;
+ }
+
+ /**
+ * Set text to encode
+ * @param string $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ */
+ public function setText($value)
+ {
+ $this->text = trim($value);
+ return $this;
+ }
+
+ /**
+ * Retrieve text to encode
+ * @return string
+ */
+ public function getText()
+ {
+ $text = $this->text;
+ if ($this->withChecksum) {
+ $text .= $this->getChecksum($this->text);
+ }
+ return $this->addLeadingZeros($text);
+ }
+
+ /**
+ * Automatically add leading zeros if barcode length is fixed
+ * @param string $text
+ * @param bool $withoutChecksum
+ * @return string
+ */
+ protected function addLeadingZeros($text, $withoutChecksum = false)
+ {
+ if ($this->barcodeLength && $this->addLeadingZeros) {
+ $omitChecksum = (int) ($this->withChecksum && $withoutChecksum);
+ if (is_int($this->barcodeLength)) {
+ $length = $this->barcodeLength - $omitChecksum;
+ if (strlen($text) < $length) {
+ $text = str_repeat('0', $length - strlen($text)) . $text;
+ }
+ } else {
+ if ($this->barcodeLength == 'even') {
+ $text = ((strlen($text) - $omitChecksum) % 2 ? '0' . $text : $text);
+ }
+ }
+ }
+ return $text;
+ }
+
+ /**
+ * Retrieve text to encode
+ * @return string
+ */
+ public function getRawText()
+ {
+ return $this->text;
+ }
+
+ /**
+ * Retrieve text to display
+ * @return string
+ */
+ public function getTextToDisplay()
+ {
+ if ($this->withChecksumInText) {
+ return $this->getText();
+ }
+
+ return $this->addLeadingZeros($this->text, true);
+ }
+
+ /**
+ * Activate/deactivate drawing of text to encode
+ * @param bool $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ */
+ public function setDrawText($value)
+ {
+ $this->drawText = (bool) $value;
+ return $this;
+ }
+
+ /**
+ * Retrieve if drawing of text to encode is enabled
+ * @return bool
+ */
+ public function getDrawText()
+ {
+ return $this->drawText;
+ }
+
+ /**
+ * Activate/deactivate the adjustment of the position
+ * of the characters to the position of the bars
+ * @param bool $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ public function setStretchText($value)
+ {
+ $this->stretchText = (bool) $value;
+ return $this;
+ }
+
+ /**
+ * Retrieve if the adjustment of the position of the characters
+ * to the position of the bars is enabled
+ * @return bool
+ */
+ public function getStretchText()
+ {
+ return $this->stretchText;
+ }
+
+ /**
+ * Activate/deactivate the automatic generation
+ * of the checksum character
+ * added to the barcode text
+ * @param bool $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ */
+ public function setWithChecksum($value)
+ {
+ if (!$this->mandatoryChecksum) {
+ $this->withChecksum = (bool) $value;
+ }
+ return $this;
+ }
+
+ /**
+ * Retrieve if the checksum character is automatically
+ * added to the barcode text
+ * @return bool
+ */
+ public function getWithChecksum()
+ {
+ return $this->withChecksum;
+ }
+
+ /**
+ * Activate/deactivate the automatic generation
+ * of the checksum character
+ * added to the barcode text
+ * @param bool $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ public function setWithChecksumInText($value)
+ {
+ if (!$this->mandatoryChecksum) {
+ $this->withChecksumInText = (bool) $value;
+ }
+ return $this;
+ }
+
+ /**
+ * Retrieve if the checksum character is automatically
+ * added to the barcode text
+ * @return bool
+ */
+ public function getWithChecksumInText()
+ {
+ return $this->withChecksumInText;
+ }
+
+ /**
+ * Set the font:
+ * - if integer between 1 and 5, use gd built-in fonts
+ * - if string, $value is assumed to be the path to a TTF font
+ * @param int|string $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ public function setFont($value)
+ {
+ if (is_int($value) && $value >= 1 && $value <= 5) {
+ if (!extension_loaded('gd')) {
+ throw new Exception\ExtensionNotLoadedException(
+ 'GD extension is required to use numeric font'
+ );
+ }
+
+ // Case of numeric font with GD
+ $this->font = $value;
+
+ // In this case font size is given by:
+ $this->fontSize = imagefontheight($value);
+ } elseif (is_string($value)) {
+ $this->font = $value;
+ } else {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Invalid font "%s" provided to setFont()',
+ $value
+ ));
+ }
+ return $this;
+ }
+
+ /**
+ * Retrieve the font
+ * @return int|string
+ */
+ public function getFont()
+ {
+ return $this->font;
+ }
+
+ /**
+ * Set the size of the font in case of TTF
+ * @param float $value
+ * @return \Zend\Barcode\Object\ObjectInterface
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ public function setFontSize($value)
+ {
+ if (is_numeric($this->font)) {
+ // Case of numeric font with GD
+ return $this;
+ }
+
+ if (!is_numeric($value)) {
+ throw new Exception\InvalidArgumentException(
+ 'Font size must be a numeric value'
+ );
+ }
+
+ $this->fontSize = $value;
+ return $this;
+ }
+
+ /**
+ * Retrieve the size of the font in case of TTF
+ * @return float
+ */
+ public function getFontSize()
+ {
+ return $this->fontSize;
+ }
+
+ /**
+ * Quiet zone before first bar
+ * and after the last bar
+ * @return int
+ */
+ public function getQuietZone()
+ {
+ if ($this->withQuietZones || $this->mandatoryQuietZones) {
+ return 10 * $this->barThinWidth * $this->factor;
+ }
+
+ return 0;
+ }
+
+ /**
+ * Add an instruction in the array of instructions
+ * @param array $instruction
+ */
+ protected function addInstruction(array $instruction)
+ {
+ $this->instructions[] = $instruction;
+ }
+
+ /**
+ * Retrieve the set of drawing instructions
+ * @return array
+ */
+ public function getInstructions()
+ {
+ return $this->instructions;
+ }
+
+ /**
+ * Add a polygon drawing instruction in the set of instructions
+ * @param array $points
+ * @param int $color
+ * @param bool $filled
+ */
+ protected function addPolygon(array $points, $color = null, $filled = true)
+ {
+ if ($color === null) {
+ $color = $this->foreColor;
+ }
+ $this->addInstruction(array(
+ 'type' => 'polygon',
+ 'points' => $points,
+ 'color' => $color,
+ 'filled' => $filled,
+ ));
+ }
+
+ /**
+ * Add a text drawing instruction in the set of instructions
+ * @param string $text
+ * @param float $size
+ * @param array $position
+ * @param string $font
+ * @param int $color
+ * @param string $alignment
+ * @param float $orientation
+ */
+ protected function addText(
+ $text,
+ $size,
+ $position,
+ $font,
+ $color,
+ $alignment = 'center',
+ $orientation = 0
+ ) {
+ if ($color === null) {
+ $color = $this->foreColor;
+ }
+ $this->addInstruction(array(
+ 'type' => 'text',
+ 'text' => $text,
+ 'size' => $size,
+ 'position' => $position,
+ 'font' => $font,
+ 'color' => $color,
+ 'alignment' => $alignment,
+ 'orientation' => $orientation,
+ ));
+ }
+
+ /**
+ * Checking of parameters after all settings
+ * @return bool
+ */
+ public function checkParams()
+ {
+ $this->checkText();
+ $this->checkFontAndOrientation();
+ $this->checkSpecificParams();
+ return true;
+ }
+
+ /**
+ * Check if a text is really provided to barcode
+ * @return void
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ protected function checkText($value = null)
+ {
+ if ($value === null) {
+ $value = $this->text;
+ }
+ if (!strlen($value)) {
+ throw new Exception\RuntimeException(
+ 'A text must be provide to Barcode before drawing'
+ );
+ }
+ $this->validateText($value);
+ }
+
+ /**
+ * Check the ratio between the thick and the thin bar
+ * @param int $min
+ * @param int $max
+ * @return void
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ protected function checkRatio($min = 2, $max = 3)
+ {
+ $ratio = $this->barThickWidth / $this->barThinWidth;
+ if (!($ratio >= $min && $ratio <= $max)) {
+ throw new Exception\OutOfRangeException(sprintf(
+ 'Ratio thick/thin bar must be between %0.1f and %0.1f (actual %0.3f)',
+ $min,
+ $max,
+ $ratio
+ ));
+ }
+ }
+
+ /**
+ * Drawing with an angle is just allow TTF font
+ * @return void
+ * @throws \Zend\Barcode\Object\Exception\ExceptionInterface
+ */
+ protected function checkFontAndOrientation()
+ {
+ if (is_numeric($this->font) && $this->orientation != 0) {
+ throw new Exception\RuntimeException(
+ 'Only drawing with TTF font allow orientation of the barcode.'
+ );
+ }
+ }
+
+ /**
+ * Width of the result image
+ * (before any rotation)
+ * @return int
+ */
+ protected function calculateWidth()
+ {
+ return (int) $this->withBorder
+ + $this->calculateBarcodeWidth()
+ + (int) $this->withBorder;
+ }
+
+ /**
+ * Calculate the width of the barcode
+ * @return int
+ */
+ abstract protected function calculateBarcodeWidth();
+
+ /**
+ * Height of the result object
+ * @return int
+ */
+ protected function calculateHeight()
+ {
+ return (int) $this->withBorder * 2
+ + $this->calculateBarcodeHeight()
+ + (int) $this->withBorder * 2;
+ }
+
+ /**
+ * Height of the barcode
+ * @return int
+ */
+ protected function calculateBarcodeHeight()
+ {
+ $textHeight = 0;
+ $extraHeight = 0;
+ if ($this->drawText) {
+ $textHeight += $this->fontSize;
+ $extraHeight = 2;
+ }
+ return ($this->barHeight + $textHeight) * $this->factor + $extraHeight;
+ }
+
+ /**
+ * Get height of the result object
+ * @param bool $recalculate
+ * @return int
+ */
+ public function getHeight($recalculate = false)
+ {
+ if ($this->height === null || $recalculate) {
+ $this->height =
+ abs($this->calculateHeight() * cos($this->orientation / 180 * pi()))
+ + abs($this->calculateWidth() * sin($this->orientation / 180 * pi()));
+ }
+ return $this->height;
+ }
+
+ /**
+ * Get width of the result object
+ * @param bool $recalculate
+ * @return int
+ */
+ public function getWidth($recalculate = false)
+ {
+ if ($this->width === null || $recalculate) {
+ $this->width =
+ abs($this->calculateWidth() * cos($this->orientation / 180 * pi()))
+ + abs($this->calculateHeight() * sin($this->orientation / 180 * pi()));
+ }
+ return $this->width;
+ }
+
+ /**
+ * Calculate the offset from the left of the object
+ * if an orientation is activated
+ * @param bool $recalculate
+ * @return float
+ */
+ public function getOffsetLeft($recalculate = false)
+ {
+ if ($this->offsetLeft === null || $recalculate) {
+ $this->offsetLeft = - min(array(
+ 0 * cos(
+ $this->orientation / 180 * pi()) - 0 * sin(
+ $this->orientation / 180 * pi()),
+ 0 * cos(
+ $this->orientation / 180 * pi()) - $this->calculateBarcodeHeight() * sin(
+ $this->orientation / 180 * pi()),
+ $this->calculateBarcodeWidth() * cos(
+ $this->orientation / 180 * pi()) - $this->calculateBarcodeHeight() * sin(
+ $this->orientation / 180 * pi()),
+ $this->calculateBarcodeWidth() * cos(
+ $this->orientation / 180 * pi()) - 0 * sin(
+ $this->orientation / 180 * pi()),
+ ));
+ }
+ return $this->offsetLeft;
+ }
+
+ /**
+ * Calculate the offset from the top of the object
+ * if an orientation is activated
+ * @param bool $recalculate
+ * @return float
+ */
+ public function getOffsetTop($recalculate = false)
+ {
+ if ($this->offsetTop === null || $recalculate) {
+ $this->offsetTop = - min(array(
+ 0 * cos(
+ $this->orientation / 180 * pi()) + 0 * sin(
+ $this->orientation / 180 * pi()),
+ $this->calculateBarcodeHeight() * cos(
+ $this->orientation / 180 * pi()) + 0 * sin(
+ $this->orientation / 180 * pi()),
+ $this->calculateBarcodeHeight() * cos(
+ $this->orientation / 180 * pi()) + $this->calculateBarcodeWidth() * sin(
+ $this->orientation / 180 * pi()),
+ 0 * cos(
+ $this->orientation / 180 * pi()) + $this->calculateBarcodeWidth() * sin(
+ $this->orientation / 180 * pi()),
+ ));
+ }
+ return $this->offsetTop;
+ }
+
+ /**
+ * Apply rotation on a point in X/Y dimensions
+ * @param float $x1 x-position before rotation
+ * @param float $y1 y-position before rotation
+ * @return array Array of two elements corresponding to the new XY point
+ */
+ protected function rotate($x1, $y1)
+ {
+ $x2 = $x1 * cos($this->orientation / 180 * pi())
+ - $y1 * sin($this->orientation / 180 * pi())
+ + $this->getOffsetLeft();
+ $y2 = $y1 * cos($this->orientation / 180 * pi())
+ + $x1 * sin($this->orientation / 180 * pi())
+ + $this->getOffsetTop();
+ return array(intval($x2), intval($y2));
+ }
+
+ /**
+ * Complete drawing of the barcode
+ * @return array Table of instructions
+ */
+ public function draw()
+ {
+ $this->checkParams();
+ $this->drawBarcode();
+ $this->drawBorder();
+ $this->drawText();
+ return $this->getInstructions();
+ }
+
+ /**
+ * Draw the barcode
+ * @return void
+ */
+ protected function drawBarcode()
+ {
+ $barcodeTable = $this->prepareBarcode();
+
+ $this->preDrawBarcode();
+
+ $xpos = (int) $this->withBorder;
+ $ypos = (int) $this->withBorder;
+
+ $point1 = $this->rotate(0, 0);
+ $point2 = $this->rotate(0, $this->calculateHeight() - 1);
+ $point3 = $this->rotate(
+ $this->calculateWidth() - 1,
+ $this->calculateHeight() - 1
+ );
+ $point4 = $this->rotate($this->calculateWidth() - 1, 0);
+
+ $this->addPolygon(array(
+ $point1,
+ $point2,
+ $point3,
+ $point4
+ ), $this->backgroundColor);
+
+ $xpos += $this->getQuietZone();
+ $barLength = $this->barHeight * $this->factor;
+
+ foreach ($barcodeTable as $bar) {
+ $width = $bar[1] * $this->factor;
+ if ($bar[0]) {
+ $point1 = $this->rotate($xpos, $ypos + $bar[2] * $barLength);
+ $point2 = $this->rotate($xpos, $ypos + $bar[3] * $barLength);
+ $point3 = $this->rotate(
+ $xpos + $width - 1,
+ $ypos + $bar[3] * $barLength
+ );
+ $point4 = $this->rotate(
+ $xpos + $width - 1,
+ $ypos + $bar[2] * $barLength
+ );
+ $this->addPolygon(array(
+ $point1,
+ $point2,
+ $point3,
+ $point4,
+ ));
+ }
+ $xpos += $width;
+ }
+
+ $this->postDrawBarcode();
+ }
+
+ /**
+ * Partial function to draw border
+ * @return void
+ */
+ protected function drawBorder()
+ {
+ if ($this->withBorder) {
+ $point1 = $this->rotate(0, 0);
+ $point2 = $this->rotate($this->calculateWidth() - 1, 0);
+ $point3 = $this->rotate(
+ $this->calculateWidth() - 1,
+ $this->calculateHeight() - 1
+ );
+ $point4 = $this->rotate(0, $this->calculateHeight() - 1);
+ $this->addPolygon(array(
+ $point1,
+ $point2,
+ $point3,
+ $point4,
+ $point1,
+ ), $this->foreColor, false);
+ }
+ }
+
+ /**
+ * Partial function to draw text
+ * @return void
+ */
+ protected function drawText()
+ {
+ if ($this->drawText) {
+ $text = $this->getTextToDisplay();
+ if ($this->stretchText) {
+ $textLength = strlen($text);
+ $space = ($this->calculateWidth() - 2 * $this->getQuietZone()) / $textLength;
+ for ($i = 0; $i < $textLength; $i ++) {
+ $leftPosition = $this->getQuietZone() + $space * ($i + 0.5);
+ $this->addText(
+ $text{$i},
+ $this->fontSize * $this->factor,
+ $this->rotate(
+ $leftPosition,
+ (int) $this->withBorder * 2
+ + $this->factor * ($this->barHeight + $this->fontSize) + 1
+ ),
+ $this->font,
+ $this->foreColor,
+ 'center',
+ - $this->orientation
+ );
+ }
+ } else {
+ $this->addText(
+ $text,
+ $this->fontSize * $this->factor,
+ $this->rotate(
+ $this->calculateWidth() / 2,
+ (int) $this->withBorder * 2
+ + $this->factor * ($this->barHeight + $this->fontSize) + 1
+ ),
+ $this->font,
+ $this->foreColor,
+ 'center',
+ - $this->orientation
+ );
+ }
+ }
+ }
+
+ /**
+ * Check for invalid characters
+ * @param string $value Text to be checked
+ * @return void
+ */
+ public function validateText($value)
+ {
+ $this->validateSpecificText($value);
+ }
+
+ /**
+ * Standard validation for most of barcode objects
+ * @param string $value
+ * @param array $options
+ */
+ protected function validateSpecificText($value, $options = array())
+ {
+ $validatorName = (isset($options['validator'])) ? $options['validator'] : $this->getType();
+
+ $validator = new BarcodeValidator(array(
+ 'adapter' => $validatorName,
+ 'usechecksum' => false,
+ ));
+
+ $checksumCharacter = '';
+ $withChecksum = false;
+ if ($this->mandatoryChecksum) {
+ $checksumCharacter = $this->substituteChecksumCharacter;
+ $withChecksum = true;
+ }
+
+ $value = $this->addLeadingZeros($value, $withChecksum) . $checksumCharacter;
+
+ if (!$validator->isValid($value)) {
+ $message = implode("\n", $validator->getMessages());
+ throw new Exception\BarcodeValidationException($message);
+ }
+ }
+
+ /**
+ * Each child must prepare the barcode and return
+ * a table like array(
+ * 0 => array(
+ * 0 => int (visible(black) or not(white))
+ * 1 => int (width of the bar)
+ * 2 => float (0->1 position from the top of the beginning of the bar in %)
+ * 3 => float (0->1 position from the top of the end of the bar in %)
+ * ),
+ * 1 => ...
+ * )
+ *
+ * @return array
+ */
+ abstract protected function prepareBarcode();
+
+ /**
+ * Checking of parameters after all settings
+ *
+ * @return void
+ */
+ abstract protected function checkSpecificParams();
+
+ /**
+ * Allow each child to draw something else
+ *
+ * @return void
+ */
+ protected function preDrawBarcode()
+ {
+ }
+
+ /**
+ * Allow each child to draw something else
+ * (ex: bearer bars in interleaved 2 of 5 code)
+ *
+ * @return void
+ */
+ protected function postDrawBarcode()
+ {
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Codabar.php zendframework-2.2.6/library/Zend/Barcode/Object/Codabar.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Codabar.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Codabar.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,75 @@
+ "101010011", '1' => "101011001", '2' => "101001011",
+ '3' => "110010101", '4' => "101101001", '5' => "110101001",
+ '6' => "100101011", '7' => "100101101", '8' => "100110101",
+ '9' => "110100101", '-' => "101001101", '$' => "101100101",
+ ':' => "1101011011", '/' => "1101101011", '.' => "1101101101",
+ '+' => "1011011011", 'A' => "1011001001", 'B' => "1010010011",
+ 'C' => "1001001011", 'D' => "1010011001"
+ );
+
+ /**
+ * Width of the barcode (in pixels)
+ * @return int
+ */
+ protected function calculateBarcodeWidth()
+ {
+ $quietZone = $this->getQuietZone();
+ $encodedData = 0;
+ $barcodeChar = str_split($this->getText());
+ if (count($barcodeChar) > 1) {
+ foreach ($barcodeChar as $c) {
+ $encodedData += ((strlen($this->codingMap[$c]) + 1) * $this->barThinWidth) * $this->factor;
+ }
+ }
+ $encodedData -= (1 * $this->barThinWidth * $this->factor);
+ return $quietZone + $encodedData + $quietZone;
+ }
+
+ /**
+ * Partial check of Codabar barcode
+ * @return void
+ */
+ protected function checkSpecificParams()
+ {}
+
+ /**
+ * Prepare array to draw barcode
+ * @return array
+ */
+ protected function prepareBarcode()
+ {
+ $text = str_split($this->getText());
+ foreach ($text as $char) {
+ $barcodeChar = str_split($this->codingMap[$char]);
+ foreach ($barcodeChar as $c) {
+ // visible, width, top, length
+ $barcodeTable[] = array($c, $this->barThinWidth, 0, 1);
+ }
+ $barcodeTable[] = array(0, $this->barThinWidth);
+ }
+ return $barcodeTable;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Code128.php zendframework-2.2.6/library/Zend/Barcode/Object/Code128.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Code128.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Code128.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,312 @@
+ "11011001100", 1 => "11001101100", 2 => "11001100110",
+ 3 => "10010011000", 4 => "10010001100", 5 => "10001001100",
+ 6 => "10011001000", 7 => "10011000100", 8 => "10001100100",
+ 9 => "11001001000", 10 => "11001000100", 11 => "11000100100",
+ 12 => "10110011100", 13 => "10011011100", 14 => "10011001110",
+ 15 => "10111001100", 16 => "10011101100", 17 => "10011100110",
+ 18 => "11001110010", 19 => "11001011100", 20 => "11001001110",
+ 21 => "11011100100", 22 => "11001110100", 23 => "11101101110",
+ 24 => "11101001100", 25 => "11100101100", 26 => "11100100110",
+ 27 => "11101100100", 28 => "11100110100", 29 => "11100110010",
+ 30 => "11011011000", 31 => "11011000110", 32 => "11000110110",
+ 33 => "10100011000", 34 => "10001011000", 35 => "10001000110",
+ 36 => "10110001000", 37 => "10001101000", 38 => "10001100010",
+ 39 => "11010001000", 40 => "11000101000", 41 => "11000100010",
+ 42 => "10110111000", 43 => "10110001110", 44 => "10001101110",
+ 45 => "10111011000", 46 => "10111000110", 47 => "10001110110",
+ 48 => "11101110110", 49 => "11010001110", 50 => "11000101110",
+ 51 => "11011101000", 52 => "11011100010", 53 => "11011101110",
+ 54 => "11101011000", 55 => "11101000110", 56 => "11100010110",
+ 57 => "11101101000", 58 => "11101100010", 59 => "11100011010",
+ 60 => "11101111010", 61 => "11001000010", 62 => "11110001010",
+ 63 => "10100110000", 64 => "10100001100", 65 => "10010110000",
+ 66 => "10010000110", 67 => "10000101100", 68 => "10000100110",
+ 69 => "10110010000", 70 => "10110000100", 71 => "10011010000",
+ 72 => "10011000010", 73 => "10000110100", 74 => "10000110010",
+ 75 => "11000010010", 76 => "11001010000", 77 => "11110111010",
+ 78 => "11000010100", 79 => "10001111010", 80 => "10100111100",
+ 81 => "10010111100", 82 => "10010011110", 83 => "10111100100",
+ 84 => "10011110100", 85 => "10011110010", 86 => "11110100100",
+ 87 => "11110010100", 88 => "11110010010", 89 => "11011011110",
+ 90 => "11011110110", 91 => "11110110110", 92 => "10101111000",
+ 93 => "10100011110", 94 => "10001011110", 95 => "10111101000",
+ 96 => "10111100010", 97 => "11110101000", 98 => "11110100010",
+ 99 => "10111011110", 100 => "10111101110", 101 => "11101011110",
+ 102 => "11110101110",
+ 103 => "11010000100", 104 => "11010010000", 105 => "11010011100",
+ 106 => "1100011101011");
+
+ /**
+ * Character sets ABC
+ * @var array
+ */
+ protected $charSets = array(
+ 'A' => array(
+ ' ', '!', '"', '#', '$', '%', '&', "'",
+ '(', ')', '*', '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', ':', ';', '<', '=', '>', '?',
+ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
+ 'FNC3', 'FNC2', 'SHIFT', 'Code C', 'Code B', 'FNC4', 'FNC1',
+ 'START A', 'START B', 'START C', 'STOP'),
+ 'B' => array(
+ ' ', '!', '"', '#', '$', '%', '&', "'",
+ '(', ')', '*', '+', ',', '-', '.', '/',
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', ':', ';', '<', '=', '>', '?',
+ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
+ 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+ '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
+ 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', '{', '|', '}', '~', 0x7F,
+ 'FNC3', 'FNC2', 'SHIFT', 'Code C', 'FNC4', 'Code A', 'FNC1',
+ 'START A', 'START B', 'START C', 'STOP',),
+ 'C' => array(
+ '00', '01', '02', '03', '04', '05', '06', '07', '08', '09',
+ '10', '11', '12', '13', '14', '15', '16', '17', '18', '19',
+ '20', '21', '22', '23', '24', '25', '26', '27', '28', '29',
+ '30', '31', '32', '33', '34', '35', '36', '37', '38', '39',
+ '40', '41', '42', '43', '44', '45', '46', '47', '48', '49',
+ '50', '51', '52', '53', '54', '55', '56', '57', '58', '59',
+ '60', '61', '62', '63', '64', '65', '66', '67', '68', '69',
+ '70', '71', '72', '73', '74', '75', '76', '77', '78', '79',
+ '80', '81', '82', '83', '84', '85', '86', '87', '88', '89',
+ '90', '91', '92', '93', '94', '95', '96', '97', '98', '99',
+ 'Code B', 'Code A', 'FNC1', 'START A', 'START B', 'START C', 'STOP'));
+
+ /**
+ * Width of the barcode (in pixels)
+ * @return int
+ */
+ protected function calculateBarcodeWidth()
+ {
+ $quietZone = $this->getQuietZone();
+ // Each characters contain 11 bars...
+ $characterLength = 11 * $this->barThinWidth * $this->factor;
+ $convertedChars = count($this->convertToBarcodeChars($this->getText()));
+ if ($this->withChecksum) {
+ $convertedChars++;
+ }
+ $encodedData = $convertedChars * $characterLength;
+ // ...except the STOP character (13)
+ $encodedData += $characterLength + 2 * $this->barThinWidth * $this->factor;
+ $width = $quietZone + $encodedData + $quietZone;
+ return $width;
+ }
+
+ /**
+ * Partial check of code128 barcode
+ * @return void
+ */
+ protected function checkSpecificParams()
+ {
+ }
+
+ /**
+ * Prepare array to draw barcode
+ * @return array
+ */
+ protected function prepareBarcode()
+ {
+ $barcodeTable = array();
+
+ $convertedChars = $this->convertToBarcodeChars($this->getText());
+
+ if ($this->withChecksum) {
+ $convertedChars[] = $this->getChecksum($this->getText());
+ }
+
+ // STOP CHARACTER
+ $convertedChars[] = 106;
+
+ foreach ($convertedChars as $barcodeChar) {
+ $barcodePattern = $this->codingMap[$barcodeChar];
+ foreach (str_split($barcodePattern) as $c) {
+ $barcodeTable[] = array($c, $this->barThinWidth, 0, 1);
+ }
+ }
+ return $barcodeTable;
+ }
+
+ /**
+ * Checks if the next $length chars of $string starting at $pos are numeric.
+ * Returns false if the end of the string is reached.
+ * @param string $string String to search
+ * @param int $pos Starting position
+ * @param int $length Length to search
+ * @return bool
+ */
+ protected static function _isDigit($string, $pos, $length = 2)
+ {
+ if ($pos + $length > strlen($string)) {
+ return false;
+ }
+
+ for ($i = $pos; $i < $pos + $length; $i++) {
+ if (!is_numeric($string[$i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Convert string to barcode string
+ * @param string $string
+ * @return array
+ */
+ protected function convertToBarcodeChars($string)
+ {
+ $string = (string) $string;
+ if (!strlen($string)) {
+ return array();
+ }
+
+ if (isset($this->convertedText[md5($string)])) {
+ return $this->convertedText[md5($string)];
+ }
+
+ $currentCharset = null;
+ $result = array();
+
+ $strlen = strlen($string);
+ for ($pos = 0; $pos < $strlen; $pos++) {
+ $char = $string[$pos];
+ $code = null;
+
+ if (static::_isDigit($string, $pos, 4) && $currentCharset != 'C'
+ || static::_isDigit($string, $pos, 2) && $currentCharset == 'C') {
+ /**
+ * Switch to C if the next 4 chars are numeric or stay C if the next 2
+ * chars are numeric
+ */
+ if ($currentCharset != 'C') {
+ if ($pos == 0) {
+ $code = array_search("START C", $this->charSets['C']);
+ } else {
+ $code = array_search("Code C", $this->charSets[$currentCharset]);
+ }
+ $result[] = $code;
+ $currentCharset = 'C';
+ }
+ } elseif (in_array($char, $this->charSets['B']) && $currentCharset != 'B'
+ && !(in_array($char, $this->charSets['A']) && $currentCharset == 'A')) {
+ /**
+ * Switch to B as B contains the char and B is not the current charset.
+ */
+ if ($pos == 0) {
+ $code = array_search("START B", $this->charSets['B']);
+ } else {
+ $code = array_search("Code B", $this->charSets[$currentCharset]);
+ }
+ $result[] = $code;
+ $currentCharset = 'B';
+ } elseif (array_key_exists($char, $this->charSets['A']) && $currentCharset != 'A'
+ && !(array_key_exists($char, $this->charSets['B']) && $currentCharset == 'B')) {
+ /**
+ * Switch to C as C contains the char and C is not the current charset.
+ */
+ if ($pos == 0) {
+ $code = array_search("START A", $this->charSets['A']);
+ } else {
+ $code =array_search("Code A", $this->charSets[$currentCharset]);
+ }
+ $result[] = $code;
+ $currentCharset = 'A';
+ }
+
+ if ($currentCharset == 'C') {
+ $code = array_search(substr($string, $pos, 2), $this->charSets['C']);
+ $pos++; //Two chars from input
+ } else {
+ $code = array_search($string[$pos], $this->charSets[$currentCharset]);
+ }
+ $result[] = $code;
+ }
+
+ $this->convertedText[md5($string)] = $result;
+ return $result;
+ }
+
+ /**
+ * Set text to encode
+ * @param string $value
+ * @return Code128
+ */
+ public function setText($value)
+ {
+ $this->text = $value;
+ return $this;
+ }
+
+ /**
+ * Retrieve text to encode
+ * @return string
+ */
+ public function getText()
+ {
+ return $this->text;
+ }
+
+ /**
+ * Get barcode checksum
+ *
+ * @param string $text
+ * @return int
+ */
+ public function getChecksum($text)
+ {
+ $tableOfChars = $this->convertToBarcodeChars($text);
+
+ $sum = $tableOfChars[0];
+ unset($tableOfChars[0]);
+
+ $k = 1;
+ foreach ($tableOfChars as $char) {
+ $sum += ($k++) * $char;
+ }
+
+ $checksum = $sum % 103;
+
+ return $checksum;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Code25interleaved.php zendframework-2.2.6/library/Zend/Barcode/Object/Code25interleaved.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Code25interleaved.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Code25interleaved.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,87 +1,65 @@
_barcodeLength = 'even';
+ $this->barcodeLength = 'even';
}
/**
* Activate/deactivate drawing of bearer bars
- * @param boolean $value
- * @return Zend_Barcode_Object_Int25
+ * @param bool $value
+ * @return Code25
*/
public function setWithBearerBars($value)
{
- $this->_withBearerBars = (bool) $value;
+ $this->withBearerBars = (bool) $value;
return $this;
}
/**
* Retrieve if bearer bars are enabled
- * @return boolean
+ * @return bool
*/
public function getWithBearerBars()
{
- return $this->_withBearerBars;
+ return $this->withBearerBars;
}
/**
* Width of the barcode (in pixels)
- * @return integer
+ * @return int
*/
- protected function _calculateBarcodeWidth()
+ protected function calculateBarcodeWidth()
{
$quietZone = $this->getQuietZone();
- $startCharacter = (4 * $this->_barThinWidth) * $this->_factor;
- $characterLength = (3 * $this->_barThinWidth + 2 * $this->_barThickWidth) * $this->_factor;
+ $startCharacter = (4 * $this->barThinWidth) * $this->factor;
+ $characterLength = (3 * $this->barThinWidth + 2 * $this->barThickWidth) * $this->factor;
$encodedData = strlen($this->getText()) * $characterLength;
- $stopCharacter = ($this->_barThickWidth + 2 * $this->_barThinWidth) * $this->_factor;
+ $stopCharacter = ($this->barThickWidth + 2 * $this->barThinWidth) * $this->factor;
return $quietZone + $startCharacter + $encodedData + $stopCharacter + $quietZone;
}
@@ -89,45 +67,45 @@
* Prepare array to draw barcode
* @return array
*/
- protected function _prepareBarcode()
+ protected function prepareBarcode()
{
- if ($this->_withBearerBars) {
- $this->_withBorder = false;
+ if ($this->withBearerBars) {
+ $this->withBorder = false;
}
// Start character (0000)
- $barcodeTable[] = array(1, $this->_barThinWidth, 0, 1);
- $barcodeTable[] = array(0, $this->_barThinWidth, 0, 1);
- $barcodeTable[] = array(1, $this->_barThinWidth, 0, 1);
- $barcodeTable[] = array(0, $this->_barThinWidth, 0, 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
// Encoded $text
$text = $this->getText();
- for ($i = 0; $i < strlen($text); $i += 2) { // Draw 2 chars at a time
+ for ($i = 0, $len = strlen($text); $i < $len; $i += 2) { // Draw 2 chars at a time
$char1 = substr($text, $i, 1);
$char2 = substr($text, $i + 1, 1);
// Interleave
for ($ibar = 0; $ibar < 5; $ibar ++) {
// Draws char1 bar (fore color)
- $barWidth = (substr($this->_codingMap[$char1], $ibar, 1))
- ? $this->_barThickWidth
- : $this->_barThinWidth;
+ $barWidth = (substr($this->codingMap[$char1], $ibar, 1))
+ ? $this->barThickWidth
+ : $this->barThinWidth;
$barcodeTable[] = array(1, $barWidth, 0, 1);
// Left space corresponding to char2 (background color)
- $barWidth = (substr($this->_codingMap[$char2], $ibar, 1))
- ? $this->_barThickWidth
- : $this->_barThinWidth;
- $barcodeTable[] = array(0, $barWidth, 0 , 1);
+ $barWidth = (substr($this->codingMap[$char2], $ibar, 1))
+ ? $this->barThickWidth
+ : $this->barThinWidth;
+ $barcodeTable[] = array(0, $barWidth, 0, 1);
}
}
// Stop character (100)
- $barcodeTable[] = array(1 , $this->_barThickWidth, 0, 1);
- $barcodeTable[] = array(0 , $this->_barThinWidth, 0, 1);
- $barcodeTable[] = array(1 , $this->_barThinWidth, 0, 1);
+ $barcodeTable[] = array(1, $this->barThickWidth, 0, 1);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
return $barcodeTable;
}
@@ -136,40 +114,40 @@
*
* @return void
*/
- protected function _postDrawBarcode()
+ protected function postDrawBarcode()
{
- if (!$this->_withBearerBars) {
+ if (!$this->withBearerBars) {
return;
}
- $width = $this->_barThickWidth * $this->_factor;
- $point1 = $this->_rotate(-1, -1);
- $point2 = $this->_rotate($this->_calculateWidth() - 1, -1);
- $point3 = $this->_rotate($this->_calculateWidth() - 1, $width - 1);
- $point4 = $this->_rotate(-1, $width - 1);
- $this->_addPolygon(array(
+ $width = $this->barThickWidth * $this->factor;
+ $point1 = $this->rotate(-1, -1);
+ $point2 = $this->rotate($this->calculateWidth() - 1, -1);
+ $point3 = $this->rotate($this->calculateWidth() - 1, $width - 1);
+ $point4 = $this->rotate(-1, $width - 1);
+ $this->addPolygon(array(
$point1,
$point2,
$point3,
$point4,
));
- $point1 = $this->_rotate(
+ $point1 = $this->rotate(
0,
- 0 + $this->_barHeight * $this->_factor - 1
+ 0 + $this->barHeight * $this->factor - 1
);
- $point2 = $this->_rotate(
- $this->_calculateWidth() - 1,
- 0 + $this->_barHeight * $this->_factor - 1
+ $point2 = $this->rotate(
+ $this->calculateWidth() - 1,
+ 0 + $this->barHeight * $this->factor - 1
);
- $point3 = $this->_rotate(
- $this->_calculateWidth() - 1,
- 0 + $this->_barHeight * $this->_factor - $width
+ $point3 = $this->rotate(
+ $this->calculateWidth() - 1,
+ 0 + $this->barHeight * $this->factor - $width
);
- $point4 = $this->_rotate(
+ $point4 = $this->rotate(
0,
- 0 + $this->_barHeight * $this->_factor - $width
+ 0 + $this->barHeight * $this->factor - $width
);
- $this->_addPolygon(array(
+ $this->addPolygon(array(
$point1,
$point2,
$point3,
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Code25.php zendframework-2.2.6/library/Zend/Barcode/Object/Code25.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Code25.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Code25.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,44 +1,18 @@
'00110',
'1' => '10001',
'2' => '01001',
@@ -61,16 +35,16 @@
/**
* Width of the barcode (in pixels)
- * @return integer
+ * @return int
*/
- protected function _calculateBarcodeWidth()
+ protected function calculateBarcodeWidth()
{
$quietZone = $this->getQuietZone();
- $startCharacter = (2 * $this->_barThickWidth + 4 * $this->_barThinWidth) * $this->_factor;
- $characterLength = (3 * $this->_barThinWidth + 2 * $this->_barThickWidth + 5 * $this->_barThinWidth)
- * $this->_factor;
+ $startCharacter = (2 * $this->barThickWidth + 4 * $this->barThinWidth) * $this->factor;
+ $characterLength = (3 * $this->barThinWidth + 2 * $this->barThickWidth + 5 * $this->barThinWidth)
+ * $this->factor;
$encodedData = strlen($this->getText()) * $characterLength;
- $stopCharacter = (2 * $this->_barThickWidth + 4 * $this->_barThinWidth) * $this->_factor;
+ $stopCharacter = (2 * $this->barThickWidth + 4 * $this->barThinWidth) * $this->factor;
return $quietZone + $startCharacter + $encodedData + $stopCharacter + $quietZone;
}
@@ -78,44 +52,44 @@
* Partial check of interleaved 2 of 5 barcode
* @return void
*/
- protected function _checkParams()
+ protected function checkSpecificParams()
{
- $this->_checkRatio();
+ $this->checkRatio();
}
/**
* Prepare array to draw barcode
* @return array
*/
- protected function _prepareBarcode()
+ protected function prepareBarcode()
{
$barcodeTable = array();
// Start character (30301)
- $barcodeTable[] = array(1 , $this->_barThickWidth , 0 , 1);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , 1);
- $barcodeTable[] = array(1 , $this->_barThickWidth , 0 , 1);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , 1);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , 1);
- $barcodeTable[] = array(0 , 1);
+ $barcodeTable[] = array(1, $this->barThickWidth, 0, 1);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(1, $this->barThickWidth, 0, 1);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(0, $this->barThinWidth);
$text = str_split($this->getText());
foreach ($text as $char) {
- $barcodeChar = str_split($this->_codingMap[$char]);
+ $barcodeChar = str_split($this->codingMap[$char]);
foreach ($barcodeChar as $c) {
/* visible, width, top, length */
- $width = $c ? $this->_barThickWidth : $this->_barThinWidth;
- $barcodeTable[] = array(1 , $width , 0 , 1);
- $barcodeTable[] = array(0 , 1);
+ $width = $c ? $this->barThickWidth : $this->barThinWidth;
+ $barcodeTable[] = array(1, $width, 0, 1);
+ $barcodeTable[] = array(0, $this->barThinWidth);
}
}
// Stop character (30103)
- $barcodeTable[] = array(1 , $this->_barThickWidth , 0 , 1);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , 1);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , 1);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , 1);
- $barcodeTable[] = array(1 , $this->_barThickWidth , 0 , 1);
+ $barcodeTable[] = array(1, $this->barThickWidth, 0, 1);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(1, $this->barThickWidth, 0, 1);
return $barcodeTable;
}
@@ -127,7 +101,7 @@
*/
public function getChecksum($text)
{
- $this->_checkText($text);
+ $this->checkText($text);
$factor = 3;
$checksum = 0;
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Code39.php zendframework-2.2.6/library/Zend/Barcode/Object/Code39.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Code39.php 2010-03-27 14:29:57.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Code39.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,50 +1,24 @@
'000110100',
'1' => '100100001',
'2' => '001100001',
@@ -95,24 +69,35 @@
* Partial check of Code39 barcode
* @return void
*/
- protected function _checkParams()
+ protected function checkSpecificParams()
{
- $this->_checkRatio();
+ $this->checkRatio();
}
/**
* Width of the barcode (in pixels)
* @return int
*/
- protected function _calculateBarcodeWidth()
+ protected function calculateBarcodeWidth()
{
$quietZone = $this->getQuietZone();
- $characterLength = (6 * $this->_barThinWidth + 3 * $this->_barThickWidth + 1) * $this->_factor;
- $encodedData = strlen($this->getText()) * $characterLength - $this->_factor;
+ $characterLength = (6 * $this->barThinWidth + 3 * $this->barThickWidth + 1) * $this->factor;
+ $encodedData = strlen($this->getText()) * $characterLength - $this->factor;
return $quietZone + $encodedData + $quietZone;
}
/**
+ * Set text to encode
+ * @param string $value
+ * @return Code39
+ */
+ public function setText($value)
+ {
+ $this->text = $value;
+ return $this;
+ }
+
+ /**
* Retrieve text to display
* @return string
*/
@@ -130,29 +115,29 @@
$text = parent::getTextToDisplay();
if (substr($text, 0, 1) != '*' && substr($text, -1) != '*') {
return '*' . $text . '*';
- } else {
- return $text;
}
+
+ return $text;
}
/**
* Prepare array to draw barcode
* @return array
*/
- protected function _prepareBarcode()
+ protected function prepareBarcode()
{
$text = str_split($this->getText());
$barcodeTable = array();
foreach ($text as $char) {
- $barcodeChar = str_split($this->_codingMap[$char]);
+ $barcodeChar = str_split($this->codingMap[$char]);
$visible = true;
foreach ($barcodeChar as $c) {
/* visible, width, top, length */
- $width = $c ? $this->_barThickWidth : $this->_barThinWidth;
+ $width = $c ? $this->barThickWidth : $this->barThinWidth;
$barcodeTable[] = array((int) $visible, $width, 0, 1);
$visible = ! $visible;
}
- $barcodeTable[] = array(0 , 1);
+ $barcodeTable[] = array(0, $this->barThinWidth);
}
return $barcodeTable;
}
@@ -165,9 +150,9 @@
*/
public function getChecksum($text)
{
- $this->_checkText($text);
+ $this->checkText($text);
$text = str_split($text);
- $charset = array_flip(array_keys($this->_codingMap));
+ $charset = array_flip(array_keys($this->codingMap));
$checksum = 0;
foreach ($text as $character) {
$checksum += $charset[$character];
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Ean13.php zendframework-2.2.6/library/Zend/Barcode/Object/Ean13.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Ean13.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Ean13.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,44 +1,18 @@
array(
0 => "0001101", 1 => "0011001", 2 => "0010011", 3 => "0111101", 4 => "0100011",
5 => "0110001", 6 => "0101111", 7 => "0111011", 8 => "0110111", 9 => "0001011"
@@ -61,40 +35,41 @@
5 => "1001110", 6 => "1010000", 7 => "1000100", 8 => "1001000", 9 => "1110100"
));
- protected $_parities = array(
- 0 => array('A','A','A','A','A','A'),
- 1 => array('A','A','B','A','B','B'),
- 2 => array('A','A','B','B','A','B'),
- 3 => array('A','A','B','B','B','A'),
- 4 => array('A','B','A','A','B','B'),
- 5 => array('A','B','B','A','A','B'),
- 6 => array('A','B','B','B','A','A'),
- 7 => array('A','B','A','B','A','B'),
- 8 => array('A','B','A','B','B','A'),
- 9 => array('A','B','B','A','B','A')
- );
+ protected $parities = array(
+ 0 => array('A','A','A','A','A','A'),
+ 1 => array('A','A','B','A','B','B'),
+ 2 => array('A','A','B','B','A','B'),
+ 3 => array('A','A','B','B','B','A'),
+ 4 => array('A','B','A','A','B','B'),
+ 5 => array('A','B','B','A','A','B'),
+ 6 => array('A','B','B','B','A','A'),
+ 7 => array('A','B','A','B','A','B'),
+ 8 => array('A','B','A','B','B','A'),
+ 9 => array('A','B','B','A','B','A')
+ );
/**
* Default options for Postnet barcode
* @return void
*/
- protected function _getDefaultOptions()
+ protected function getDefaultOptions()
{
- $this->_barcodeLength = 13;
- $this->_mandatoryChecksum = true;
+ $this->barcodeLength = 13;
+ $this->mandatoryChecksum = true;
+ $this->mandatoryQuietZones = true;
}
/**
* Width of the barcode (in pixels)
- * @return integer
+ * @return int
*/
- protected function _calculateBarcodeWidth()
+ protected function calculateBarcodeWidth()
{
$quietZone = $this->getQuietZone();
- $startCharacter = (3 * $this->_barThinWidth) * $this->_factor;
- $middleCharacter = (5 * $this->_barThinWidth) * $this->_factor;
- $stopCharacter = (3 * $this->_barThinWidth) * $this->_factor;
- $encodedData = (7 * $this->_barThinWidth) * $this->_factor * 12;
+ $startCharacter = (3 * $this->barThinWidth) * $this->factor;
+ $middleCharacter = (5 * $this->barThinWidth) * $this->factor;
+ $stopCharacter = (3 * $this->barThinWidth) * $this->factor;
+ $encodedData = (7 * $this->barThinWidth) * $this->factor * 12;
return $quietZone + $startCharacter + $middleCharacter + $encodedData + $stopCharacter + $quietZone;
}
@@ -102,53 +77,53 @@
* Partial check of interleaved EAN/UPC barcode
* @return void
*/
- protected function _checkParams()
+ protected function checkSpecificParams()
{}
/**
* Prepare array to draw barcode
* @return array
*/
- protected function _prepareBarcode()
+ protected function prepareBarcode()
{
$barcodeTable = array();
- $height = ($this->_drawText) ? 1.1 : 1;
+ $height = ($this->drawText) ? 1.1 : 1;
// Start character (101)
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
$textTable = str_split($this->getText());
- $parity = $this->_parities[$textTable[0]];
+ $parity = $this->parities[$textTable[0]];
// First part
for ($i = 1; $i < 7; $i++) {
- $bars = str_split($this->_codingMap[$parity[$i - 1]][$textTable[$i]]);
+ $bars = str_split($this->codingMap[$parity[$i - 1]][$textTable[$i]]);
foreach ($bars as $b) {
- $barcodeTable[] = array($b , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array($b, $this->barThinWidth, 0, 1);
}
}
// Middle character (01010)
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
// Second part
for ($i = 7; $i < 13; $i++) {
- $bars = str_split($this->_codingMap['C'][$textTable[$i]]);
+ $bars = str_split($this->codingMap['C'][$textTable[$i]]);
foreach ($bars as $b) {
- $barcodeTable[] = array($b , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array($b, $this->barThinWidth, 0, 1);
}
}
// Stop character (101)
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
return $barcodeTable;
}
@@ -160,7 +135,7 @@
*/
public function getChecksum($text)
{
- $this->_checkText($text);
+ $this->checkText($text);
$factor = 3;
$checksum = 0;
@@ -178,34 +153,34 @@
* Partial function to draw text
* @return void
*/
- protected function _drawText()
+ protected function drawText()
{
- if (get_class($this) == 'Zend_Barcode_Object_Ean13') {
- $this->_drawEan13Text();
+ if (get_class($this) == 'Zend\Barcode\Object\Ean13') {
+ $this->drawEan13Text();
} else {
- parent::_drawText();
+ parent::drawText();
}
}
- protected function _drawEan13Text()
+ protected function drawEan13Text()
{
- if ($this->_drawText) {
+ if ($this->drawText) {
$text = $this->getTextToDisplay();
- $characterWidth = (7 * $this->_barThinWidth) * $this->_factor;
+ $characterWidth = (7 * $this->barThinWidth) * $this->factor;
$leftPosition = $this->getQuietZone() - $characterWidth;
- for ($i = 0; $i < $this->_barcodeLength; $i ++) {
- $this->_addText(
+ for ($i = 0; $i < $this->barcodeLength; $i ++) {
+ $this->addText(
$text{$i},
- $this->_fontSize * $this->_factor,
- $this->_rotate(
+ $this->fontSize * $this->factor,
+ $this->rotate(
$leftPosition,
- (int) $this->_withBorder * 2
- + $this->_factor * ($this->_barHeight + $this->_fontSize) + 1
+ (int) $this->withBorder * 2
+ + $this->factor * ($this->barHeight + $this->fontSize) + 1
),
- $this->_font,
- $this->_foreColor,
+ $this->font,
+ $this->foreColor,
'left',
- - $this->_orientation
+ - $this->orientation
);
switch ($i) {
case 0:
@@ -217,7 +192,7 @@
default:
$factor = 0;
}
- $leftPosition = $leftPosition + $characterWidth + ($factor * $this->_barThinWidth * $this->_factor);
+ $leftPosition = $leftPosition + $characterWidth + ($factor * $this->barThinWidth * $this->factor);
}
}
}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Ean2.php zendframework-2.2.6/library/Zend/Barcode/Object/Ean2.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Ean2.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Ean2.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,47 +1,21 @@
array('A','A'),
1 => array('A','B'),
2 => array('B','A'),
@@ -52,14 +26,14 @@
* Default options for Ean2 barcode
* @return void
*/
- protected function _getDefaultOptions()
+ protected function getDefaultOptions()
{
- $this->_barcodeLength = 2;
+ $this->barcodeLength = 2;
}
- protected function _getParity($i)
+ protected function getParity($i)
{
$modulo = $this->getText() % 4;
- return $this->_parities[$modulo][$i];
+ return $this->parities[$modulo][$i];
}
}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Ean5.php zendframework-2.2.6/library/Zend/Barcode/Object/Ean5.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Ean5.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Ean5.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,47 +1,21 @@
array('B','B','A','A','A'),
1 => array('B','A','B','A','A'),
2 => array('B','A','A','B','A'),
@@ -58,54 +32,54 @@
* Default options for Ean5 barcode
* @return void
*/
- protected function _getDefaultOptions()
+ protected function getDefaultOptions()
{
- $this->_barcodeLength = 5;
+ $this->barcodeLength = 5;
}
/**
* Width of the barcode (in pixels)
- * @return integer
+ * @return int
*/
- protected function _calculateBarcodeWidth()
+ protected function calculateBarcodeWidth()
{
$quietZone = $this->getQuietZone();
- $startCharacter = (5 * $this->_barThinWidth) * $this->_factor;
- $middleCharacter = (2 * $this->_barThinWidth) * $this->_factor;
- $encodedData = (7 * $this->_barThinWidth) * $this->_factor;
- return $quietZone + $startCharacter + ($this->_barcodeLength - 1) * $middleCharacter + $this->_barcodeLength * $encodedData + $quietZone;
+ $startCharacter = (5 * $this->barThinWidth) * $this->factor;
+ $middleCharacter = (2 * $this->barThinWidth) * $this->factor;
+ $encodedData = (7 * $this->barThinWidth) * $this->factor;
+ return $quietZone + $startCharacter + ($this->barcodeLength - 1) * $middleCharacter + $this->barcodeLength * $encodedData + $quietZone;
}
/**
* Prepare array to draw barcode
* @return array
*/
- protected function _prepareBarcode()
+ protected function prepareBarcode()
{
$barcodeTable = array();
// Start character (01011)
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , 1);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , 1);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , 1);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , 1);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
$firstCharacter = true;
$textTable = str_split($this->getText());
// Characters
- for ($i = 0; $i < $this->_barcodeLength; $i++) {
+ for ($i = 0; $i < $this->barcodeLength; $i++) {
if ($firstCharacter) {
$firstCharacter = false;
} else {
// Intermediate character (01)
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , 1);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
}
- $bars = str_split($this->_codingMap[$this->_getParity($i)][$textTable[$i]]);
+ $bars = str_split($this->codingMap[$this->getParity($i)][$textTable[$i]]);
foreach ($bars as $b) {
- $barcodeTable[] = array($b , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array($b, $this->barThinWidth, 0, 1);
}
}
@@ -120,20 +94,20 @@
*/
public function getChecksum($text)
{
- $this->_checkText($text);
+ $this->checkText($text);
$checksum = 0;
- for ($i = 0 ; $i < $this->_barcodeLength; $i ++) {
+ for ($i = 0; $i < $this->barcodeLength; $i ++) {
$checksum += intval($text{$i}) * ($i % 2 ? 9 : 3);
}
return ($checksum % 10);
}
- protected function _getParity($i)
+ protected function getParity($i)
{
$checksum = $this->getChecksum($this->getText());
- return $this->_parities[$checksum][$i];
+ return $this->parities[$checksum][$i];
}
/**
@@ -142,6 +116,6 @@
*/
public function getText()
{
- return $this->_addLeadingZeros($this->_text);
+ return $this->addLeadingZeros($this->text);
}
}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Ean8.php zendframework-2.2.6/library/Zend/Barcode/Object/Ean8.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Ean8.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Ean8.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,112 +1,89 @@
_barcodeLength = 8;
- $this->_mandatoryChecksum = true;
+ $this->barcodeLength = 8;
+ $this->mandatoryChecksum = true;
}
/**
* Width of the barcode (in pixels)
- * @return integer
+ * @return int
*/
- protected function _calculateBarcodeWidth()
+ protected function calculateBarcodeWidth()
{
$quietZone = $this->getQuietZone();
- $startCharacter = (3 * $this->_barThinWidth) * $this->_factor;
- $stopCharacter = (3 * $this->_barThinWidth) * $this->_factor;
- $encodedData = (7 * $this->_barThinWidth) * $this->_factor * 8;
- return $quietZone + $startCharacter + $encodedData + $stopCharacter + $quietZone;
+ $startCharacter = (3 * $this->barThinWidth) * $this->factor;
+ $middleCharacter = (5 * $this->barThinWidth) * $this->factor;
+ $stopCharacter = (3 * $this->barThinWidth) * $this->factor;
+ $encodedData = (7 * $this->barThinWidth) * $this->factor * 8;
+ return $quietZone + $startCharacter + $middleCharacter + $encodedData + $stopCharacter + $quietZone;
}
/**
* Prepare array to draw barcode
* @return array
*/
- protected function _prepareBarcode()
+ protected function prepareBarcode()
{
$barcodeTable = array();
- $height = ($this->_drawText) ? 1.1 : 1;
+ $height = ($this->drawText) ? 1.1 : 1;
// Start character (101)
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
$textTable = str_split($this->getText());
// First part
for ($i = 0; $i < 4; $i++) {
- $bars = str_split($this->_codingMap['A'][$textTable[$i]]);
+ $bars = str_split($this->codingMap['A'][$textTable[$i]]);
foreach ($bars as $b) {
- $barcodeTable[] = array($b , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array($b, $this->barThinWidth, 0, 1);
}
}
// Middle character (01010)
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
// Second part
for ($i = 4; $i < 8; $i++) {
- $bars = str_split($this->_codingMap['C'][$textTable[$i]]);
+ $bars = str_split($this->codingMap['C'][$textTable[$i]]);
foreach ($bars as $b) {
- $barcodeTable[] = array($b , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array($b, $this->barThinWidth, 0, 1);
}
}
// Stop character (101)
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
return $barcodeTable;
}
@@ -114,25 +91,25 @@
* Partial function to draw text
* @return void
*/
- protected function _drawText()
+ protected function drawText()
{
- if ($this->_drawText) {
+ if ($this->drawText) {
$text = $this->getTextToDisplay();
- $characterWidth = (7 * $this->_barThinWidth) * $this->_factor;
- $leftPosition = $this->getQuietZone() + (3 * $this->_barThinWidth) * $this->_factor;
- for ($i = 0; $i < $this->_barcodeLength; $i ++) {
- $this->_addText(
+ $characterWidth = (7 * $this->barThinWidth) * $this->factor;
+ $leftPosition = $this->getQuietZone() + (3 * $this->barThinWidth) * $this->factor;
+ for ($i = 0; $i < $this->barcodeLength; $i ++) {
+ $this->addText(
$text{$i},
- $this->_fontSize * $this->_factor,
- $this->_rotate(
+ $this->fontSize * $this->factor,
+ $this->rotate(
$leftPosition,
- (int) $this->_withBorder * 2
- + $this->_factor * ($this->_barHeight + $this->_fontSize) + 1
+ (int) $this->withBorder * 2
+ + $this->factor * ($this->barHeight + $this->fontSize) + 1
),
- $this->_font,
- $this->_foreColor,
+ $this->font,
+ $this->foreColor,
'left',
- - $this->_orientation
+ - $this->orientation
);
switch ($i) {
case 3:
@@ -141,7 +118,7 @@
default:
$factor = 0;
}
- $leftPosition = $leftPosition + $characterWidth + ($factor * $this->_barThinWidth * $this->_factor);
+ $leftPosition = $leftPosition + $characterWidth + ($factor * $this->barThinWidth * $this->factor);
}
}
}
@@ -149,26 +126,23 @@
/**
* Particular validation for Ean8 barcode objects
* (to suppress checksum character substitution)
+ *
* @param string $value
* @param array $options
+ * @throws Exception\BarcodeValidationException
*/
- protected function _validateText($value, $options = array())
+ protected function validateSpecificText($value, $options = array())
{
- $validator = new Zend_Validate_Barcode(array(
+ $validator = new BarcodeValidator(array(
'adapter' => 'ean8',
'checksum' => false,
));
- $value = $this->_addLeadingZeros($value, true);
+ $value = $this->addLeadingZeros($value, true);
if (!$validator->isValid($value)) {
$message = implode("\n", $validator->getMessages());
-
- /**
- * @see Zend_Barcode_Object_Exception
- */
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception($message);
+ throw new Exception\BarcodeValidationException($message);
}
}
}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Error.php zendframework-2.2.6/library/Zend/Barcode/Object/Error.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Error.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Error.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,42 +1,23 @@
_instructions = array();
- $this->_addText('ERROR:', 10, array(5 , 18), $this->_font, 0, 'left');
- $this->_addText($this->_text, 10, array(5 , 32), $this->_font, 0, 'left');
- return $this->_instructions;
+ $this->instructions = array();
+ $this->addText('ERROR:', 10, array(5, 18), $this->font, 0, 'left');
+ $this->addText($this->text, 10, array(5, 32), $this->font, 0, 'left');
+ return $this->instructions;
}
/**
* For compatibility reason
* @return void
*/
- protected function _prepareBarcode()
+ protected function prepareBarcode()
{
}
@@ -86,7 +69,7 @@
* For compatibility reason
* @return void
*/
- protected function _checkParams()
+ protected function checkSpecificParams()
{
}
@@ -94,7 +77,7 @@
* For compatibility reason
* @return void
*/
- protected function _calculateBarcodeWidth()
+ protected function calculateBarcodeWidth()
{
}
}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Exception/BarcodeValidationException.php zendframework-2.2.6/library/Zend/Barcode/Object/Exception/BarcodeValidationException.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Exception/BarcodeValidationException.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Exception/BarcodeValidationException.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,17 @@
+_barcodeLength = 12;
- $this->_mandatoryChecksum = true;
+ $this->barcodeLength = 12;
+ $this->mandatoryChecksum = true;
}
/**
@@ -64,13 +38,13 @@
/**
* Check allowed characters
- * @param string $value
+ * @param string $value
* @return string
- * @throw Zend_Barcode_Object_Exception
+ * @throws Exception
*/
public function validateText($value)
{
- $this->_validateText($value, array('validator' => $this->getType()));
+ $this->validateSpecificText($value, array('validator' => $this->getType()));
}
/**
@@ -81,7 +55,7 @@
*/
public function getChecksum($text)
{
- $this->_checkText($text);
+ $this->checkText($text);
$checksum = 0;
for ($i = strlen($text); $i > 0; $i --) {
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Itf14.php zendframework-2.2.6/library/Zend/Barcode/Object/Itf14.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Itf14.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Itf14.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,49 +1,27 @@
_barcodeLength = 14;
- $this->_mandatoryChecksum = true;
+ $this->barcodeLength = 14;
+ $this->mandatoryChecksum = true;
}
}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Leitcode.php zendframework-2.2.6/library/Zend/Barcode/Object/Leitcode.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Leitcode.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Leitcode.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,54 +1,28 @@
_barcodeLength = 14;
- $this->_mandatoryChecksum = true;
+ $this->barcodeLength = 14;
+ $this->mandatoryChecksum = true;
}
/**
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/ObjectAbstract.php zendframework-2.2.6/library/Zend/Barcode/Object/ObjectAbstract.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/ObjectAbstract.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/ObjectAbstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,1281 +0,0 @@
-_getDefaultOptions();
- if (self::$_staticFont !== null) {
- $this->_font = self::$_staticFont;
- }
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- }
- if (is_array($options)) {
- $this->setOptions($options);
- }
- $this->_type = strtolower(substr(get_class($this), strlen($this->_barcodeNamespace) + 1));
- if ($this->_mandatoryChecksum) {
- $this->_withChecksum = true;
- $this->_withChecksumInText = true;
- }
- }
-
- /**
- * Set default options for particular object
- * @return void
- */
- protected function _getDefaultOptions()
- {
- }
-
- /**
- * Set barcode state from options array
- * @param array $options
- * @return Zend_Barcode_Object
- */
- public function setOptions($options)
- {
- foreach ($options as $key => $value) {
- $method = 'set' . $key;
- if (method_exists($this, $method)) {
- $this->$method($value);
- }
- }
- return $this;
- }
-
- /**
- * Set barcode state from config object
- * @param Zend_Config $config
- * @return Zend_Barcode_Object
- */
- public function setConfig(Zend_Config $config)
- {
- return $this->setOptions($config->toArray());
- }
-
- /**
- * Set barcode namespace for autoloading
- *
- * @param string $namespace
- * @return Zend_Barcode_Object
- */
- public function setBarcodeNamespace($namespace)
- {
- $this->_barcodeNamespace = $namespace;
- return $this;
- }
-
- /**
- * Retrieve barcode namespace
- *
- * @return string
- */
- public function getBarcodeNamespace()
- {
- return $this->_barcodeNamespace;
- }
-
- /**
- * Retrieve type of barcode
- * @return string
- */
- public function getType()
- {
- return $this->_type;
- }
-
- /**
- * Set height of the barcode bar
- * @param integer $value
- * @return Zend_Barcode_Object
- * @throw Zend_Barcode_Object_Exception
- */
- public function setBarHeight($value)
- {
- if (intval($value) <= 0) {
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception(
- 'Bar height must be greater than 0'
- );
- }
- $this->_barHeight = intval($value);
- return $this;
- }
-
- /**
- * Get height of the barcode bar
- * @return integer
- */
- public function getBarHeight()
- {
- return $this->_barHeight;
- }
-
- /**
- * Set thickness of thin bar
- * @param integer $value
- * @return Zend_Barcode_Object
- * @throw Zend_Barcode_Object_Exception
- */
- public function setBarThinWidth($value)
- {
- if (intval($value) <= 0) {
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception(
- 'Bar width must be greater than 0'
- );
- }
- $this->_barThinWidth = intval($value);
- return $this;
- }
-
- /**
- * Get thickness of thin bar
- * @return integer
- */
- public function getBarThinWidth()
- {
- return $this->_barThinWidth;
- }
-
- /**
- * Set thickness of thick bar
- * @param integer $value
- * @return Zend_Barcode_Object
- * @throw Zend_Barcode_Object_Exception
- */
- public function setBarThickWidth($value)
- {
- if (intval($value) <= 0) {
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception(
- 'Bar width must be greater than 0'
- );
- }
- $this->_barThickWidth = intval($value);
- return $this;
- }
-
- /**
- * Get thickness of thick bar
- * @return integer
- */
- public function getBarThickWidth()
- {
- return $this->_barThickWidth;
- }
-
- /**
- * Set factor applying to
- * thinBarWidth - thickBarWidth - barHeight - fontSize
- * @param integer $value
- * @return Zend_Barcode_Object
- * @throw Zend_Barcode_Object_Exception
- */
- public function setFactor($value)
- {
- if (floatval($value) <= 0) {
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception(
- 'Factor must be greater than 0'
- );
- }
- $this->_factor = floatval($value);
- return $this;
- }
-
- /**
- * Get factor applying to
- * thinBarWidth - thickBarWidth - barHeight - fontSize
- * @return integer
- */
- public function getFactor()
- {
- return $this->_factor;
- }
-
- /**
- * Set color of the barcode and text
- * @param string $value
- * @return Zend_Barcode_Object
- * @throw Zend_Barcode_Object_Exception
- */
- public function setForeColor($value)
- {
- if (preg_match('`\#[0-9A-F]{6}`', $value)) {
- $this->_foreColor = hexdec($value);
- } elseif (is_numeric($value) && $value >= 0 && $value <= 16777125) {
- $this->_foreColor = intval($value);
- } else {
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception(
- 'Text color must be set as #[0-9A-F]{6}'
- );
- }
- return $this;
- }
-
- /**
- * Retrieve color of the barcode and text
- * @return unknown
- */
- public function getForeColor()
- {
- return $this->_foreColor;
- }
-
- /**
- * Set the color of the background
- * @param integer $value
- * @return Zend_Barcode_Object
- * @throw Zend_Barcode_Object_Exception
- */
- public function setBackgroundColor($value)
- {
- if (preg_match('`\#[0-9A-F]{6}`', $value)) {
- $this->_backgroundColor = hexdec($value);
- } elseif (is_numeric($value) && $value >= 0 && $value <= 16777125) {
- $this->_backgroundColor = intval($value);
- } else {
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception(
- 'Background color must be set as #[0-9A-F]{6}'
- );
- }
- return $this;
- }
-
- /**
- * Retrieve background color of the image
- * @return integer
- */
- public function getBackgroundColor()
- {
- return $this->_backgroundColor;
- }
-
- /**
- * Activate/deactivate drawing of the bar
- * @param boolean $value
- * @return Zend_Barcode_Object
- */
- public function setWithBorder($value)
- {
- $this->_withBorder = (bool) $value;
- return $this;
- }
-
- /**
- * Retrieve if border are draw or not
- * @return boolean
- */
- public function getWithBorder()
- {
- return $this->_withBorder;
- }
-
- /**
- * Allow fast inversion of font/bars color and background color
- * @return Zend_Barcode_Object
- */
- public function setReverseColor()
- {
- $tmp = $this->_foreColor;
- $this->_foreColor = $this->_backgroundColor;
- $this->_backgroundColor = $tmp;
- return $this;
- }
-
- /**
- * Set orientation of barcode and text
- * @param float $value
- * @return Zend_Barcode_Object
- * @throw Zend_Barcode_Object_Exception
- */
- public function setOrientation($value)
- {
- $this->_orientation = floatval($value) - floor(floatval($value) / 360) * 360;
- return $this;
- }
-
- /**
- * Retrieve orientation of barcode and text
- * @return float
- */
- public function getOrientation()
- {
- return $this->_orientation;
- }
-
- /**
- * Set text to encode
- * @param string $value
- * @return Zend_Barcode_Object
- */
- public function setText($value)
- {
- $this->_text = trim($value);
- return $this;
- }
-
- /**
- * Retrieve text to encode
- * @return string
- */
- public function getText()
- {
- $text = $this->_text;
- if ($this->_withChecksum) {
- $text .= $this->getChecksum($this->_text);
- }
- return $this->_addLeadingZeros($text);
- }
-
- /**
- * Automatically add leading zeros if barcode length is fixed
- * @param string $text
- * @param boolean $withoutChecksum
- */
- protected function _addLeadingZeros($text, $withoutChecksum = false)
- {
- if ($this->_barcodeLength && $this->_addLeadingZeros) {
- $omitChecksum = (int) ($this->_withChecksum && $withoutChecksum);
- if (is_int($this->_barcodeLength)) {
- $length = $this->_barcodeLength - $omitChecksum;
- if (strlen($text) < $length) {
- $text = str_repeat('0', $length - strlen($text)) . $text;
- }
- } else {
- if ($this->_barcodeLength == 'even') {
- $text = ((strlen($text) - $omitChecksum) % 2 ? '0' . $text : $text);
- }
- }
- }
- return $text;
- }
-
- /**
- * Retrieve text to encode
- * @return string
- */
- public function getRawText()
- {
- return $this->_text;
- }
-
- /**
- * Retrieve text to display
- * @return string
- */
- public function getTextToDisplay()
- {
- if ($this->_withChecksumInText) {
- return $this->getText();
- } else {
- return $this->_addLeadingZeros($this->_text, true);
- }
- }
-
- /**
- * Activate/deactivate drawing of text to encode
- * @param boolean $value
- * @return Zend_Barcode_Object
- */
- public function setDrawText($value)
- {
- $this->_drawText = (bool) $value;
- return $this;
- }
-
- /**
- * Retrieve if drawing of text to encode is enabled
- * @return boolean
- */
- public function getDrawText()
- {
- return $this->_drawText;
- }
-
- /**
- * Activate/deactivate the adjustment of the position
- * of the characters to the position of the bars
- * @param boolean $value
- * @return Zend_Barcode_Object
- * @throw Zend_Barcode_Object_Exception
- */
- public function setStretchText($value)
- {
- $this->_stretchText = (bool) $value;
- return $this;
- }
-
- /**
- * Retrieve if the adjustment of the position of the characters
- * to the position of the bars is enabled
- * @return boolean
- */
- public function getStretchText()
- {
- return $this->_stretchText;
- }
-
- /**
- * Activate/deactivate the automatic generation
- * of the checksum character
- * added to the barcode text
- * @param boolean $value
- * @return Zend_Barcode_Object
- */
- public function setWithChecksum($value)
- {
- if (!$this->_mandatoryChecksum) {
- $this->_withChecksum = (bool) $value;
- }
- return $this;
- }
-
- /**
- * Retrieve if the checksum character is automatically
- * added to the barcode text
- * @return boolean
- */
- public function getWithChecksum()
- {
- return $this->_withChecksum;
- }
-
- /**
- * Activate/deactivate the automatic generation
- * of the checksum character
- * added to the barcode text
- * @param boolean $value
- * @return Zend_Barcode_Object
- * @throw Zend_Barcode_Object_Exception
- */
- public function setWithChecksumInText($value)
- {
- if (!$this->_mandatoryChecksum) {
- $this->_withChecksumInText = (bool) $value;
- }
- return $this;
- }
-
- /**
- * Retrieve if the checksum character is automatically
- * added to the barcode text
- * @return boolean
- */
- public function getWithChecksumInText()
- {
- return $this->_withChecksumInText;
- }
-
- /**
- * Set the font for all instances of barcode
- * @param string $font
- * @return void
- */
- public static function setBarcodeFont($font)
- {
- if (is_string($font) || (is_int($font) && $font >= 1 && $font <= 5)) {
- self::$_staticFont = $font;
- }
- }
-
- /**
- * Set the font:
- * - if integer between 1 and 5, use gd built-in fonts
- * - if string, $value is assumed to be the path to a TTF font
- * @param integer|string $value
- * @return Zend_Barcode_Object
- * @throw Zend_Barcode_Object_Exception
- */
- public function setFont($value)
- {
- if (is_int($value) && $value >= 1 && $value <= 5) {
- if (!extension_loaded('gd')) {
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception(
- 'GD extension is required to use numeric font'
- );
- }
-
- // Case of numeric font with GD
- $this->_font = $value;
-
- // In this case font size is given by:
- $this->_fontSize = imagefontheight($value);
- } elseif (is_string($value)) {
- $this->_font = $value;
- } else {
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception(sprintf(
- 'Invalid font "%s" provided to setFont()',
- $value
- ));
- }
- return $this;
- }
-
- /**
- * Retrieve the font
- * @return integer|string
- */
- public function getFont()
- {
- return $this->_font;
- }
-
- /**
- * Set the size of the font in case of TTF
- * @param float $value
- * @return Zend_Barcode_Object
- * @throw Zend_Barcode_Object_Exception
- */
- public function setFontSize($value)
- {
- if (is_numeric($this->_font)) {
- // Case of numeric font with GD
- return $this;
- }
-
- if (!is_numeric($value)) {
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception(
- 'Font size must be a numeric value'
- );
- }
-
- $this->_fontSize = $value;
- return $this;
- }
-
- /**
- * Retrieve the size of the font in case of TTF
- * @return float
- */
- public function getFontSize()
- {
- return $this->_fontSize;
- }
-
- /**
- * Quiet zone before first bar
- * and after the last bar
- * @return integer
- */
- public function getQuietZone()
- {
- return 10 * $this->_barThinWidth * $this->_factor;
- }
-
- /**
- * Add an instruction in the array of instructions
- * @param array $instruction
- */
- protected function _addInstruction(array $instruction)
- {
- $this->_instructions[] = $instruction;
- }
-
- /**
- * Retrieve the set of drawing instructions
- * @return array
- */
- public function getInstructions()
- {
- return $this->_instructions;
- }
-
- /**
- * Add a polygon drawing instruction in the set of instructions
- * @param array $points
- * @param integer $color
- * @param boolean $filled
- */
- protected function _addPolygon(array $points, $color = null, $filled = true)
- {
- if ($color === null) {
- $color = $this->_foreColor;
- }
- $this->_addInstruction(array(
- 'type' => 'polygon',
- 'points' => $points,
- 'color' => $color,
- 'filled' => $filled,
- ));
- }
-
- /**
- * Add a text drawing instruction in the set of instructions
- * @param string $text
- * @param float $size
- * @param array $position
- * @param string $font
- * @param integer $color
- * @param string $alignment
- * @param float $orientation
- */
- protected function _addText(
- $text,
- $size,
- $position,
- $font,
- $color,
- $alignment = 'center',
- $orientation = 0
- ) {
- if ($color === null) {
- $color = $this->_foreColor;
- }
- $this->_addInstruction(array(
- 'type' => 'text',
- 'text' => $text,
- 'size' => $size,
- 'position' => $position,
- 'font' => $font,
- 'color' => $color,
- 'alignment' => $alignment,
- 'orientation' => $orientation,
- ));
- }
-
- /**
- * Checking of parameters after all settings
- * @return void
- */
- public function checkParams()
- {
- $this->_checkText();
- $this->_checkFontAndOrientation();
- $this->_checkParams();
- return true;
- }
-
- /**
- * Check if a text is really provided to barcode
- * @return void
- * @throw Zend_Barcode_Object_Exception
- */
- protected function _checkText($value = null)
- {
- if ($value === null) {
- $value = $this->_text;
- }
- if (!strlen($value)) {
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception(
- 'A text must be provide to Barcode before drawing'
- );
- }
- $this->validateText($value);
- }
-
- /**
- * Check the ratio between the thick and the thin bar
- * @param integer $min
- * @param integer $max
- * @return void
- * @throw Zend_Barcode_Object_Exception
- */
- protected function _checkRatio($min = 2, $max = 3)
- {
- $ratio = $this->_barThickWidth / $this->_barThinWidth;
- if (!($ratio >= $min && $ratio <= $max)) {
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception(sprintf(
- 'Ratio thick/thin bar must be between %0.1f and %0.1f (actual %0.3f)',
- $min,
- $max,
- $ratio
- ));
- }
- }
-
- /**
- * Drawing with an angle is just allow TTF font
- * @return void
- * @throw Zend_Barcode_Object_Exception
- */
- protected function _checkFontAndOrientation()
- {
- if (is_numeric($this->_font) && $this->_orientation != 0) {
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception(
- 'Only drawing with TTF font allow orientation of the barcode.'
- );
- }
- }
-
- /**
- * Width of the result image
- * (before any rotation)
- * @return integer
- */
- protected function _calculateWidth()
- {
- return (int) $this->_withBorder
- + $this->_calculateBarcodeWidth()
- + (int) $this->_withBorder;
- }
-
- /**
- * Calculate the width of the barcode
- * @return integer
- */
- abstract protected function _calculateBarcodeWidth();
-
- /**
- * Height of the result object
- * @return integer
- */
- protected function _calculateHeight()
- {
- return (int) $this->_withBorder * 2
- + $this->_calculateBarcodeHeight()
- + (int) $this->_withBorder * 2;
- }
-
- /**
- * Height of the barcode
- * @return integer
- */
- protected function _calculateBarcodeHeight()
- {
- $textHeight = 0;
- $extraHeight = 0;
- if ($this->_drawText) {
- $textHeight += $this->_fontSize;
- $extraHeight = 2;
- }
- return ($this->_barHeight + $textHeight) * $this->_factor + $extraHeight;
- }
-
- /**
- * Get height of the result object
- * @return integer
- */
- public function getHeight($recalculate = false)
- {
- if ($this->_height === null || $recalculate) {
- $this->_height =
- abs($this->_calculateHeight() * cos($this->_orientation / 180 * pi()))
- + abs($this->_calculateWidth() * sin($this->_orientation / 180 * pi()));
- }
- return $this->_height;
- }
-
- /**
- * Get width of the result object
- * @return integer
- */
- public function getWidth($recalculate = false)
- {
- if ($this->_width === null || $recalculate) {
- $this->_width =
- abs($this->_calculateWidth() * cos($this->_orientation / 180 * pi()))
- + abs($this->_calculateHeight() * sin($this->_orientation / 180 * pi()));
- }
- return $this->_width;
- }
-
- /**
- * Calculate the offset from the left of the object
- * if an orientation is activated
- * @param boolean $recalculate
- * @return float
- */
- public function getOffsetLeft($recalculate = false)
- {
- if ($this->_offsetLeft === null || $recalculate) {
- $this->_offsetLeft = - min(array(
- 0 * cos(
- $this->_orientation / 180 * pi()) - 0 * sin(
- $this->_orientation / 180 * pi()),
- 0 * cos(
- $this->_orientation / 180 * pi()) - $this->_calculateBarcodeHeight() * sin(
- $this->_orientation / 180 * pi()),
- $this->_calculateBarcodeWidth() * cos(
- $this->_orientation / 180 * pi()) - $this->_calculateBarcodeHeight() * sin(
- $this->_orientation / 180 * pi()),
- $this->_calculateBarcodeWidth() * cos(
- $this->_orientation / 180 * pi()) - 0 * sin(
- $this->_orientation / 180 * pi()),
- ));
- }
- return $this->_offsetLeft;
- }
-
- /**
- * Calculate the offset from the top of the object
- * if an orientation is activated
- * @param boolean $recalculate
- * @return float
- */
- public function getOffsetTop($recalculate = false)
- {
- if ($this->_offsetTop === null || $recalculate) {
- $this->_offsetTop = - min(array(
- 0 * cos(
- $this->_orientation / 180 * pi()) + 0 * sin(
- $this->_orientation / 180 * pi()),
- $this->_calculateBarcodeHeight() * cos(
- $this->_orientation / 180 * pi()) + 0 * sin(
- $this->_orientation / 180 * pi()),
- $this->_calculateBarcodeHeight() * cos(
- $this->_orientation / 180 * pi()) + $this->_calculateBarcodeWidth() * sin(
- $this->_orientation / 180 * pi()),
- 0 * cos(
- $this->_orientation / 180 * pi()) + $this->_calculateBarcodeWidth() * sin(
- $this->_orientation / 180 * pi()),
- ));
- }
- return $this->_offsetTop;
- }
-
- /**
- * Apply rotation on a point in X/Y dimensions
- * @param float $x1 x-position before rotation
- * @param float $y1 y-position before rotation
- * @return array Array of two elements corresponding to the new XY point
- */
- protected function _rotate($x1, $y1)
- {
- $x2 = $x1 * cos($this->_orientation / 180 * pi())
- - $y1 * sin($this->_orientation / 180 * pi())
- + $this->getOffsetLeft();
- $y2 = $y1 * cos($this->_orientation / 180 * pi())
- + $x1 * sin($this->_orientation / 180 * pi())
- + $this->getOffsetTop();
- return array(intval($x2) , intval($y2));
- }
-
- /**
- * Complete drawing of the barcode
- * @return array Table of instructions
- */
- public function draw()
- {
- $this->checkParams();
- $this->_drawBarcode();
- $this->_drawBorder();
- $this->_drawText();
- return $this->getInstructions();
- }
-
- /**
- * Draw the barcode
- * @return void
- */
- protected function _drawBarcode()
- {
- $barcodeTable = $this->_prepareBarcode();
-
- $this->_preDrawBarcode();
-
- $xpos = (int) $this->_withBorder;
- $ypos = (int) $this->_withBorder;
-
- $point1 = $this->_rotate(0, 0);
- $point2 = $this->_rotate(0, $this->_calculateHeight() - 1);
- $point3 = $this->_rotate(
- $this->_calculateWidth() - 1,
- $this->_calculateHeight() - 1
- );
- $point4 = $this->_rotate($this->_calculateWidth() - 1, 0);
-
- $this->_addPolygon(array(
- $point1,
- $point2,
- $point3,
- $point4
- ), $this->_backgroundColor);
-
- $xpos += $this->getQuietZone();
- $barLength = $this->_barHeight * $this->_factor;
-
- foreach ($barcodeTable as $bar) {
- $width = $bar[1] * $this->_factor;
- if ($bar[0]) {
- $point1 = $this->_rotate($xpos, $ypos + $bar[2] * $barLength);
- $point2 = $this->_rotate($xpos, $ypos + $bar[3] * $barLength);
- $point3 = $this->_rotate(
- $xpos + $width - 1,
- $ypos + $bar[3] * $barLength
- );
- $point4 = $this->_rotate(
- $xpos + $width - 1,
- $ypos + $bar[2] * $barLength
- );
- $this->_addPolygon(array(
- $point1,
- $point2,
- $point3,
- $point4,
- ));
- }
- $xpos += $width;
- }
-
- $this->_postDrawBarcode();
- }
-
- /**
- * Partial function to draw border
- * @return void
- */
- protected function _drawBorder()
- {
- if ($this->_withBorder) {
- $point1 = $this->_rotate(0, 0);
- $point2 = $this->_rotate($this->_calculateWidth() - 1, 0);
- $point3 = $this->_rotate(
- $this->_calculateWidth() - 1,
- $this->_calculateHeight() - 1
- );
- $point4 = $this->_rotate(0, $this->_calculateHeight() - 1);
- $this->_addPolygon(array(
- $point1,
- $point2,
- $point3,
- $point4,
- $point1,
- ), $this->_foreColor, false);
- }
- }
-
- /**
- * Partial function to draw text
- * @return void
- */
- protected function _drawText()
- {
- if ($this->_drawText) {
- $text = $this->getTextToDisplay();
- if ($this->_stretchText) {
- $textLength = strlen($text);
- $space = ($this->_calculateWidth() - 2 * $this->getQuietZone()) / $textLength;
- for ($i = 0; $i < $textLength; $i ++) {
- $leftPosition = $this->getQuietZone() + $space * ($i + 0.5);
- $this->_addText(
- $text{$i},
- $this->_fontSize * $this->_factor,
- $this->_rotate(
- $leftPosition,
- (int) $this->_withBorder * 2
- + $this->_factor * ($this->_barHeight + $this->_fontSize) + 1
- ),
- $this->_font,
- $this->_foreColor,
- 'center',
- - $this->_orientation
- );
- }
- } else {
- $this->_addText(
- $text,
- $this->_fontSize * $this->_factor,
- $this->_rotate(
- $this->_calculateWidth() / 2,
- (int) $this->_withBorder * 2
- + $this->_factor * ($this->_barHeight + $this->_fontSize) + 1
- ),
- $this->_font,
- $this->_foreColor,
- 'center',
- - $this->_orientation
- );
- }
- }
- }
-
- /**
- * Check for invalid characters
- * @param string $value Text to be ckecked
- * @return void
- */
- public function validateText($value)
- {
- $this->_validateText($value);
- }
-
- /**
- * Standard validation for most of barcode objects
- * @param string $value
- * @param array $options
- */
- protected function _validateText($value, $options = array())
- {
- $validatorName = (isset($options['validator'])) ? $options['validator'] : $this->getType();
-
- $validator = new Zend_Validate_Barcode(array(
- 'adapter' => $validatorName,
- 'checksum' => false,
- ));
-
- $checksumCharacter = '';
- $withChecksum = false;
- if ($this->_mandatoryChecksum) {
- $checksumCharacter = $this->_substituteChecksumCharacter;
- $withChecksum = true;
- }
-
- $value = $this->_addLeadingZeros($value, $withChecksum) . $checksumCharacter;
-
- if (!$validator->isValid($value)) {
- $message = implode("\n", $validator->getMessages());
-
- /**
- * @see Zend_Barcode_Object_Exception
- */
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception($message);
- }
- }
-
- /**
- * Each child must prepare the barcode and return
- * a table like array(
- * 0 => array(
- * 0 => int (visible(black) or not(white))
- * 1 => int (width of the bar)
- * 2 => float (0->1 position from the top of the beginning of the bar in %)
- * 3 => float (0->1 position from the top of the end of the bar in %)
- * ),
- * 1 => ...
- * )
- *
- * @return array
- */
- abstract protected function _prepareBarcode();
-
- /**
- * Checking of parameters after all settings
- *
- * @return void
- */
- abstract protected function _checkParams();
-
- /**
- * Allow each child to draw something else
- *
- * @return void
- */
- protected function _preDrawBarcode()
- {
- }
-
- /**
- * Allow each child to draw something else
- * (ex: bearer bars in interleaved 2 of 5 code)
- *
- * @return void
- */
- protected function _postDrawBarcode()
- {
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/ObjectInterface.php zendframework-2.2.6/library/Zend/Barcode/Object/ObjectInterface.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/ObjectInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/ObjectInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,337 @@
+ "00111",
1 => "11100",
2 => "11010",
@@ -59,4 +33,4 @@
8 => "01101",
9 => "01011"
);
-}
\ No newline at end of file
+}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Postnet.php zendframework-2.2.6/library/Zend/Barcode/Object/Postnet.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Postnet.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Postnet.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,44 +1,18 @@
"11000",
1 => "00011",
2 => "00101",
@@ -64,25 +38,25 @@
* Default options for Postnet barcode
* @return void
*/
- protected function _getDefaultOptions()
+ protected function getDefaultOptions()
{
- $this->_barThinWidth = 2;
- $this->_barHeight = 20;
- $this->_drawText = false;
- $this->_stretchText = true;
- $this->_mandatoryChecksum = true;
+ $this->barThinWidth = 2;
+ $this->barHeight = 20;
+ $this->drawText = false;
+ $this->stretchText = true;
+ $this->mandatoryChecksum = true;
}
/**
* Width of the barcode (in pixels)
- * @return integer
+ * @return int
*/
- protected function _calculateBarcodeWidth()
+ protected function calculateBarcodeWidth()
{
$quietZone = $this->getQuietZone();
- $startCharacter = (2 * $this->_barThinWidth) * $this->_factor;
- $stopCharacter = (1 * $this->_barThinWidth) * $this->_factor;
- $encodedData = (10 * $this->_barThinWidth) * $this->_factor * strlen($this->getText());
+ $startCharacter = (2 * $this->barThinWidth) * $this->factor;
+ $stopCharacter = (1 * $this->barThinWidth) * $this->factor;
+ $encodedData = (10 * $this->barThinWidth) * $this->factor * strlen($this->getText());
return $quietZone + $startCharacter + $encodedData + $stopCharacter + $quietZone;
}
@@ -90,33 +64,33 @@
* Partial check of interleaved Postnet barcode
* @return void
*/
- protected function _checkParams()
+ protected function checkSpecificParams()
{}
/**
* Prepare array to draw barcode
* @return array
*/
- protected function _prepareBarcode()
+ protected function prepareBarcode()
{
$barcodeTable = array();
// Start character (1)
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , 1);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
// Text to encode
$textTable = str_split($this->getText());
foreach ($textTable as $char) {
- $bars = str_split($this->_codingMap[$char]);
+ $bars = str_split($this->codingMap[$char]);
foreach ($bars as $b) {
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0.5 - $b * 0.5 , 1);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0.5 - $b * 0.5, 1);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
}
}
// Stop character (1)
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
return $barcodeTable;
}
@@ -128,7 +102,7 @@
*/
public function getChecksum($text)
{
- $this->_checkText($text);
+ $this->checkText($text);
$sum = array_sum(str_split($text));
$checksum = (10 - ($sum % 10)) % 10;
return $checksum;
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Royalmail.php zendframework-2.2.6/library/Zend/Barcode/Object/Royalmail.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Royalmail.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Royalmail.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,44 +1,18 @@
'3300', '1' => '3210', '2' => '3201', '3' => '2310', '4' => '2301', '5' => '2211',
'6' => '3120', '7' => '3030', '8' => '3021', '9' => '2130', 'A' => '2121', 'B' => '2031',
'C' => '3102', 'D' => '3012', 'E' => '3003', 'F' => '2112', 'G' => '2103', 'H' => '2013',
@@ -58,7 +32,7 @@
'U' => '1122', 'V' => '1032', 'W' => '1023', 'X' => '0132', 'Y' => '0123', 'Z' => '0033'
);
- protected $_rows = array(
+ protected $rows = array(
'0' => 1, '1' => 1, '2' => 1, '3' => 1, '4' => 1, '5' => 1,
'6' => 2, '7' => 2, '8' => 2, '9' => 2, 'A' => 2, 'B' => 2,
'C' => 3, 'D' => 3, 'E' => 3, 'F' => 3, 'G' => 3, 'H' => 3,
@@ -67,7 +41,7 @@
'U' => 0, 'V' => 0, 'W' => 0, 'X' => 0, 'Y' => 0, 'Z' => 0,
);
- protected $_columns = array(
+ protected $columns = array(
'0' => 1, '1' => 2, '2' => 3, '3' => 4, '4' => 5, '5' => 0,
'6' => 1, '7' => 2, '8' => 3, '9' => 4, 'A' => 5, 'B' => 0,
'C' => 1, 'D' => 2, 'E' => 3, 'F' => 4, 'G' => 5, 'H' => 0,
@@ -80,25 +54,25 @@
* Default options for Postnet barcode
* @return void
*/
- protected function _getDefaultOptions()
+ protected function getDefaultOptions()
{
- $this->_barThinWidth = 2;
- $this->_barHeight = 20;
- $this->_drawText = false;
- $this->_stretchText = true;
- $this->_mandatoryChecksum = true;
+ $this->barThinWidth = 2;
+ $this->barHeight = 20;
+ $this->drawText = false;
+ $this->stretchText = true;
+ $this->mandatoryChecksum = true;
}
/**
* Width of the barcode (in pixels)
- * @return integer
+ * @return int
*/
- protected function _calculateBarcodeWidth()
+ protected function calculateBarcodeWidth()
{
$quietZone = $this->getQuietZone();
- $startCharacter = (2 * $this->_barThinWidth) * $this->_factor;
- $stopCharacter = (1 * $this->_barThinWidth) * $this->_factor;
- $encodedData = (8 * $this->_barThinWidth) * $this->_factor * strlen($this->getText());
+ $startCharacter = (2 * $this->barThinWidth) * $this->factor;
+ $stopCharacter = (1 * $this->barThinWidth) * $this->factor;
+ $encodedData = (8 * $this->barThinWidth) * $this->factor * strlen($this->getText());
return $quietZone + $startCharacter + $encodedData + $stopCharacter + $quietZone;
}
@@ -106,33 +80,33 @@
* Partial check of interleaved Postnet barcode
* @return void
*/
- protected function _checkParams()
+ protected function checkSpecificParams()
{}
/**
* Prepare array to draw barcode
* @return array
*/
- protected function _prepareBarcode()
+ protected function prepareBarcode()
{
$barcodeTable = array();
// Start character (1)
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , 5/8);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, 5/8);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
// Text to encode
$textTable = str_split($this->getText());
foreach ($textTable as $char) {
- $bars = str_split($this->_codingMap[$char]);
+ $bars = str_split($this->codingMap[$char]);
foreach ($bars as $b) {
- $barcodeTable[] = array(1 , $this->_barThinWidth , ($b > 1 ? 3/8 : 0) , ($b % 2 ? 5/8 : 1));
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, ($b > 1 ? 3/8 : 0), ($b % 2 ? 5/8 : 1));
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, 1);
}
}
// Stop character (1)
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, 1);
return $barcodeTable;
}
@@ -144,20 +118,20 @@
*/
public function getChecksum($text)
{
- $this->_checkText($text);
+ $this->checkText($text);
$values = str_split($text);
$rowvalue = 0;
$colvalue = 0;
- foreach($values as $row) {
- $rowvalue += $this->_rows[$row];
- $colvalue += $this->_columns[$row];
+ foreach ($values as $row) {
+ $rowvalue += $this->rows[$row];
+ $colvalue += $this->columns[$row];
}
$rowvalue %= 6;
$colvalue %= 6;
- $rowchkvalue = array_keys($this->_rows, $rowvalue);
- $colchkvalue = array_keys($this->_columns, $colvalue);
+ $rowchkvalue = array_keys($this->rows, $rowvalue);
+ $colchkvalue = array_keys($this->columns, $colvalue);
return current(array_intersect($rowchkvalue, $colchkvalue));
}
}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Upca.php zendframework-2.2.6/library/Zend/Barcode/Object/Upca.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Upca.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Upca.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,67 +1,42 @@
_barcodeLength = 12;
- $this->_mandatoryChecksum = true;
+ $this->barcodeLength = 12;
+ $this->mandatoryChecksum = true;
+ $this->mandatoryQuietZones = true;
}
/**
* Width of the barcode (in pixels)
- * @return integer
+ * @return int
*/
- protected function _calculateBarcodeWidth()
+ protected function calculateBarcodeWidth()
{
$quietZone = $this->getQuietZone();
- $startCharacter = (3 * $this->_barThinWidth) * $this->_factor;
- $middleCharacter = (5 * $this->_barThinWidth) * $this->_factor;
- $stopCharacter = (3 * $this->_barThinWidth) * $this->_factor;
- $encodedData = (7 * $this->_barThinWidth) * $this->_factor * 12;
+ $startCharacter = (3 * $this->barThinWidth) * $this->factor;
+ $middleCharacter = (5 * $this->barThinWidth) * $this->factor;
+ $stopCharacter = (3 * $this->barThinWidth) * $this->factor;
+ $encodedData = (7 * $this->barThinWidth) * $this->factor * 12;
return $quietZone + $startCharacter + $middleCharacter + $encodedData + $stopCharacter + $quietZone;
}
@@ -69,57 +44,57 @@
* Prepare array to draw barcode
* @return array
*/
- protected function _prepareBarcode()
+ protected function prepareBarcode()
{
$barcodeTable = array();
- $height = ($this->_drawText) ? 1.1 : 1;
+ $height = ($this->drawText) ? 1.1 : 1;
// Start character (101)
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
$textTable = str_split($this->getText());
// First character
- $bars = str_split($this->_codingMap['A'][$textTable[0]]);
+ $bars = str_split($this->codingMap['A'][$textTable[0]]);
foreach ($bars as $b) {
- $barcodeTable[] = array($b , $this->_barThinWidth , 0 , $height);
+ $barcodeTable[] = array($b, $this->barThinWidth, 0, $height);
}
// First part
for ($i = 1; $i < 6; $i++) {
- $bars = str_split($this->_codingMap['A'][$textTable[$i]]);
+ $bars = str_split($this->codingMap['A'][$textTable[$i]]);
foreach ($bars as $b) {
- $barcodeTable[] = array($b , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array($b, $this->barThinWidth, 0, 1);
}
}
// Middle character (01010)
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
// Second part
for ($i = 6; $i < 11; $i++) {
- $bars = str_split($this->_codingMap['C'][$textTable[$i]]);
+ $bars = str_split($this->codingMap['C'][$textTable[$i]]);
foreach ($bars as $b) {
- $barcodeTable[] = array($b , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array($b, $this->barThinWidth, 0, 1);
}
}
// Last character
- $bars = str_split($this->_codingMap['C'][$textTable[11]]);
+ $bars = str_split($this->codingMap['C'][$textTable[11]]);
foreach ($bars as $b) {
- $barcodeTable[] = array($b , $this->_barThinWidth , 0 , $height);
+ $barcodeTable[] = array($b, $this->barThinWidth, 0, $height);
}
// Stop character (101)
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
return $barcodeTable;
}
@@ -127,29 +102,29 @@
* Partial function to draw text
* @return void
*/
- protected function _drawText()
+ protected function drawText()
{
- if ($this->_drawText) {
+ if ($this->drawText) {
$text = $this->getTextToDisplay();
- $characterWidth = (7 * $this->_barThinWidth) * $this->_factor;
+ $characterWidth = (7 * $this->barThinWidth) * $this->factor;
$leftPosition = $this->getQuietZone() - $characterWidth;
- for ($i = 0; $i < $this->_barcodeLength; $i ++) {
- $fontSize = $this->_fontSize;
+ for ($i = 0; $i < $this->barcodeLength; $i ++) {
+ $fontSize = $this->fontSize;
if ($i == 0 || $i == 11) {
$fontSize *= 0.8;
}
- $this->_addText(
+ $this->addText(
$text{$i},
- $fontSize * $this->_factor,
- $this->_rotate(
+ $fontSize * $this->factor,
+ $this->rotate(
$leftPosition,
- (int) $this->_withBorder * 2
- + $this->_factor * ($this->_barHeight + $fontSize) + 1
+ (int) $this->withBorder * 2
+ + $this->factor * ($this->barHeight + $fontSize) + 1
),
- $this->_font,
- $this->_foreColor,
+ $this->font,
+ $this->foreColor,
'left',
- - $this->_orientation
+ - $this->orientation
);
switch ($i) {
case 0:
@@ -164,7 +139,7 @@
default:
$factor = 0;
}
- $leftPosition = $leftPosition + $characterWidth + ($factor * $this->_barThinWidth * $this->_factor);
+ $leftPosition = $leftPosition + $characterWidth + ($factor * $this->barThinWidth * $this->factor);
}
}
}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Object/Upce.php zendframework-2.2.6/library/Zend/Barcode/Object/Upce.php
--- zendframework-1.10.4/library/Zend/Barcode/Object/Upce.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Object/Upce.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,47 +1,23 @@
array(
0 => array('B','B','B','A','A','A'),
1 => array('B','B','A','B','A','A'),
@@ -70,10 +46,11 @@
* Default options for Postnet barcode
* @return void
*/
- protected function _getDefaultOptions()
+ protected function getDefaultOptions()
{
- $this->_barcodeLength = 8;
- $this->_mandatoryChecksum = true;
+ $this->barcodeLength = 8;
+ $this->mandatoryChecksum = true;
+ $this->mandatoryQuietZones = true;
}
/**
@@ -91,14 +68,14 @@
/**
* Width of the barcode (in pixels)
- * @return integer
+ * @return int
*/
- protected function _calculateBarcodeWidth()
+ protected function calculateBarcodeWidth()
{
$quietZone = $this->getQuietZone();
- $startCharacter = (3 * $this->_barThinWidth) * $this->_factor;
- $stopCharacter = (6 * $this->_barThinWidth) * $this->_factor;
- $encodedData = (7 * $this->_barThinWidth) * $this->_factor * 6;
+ $startCharacter = (3 * $this->barThinWidth) * $this->factor;
+ $stopCharacter = (6 * $this->barThinWidth) * $this->factor;
+ $encodedData = (7 * $this->barThinWidth) * $this->factor * 6;
return $quietZone + $startCharacter + $encodedData + $stopCharacter + $quietZone;
}
@@ -106,15 +83,15 @@
* Prepare array to draw barcode
* @return array
*/
- protected function _prepareBarcode()
+ protected function prepareBarcode()
{
$barcodeTable = array();
- $height = ($this->_drawText) ? 1.1 : 1;
+ $height = ($this->drawText) ? 1.1 : 1;
// Start character (101)
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
$textTable = str_split($this->getText());
$system = 0;
@@ -122,22 +99,22 @@
$system = 1;
}
$checksum = $textTable[7];
- $parity = $this->_parities[$system][$checksum];
+ $parity = $this->parities[$system][$checksum];
for ($i = 1; $i < 7; $i++) {
- $bars = str_split($this->_codingMap[$parity[$i - 1]][$textTable[$i]]);
+ $bars = str_split($this->codingMap[$parity[$i - 1]][$textTable[$i]]);
foreach ($bars as $b) {
- $barcodeTable[] = array($b , $this->_barThinWidth , 0 , 1);
+ $barcodeTable[] = array($b, $this->barThinWidth, 0, 1);
}
}
// Stop character (10101)
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(0 , $this->_barThinWidth , 0 , $height);
- $barcodeTable[] = array(1 , $this->_barThinWidth , 0 , $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
+ $barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
return $barcodeTable;
}
@@ -145,29 +122,29 @@
* Partial function to draw text
* @return void
*/
- protected function _drawText()
+ protected function drawText()
{
- if ($this->_drawText) {
+ if ($this->drawText) {
$text = $this->getTextToDisplay();
- $characterWidth = (7 * $this->_barThinWidth) * $this->_factor;
+ $characterWidth = (7 * $this->barThinWidth) * $this->factor;
$leftPosition = $this->getQuietZone() - $characterWidth;
- for ($i = 0; $i < $this->_barcodeLength; $i ++) {
- $fontSize = $this->_fontSize;
+ for ($i = 0; $i < $this->barcodeLength; $i ++) {
+ $fontSize = $this->fontSize;
if ($i == 0 || $i == 7) {
$fontSize *= 0.8;
}
- $this->_addText(
+ $this->addText(
$text{$i},
- $fontSize * $this->_factor,
- $this->_rotate(
+ $fontSize * $this->factor,
+ $this->rotate(
$leftPosition,
- (int) $this->_withBorder * 2
- + $this->_factor * ($this->_barHeight + $fontSize) + 1
+ (int) $this->withBorder * 2
+ + $this->factor * ($this->barHeight + $fontSize) + 1
),
- $this->_font,
- $this->_foreColor,
+ $this->font,
+ $this->foreColor,
'left',
- - $this->_orientation
+ - $this->orientation
);
switch ($i) {
case 0:
@@ -179,7 +156,7 @@
default:
$factor = 0;
}
- $leftPosition = $leftPosition + $characterWidth + ($factor * $this->_barThinWidth * $this->_factor);
+ $leftPosition = $leftPosition + $characterWidth + ($factor * $this->barThinWidth * $this->factor);
}
}
}
@@ -187,26 +164,23 @@
/**
* Particular validation for Upce barcode objects
* (to suppress checksum character substitution)
+ *
* @param string $value
* @param array $options
+ * @throws Exception\BarcodeValidationException
*/
- protected function _validateText($value, $options = array())
+ protected function validateSpecificText($value, $options = array())
{
- $validator = new Zend_Validate_Barcode(array(
+ $validator = new BarcodeValidator(array(
'adapter' => 'upce',
'checksum' => false,
));
- $value = $this->_addLeadingZeros($value, true);
+ $value = $this->addLeadingZeros($value, true);
if (!$validator->isValid($value)) {
$message = implode("\n", $validator->getMessages());
-
- /**
- * @see Zend_Barcode_Object_Exception
- */
- require_once 'Zend/Barcode/Object/Exception.php';
- throw new Zend_Barcode_Object_Exception($message);
+ throw new Exception\BarcodeValidationException($message);
}
}
@@ -218,7 +192,7 @@
*/
public function getChecksum($text)
{
- $text = $this->_addLeadingZeros($text, true);
+ $text = $this->addLeadingZeros($text, true);
if ($text{0} != 1) {
$text{0} = 0;
}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/ObjectPluginManager.php zendframework-2.2.6/library/Zend/Barcode/ObjectPluginManager.php
--- zendframework-1.10.4/library/Zend/Barcode/ObjectPluginManager.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/ObjectPluginManager.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,77 @@
+ 'Zend\Barcode\Object\Codabar',
+ 'code128' => 'Zend\Barcode\Object\Code128',
+ 'code25' => 'Zend\Barcode\Object\Code25',
+ 'code25interleaved' => 'Zend\Barcode\Object\Code25interleaved',
+ 'code39' => 'Zend\Barcode\Object\Code39',
+ 'ean13' => 'Zend\Barcode\Object\Ean13',
+ 'ean2' => 'Zend\Barcode\Object\Ean2',
+ 'ean5' => 'Zend\Barcode\Object\Ean5',
+ 'ean8' => 'Zend\Barcode\Object\Ean8',
+ 'error' => 'Zend\Barcode\Object\Error',
+ 'identcode' => 'Zend\Barcode\Object\Identcode',
+ 'itf14' => 'Zend\Barcode\Object\Itf14',
+ 'leitcode' => 'Zend\Barcode\Object\Leitcode',
+ 'planet' => 'Zend\Barcode\Object\Planet',
+ 'postnet' => 'Zend\Barcode\Object\Postnet',
+ 'royalmail' => 'Zend\Barcode\Object\Royalmail',
+ 'upca' => 'Zend\Barcode\Object\Upca',
+ 'upce' => 'Zend\Barcode\Object\Upce',
+ );
+
+ /**
+ * Validate the plugin
+ *
+ * Checks that the barcode parser loaded is an instance
+ * of Object\AbstractObject.
+ *
+ * @param mixed $plugin
+ * @return void
+ * @throws Exception\InvalidArgumentException if invalid
+ */
+ public function validatePlugin($plugin)
+ {
+ if ($plugin instanceof Object\AbstractObject) {
+ // we're okay
+ return;
+ }
+
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Plugin of type %s is invalid; must extend %s\Object\AbstractObject',
+ (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
+ __NAMESPACE__
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/README.md zendframework-2.2.6/library/Zend/Barcode/README.md
--- zendframework-1.10.4/library/Zend/Barcode/README.md 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/README.md 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,14 @@
+Barcode Component from ZF2
+==========================
+
+This is the Barcode component for ZF2.
+
+- File issues at https://github.com/zendframework/zf2/issues
+- Create pull requests against https://github.com/zendframework/zf2
+- Documentation is at http://framework.zend.com/docs
+
+LICENSE
+-------
+
+The files in this archive are released under the [Zend Framework
+license](http://framework.zend.com/license), which is a 3-clause BSD license.
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Renderer/AbstractRenderer.php zendframework-2.2.6/library/Zend/Barcode/Renderer/AbstractRenderer.php
--- zendframework-1.10.4/library/Zend/Barcode/Renderer/AbstractRenderer.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Renderer/AbstractRenderer.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,518 @@
+setOptions($options);
+ }
+ $this->type = strtolower(substr(
+ get_class($this),
+ strlen($this->rendererNamespace) + 1
+ ));
+ }
+
+ /**
+ * Set renderer state from options array
+ * @param array $options
+ * @return AbstractRenderer
+ */
+ public function setOptions($options)
+ {
+ foreach ($options as $key => $value) {
+ $method = 'set' . $key;
+ if (method_exists($this, $method)) {
+ $this->$method($value);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Set renderer namespace for autoloading
+ *
+ * @param string $namespace
+ * @return AbstractRenderer
+ */
+ public function setRendererNamespace($namespace)
+ {
+ $this->rendererNamespace = $namespace;
+ return $this;
+ }
+
+ /**
+ * Retrieve renderer namespace
+ *
+ * @return string
+ */
+ public function getRendererNamespace()
+ {
+ return $this->rendererNamespace;
+ }
+
+ /**
+ * Set whether background should be transparent
+ * Will work for SVG and Image (png and gif only)
+ *
+ * @param $bool
+ * @return $this
+ */
+ public function setTransparentBackground($bool)
+ {
+ $this->transparentBackground = $bool;
+
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function getTransparentBackground()
+ {
+ return $this->transparentBackground;
+ }
+
+ /**
+ * Retrieve renderer type
+ * @return string
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * Manually adjust top position
+ * @param int $value
+ * @return AbstractRenderer
+ * @throws Exception\OutOfRangeException
+ */
+ public function setTopOffset($value)
+ {
+ if (!is_numeric($value) || intval($value) < 0) {
+ throw new Exception\OutOfRangeException(
+ 'Vertical position must be greater than or equals 0'
+ );
+ }
+ $this->topOffset = intval($value);
+ return $this;
+ }
+
+ /**
+ * Retrieve vertical adjustment
+ * @return int
+ */
+ public function getTopOffset()
+ {
+ return $this->topOffset;
+ }
+
+ /**
+ * Manually adjust left position
+ * @param int $value
+ * @return AbstractRenderer
+ * @throws Exception\OutOfRangeException
+ */
+ public function setLeftOffset($value)
+ {
+ if (!is_numeric($value) || intval($value) < 0) {
+ throw new Exception\OutOfRangeException(
+ 'Horizontal position must be greater than or equals 0'
+ );
+ }
+ $this->leftOffset = intval($value);
+ return $this;
+ }
+
+ /**
+ * Retrieve vertical adjustment
+ * @return int
+ */
+ public function getLeftOffset()
+ {
+ return $this->leftOffset;
+ }
+
+ /**
+ * Activate/Deactivate the automatic rendering of exception
+ * @param bool $value
+ * @return AbstractRenderer
+ */
+ public function setAutomaticRenderError($value)
+ {
+ $this->automaticRenderError = (bool) $value;
+ return $this;
+ }
+
+ /**
+ * Horizontal position of the barcode in the rendering resource
+ * @param string $value
+ * @return AbstractRenderer
+ * @throws Exception\UnexpectedValueException
+ */
+ public function setHorizontalPosition($value)
+ {
+ if (!in_array($value, array('left', 'center', 'right'))) {
+ throw new Exception\UnexpectedValueException(
+ "Invalid barcode position provided must be 'left', 'center' or 'right'"
+ );
+ }
+ $this->horizontalPosition = $value;
+ return $this;
+ }
+
+ /**
+ * Horizontal position of the barcode in the rendering resource
+ * @return string
+ */
+ public function getHorizontalPosition()
+ {
+ return $this->horizontalPosition;
+ }
+
+ /**
+ * Vertical position of the barcode in the rendering resource
+ * @param string $value
+ * @return AbstractRenderer
+ * @throws Exception\UnexpectedValueException
+ */
+ public function setVerticalPosition($value)
+ {
+ if (!in_array($value, array('top', 'middle', 'bottom'))) {
+ throw new Exception\UnexpectedValueException(
+ "Invalid barcode position provided must be 'top', 'middle' or 'bottom'"
+ );
+ }
+ $this->verticalPosition = $value;
+ return $this;
+ }
+
+ /**
+ * Vertical position of the barcode in the rendering resource
+ * @return string
+ */
+ public function getVerticalPosition()
+ {
+ return $this->verticalPosition;
+ }
+
+ /**
+ * Set the size of a module
+ * @param float $value
+ * @return AbstractRenderer
+ * @throws Exception\OutOfRangeException
+ */
+ public function setModuleSize($value)
+ {
+ if (!is_numeric($value) || floatval($value) <= 0) {
+ throw new Exception\OutOfRangeException(
+ 'Float size must be greater than 0'
+ );
+ }
+ $this->moduleSize = floatval($value);
+ return $this;
+ }
+
+
+ /**
+ * Set the size of a module
+ * @return float
+ */
+ public function getModuleSize()
+ {
+ return $this->moduleSize;
+ }
+
+ /**
+ * Retrieve the automatic rendering of exception
+ * @return bool
+ */
+ public function getAutomaticRenderError()
+ {
+ return $this->automaticRenderError;
+ }
+
+ /**
+ * Set the barcode object
+ * @param Object\ObjectInterface $barcode
+ * @return AbstractRenderer
+ */
+ public function setBarcode(Object\ObjectInterface $barcode)
+ {
+ $this->barcode = $barcode;
+ return $this;
+ }
+
+ /**
+ * Retrieve the barcode object
+ * @return Object\ObjectInterface
+ */
+ public function getBarcode()
+ {
+ return $this->barcode;
+ }
+
+ /**
+ * Checking of parameters after all settings
+ * @return bool
+ */
+ public function checkParams()
+ {
+ $this->checkBarcodeObject();
+ $this->checkSpecificParams();
+ return true;
+ }
+
+ /**
+ * Check if a barcode object is correctly provided
+ * @return void
+ * @throws Exception\RuntimeException
+ */
+ protected function checkBarcodeObject()
+ {
+ if ($this->barcode === null) {
+ throw new Exception\RuntimeException(
+ 'No barcode object provided'
+ );
+ }
+ }
+
+ /**
+ * Calculate the left and top offset of the barcode in the
+ * rendering support
+ *
+ * @param float $supportHeight
+ * @param float $supportWidth
+ * @return void
+ */
+ protected function adjustPosition($supportHeight, $supportWidth)
+ {
+ $barcodeHeight = $this->barcode->getHeight(true) * $this->moduleSize;
+ if ($barcodeHeight != $supportHeight && $this->topOffset == 0) {
+ switch ($this->verticalPosition) {
+ case 'middle':
+ $this->topOffset = floor(
+ ($supportHeight - $barcodeHeight) / 2);
+ break;
+ case 'bottom':
+ $this->topOffset = $supportHeight - $barcodeHeight;
+ break;
+ case 'top':
+ default:
+ $this->topOffset = 0;
+ break;
+ }
+ }
+ $barcodeWidth = $this->barcode->getWidth(true) * $this->moduleSize;
+ if ($barcodeWidth != $supportWidth && $this->leftOffset == 0) {
+ switch ($this->horizontalPosition) {
+ case 'center':
+ $this->leftOffset = floor(
+ ($supportWidth - $barcodeWidth) / 2);
+ break;
+ case 'right':
+ $this->leftOffset = $supportWidth - $barcodeWidth;
+ break;
+ case 'left':
+ default:
+ $this->leftOffset = 0;
+ break;
+ }
+ }
+ }
+
+ /**
+ * Draw the barcode in the rendering resource
+ *
+ * @throws BarcodeException\ExceptionInterface
+ * @return mixed
+ */
+ public function draw()
+ {
+ try {
+ $this->checkParams();
+ $this->initRenderer();
+ $this->drawInstructionList();
+ } catch (BarcodeException\ExceptionInterface $e) {
+ if ($this->automaticRenderError && !($e instanceof BarcodeException\RendererCreationException)) {
+ $barcode = Barcode::makeBarcode(
+ 'error',
+ array('text' => $e->getMessage())
+ );
+ $this->setBarcode($barcode);
+ $this->resource = null;
+ $this->initRenderer();
+ $this->drawInstructionList();
+ } else {
+ throw $e;
+ }
+ }
+ return $this->resource;
+ }
+
+ /**
+ * Sub process to draw the barcode instructions
+ * Needed by the automatic error rendering
+ */
+ private function drawInstructionList()
+ {
+ $instructionList = $this->barcode->draw();
+ foreach ($instructionList as $instruction) {
+ switch ($instruction['type']) {
+ case 'polygon':
+ $this->drawPolygon(
+ $instruction['points'],
+ $instruction['color'],
+ $instruction['filled']
+ );
+ break;
+ case 'text': //$text, $size, $position, $font, $color, $alignment = 'center', $orientation = 0)
+ $this->drawText(
+ $instruction['text'],
+ $instruction['size'],
+ $instruction['position'],
+ $instruction['font'],
+ $instruction['color'],
+ $instruction['alignment'],
+ $instruction['orientation']
+ );
+ break;
+ default:
+ throw new Exception\UnexpectedValueException(
+ 'Unkown drawing command'
+ );
+ }
+ }
+ }
+
+ /**
+ * Checking of parameters after all settings
+ * @return void
+ */
+ abstract protected function checkSpecificParams();
+
+ /**
+ * Initialize the rendering resource
+ * @return void
+ */
+ abstract protected function initRenderer();
+
+ /**
+ * Draw a polygon in the rendering resource
+ * @param array $points
+ * @param int $color
+ * @param bool $filled
+ */
+ abstract protected function drawPolygon($points, $color, $filled = true);
+
+ /**
+ * Draw a polygon in the rendering resource
+ * @param string $text
+ * @param float $size
+ * @param array $position
+ * @param string $font
+ * @param int $color
+ * @param string $alignment
+ * @param float $orientation
+ */
+ abstract protected function drawText(
+ $text,
+ $size,
+ $position,
+ $font,
+ $color,
+ $alignment = 'center',
+ $orientation = 0
+ );
+}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Renderer/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Barcode/Renderer/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Barcode/Renderer/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Renderer/Exception/ExceptionInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,16 @@
+_userHeight = intval($value);
+ $this->userHeight = intval($value);
return $this;
}
@@ -114,24 +101,24 @@
*/
public function getHeight()
{
- return $this->_userHeight;
+ return $this->userHeight;
}
/**
* Set barcode width
*
* @param mixed $value
- * @return void
+ * @throws Exception\OutOfRangeException
+ * @return self
*/
public function setWidth($value)
{
if (!is_numeric($value) || intval($value) < 0) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
+ throw new Exception\OutOfRangeException(
'Image width must be greater than or equals 0'
);
}
- $this->_userWidth = intval($value);
+ $this->userWidth = intval($value);
return $this;
}
@@ -142,25 +129,24 @@
*/
public function getWidth()
{
- return $this->_userWidth;
+ return $this->userWidth;
}
/**
* Set an image resource to draw the barcode inside
*
- * @param resource $value
- * @return Zend_Barcode_Renderer
- * @throw Zend_Barcode_Renderer_Exception
+ * @param resource $image
+ * @return Image
+ * @throws Exception\InvalidArgumentException
*/
public function setResource($image)
{
if (gettype($image) != 'resource' || get_resource_type($image) != 'gd') {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
+ throw new Exception\InvalidArgumentException(
'Invalid image resource provided to setResource()'
);
}
- $this->_resource = $image;
+ $this->resource = $image;
return $this;
}
@@ -168,8 +154,8 @@
* Set the image type to produce (png, jpeg, gif)
*
* @param string $value
- * @return Zend_Barcode_RendererAbstract
- * @throw Zend_Barcode_Renderer_Exception
+ * @throws Exception\InvalidArgumentException
+ * @return Image
*/
public function setImageType($value)
{
@@ -177,15 +163,14 @@
$value = 'jpeg';
}
- if (!in_array($value, $this->_allowedImageType)) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(sprintf(
+ if (!in_array($value, $this->allowedImageType)) {
+ throw new Exception\InvalidArgumentException(sprintf(
'Invalid type "%s" provided to setImageType()',
$value
));
}
- $this->_imageType = $value;
+ $this->imageType = $value;
return $this;
}
@@ -196,7 +181,7 @@
*/
public function getImageType()
{
- return $this->_imageType;
+ return $this->imageType;
}
/**
@@ -204,72 +189,58 @@
*
* @return void
*/
- protected function _initRenderer()
+ protected function initRenderer()
{
- if (!extension_loaded('gd')) {
- require_once 'Zend/Barcode/Exception.php';
- $e = new Zend_Barcode_Exception(
- 'Gd extension must be loaded to render barcode as image'
- );
- $e->setIsRenderable(false);
- throw $e;
- }
-
- $barcodeWidth = $this->_barcode->getWidth(true);
- $barcodeHeight = $this->_barcode->getHeight(true);
+ $barcodeWidth = $this->barcode->getWidth(true);
+ $barcodeHeight = $this->barcode->getHeight(true);
- if ($this->_resource !== null) {
- $foreColor = $this->_barcode->getForeColor();
- $backgroundColor = $this->_barcode->getBackgroundColor();
- $this->_imageBackgroundColor = imagecolorallocate(
- $this->_resource,
- ($backgroundColor & 0xFF0000) >> 16,
- ($backgroundColor & 0x00FF00) >> 8,
- $backgroundColor & 0x0000FF
- );
- $this->_imageForeColor = imagecolorallocate(
- $this->_resource,
- ($foreColor & 0xFF0000) >> 16,
- ($foreColor & 0x00FF00) >> 8,
- $foreColor & 0x0000FF
- );
- } else {
+ if (is_null($this->resource)) {
$width = $barcodeWidth;
$height = $barcodeHeight;
- if ($this->_userWidth && $this->_barcode->getType() != 'error') {
- $width = $this->_userWidth;
+ if ($this->userWidth && $this->barcode->getType() != 'error') {
+ $width = $this->userWidth;
}
- if ($this->_userHeight && $this->_barcode->getType() != 'error') {
- $height = $this->_userHeight;
+ if ($this->userHeight && $this->barcode->getType() != 'error') {
+ $height = $this->userHeight;
}
- $foreColor = $this->_barcode->getForeColor();
- $backgroundColor = $this->_barcode->getBackgroundColor();
- $this->_resource = imagecreatetruecolor($width, $height);
-
- $this->_imageBackgroundColor = imagecolorallocate(
- $this->_resource,
- ($backgroundColor & 0xFF0000) >> 16,
- ($backgroundColor & 0x00FF00) >> 8,
- $backgroundColor & 0x0000FF
- );
- $this->_imageForeColor = imagecolorallocate(
- $this->_resource,
- ($foreColor & 0xFF0000) >> 16,
- ($foreColor & 0x00FF00) >> 8,
- $foreColor & 0x0000FF
- );
- $white = imagecolorallocate($this->_resource, 255, 255, 255);
- imagefilledrectangle($this->_resource, 0, 0, $width - 1, $height - 1, $white);
+ $this->resource = imagecreatetruecolor($width, $height);
+
+ $white = imagecolorallocate($this->resource, 255, 255, 255);
+ imagefilledrectangle($this->resource, 0, 0, $width - 1, $height - 1, $white);
+ }
+
+ $foreColor = $this->barcode->getForeColor();
+ $this->imageForeColor = imagecolorallocate(
+ $this->resource,
+ ($foreColor & 0xFF0000) >> 16,
+ ($foreColor & 0x00FF00) >> 8,
+ $foreColor & 0x0000FF
+ );
+
+ $backgroundColor = $this->barcode->getBackgroundColor();
+ $this->imageBackgroundColor = imagecolorallocate(
+ $this->resource,
+ ($backgroundColor & 0xFF0000) >> 16,
+ ($backgroundColor & 0x00FF00) >> 8,
+ $backgroundColor & 0x0000FF
+ );
+
+ // JPEG does not support transparency, if transparentBackground is true and
+ // image type is JPEG, ignore transparency
+ if($this->getImageType() != "jpeg" && $this->transparentBackground) {
+ imagecolortransparent($this->resource, $this->imageBackgroundColor);
}
- $this->_adjustPosition(imagesy($this->_resource), imagesx($this->_resource));
+
+ $this->adjustPosition(imagesy($this->resource), imagesx($this->resource));
+
imagefilledrectangle(
- $this->_resource,
- $this->_leftOffset,
- $this->_topOffset,
- $this->_leftOffset + $barcodeWidth - 1,
- $this->_topOffset + $barcodeHeight - 1,
- $this->_imageBackgroundColor
+ $this->resource,
+ $this->leftOffset,
+ $this->topOffset,
+ $this->leftOffset + $barcodeWidth - 1,
+ $this->topOffset + $barcodeHeight - 1,
+ $this->imageBackgroundColor
);
}
@@ -278,54 +249,51 @@
*
* @return void
*/
- protected function _checkParams()
+ protected function checkSpecificParams()
{
- $this->_checkDimensions();
+ $this->checkDimensions();
}
/**
* Check barcode dimensions
*
+ * @throws Exception\RuntimeException
* @return void
*/
- protected function _checkDimensions()
+ protected function checkDimensions()
{
- if ($this->_resource !== null) {
- if (imagesy($this->_resource) < $this->_barcode->getHeight(true)) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
+ if ($this->resource !== null) {
+ if (imagesy($this->resource) < $this->barcode->getHeight(true)) {
+ throw new Exception\RuntimeException(
'Barcode is define outside the image (height)'
);
}
} else {
- if ($this->_userHeight) {
- $height = $this->_barcode->getHeight(true);
- if ($this->_userHeight < $height) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(sprintf(
+ if ($this->userHeight) {
+ $height = $this->barcode->getHeight(true);
+ if ($this->userHeight < $height) {
+ throw new Exception\RuntimeException(sprintf(
"Barcode is define outside the image (calculated: '%d', provided: '%d')",
$height,
- $this->_userHeight
+ $this->userHeight
));
}
}
}
- if ($this->_resource !== null) {
- if (imagesx($this->_resource) < $this->_barcode->getWidth(true)) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
+ if ($this->resource !== null) {
+ if (imagesx($this->resource) < $this->barcode->getWidth(true)) {
+ throw new Exception\RuntimeException(
'Barcode is define outside the image (width)'
);
}
} else {
- if ($this->_userWidth) {
- $width = $this->_barcode->getWidth(true);
- if ($this->_userWidth < $width) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(sprintf(
+ if ($this->userWidth) {
+ $width = $this->barcode->getWidth(true);
+ if ($this->userWidth < $width) {
+ throw new Exception\RuntimeException(sprintf(
"Barcode is define outside the image (calculated: '%d', provided: '%d')",
$width,
- $this->_userWidth
+ $this->userWidth
));
}
}
@@ -340,43 +308,42 @@
public function render()
{
$this->draw();
- header("Content-Type: image/" . $this->_imageType);
- $functionName = 'image' . $this->_imageType;
- call_user_func($functionName, $this->_resource);
- @imagedestroy($this->_resource);
+ header("Content-Type: image/" . $this->imageType);
+ $functionName = 'image' . $this->imageType;
+ $functionName($this->resource);
+
+ ErrorHandler::start(E_WARNING);
+ imagedestroy($this->resource);
+ ErrorHandler::stop();
}
/**
* Draw a polygon in the image resource
*
* @param array $points
- * @param integer $color
- * @param boolean $filled
+ * @param int $color
+ * @param bool $filled
*/
- protected function _drawPolygon($points, $color, $filled = true)
+ protected function drawPolygon($points, $color, $filled = true)
{
- $newPoints = array(
- $points[0][0] + $this->_leftOffset,
- $points[0][1] + $this->_topOffset,
- $points[1][0] + $this->_leftOffset,
- $points[1][1] + $this->_topOffset,
- $points[2][0] + $this->_leftOffset,
- $points[2][1] + $this->_topOffset,
- $points[3][0] + $this->_leftOffset,
- $points[3][1] + $this->_topOffset,
- );
+ $newPoints = array($points[0][0] + $this->leftOffset,
+ $points[0][1] + $this->topOffset,
+ $points[1][0] + $this->leftOffset,
+ $points[1][1] + $this->topOffset,
+ $points[2][0] + $this->leftOffset,
+ $points[2][1] + $this->topOffset,
+ $points[3][0] + $this->leftOffset,
+ $points[3][1] + $this->topOffset, );
- $allocatedColor = imagecolorallocate(
- $this->_resource,
+ $allocatedColor = imagecolorallocate($this->resource,
($color & 0xFF0000) >> 16,
($color & 0x00FF00) >> 8,
- $color & 0x0000FF
- );
+ $color & 0x0000FF );
if ($filled) {
- imagefilledpolygon($this->_resource, $newPoints, 4, $allocatedColor);
+ imagefilledpolygon($this->resource, $newPoints, 4, $allocatedColor);
} else {
- imagepolygon($this->_resource, $newPoints, 4, $allocatedColor);
+ imagepolygon($this->resource, $newPoints, 4, $allocatedColor);
}
}
@@ -387,24 +354,23 @@
* @param float $size
* @param array $position
* @param string $font
- * @param integer $color
+ * @param int $color
* @param string $alignment
* @param float $orientation
+ * @throws Exception\RuntimeException
*/
- protected function _drawText($text, $size, $position, $font, $color, $alignment = 'center', $orientation = 0)
+ protected function drawText($text, $size, $position, $font, $color, $alignment = 'center', $orientation = 0)
{
- $allocatedColor = imagecolorallocate(
- $this->_resource,
+ $allocatedColor = imagecolorallocate($this->resource,
($color & 0xFF0000) >> 16,
($color & 0x00FF00) >> 8,
- $color & 0x0000FF
- );
+ $color & 0x0000FF );
if ($font == null) {
$font = 3;
}
- $position[0] += $this->_leftOffset;
- $position[1] += $this->_topOffset;
+ $position[0] += $this->leftOffset;
+ $position[1] += $this->topOffset;
if (is_numeric($font)) {
if ($orientation) {
@@ -415,8 +381,7 @@
* to informe user of the problem instead of simply not drawing
* the text
*/
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
+ throw new Exception\RuntimeException(
'No orientation possible with GD internal font'
);
}
@@ -433,16 +398,14 @@
$positionX = $position[0] - ($fontWidth * strlen($text));
break;
}
- imagestring($this->_resource, $font, $positionX, $positionY, $text, $color);
+ imagestring($this->resource, $font, $positionX, $positionY, $text, $color);
} else {
-
+
if (!function_exists('imagettfbbox')) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
- 'A font was provided, but this instance of PHP does not have TTF (FreeType) support'
- );
+ throw new Exception\RuntimeException(
+ 'A font was provided, but this instance of PHP does not have TTF (FreeType) support');
}
-
+
$box = imagettfbbox($size, 0, $font, $text);
switch ($alignment) {
case 'left':
@@ -455,16 +418,14 @@
$width = ($box[2] - $box[0]);
break;
}
- imagettftext(
- $this->_resource,
+ imagettftext($this->resource,
$size,
$orientation,
$position[0] - ($width * cos(pi() * $orientation / 180)),
$position[1] + ($width * sin(pi() * $orientation / 180)),
$allocatedColor,
$font,
- $text
- );
+ $text);
}
}
}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Renderer/Pdf.php zendframework-2.2.6/library/Zend/Barcode/Renderer/Pdf.php
--- zendframework-1.10.4/library/Zend/Barcode/Renderer/Pdf.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Renderer/Pdf.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,87 +1,58 @@
_resource = $pdf;
- $this->_page = intval($page);
-
- if (!count($this->_resource->pages)) {
- $this->_page = 0;
- $this->_resource->pages[] = new Zend_Pdf_Page(
- Zend_Pdf_Page::SIZE_A4
+ * Set a PDF resource to draw the barcode inside
+ *
+ * @param PdfDocument $pdf
+ * @param int $page
+ * @return Pdf
+ */
+ public function setResource(PdfDocument $pdf, $page = 0)
+ {
+ $this->resource = $pdf;
+ $this->page = intval($page);
+
+ if (!count($this->resource->pages)) {
+ $this->page = 0;
+ $this->resource->pages[] = new Page(
+ Page::SIZE_A4
);
}
return $this;
@@ -92,7 +63,7 @@
*
* @return void
*/
- protected function _checkParams()
+ protected function checkSpecificParams()
{
}
@@ -104,78 +75,78 @@
{
$this->draw();
header("Content-Type: application/pdf");
- echo $this->_resource->render();
+ echo $this->resource->render();
}
/**
* Initialize the PDF resource
* @return void
*/
- protected function _initRenderer()
+ protected function initRenderer()
{
- if ($this->_resource === null) {
- $this->_resource = new Zend_Pdf();
- $this->_resource->pages[] = new Zend_Pdf_Page(
- Zend_Pdf_Page::SIZE_A4
+ if ($this->resource === null) {
+ $this->resource = new PdfDocument();
+ $this->resource->pages[] = new Page(
+ Page::SIZE_A4
);
}
- $pdfPage = $this->_resource->pages[$this->_page];
- $this->_adjustPosition($pdfPage->getHeight(), $pdfPage->getWidth());
+ $pdfPage = $this->resource->pages[$this->page];
+ $this->adjustPosition($pdfPage->getHeight(), $pdfPage->getWidth());
}
/**
* Draw a polygon in the rendering resource
* @param array $points
- * @param integer $color
- * @param boolean $filled
+ * @param int $color
+ * @param bool $filled
*/
- protected function _drawPolygon($points, $color, $filled = true)
+ protected function drawPolygon($points, $color, $filled = true)
{
- $page = $this->_resource->pages[$this->_page];
+ $page = $this->resource->pages[$this->page];
foreach ($points as $point) {
- $x[] = $point[0] * $this->_moduleSize + $this->_leftOffset;
- $y[] = $page->getHeight() - $point[1] * $this->_moduleSize - $this->_topOffset;
+ $x[] = $point[0] * $this->moduleSize + $this->leftOffset;
+ $y[] = $page->getHeight() - $point[1] * $this->moduleSize - $this->topOffset;
}
if (count($y) == 4) {
if ($x[0] != $x[3] && $y[0] == $y[3]) {
- $y[0] -= ($this->_moduleSize / 2);
- $y[3] -= ($this->_moduleSize / 2);
+ $y[0] -= ($this->moduleSize / 2);
+ $y[3] -= ($this->moduleSize / 2);
}
if ($x[1] != $x[2] && $y[1] == $y[2]) {
- $y[1] += ($this->_moduleSize / 2);
- $y[2] += ($this->_moduleSize / 2);
+ $y[1] += ($this->moduleSize / 2);
+ $y[2] += ($this->moduleSize / 2);
}
}
- $color = new Zend_Pdf_Color_RGB(
- ($color & 0xFF0000) >> 16,
- ($color & 0x00FF00) >> 8,
- $color & 0x0000FF
+ $color = new Color\Rgb(
+ (($color & 0xFF0000) >> 16) / 255.0,
+ (($color & 0x00FF00) >> 8) / 255.0,
+ ($color & 0x0000FF) / 255.0
);
$page->setLineColor($color);
$page->setFillColor($color);
- $page->setLineWidth($this->_moduleSize);
+ $page->setLineWidth($this->moduleSize);
$fillType = ($filled)
- ? Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE
- : Zend_Pdf_Page::SHAPE_DRAW_STROKE;
+ ? Page::SHAPE_DRAW_FILL_AND_STROKE
+ : Page::SHAPE_DRAW_STROKE;
$page->drawPolygon($x, $y, $fillType);
}
/**
* Draw a polygon in the rendering resource
- * @param string $text
- * @param float $size
- * @param array $position
- * @param string $font
- * @param integer $color
- * @param string $alignment
- * @param float $orientation
+ * @param string $text
+ * @param float $size
+ * @param array $position
+ * @param string $font
+ * @param int $color
+ * @param string $alignment
+ * @param float $orientation
*/
- protected function _drawText(
+ protected function drawText(
$text,
$size,
$position,
@@ -184,26 +155,26 @@
$alignment = 'center',
$orientation = 0
) {
- $page = $this->_resource->pages[$this->_page];
- $color = new Zend_Pdf_Color_RGB(
- ($color & 0xFF0000) >> 16,
- ($color & 0x00FF00) >> 8,
- $color & 0x0000FF
+ $page = $this->resource->pages[$this->page];
+ $color = new Color\Rgb(
+ (($color & 0xFF0000) >> 16) / 255.0,
+ (($color & 0x00FF00) >> 8) / 255.0,
+ ($color & 0x0000FF) / 255.0
);
$page->setLineColor($color);
$page->setFillColor($color);
- $page->setFont(Zend_Pdf_Font::fontWithPath($font), $size * $this->_moduleSize * 1.2);
+ $page->setFont(Font::fontWithPath($font), $size * $this->moduleSize * 1.2);
$width = $this->widthForStringUsingFontSize(
$text,
- Zend_Pdf_Font::fontWithPath($font),
- $size * $this->_moduleSize
+ Font::fontWithPath($font),
+ $size * $this->moduleSize
);
$angle = pi() * $orientation / 180;
- $left = $position[0] * $this->_moduleSize + $this->_leftOffset;
- $top = $page->getHeight() - $position[1] * $this->_moduleSize - $this->_topOffset;
+ $left = $position[0] * $this->moduleSize + $this->leftOffset;
+ $top = $page->getHeight() - $position[1] * $this->moduleSize - $this->topOffset;
switch ($alignment) {
case 'center':
@@ -223,7 +194,7 @@
* Calculate the width of a string:
* in case of using alignment parameter in drawText
* @param string $text
- * @param Zend_Pdf_Font $font
+ * @param Font $font
* @param float $fontSize
* @return float
*/
@@ -231,7 +202,7 @@
{
$drawingString = iconv('UTF-8', 'UTF-16BE//IGNORE', $text);
$characters = array();
- for ($i = 0; $i < strlen($drawingString); $i ++) {
+ for ($i = 0, $len = strlen($drawingString); $i < $len; $i++) {
$characters[] = (ord($drawingString[$i ++]) << 8) | ord($drawingString[$i]);
}
$glyphs = $font->glyphNumbersForCharacters($characters);
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Renderer/RendererAbstract.php zendframework-2.2.6/library/Zend/Barcode/Renderer/RendererAbstract.php
--- zendframework-1.10.4/library/Zend/Barcode/Renderer/RendererAbstract.php 2010-01-15 22:27:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Renderer/RendererAbstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,540 +0,0 @@
-toArray();
- }
- if (is_array($options)) {
- $this->setOptions($options);
- }
- $this->_type = strtolower(substr(
- get_class($this),
- strlen($this->_rendererNamespace) + 1
- ));
- }
-
- /**
- * Set renderer state from options array
- * @param array $options
- * @return Zend_Renderer_Object
- */
- public function setOptions($options)
- {
- foreach ($options as $key => $value) {
- $method = 'set' . $key;
- if (method_exists($this, $method)) {
- $this->$method($value);
- }
- }
- return $this;
- }
-
- /**
- * Set renderer state from config object
- * @param Zend_Config $config
- * @return Zend_Renderer_Object
- */
- public function setConfig(Zend_Config $config)
- {
- return $this->setOptions($config->toArray());
- }
-
- /**
- * Set renderer namespace for autoloading
- *
- * @param string $namespace
- * @return Zend_Renderer_Object
- */
- public function setRendererNamespace($namespace)
- {
- $this->_rendererNamespace = $namespace;
- return $this;
- }
-
- /**
- * Retrieve renderer namespace
- *
- * @return string
- */
- public function getRendererNamespace()
- {
- return $this->_rendererNamespace;
- }
-
- /**
- * Retrieve renderer type
- * @return string
- */
- public function getType()
- {
- return $this->_type;
- }
-
- /**
- * Manually adjust top position
- * @param integer $value
- * @return Zend_Barcode_Renderer
- * @throw Zend_Barcode_Renderer_Exception
- */
- public function setTopOffset($value)
- {
- if (!is_numeric($value) || intval($value) < 0) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
- 'Vertical position must be greater than or equals 0'
- );
- }
- $this->_topOffset = intval($value);
- return $this;
- }
-
- /**
- * Retrieve vertical adjustment
- * @return integer
- */
- public function getTopOffset()
- {
- return $this->_topOffset;
- }
-
- /**
- * Manually adjust left position
- * @param integer $value
- * @return Zend_Barcode_Renderer
- * @throw Zend_Barcode_Renderer_Exception
- */
- public function setLeftOffset($value)
- {
- if (!is_numeric($value) || intval($value) < 0) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
- 'Horizontal position must be greater than or equals 0'
- );
- }
- $this->_leftOffset = intval($value);
- return $this;
- }
-
- /**
- * Retrieve vertical adjustment
- * @return integer
- */
- public function getLeftOffset()
- {
- return $this->_leftOffset;
- }
-
- /**
- * Activate/Deactivate the automatic rendering of exception
- * @param boolean $value
- */
- public function setAutomaticRenderError($value)
- {
- $this->_automaticRenderError = (bool) $value;
- return $this;
- }
-
- /**
- * Horizontal position of the barcode in the rendering resource
- * @param string $value
- * @return Zend_Barcode_Renderer
- * @throw Zend_Barcode_Renderer_Exception
- */
- public function setHorizontalPosition($value)
- {
- if (!in_array($value, array('left' , 'center' , 'right'))) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
- "Invalid barcode position provided must be 'left', 'center' or 'right'"
- );
- }
- $this->_horizontalPosition = $value;
- return $this;
- }
-
- /**
- * Horizontal position of the barcode in the rendering resource
- * @return string
- */
- public function getHorizontalPosition()
- {
- return $this->_horizontalPosition;
- }
-
- /**
- * Vertical position of the barcode in the rendering resource
- * @param string $value
- * @return Zend_Barcode_Renderer
- * @throw Zend_Barcode_Renderer_Exception
- */
- public function setVerticalPosition($value)
- {
- if (!in_array($value, array('top' , 'middle' , 'bottom'))) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
- "Invalid barcode position provided must be 'top', 'middle' or 'bottom'"
- );
- }
- $this->_verticalPosition = $value;
- return $this;
- }
-
- /**
- * Vertical position of the barcode in the rendering resource
- * @return string
- */
- public function getVerticalPosition()
- {
- return $this->_verticalPosition;
- }
-
- /**
- * Set the size of a module
- * @param float $value
- * @return Zend_Barcode_Renderer
- * @throw Zend_Barcode_Renderer_Exception
- */
- public function setModuleSize($value)
- {
- if (!is_numeric($value) || floatval($value) <= 0) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
- 'Float size must be greater than 0'
- );
- }
- $this->_moduleSize = floatval($value);
- return $this;
- }
-
-
- /**
- * Set the size of a module
- * @return float
- */
- public function getModuleSize()
- {
- return $this->_moduleSize;
- }
-
- /**
- * Retrieve the automatic rendering of exception
- * @return boolean
- */
- public function getAutomaticRenderError()
- {
- return $this->_automaticRenderError;
- }
-
- /**
- * Set the barcode object
- * @param Zend_Barcode_Object $barcode
- * @return Zend_Barcode_Renderer
- */
- public function setBarcode($barcode)
- {
- if (!$barcode instanceof Zend_Barcode_Object_ObjectAbstract) {
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
- 'Invalid barcode object provided to setBarcode()'
- );
- }
- $this->_barcode = $barcode;
- return $this;
- }
-
- /**
- * Retrieve the barcode object
- * @return Zend_Barcode_Object
- */
- public function getBarcode()
- {
- return $this->_barcode;
- }
-
- /**
- * Checking of parameters after all settings
- * @return boolean
- */
- public function checkParams()
- {
- $this->_checkBarcodeObject();
- $this->_checkParams();
- return true;
- }
-
- /**
- * Check if a barcode object is correctly provided
- * @return void
- * @throw Zend_Barcode_Renderer_Exception
- */
- protected function _checkBarcodeObject()
- {
- if ($this->_barcode === null) {
- /**
- * @see Zend_Barcode_Renderer_Exception
- */
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
- 'No barcode object provided'
- );
- }
- }
-
- /**
- * Calculate the left and top offset of the barcode in the
- * rendering support
- *
- * @param float $supportHeight
- * @param float $supportWidth
- * @return void
- */
- protected function _adjustPosition($supportHeight, $supportWidth)
- {
- $barcodeHeight = $this->_barcode->getHeight(true) * $this->_moduleSize;
- if ($barcodeHeight != $supportHeight && $this->_topOffset == 0) {
- switch ($this->_verticalPosition) {
- case 'middle':
- $this->_topOffset = floor(
- ($supportHeight - $barcodeHeight) / 2);
- break;
- case 'bottom':
- $this->_topOffset = $supportHeight - $barcodeHeight;
- break;
- case 'top':
- default:
- $this->_topOffset = 0;
- break;
- }
- }
- $barcodeWidth = $this->_barcode->getWidth(true) * $this->_moduleSize;
- if ($barcodeWidth != $supportWidth && $this->_leftOffset == 0) {
- switch ($this->_horizontalPosition) {
- case 'center':
- $this->_leftOffset = floor(
- ($supportWidth - $barcodeWidth) / 2);
- break;
- case 'right':
- $this->_leftOffset = $supportWidth - $barcodeWidth;
- break;
- case 'left':
- default:
- $this->_leftOffset = 0;
- break;
- }
- }
- }
-
- /**
- * Draw the barcode in the rendering resource
- * @return mixed
- */
- public function draw()
- {
- try {
- $this->checkParams();
- $this->_initRenderer();
- $this->_drawInstructionList();
- } catch (Zend_Exception $e) {
- $renderable = false;
- if ($e instanceof Zend_Barcode_Exception) {
- $renderable = $e->isRenderable();
- }
- if ($this->_automaticRenderError && $renderable) {
- $barcode = Zend_Barcode::makeBarcode(
- 'error',
- array('text' => $e->getMessage())
- );
- $this->setBarcode($barcode);
- $this->_resource = null;
- $this->_initRenderer();
- $this->_drawInstructionList();
- } else {
- if ($e instanceof Zend_Barcode_Exception) {
- $e->setIsRenderable(false);
- }
- throw $e;
- }
- }
- return $this->_resource;
- }
-
- /**
- * Sub process to draw the barcode instructions
- * Needed by the automatic error rendering
- */
- private function _drawInstructionList()
- {
- $instructionList = $this->_barcode->draw();
- foreach ($instructionList as $instruction) {
- switch ($instruction['type']) {
- case 'polygon':
- $this->_drawPolygon(
- $instruction['points'],
- $instruction['color'],
- $instruction['filled']
- );
- break;
- case 'text': //$text, $size, $position, $font, $color, $alignment = 'center', $orientation = 0)
- $this->_drawText(
- $instruction['text'],
- $instruction['size'],
- $instruction['position'],
- $instruction['font'],
- $instruction['color'],
- $instruction['alignment'],
- $instruction['orientation']
- );
- break;
- default:
- /**
- * @see Zend_Barcode_Renderer_Exception
- */
- require_once 'Zend/Barcode/Renderer/Exception.php';
- throw new Zend_Barcode_Renderer_Exception(
- 'Unkown drawing command'
- );
- }
- }
- }
-
- /**
- * Checking of parameters after all settings
- * @return void
- */
- abstract protected function _checkParams();
-
- /**
- * Render the resource by sending headers and drawed resource
- * @return mixed
- */
- abstract public function render();
-
- /**
- * Initialize the rendering resource
- * @return void
- */
- abstract protected function _initRenderer();
-
- /**
- * Draw a polygon in the rendering resource
- * @param array $points
- * @param integer $color
- * @param boolean $filled
- */
- abstract protected function _drawPolygon($points, $color, $filled = true);
-
- /**
- * Draw a polygon in the rendering resource
- * @param string $text
- * @param float $size
- * @param array $position
- * @param string $font
- * @param integer $color
- * @param string $alignment
- * @param float $orientation
- */
- abstract protected function _drawText(
- $text,
- $size,
- $position,
- $font,
- $color,
- $alignment = 'center',
- $orientation = 0
- );
-}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/Renderer/RendererInterface.php zendframework-2.2.6/library/Zend/Barcode/Renderer/RendererInterface.php
--- zendframework-1.10.4/library/Zend/Barcode/Renderer/RendererInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/Renderer/RendererInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,160 @@
+userHeight = intval($value);
+ return $this;
+ }
+
+ /**
+ * Get barcode height
+ *
+ * @return int
+ */
+ public function getHeight()
+ {
+ return $this->userHeight;
+ }
+
+ /**
+ * Set barcode width
+ *
+ * @param mixed $value
+ * @throws Exception\OutOfRangeException
+ * @return self
+ */
+ public function setWidth($value)
+ {
+ if (!is_numeric($value) || intval($value) < 0) {
+ throw new Exception\OutOfRangeException(
+ 'Svg width must be greater than or equals 0'
+ );
+ }
+ $this->userWidth = intval($value);
+ return $this;
+ }
+
+ /**
+ * Get barcode width
+ *
+ * @return int
+ */
+ public function getWidth()
+ {
+ return $this->userWidth;
+ }
+
+ /**
+ * Set an image resource to draw the barcode inside
+ *
+ * @param DOMDocument $svg
+ * @return Svg
+ */
+ public function setResource(DOMDocument $svg)
+ {
+ $this->resource = $svg;
+ return $this;
+ }
+
+ /**
+ * Initialize the image resource
+ *
+ * @return void
+ */
+ protected function initRenderer()
+ {
+ $barcodeWidth = $this->barcode->getWidth(true);
+ $barcodeHeight = $this->barcode->getHeight(true);
+
+ $backgroundColor = $this->barcode->getBackgroundColor();
+ $imageBackgroundColor = 'rgb(' . implode(', ', array(($backgroundColor & 0xFF0000) >> 16,
+ ($backgroundColor & 0x00FF00) >> 8,
+ ($backgroundColor & 0x0000FF))) . ')';
+
+ $width = $barcodeWidth;
+ $height = $barcodeHeight;
+ if ($this->userWidth && $this->barcode->getType() != 'error') {
+ $width = $this->userWidth;
+ }
+ if ($this->userHeight && $this->barcode->getType() != 'error') {
+ $height = $this->userHeight;
+ }
+ if ($this->resource === null) {
+ $this->resource = new DOMDocument('1.0', 'utf-8');
+ $this->resource->formatOutput = true;
+ $this->rootElement = $this->resource->createElement('svg');
+ $this->rootElement->setAttribute('xmlns', "http://www.w3.org/2000/svg");
+ $this->rootElement->setAttribute('version', '1.1');
+ $this->rootElement->setAttribute('width', $width);
+ $this->rootElement->setAttribute('height', $height);
+
+ $this->appendRootElement('title',
+ array(),
+ "Barcode " . strtoupper($this->barcode->getType()) . " " . $this->barcode->getText());
+ } else {
+ $this->readRootElement();
+ $width = $this->rootElement->getAttribute('width');
+ $height = $this->rootElement->getAttribute('height');
+ }
+ $this->adjustPosition($height, $width);
+
+ $rect = array('x' => $this->leftOffset,
+ 'y' => $this->topOffset,
+ 'width' => ($this->leftOffset + $barcodeWidth - 1),
+ 'height' => ($this->topOffset + $barcodeHeight - 1),
+ 'fill' => $imageBackgroundColor);
+
+ if($this->transparentBackground) {
+ $rect['fill-opacity'] = 0;
+ }
+
+ $this->appendRootElement('rect', $rect);
+ }
+
+ protected function readRootElement()
+ {
+ if ($this->resource !== null) {
+ $this->rootElement = $this->resource->documentElement;
+ }
+ }
+
+ /**
+ * Append a new DOMElement to the root element
+ *
+ * @param string $tagName
+ * @param array $attributes
+ * @param string $textContent
+ */
+ protected function appendRootElement($tagName, $attributes = array(), $textContent = null)
+ {
+ $newElement = $this->createElement($tagName, $attributes, $textContent);
+ $this->rootElement->appendChild($newElement);
+ }
+
+ /**
+ * Create DOMElement
+ *
+ * @param string $tagName
+ * @param array $attributes
+ * @param string $textContent
+ * @return DOMElement
+ */
+ protected function createElement($tagName, $attributes = array(), $textContent = null)
+ {
+ $element = $this->resource->createElement($tagName);
+ foreach ($attributes as $k => $v) {
+ $element->setAttribute($k, $v);
+ }
+ if ($textContent !== null) {
+ $element->appendChild(new DOMText((string) $textContent));
+ }
+ return $element;
+ }
+
+ /**
+ * Check barcode parameters
+ *
+ * @return void
+ */
+ protected function checkSpecificParams()
+ {
+ $this->checkDimensions();
+ }
+
+ /**
+ * Check barcode dimensions
+ *
+ * @throws Exception\RuntimeException
+ * @return void
+ */
+ protected function checkDimensions()
+ {
+ if ($this->resource !== null) {
+ $this->readRootElement();
+ $height = (float) $this->rootElement->getAttribute('height');
+ if ($height < $this->barcode->getHeight(true)) {
+ throw new Exception\RuntimeException(
+ 'Barcode is define outside the image (height)'
+ );
+ }
+ } else {
+ if ($this->userHeight) {
+ $height = $this->barcode->getHeight(true);
+ if ($this->userHeight < $height) {
+ throw new Exception\RuntimeException(sprintf(
+ "Barcode is define outside the image (calculated: '%d', provided: '%d')",
+ $height,
+ $this->userHeight
+ ));
+ }
+ }
+ }
+ if ($this->resource !== null) {
+ $this->readRootElement();
+ $width = $this->rootElement->getAttribute('width');
+ if ($width < $this->barcode->getWidth(true)) {
+ throw new Exception\RuntimeException(
+ 'Barcode is define outside the image (width)'
+ );
+ }
+ } else {
+ if ($this->userWidth) {
+ $width = (float) $this->barcode->getWidth(true);
+ if ($this->userWidth < $width) {
+ throw new Exception\RuntimeException(sprintf(
+ "Barcode is define outside the image (calculated: '%d', provided: '%d')",
+ $width,
+ $this->userWidth
+ ));
+ }
+ }
+ }
+ }
+
+ /**
+ * Draw the barcode in the rendering resource
+ * @return mixed
+ */
+ public function draw()
+ {
+ parent::draw();
+ $this->resource->appendChild($this->rootElement);
+ return $this->resource;
+ }
+
+ /**
+ * Draw and render the barcode with correct headers
+ *
+ * @return mixed
+ */
+ public function render()
+ {
+ $this->draw();
+ header("Content-Type: image/svg+xml");
+ echo $this->resource->saveXML();
+ }
+
+ /**
+ * Draw a polygon in the svg resource
+ *
+ * @param array $points
+ * @param int $color
+ * @param bool $filled
+ */
+ protected function drawPolygon($points, $color, $filled = true)
+ {
+ $color = 'rgb(' . implode(', ', array(($color & 0xFF0000) >> 16,
+ ($color & 0x00FF00) >> 8,
+ ($color & 0x0000FF))) . ')';
+ $orientation = $this->getBarcode()->getOrientation();
+ $newPoints = array(
+ $points[0][0] + $this->leftOffset,
+ $points[0][1] + $this->topOffset,
+ $points[1][0] + $this->leftOffset,
+ $points[1][1] + $this->topOffset,
+ $points[2][0] + $this->leftOffset + cos(-$orientation),
+ $points[2][1] + $this->topOffset - sin($orientation),
+ $points[3][0] + $this->leftOffset + cos(-$orientation),
+ $points[3][1] + $this->topOffset - sin($orientation),
+ );
+ $newPoints = implode(' ', $newPoints);
+ $attributes['points'] = $newPoints;
+ $attributes['fill'] = $color;
+
+ // SVG passes a rect in as the first call to drawPolygon, we'll need to intercept
+ // this and set transparency if necessary.
+ $objId = spl_object_hash($this);
+ if(!$this->drawPolygonExecuted) {
+ if($this->transparentBackground) {
+ $attributes['fill-opacity'] = '0';
+ }
+ $this->drawPolygonExecuted = true;
+ }
+
+ $this->appendRootElement('polygon', $attributes);
+ }
+
+ /**
+ * Draw a polygon in the svg resource
+ *
+ * @param string $text
+ * @param float $size
+ * @param array $position
+ * @param string $font
+ * @param int $color
+ * @param string $alignment
+ * @param float $orientation
+ */
+ protected function drawText($text, $size, $position, $font, $color, $alignment = 'center', $orientation = 0)
+ {
+ $color = 'rgb(' . implode(', ', array(($color & 0xFF0000) >> 16,
+ ($color & 0x00FF00) >> 8,
+ ($color & 0x0000FF))) . ')';
+ $attributes['x'] = $position[0] + $this->leftOffset;
+ $attributes['y'] = $position[1] + $this->topOffset;
+ //$attributes['font-family'] = $font;
+ $attributes['color'] = $color;
+ $attributes['font-size'] = $size * 1.2;
+ switch ($alignment) {
+ case 'left':
+ $textAnchor = 'start';
+ break;
+ case 'right':
+ $textAnchor = 'end';
+ break;
+ case 'center':
+ default:
+ $textAnchor = 'middle';
+ }
+ $attributes['style'] = 'text-anchor: ' . $textAnchor;
+ $attributes['transform'] = 'rotate('
+ . (- $orientation)
+ . ', '
+ . ($position[0] + $this->leftOffset)
+ . ', ' . ($position[1] + $this->topOffset)
+ . ')';
+ $this->appendRootElement('text', $attributes, $text);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Barcode/RendererPluginManager.php zendframework-2.2.6/library/Zend/Barcode/RendererPluginManager.php
--- zendframework-1.10.4/library/Zend/Barcode/RendererPluginManager.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode/RendererPluginManager.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,62 @@
+ 'Zend\Barcode\Renderer\Image',
+ 'pdf' => 'Zend\Barcode\Renderer\Pdf',
+ 'svg' => 'Zend\Barcode\Renderer\Svg'
+ );
+
+ /**
+ * Validate the plugin
+ *
+ * Checks that the barcode parser loaded is an instance
+ * of Renderer\AbstractRenderer.
+ *
+ * @param mixed $plugin
+ * @return void
+ * @throws Exception\InvalidArgumentException if invalid
+ */
+ public function validatePlugin($plugin)
+ {
+ if ($plugin instanceof Renderer\AbstractRenderer) {
+ // we're okay
+ return;
+ }
+
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Plugin of type %s is invalid; must extend %s\Renderer\AbstractRenderer',
+ (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
+ __NAMESPACE__
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Barcode.php zendframework-2.2.6/library/Zend/Barcode.php
--- zendframework-1.10.4/library/Zend/Barcode.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Barcode.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,352 +0,0 @@
-rendererParams)) {
- $rendererConfig = $barcode->rendererParams->toArray();
- }
- if (isset($barcode->renderer)) {
- $renderer = (string) $barcode->renderer;
- }
- if (isset($barcode->barcodeParams)) {
- $barcodeConfig = $barcode->barcodeParams->toArray();
- }
- if (isset($barcode->barcode)) {
- $barcode = (string) $barcode->barcode;
- } else {
- $barcode = null;
- }
- }
-
- try {
- $barcode = self::makeBarcode($barcode, $barcodeConfig);
- $renderer = self::makeRenderer($renderer, $rendererConfig);
- } catch (Zend_Exception $e) {
- $renderable = ($e instanceof Zend_Barcode_Exception) ? $e->isRenderable() : false;
- if ($automaticRenderError && $renderable) {
- $barcode = self::makeBarcode('error', array(
- 'text' => $e->getMessage()
- ));
- $renderer = self::makeRenderer($renderer, array());
- } else {
- throw $e;
- }
- }
-
- $renderer->setAutomaticRenderError($automaticRenderError);
- return $renderer->setBarcode($barcode);
- }
-
- /**
- * Barcode Constructor
- *
- * @param mixed $barcode String name of barcode class, or Zend_Config object.
- * @param mixed $barcodeConfig OPTIONAL; an array or Zend_Config object with barcode parameters.
- * @return Zend_Barcode_Object
- */
- public static function makeBarcode($barcode, $barcodeConfig = array())
- {
- if ($barcode instanceof Zend_Barcode_Object_ObjectAbstract) {
- return $barcode;
- }
-
- /*
- * Convert Zend_Config argument to plain string
- * barcode name and separate config object.
- */
- if ($barcode instanceof Zend_Config) {
- if (isset($barcode->barcodeParams) && $barcode->barcodeParams instanceof Zend_Config) {
- $barcodeConfig = $barcode->barcodeParams->toArray();
- }
- if (isset($barcode->barcode)) {
- $barcode = (string) $barcode->barcode;
- } else {
- $barcode = null;
- }
- }
- if ($barcodeConfig instanceof Zend_Config) {
- $barcodeConfig = $barcodeConfig->toArray();
- }
-
- /*
- * Verify that barcode parameters are in an array.
- */
- if (!is_array($barcodeConfig)) {
- /**
- * @see Zend_Barcode_Exception
- */
- require_once 'Zend/Barcode/Exception.php';
- throw new Zend_Barcode_Exception(
- 'Barcode parameters must be in an array or a Zend_Config object'
- );
- }
-
- /*
- * Verify that an barcode name has been specified.
- */
- if (!is_string($barcode) || empty($barcode)) {
- /**
- * @see Zend_Barcode_Exception
- */
- require_once 'Zend/Barcode/Exception.php';
- throw new Zend_Barcode_Exception(
- 'Barcode name must be specified in a string'
- );
- }
- /*
- * Form full barcode class name
- */
- $barcodeNamespace = 'Zend_Barcode_Object';
- if (isset($barcodeConfig['barcodeNamespace'])) {
- $barcodeNamespace = $barcodeConfig['barcodeNamespace'];
- }
-
- $barcodeName = strtolower($barcodeNamespace . '_' . $barcode);
- $barcodeName = str_replace(' ', '_', ucwords(
- str_replace( '_', ' ', $barcodeName)
- ));
-
- /*
- * Load the barcode class. This throws an exception
- * if the specified class cannot be loaded.
- */
- if (!class_exists($barcodeName)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($barcodeName);
- }
-
- /*
- * Create an instance of the barcode class.
- * Pass the config to the barcode class constructor.
- */
- $bcAdapter = new $barcodeName($barcodeConfig);
-
- /*
- * Verify that the object created is a descendent of the abstract barcode type.
- */
- if (!$bcAdapter instanceof Zend_Barcode_Object_ObjectAbstract) {
- /**
- * @see Zend_Barcode_Exception
- */
- require_once 'Zend/Barcode/Exception.php';
- throw new Zend_Barcode_Exception(
- "Barcode class '$barcodeName' does not extend Zend_Barcode_Object_ObjectAbstract"
- );
- }
- return $bcAdapter;
- }
-
- /**
- * Renderer Constructor
- *
- * @param mixed $renderer String name of renderer class, or Zend_Config object.
- * @param mixed $rendererConfig OPTIONAL; an array or Zend_Config object with renderer parameters.
- * @return Zend_Barcode_Renderer
- */
- public static function makeRenderer($renderer = 'image', $rendererConfig = array())
- {
- if ($renderer instanceof Zend_Barcode_Renderer_RendererAbstract) {
- return $renderer;
- }
-
- /*
- * Convert Zend_Config argument to plain string
- * barcode name and separate config object.
- */
- if ($renderer instanceof Zend_Config) {
- if (isset($renderer->rendererParams)) {
- $rendererConfig = $renderer->rendererParams->toArray();
- }
- if (isset($renderer->renderer)) {
- $renderer = (string) $renderer->renderer;
- }
- }
- if ($rendererConfig instanceof Zend_Config) {
- $rendererConfig = $rendererConfig->toArray();
- }
-
- /*
- * Verify that barcode parameters are in an array.
- */
- if (!is_array($rendererConfig)) {
- /**
- * @see Zend_Barcode_Exception
- */
- require_once 'Zend/Barcode/Exception.php';
- $e = new Zend_Barcode_Exception(
- 'Barcode parameters must be in an array or a Zend_Config object'
- );
- $e->setIsRenderable(false);
- throw $e;
- }
-
- /*
- * Verify that an barcode name has been specified.
- */
- if (!is_string($renderer) || empty($renderer)) {
- /**
- * @see Zend_Barcode_Exception
- */
- require_once 'Zend/Barcode/Exception.php';
- $e = new Zend_Barcode_Exception(
- 'Renderer name must be specified in a string'
- );
- $e->setIsRenderable(false);
- throw $e;
- }
-
- /*
- * Form full barcode class name
- */
- $rendererNamespace = 'Zend_Barcode_Renderer';
- if (isset($rendererConfig['rendererNamespace'])) {
- $rendererNamespace = $rendererConfig['rendererNamespace'];
- }
-
- $rendererName = strtolower($rendererNamespace . '_' . $renderer);
- $rendererName = str_replace(' ', '_', ucwords(
- str_replace( '_', ' ', $rendererName)
- ));
-
- /*
- * Load the barcode class. This throws an exception
- * if the specified class cannot be loaded.
- */
- if (!class_exists($rendererName)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($rendererName);
- }
-
- /*
- * Create an instance of the barcode class.
- * Pass the config to the barcode class constructor.
- */
- $rdrAdapter = new $rendererName($rendererConfig);
-
- /*
- * Verify that the object created is a descendent of the abstract barcode type.
- */
- if (!$rdrAdapter instanceof Zend_Barcode_Renderer_RendererAbstract) {
- /**
- * @see Zend_Barcode_Exception
- */
- require_once 'Zend/Barcode/Exception.php';
- $e = new Zend_Barcode_Exception(
- "Renderer class '$rendererName' does not extend Zend_Barcode_Renderer_RendererAbstract"
- );
- $e->setIsRenderable(false);
- throw $e;
- }
- return $rdrAdapter;
- }
-
- /**
- * Proxy to renderer render() method
- *
- * @param string | Zend_Barcode_Object | array | Zend_Config $barcode
- * @param string | Zend_Barcode_Renderer $renderer
- * @param array | Zend_Config $barcodeConfig
- * @param array | Zend_Config $rendererConfig
- */
- public static function render(
- $barcode,
- $renderer,
- $barcodeConfig = array(),
- $rendererConfig = array()
- ) {
- self::factory($barcode, $renderer, $barcodeConfig, $rendererConfig)->render();
- }
-
- /**
- * Proxy to renderer draw() method
- *
- * @param string | Zend_Barcode_Object | array | Zend_Config $barcode
- * @param string | Zend_Barcode_Renderer $renderer
- * @param array | Zend_Config $barcodeConfig
- * @param array | Zend_Config $rendererConfig
- * @return mixed
- */
- public static function draw(
- $barcode,
- $renderer,
- $barcodeConfig = array(),
- $rendererConfig = array()
- ) {
- return self::factory($barcode, $renderer, $barcodeConfig, $rendererConfig)->draw();
- }
-
- /**
- * Proxy for setBarcodeFont of Zend_Barcode_Object
- * @param string $font
- * @eturn void
- */
- public static function setBarcodeFont($font)
- {
- require_once 'Zend/Barcode/Object/ObjectAbstract.php';
- Zend_Barcode_Object_ObjectAbstract::setBarcodeFont($font);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/Apc.php zendframework-2.2.6/library/Zend/Cache/Backend/Apc.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/Apc.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/Apc.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,355 +0,0 @@
- infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $lifetime = $this->getLifetime($specificLifetime);
- $result = apc_store($id, array($data, time(), $lifetime), $lifetime);
- if (count($tags) > 0) {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
- }
- return $result;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id cache id
- * @return boolean true if no problem
- */
- public function remove($id)
- {
- return apc_delete($id);
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => unsupported
- * 'matchingTag' => unsupported
- * 'notMatchingTag' => unsupported
- * 'matchingAnyTag' => unsupported
- *
- * @param string $mode clean mode
- * @param array $tags array of tags
- * @throws Zend_Cache_Exception
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- return apc_clear_cache('user');
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $this->_log("Zend_Cache_Backend_Apc::clean() : CLEANING_MODE_OLD is unsupported by the Apc backend");
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_APC_BACKEND);
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-
- /**
- * Return true if the automatic cleaning is available for the backend
- *
- * DEPRECATED : use getCapabilities() instead
- *
- * @deprecated
- * @return boolean
- */
- public function isAutomaticCleaningAvailable()
- {
- return false;
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @throws Zend_Cache_Exception
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- $mem = apc_sma_info(true);
- $memSize = $mem['num_seg'] * $mem['seg_size'];
- $memAvailable= $mem['avail_mem'];
- $memUsed = $memSize - $memAvailable;
- if ($memSize == 0) {
- Zend_Cache::throwException('can\'t get apc memory size');
- }
- if ($memUsed > $memSize) {
- return 100;
- }
- return ((int) (100. * ($memUsed / $memSize)));
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- $res = array();
- $array = apc_cache_info('user', false);
- $records = $array['cache_list'];
- foreach ($records as $record) {
- $res[] = $record['info'];
- }
- return $res;
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- $tmp = apc_fetch($id);
- if (is_array($tmp)) {
- $data = $tmp[0];
- $mtime = $tmp[1];
- if (!isset($tmp[2])) {
- // because this record is only with 1.7 release
- // if old cache records are still there...
- return false;
- }
- $lifetime = $tmp[2];
- return array(
- 'expire' => $mtime + $lifetime,
- 'tags' => array(),
- 'mtime' => $mtime
- );
- }
- return false;
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- $tmp = apc_fetch($id);
- if (is_array($tmp)) {
- $data = $tmp[0];
- $mtime = $tmp[1];
- if (!isset($tmp[2])) {
- // because this record is only with 1.7 release
- // if old cache records are still there...
- return false;
- }
- $lifetime = $tmp[2];
- $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime;
- if ($newLifetime <=0) {
- return false;
- }
- apc_store($id, array($data, time(), $newLifetime), $newLifetime);
- return true;
- }
- return false;
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => false,
- 'tags' => false,
- 'expired_read' => false,
- 'priority' => false,
- 'infinite_lifetime' => false,
- 'get_list' => true
- );
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/BlackHole.php zendframework-2.2.6/library/Zend/Cache/Backend/BlackHole.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/BlackHole.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/BlackHole.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,250 +0,0 @@
- infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- return true;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id cache id
- * @return boolean true if no problem
- */
- public function remove($id)
- {
- return true;
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => remove too old cache entries ($tags is not used)
- * 'matchingTag' => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * 'notMatchingTag' => remove cache entries not matching one of the given tags
- * ($tags can be an array of strings or a single string)
- * 'matchingAnyTag' => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode clean mode
- * @param tags array $tags array of tags
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- return true;
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- return array();
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- return array();
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- return array();
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @return int integer between 0 and 100
- * @throws Zend_Cache_Exception
- */
- public function getFillingPercentage()
- {
- return 0;
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- return false;
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- return false;
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => true,
- 'tags' => true,
- 'expired_read' => true,
- 'priority' => true,
- 'infinite_lifetime' => true,
- 'get_list' => true,
- );
- }
-
- /**
- * PUBLIC METHOD FOR UNIT TESTING ONLY !
- *
- * Force a cache record to expire
- *
- * @param string $id cache id
- */
- public function ___expire($id)
- {
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/ExtendedInterface.php zendframework-2.2.6/library/Zend/Cache/Backend/ExtendedInterface.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/ExtendedInterface.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/ExtendedInterface.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,126 +0,0 @@
- (string) cache_dir :
- * - Directory where to put the cache files
- *
- * =====> (boolean) file_locking :
- * - Enable / disable file_locking
- * - Can avoid cache corruption under bad circumstances but it doesn't work on multithread
- * webservers and on NFS filesystems for example
- *
- * =====> (boolean) read_control :
- * - Enable / disable read control
- * - If enabled, a control key is embeded in cache file and this key is compared with the one
- * calculated after the reading.
- *
- * =====> (string) read_control_type :
- * - Type of read control (only if read control is enabled). Available values are :
- * 'md5' for a md5 hash control (best but slowest)
- * 'crc32' for a crc32 hash control (lightly less safe but faster, better choice)
- * 'adler32' for an adler32 hash control (excellent choice too, faster than crc32)
- * 'strlen' for a length only test (fastest)
- *
- * =====> (int) hashed_directory_level :
- * - Hashed directory level
- * - Set the hashed directory structure level. 0 means "no hashed directory
- * structure", 1 means "one level of directory", 2 means "two levels"...
- * This option can speed up the cache only when you have many thousands of
- * cache file. Only specific benchs can help you to choose the perfect value
- * for you. Maybe, 1 or 2 is a good start.
- *
- * =====> (int) hashed_directory_umask :
- * - Umask for hashed directory structure
- *
- * =====> (string) file_name_prefix :
- * - prefix for cache files
- * - be really carefull with this option because a too generic value in a system cache dir
- * (like /tmp) can cause disasters when cleaning the cache
- *
- * =====> (int) cache_file_umask :
- * - Umask for cache files
- *
- * =====> (int) metatadatas_array_max_size :
- * - max size for the metadatas array (don't change this value unless you
- * know what you are doing)
- *
- * @var array available options
- */
- protected $_options = array(
- 'cache_dir' => null,
- 'file_locking' => true,
- 'read_control' => true,
- 'read_control_type' => 'crc32',
- 'hashed_directory_level' => 0,
- 'hashed_directory_umask' => 0700,
- 'file_name_prefix' => 'zend_cache',
- 'cache_file_umask' => 0600,
- 'metadatas_array_max_size' => 100
- );
-
- /**
- * Array of metadatas (each item is an associative array)
- *
- * @var array
- */
- protected $_metadatasArray = array();
-
-
- /**
- * Constructor
- *
- * @param array $options associative array of options
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- parent::__construct($options);
- if ($this->_options['cache_dir'] !== null) { // particular case for this option
- $this->setCacheDir($this->_options['cache_dir']);
- } else {
- $this->setCacheDir(self::getTmpDir() . DIRECTORY_SEPARATOR, false);
- }
- if (isset($this->_options['file_name_prefix'])) { // particular case for this option
- if (!preg_match('~^[a-zA-Z0-9_]+$~D', $this->_options['file_name_prefix'])) {
- Zend_Cache::throwException('Invalid file_name_prefix : must use only [a-zA-Z0-9_]');
- }
- }
- if ($this->_options['metadatas_array_max_size'] < 10) {
- Zend_Cache::throwException('Invalid metadatas_array_max_size, must be > 10');
- }
- if (isset($options['hashed_directory_umask']) && is_string($options['hashed_directory_umask'])) {
- // See #ZF-4422
- $this->_options['hashed_directory_umask'] = octdec($this->_options['hashed_directory_umask']);
- }
- if (isset($options['cache_file_umask']) && is_string($options['cache_file_umask'])) {
- // See #ZF-4422
- $this->_options['cache_file_umask'] = octdec($this->_options['cache_file_umask']);
- }
- }
-
- /**
- * Set the cache_dir (particular case of setOption() method)
- *
- * @param string $value
- * @param boolean $trailingSeparator If true, add a trailing separator is necessary
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setCacheDir($value, $trailingSeparator = true)
- {
- if (!is_dir($value)) {
- Zend_Cache::throwException('cache_dir must be a directory');
- }
- if (!is_writable($value)) {
- Zend_Cache::throwException('cache_dir is not writable');
- }
- if ($trailingSeparator) {
- // add a trailing DIRECTORY_SEPARATOR if necessary
- $value = rtrim(realpath($value), '\\/') . DIRECTORY_SEPARATOR;
- }
- $this->_options['cache_dir'] = $value;
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * @param string $id cache id
- * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
- * @return string|false cached datas
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- if (!($this->_test($id, $doNotTestCacheValidity))) {
- // The cache is not hit !
- return false;
- }
- $metadatas = $this->_getMetadatas($id);
- $file = $this->_file($id);
- $data = $this->_fileGetContents($file);
- if ($this->_options['read_control']) {
- $hashData = $this->_hash($data, $this->_options['read_control_type']);
- $hashControl = $metadatas['hash'];
- if ($hashData != $hashControl) {
- // Problem detected by the read control !
- $this->_log('Zend_Cache_Backend_File::load() / read_control : stored hash and computed hash do not match');
- $this->remove($id);
- return false;
- }
- }
- return $data;
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id cache id
- * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- clearstatcache();
- return $this->_test($id, false);
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- clearstatcache();
- $file = $this->_file($id);
- $path = $this->_path($id);
- if ($this->_options['hashed_directory_level'] > 0) {
- if (!is_writable($path)) {
- // maybe, we just have to build the directory structure
- $this->_recursiveMkdirAndChmod($id);
- }
- if (!is_writable($path)) {
- return false;
- }
- }
- if ($this->_options['read_control']) {
- $hash = $this->_hash($data, $this->_options['read_control_type']);
- } else {
- $hash = '';
- }
- $metadatas = array(
- 'hash' => $hash,
- 'mtime' => time(),
- 'expire' => $this->_expireTime($this->getLifetime($specificLifetime)),
- 'tags' => $tags
- );
- $res = $this->_setMetadatas($id, $metadatas);
- if (!$res) {
- $this->_log('Zend_Cache_Backend_File::save() / error on saving metadata');
- return false;
- }
- $res = $this->_filePutContents($file, $data);
- return $res;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id cache id
- * @return boolean true if no problem
- */
- public function remove($id)
- {
- $file = $this->_file($id);
- $boolRemove = $this->_remove($file);
- $boolMetadata = $this->_delMetadatas($id);
- return $boolMetadata && $boolRemove;
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => remove too old cache entries ($tags is not used)
- * 'matchingTag' => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * 'notMatchingTag' => remove cache entries not matching one of the given tags
- * ($tags can be an array of strings or a single string)
- * 'matchingAnyTag' => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode clean mode
- * @param tags array $tags array of tags
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- // We use this protected method to hide the recursive stuff
- clearstatcache();
- return $this->_clean($this->_options['cache_dir'], $mode, $tags);
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- return $this->_get($this->_options['cache_dir'], 'ids', array());
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- return $this->_get($this->_options['cache_dir'], 'tags', array());
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- return $this->_get($this->_options['cache_dir'], 'matching', $tags);
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- return $this->_get($this->_options['cache_dir'], 'notMatching', $tags);
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- return $this->_get($this->_options['cache_dir'], 'matchingAny', $tags);
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @throws Zend_Cache_Exception
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- $free = disk_free_space($this->_options['cache_dir']);
- $total = disk_total_space($this->_options['cache_dir']);
- if ($total == 0) {
- Zend_Cache::throwException('can\'t get disk_total_space');
- } else {
- if ($free >= $total) {
- return 100;
- }
- return ((int) (100. * ($total - $free) / $total));
- }
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- $metadatas = $this->_getMetadatas($id);
- if (!$metadatas) {
- return false;
- }
- if (time() > $metadatas['expire']) {
- return false;
- }
- return array(
- 'expire' => $metadatas['expire'],
- 'tags' => $metadatas['tags'],
- 'mtime' => $metadatas['mtime']
- );
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- $metadatas = $this->_getMetadatas($id);
- if (!$metadatas) {
- return false;
- }
- if (time() > $metadatas['expire']) {
- return false;
- }
- $newMetadatas = array(
- 'hash' => $metadatas['hash'],
- 'mtime' => time(),
- 'expire' => $metadatas['expire'] + $extraLifetime,
- 'tags' => $metadatas['tags']
- );
- $res = $this->_setMetadatas($id, $newMetadatas);
- if (!$res) {
- return false;
- }
- return true;
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => true,
- 'tags' => true,
- 'expired_read' => true,
- 'priority' => false,
- 'infinite_lifetime' => true,
- 'get_list' => true
- );
- }
-
- /**
- * PUBLIC METHOD FOR UNIT TESTING ONLY !
- *
- * Force a cache record to expire
- *
- * @param string $id cache id
- */
- public function ___expire($id)
- {
- $metadatas = $this->_getMetadatas($id);
- if ($metadatas) {
- $metadatas['expire'] = 1;
- $this->_setMetadatas($id, $metadatas);
- }
- }
-
- /**
- * Get a metadatas record
- *
- * @param string $id Cache id
- * @return array|false Associative array of metadatas
- */
- protected function _getMetadatas($id)
- {
- if (isset($this->_metadatasArray[$id])) {
- return $this->_metadatasArray[$id];
- } else {
- $metadatas = $this->_loadMetadatas($id);
- if (!$metadatas) {
- return false;
- }
- $this->_setMetadatas($id, $metadatas, false);
- return $metadatas;
- }
- }
-
- /**
- * Set a metadatas record
- *
- * @param string $id Cache id
- * @param array $metadatas Associative array of metadatas
- * @param boolean $save optional pass false to disable saving to file
- * @return boolean True if no problem
- */
- protected function _setMetadatas($id, $metadatas, $save = true)
- {
- if (count($this->_metadatasArray) >= $this->_options['metadatas_array_max_size']) {
- $n = (int) ($this->_options['metadatas_array_max_size'] / 10);
- $this->_metadatasArray = array_slice($this->_metadatasArray, $n);
- }
- if ($save) {
- $result = $this->_saveMetadatas($id, $metadatas);
- if (!$result) {
- return false;
- }
- }
- $this->_metadatasArray[$id] = $metadatas;
- return true;
- }
-
- /**
- * Drop a metadata record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- protected function _delMetadatas($id)
- {
- if (isset($this->_metadatasArray[$id])) {
- unset($this->_metadatasArray[$id]);
- }
- $file = $this->_metadatasFile($id);
- return $this->_remove($file);
- }
-
- /**
- * Clear the metadatas array
- *
- * @return void
- */
- protected function _cleanMetadatas()
- {
- $this->_metadatasArray = array();
- }
-
- /**
- * Load metadatas from disk
- *
- * @param string $id Cache id
- * @return array|false Metadatas associative array
- */
- protected function _loadMetadatas($id)
- {
- $file = $this->_metadatasFile($id);
- $result = $this->_fileGetContents($file);
- if (!$result) {
- return false;
- }
- $tmp = @unserialize($result);
- return $tmp;
- }
-
- /**
- * Save metadatas to disk
- *
- * @param string $id Cache id
- * @param array $metadatas Associative array
- * @return boolean True if no problem
- */
- protected function _saveMetadatas($id, $metadatas)
- {
- $file = $this->_metadatasFile($id);
- $result = $this->_filePutContents($file, serialize($metadatas));
- if (!$result) {
- return false;
- }
- return true;
- }
-
- /**
- * Make and return a file name (with path) for metadatas
- *
- * @param string $id Cache id
- * @return string Metadatas file name (with path)
- */
- protected function _metadatasFile($id)
- {
- $path = $this->_path($id);
- $fileName = $this->_idToFileName('internal-metadatas---' . $id);
- return $path . $fileName;
- }
-
- /**
- * Check if the given filename is a metadatas one
- *
- * @param string $fileName File name
- * @return boolean True if it's a metadatas one
- */
- protected function _isMetadatasFile($fileName)
- {
- $id = $this->_fileNameToId($fileName);
- if (substr($id, 0, 21) == 'internal-metadatas---') {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Remove a file
- *
- * If we can't remove the file (because of locks or any problem), we will touch
- * the file to invalidate it
- *
- * @param string $file Complete file path
- * @return boolean True if ok
- */
- protected function _remove($file)
- {
- if (!is_file($file)) {
- return false;
- }
- if (!@unlink($file)) {
- # we can't remove the file (because of locks or any problem)
- $this->_log("Zend_Cache_Backend_File::_remove() : we can't remove $file");
- return false;
- }
- return true;
- }
-
- /**
- * Clean some cache records (protected method used for recursive stuff)
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $dir Directory to clean
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @throws Zend_Cache_Exception
- * @return boolean True if no problem
- */
- protected function _clean($dir, $mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- if (!is_dir($dir)) {
- return false;
- }
- $result = true;
- $prefix = $this->_options['file_name_prefix'];
- $glob = @glob($dir . $prefix . '--*');
- if ($glob === false) {
- // On some systems it is impossible to distinguish between empty match and an error.
- return true;
- }
- foreach ($glob as $file) {
- if (is_file($file)) {
- $fileName = basename($file);
- if ($this->_isMetadatasFile($fileName)) {
- // in CLEANING_MODE_ALL, we drop anything, even remainings old metadatas files
- if ($mode != Zend_Cache::CLEANING_MODE_ALL) {
- continue;
- }
- }
- $id = $this->_fileNameToId($fileName);
- $metadatas = $this->_getMetadatas($id);
- if ($metadatas === FALSE) {
- $metadatas = array('expire' => 1, 'tags' => array());
- }
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- $res = $this->remove($id);
- if (!$res) {
- // in this case only, we accept a problem with the metadatas file drop
- $res = $this->_remove($file);
- }
- $result = $result && $res;
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- if (time() > $metadatas['expire']) {
- $result = $this->remove($id) && $result;
- }
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- $matching = true;
- foreach ($tags as $tag) {
- if (!in_array($tag, $metadatas['tags'])) {
- $matching = false;
- break;
- }
- }
- if ($matching) {
- $result = $this->remove($id) && $result;
- }
- break;
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- $matching = false;
- foreach ($tags as $tag) {
- if (in_array($tag, $metadatas['tags'])) {
- $matching = true;
- break;
- }
- }
- if (!$matching) {
- $result = $this->remove($id) && $result;
- }
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $matching = false;
- foreach ($tags as $tag) {
- if (in_array($tag, $metadatas['tags'])) {
- $matching = true;
- break;
- }
- }
- if ($matching) {
- $result = $this->remove($id) && $result;
- }
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
- if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) {
- // Recursive call
- $result = $this->_clean($file . DIRECTORY_SEPARATOR, $mode, $tags) && $result;
- if ($mode=='all') {
- // if mode=='all', we try to drop the structure too
- @rmdir($file);
- }
- }
- }
- return $result;
- }
-
- protected function _get($dir, $mode, $tags = array())
- {
- if (!is_dir($dir)) {
- return false;
- }
- $result = array();
- $prefix = $this->_options['file_name_prefix'];
- $glob = @glob($dir . $prefix . '--*');
- if ($glob === false) {
- // On some systems it is impossible to distinguish between empty match and an error.
- return array();
- }
- foreach ($glob as $file) {
- if (is_file($file)) {
- $fileName = basename($file);
- $id = $this->_fileNameToId($fileName);
- $metadatas = $this->_getMetadatas($id);
- if ($metadatas === FALSE) {
- continue;
- }
- if (time() > $metadatas['expire']) {
- continue;
- }
- switch ($mode) {
- case 'ids':
- $result[] = $id;
- break;
- case 'tags':
- $result = array_unique(array_merge($result, $metadatas['tags']));
- break;
- case 'matching':
- $matching = true;
- foreach ($tags as $tag) {
- if (!in_array($tag, $metadatas['tags'])) {
- $matching = false;
- break;
- }
- }
- if ($matching) {
- $result[] = $id;
- }
- break;
- case 'notMatching':
- $matching = false;
- foreach ($tags as $tag) {
- if (in_array($tag, $metadatas['tags'])) {
- $matching = true;
- break;
- }
- }
- if (!$matching) {
- $result[] = $id;
- }
- break;
- case 'matchingAny':
- $matching = false;
- foreach ($tags as $tag) {
- if (in_array($tag, $metadatas['tags'])) {
- $matching = true;
- break;
- }
- }
- if ($matching) {
- $result[] = $id;
- }
- break;
- default:
- Zend_Cache::throwException('Invalid mode for _get() method');
- break;
- }
- }
- if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) {
- // Recursive call
- $recursiveRs = $this->_get($file . DIRECTORY_SEPARATOR, $mode, $tags);
- if ($recursiveRs === false) {
- $this->_log('Zend_Cache_Backend_File::_get() / recursive call : can\'t list entries of "'.$file.'"');
- } else {
- $result = array_unique(array_merge($result, $recursiveRs));
- }
- }
- }
- return array_unique($result);
- }
-
- /**
- * Compute & return the expire time
- *
- * @return int expire time (unix timestamp)
- */
- protected function _expireTime($lifetime)
- {
- if ($lifetime === null) {
- return 9999999999;
- }
- return time() + $lifetime;
- }
-
- /**
- * Make a control key with the string containing datas
- *
- * @param string $data Data
- * @param string $controlType Type of control 'md5', 'crc32' or 'strlen'
- * @throws Zend_Cache_Exception
- * @return string Control key
- */
- protected function _hash($data, $controlType)
- {
- switch ($controlType) {
- case 'md5':
- return md5($data);
- case 'crc32':
- return crc32($data);
- case 'strlen':
- return strlen($data);
- case 'adler32':
- return hash('adler32', $data);
- default:
- Zend_Cache::throwException("Incorrect hash function : $controlType");
- }
- }
-
- /**
- * Transform a cache id into a file name and return it
- *
- * @param string $id Cache id
- * @return string File name
- */
- protected function _idToFileName($id)
- {
- $prefix = $this->_options['file_name_prefix'];
- $result = $prefix . '---' . $id;
- return $result;
- }
-
- /**
- * Make and return a file name (with path)
- *
- * @param string $id Cache id
- * @return string File name (with path)
- */
- protected function _file($id)
- {
- $path = $this->_path($id);
- $fileName = $this->_idToFileName($id);
- return $path . $fileName;
- }
-
- /**
- * Return the complete directory path of a filename (including hashedDirectoryStructure)
- *
- * @param string $id Cache id
- * @param boolean $parts if true, returns array of directory parts instead of single string
- * @return string Complete directory path
- */
- protected function _path($id, $parts = false)
- {
- $partsArray = array();
- $root = $this->_options['cache_dir'];
- $prefix = $this->_options['file_name_prefix'];
- if ($this->_options['hashed_directory_level']>0) {
- $hash = hash('adler32', $id);
- for ($i=0 ; $i < $this->_options['hashed_directory_level'] ; $i++) {
- $root = $root . $prefix . '--' . substr($hash, 0, $i + 1) . DIRECTORY_SEPARATOR;
- $partsArray[] = $root;
- }
- }
- if ($parts) {
- return $partsArray;
- } else {
- return $root;
- }
- }
-
- /**
- * Make the directory strucuture for the given id
- *
- * @param string $id cache id
- * @return boolean true
- */
- protected function _recursiveMkdirAndChmod($id)
- {
- if ($this->_options['hashed_directory_level'] <=0) {
- return true;
- }
- $partsArray = $this->_path($id, true);
- foreach ($partsArray as $part) {
- if (!is_dir($part)) {
- @mkdir($part, $this->_options['hashed_directory_umask']);
- @chmod($part, $this->_options['hashed_directory_umask']); // see #ZF-320 (this line is required in some configurations)
- }
- }
- return true;
- }
-
- /**
- * Test if the given cache id is available (and still valid as a cache record)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @return boolean|mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- protected function _test($id, $doNotTestCacheValidity)
- {
- $metadatas = $this->_getMetadatas($id);
- if (!$metadatas) {
- return false;
- }
- if ($doNotTestCacheValidity || (time() <= $metadatas['expire'])) {
- return $metadatas['mtime'];
- }
- return false;
- }
-
- /**
- * Return the file content of the given file
- *
- * @param string $file File complete path
- * @return string File content (or false if problem)
- */
- protected function _fileGetContents($file)
- {
- $result = false;
- if (!is_file($file)) {
- return false;
- }
- $f = @fopen($file, 'rb');
- if ($f) {
- if ($this->_options['file_locking']) @flock($f, LOCK_SH);
- $result = stream_get_contents($f);
- if ($this->_options['file_locking']) @flock($f, LOCK_UN);
- @fclose($f);
- }
- return $result;
- }
-
- /**
- * Put the given string into the given file
- *
- * @param string $file File complete path
- * @param string $string String to put in file
- * @return boolean true if no problem
- */
- protected function _filePutContents($file, $string)
- {
- $result = false;
- $f = @fopen($file, 'ab+');
- if ($f) {
- if ($this->_options['file_locking']) @flock($f, LOCK_EX);
- fseek($f, 0);
- ftruncate($f, 0);
- $tmp = @fwrite($f, $string);
- if (!($tmp === FALSE)) {
- $result = true;
- }
- @fclose($f);
- }
- @chmod($file, $this->_options['cache_file_umask']);
- return $result;
- }
-
- /**
- * Transform a file name into cache id and return it
- *
- * @param string $fileName File name
- * @return string Cache id
- */
- protected function _fileNameToId($fileName)
- {
- $prefix = $this->_options['file_name_prefix'];
- return preg_replace('~^' . $prefix . '---(.*)$~', '$1', $fileName);
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/Interface.php zendframework-2.2.6/library/Zend/Cache/Backend/Interface.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/Interface.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/Interface.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,99 +0,0 @@
- infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false);
-
- /**
- * Remove a cache record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id);
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array());
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/Memcached.php zendframework-2.2.6/library/Zend/Cache/Backend/Memcached.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/Memcached.php 2010-03-17 18:20:53.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/Memcached.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,504 +0,0 @@
- (array) servers :
- * an array of memcached server ; each memcached server is described by an associative array :
- * 'host' => (string) : the name of the memcached server
- * 'port' => (int) : the port of the memcached server
- * 'persistent' => (bool) : use or not persistent connections to this memcached server
- * 'weight' => (int) : number of buckets to create for this server which in turn control its
- * probability of it being selected. The probability is relative to the total
- * weight of all servers.
- * 'timeout' => (int) : value in seconds which will be used for connecting to the daemon. Think twice
- * before changing the default value of 1 second - you can lose all the
- * advantages of caching if your connection is too slow.
- * 'retry_interval' => (int) : controls how often a failed server will be retried, the default value
- * is 15 seconds. Setting this parameter to -1 disables automatic retry.
- * 'status' => (bool) : controls if the server should be flagged as online.
- * 'failure_callback' => (callback) : Allows the user to specify a callback function to run upon
- * encountering an error. The callback is run before failover
- * is attempted. The function takes two parameters, the hostname
- * and port of the failed server.
- *
- * =====> (boolean) compression :
- * true if you want to use on-the-fly compression
- *
- * =====> (boolean) compatibility :
- * true if you use old memcache server or extension
- *
- * @var array available options
- */
- protected $_options = array(
- 'servers' => array(array(
- 'host' => self::DEFAULT_HOST,
- 'port' => self::DEFAULT_PORT,
- 'persistent' => self::DEFAULT_PERSISTENT,
- 'weight' => self::DEFAULT_WEIGHT,
- 'timeout' => self::DEFAULT_TIMEOUT,
- 'retry_interval' => self::DEFAULT_RETRY_INTERVAL,
- 'status' => self::DEFAULT_STATUS,
- 'failure_callback' => self::DEFAULT_FAILURE_CALLBACK
- )),
- 'compression' => false,
- 'compatibility' => false,
- );
-
- /**
- * Memcache object
- *
- * @var mixed memcache object
- */
- protected $_memcache = null;
-
- /**
- * Constructor
- *
- * @param array $options associative array of options
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- if (!extension_loaded('memcache')) {
- Zend_Cache::throwException('The memcache extension must be loaded for using this backend !');
- }
- parent::__construct($options);
- if (isset($this->_options['servers'])) {
- $value= $this->_options['servers'];
- if (isset($value['host'])) {
- // in this case, $value seems to be a simple associative array (one server only)
- $value = array(0 => $value); // let's transform it into a classical array of associative arrays
- }
- $this->setOption('servers', $value);
- }
- $this->_memcache = new Memcache;
- foreach ($this->_options['servers'] as $server) {
- if (!array_key_exists('port', $server)) {
- $server['port'] = self::DEFAULT_PORT;
- }
- if (!array_key_exists('persistent', $server)) {
- $server['persistent'] = self::DEFAULT_PERSISTENT;
- }
- if (!array_key_exists('weight', $server)) {
- $server['weight'] = self::DEFAULT_WEIGHT;
- }
- if (!array_key_exists('timeout', $server)) {
- $server['timeout'] = self::DEFAULT_TIMEOUT;
- }
- if (!array_key_exists('retry_interval', $server)) {
- $server['retry_interval'] = self::DEFAULT_RETRY_INTERVAL;
- }
- if (!array_key_exists('status', $server)) {
- $server['status'] = self::DEFAULT_STATUS;
- }
- if (!array_key_exists('failure_callback', $server)) {
- $server['failure_callback'] = self::DEFAULT_FAILURE_CALLBACK;
- }
- if ($this->_options['compatibility']) {
- // No status for compatibility mode (#ZF-5887)
- $this->_memcache->addServer($server['host'], $server['port'], $server['persistent'],
- $server['weight'], $server['timeout'],
- $server['retry_interval']);
- } else {
- $this->_memcache->addServer($server['host'], $server['port'], $server['persistent'],
- $server['weight'], $server['timeout'],
- $server['retry_interval'],
- $server['status'], $server['failure_callback']);
- }
- }
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @return string|false cached datas
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- $tmp = $this->_memcache->get($id);
- if (is_array($tmp) && isset($tmp[0])) {
- return $tmp[0];
- }
- return false;
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id Cache id
- * @return mixed|false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- $tmp = $this->_memcache->get($id);
- if (is_array($tmp)) {
- return $tmp[1];
- }
- return false;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean True if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $lifetime = $this->getLifetime($specificLifetime);
- if ($this->_options['compression']) {
- $flag = MEMCACHE_COMPRESSED;
- } else {
- $flag = 0;
- }
-
- // ZF-8856: using set because add needs a second request if item already exists
- $result = @$this->_memcache->set($id, array($data, time(), $lifetime), $flag, $lifetime);
-
- if (count($tags) > 0) {
- $this->_log("Zend_Cache_Backend_Memcached::save() : tags are unsupported by the Memcached backend");
- }
-
- return $result;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id)
- {
- return $this->_memcache->delete($id, 0);
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => unsupported
- * 'matchingTag' => unsupported
- * 'notMatchingTag' => unsupported
- * 'matchingAnyTag' => unsupported
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @throws Zend_Cache_Exception
- * @return boolean True if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- return $this->_memcache->flush();
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $this->_log("Zend_Cache_Backend_Memcached::clean() : CLEANING_MODE_OLD is unsupported by the Memcached backend");
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_MEMCACHED_BACKEND);
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-
- /**
- * Return true if the automatic cleaning is available for the backend
- *
- * @return boolean
- */
- public function isAutomaticCleaningAvailable()
- {
- return false;
- }
-
- /**
- * Set the frontend directives
- *
- * @param array $directives Assoc of directives
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setDirectives($directives)
- {
- parent::setDirectives($directives);
- $lifetime = $this->getLifetime(false);
- if ($lifetime > 2592000) {
- // #ZF-3490 : For the memcached backend, there is a lifetime limit of 30 days (2592000 seconds)
- $this->_log('memcached backend has a limit of 30 days (2592000 seconds) for the lifetime');
- }
- if ($lifetime === null) {
- // #ZF-4614 : we tranform null to zero to get the maximal lifetime
- parent::setDirectives(array('lifetime' => 0));
- }
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- $this->_log("Zend_Cache_Backend_Memcached::save() : getting the list of cache ids is unsupported by the Memcache backend");
- return array();
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND);
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND);
- return array();
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @throws Zend_Cache_Exception
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- $mems = $this->_memcache->getExtendedStats();
-
- $memSize = null;
- $memUsed = null;
- foreach ($mems as $key => $mem) {
- if ($mem === false) {
- $this->_log('can\'t get stat from ' . $key);
- continue;
- }
-
- $eachSize = $mem['limit_maxbytes'];
- $eachUsed = $mem['bytes'];
- if ($eachUsed > $eachSize) {
- $eachUsed = $eachSize;
- }
-
- $memSize += $eachSize;
- $memUsed += $eachUsed;
- }
-
- if ($memSize === null || $memUsed === null) {
- Zend_Cache::throwException('Can\'t get filling percentage');
- }
-
- return ((int) (100. * ($memUsed / $memSize)));
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- $tmp = $this->_memcache->get($id);
- if (is_array($tmp)) {
- $data = $tmp[0];
- $mtime = $tmp[1];
- if (!isset($tmp[2])) {
- // because this record is only with 1.7 release
- // if old cache records are still there...
- return false;
- }
- $lifetime = $tmp[2];
- return array(
- 'expire' => $mtime + $lifetime,
- 'tags' => array(),
- 'mtime' => $mtime
- );
- }
- return false;
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- if ($this->_options['compression']) {
- $flag = MEMCACHE_COMPRESSED;
- } else {
- $flag = 0;
- }
- $tmp = $this->_memcache->get($id);
- if (is_array($tmp)) {
- $data = $tmp[0];
- $mtime = $tmp[1];
- if (!isset($tmp[2])) {
- // because this record is only with 1.7 release
- // if old cache records are still there...
- return false;
- }
- $lifetime = $tmp[2];
- $newLifetime = $lifetime - (time() - $mtime) + $extraLifetime;
- if ($newLifetime <=0) {
- return false;
- }
- // #ZF-5702 : we try replace() first becase set() seems to be slower
- if (!($result = $this->_memcache->replace($id, array($data, time(), $newLifetime), $flag, $newLifetime))) {
- $result = $this->_memcache->set($id, array($data, time(), $newLifetime), $flag, $newLifetime);
- }
- return $result;
- }
- return false;
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => false,
- 'tags' => false,
- 'expired_read' => false,
- 'priority' => false,
- 'infinite_lifetime' => false,
- 'get_list' => false
- );
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/Sqlite.php zendframework-2.2.6/library/Zend/Cache/Backend/Sqlite.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/Sqlite.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/Sqlite.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,679 +0,0 @@
- (string) cache_db_complete_path :
- * - the complete path (filename included) of the SQLITE database
- *
- * ====> (int) automatic_vacuum_factor :
- * - Disable / Tune the automatic vacuum process
- * - The automatic vacuum process defragment the database file (and make it smaller)
- * when a clean() or delete() is called
- * 0 => no automatic vacuum
- * 1 => systematic vacuum (when delete() or clean() methods are called)
- * x (integer) > 1 => automatic vacuum randomly 1 times on x clean() or delete()
- *
- * @var array Available options
- */
- protected $_options = array(
- 'cache_db_complete_path' => null,
- 'automatic_vacuum_factor' => 10
- );
-
- /**
- * DB ressource
- *
- * @var mixed $_db
- */
- private $_db = null;
-
- /**
- * Boolean to store if the structure has benn checked or not
- *
- * @var boolean $_structureChecked
- */
- private $_structureChecked = false;
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- * @throws Zend_cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- parent::__construct($options);
- if ($this->_options['cache_db_complete_path'] === null) {
- Zend_Cache::throwException('cache_db_complete_path option has to set');
- }
- if (!extension_loaded('sqlite')) {
- Zend_Cache::throwException("Cannot use SQLite storage because the 'sqlite' extension is not loaded in the current PHP environment");
- }
- $this->_getConnection();
- }
-
- /**
- * Destructor
- *
- * @return void
- */
- public function __destruct()
- {
- @sqlite_close($this->_getConnection());
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @return string|false Cached datas
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- $this->_checkAndBuildStructure();
- $sql = "SELECT content FROM cache WHERE id='$id'";
- if (!$doNotTestCacheValidity) {
- $sql = $sql . " AND (expire=0 OR expire>" . time() . ')';
- }
- $result = $this->_query($sql);
- $row = @sqlite_fetch_array($result);
- if ($row) {
- return $row['content'];
- }
- return false;
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id Cache id
- * @return mixed|false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- $this->_checkAndBuildStructure();
- $sql = "SELECT lastModified FROM cache WHERE id='$id' AND (expire=0 OR expire>" . time() . ')';
- $result = $this->_query($sql);
- $row = @sqlite_fetch_array($result);
- if ($row) {
- return ((int) $row['lastModified']);
- }
- return false;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @throws Zend_Cache_Exception
- * @return boolean True if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $this->_checkAndBuildStructure();
- $lifetime = $this->getLifetime($specificLifetime);
- $data = @sqlite_escape_string($data);
- $mktime = time();
- if ($lifetime === null) {
- $expire = 0;
- } else {
- $expire = $mktime + $lifetime;
- }
- $this->_query("DELETE FROM cache WHERE id='$id'");
- $sql = "INSERT INTO cache (id, content, lastModified, expire) VALUES ('$id', '$data', $mktime, $expire)";
- $res = $this->_query($sql);
- if (!$res) {
- $this->_log("Zend_Cache_Backend_Sqlite::save() : impossible to store the cache id=$id");
- return false;
- }
- $res = true;
- foreach ($tags as $tag) {
- $res = $this->_registerTag($id, $tag) && $res;
- }
- return $res;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id)
- {
- $this->_checkAndBuildStructure();
- $res = $this->_query("SELECT COUNT(*) AS nbr FROM cache WHERE id='$id'");
- $result1 = @sqlite_fetch_single($res);
- $result2 = $this->_query("DELETE FROM cache WHERE id='$id'");
- $result3 = $this->_query("DELETE FROM tag WHERE id='$id'");
- $this->_automaticVacuum();
- return ($result1 && $result2 && $result3);
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @return boolean True if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- $this->_checkAndBuildStructure();
- $return = $this->_clean($mode, $tags);
- $this->_automaticVacuum();
- return $return;
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- $this->_checkAndBuildStructure();
- $res = $this->_query("SELECT id FROM cache WHERE (expire=0 OR expire>" . time() . ")");
- $result = array();
- while ($id = @sqlite_fetch_single($res)) {
- $result[] = $id;
- }
- return $result;
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- $this->_checkAndBuildStructure();
- $res = $this->_query("SELECT DISTINCT(name) AS name FROM tag");
- $result = array();
- while ($id = @sqlite_fetch_single($res)) {
- $result[] = $id;
- }
- return $result;
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- $first = true;
- $ids = array();
- foreach ($tags as $tag) {
- $res = $this->_query("SELECT DISTINCT(id) AS id FROM tag WHERE name='$tag'");
- if (!$res) {
- return array();
- }
- $rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
- $ids2 = array();
- foreach ($rows as $row) {
- $ids2[] = $row['id'];
- }
- if ($first) {
- $ids = $ids2;
- $first = false;
- } else {
- $ids = array_intersect($ids, $ids2);
- }
- }
- $result = array();
- foreach ($ids as $id) {
- $result[] = $id;
- }
- return $result;
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- $res = $this->_query("SELECT id FROM cache");
- $rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
- $result = array();
- foreach ($rows as $row) {
- $id = $row['id'];
- $matching = false;
- foreach ($tags as $tag) {
- $res = $this->_query("SELECT COUNT(*) AS nbr FROM tag WHERE name='$tag' AND id='$id'");
- if (!$res) {
- return array();
- }
- $nbr = (int) @sqlite_fetch_single($res);
- if ($nbr > 0) {
- $matching = true;
- }
- }
- if (!$matching) {
- $result[] = $id;
- }
- }
- return $result;
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- $first = true;
- $ids = array();
- foreach ($tags as $tag) {
- $res = $this->_query("SELECT DISTINCT(id) AS id FROM tag WHERE name='$tag'");
- if (!$res) {
- return array();
- }
- $rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
- $ids2 = array();
- foreach ($rows as $row) {
- $ids2[] = $row['id'];
- }
- if ($first) {
- $ids = $ids2;
- $first = false;
- } else {
- $ids = array_merge($ids, $ids2);
- }
- }
- $result = array();
- foreach ($ids as $id) {
- $result[] = $id;
- }
- return $result;
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @throws Zend_Cache_Exception
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- $dir = dirname($this->_options['cache_db_complete_path']);
- $free = disk_free_space($dir);
- $total = disk_total_space($dir);
- if ($total == 0) {
- Zend_Cache::throwException('can\'t get disk_total_space');
- } else {
- if ($free >= $total) {
- return 100;
- }
- return ((int) (100. * ($total - $free) / $total));
- }
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- $tags = array();
- $res = $this->_query("SELECT name FROM tag WHERE id='$id'");
- if ($res) {
- $rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
- foreach ($rows as $row) {
- $tags[] = $row['name'];
- }
- }
- $this->_query('CREATE TABLE cache (id TEXT PRIMARY KEY, content BLOB, lastModified INTEGER, expire INTEGER)');
- $res = $this->_query("SELECT lastModified,expire FROM cache WHERE id='$id'");
- if (!$res) {
- return false;
- }
- $row = @sqlite_fetch_array($res, SQLITE_ASSOC);
- return array(
- 'tags' => $tags,
- 'mtime' => $row['lastModified'],
- 'expire' => $row['expire']
- );
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- $sql = "SELECT expire FROM cache WHERE id='$id' AND (expire=0 OR expire>" . time() . ')';
- $res = $this->_query($sql);
- if (!$res) {
- return false;
- }
- $expire = @sqlite_fetch_single($res);
- $newExpire = $expire + $extraLifetime;
- $res = $this->_query("UPDATE cache SET lastModified=" . time() . ", expire=$newExpire WHERE id='$id'");
- if ($res) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => true,
- 'tags' => true,
- 'expired_read' => true,
- 'priority' => false,
- 'infinite_lifetime' => true,
- 'get_list' => true
- );
- }
-
- /**
- * PUBLIC METHOD FOR UNIT TESTING ONLY !
- *
- * Force a cache record to expire
- *
- * @param string $id Cache id
- */
- public function ___expire($id)
- {
- $time = time() - 1;
- $this->_query("UPDATE cache SET lastModified=$time, expire=$time WHERE id='$id'");
- }
-
- /**
- * Return the connection resource
- *
- * If we are not connected, the connection is made
- *
- * @throws Zend_Cache_Exception
- * @return resource Connection resource
- */
- private function _getConnection()
- {
- if (is_resource($this->_db)) {
- return $this->_db;
- } else {
- $this->_db = @sqlite_open($this->_options['cache_db_complete_path']);
- if (!(is_resource($this->_db))) {
- Zend_Cache::throwException("Impossible to open " . $this->_options['cache_db_complete_path'] . " cache DB file");
- }
- return $this->_db;
- }
- }
-
- /**
- * Execute an SQL query silently
- *
- * @param string $query SQL query
- * @return mixed|false query results
- */
- private function _query($query)
- {
- $db = $this->_getConnection();
- if (is_resource($db)) {
- $res = @sqlite_query($db, $query);
- if ($res === false) {
- return false;
- } else {
- return $res;
- }
- }
- return false;
- }
-
- /**
- * Deal with the automatic vacuum process
- *
- * @return void
- */
- private function _automaticVacuum()
- {
- if ($this->_options['automatic_vacuum_factor'] > 0) {
- $rand = rand(1, $this->_options['automatic_vacuum_factor']);
- if ($rand == 1) {
- $this->_query('VACUUM');
- @sqlite_close($this->_getConnection());
- }
- }
- }
-
- /**
- * Register a cache id with the given tag
- *
- * @param string $id Cache id
- * @param string $tag Tag
- * @return boolean True if no problem
- */
- private function _registerTag($id, $tag) {
- $res = $this->_query("DELETE FROM TAG WHERE name='$tag' AND id='$id'");
- $res = $this->_query("INSERT INTO tag (name, id) VALUES ('$tag', '$id')");
- if (!$res) {
- $this->_log("Zend_Cache_Backend_Sqlite::_registerTag() : impossible to register tag=$tag on id=$id");
- return false;
- }
- return true;
- }
-
- /**
- * Build the database structure
- *
- * @return false
- */
- private function _buildStructure()
- {
- $this->_query('DROP INDEX tag_id_index');
- $this->_query('DROP INDEX tag_name_index');
- $this->_query('DROP INDEX cache_id_expire_index');
- $this->_query('DROP TABLE version');
- $this->_query('DROP TABLE cache');
- $this->_query('DROP TABLE tag');
- $this->_query('CREATE TABLE version (num INTEGER PRIMARY KEY)');
- $this->_query('CREATE TABLE cache (id TEXT PRIMARY KEY, content BLOB, lastModified INTEGER, expire INTEGER)');
- $this->_query('CREATE TABLE tag (name TEXT, id TEXT)');
- $this->_query('CREATE INDEX tag_id_index ON tag(id)');
- $this->_query('CREATE INDEX tag_name_index ON tag(name)');
- $this->_query('CREATE INDEX cache_id_expire_index ON cache(id, expire)');
- $this->_query('INSERT INTO version (num) VALUES (1)');
- }
-
- /**
- * Check if the database structure is ok (with the good version)
- *
- * @return boolean True if ok
- */
- private function _checkStructureVersion()
- {
- $result = $this->_query("SELECT num FROM version");
- if (!$result) return false;
- $row = @sqlite_fetch_array($result);
- if (!$row) {
- return false;
- }
- if (((int) $row['num']) != 1) {
- // old cache structure
- $this->_log('Zend_Cache_Backend_Sqlite::_checkStructureVersion() : old cache structure version detected => the cache is going to be dropped');
- return false;
- }
- return true;
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @return boolean True if no problem
- */
- private function _clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- $res1 = $this->_query('DELETE FROM cache');
- $res2 = $this->_query('DELETE FROM tag');
- return $res1 && $res2;
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $mktime = time();
- $res1 = $this->_query("DELETE FROM tag WHERE id IN (SELECT id FROM cache WHERE expire>0 AND expire<=$mktime)");
- $res2 = $this->_query("DELETE FROM cache WHERE expire>0 AND expire<=$mktime");
- return $res1 && $res2;
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- $ids = $this->getIdsMatchingTags($tags);
- $result = true;
- foreach ($ids as $id) {
- $result = $this->remove($id) && $result;
- }
- return $result;
- break;
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- $ids = $this->getIdsNotMatchingTags($tags);
- $result = true;
- foreach ($ids as $id) {
- $result = $this->remove($id) && $result;
- }
- return $result;
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $ids = $this->getIdsMatchingAnyTags($tags);
- $result = true;
- foreach ($ids as $id) {
- $result = $this->remove($id) && $result;
- }
- return $result;
- break;
- default:
- break;
- }
- return false;
- }
-
- /**
- * Check if the database structure is ok (with the good version), if no : build it
- *
- * @throws Zend_Cache_Exception
- * @return boolean True if ok
- */
- private function _checkAndBuildStructure()
- {
- if (!($this->_structureChecked)) {
- if (!$this->_checkStructureVersion()) {
- $this->_buildStructure();
- if (!$this->_checkStructureVersion()) {
- Zend_Cache::throwException("Impossible to build cache structure in " . $this->_options['cache_db_complete_path']);
- }
- }
- $this->_structureChecked = true;
- }
- return true;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/Static.php zendframework-2.2.6/library/Zend/Cache/Backend/Static.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/Static.php 2010-03-29 14:50:28.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/Static.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,558 +0,0 @@
- null,
- 'sub_dir' => 'html',
- 'file_extension' => '.html',
- 'index_filename' => 'index',
- 'file_locking' => true,
- 'cache_file_umask' => 0600,
- 'cache_directory_umask' => 0700,
- 'debug_header' => false,
- 'tag_cache' => null,
- 'disable_caching' => false
- );
-
- /**
- * Cache for handling tags
- * @var Zend_Cache_Core
- */
- protected $_tagCache = null;
-
- /**
- * Tagged items
- * @var array
- */
- protected $_tagged = null;
-
- /**
- * Interceptor child method to handle the case where an Inner
- * Cache object is being set since it's not supported by the
- * standard backend interface
- *
- * @param string $name
- * @param mixed $value
- * @return Zend_Cache_Backend_Static
- */
- public function setOption($name, $value)
- {
- if ($name == 'tag_cache') {
- $this->setInnerCache($value);
- } else {
- parent::setOption($name, $value);
- }
- return $this;
- }
-
- /**
- * Retrieve any option via interception of the parent's statically held
- * options including the local option for a tag cache.
- *
- * @param string $name
- * @return mixed
- */
- public function getOption($name)
- {
- if ($name == 'tag_cache') {
- return $this->getInnerCache();
- } else {
- if (in_array($name, $this->_options)) {
- return $this->_options[$name];
- }
- if ($name == 'lifetime') {
- return parent::getLifetime();
- }
- return null;
- }
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * Note : return value is always "string" (unserialization is done by the core not by the backend)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @return string|false cached datas
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- if (empty($id)) {
- $id = $this->_detectId();
- } else {
- $id = $this->_decodeId($id);
- }
- if (!$this->_verifyPath($id)) {
- Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path');
- }
- if ($doNotTestCacheValidity) {
- $this->_log("Zend_Cache_Backend_Static::load() : \$doNotTestCacheValidity=true is unsupported by the Static backend");
- }
-
- $fileName = basename($id);
- if (empty($fileName)) {
- $fileName = $this->_options['index_filename'];
- }
- $pathName = $this->_options['public_dir'] . dirname($id);
- $file = rtrim($pathName, '/') . '/' . $fileName . $this->_options['file_extension'];
- if (file_exists($file)) {
- $content = file_get_contents($file);
- return $content;
- }
-
- return false;
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id cache id
- * @return bool
- */
- public function test($id)
- {
- $id = $this->_decodeId($id);
- if (!$this->_verifyPath($id)) {
- Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path');
- }
-
- $fileName = basename($id);
- if (empty($fileName)) {
- $fileName = $this->_options['index_filename'];
- }
- if (is_null($this->_tagged) && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) {
- $this->_tagged = $tagged;
- } elseif (!$this->_tagged) {
- return false;
- }
- $pathName = $this->_options['public_dir'] . dirname($id);
-
- // Switch extension if needed
- if (isset($this->_tagged[$id])) {
- $extension = $this->_tagged[$id]['extension'];
- } else {
- $extension = $this->_options['file_extension'];
- }
- $file = $pathName . '/' . $fileName . $extension;
- if (file_exists($file)) {
- return true;
- }
- return false;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- if ($this->_options['disable_caching']) {
- return true;
- }
- $extension = null;
- if ($this->_isSerialized($data)) {
- $data = unserialize($data);
- $extension = '.' . ltrim($data[1], '.');
- $data = $data[0];
- }
-
- clearstatcache();
- if (is_null($id) || strlen($id) == 0) {
- $id = $this->_detectId();
- } else {
- $id = $this->_decodeId($id);
- }
-
- $fileName = basename($id);
- if (empty($fileName)) {
- $fileName = $this->_options['index_filename'];
- }
-
- $pathName = realpath($this->_options['public_dir']) . dirname($id);
- $this->_createDirectoriesFor($pathName);
-
- if (is_null($id) || strlen($id) == 0) {
- $dataUnserialized = unserialize($data);
- $data = $dataUnserialized['data'];
- }
- $ext = $this->_options['file_extension'];
- if ($extension) $ext = $extension;
- $file = rtrim($pathName, '/') . '/' . $fileName . $ext;
- if ($this->_options['file_locking']) {
- $result = file_put_contents($file, $data, LOCK_EX);
- } else {
- $result = file_put_contents($file, $data);
- }
- @chmod($file, $this->_octdec($this->_options['cache_file_umask']));
-
- if (is_null($this->_tagged) && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) {
- $this->_tagged = $tagged;
- } elseif (is_null($this->_tagged)) {
- $this->_tagged = array();
- }
- if (!isset($this->_tagged[$id])) {
- $this->_tagged[$id] = array();
- }
- if (!isset($this->_tagged[$id]['tags'])) {
- $this->_tagged[$id]['tags'] = array();
- }
- $this->_tagged[$id]['tags'] = array_unique(array_merge($this->_tagged[$id]['tags'], $tags));
- $this->_tagged[$id]['extension'] = $ext;
- $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME);
- return (bool) $result;
- }
-
- /**
- * Recursively create the directories needed to write the static file
- */
- protected function _createDirectoriesFor($path)
- {
- $parts = explode('/', $path);
- $directory = '';
- foreach ($parts as $part) {
- $directory = rtrim($directory, '/') . '/' . $part;
- if (!is_dir($directory)) {
- mkdir($directory, $this->_octdec($this->_options['cache_directory_umask']));
- }
- }
- }
-
- /**
- * Detect serialization of data (cannot predict since this is the only way
- * to obey the interface yet pass in another parameter).
- *
- * In future, ZF 2.0, check if we can just avoid the interface restraints.
- *
- * This format is the only valid one possible for the class, so it's simple
- * to just run a regular expression for the starting serialized format.
- */
- protected function _isSerialized($data)
- {
- return preg_match("/a:2:\{i:0;s:\d+:\"/", $data);
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id)
- {
- if (!$this->_verifyPath($id)) {
- Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path');
- }
- $fileName = basename($id);
- if (is_null($this->_tagged) && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) {
- $this->_tagged = $tagged;
- } elseif (!$this->_tagged) {
- return false;
- }
- if (isset($this->_tagged[$id])) {
- $extension = $this->_tagged[$id]['extension'];
- } else {
- $extension = $this->_options['file_extension'];
- }
- if (empty($fileName)) {
- $fileName = $this->_options['index_filename'];
- }
- $pathName = $this->_options['public_dir'] . dirname($id);
- $file = realpath($pathName) . '/' . $fileName . $extension;
- if (!file_exists($file)) {
- return false;
- }
- return unlink($file);
- }
-
- /**
- * Remove a cache record recursively for the given directory matching a
- * REQUEST_URI based relative path (deletes the actual file matching this
- * in addition to the matching directory)
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function removeRecursively($id)
- {
- if (!$this->_verifyPath($id)) {
- Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path');
- }
- $fileName = basename($id);
- if (empty($fileName)) {
- $fileName = $this->_options['index_filename'];
- }
- $pathName = $this->_options['public_dir'] . dirname($id);
- $file = $pathName . '/' . $fileName . $this->_options['file_extension'];
- $directory = $pathName . '/' . $fileName;
- if (file_exists($directory)) {
- if (!is_writable($directory)) {
- return false;
- }
- foreach (new DirectoryIterator($directory) as $file) {
- if (true === $file->isFile()) {
- if (false === unlink($file->getPathName())) {
- return false;
- }
- }
- }
- rmdir(dirname($path));
- }
- if (file_exists($file)) {
- if (!is_writable($file)) {
- return false;
- }
- return unlink($file);
- }
- return true;
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- $result = false;
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- if (empty($tags)) {
- throw new Zend_Exception('Cannot use tag matching modes as no tags were defined');
- }
- if (is_null($this->_tagged) && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) {
- $this->_tagged = $tagged;
- } elseif (!$this->_tagged) {
- return true;
- }
- foreach ($tags as $tag) {
- $urls = array_keys($this->_tagged);
- foreach ($urls as $url) {
- if (isset($this->_tagged[$url]['tags']) && in_array($tag, $this->_tagged[$url]['tags'])) {
- $this->remove($url);
- unset($this->_tagged[$url]);
- }
- }
- }
- $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME);
- $result = true;
- break;
- case Zend_Cache::CLEANING_MODE_ALL:
- if (is_null($this->_tagged)) {
- $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME);
- $this->_tagged = $tagged;
- }
- if (is_null($this->_tagged) || empty($this->_tagged)) {
- return true;
- }
- $urls = array_keys($this->_tagged);
- foreach ($urls as $url) {
- $this->remove($url);
- unset($this->_tagged[$url]);
- }
- $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME);
- $result = true;
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $this->_log("Zend_Cache_Backend_Static : Selected Cleaning Mode Currently Unsupported By This Backend");
- break;
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- if (empty($tags)) {
- throw new Zend_Exception('Cannot use tag matching modes as no tags were defined');
- }
- if (is_null($this->_tagged)) {
- $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME);
- $this->_tagged = $tagged;
- }
- if (is_null($this->_tagged) || empty($this->_tagged)) {
- return true;
- }
- $urls = array_keys($this->_tagged);
- foreach ($urls as $url) {
- $difference = array_diff($tags, $this->_tagged[$url]['tags']);
- if (count($tags) == count($difference)) {
- $this->remove($url);
- unset($this->_tagged[$url]);
- }
- }
- $this->getInnerCache()->save($this->_tagged, self::INNER_CACHE_NAME);
- $result = true;
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- return $result;
- }
-
- /**
- * Set an Inner Cache, used here primarily to store Tags associated
- * with caches created by this backend. Note: If Tags are lost, the cache
- * should be completely cleaned as the mapping of tags to caches will
- * have been irrevocably lost.
- *
- * @param Zend_Cache_Core
- * @return void
- */
- public function setInnerCache(Zend_Cache_Core $cache)
- {
- $this->_tagCache = $cache;
- $this->_options['tag_cache'] = $cache;
- }
-
- /**
- * Get the Inner Cache if set
- *
- * @return Zend_Cache_Core
- */
- public function getInnerCache()
- {
- if (is_null($this->_tagCache)) {
- Zend_Cache::throwException('An Inner Cache has not been set; use setInnerCache()');
- }
- return $this->_tagCache;
- }
-
- /**
- * Verify path exists and is non-empty
- *
- * @param string $path
- * @return bool
- */
- protected function _verifyPath($path)
- {
- $path = realpath($path);
- $base = realpath($this->_options['public_dir']);
- return strncmp($path, $base, strlen($base)) !== 0;
- }
-
- /**
- * Determine the page to save from the request
- *
- * @return string
- */
- protected function _detectId()
- {
- return $_SERVER['REQUEST_URI'];
- }
-
- /**
- * Validate a cache id or a tag (security, reliable filenames, reserved prefixes...)
- *
- * Throw an exception if a problem is found
- *
- * @param string $string Cache id or tag
- * @throws Zend_Cache_Exception
- * @return void
- * @deprecated Not usable until perhaps ZF 2.0
- */
- protected static function _validateIdOrTag($string)
- {
- if (!is_string($string)) {
- Zend_Cache::throwException('Invalid id or tag : must be a string');
- }
-
- // Internal only checked in Frontend - not here!
- if (substr($string, 0, 9) == 'internal-') {
- return;
- }
-
- // Validation assumes no query string, fragments or scheme included - only the path
- if (!preg_match(
- '/^(?:\/(?:(?:%[[:xdigit:]]{2}|[A-Za-z0-9-_.!~*\'()\[\]:@&=+$,;])*)?)+$/',
- $string
- )
- ) {
- Zend_Cache::throwException("Invalid id or tag '$string' : must be a valid URL path");
- }
- }
-
- /**
- * Detect an octal string and return its octal value for file permission ops
- * otherwise return the non-string (assumed octal or decimal int already)
- *
- * @param $val The potential octal in need of conversion
- * @return int
- */
- protected function _octdec($val)
- {
- if (decoct(octdec($val)) == $val && is_string($val)) {
- return octdec($val);
- }
- return $val;
- }
-
- /**
- * Decode a request URI from the provided ID
- */
- protected function _decodeId($id)
- {
- return pack('H*', $id);;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/Test.php zendframework-2.2.6/library/Zend/Cache/Backend/Test.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/Test.php 2010-03-02 10:25:22.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/Test.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,410 +0,0 @@
-_addLog('construct', array($options));
- }
-
- /**
- * Set the frontend directives
- *
- * @param array $directives assoc of directives
- * @return void
- */
- public function setDirectives($directives)
- {
- $this->_addLog('setDirectives', array($directives));
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * For this test backend only, if $id == 'false', then the method will return false
- * if $id == 'serialized', the method will return a serialized array
- * ('foo' else)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @return string Cached datas (or false)
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- $this->_addLog('get', array($id, $doNotTestCacheValidity));
- if ( $id == 'false'
- || $id == 'd8523b3ee441006261eeffa5c3d3a0a7'
- || $id == 'e83249ea22178277d5befc2c5e2e9ace'
- || $id == '40f649b94977c0a6e76902e2a0b43587')
- {
- return false;
- }
- if ($id=='serialized') {
- return serialize(array('foo'));
- }
- if ($id=='serialized2') {
- return serialize(array('headers' => array(), 'data' => 'foo'));
- }
- if (($id=='71769f39054f75894288e397df04e445') or ($id=='615d222619fb20b527168340cebd0578')) {
- return serialize(array('foo', 'bar'));
- }
- if (($id=='8a02d218a5165c467e7a5747cc6bd4b6') or ($id=='648aca1366211d17cbf48e65dc570bee')) {
- return serialize(array('foo', 'bar'));
- }
- return 'foo';
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * For this test backend only, if $id == 'false', then the method will return false
- * (123456 else)
- *
- * @param string $id Cache id
- * @return mixed|false false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- $this->_addLog('test', array($id));
- if ($id=='false') {
- return false;
- }
- if (($id=='3c439c922209e2cb0b54d6deffccd75a')) {
- return false;
- }
- return 123456;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * For this test backend only, if $id == 'false', then the method will return false
- * (true else)
- *
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean True if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $this->_addLog('save', array($data, $id, $tags));
- if ($id=='false') {
- return false;
- }
- return true;
- }
-
- /**
- * Remove a cache record
- *
- * For this test backend only, if $id == 'false', then the method will return false
- * (true else)
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id)
- {
- $this->_addLog('remove', array($id));
- if ($id=='false') {
- return false;
- }
- return true;
- }
-
- /**
- * Clean some cache records
- *
- * For this test backend only, if $mode == 'false', then the method will return false
- * (true else)
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @return boolean True if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- $this->_addLog('clean', array($mode, $tags));
- if ($mode=='false') {
- return false;
- }
- return true;
- }
-
- /**
- * Get the last log
- *
- * @return string The last log
- */
- public function getLastLog()
- {
- return $this->_log[$this->_index - 1];
- }
-
- /**
- * Get the log index
- *
- * @return int Log index
- */
- public function getLogIndex()
- {
- return $this->_index;
- }
-
- /**
- * Get the complete log array
- *
- * @return array Complete log array
- */
- public function getAllLogs()
- {
- return $this->_log;
- }
-
- /**
- * Return true if the automatic cleaning is available for the backend
- *
- * @return boolean
- */
- public function isAutomaticCleaningAvailable()
- {
- return true;
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- return array(
- 'prefix_id1', 'prefix_id2'
- );
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- return array(
- 'tag1', 'tag2'
- );
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- if ($tags == array('tag1', 'tag2')) {
- return array('prefix_id1', 'prefix_id2');
- }
-
- return array();
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- if ($tags == array('tag3', 'tag4')) {
- return array('prefix_id3', 'prefix_id4');
- }
-
- return array();
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- if ($tags == array('tag5', 'tag6')) {
- return array('prefix_id5', 'prefix_id6');
- }
-
- return array();
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- return 50;
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- return false;
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- return true;
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- return array(
- 'automatic_cleaning' => true,
- 'tags' => true,
- 'expired_read' => false,
- 'priority' => true,
- 'infinite_lifetime' => true,
- 'get_list' => true
- );
- }
-
- /**
- * Add an event to the log array
- *
- * @param string $methodName MethodName
- * @param array $args Arguments
- * @return void
- */
- private function _addLog($methodName, $args)
- {
- $this->_log[$this->_index] = array(
- 'methodName' => $methodName,
- 'args' => $args
- );
- $this->_index = $this->_index + 1;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/TwoLevels.php zendframework-2.2.6/library/Zend/Cache/Backend/TwoLevels.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/TwoLevels.php 2010-04-19 19:19:24.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/TwoLevels.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,531 +0,0 @@
- (string) slow_backend :
- * - Slow backend name
- * - Must implement the Zend_Cache_Backend_ExtendedInterface
- * - Should provide a big storage
- *
- * =====> (string) fast_backend :
- * - Flow backend name
- * - Must implement the Zend_Cache_Backend_ExtendedInterface
- * - Must be much faster than slow_backend
- *
- * =====> (array) slow_backend_options :
- * - Slow backend options (see corresponding backend)
- *
- * =====> (array) fast_backend_options :
- * - Fast backend options (see corresponding backend)
- *
- * =====> (int) stats_update_factor :
- * - Disable / Tune the computation of the fast backend filling percentage
- * - When saving a record into cache :
- * 1 => systematic computation of the fast backend filling percentage
- * x (integer) > 1 => computation of the fast backend filling percentage randomly 1 times on x cache write
- *
- * =====> (boolean) slow_backend_custom_naming :
- * =====> (boolean) fast_backend_custom_naming :
- * =====> (boolean) slow_backend_autoload :
- * =====> (boolean) fast_backend_autoload :
- * - See Zend_Cache::factory() method
- *
- * =====> (boolean) auto_refresh_fast_cache
- * - If true, auto refresh the fast cache when a cache record is hit
- *
- * @var array available options
- */
- protected $_options = array(
- 'slow_backend' => 'File',
- 'fast_backend' => 'Apc',
- 'slow_backend_options' => array(),
- 'fast_backend_options' => array(),
- 'stats_update_factor' => 10,
- 'slow_backend_custom_naming' => false,
- 'fast_backend_custom_naming' => false,
- 'slow_backend_autoload' => false,
- 'fast_backend_autoload' => false,
- 'auto_refresh_fast_cache' => true
- );
-
- /**
- * Slow Backend
- *
- * @var Zend_Cache_Backend
- */
- protected $_slowBackend;
-
- /**
- * Fast Backend
- *
- * @var Zend_Cache_Backend
- */
- protected $_fastBackend;
-
- /**
- * Cache for the fast backend filling percentage
- *
- * @var int
- */
- protected $_fastBackendFillingPercentage = null;
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- parent::__construct($options);
-
- if ($this->_options['slow_backend'] === null) {
- Zend_Cache::throwException('slow_backend option has to set');
- } elseif ($this->_options['slow_backend'] instanceof Zend_Cache_Backend_ExtendedInterface) {
- $this->_slowBackend = $this->_options['slow_backend'];
- } else {
- $this->_slowBackend = Zend_Cache::_makeBackend(
- $this->_options['slow_backend'],
- $this->_options['slow_backend_options'],
- $this->_options['slow_backend_custom_naming'],
- $this->_options['slow_backend_autoload']
- );
- if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_slowBackend))) {
- Zend_Cache::throwException('slow_backend must implement the Zend_Cache_Backend_ExtendedInterface interface');
- }
- }
-
- if ($this->_options['fast_backend'] === null) {
- Zend_Cache::throwException('fast_backend option has to set');
- } elseif ($this->_options['fast_backend'] instanceof Zend_Cache_Backend_ExtendedInterface) {
- $this->_fastBackend = $this->_options['fast_backend'];
- } else {
- $this->_fastBackend = Zend_Cache::_makeBackend(
- $this->_options['fast_backend'],
- $this->_options['fast_backend_options'],
- $this->_options['fast_backend_custom_naming'],
- $this->_options['fast_backend_autoload']
- );
- if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_fastBackend))) {
- Zend_Cache::throwException('fast_backend must implement the Zend_Cache_Backend_ExtendedInterface interface');
- }
- }
-
- $this->_slowBackend->setDirectives($this->_directives);
- $this->_fastBackend->setDirectives($this->_directives);
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id cache id
- * @return mixed|false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- $fastTest = $this->_fastBackend->test($id);
- if ($fastTest) {
- return $fastTest;
- } else {
- return $this->_slowBackend->test($id);
- }
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false, $priority = 8)
- {
- $usage = $this->_getFastFillingPercentage('saving');
- $boolFast = true;
- $lifetime = $this->getLifetime($specificLifetime);
- $preparedData = $this->_prepareData($data, $lifetime, $priority);
- if (($priority > 0) && (10 * $priority >= $usage)) {
- $fastLifetime = $this->_getFastLifetime($lifetime, $priority);
- $boolFast = $this->_fastBackend->save($preparedData, $id, array(), $fastLifetime);
- $boolSlow = $this->_slowBackend->save($preparedData, $id, $tags, $lifetime);
- } else {
- $boolSlow = $this->_slowBackend->save($preparedData, $id, $tags, $lifetime);
- if ($boolSlow === true) {
- $boolFast = $this->_fastBackend->remove($id);
- }
- }
-
- return ($boolFast && $boolSlow);
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * Note : return value is always "string" (unserialization is done by the core not by the backend)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @return string|false cached datas
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- $res = $this->_fastBackend->load($id, $doNotTestCacheValidity);
- if ($res === false) {
- $res = $this->_slowBackend->load($id, $doNotTestCacheValidity);
- if ($res === false) {
- // there is no cache at all for this id
- return false;
- }
- }
- $array = unserialize($res);
- // maybe, we have to refresh the fast cache ?
- if ($this->_options['auto_refresh_fast_cache']) {
- if ($array['priority'] == 10) {
- // no need to refresh the fast cache with priority = 10
- return $array['data'];
- }
- $newFastLifetime = $this->_getFastLifetime($array['lifetime'], $array['priority'], time() - $array['expire']);
- // we have the time to refresh the fast cache
- $usage = $this->_getFastFillingPercentage('loading');
- if (($array['priority'] > 0) && (10 * $array['priority'] >= $usage)) {
- // we can refresh the fast cache
- $preparedData = $this->_prepareData($array['data'], $array['lifetime'], $array['priority']);
- $this->_fastBackend->save($preparedData, $id, array(), $newFastLifetime);
- }
- }
- return $array['data'];
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id)
- {
- $boolFast = $this->_fastBackend->remove($id);
- $boolSlow = $this->_slowBackend->remove($id);
- return $boolFast && $boolSlow;
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @throws Zend_Cache_Exception
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- $boolFast = $this->_fastBackend->clean(Zend_Cache::CLEANING_MODE_ALL);
- $boolSlow = $this->_slowBackend->clean(Zend_Cache::CLEANING_MODE_ALL);
- return $boolFast && $boolSlow;
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- return $this->_slowBackend->clean(Zend_Cache::CLEANING_MODE_OLD);
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- $ids = $this->_slowBackend->getIdsMatchingTags($tags);
- $res = true;
- foreach ($ids as $id) {
- $bool = $this->remove($id);
- $res = $res && $bool;
- }
- return $res;
- break;
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- $ids = $this->_slowBackend->getIdsNotMatchingTags($tags);
- $res = true;
- foreach ($ids as $id) {
- $bool = $this->remove($id);
- $res = $res && $bool;
- }
- return $res;
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $ids = $this->_slowBackend->getIdsMatchingAnyTags($tags);
- $res = true;
- foreach ($ids as $id) {
- $bool = $this->remove($id);
- $res = $res && $bool;
- }
- return $res;
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- return $this->_slowBackend->getIds();
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- return $this->_slowBackend->getTags();
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- return $this->_slowBackend->getIdsMatchingTags($tags);
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- return $this->_slowBackend->getIdsNotMatchingTags($tags);
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- return $this->_slowBackend->getIdsMatchingAnyTags($tags);
- }
-
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- return $this->_slowBackend->getFillingPercentage();
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array must include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- return $this->_slowBackend->getMetadatas($id);
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- return $this->_slowBackend->touch($id, $extraLifetime);
- }
-
- /**
- * Return an associative array of capabilities (booleans) of the backend
- *
- * The array must include these keys :
- * - automatic_cleaning (is automating cleaning necessary)
- * - tags (are tags supported)
- * - expired_read (is it possible to read expired cache records
- * (for doNotTestCacheValidity option for example))
- * - priority does the backend deal with priority when saving
- * - infinite_lifetime (is infinite lifetime can work with this backend)
- * - get_list (is it possible to get the list of cache ids and the complete list of tags)
- *
- * @return array associative of with capabilities
- */
- public function getCapabilities()
- {
- $slowBackendCapabilities = $this->_slowBackend->getCapabilities();
- return array(
- 'automatic_cleaning' => $slowBackendCapabilities['automatic_cleaning'],
- 'tags' => $slowBackendCapabilities['tags'],
- 'expired_read' => $slowBackendCapabilities['expired_read'],
- 'priority' => $slowBackendCapabilities['priority'],
- 'infinite_lifetime' => $slowBackendCapabilities['infinite_lifetime'],
- 'get_list' => $slowBackendCapabilities['get_list']
- );
- }
-
- /**
- * Prepare a serialized array to store datas and metadatas informations
- *
- * @param string $data data to store
- * @param int $lifetime original lifetime
- * @param int $priority priority
- * @return string serialize array to store into cache
- */
- private function _prepareData($data, $lifetime, $priority)
- {
- $lt = $lifetime;
- if ($lt === null) {
- $lt = 9999999999;
- }
- return serialize(array(
- 'data' => $data,
- 'lifetime' => $lifetime,
- 'expire' => time() + $lt,
- 'priority' => $priority
- ));
- }
-
- /**
- * Compute and return the lifetime for the fast backend
- *
- * @param int $lifetime original lifetime
- * @param int $priority priority
- * @param int $maxLifetime maximum lifetime
- * @return int lifetime for the fast backend
- */
- private function _getFastLifetime($lifetime, $priority, $maxLifetime = null)
- {
- if ($lifetime === null) {
- // if lifetime is null, we have an infinite lifetime
- // we need to use arbitrary lifetimes
- $fastLifetime = (int) (2592000 / (11 - $priority));
- } else {
- $fastLifetime = (int) ($lifetime / (11 - $priority));
- }
- if (($maxLifetime !== null) && ($maxLifetime >= 0)) {
- if ($fastLifetime > $maxLifetime) {
- return $maxLifetime;
- }
- }
- return $fastLifetime;
- }
-
- /**
- * PUBLIC METHOD FOR UNIT TESTING ONLY !
- *
- * Force a cache record to expire
- *
- * @param string $id cache id
- */
- public function ___expire($id)
- {
- $this->_fastBackend->remove($id);
- $this->_slowBackend->___expire($id);
- }
-
- private function _getFastFillingPercentage($mode)
- {
-
- if ($mode == 'saving') {
- // mode saving
- if ($this->_fastBackendFillingPercentage === null) {
- $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage();
- } else {
- $rand = rand(1, $this->_options['stats_update_factor']);
- if ($rand == 1) {
- // we force a refresh
- $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage();
- }
- }
- } else {
- // mode loading
- // we compute the percentage only if it's not available in cache
- if ($this->_fastBackendFillingPercentage === null) {
- $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage();
- }
- }
- return $this->_fastBackendFillingPercentage;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/Xcache.php zendframework-2.2.6/library/Zend/Cache/Backend/Xcache.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/Xcache.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/Xcache.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,216 +0,0 @@
- (string) user :
- * xcache.admin.user (necessary for the clean() method)
- *
- * =====> (string) password :
- * xcache.admin.pass (clear, not MD5) (necessary for the clean() method)
- *
- * @var array available options
- */
- protected $_options = array(
- 'user' => null,
- 'password' => null
- );
-
- /**
- * Constructor
- *
- * @param array $options associative array of options
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- if (!extension_loaded('xcache')) {
- Zend_Cache::throwException('The xcache extension must be loaded for using this backend !');
- }
- parent::__construct($options);
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * WARNING $doNotTestCacheValidity=true is unsupported by the Xcache backend
- *
- * @param string $id cache id
- * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
- * @return string cached datas (or false)
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- if ($doNotTestCacheValidity) {
- $this->_log("Zend_Cache_Backend_Xcache::load() : \$doNotTestCacheValidity=true is unsupported by the Xcache backend");
- }
- $tmp = xcache_get($id);
- if (is_array($tmp)) {
- return $tmp[0];
- }
- return false;
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id cache id
- * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- if (xcache_isset($id)) {
- $tmp = xcache_get($id);
- if (is_array($tmp)) {
- return $tmp[1];
- }
- }
- return false;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data datas to cache
- * @param string $id cache id
- * @param array $tags array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime if != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $lifetime = $this->getLifetime($specificLifetime);
- $result = xcache_set($id, array($data, time()), $lifetime);
- if (count($tags) > 0) {
- $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_XCACHE_BACKEND);
- }
- return $result;
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id cache id
- * @return boolean true if no problem
- */
- public function remove($id)
- {
- return xcache_unset($id);
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => unsupported
- * 'matchingTag' => unsupported
- * 'notMatchingTag' => unsupported
- * 'matchingAnyTag' => unsupported
- *
- * @param string $mode clean mode
- * @param array $tags array of tags
- * @throws Zend_Cache_Exception
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- // Necessary because xcache_clear_cache() need basic authentification
- $backup = array();
- if (isset($_SERVER['PHP_AUTH_USER'])) {
- $backup['PHP_AUTH_USER'] = $_SERVER['PHP_AUTH_USER'];
- }
- if (isset($_SERVER['PHP_AUTH_PW'])) {
- $backup['PHP_AUTH_PW'] = $_SERVER['PHP_AUTH_PW'];
- }
- if ($this->_options['user']) {
- $_SERVER['PHP_AUTH_USER'] = $this->_options['user'];
- }
- if ($this->_options['password']) {
- $_SERVER['PHP_AUTH_PW'] = $this->_options['password'];
- }
- xcache_clear_cache(XC_TYPE_VAR, 0);
- if (isset($backup['PHP_AUTH_USER'])) {
- $_SERVER['PHP_AUTH_USER'] = $backup['PHP_AUTH_USER'];
- $_SERVER['PHP_AUTH_PW'] = $backup['PHP_AUTH_PW'];
- }
- return true;
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $this->_log("Zend_Cache_Backend_Xcache::clean() : CLEANING_MODE_OLD is unsupported by the Xcache backend");
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_XCACHE_BACKEND);
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-
- /**
- * Return true if the automatic cleaning is available for the backend
- *
- * @return boolean
- */
- public function isAutomaticCleaningAvailable()
- {
- return false;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/ZendPlatform.php zendframework-2.2.6/library/Zend/Cache/Backend/ZendPlatform.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/ZendPlatform.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/ZendPlatform.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,317 +0,0 @@
-_directives['lifetime'];
- }
- $res = output_cache_get($id, $lifetime);
- if($res) {
- return $res[0];
- } else {
- return false;
- }
- }
-
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id Cache id
- * @return mixed|false false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- */
- public function test($id)
- {
- $result = output_cache_get($id, $this->_directives['lifetime']);
- if ($result) {
- return $result[1];
- }
- return false;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data Data to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- if (!($specificLifetime === false)) {
- $this->_log("Zend_Cache_Backend_ZendPlatform::save() : non false specifc lifetime is unsuported for this backend");
- }
-
- $lifetime = $this->_directives['lifetime'];
- $result1 = output_cache_put($id, array($data, time()));
- $result2 = (count($tags) == 0);
-
- foreach ($tags as $tag) {
- $tagid = self::TAGS_PREFIX.$tag;
- $old_tags = output_cache_get($tagid, $lifetime);
- if ($old_tags === false) {
- $old_tags = array();
- }
- $old_tags[$id] = $id;
- output_cache_remove_key($tagid);
- $result2 = output_cache_put($tagid, $old_tags);
- }
-
- return $result1 && $result2;
- }
-
-
- /**
- * Remove a cache record
- *
- * @param string $id Cache id
- * @return boolean True if no problem
- */
- public function remove($id)
- {
- return output_cache_remove_key($id);
- }
-
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used)
- * Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used)
- * This mode is not supported in this backend
- * Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => unsupported
- * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode Clean mode
- * @param array $tags Array of tags
- * @throws Zend_Cache_Exception
- * @return boolean True if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- case Zend_Cache::CLEANING_MODE_OLD:
- $cache_dir = ini_get('zend_accelerator.output_cache_dir');
- if (!$cache_dir) {
- return false;
- }
- $cache_dir .= '/.php_cache_api/';
- return $this->_clean($cache_dir, $mode);
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- $idlist = null;
- foreach ($tags as $tag) {
- $next_idlist = output_cache_get(self::TAGS_PREFIX.$tag, $this->_directives['lifetime']);
- if ($idlist) {
- $idlist = array_intersect_assoc($idlist, $next_idlist);
- } else {
- $idlist = $next_idlist;
- }
- if (count($idlist) == 0) {
- // if ID list is already empty - we may skip checking other IDs
- $idlist = null;
- break;
- }
- }
- if ($idlist) {
- foreach ($idlist as $id) {
- output_cache_remove_key($id);
- }
- }
- return true;
- break;
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- $this->_log("Zend_Cache_Backend_ZendPlatform::clean() : CLEANING_MODE_NOT_MATCHING_TAG is not supported by the Zend Platform backend");
- return false;
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $idlist = null;
- foreach ($tags as $tag) {
- $next_idlist = output_cache_get(self::TAGS_PREFIX.$tag, $this->_directives['lifetime']);
- if ($idlist) {
- $idlist = array_merge_recursive($idlist, $next_idlist);
- } else {
- $idlist = $next_idlist;
- }
- if (count($idlist) == 0) {
- // if ID list is already empty - we may skip checking other IDs
- $idlist = null;
- break;
- }
- }
- if ($idlist) {
- foreach ($idlist as $id) {
- output_cache_remove_key($id);
- }
- }
- return true;
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-
- /**
- * Clean a directory and recursivly go over it's subdirectories
- *
- * Remove all the cached files that need to be cleaned (according to mode and files mtime)
- *
- * @param string $dir Path of directory ot clean
- * @param string $mode The same parameter as in Zend_Cache_Backend_ZendPlatform::clean()
- * @return boolean True if ok
- */
- private function _clean($dir, $mode)
- {
- $d = @dir($dir);
- if (!$d) {
- return false;
- }
- $result = true;
- while (false !== ($file = $d->read())) {
- if ($file == '.' || $file == '..') {
- continue;
- }
- $file = $d->path . $file;
- if (is_dir($file)) {
- $result = ($this->_clean($file .'/', $mode)) && ($result);
- } else {
- if ($mode == Zend_Cache::CLEANING_MODE_ALL) {
- $result = ($this->_remove($file)) && ($result);
- } else if ($mode == Zend_Cache::CLEANING_MODE_OLD) {
- // Files older than lifetime get deleted from cache
- if ($this->_directives['lifetime'] !== null) {
- if ((time() - @filemtime($file)) > $this->_directives['lifetime']) {
- $result = ($this->_remove($file)) && ($result);
- }
- }
- }
- }
- }
- $d->close();
- return $result;
- }
-
- /**
- * Remove a file
- *
- * If we can't remove the file (because of locks or any problem), we will touch
- * the file to invalidate it
- *
- * @param string $file Complete file path
- * @return boolean True if ok
- */
- private function _remove($file)
- {
- if (!@unlink($file)) {
- # If we can't remove the file (because of locks or any problem), we will touch
- # the file to invalidate it
- $this->_log("Zend_Cache_Backend_ZendPlatform::_remove() : we can't remove $file => we are going to try to invalidate it");
- if ($this->_directives['lifetime'] === null) {
- return false;
- }
- if (!file_exists($file)) {
- return false;
- }
- return @touch($file, time() - 2*abs($this->_directives['lifetime']));
- }
- return true;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/ZendServer/Disk.php zendframework-2.2.6/library/Zend/Cache/Backend/ZendServer/Disk.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/ZendServer/Disk.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/ZendServer/Disk.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,100 +0,0 @@
-_options['namespace'] . '::' . $id,
- $data,
- $timeToLive) === false) {
- $this->_log('Store operation failed.');
- return false;
- }
- return true;
- }
-
- /**
- * Fetch data
- *
- * @param string $id Cache id
- */
- protected function _fetch($id)
- {
- return zend_disk_cache_fetch($this->_options['namespace'] . '::' . $id);
- }
-
- /**
- * Unset data
- *
- * @param string $id Cache id
- * @return boolean true if no problem
- */
- protected function _unset($id)
- {
- return zend_disk_cache_delete($this->_options['namespace'] . '::' . $id);
- }
-
- /**
- * Clear cache
- */
- protected function _clear()
- {
- zend_disk_cache_clear($this->_options['namespace']);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/ZendServer/ShMem.php zendframework-2.2.6/library/Zend/Cache/Backend/ZendServer/ShMem.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/ZendServer/ShMem.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/ZendServer/ShMem.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,100 +0,0 @@
-_options['namespace'] . '::' . $id,
- $data,
- $timeToLive) === false) {
- $this->_log('Store operation failed.');
- return false;
- }
- return true;
- }
-
- /**
- * Fetch data
- *
- * @param string $id Cache id
- */
- protected function _fetch($id)
- {
- return zend_shm_cache_fetch($this->_options['namespace'] . '::' . $id);
- }
-
- /**
- * Unset data
- *
- * @param string $id Cache id
- * @return boolean true if no problem
- */
- protected function _unset($id)
- {
- return zend_shm_cache_delete($this->_options['namespace'] . '::' . $id);
- }
-
- /**
- * Clear cache
- */
- protected function _clear()
- {
- zend_shm_cache_clear($this->_options['namespace']);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend/ZendServer.php zendframework-2.2.6/library/Zend/Cache/Backend/ZendServer.php
--- zendframework-1.10.4/library/Zend/Cache/Backend/ZendServer.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend/ZendServer.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,207 +0,0 @@
- (string) namespace :
- * Namespace to be used for chaching operations
- *
- * @var array available options
- */
- protected $_options = array(
- 'namespace' => 'zendframework'
- );
-
- /**
- * Store data
- *
- * @param mixed $data Object to store
- * @param string $id Cache id
- * @param int $timeToLive Time to live in seconds
- * @throws Zend_Cache_Exception
- */
- abstract protected function _store($data, $id, $timeToLive);
-
- /**
- * Fetch data
- *
- * @param string $id Cache id
- * @throws Zend_Cache_Exception
- */
- abstract protected function _fetch($id);
-
- /**
- * Unset data
- *
- * @param string $id Cache id
- */
- abstract protected function _unset($id);
-
- /**
- * Clear cache
- */
- abstract protected function _clear();
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * @param string $id cache id
- * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
- * @return string cached datas (or false)
- */
- public function load($id, $doNotTestCacheValidity = false)
- {
- $tmp = $this->_fetch($id);
- if ($tmp !== null) {
- return $tmp;
- }
- return false;
- }
-
- /**
- * Test if a cache is available or not (for the given id)
- *
- * @param string $id cache id
- * @return mixed false (a cache is not available) or "last modified" timestamp (int) of the available cache record
- * @throws Zend_Cache_Exception
- */
- public function test($id)
- {
- $tmp = $this->_fetch('internal-metadatas---' . $id);
- if ($tmp !== false) {
- if (!is_array($tmp) || !isset($tmp['mtime'])) {
- Zend_Cache::throwException('Cache metadata for \'' . $id . '\' id is corrupted' );
- }
- return $tmp['mtime'];
- }
- return false;
- }
-
- /**
- * Compute & return the expire time
- *
- * @return int expire time (unix timestamp)
- */
- private function _expireTime($lifetime)
- {
- if ($lifetime === null) {
- return 9999999999;
- }
- return time() + $lifetime;
- }
-
- /**
- * Save some string datas into a cache record
- *
- * Note : $data is always "string" (serialization is done by the
- * core not by the backend)
- *
- * @param string $data datas to cache
- * @param string $id cache id
- * @param array $tags array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime if != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean true if no problem
- */
- public function save($data, $id, $tags = array(), $specificLifetime = false)
- {
- $lifetime = $this->getLifetime($specificLifetime);
- $metadatas = array(
- 'mtime' => time(),
- 'expire' => $this->_expireTime($lifetime),
- );
-
- if (count($tags) > 0) {
- $this->_log('Zend_Cache_Backend_ZendServer::save() : tags are unsupported by the ZendServer backends');
- }
-
- return $this->_store($data, $id, $lifetime) &&
- $this->_store($metadatas, 'internal-metadatas---' . $id, $lifetime);
- }
-
- /**
- * Remove a cache record
- *
- * @param string $id cache id
- * @return boolean true if no problem
- */
- public function remove($id)
- {
- $result1 = $this->_unset($id);
- $result2 = $this->_unset('internal-metadatas---' . $id);
-
- return $result1 && $result2;
- }
-
- /**
- * Clean some cache records
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => unsupported
- * 'matchingTag' => unsupported
- * 'notMatchingTag' => unsupported
- * 'matchingAnyTag' => unsupported
- *
- * @param string $mode clean mode
- * @param array $tags array of tags
- * @throws Zend_Cache_Exception
- * @return boolean true if no problem
- */
- public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
- {
- switch ($mode) {
- case Zend_Cache::CLEANING_MODE_ALL:
- $this->_clear();
- return true;
- break;
- case Zend_Cache::CLEANING_MODE_OLD:
- $this->_log("Zend_Cache_Backend_ZendServer::clean() : CLEANING_MODE_OLD is unsupported by the Zend Server backends.");
- break;
- case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
- case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
- $this->_clear();
- $this->_log('Zend_Cache_Backend_ZendServer::clean() : tags are unsupported by the Zend Server backends.');
- break;
- default:
- Zend_Cache::throwException('Invalid mode for clean() method');
- break;
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Backend.php zendframework-2.2.6/library/Zend/Cache/Backend.php
--- zendframework-1.10.4/library/Zend/Cache/Backend.php 2010-02-03 18:19:44.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Backend.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,266 +0,0 @@
- (int) lifetime :
- * - Cache lifetime (in seconds)
- * - If null, the cache is valid forever
- *
- * =====> (int) logging :
- * - if set to true, a logging is activated throw Zend_Log
- *
- * @var array directives
- */
- protected $_directives = array(
- 'lifetime' => 3600,
- 'logging' => false,
- 'logger' => null
- );
-
- /**
- * Available options
- *
- * @var array available options
- */
- protected $_options = array();
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- while (list($name, $value) = each($options)) {
- $this->setOption($name, $value);
- }
- }
-
- /**
- * Set the frontend directives
- *
- * @param array $directives Assoc of directives
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setDirectives($directives)
- {
- if (!is_array($directives)) Zend_Cache::throwException('Directives parameter must be an array');
- while (list($name, $value) = each($directives)) {
- if (!is_string($name)) {
- Zend_Cache::throwException("Incorrect option name : $name");
- }
- $name = strtolower($name);
- if (array_key_exists($name, $this->_directives)) {
- $this->_directives[$name] = $value;
- }
-
- }
-
- $this->_loggerSanity();
- }
-
- /**
- * Set an option
- *
- * @param string $name
- * @param mixed $value
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setOption($name, $value)
- {
- if (!is_string($name)) {
- Zend_Cache::throwException("Incorrect option name : $name");
- }
- $name = strtolower($name);
- if (array_key_exists($name, $this->_options)) {
- $this->_options[$name] = $value;
- }
- }
-
- /**
- * Get the life time
- *
- * if $specificLifetime is not false, the given specific life time is used
- * else, the global lifetime is used
- *
- * @param int $specificLifetime
- * @return int Cache life time
- */
- public function getLifetime($specificLifetime)
- {
- if ($specificLifetime === false) {
- return $this->_directives['lifetime'];
- }
- return $specificLifetime;
- }
-
- /**
- * Return true if the automatic cleaning is available for the backend
- *
- * DEPRECATED : use getCapabilities() instead
- *
- * @deprecated
- * @return boolean
- */
- public function isAutomaticCleaningAvailable()
- {
- return true;
- }
-
- /**
- * Determine system TMP directory and detect if we have read access
- *
- * inspired from Zend_File_Transfer_Adapter_Abstract
- *
- * @return string
- * @throws Zend_Cache_Exception if unable to determine directory
- */
- public function getTmpDir()
- {
- $tmpdir = array();
- foreach (array($_ENV, $_SERVER) as $tab) {
- foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
- if (isset($tab[$key])) {
- if (($key == 'windir') or ($key == 'SystemRoot')) {
- $dir = realpath($tab[$key] . '\\temp');
- } else {
- $dir = realpath($tab[$key]);
- }
- if ($this->_isGoodTmpDir($dir)) {
- return $dir;
- }
- }
- }
- }
- $upload = ini_get('upload_tmp_dir');
- if ($upload) {
- $dir = realpath($upload);
- if ($this->_isGoodTmpDir($dir)) {
- return $dir;
- }
- }
- if (function_exists('sys_get_temp_dir')) {
- $dir = sys_get_temp_dir();
- if ($this->_isGoodTmpDir($dir)) {
- return $dir;
- }
- }
- // Attemp to detect by creating a temporary file
- $tempFile = tempnam(md5(uniqid(rand(), TRUE)), '');
- if ($tempFile) {
- $dir = realpath(dirname($tempFile));
- unlink($tempFile);
- if ($this->_isGoodTmpDir($dir)) {
- return $dir;
- }
- }
- if ($this->_isGoodTmpDir('/tmp')) {
- return '/tmp';
- }
- if ($this->_isGoodTmpDir('\\temp')) {
- return '\\temp';
- }
- Zend_Cache::throwException('Could not determine temp directory, please specify a cache_dir manually');
- }
-
- /**
- * Verify if the given temporary directory is readable and writable
- *
- * @param $dir temporary directory
- * @return boolean true if the directory is ok
- */
- protected function _isGoodTmpDir($dir)
- {
- if (is_readable($dir)) {
- if (is_writable($dir)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Make sure if we enable logging that the Zend_Log class
- * is available.
- * Create a default log object if none is set.
- *
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected function _loggerSanity()
- {
- if (!isset($this->_directives['logging']) || !$this->_directives['logging']) {
- return;
- }
-
- if (isset($this->_directives['logger'])) {
- if ($this->_directives['logger'] instanceof Zend_Log) {
- return;
- }
- Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.');
- }
-
- // Create a default logger to the standard output stream
- require_once 'Zend/Log.php';
- require_once 'Zend/Log/Writer/Stream.php';
- $logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output'));
- $this->_directives['logger'] = $logger;
- }
-
- /**
- * Log a message at the WARN (4) priority.
- *
- * @param string $message
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected function _log($message, $priority = 4)
- {
- if (!$this->_directives['logging']) {
- return;
- }
-
- if (!isset($this->_directives['logger'])) {
- Zend_Cache::throwException('Logging is enabled but logger is not set.');
- }
- $logger = $this->_directives['logger'];
- if (!$logger instanceof Zend_Log) {
- Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.');
- }
- $logger->log($message, $priority);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/composer.json zendframework-2.2.6/library/Zend/Cache/composer.json
--- zendframework-1.10.4/library/Zend/Cache/composer.json 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/composer.json 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,38 @@
+{
+ "name": "zendframework/zend-cache",
+ "description": "provides a generic way to cache any data",
+ "license": "BSD-3-Clause",
+ "keywords": [
+ "zf2",
+ "cache"
+ ],
+ "autoload": {
+ "psr-0": {
+ "Zend\\Cache\\": ""
+ }
+ },
+ "target-dir": "Zend/Cache",
+ "require": {
+ "php": ">=5.3.3",
+ "zendframework/zend-stdlib": "self.version",
+ "zendframework/zend-servicemanager": "self.version",
+ "zendframework/zend-eventmanager": "self.version"
+ },
+ "require-dev": {
+ "zendframework/zend-serializer": "self.version"
+ },
+ "suggest": {
+ "zendframework/zend-serializer": "Zend\\Serializer component",
+ "zendframework/zend-session": "Zend\\Session component",
+ "ext-apc": "APC >= 3.1.6 to use the APC storage adapter",
+ "ext-dba": "DBA, to use the DBA storage adapter",
+ "ext-memcached": "Memcached >= 1.0.0 to use the Memcached storage adapter",
+ "ext-wincache": "WinCache, to use the WinCache storage adapter"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev",
+ "dev-develop": "2.3-dev"
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Core.php zendframework-2.2.6/library/Zend/Cache/Core.php
--- zendframework-1.10.4/library/Zend/Cache/Core.php 2010-03-02 10:26:32.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Core.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,756 +0,0 @@
- (boolean) write_control :
- * - Enable / disable write control (the cache is read just after writing to detect corrupt entries)
- * - Enable write control will lightly slow the cache writing but not the cache reading
- * Write control can detect some corrupt cache files but maybe it's not a perfect control
- *
- * ====> (boolean) caching :
- * - Enable / disable caching
- * (can be very useful for the debug of cached scripts)
- *
- * =====> (string) cache_id_prefix :
- * - prefix for cache ids (namespace)
- *
- * ====> (boolean) automatic_serialization :
- * - Enable / disable automatic serialization
- * - It can be used to save directly datas which aren't strings (but it's slower)
- *
- * ====> (int) automatic_cleaning_factor :
- * - Disable / Tune the automatic cleaning process
- * - The automatic cleaning process destroy too old (for the given life time)
- * cache files when a new cache file is written :
- * 0 => no automatic cache cleaning
- * 1 => systematic cache cleaning
- * x (integer) > 1 => automatic cleaning randomly 1 times on x cache write
- *
- * ====> (int) lifetime :
- * - Cache lifetime (in seconds)
- * - If null, the cache is valid forever.
- *
- * ====> (boolean) logging :
- * - If set to true, logging is activated (but the system is slower)
- *
- * ====> (boolean) ignore_user_abort
- * - If set to true, the core will set the ignore_user_abort PHP flag inside the
- * save() method to avoid cache corruptions in some cases (default false)
- *
- * @var array $_options available options
- */
- protected $_options = array(
- 'write_control' => true,
- 'caching' => true,
- 'cache_id_prefix' => null,
- 'automatic_serialization' => false,
- 'automatic_cleaning_factor' => 10,
- 'lifetime' => 3600,
- 'logging' => false,
- 'logger' => null,
- 'ignore_user_abort' => false
- );
-
- /**
- * Array of options which have to be transfered to backend
- *
- * @var array $_directivesList
- */
- protected static $_directivesList = array('lifetime', 'logging', 'logger');
-
- /**
- * Not used for the core, just a sort a hint to get a common setOption() method (for the core and for frontends)
- *
- * @var array $_specificOptions
- */
- protected $_specificOptions = array();
-
- /**
- * Last used cache id
- *
- * @var string $_lastId
- */
- private $_lastId = null;
-
- /**
- * True if the backend implements Zend_Cache_Backend_ExtendedInterface
- *
- * @var boolean $_extendedBackend
- */
- protected $_extendedBackend = false;
-
- /**
- * Array of capabilities of the backend (only if it implements Zend_Cache_Backend_ExtendedInterface)
- *
- * @var array
- */
- protected $_backendCapabilities = array();
-
- /**
- * Constructor
- *
- * @param array|Zend_Config $options Associative array of options or Zend_Config instance
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct($options = array())
- {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- }
- if (!is_array($options)) {
- Zend_Cache::throwException("Options passed were not an array"
- . " or Zend_Config instance.");
- }
- while (list($name, $value) = each($options)) {
- $this->setOption($name, $value);
- }
- $this->_loggerSanity();
- }
-
- /**
- * Set options using an instance of type Zend_Config
- *
- * @param Zend_Config $config
- * @return Zend_Cache_Core
- */
- public function setConfig(Zend_Config $config)
- {
- $options = $config->toArray();
- while (list($name, $value) = each($options)) {
- $this->setOption($name, $value);
- }
- return $this;
- }
-
- /**
- * Set the backend
- *
- * @param object $backendObject
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setBackend(Zend_Cache_Backend $backendObject)
- {
- $this->_backend= $backendObject;
- // some options (listed in $_directivesList) have to be given
- // to the backend too (even if they are not "backend specific")
- $directives = array();
- foreach (Zend_Cache_Core::$_directivesList as $directive) {
- $directives[$directive] = $this->_options[$directive];
- }
- $this->_backend->setDirectives($directives);
- if (in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_backend))) {
- $this->_extendedBackend = true;
- $this->_backendCapabilities = $this->_backend->getCapabilities();
- }
-
- }
-
- /**
- * Returns the backend
- *
- * @return object backend object
- */
- public function getBackend()
- {
- return $this->_backend;
- }
-
- /**
- * Public frontend to set an option
- *
- * There is an additional validation (relatively to the protected _setOption method)
- *
- * @param string $name Name of the option
- * @param mixed $value Value of the option
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setOption($name, $value)
- {
- if (!is_string($name)) {
- Zend_Cache::throwException("Incorrect option name : $name");
- }
- $name = strtolower($name);
- if (array_key_exists($name, $this->_options)) {
- // This is a Core option
- $this->_setOption($name, $value);
- return;
- }
- if (array_key_exists($name, $this->_specificOptions)) {
- // This a specic option of this frontend
- $this->_specificOptions[$name] = $value;
- return;
- }
- }
-
- /**
- * Public frontend to get an option value
- *
- * @param string $name Name of the option
- * @throws Zend_Cache_Exception
- * @return mixed option value
- */
- public function getOption($name)
- {
- if (is_string($name)) {
- $name = strtolower($name);
- if (array_key_exists($name, $this->_options)) {
- // This is a Core option
- return $this->_options[$name];
- }
- if (array_key_exists($name, $this->_specificOptions)) {
- // This a specic option of this frontend
- return $this->_specificOptions[$name];
- }
- }
- Zend_Cache::throwException("Incorrect option name : $name");
- }
-
- /**
- * Set an option
- *
- * @param string $name Name of the option
- * @param mixed $value Value of the option
- * @throws Zend_Cache_Exception
- * @return void
- */
- private function _setOption($name, $value)
- {
- if (!is_string($name) || !array_key_exists($name, $this->_options)) {
- Zend_Cache::throwException("Incorrect option name : $name");
- }
- if ($name == 'lifetime' && empty($value)) {
- $value = null;
- }
- $this->_options[$name] = $value;
- }
-
- /**
- * Force a new lifetime
- *
- * The new value is set for the core/frontend but for the backend too (directive)
- *
- * @param int $newLifetime New lifetime (in seconds)
- * @return void
- */
- public function setLifetime($newLifetime)
- {
- $this->_options['lifetime'] = $newLifetime;
- $this->_backend->setDirectives(array(
- 'lifetime' => $newLifetime
- ));
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @param boolean $doNotUnserialize Do not serialize (even if automatic_serialization is true) => for internal use
- * @return mixed|false Cached datas
- */
- public function load($id, $doNotTestCacheValidity = false, $doNotUnserialize = false)
- {
- if (!$this->_options['caching']) {
- return false;
- }
- $id = $this->_id($id); // cache id may need prefix
- $this->_lastId = $id;
- self::_validateIdOrTag($id);
- $data = $this->_backend->load($id, $doNotTestCacheValidity);
- if ($data===false) {
- // no cache available
- return false;
- }
- if ((!$doNotUnserialize) && $this->_options['automatic_serialization']) {
- // we need to unserialize before sending the result
- return unserialize($data);
- }
- return $data;
- }
-
- /**
- * Test if a cache is available for the given id
- *
- * @param string $id Cache id
- * @return int|false Last modified time of cache entry if it is available, false otherwise
- */
- public function test($id)
- {
- if (!$this->_options['caching']) {
- return false;
- }
- $id = $this->_id($id); // cache id may need prefix
- self::_validateIdOrTag($id);
- $this->_lastId = $id;
- return $this->_backend->test($id);
- }
-
- /**
- * Save some data in a cache
- *
- * @param mixed $data Data to put in cache (can be another type than string if automatic_serialization is on)
- * @param string $id Cache id (if not set, the last cache id will be used)
- * @param array $tags Cache tags
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
- * @throws Zend_Cache_Exception
- * @return boolean True if no problem
- */
- public function save($data, $id = null, $tags = array(), $specificLifetime = false, $priority = 8)
- {
- if (!$this->_options['caching']) {
- return true;
- }
- if ($id === null) {
- $id = $this->_lastId;
- } else {
- $id = $this->_id($id);
- }
- self::_validateIdOrTag($id);
- self::_validateTagsArray($tags);
- if ($this->_options['automatic_serialization']) {
- // we need to serialize datas before storing them
- $data = serialize($data);
- } else {
- if (!is_string($data)) {
- Zend_Cache::throwException("Datas must be string or set automatic_serialization = true");
- }
- }
- // automatic cleaning
- if ($this->_options['automatic_cleaning_factor'] > 0) {
- $rand = rand(1, $this->_options['automatic_cleaning_factor']);
- if ($rand==1) {
- if ($this->_extendedBackend) {
- // New way
- if ($this->_backendCapabilities['automatic_cleaning']) {
- $this->clean(Zend_Cache::CLEANING_MODE_OLD);
- } else {
- $this->_log('Zend_Cache_Core::save() / automatic cleaning is not available/necessary with this backend');
- }
- } else {
- // Deprecated way (will be removed in next major version)
- if (method_exists($this->_backend, 'isAutomaticCleaningAvailable') && ($this->_backend->isAutomaticCleaningAvailable())) {
- $this->clean(Zend_Cache::CLEANING_MODE_OLD);
- } else {
- $this->_log('Zend_Cache_Core::save() / automatic cleaning is not available/necessary with this backend');
- }
- }
- }
- }
- if ($this->_options['ignore_user_abort']) {
- $abort = ignore_user_abort(true);
- }
- if (($this->_extendedBackend) && ($this->_backendCapabilities['priority'])) {
- $result = $this->_backend->save($data, $id, $tags, $specificLifetime, $priority);
- } else {
- $result = $this->_backend->save($data, $id, $tags, $specificLifetime);
- }
- if ($this->_options['ignore_user_abort']) {
- ignore_user_abort($abort);
- }
- if (!$result) {
- // maybe the cache is corrupted, so we remove it !
- if ($this->_options['logging']) {
- $this->_log("Zend_Cache_Core::save() : impossible to save cache (id=$id)");
- }
- $this->remove($id);
- return false;
- }
- if ($this->_options['write_control']) {
- $data2 = $this->_backend->load($id, true);
- if ($data!=$data2) {
- $this->_log('Zend_Cache_Core::save() / write_control : written and read data do not match');
- $this->_backend->remove($id);
- return false;
- }
- }
- return true;
- }
-
- /**
- * Remove a cache
- *
- * @param string $id Cache id to remove
- * @return boolean True if ok
- */
- public function remove($id)
- {
- if (!$this->_options['caching']) {
- return true;
- }
- $id = $this->_id($id); // cache id may need prefix
- self::_validateIdOrTag($id);
- return $this->_backend->remove($id);
- }
-
- /**
- * Clean cache entries
- *
- * Available modes are :
- * 'all' (default) => remove all cache entries ($tags is not used)
- * 'old' => remove too old cache entries ($tags is not used)
- * 'matchingTag' => remove cache entries matching all given tags
- * ($tags can be an array of strings or a single string)
- * 'notMatchingTag' => remove cache entries not matching one of the given tags
- * ($tags can be an array of strings or a single string)
- * 'matchingAnyTag' => remove cache entries matching any given tags
- * ($tags can be an array of strings or a single string)
- *
- * @param string $mode
- * @param array|string $tags
- * @throws Zend_Cache_Exception
- * @return boolean True if ok
- */
- public function clean($mode = 'all', $tags = array())
- {
- if (!$this->_options['caching']) {
- return true;
- }
- if (!in_array($mode, array(Zend_Cache::CLEANING_MODE_ALL,
- Zend_Cache::CLEANING_MODE_OLD,
- Zend_Cache::CLEANING_MODE_MATCHING_TAG,
- Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG,
- Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG))) {
- Zend_Cache::throwException('Invalid cleaning mode');
- }
- self::_validateTagsArray($tags);
- return $this->_backend->clean($mode, $tags);
- }
-
- /**
- * Return an array of stored cache ids which match given tags
- *
- * In case of multiple tags, a logical AND is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
- */
- public function getIdsMatchingTags($tags = array())
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- if (!($this->_backendCapabilities['tags'])) {
- Zend_Cache::throwException(self::BACKEND_NOT_SUPPORT_TAG);
- }
-
- $ids = $this->_backend->getIdsMatchingTags($tags);
-
- // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
- if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
- $prefix = & $this->_options['cache_id_prefix'];
- $prefixLen = strlen($prefix);
- foreach ($ids as &$id) {
- if (strpos($id, $prefix) === 0) {
- $id = substr($id, $prefixLen);
- }
- }
- }
-
- return $ids;
- }
-
- /**
- * Return an array of stored cache ids which don't match given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
- */
- public function getIdsNotMatchingTags($tags = array())
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- if (!($this->_backendCapabilities['tags'])) {
- Zend_Cache::throwException(self::BACKEND_NOT_SUPPORT_TAG);
- }
-
- $ids = $this->_backend->getIdsNotMatchingTags($tags);
-
- // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
- if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
- $prefix = & $this->_options['cache_id_prefix'];
- $prefixLen = strlen($prefix);
- foreach ($ids as &$id) {
- if (strpos($id, $prefix) === 0) {
- $id = substr($id, $prefixLen);
- }
- }
- }
-
- return $ids;
- }
-
- /**
- * Return an array of stored cache ids which match any given tags
- *
- * In case of multiple tags, a logical OR is made between tags
- *
- * @param array $tags array of tags
- * @return array array of matching any cache ids (string)
- */
- public function getIdsMatchingAnyTags($tags = array())
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- if (!($this->_backendCapabilities['tags'])) {
- Zend_Cache::throwException(self::BACKEND_NOT_SUPPORT_TAG);
- }
-
- $ids = $this->_backend->getIdsMatchingAnyTags($tags);
-
- // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
- if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
- $prefix = & $this->_options['cache_id_prefix'];
- $prefixLen = strlen($prefix);
- foreach ($ids as &$id) {
- if (strpos($id, $prefix) === 0) {
- $id = substr($id, $prefixLen);
- }
- }
- }
-
- return $ids;
- }
-
- /**
- * Return an array of stored cache ids
- *
- * @return array array of stored cache ids (string)
- */
- public function getIds()
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
-
- $ids = $this->_backend->getIds();
-
- // we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
- if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
- $prefix = & $this->_options['cache_id_prefix'];
- $prefixLen = strlen($prefix);
- foreach ($ids as &$id) {
- if (strpos($id, $prefix) === 0) {
- $id = substr($id, $prefixLen);
- }
- }
- }
-
- return $ids;
- }
-
- /**
- * Return an array of stored tags
- *
- * @return array array of stored tags (string)
- */
- public function getTags()
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- if (!($this->_backendCapabilities['tags'])) {
- Zend_Cache::throwException(self::BACKEND_NOT_SUPPORT_TAG);
- }
- return $this->_backend->getTags();
- }
-
- /**
- * Return the filling percentage of the backend storage
- *
- * @return int integer between 0 and 100
- */
- public function getFillingPercentage()
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- return $this->_backend->getFillingPercentage();
- }
-
- /**
- * Return an array of metadatas for the given cache id
- *
- * The array will include these keys :
- * - expire : the expire timestamp
- * - tags : a string array of tags
- * - mtime : timestamp of last modification time
- *
- * @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
- */
- public function getMetadatas($id)
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- $id = $this->_id($id); // cache id may need prefix
- return $this->_backend->getMetadatas($id);
- }
-
- /**
- * Give (if possible) an extra lifetime to the given cache id
- *
- * @param string $id cache id
- * @param int $extraLifetime
- * @return boolean true if ok
- */
- public function touch($id, $extraLifetime)
- {
- if (!$this->_extendedBackend) {
- Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
- }
- $id = $this->_id($id); // cache id may need prefix
- return $this->_backend->touch($id, $extraLifetime);
- }
-
- /**
- * Validate a cache id or a tag (security, reliable filenames, reserved prefixes...)
- *
- * Throw an exception if a problem is found
- *
- * @param string $string Cache id or tag
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected static function _validateIdOrTag($string)
- {
- if (!is_string($string)) {
- Zend_Cache::throwException('Invalid id or tag : must be a string');
- }
- if (substr($string, 0, 9) == 'internal-') {
- Zend_Cache::throwException('"internal-*" ids or tags are reserved');
- }
- if (!preg_match('~^[a-zA-Z0-9_]+$~D', $string)) {
- Zend_Cache::throwException("Invalid id or tag '$string' : must use only [a-zA-Z0-9_]");
- }
- }
-
- /**
- * Validate a tags array (security, reliable filenames, reserved prefixes...)
- *
- * Throw an exception if a problem is found
- *
- * @param array $tags Array of tags
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected static function _validateTagsArray($tags)
- {
- if (!is_array($tags)) {
- Zend_Cache::throwException('Invalid tags array : must be an array');
- }
- foreach($tags as $tag) {
- self::_validateIdOrTag($tag);
- }
- reset($tags);
- }
-
- /**
- * Make sure if we enable logging that the Zend_Log class
- * is available.
- * Create a default log object if none is set.
- *
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected function _loggerSanity()
- {
- if (!isset($this->_options['logging']) || !$this->_options['logging']) {
- return;
- }
-
- if (isset($this->_options['logger']) && $this->_options['logger'] instanceof Zend_Log) {
- return;
- }
-
- // Create a default logger to the standard output stream
- require_once 'Zend/Log/Writer/Stream.php';
- $logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output'));
- $this->_options['logger'] = $logger;
- }
-
- /**
- * Log a message at the WARN (4) priority.
- *
- * @param string $message
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected function _log($message, $priority = 4)
- {
- if (!$this->_options['logging']) {
- return;
- }
- if (!(isset($this->_options['logger']) || $this->_options['logger'] instanceof Zend_Log)) {
- Zend_Cache::throwException('Logging is enabled but logger is not set');
- }
- $logger = $this->_options['logger'];
- $logger->log($message, $priority);
- }
-
- /**
- * Make and return a cache id
- *
- * Checks 'cache_id_prefix' and returns new id with prefix or simply the id if null
- *
- * @param string $id Cache id
- * @return string Cache id (with or without prefix)
- */
- protected function _id($id)
- {
- if (($id !== null) && isset($this->_options['cache_id_prefix'])) {
- return $this->_options['cache_id_prefix'] . $id; // return with prefix
- }
- return $id; // no prefix, just return the $id passed
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Exception/BadMethodCallException.php zendframework-2.2.6/library/Zend/Cache/Exception/BadMethodCallException.php
--- zendframework-1.10.4/library/Zend/Cache/Exception/BadMethodCallException.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Exception/BadMethodCallException.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,15 @@
+_tags = $tags;
- $this->_extension = $extension;
- ob_start(array($this, '_flush'));
- ob_implicit_flush(false);
- $this->_idStack[] = $id;
- return false;
- }
-
- /**
- * callback for output buffering
- * (shouldn't really be called manually)
- *
- * @param string $data Buffered output
- * @return string Data to send to browser
- */
- public function _flush($data)
- {
- $id = array_pop($this->_idStack);
- if (is_null($id)) {
- Zend_Cache::throwException('use of _flush() without a start()');
- }
- if ($this->_extension) {
- $this->save(serialize(array($data, $this->_extension)), $id, $this->_tags);
- } else {
- $this->save($data, $id, $this->_tags);
- }
- return $data;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Frontend/Class.php zendframework-2.2.6/library/Zend/Cache/Frontend/Class.php
--- zendframework-1.10.4/library/Zend/Cache/Frontend/Class.php 2010-01-18 14:40:57.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Frontend/Class.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,244 +0,0 @@
- (mixed) cached_entity :
- * - if set to a class name, we will cache an abstract class and will use only static calls
- * - if set to an object, we will cache this object methods
- *
- * ====> (boolean) cache_by_default :
- * - if true, method calls will be cached by default
- *
- * ====> (array) cached_methods :
- * - an array of method names which will be cached (even if cache_by_default = false)
- *
- * ====> (array) non_cached_methods :
- * - an array of method names which won't be cached (even if cache_by_default = true)
- *
- * @var array available options
- */
- protected $_specificOptions = array(
- 'cached_entity' => null,
- 'cache_by_default' => true,
- 'cached_methods' => array(),
- 'non_cached_methods' => array()
- );
-
- /**
- * Tags array
- *
- * @var array
- */
- private $_tags = array();
-
- /**
- * SpecificLifetime value
- *
- * false => no specific life time
- *
- * @var int
- */
- private $_specificLifetime = false;
-
- /**
- * The cached object or the name of the cached abstract class
- *
- * @var mixed
- */
- private $_cachedEntity = null;
-
- /**
- * The class name of the cached object or cached abstract class
- *
- * Used to differentiate between different classes with the same method calls.
- *
- * @var string
- */
- private $_cachedEntityLabel = '';
-
- /**
- * Priority (used by some particular backends)
- *
- * @var int
- */
- private $_priority = 8;
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- while (list($name, $value) = each($options)) {
- $this->setOption($name, $value);
- }
- if ($this->_specificOptions['cached_entity'] === null) {
- Zend_Cache::throwException('cached_entity must be set !');
- }
- $this->setCachedEntity($this->_specificOptions['cached_entity']);
- $this->setOption('automatic_serialization', true);
- }
-
- /**
- * Set a specific life time
- *
- * @param int $specificLifetime
- * @return void
- */
- public function setSpecificLifetime($specificLifetime = false)
- {
- $this->_specificLifetime = $specificLifetime;
- }
-
- /**
- * Set the priority (used by some particular backends)
- *
- * @param int $priority integer between 0 (very low priority) and 10 (maximum priority)
- */
- public function setPriority($priority)
- {
- $this->_priority = $priority;
- }
-
- /**
- * Public frontend to set an option
- *
- * Just a wrapper to get a specific behaviour for cached_entity
- *
- * @param string $name Name of the option
- * @param mixed $value Value of the option
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setOption($name, $value)
- {
- if ($name == 'cached_entity') {
- $this->setCachedEntity($value);
- } else {
- parent::setOption($name, $value);
- }
- }
-
- /**
- * Specific method to set the cachedEntity
- *
- * if set to a class name, we will cache an abstract class and will use only static calls
- * if set to an object, we will cache this object methods
- *
- * @param mixed $cachedEntity
- */
- public function setCachedEntity($cachedEntity)
- {
- if (!is_string($cachedEntity) && !is_object($cachedEntity)) {
- Zend_Cache::throwException('cached_entity must be an object or a class name');
- }
- $this->_cachedEntity = $cachedEntity;
- $this->_specificOptions['cached_entity'] = $cachedEntity;
- if (is_string($this->_cachedEntity)){
- $this->_cachedEntityLabel = $this->_cachedEntity;
- } else {
- $ro = new ReflectionObject($this->_cachedEntity);
- $this->_cachedEntityLabel = $ro->getName();
- }
- }
-
- /**
- * Set the cache array
- *
- * @param array $tags
- * @return void
- */
- public function setTagsArray($tags = array())
- {
- $this->_tags = $tags;
- }
-
- /**
- * Main method : call the specified method or get the result from cache
- *
- * @param string $name Method name
- * @param array $parameters Method parameters
- * @return mixed Result
- */
- public function __call($name, $parameters)
- {
- $cacheBool1 = $this->_specificOptions['cache_by_default'];
- $cacheBool2 = in_array($name, $this->_specificOptions['cached_methods']);
- $cacheBool3 = in_array($name, $this->_specificOptions['non_cached_methods']);
- $cache = (($cacheBool1 || $cacheBool2) && (!$cacheBool3));
- if (!$cache) {
- // We do not have not cache
- return call_user_func_array(array($this->_cachedEntity, $name), $parameters);
- }
-
- $id = $this->_makeId($name, $parameters);
- if ( ($rs = $this->load($id)) && isset($rs[0], $rs[1]) ) {
- // A cache is available
- $output = $rs[0];
- $return = $rs[1];
- } else {
- // A cache is not available (or not valid for this frontend)
- ob_start();
- ob_implicit_flush(false);
- $return = call_user_func_array(array($this->_cachedEntity, $name), $parameters);
- $output = ob_get_contents();
- ob_end_clean();
- $data = array($output, $return);
- $this->save($data, $id, $this->_tags, $this->_specificLifetime, $this->_priority);
- }
-
- echo $output;
- return $return;
- }
-
- /**
- * Make a cache id from the method name and parameters
- *
- * @param string $name Method name
- * @param array $parameters Method parameters
- * @return string Cache id
- */
- private function _makeId($name, $parameters)
- {
- return md5($this->_cachedEntityLabel . '__' . $name . '__' . serialize($parameters));
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Frontend/File.php zendframework-2.2.6/library/Zend/Cache/Frontend/File.php
--- zendframework-1.10.4/library/Zend/Cache/Frontend/File.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Frontend/File.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,209 +0,0 @@
- (string) master_file :
- * - a complete path of the master file
- * - deprecated (see master_files)
- *
- * ====> (array) master_files :
- * - an array of complete path of master files
- * - this option has to be set !
- *
- * ====> (string) master_files_mode :
- * - Zend_Cache_Frontend_File::MODE_AND or Zend_Cache_Frontend_File::MODE_OR
- * - if MODE_AND, then all master files have to be touched to get a cache invalidation
- * - if MODE_OR (default), then a single touched master file is enough to get a cache invalidation
- *
- * ====> (boolean) ignore_missing_master_files
- * - if set to true, missing master files are ignored silently
- * - if set to false (default), an exception is thrown if there is a missing master file
- * @var array available options
- */
- protected $_specificOptions = array(
- 'master_file' => null,
- 'master_files' => null,
- 'master_files_mode' => 'OR',
- 'ignore_missing_master_files' => false
- );
-
- /**
- * Master file mtimes
- *
- * Array of int
- *
- * @var array
- */
- private $_masterFile_mtimes = null;
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- while (list($name, $value) = each($options)) {
- $this->setOption($name, $value);
- }
- if (!isset($this->_specificOptions['master_files'])) {
- Zend_Cache::throwException('master_files option must be set');
- }
- }
-
- /**
- * Change the master_file option
- *
- * @param string $masterFile the complete path and name of the master file
- */
- public function setMasterFiles($masterFiles)
- {
- clearstatcache();
- $this->_specificOptions['master_file'] = $masterFiles[0]; // to keep a compatibility
- $this->_specificOptions['master_files'] = $masterFiles;
- $this->_masterFile_mtimes = array();
- $i = 0;
- foreach ($masterFiles as $masterFile) {
- $this->_masterFile_mtimes[$i] = @filemtime($masterFile);
- if ((!($this->_specificOptions['ignore_missing_master_files'])) && (!($this->_masterFile_mtimes[$i]))) {
- Zend_Cache::throwException('Unable to read master_file : '.$masterFile);
- }
- $i++;
- }
- }
-
- /**
- * Change the master_file option
- *
- * To keep the compatibility
- *
- * @deprecated
- * @param string $masterFile the complete path and name of the master file
- */
- public function setMasterFile($masterFile)
- {
- $this->setMasterFiles(array(0 => $masterFile));
- }
-
- /**
- * Public frontend to set an option
- *
- * Just a wrapper to get a specific behaviour for master_file
- *
- * @param string $name Name of the option
- * @param mixed $value Value of the option
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function setOption($name, $value)
- {
- if ($name == 'master_file') {
- $this->setMasterFile($value);
- } else if ($name == 'master_files') {
- $this->setMasterFiles($value);
- } else {
- parent::setOption($name, $value);
- }
- }
-
- /**
- * Test if a cache is available for the given id and (if yes) return it (false else)
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @param boolean $doNotUnserialize Do not serialize (even if automatic_serialization is true) => for internal use
- * @return mixed|false Cached datas
- */
- public function load($id, $doNotTestCacheValidity = false, $doNotUnserialize = false)
- {
- if (!$doNotTestCacheValidity) {
- if ($this->test($id)) {
- return parent::load($id, true, $doNotUnserialize);
- }
- return false;
- }
- return parent::load($id, true, $doNotUnserialize);
- }
-
- /**
- * Test if a cache is available for the given id
- *
- * @param string $id Cache id
- * @return int|false Last modified time of cache entry if it is available, false otherwise
- */
- public function test($id)
- {
- $lastModified = parent::test($id);
- if ($lastModified) {
- if ($this->_specificOptions['master_files_mode'] == self::MODE_AND) {
- // MODE_AND
- foreach($this->_masterFile_mtimes as $masterFileMTime) {
- if ($masterFileMTime) {
- if ($lastModified > $masterFileMTime) {
- return $lastModified;
- }
- }
- }
- } else {
- // MODE_OR
- $res = true;
- foreach($this->_masterFile_mtimes as $masterFileMTime) {
- if ($masterFileMTime) {
- if ($lastModified <= $masterFileMTime) {
- return false;
- }
- }
- }
- return $lastModified;
- }
- }
- return false;
- }
-
-}
-
diff -Nru zendframework-1.10.4/library/Zend/Cache/Frontend/Function.php zendframework-2.2.6/library/Zend/Cache/Frontend/Function.php
--- zendframework-1.10.4/library/Zend/Cache/Frontend/Function.php 2010-01-18 14:40:57.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Frontend/Function.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,132 +0,0 @@
- (boolean) cache_by_default :
- * - if true, function calls will be cached by default
- *
- * ====> (array) cached_functions :
- * - an array of function names which will be cached (even if cache_by_default = false)
- *
- * ====> (array) non_cached_functions :
- * - an array of function names which won't be cached (even if cache_by_default = true)
- *
- * @var array options
- */
- protected $_specificOptions = array(
- 'cache_by_default' => true,
- 'cached_functions' => array(),
- 'non_cached_functions' => array()
- );
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- * @return void
- */
- public function __construct(array $options = array())
- {
- while (list($name, $value) = each($options)) {
- $this->setOption($name, $value);
- }
- $this->setOption('automatic_serialization', true);
- }
-
- /**
- * Main method : call the specified function or get the result from cache
- *
- * @param string $name Function name
- * @param array $parameters Function parameters
- * @param array $tags Cache tags
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
- * @return mixed Result
- */
- public function call($name, $parameters = array(), $tags = array(), $specificLifetime = false, $priority = 8)
- {
- $cacheBool1 = $this->_specificOptions['cache_by_default'];
- $cacheBool2 = in_array($name, $this->_specificOptions['cached_functions']);
- $cacheBool3 = in_array($name, $this->_specificOptions['non_cached_functions']);
- $cache = (($cacheBool1 || $cacheBool2) && (!$cacheBool3));
- if (!$cache) {
- // We do not have not cache
- return call_user_func_array($name, $parameters);
- }
-
- $id = $this->_makeId($name, $parameters);
- if ( ($rs = $this->load($id)) && isset($rs[0], $rs[1])) {
- // A cache is available
- $output = $rs[0];
- $return = $rs[1];
- } else {
- // A cache is not available (or not valid for this frontend)
- ob_start();
- ob_implicit_flush(false);
- $return = call_user_func_array($name, $parameters);
- $output = ob_get_contents();
- ob_end_clean();
- $data = array($output, $return);
- $this->save($data, $id, $tags, $specificLifetime, $priority);
- }
-
- echo $output;
- return $return;
- }
-
- /**
- * Make a cache id from the function name and parameters
- *
- * @param string $name Function name
- * @param array $parameters Function parameters
- * @throws Zend_Cache_Exception
- * @return string Cache id
- */
- private function _makeId($name, $parameters)
- {
- if (!is_string($name)) {
- Zend_Cache::throwException('Incorrect function name');
- }
- if (!is_array($parameters)) {
- Zend_Cache::throwException('parameters argument must be an array');
- }
- return md5($name . serialize($parameters));
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Frontend/Output.php zendframework-2.2.6/library/Zend/Cache/Frontend/Output.php
--- zendframework-1.10.4/library/Zend/Cache/Frontend/Output.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Frontend/Output.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,106 +0,0 @@
-_idStack = array();
- }
-
- /**
- * Start the cache
- *
- * @param string $id Cache id
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @param boolean $echoData If set to true, datas are sent to the browser if the cache is hit (simpy returned else)
- * @return mixed True if the cache is hit (false else) with $echoData=true (default) ; string else (datas)
- */
- public function start($id, $doNotTestCacheValidity = false, $echoData = true)
- {
- $data = $this->load($id, $doNotTestCacheValidity);
- if ($data !== false) {
- if ( $echoData ) {
- echo($data);
- return true;
- } else {
- return $data;
- }
- }
- ob_start();
- ob_implicit_flush(false);
- $this->_idStack[] = $id;
- return false;
- }
-
- /**
- * Stop the cache
- *
- * @param array $tags Tags array
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @param string $forcedDatas If not null, force written datas with this
- * @param boolean $echoData If set to true, datas are sent to the browser
- * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
- * @return void
- */
- public function end($tags = array(), $specificLifetime = false, $forcedDatas = null, $echoData = true, $priority = 8)
- {
- if ($forcedDatas === null) {
- $data = ob_get_contents();
- ob_end_clean();
- } else {
- $data =& $forcedDatas;
- }
- $id = array_pop($this->_idStack);
- if ($id === null) {
- Zend_Cache::throwException('use of end() without a start()');
- }
- $this->save($data, $id, $tags, $specificLifetime, $priority);
- if ($echoData) {
- echo($data);
- }
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Frontend/Page.php zendframework-2.2.6/library/Zend/Cache/Frontend/Page.php
--- zendframework-1.10.4/library/Zend/Cache/Frontend/Page.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Frontend/Page.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,402 +0,0 @@
- (boolean) http_conditional :
- * - if true, http conditional mode is on
- * WARNING : http_conditional OPTION IS NOT IMPLEMENTED FOR THE MOMENT (TODO)
- *
- * ====> (boolean) debug_header :
- * - if true, a debug text is added before each cached pages
- *
- * ====> (boolean) content_type_memorization :
- * - deprecated => use memorize_headers instead
- * - if the Content-Type header is sent after the cache was started, the
- * corresponding value can be memorized and replayed when the cache is hit
- * (if false (default), the frontend doesn't take care of Content-Type header)
- *
- * ====> (array) memorize_headers :
- * - an array of strings corresponding to some HTTP headers name. Listed headers
- * will be stored with cache datas and "replayed" when the cache is hit
- *
- * ====> (array) default_options :
- * - an associative array of default options :
- * - (boolean) cache : cache is on by default if true
- * - (boolean) cacheWithXXXVariables (XXXX = 'Get', 'Post', 'Session', 'Files' or 'Cookie') :
- * if true, cache is still on even if there are some variables in this superglobal array
- * if false, cache is off if there are some variables in this superglobal array
- * - (boolean) makeIdWithXXXVariables (XXXX = 'Get', 'Post', 'Session', 'Files' or 'Cookie') :
- * if true, we have to use the content of this superglobal array to make a cache id
- * if false, the cache id won't be dependent of the content of this superglobal array
- * - (int) specific_lifetime : cache specific lifetime
- * (false => global lifetime is used, null => infinite lifetime,
- * integer => this lifetime is used), this "lifetime" is probably only
- * usefull when used with "regexps" array
- * - (array) tags : array of tags (strings)
- * - (int) priority : integer between 0 (very low priority) and 10 (maximum priority) used by
- * some particular backends
- *
- * ====> (array) regexps :
- * - an associative array to set options only for some REQUEST_URI
- * - keys are (pcre) regexps
- * - values are associative array with specific options to set if the regexp matchs on $_SERVER['REQUEST_URI']
- * (see default_options for the list of available options)
- * - if several regexps match the $_SERVER['REQUEST_URI'], only the last one will be used
- *
- * @var array options
- */
- protected $_specificOptions = array(
- 'http_conditional' => false,
- 'debug_header' => false,
- 'content_type_memorization' => false,
- 'memorize_headers' => array(),
- 'default_options' => array(
- 'cache_with_get_variables' => false,
- 'cache_with_post_variables' => false,
- 'cache_with_session_variables' => false,
- 'cache_with_files_variables' => false,
- 'cache_with_cookie_variables' => false,
- 'make_id_with_get_variables' => true,
- 'make_id_with_post_variables' => true,
- 'make_id_with_session_variables' => true,
- 'make_id_with_files_variables' => true,
- 'make_id_with_cookie_variables' => true,
- 'cache' => true,
- 'specific_lifetime' => false,
- 'tags' => array(),
- 'priority' => null
- ),
- 'regexps' => array()
- );
-
- /**
- * Internal array to store some options
- *
- * @var array associative array of options
- */
- protected $_activeOptions = array();
-
- /**
- * If true, the page won't be cached
- *
- * @var boolean
- */
- protected $_cancel = false;
-
- /**
- * Constructor
- *
- * @param array $options Associative array of options
- * @param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
- * @throws Zend_Cache_Exception
- * @return void
- */
- public function __construct(array $options = array())
- {
- while (list($name, $value) = each($options)) {
- $name = strtolower($name);
- switch ($name) {
- case 'regexps':
- $this->_setRegexps($value);
- break;
- case 'default_options':
- $this->_setDefaultOptions($value);
- break;
- case 'content_type_memorization':
- $this->_setContentTypeMemorization($value);
- break;
- default:
- $this->setOption($name, $value);
- }
- }
- if (isset($this->_specificOptions['http_conditional'])) {
- if ($this->_specificOptions['http_conditional']) {
- Zend_Cache::throwException('http_conditional is not implemented for the moment !');
- }
- }
- $this->setOption('automatic_serialization', true);
- }
-
- /**
- * Specific setter for the 'default_options' option (with some additional tests)
- *
- * @param array $options Associative array
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected function _setDefaultOptions($options)
- {
- if (!is_array($options)) {
- Zend_Cache::throwException('default_options must be an array !');
- }
- foreach ($options as $key=>$value) {
- if (!is_string($key)) {
- Zend_Cache::throwException("invalid option [$key] !");
- }
- $key = strtolower($key);
- if (isset($this->_specificOptions['default_options'][$key])) {
- $this->_specificOptions['default_options'][$key] = $value;
- }
- }
- }
-
- /**
- * Set the deprecated contentTypeMemorization option
- *
- * @param boolean $value value
- * @return void
- * @deprecated
- */
- protected function _setContentTypeMemorization($value)
- {
- $found = null;
- foreach ($this->_specificOptions['memorize_headers'] as $key => $value) {
- if (strtolower($value) == 'content-type') {
- $found = $key;
- }
- }
- if ($value) {
- if (!$found) {
- $this->_specificOptions['memorize_headers'][] = 'Content-Type';
- }
- } else {
- if ($found) {
- unset($this->_specificOptions['memorize_headers'][$found]);
- }
- }
- }
-
- /**
- * Specific setter for the 'regexps' option (with some additional tests)
- *
- * @param array $options Associative array
- * @throws Zend_Cache_Exception
- * @return void
- */
- protected function _setRegexps($regexps)
- {
- if (!is_array($regexps)) {
- Zend_Cache::throwException('regexps option must be an array !');
- }
- foreach ($regexps as $regexp=>$conf) {
- if (!is_array($conf)) {
- Zend_Cache::throwException('regexps option must be an array of arrays !');
- }
- $validKeys = array_keys($this->_specificOptions['default_options']);
- foreach ($conf as $key=>$value) {
- if (!is_string($key)) {
- Zend_Cache::throwException("unknown option [$key] !");
- }
- $key = strtolower($key);
- if (!in_array($key, $validKeys)) {
- unset($regexps[$regexp][$key]);
- }
- }
- }
- $this->setOption('regexps', $regexps);
- }
-
- /**
- * Start the cache
- *
- * @param string $id (optional) A cache id (if you set a value here, maybe you have to use Output frontend instead)
- * @param boolean $doNotDie For unit testing only !
- * @return boolean True if the cache is hit (false else)
- */
- public function start($id = false, $doNotDie = false)
- {
- $this->_cancel = false;
- $lastMatchingRegexp = null;
- foreach ($this->_specificOptions['regexps'] as $regexp => $conf) {
- if (preg_match("`$regexp`", $_SERVER['REQUEST_URI'])) {
- $lastMatchingRegexp = $regexp;
- }
- }
- $this->_activeOptions = $this->_specificOptions['default_options'];
- if ($lastMatchingRegexp !== null) {
- $conf = $this->_specificOptions['regexps'][$lastMatchingRegexp];
- foreach ($conf as $key=>$value) {
- $this->_activeOptions[$key] = $value;
- }
- }
- if (!($this->_activeOptions['cache'])) {
- return false;
- }
- if (!$id) {
- $id = $this->_makeId();
- if (!$id) {
- return false;
- }
- }
- $array = $this->load($id);
- if ($array !== false) {
- $data = $array['data'];
- $headers = $array['headers'];
- if (!headers_sent()) {
- foreach ($headers as $key=>$headerCouple) {
- $name = $headerCouple[0];
- $value = $headerCouple[1];
- header("$name: $value");
- }
- }
- if ($this->_specificOptions['debug_header']) {
- echo 'DEBUG HEADER : This is a cached page !';
- }
- echo $data;
- if ($doNotDie) {
- return true;
- }
- die();
- }
- ob_start(array($this, '_flush'));
- ob_implicit_flush(false);
- return false;
- }
-
- /**
- * Cancel the current caching process
- */
- public function cancel()
- {
- $this->_cancel = true;
- }
-
- /**
- * callback for output buffering
- * (shouldn't really be called manually)
- *
- * @param string $data Buffered output
- * @return string Data to send to browser
- */
- public function _flush($data)
- {
- if ($this->_cancel) {
- return $data;
- }
- $contentType = null;
- $storedHeaders = array();
- $headersList = headers_list();
- foreach($this->_specificOptions['memorize_headers'] as $key=>$headerName) {
- foreach ($headersList as $headerSent) {
- $tmp = explode(':', $headerSent);
- $headerSentName = trim(array_shift($tmp));
- if (strtolower($headerName) == strtolower($headerSentName)) {
- $headerSentValue = trim(implode(':', $tmp));
- $storedHeaders[] = array($headerSentName, $headerSentValue);
- }
- }
- }
- $array = array(
- 'data' => $data,
- 'headers' => $storedHeaders
- );
- $this->save($array, null, $this->_activeOptions['tags'], $this->_activeOptions['specific_lifetime'], $this->_activeOptions['priority']);
- return $data;
- }
-
- /**
- * Make an id depending on REQUEST_URI and superglobal arrays (depending on options)
- *
- * @return mixed|false a cache id (string), false if the cache should have not to be used
- */
- protected function _makeId()
- {
- $tmp = $_SERVER['REQUEST_URI'];
- $array = explode('?', $tmp, 2);
- $tmp = $array[0];
- foreach (array('Get', 'Post', 'Session', 'Files', 'Cookie') as $arrayName) {
- $tmp2 = $this->_makePartialId($arrayName, $this->_activeOptions['cache_with_' . strtolower($arrayName) . '_variables'], $this->_activeOptions['make_id_with_' . strtolower($arrayName) . '_variables']);
- if ($tmp2===false) {
- return false;
- }
- $tmp = $tmp . $tmp2;
- }
- return md5($tmp);
- }
-
- /**
- * Make a partial id depending on options
- *
- * @param string $arrayName Superglobal array name
- * @param bool $bool1 If true, cache is still on even if there are some variables in the superglobal array
- * @param bool $bool2 If true, we have to use the content of the superglobal array to make a partial id
- * @return mixed|false Partial id (string) or false if the cache should have not to be used
- */
- protected function _makePartialId($arrayName, $bool1, $bool2)
- {
- switch ($arrayName) {
- case 'Get':
- $var = $_GET;
- break;
- case 'Post':
- $var = $_POST;
- break;
- case 'Session':
- if (isset($_SESSION)) {
- $var = $_SESSION;
- } else {
- $var = null;
- }
- break;
- case 'Cookie':
- if (isset($_COOKIE)) {
- $var = $_COOKIE;
- } else {
- $var = null;
- }
- break;
- case 'Files':
- $var = $_FILES;
- break;
- default:
- return false;
- }
- if ($bool1) {
- if ($bool2) {
- return serialize($var);
- }
- return '';
- }
- if (count($var) > 0) {
- return false;
- }
- return '';
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Manager.php zendframework-2.2.6/library/Zend/Cache/Manager.php
--- zendframework-1.10.4/library/Zend/Cache/Manager.php 2010-04-23 19:36:44.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Manager.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,286 +0,0 @@
- array(
- 'frontend' => array(
- 'name' => null,
- 'options' => array(),
- ),
- 'backend' => array(
- 'name' => null,
- 'options' => array(),
- ),
- ),
- // Simple Common Default
- 'default' => array(
- 'frontend' => array(
- 'name' => 'Core',
- 'options' => array(
- 'automatic_serialization' => true,
- ),
- ),
- 'backend' => array(
- 'name' => 'File',
- 'options' => array(
- 'cache_dir' => '../cache',
- ),
- ),
- ),
- // Static Page HTML Cache
- 'page' => array(
- 'frontend' => array(
- 'name' => 'Capture',
- 'options' => array(
- 'ignore_user_abort' => true,
- ),
- ),
- 'backend' => array(
- 'name' => 'Static',
- 'options' => array(
- 'public_dir' => '../public',
- ),
- ),
- ),
- // Tag Cache
- 'pagetag' => array(
- 'frontend' => array(
- 'name' => 'Core',
- 'options' => array(
- 'automatic_serialization' => true,
- 'lifetime' => null
- ),
- ),
- 'backend' => array(
- 'name' => 'File',
- 'options' => array(
- 'cache_dir' => '../cache',
- 'cache_file_umask' => 0644
- ),
- ),
- ),
- );
-
- /**
- * Set a new cache for the Cache Manager to contain
- *
- * @param string $name
- * @param Zend_Cache_Core $cache
- * @return Zend_Cache_Manager
- */
- public function setCache($name, Zend_Cache_Core $cache)
- {
- $this->_caches[$name] = $cache;
- return $this;
- }
-
- /**
- * Check if the Cache Manager contains the named cache object, or a named
- * configuration template to lazy load the cache object
- *
- * @param string $name
- * @return bool
- */
- public function hasCache($name)
- {
- if (isset($this->_caches[$name])
- || $this->hasCacheTemplate($name)
- ) {
- return true;
- }
- return false;
- }
-
- /**
- * Fetch the named cache object, or instantiate and return a cache object
- * using a named configuration template
- *
- * @param string $name
- * @return Zend_Cache_Core
- */
- public function getCache($name)
- {
- if (isset($this->_caches[$name])) {
- return $this->_caches[$name];
- }
- if (isset($this->_optionTemplates[$name])) {
- if ($name == self::PAGECACHE
- && (!isset($this->_optionTemplates[$name]['backend']['options']['tag_cache'])
- || !$this->_optionTemplates[$name]['backend']['options']['tag_cache'] instanceof Zend_Cache_Core)
- ) {
- $this->_optionTemplates[$name]['backend']['options']['tag_cache']
- = $this->getCache(self::PAGETAGCACHE );
- }
- $this->_caches[$name] = Zend_Cache::factory(
- $this->_optionTemplates[$name]['frontend']['name'],
- $this->_optionTemplates[$name]['backend']['name'],
- isset($this->_optionTemplates[$name]['frontend']['options']) ? $this->_optionTemplates[$name]['frontend']['options'] : array(),
- isset($this->_optionTemplates[$name]['backend']['options']) ? $this->_optionTemplates[$name]['backend']['options'] : array(),
- isset($this->_optionTemplates[$name]['frontend']['customFrontendNaming']) ? $this->_optionTemplates[$name]['frontend']['customFrontendNaming'] : false,
- isset($this->_optionTemplates[$name]['backend']['customBackendNaming']) ? $this->_optionTemplates[$name]['backend']['customBackendNaming'] : false,
- isset($this->_optionTemplates[$name]['frontendBackendAutoload']) ? $this->_optionTemplates[$name]['frontendBackendAutoload'] : false
- );
- return $this->_caches[$name];
- }
- }
-
- /**
- * Set a named configuration template from which a cache object can later
- * be lazy loaded
- *
- * @param string $name
- * @param array $options
- * @return Zend_Cache_Manager
- */
- public function setCacheTemplate($name, $options)
- {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- } elseif (!is_array($options)) {
- require_once 'Zend/Cache/Exception.php';
- throw new Zend_Cache_Exception('Options passed must be in'
- . ' an associative array or instance of Zend_Config');
- }
- $this->_optionTemplates[$name] = $options;
- return $this;
- }
-
- /**
- * Check if the named configuration template
- *
- * @param string $name
- * @return bool
- */
- public function hasCacheTemplate($name)
- {
- if (isset($this->_optionTemplates[$name])) {
- return true;
- }
- return false;
- }
-
- /**
- * Get the named configuration template
- *
- * @param string $name
- * @return array
- */
- public function getCacheTemplate($name)
- {
- if (isset($this->_optionTemplates[$name])) {
- return $this->_optionTemplates[$name];
- }
- }
-
- /**
- * Pass an array containing changes to be applied to a named
- * configuration
- * template
- *
- * @param string $name
- * @param array $options
- * @return Zend_Cache_Manager
- * @throws Zend_Cache_Exception for invalid options format or if option templates do not have $name
- */
- public function setTemplateOptions($name, $options)
- {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- } elseif (!is_array($options)) {
- require_once 'Zend/Cache/Exception.php';
- throw new Zend_Cache_Exception('Options passed must be in'
- . ' an associative array or instance of Zend_Config');
- }
- if (!isset($this->_optionTemplates[$name])) {
- throw new Zend_Cache_Exception('A cache configuration template'
- . 'does not exist with the name "' . $name . '"');
- }
- $this->_optionTemplates[$name]
- = $this->_mergeOptions($this->_optionTemplates[$name], $options);
- return $this;
- }
-
- /**
- * Simple method to merge two configuration arrays
- *
- * @param array $current
- * @param array $options
- * @return array
- */
- protected function _mergeOptions(array $current, array $options)
- {
- if (isset($options['frontend']['name'])) {
- $current['frontend']['name'] = $options['frontend']['name'];
- }
- if (isset($options['backend']['name'])) {
- $current['backend']['name'] = $options['backend']['name'];
- }
- if (isset($options['frontend']['options'])) {
- foreach ($options['frontend']['options'] as $key=>$value) {
- $current['frontend']['options'][$key] = $value;
- }
- }
- if (isset($options['backend']['options'])) {
- foreach ($options['backend']['options'] as $key=>$value) {
- $current['backend']['options'][$key] = $value;
- }
- }
- return $current;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Pattern/AbstractPattern.php zendframework-2.2.6/library/Zend/Cache/Pattern/AbstractPattern.php
--- zendframework-1.10.4/library/Zend/Cache/Pattern/AbstractPattern.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Pattern/AbstractPattern.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,51 @@
+options = $options;
+ return $this;
+ }
+
+ /**
+ * Get all pattern options
+ *
+ * @return PatternOptions
+ */
+ public function getOptions()
+ {
+ if (null === $this->options) {
+ $this->setOptions(new PatternOptions());
+ }
+ return $this->options;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Pattern/CallbackCache.php zendframework-2.2.6/library/Zend/Cache/Pattern/CallbackCache.php
--- zendframework-1.10.4/library/Zend/Cache/Pattern/CallbackCache.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Pattern/CallbackCache.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,202 @@
+getStorage()) {
+ throw new Exception\InvalidArgumentException("Missing option 'storage'");
+ }
+ return $this;
+ }
+
+ /**
+ * Call the specified callback or get the result from cache
+ *
+ * @param callable $callback A valid callback
+ * @param array $args Callback arguments
+ * @return mixed Result
+ * @throws Exception\RuntimeException if invalid cached data
+ * @throws \Exception
+ */
+ public function call($callback, array $args = array())
+ {
+ $options = $this->getOptions();
+ $storage = $options->getStorage();
+ $success = null;
+ $key = $this->generateCallbackKey($callback, $args);
+ $result = $storage->getItem($key, $success);
+ if ($success) {
+ if (!array_key_exists(0, $result)) {
+ throw new Exception\RuntimeException("Invalid cached data for key '{$key}'");
+ }
+
+ echo isset($result[1]) ? $result[1] : '';
+ return $result[0];
+ }
+
+ $cacheOutput = $options->getCacheOutput();
+ if ($cacheOutput) {
+ ob_start();
+ ob_implicit_flush(false);
+ }
+
+ // TODO: do not cache on errors using [set|restore]_error_handler
+
+ try {
+ if ($args) {
+ $ret = call_user_func_array($callback, $args);
+ } else {
+ $ret = call_user_func($callback);
+ }
+ } catch (\Exception $e) {
+ if ($cacheOutput) {
+ ob_end_flush();
+ }
+ throw $e;
+ }
+
+ if ($cacheOutput) {
+ $data = array($ret, ob_get_flush());
+ } else {
+ $data = array($ret);
+ }
+
+ $storage->setItem($key, $data);
+
+ return $ret;
+ }
+
+ /**
+ * function call handler
+ *
+ * @param string $function Function name to call
+ * @param array $args Function arguments
+ * @return mixed
+ * @throws Exception\RuntimeException
+ * @throws \Exception
+ */
+ public function __call($function, array $args)
+ {
+ return $this->call($function, $args);
+ }
+
+ /**
+ * Generate a unique key in base of a key representing the callback part
+ * and a key representing the arguments part.
+ *
+ * @param callable $callback A valid callback
+ * @param array $args Callback arguments
+ * @return string
+ * @throws Exception\RuntimeException
+ * @throws Exception\InvalidArgumentException
+ */
+ public function generateKey($callback, array $args = array())
+ {
+ return $this->generateCallbackKey($callback, $args);
+ }
+
+ /**
+ * Generate a unique key in base of a key representing the callback part
+ * and a key representing the arguments part.
+ *
+ * @param callable $callback A valid callback
+ * @param array $args Callback arguments
+ * @throws Exception\RuntimeException if callback not serializable
+ * @throws Exception\InvalidArgumentException if invalid callback
+ * @return string
+ */
+ protected function generateCallbackKey($callback, array $args)
+ {
+ if (!is_callable($callback, false, $callbackKey)) {
+ throw new Exception\InvalidArgumentException('Invalid callback');
+ }
+
+ // functions, methods and classnames are case-insensitive
+ $callbackKey = strtolower($callbackKey);
+
+ // generate a unique key of object callbacks
+ if (is_object($callback)) { // Closures & __invoke
+ $object = $callback;
+ } elseif (isset($callback[0])) { // array($object, 'method')
+ $object = $callback[0];
+ }
+ if (isset($object)) {
+ ErrorHandler::start();
+ try {
+ $serializedObject = serialize($object);
+ } catch (\Exception $e) {
+ ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "Can't serialize callback: see previous exception", 0, $e
+ );
+ }
+ $error = ErrorHandler::stop();
+
+ if (!$serializedObject) {
+ throw new Exception\RuntimeException(sprintf(
+ 'Cannot serialize callback%s',
+ ($error ? ': ' . $error->getMessage() : '')
+ ), 0, $error);
+ }
+ $callbackKey.= $serializedObject;
+ }
+
+ return md5($callbackKey) . $this->generateArgumentsKey($args);
+ }
+
+ /**
+ * Generate a unique key of the argument part.
+ *
+ * @param array $args
+ * @throws Exception\RuntimeException
+ * @return string
+ */
+ protected function generateArgumentsKey(array $args)
+ {
+ if (!$args) {
+ return '';
+ }
+
+ ErrorHandler::start();
+ try {
+ $serializedArgs = serialize(array_values($args));
+ } catch (\Exception $e) {
+ ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "Can't serialize arguments: see previous exception"
+ , 0, $e);
+ }
+ $error = ErrorHandler::stop();
+
+ if (!$serializedArgs) {
+ throw new Exception\RuntimeException(sprintf(
+ 'Cannot serialize arguments%s',
+ ($error ? ': ' . $error->getMessage() : '')
+ ), 0, $error);
+ }
+
+ return md5($serializedArgs);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Pattern/CaptureCache.php zendframework-2.2.6/library/Zend/Cache/Pattern/CaptureCache.php
--- zendframework-1.10.4/library/Zend/Cache/Pattern/CaptureCache.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Pattern/CaptureCache.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,399 @@
+detectPageId();
+ }
+
+ $that = $this;
+ ob_start(function ($content) use ($that, $pageId) {
+ $that->set($content, $pageId);
+
+ // http://php.net/manual/function.ob-start.php
+ // -> If output_callback returns FALSE original input is sent to the browser.
+ return false;
+ });
+
+ ob_implicit_flush(false);
+ }
+
+ /**
+ * Write content to page identity
+ *
+ * @param string $content
+ * @param null|string $pageId
+ * @throws Exception\LogicException
+ */
+ public function set($content, $pageId = null)
+ {
+ $publicDir = $this->getOptions()->getPublicDir();
+ if ($publicDir === null) {
+ throw new Exception\LogicException("Option 'public_dir' no set");
+ }
+
+ if ($pageId === null) {
+ $pageId = $this->detectPageId();
+ }
+
+ $path = $this->pageId2Path($pageId);
+ $file = $path . DIRECTORY_SEPARATOR . $this->pageId2Filename($pageId);
+
+ $this->createDirectoryStructure($publicDir . DIRECTORY_SEPARATOR . $path);
+ $this->putFileContent($publicDir . DIRECTORY_SEPARATOR . $file, $content);
+ }
+
+ /**
+ * Get from cache
+ *
+ * @param null|string $pageId
+ * @return bool|string
+ * @throws Exception\LogicException
+ * @throws Exception\RuntimeException
+ */
+ public function get($pageId = null)
+ {
+ $publicDir = $this->getOptions()->getPublicDir();
+ if ($publicDir === null) {
+ throw new Exception\LogicException("Option 'public_dir' no set");
+ }
+
+ if ($pageId === null) {
+ $pageId = $this->detectPageId();
+ }
+
+ $file = $publicDir
+ . DIRECTORY_SEPARATOR . $this->pageId2Path($pageId)
+ . DIRECTORY_SEPARATOR . $this->pageId2Filename($pageId);
+
+ if (file_exists($file)) {
+ ErrorHandler::start();
+ $content = file_get_contents($file);
+ $error = ErrorHandler::stop();
+ if ($content === false) {
+ throw new Exception\RuntimeException(
+ "Failed to read cached pageId '{$pageId}'", 0, $error
+ );
+ }
+ return $content;
+ }
+ }
+
+ /**
+ * Checks if a cache with given id exists
+ *
+ * @param null|string $pageId
+ * @throws Exception\LogicException
+ * @return bool
+ */
+ public function has($pageId = null)
+ {
+ $publicDir = $this->getOptions()->getPublicDir();
+ if ($publicDir === null) {
+ throw new Exception\LogicException("Option 'public_dir' no set");
+ }
+
+ if ($pageId === null) {
+ $pageId = $this->detectPageId();
+ }
+
+ $file = $publicDir
+ . DIRECTORY_SEPARATOR . $this->pageId2Path($pageId)
+ . DIRECTORY_SEPARATOR . $this->pageId2Filename($pageId);
+
+ return file_exists($file);
+ }
+
+ /**
+ * Remove from cache
+ *
+ * @param null|string $pageId
+ * @throws Exception\LogicException
+ * @throws Exception\RuntimeException
+ * @return bool
+ */
+ public function remove($pageId = null)
+ {
+ $publicDir = $this->getOptions()->getPublicDir();
+ if ($publicDir === null) {
+ throw new Exception\LogicException("Option 'public_dir' no set");
+ }
+
+ if ($pageId === null) {
+ $pageId = $this->detectPageId();
+ }
+
+ $file = $publicDir
+ . DIRECTORY_SEPARATOR . $this->pageId2Path($pageId)
+ . DIRECTORY_SEPARATOR . $this->pageId2Filename($pageId);
+
+ if (file_exists($file)) {
+ ErrorHandler::start();
+ $res = unlink($file);
+ $err = ErrorHandler::stop();
+ if (!$res) {
+ throw new Exception\RuntimeException(
+ "Failed to remove cached pageId '{$pageId}'", 0, $err
+ );
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Clear cached pages matching glob pattern
+ *
+ * @param string $pattern
+ * @throws Exception\LogicException
+ */
+ public function clearByGlob($pattern = '**')
+ {
+ $publicDir = $this->getOptions()->getPublicDir();
+ if ($publicDir === null) {
+ throw new Exception\LogicException("Option 'public_dir' no set");
+ }
+
+ $it = new \GlobIterator(
+ $publicDir . '/' . $pattern,
+ \GlobIterator::CURRENT_AS_SELF | \GlobIterator::SKIP_DOTS | \GlobIterator::UNIX_PATHS
+ );
+ foreach ($it as $pathname => $entry) {
+ if ($entry->isFile()) {
+ unlink($pathname);
+ }
+ }
+ }
+
+ /**
+ * Determine the page to save from the request
+ *
+ * @throws Exception\RuntimeException
+ * @return string
+ */
+ protected function detectPageId()
+ {
+ if (!isset($_SERVER['REQUEST_URI'])) {
+ throw new Exception\RuntimeException("Can't auto-detect current page identity");
+ }
+
+ return $_SERVER['REQUEST_URI'];
+ }
+
+ /**
+ * Get filename for page id
+ *
+ * @param string $pageId
+ * @return string
+ */
+ protected function pageId2Filename($pageId)
+ {
+ if (substr($pageId, -1) === '/') {
+ return $this->getOptions()->getIndexFilename();
+ }
+
+ return basename($pageId);
+ }
+
+ /**
+ * Get path for page id
+ *
+ * @param string $pageId
+ * @return string
+ */
+ protected function pageId2Path($pageId)
+ {
+ if (substr($pageId, -1) == '/') {
+ $path = rtrim($pageId, '/');
+ } else {
+ $path = dirname($pageId);
+ }
+
+ // convert requested "/" to the valid local directory separator
+ if ('/' != DIRECTORY_SEPARATOR) {
+ $path = str_replace('/', DIRECTORY_SEPARATOR, $path);
+ }
+
+ return $path;
+ }
+
+ /**
+ * Write content to a file
+ *
+ * @param string $file File complete path
+ * @param string $data Data to write
+ * @return void
+ * @throws Exception\RuntimeException
+ */
+ protected function putFileContent($file, $data)
+ {
+ $options = $this->getOptions();
+ $locking = $options->getFileLocking();
+ $perm = $options->getFilePermission();
+ $umask = $options->getUmask();
+ if ($umask !== false && $perm !== false) {
+ $perm = $perm & ~$umask;
+ }
+
+ ErrorHandler::start();
+
+ $umask = ($umask !== false) ? umask($umask) : false;
+ $rs = file_put_contents($file, $data, $locking ? LOCK_EX : 0);
+ if ($umask) {
+ umask($umask);
+ }
+
+ if ($rs === false) {
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "Error writing file '{$file}'", 0, $err
+ );
+ }
+
+ if ($perm !== false && !chmod($file, $perm)) {
+ $oct = decoct($perm);
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException("chmod('{$file}', 0{$oct}) failed", 0, $err);
+ }
+
+ ErrorHandler::stop();
+ }
+
+ /**
+ * Creates directory if not already done.
+ *
+ * @param string $pathname
+ * @return void
+ * @throws Exception\RuntimeException
+ */
+ protected function createDirectoryStructure($pathname)
+ {
+ // Directory structure already exists
+ if (file_exists($pathname)) {
+ return;
+ }
+
+ $options = $this->getOptions();
+ $perm = $options->getDirPermission();
+ $umask = $options->getUmask();
+ if ($umask !== false && $perm !== false) {
+ $perm = $perm & ~$umask;
+ }
+
+ ErrorHandler::start();
+
+ if ($perm === false) {
+ // build-in mkdir function is enough
+
+ $umask = ($umask !== false) ? umask($umask) : false;
+ $res = mkdir($pathname, ($perm !== false) ? $perm : 0777, true);
+
+ if ($umask !== false) {
+ umask($umask);
+ }
+
+ if (!$res) {
+ $oct = ($perm === false) ? '777' : decoct($perm);
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "mkdir('{$pathname}', 0{$oct}, true) failed", 0, $err
+ );
+ }
+
+ if ($perm !== false && !chmod($pathname, $perm)) {
+ $oct = decoct($perm);
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "chmod('{$pathname}', 0{$oct}) failed", 0, $err
+ );
+ }
+
+ } else {
+ // build-in mkdir function sets permission together with current umask
+ // which doesn't work well on multo threaded webservers
+ // -> create directories one by one and set permissions
+
+ // find existing path and missing path parts
+ $parts = array();
+ $path = $pathname;
+ while (!file_exists($path)) {
+ array_unshift($parts, basename($path));
+ $nextPath = dirname($path);
+ if ($nextPath === $path) {
+ break;
+ }
+ $path = $nextPath;
+ }
+
+ // make all missing path parts
+ foreach ($parts as $part) {
+ $path.= DIRECTORY_SEPARATOR . $part;
+
+ // create a single directory, set and reset umask immediately
+ $umask = ($umask !== false) ? umask($umask) : false;
+ $res = mkdir($path, ($perm === false) ? 0777 : $perm, false);
+ if ($umask !== false) {
+ umask($umask);
+ }
+
+ if (!$res) {
+ $oct = ($perm === false) ? '777' : decoct($perm);
+ ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "mkdir('{$path}', 0{$oct}, false) failed"
+ );
+ }
+
+ if ($perm !== false && !chmod($path, $perm)) {
+ $oct = decoct($perm);
+ ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "chmod('{$path}', 0{$oct}) failed"
+ );
+ }
+ }
+ }
+
+ ErrorHandler::stop();
+ }
+
+ /**
+ * Returns the generated file name.
+ *
+ * @param null|string $pageId
+ * @return string
+ */
+ public function getFilename($pageId = null)
+ {
+ if ($pageId === null) {
+ $pageId = $this->detectPageId();
+ }
+
+ $publicDir = $this->getOptions()->getPublicDir();
+ $path = $this->pageId2Path($pageId);
+ $file = $path . DIRECTORY_SEPARATOR . $this->pageId2Filename($pageId);
+
+ return $publicDir . $file;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Pattern/ClassCache.php zendframework-2.2.6/library/Zend/Cache/Pattern/ClassCache.php
--- zendframework-1.10.4/library/Zend/Cache/Pattern/ClassCache.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Pattern/ClassCache.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,167 @@
+getClass()) {
+ throw new Exception\InvalidArgumentException("Missing option 'class'");
+ } elseif (!$options->getStorage()) {
+ throw new Exception\InvalidArgumentException("Missing option 'storage'");
+ }
+ return $this;
+ }
+
+ /**
+ * Call and cache a class method
+ *
+ * @param string $method Method name to call
+ * @param array $args Method arguments
+ * @return mixed
+ * @throws Exception\RuntimeException
+ * @throws \Exception
+ */
+ public function call($method, array $args = array())
+ {
+ $options = $this->getOptions();
+ $classname = $options->getClass();
+ $method = strtolower($method);
+ $callback = $classname . '::' . $method;
+
+ $cache = $options->getCacheByDefault();
+ if ($cache) {
+ $cache = !in_array($method, $options->getClassNonCacheMethods());
+ } else {
+ $cache = in_array($method, $options->getClassCacheMethods());
+ }
+
+ if (!$cache) {
+ if ($args) {
+ return call_user_func_array($callback, $args);
+ } else {
+ return $classname::$method();
+ }
+ }
+
+ return parent::call($callback, $args);
+ }
+
+ /**
+ * Generate a unique key in base of a key representing the callback part
+ * and a key representing the arguments part.
+ *
+ * @param string $method The method
+ * @param array $args Callback arguments
+ * @return string
+ * @throws Exception\RuntimeException
+ */
+ public function generateKey($method, array $args = array())
+ {
+ return $this->generateCallbackKey(
+ $this->getOptions()->getClass() . '::' . $method,
+ $args
+ );
+ }
+
+ /**
+ * Generate a unique key in base of a key representing the callback part
+ * and a key representing the arguments part.
+ *
+ * @param callable $callback A valid callback
+ * @param array $args Callback arguments
+ * @return string
+ * @throws Exception\RuntimeException
+ */
+ protected function generateCallbackKey($callback, array $args)
+ {
+ $callbackKey = md5(strtolower($callback));
+ $argumentKey = $this->generateArgumentsKey($args);
+ return $callbackKey . $argumentKey;
+ }
+
+ /**
+ * Calling a method of the entity.
+ *
+ * @param string $method Method name to call
+ * @param array $args Method arguments
+ * @return mixed
+ * @throws Exception\RuntimeException
+ * @throws \Exception
+ */
+ public function __call($method, array $args)
+ {
+ return $this->call($method, $args);
+ }
+
+ /**
+ * Set a static property
+ *
+ * @param string $name
+ * @param mixed $value
+ * @return void
+ * @see http://php.net/manual/language.oop5.overloading.php#language.oop5.overloading.members
+ */
+ public function __set($name, $value)
+ {
+ $class = $this->getOptions()->getClass();
+ $class::$name = $value;
+ }
+
+ /**
+ * Get a static property
+ *
+ * @param string $name
+ * @return mixed
+ * @see http://php.net/manual/language.oop5.overloading.php#language.oop5.overloading.members
+ */
+ public function __get($name)
+ {
+ $class = $this->getOptions()->getClass();
+ return $class::$name;
+ }
+
+ /**
+ * Is a static property exists.
+ *
+ * @param string $name
+ * @return bool
+ */
+ public function __isset($name)
+ {
+ $class = $this->getOptions()->getClass();
+ return isset($class::$name);
+ }
+
+ /**
+ * Unset a static property
+ *
+ * @param string $name
+ * @return void
+ */
+ public function __unset($name)
+ {
+ $class = $this->getOptions()->getClass();
+ unset($class::$name);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Pattern/ObjectCache.php zendframework-2.2.6/library/Zend/Cache/Pattern/ObjectCache.php
--- zendframework-1.10.4/library/Zend/Cache/Pattern/ObjectCache.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Pattern/ObjectCache.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,284 @@
+getObject()) {
+ throw new Exception\InvalidArgumentException("Missing option 'object'");
+ } elseif (!$options->getStorage()) {
+ throw new Exception\InvalidArgumentException("Missing option 'storage'");
+ }
+ }
+
+ /**
+ * Call and cache a class method
+ *
+ * @param string $method Method name to call
+ * @param array $args Method arguments
+ * @return mixed
+ * @throws Exception\RuntimeException
+ * @throws \Exception
+ */
+ public function call($method, array $args = array())
+ {
+ $options = $this->getOptions();
+ $object = $options->getObject();
+ $method = strtolower($method);
+
+ // handle magic methods
+ switch ($method) {
+ case '__set':
+ $property = array_shift($args);
+ $value = array_shift($args);
+
+ $object->{$property} = $value;
+
+ if (!$options->getObjectCacheMagicProperties()
+ || property_exists($object, $property)
+ ) {
+ // no caching if property isn't magic
+ // or caching magic properties is disabled
+ return;
+ }
+
+ // remove cached __get and __isset
+ $removeKeys = null;
+ if (method_exists($object, '__get')) {
+ $removeKeys[] = $this->generateKey('__get', array($property));
+ }
+ if (method_exists($object, '__isset')) {
+ $removeKeys[] = $this->generateKey('__isset', array($property));
+ }
+ if ($removeKeys) {
+ $options->getStorage()->removeItems($removeKeys);
+ }
+ return;
+
+ case '__get':
+ $property = array_shift($args);
+
+ if (!$options->getObjectCacheMagicProperties()
+ || property_exists($object, $property)
+ ) {
+ // no caching if property isn't magic
+ // or caching magic properties is disabled
+ return $object->{$property};
+ }
+
+ array_unshift($args, $property);
+ return parent::call(array($object, '__get'), $args);
+
+ case '__isset':
+ $property = array_shift($args);
+
+ if (!$options->getObjectCacheMagicProperties()
+ || property_exists($object, $property)
+ ) {
+ // no caching if property isn't magic
+ // or caching magic properties is disabled
+ return isset($object->{$property});
+ }
+
+ return parent::call(array($object, '__isset'), array($property));
+
+ case '__unset':
+ $property = array_shift($args);
+
+ unset($object->{$property});
+
+ if (!$options->getObjectCacheMagicProperties()
+ || property_exists($object, $property)
+ ) {
+ // no caching if property isn't magic
+ // or caching magic properties is disabled
+ return;
+ }
+
+ // remove previous cached __get and __isset calls
+ $removeKeys = null;
+ if (method_exists($object, '__get')) {
+ $removeKeys[] = $this->generateKey('__get', array($property));
+ }
+ if (method_exists($object, '__isset')) {
+ $removeKeys[] = $this->generateKey('__isset', array($property));
+ }
+ if ($removeKeys) {
+ $options->getStorage()->removeItems($removeKeys);
+ }
+ return;
+ }
+
+ $cache = $options->getCacheByDefault();
+ if ($cache) {
+ $cache = !in_array($method, $options->getObjectNonCacheMethods());
+ } else {
+ $cache = in_array($method, $options->getObjectCacheMethods());
+ }
+
+ if (!$cache) {
+ if ($args) {
+ return call_user_func_array(array($object, $method), $args);
+ }
+ return $object->{$method}();
+ }
+
+ return parent::call(array($object, $method), $args);
+ }
+
+ /**
+ * Generate a unique key in base of a key representing the callback part
+ * and a key representing the arguments part.
+ *
+ * @param string $method The method
+ * @param array $args Callback arguments
+ * @return string
+ * @throws Exception\RuntimeException
+ */
+ public function generateKey($method, array $args = array())
+ {
+ return $this->generateCallbackKey(
+ array($this->getOptions()->getObject(), $method),
+ $args
+ );
+ }
+
+ /**
+ * Generate a unique key in base of a key representing the callback part
+ * and a key representing the arguments part.
+ *
+ * @param callable $callback A valid callback
+ * @param array $args Callback arguments
+ * @return string
+ * @throws Exception\RuntimeException
+ */
+ protected function generateCallbackKey($callback, array $args = array())
+ {
+ $callbackKey = md5($this->getOptions()->getObjectKey() . '::' . strtolower($callback[1]));
+ $argumentKey = $this->generateArgumentsKey($args);
+ return $callbackKey . $argumentKey;
+ }
+
+ /**
+ * Class method call handler
+ *
+ * @param string $method Method name to call
+ * @param array $args Method arguments
+ * @return mixed
+ * @throws Exception\RuntimeException
+ * @throws \Exception
+ */
+ public function __call($method, array $args)
+ {
+ return $this->call($method, $args);
+ }
+
+ /**
+ * Writing data to properties.
+ *
+ * NOTE:
+ * Magic properties will be cached too if the option cacheMagicProperties
+ * is enabled and the property doesn't exist in real. If so it calls __set
+ * and removes cached data of previous __get and __isset calls.
+ *
+ * @param string $name
+ * @param mixed $value
+ * @return void
+ * @see http://php.net/manual/language.oop5.overloading.php#language.oop5.overloading.members
+ */
+ public function __set($name, $value)
+ {
+ return $this->call('__set', array($name, $value));
+ }
+
+ /**
+ * Reading data from properties.
+ *
+ * NOTE:
+ * Magic properties will be cached too if the option cacheMagicProperties
+ * is enabled and the property doesn't exist in real. If so it calls __get.
+ *
+ * @param string $name
+ * @return mixed
+ * @see http://php.net/manual/language.oop5.overloading.php#language.oop5.overloading.members
+ */
+ public function __get($name)
+ {
+ return $this->call('__get', array($name));
+ }
+
+ /**
+ * Checking existing properties.
+ *
+ * NOTE:
+ * Magic properties will be cached too if the option cacheMagicProperties
+ * is enabled and the property doesn't exist in real. If so it calls __get.
+ *
+ * @param string $name
+ * @return bool
+ * @see http://php.net/manual/language.oop5.overloading.php#language.oop5.overloading.members
+ */
+ public function __isset($name)
+ {
+ return $this->call('__isset', array($name));
+ }
+
+ /**
+ * Unseting a property.
+ *
+ * NOTE:
+ * Magic properties will be cached too if the option cacheMagicProperties
+ * is enabled and the property doesn't exist in real. If so it removes
+ * previous cached __isset and __get calls.
+ *
+ * @param string $name
+ * @return void
+ * @see http://php.net/manual/language.oop5.overloading.php#language.oop5.overloading.members
+ */
+ public function __unset($name)
+ {
+ return $this->call('__unset', array($name));
+ }
+
+ /**
+ * Handle casting to string
+ *
+ * @return string
+ * @see http://php.net/manual/language.oop5.magic.php#language.oop5.magic.tostring
+ */
+ public function __toString()
+ {
+ return $this->call('__toString');
+ }
+
+ /**
+ * Handle invoke calls
+ *
+ * @return mixed
+ * @see http://php.net/manual/language.oop5.magic.php#language.oop5.magic.invoke
+ */
+ public function __invoke()
+ {
+ return $this->call('__invoke', func_get_args());
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Pattern/OutputCache.php zendframework-2.2.6/library/Zend/Cache/Pattern/OutputCache.php
--- zendframework-1.10.4/library/Zend/Cache/Pattern/OutputCache.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Pattern/OutputCache.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,89 @@
+getStorage()) {
+ throw new Exception\InvalidArgumentException("Missing option 'storage'");
+ }
+
+ return $this;
+ }
+
+ /**
+ * if there is a cached item with the given key display it's data and return true
+ * else start buffering output until end() is called or the script ends.
+ *
+ * @param string $key Key
+ * @throws Exception\MissingKeyException if key is missing
+ * @return bool
+ */
+ public function start($key)
+ {
+ if (($key = (string) $key) === '') {
+ throw new Exception\MissingKeyException('Missing key to read/write output from cache');
+ }
+
+ $success = null;
+ $data = $this->getOptions()->getStorage()->getItem($key, $success);
+ if ($success) {
+ echo $data;
+ return true;
+ }
+
+ ob_start();
+ ob_implicit_flush(false);
+ $this->keyStack[] = $key;
+ return false;
+ }
+
+ /**
+ * Stops buffering output, write buffered data to cache using the given key on start()
+ * and displays the buffer.
+ *
+ * @throws Exception\RuntimeException if output cache not started or buffering not active
+ * @return bool TRUE on success, FALSE on failure writing to cache
+ */
+ public function end()
+ {
+ $key = array_pop($this->keyStack);
+ if ($key === null) {
+ throw new Exception\RuntimeException('Output cache not started');
+ }
+
+ $output = ob_get_flush();
+ if ($output === false) {
+ throw new Exception\RuntimeException('Output buffering not active');
+ }
+
+ return $this->getOptions()->getStorage()->setItem($key, $output);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Pattern/PatternInterface.php zendframework-2.2.6/library/Zend/Cache/Pattern/PatternInterface.php
--- zendframework-1.10.4/library/Zend/Cache/Pattern/PatternInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Pattern/PatternInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,28 @@
+filePermission = false;
+ $this->dirPermission = false;
+ }
+
+ parent::__construct($options);
+ }
+
+ /**
+ * Set flag indicating whether or not to cache by default
+ *
+ * Used by:
+ * - ClassCache
+ * - ObjectCache
+ *
+ * @param bool $cacheByDefault
+ * @return PatternOptions
+ */
+ public function setCacheByDefault($cacheByDefault)
+ {
+ $this->cacheByDefault = $cacheByDefault;
+ return $this;
+ }
+
+ /**
+ * Do we cache by default?
+ *
+ * Used by:
+ * - ClassCache
+ * - ObjectCache
+ *
+ * @return bool
+ */
+ public function getCacheByDefault()
+ {
+ return $this->cacheByDefault;
+ }
+
+ /**
+ * Set whether or not to cache output
+ *
+ * Used by:
+ * - CallbackCache
+ * - ClassCache
+ * - ObjectCache
+ *
+ * @param bool $cacheOutput
+ * @return PatternOptions
+ */
+ public function setCacheOutput($cacheOutput)
+ {
+ $this->cacheOutput = (bool) $cacheOutput;
+ return $this;
+ }
+
+ /**
+ * Will we cache output?
+ *
+ * Used by:
+ * - CallbackCache
+ * - ClassCache
+ * - ObjectCache
+ *
+ * @return bool
+ */
+ public function getCacheOutput()
+ {
+ return $this->cacheOutput;
+ }
+
+ /**
+ * Set class name
+ *
+ * Used by:
+ * - ClassCache
+ *
+ * @param string $class
+ * @throws Exception\InvalidArgumentException
+ * @return PatternOptions
+ */
+ public function setClass($class)
+ {
+ if (!is_string($class)) {
+ throw new Exception\InvalidArgumentException('Invalid classname provided; must be a string');
+ }
+ $this->class = $class;
+ return $this;
+ }
+
+ /**
+ * Get class name
+ *
+ * Used by:
+ * - ClassCache
+ *
+ * @return null|string
+ */
+ public function getClass()
+ {
+ return $this->class;
+ }
+
+ /**
+ * Set list of method return values to cache
+ *
+ * Used by:
+ * - ClassCache
+ *
+ * @param array $classCacheMethods
+ * @return PatternOptions
+ */
+ public function setClassCacheMethods(array $classCacheMethods)
+ {
+ $this->classCacheMethods = $this->recursiveStrtolower($classCacheMethods);
+ return $this;
+ }
+
+ /**
+ * Get list of methods from which to cache return values
+ *
+ * Used by:
+ * - ClassCache
+ *
+ * @return array
+ */
+ public function getClassCacheMethods()
+ {
+ return $this->classCacheMethods;
+ }
+
+ /**
+ * Set list of method return values NOT to cache
+ *
+ * Used by:
+ * - ClassCache
+ *
+ * @param array $classNonCacheMethods
+ * @return PatternOptions
+ */
+ public function setClassNonCacheMethods(array $classNonCacheMethods)
+ {
+ $this->classNonCacheMethods = $this->recursiveStrtolower($classNonCacheMethods);
+ return $this;
+ }
+
+ /**
+ * Get list of methods from which NOT to cache return values
+ *
+ * Used by:
+ * - ClassCache
+ *
+ * @return array
+ */
+ public function getClassNonCacheMethods()
+ {
+ return $this->classNonCacheMethods;
+ }
+
+ /**
+ * Set directory permission
+ *
+ * @param false|int $dirPermission
+ * @throws Exception\InvalidArgumentException
+ * @return PatternOptions
+ */
+ public function setDirPermission($dirPermission)
+ {
+ if ($dirPermission !== false) {
+ if (is_string($dirPermission)) {
+ $dirPermission = octdec($dirPermission);
+ } else {
+ $dirPermission = (int) $dirPermission;
+ }
+
+ // validate
+ if (($dirPermission & 0700) != 0700) {
+ throw new Exception\InvalidArgumentException(
+ 'Invalid directory permission: need permission to execute, read and write by owner'
+ );
+ }
+ }
+
+ $this->dirPermission = $dirPermission;
+ return $this;
+ }
+
+ /**
+ * Gets directory permission
+ *
+ * @return false|int
+ */
+ public function getDirPermission()
+ {
+ return $this->dirPermission;
+ }
+
+ /**
+ * Set umask
+ *
+ * Used by:
+ * - CaptureCache
+ *
+ * @param false|int $umask
+ * @throws Exception\InvalidArgumentException
+ * @return PatternOptions
+ */
+ public function setUmask($umask)
+ {
+ if ($umask !== false) {
+ if (is_string($umask)) {
+ $umask = octdec($umask);
+ } else {
+ $umask = (int) $umask;
+ }
+
+ // validate
+ if ($umask & 0700) {
+ throw new Exception\InvalidArgumentException(
+ 'Invalid umask: need permission to execute, read and write by owner'
+ );
+ }
+
+ // normalize
+ $umask = $umask & 0777;
+ }
+
+ $this->umask = $umask;
+ return $this;
+ }
+
+ /**
+ * Get umask
+ *
+ * Used by:
+ * - CaptureCache
+ *
+ * @return false|int
+ */
+ public function getUmask()
+ {
+ return $this->umask;
+ }
+
+ /**
+ * Set whether or not file locking should be used
+ *
+ * Used by:
+ * - CaptureCache
+ *
+ * @param bool $fileLocking
+ * @return PatternOptions
+ */
+ public function setFileLocking($fileLocking)
+ {
+ $this->fileLocking = (bool) $fileLocking;
+ return $this;
+ }
+
+ /**
+ * Is file locking enabled?
+ *
+ * Used by:
+ * - CaptureCache
+ *
+ * @return bool
+ */
+ public function getFileLocking()
+ {
+ return $this->fileLocking;
+ }
+
+ /**
+ * Set file permission
+ *
+ * @param false|int $filePermission
+ * @throws Exception\InvalidArgumentException
+ * @return PatternOptions
+ */
+ public function setFilePermission($filePermission)
+ {
+ if ($filePermission !== false) {
+ if (is_string($filePermission)) {
+ $filePermission = octdec($filePermission);
+ } else {
+ $filePermission = (int) $filePermission;
+ }
+
+ // validate
+ if (($filePermission & 0600) != 0600) {
+ throw new Exception\InvalidArgumentException(
+ 'Invalid file permission: need permission to read and write by owner'
+ );
+ } elseif ($filePermission & 0111) {
+ throw new Exception\InvalidArgumentException(
+ "Invalid file permission: Files shoudn't be executable"
+ );
+ }
+ }
+
+ $this->filePermission = $filePermission;
+ return $this;
+ }
+
+ /**
+ * Gets file permission
+ *
+ * @return false|int
+ */
+ public function getFilePermission()
+ {
+ return $this->filePermission;
+ }
+
+ /**
+ * Set value for index filename
+ *
+ * @param string $indexFilename
+ * @return PatternOptions
+ */
+ public function setIndexFilename($indexFilename)
+ {
+ $this->indexFilename = (string) $indexFilename;
+ return $this;
+ }
+
+ /**
+ * Get value for index filename
+ *
+ * @return string
+ */
+ public function getIndexFilename()
+ {
+ return $this->indexFilename;
+ }
+
+ /**
+ * Set object to cache
+ *
+ * @param mixed $object
+ * @throws Exception\InvalidArgumentException
+ * @return PatternOptions
+ */
+ public function setObject($object)
+ {
+ if (!is_object($object)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s expects an object; received "%s"', __METHOD__, gettype($object)
+ ));
+ }
+ $this->object = $object;
+ return $this;
+ }
+
+ /**
+ * Get object to cache
+ *
+ * @return null|object
+ */
+ public function getObject()
+ {
+ return $this->object;
+ }
+
+ /**
+ * Set flag indicating whether or not to cache magic properties
+ *
+ * Used by:
+ * - ObjectCache
+ *
+ * @param bool $objectCacheMagicProperties
+ * @return PatternOptions
+ */
+ public function setObjectCacheMagicProperties($objectCacheMagicProperties)
+ {
+ $this->objectCacheMagicProperties = (bool) $objectCacheMagicProperties;
+ return $this;
+ }
+
+ /**
+ * Should we cache magic properties?
+ *
+ * Used by:
+ * - ObjectCache
+ *
+ * @return bool
+ */
+ public function getObjectCacheMagicProperties()
+ {
+ return $this->objectCacheMagicProperties;
+ }
+
+ /**
+ * Set list of object methods for which to cache return values
+ *
+ * @param array $objectCacheMethods
+ * @return PatternOptions
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setObjectCacheMethods(array $objectCacheMethods)
+ {
+ $this->objectCacheMethods = $this->normalizeObjectMethods($objectCacheMethods);
+ return $this;
+ }
+
+ /**
+ * Get list of object methods for which to cache return values
+ *
+ * @return array
+ */
+ public function getObjectCacheMethods()
+ {
+ return $this->objectCacheMethods;
+ }
+
+ /**
+ * Set the object key part.
+ *
+ * Used to generate a callback key in order to speed up key generation.
+ *
+ * Used by:
+ * - ObjectCache
+ *
+ * @param mixed $objectKey
+ * @return PatternOptions
+ */
+ public function setObjectKey($objectKey)
+ {
+ if ($objectKey !== null) {
+ $this->objectKey = (string) $objectKey;
+ } else {
+ $this->objectKey = null;
+ }
+ return $this;
+ }
+
+ /**
+ * Get object key
+ *
+ * Used by:
+ * - ObjectCache
+ *
+ * @return mixed
+ */
+ public function getObjectKey()
+ {
+ if (!$this->objectKey) {
+ return get_class($this->getObject());
+ }
+ return $this->objectKey;
+ }
+
+ /**
+ * Set list of object methods for which NOT to cache return values
+ *
+ * @param array $objectNonCacheMethods
+ * @return PatternOptions
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setObjectNonCacheMethods(array $objectNonCacheMethods)
+ {
+ $this->objectNonCacheMethods = $this->normalizeObjectMethods($objectNonCacheMethods);
+ return $this;
+ }
+
+ /**
+ * Get list of object methods for which NOT to cache return values
+ *
+ * @return array
+ */
+ public function getObjectNonCacheMethods()
+ {
+ return $this->objectNonCacheMethods;
+ }
+
+ /**
+ * Set location of public directory
+ *
+ * Used by:
+ * - CaptureCache
+ *
+ * @param string $publicDir
+ * @throws Exception\InvalidArgumentException
+ * @return PatternOptions
+ */
+ public function setPublicDir($publicDir)
+ {
+ $publicDir = (string) $publicDir;
+
+ if (!is_dir($publicDir)) {
+ throw new Exception\InvalidArgumentException(
+ "Public directory '{$publicDir}' not found or not a directory"
+ );
+ } elseif (!is_writable($publicDir)) {
+ throw new Exception\InvalidArgumentException(
+ "Public directory '{$publicDir}' not writable"
+ );
+ } elseif (!is_readable($publicDir)) {
+ throw new Exception\InvalidArgumentException(
+ "Public directory '{$publicDir}' not readable"
+ );
+ }
+
+ $this->publicDir = rtrim(realpath($publicDir), DIRECTORY_SEPARATOR);
+ return $this;
+ }
+
+ /**
+ * Get location of public directory
+ *
+ * Used by:
+ * - CaptureCache
+ *
+ * @return null|string
+ */
+ public function getPublicDir()
+ {
+ return $this->publicDir;
+ }
+
+ /**
+ * Set storage adapter
+ *
+ * Required for the following Pattern classes:
+ * - CallbackCache
+ * - ClassCache
+ * - ObjectCache
+ * - OutputCache
+ *
+ * @param string|array|Storage $storage
+ * @return PatternOptions
+ */
+ public function setStorage($storage)
+ {
+ $this->storage = $this->storageFactory($storage);
+ return $this;
+ }
+
+ /**
+ * Get storage adapter
+ *
+ * Used by:
+ * - CallbackCache
+ * - ClassCache
+ * - ObjectCache
+ * - OutputCache
+ *
+ * @return null|Storage
+ */
+ public function getStorage()
+ {
+ return $this->storage;
+ }
+
+ /**
+ * Recursively apply strtolower on all values of an array, and return as a
+ * list of unique values
+ *
+ * @param array $array
+ * @return array
+ */
+ protected function recursiveStrtolower(array $array)
+ {
+ return array_values(array_unique(array_map('strtolower', $array)));
+ }
+
+ /**
+ * Normalize object methods
+ *
+ * Recursively casts values to lowercase, then determines if any are in a
+ * list of methods not handled, raising an exception if so.
+ *
+ * @param array $methods
+ * @return array
+ * @throws Exception\InvalidArgumentException
+ */
+ protected function normalizeObjectMethods(array $methods)
+ {
+ $methods = $this->recursiveStrtolower($methods);
+ $intersect = array_intersect(array('__set', '__get', '__unset', '__isset'), $methods);
+ if (!empty($intersect)) {
+ throw new Exception\InvalidArgumentException(
+ "Magic properties are handled by option 'cache_magic_properties'"
+ );
+ }
+ return $methods;
+ }
+
+ /**
+ * Create a storage object from a given specification
+ *
+ * @param array|string|Storage $storage
+ * @throws Exception\InvalidArgumentException
+ * @return Storage
+ */
+ protected function storageFactory($storage)
+ {
+ if (is_array($storage)) {
+ $storage = StorageFactory::factory($storage);
+ } elseif (is_string($storage)) {
+ $storage = StorageFactory::adapterFactory($storage);
+ } elseif (!($storage instanceof Storage)) {
+ throw new Exception\InvalidArgumentException(
+ 'The storage must be an instanceof Zend\Cache\Storage\StorageInterface '
+ . 'or an array passed to Zend\Cache\Storage::factory '
+ . 'or simply the name of the storage adapter'
+ );
+ }
+
+ return $storage;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/PatternFactory.php zendframework-2.2.6/library/Zend/Cache/PatternFactory.php
--- zendframework-1.10.4/library/Zend/Cache/PatternFactory.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/PatternFactory.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,92 @@
+setOptions($options);
+ return $patternName;
+ }
+
+ $pattern = static::getPluginManager()->get($patternName);
+ $pattern->setOptions($options);
+ return $pattern;
+ }
+
+ /**
+ * Get the pattern plugin manager
+ *
+ * @return PatternPluginManager
+ */
+ public static function getPluginManager()
+ {
+ if (static::$plugins === null) {
+ static::$plugins = new PatternPluginManager();
+ }
+
+ return static::$plugins;
+ }
+
+ /**
+ * Set the pattern plugin manager
+ *
+ * @param PatternPluginManager $plugins
+ * @return void
+ */
+ public static function setPluginManager(PatternPluginManager $plugins)
+ {
+ static::$plugins = $plugins;
+ }
+
+ /**
+ * Reset pattern plugin manager to default
+ *
+ * @return void
+ */
+ public static function resetPluginManager()
+ {
+ static::$plugins = null;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/PatternPluginManager.php zendframework-2.2.6/library/Zend/Cache/PatternPluginManager.php
--- zendframework-1.10.4/library/Zend/Cache/PatternPluginManager.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/PatternPluginManager.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,66 @@
+ 'Zend\Cache\Pattern\CallbackCache',
+ 'capture' => 'Zend\Cache\Pattern\CaptureCache',
+ 'class' => 'Zend\Cache\Pattern\ClassCache',
+ 'object' => 'Zend\Cache\Pattern\ObjectCache',
+ 'output' => 'Zend\Cache\Pattern\OutputCache',
+ 'page' => 'Zend\Cache\Pattern\PageCache',
+ );
+
+ /**
+ * Don't share by default
+ *
+ * @var array
+ */
+ protected $shareByDefault = false;
+
+ /**
+ * Validate the plugin
+ *
+ * Checks that the pattern adapter loaded is an instance of Pattern\PatternInterface.
+ *
+ * @param mixed $plugin
+ * @return void
+ * @throws Exception\RuntimeException if invalid
+ */
+ public function validatePlugin($plugin)
+ {
+ if ($plugin instanceof Pattern\PatternInterface) {
+ // we're okay
+ return;
+ }
+
+ throw new Exception\RuntimeException(sprintf(
+ 'Plugin of type %s is invalid; must implement %s\Pattern\PatternInterface',
+ (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
+ __NAMESPACE__
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/README.md zendframework-2.2.6/library/Zend/Cache/README.md
--- zendframework-1.10.4/library/Zend/Cache/README.md 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/README.md 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,14 @@
+Cache Component from ZF2
+========================
+
+This is the Cache component for ZF2.
+
+- File issues at https://github.com/zendframework/zf2/issues
+- Create pull requests against https://github.com/zendframework/zf2
+- Documentation is at http://framework.zend.com/docs
+
+LICENSE
+-------
+
+The files in this archive are released under the [Zend Framework
+license](http://framework.zend.com/license), which is a 3-clause BSD license.
diff -Nru zendframework-1.10.4/library/Zend/Cache/Service/StorageCacheAbstractServiceFactory.php zendframework-2.2.6/library/Zend/Cache/Service/StorageCacheAbstractServiceFactory.php
--- zendframework-1.10.4/library/Zend/Cache/Service/StorageCacheAbstractServiceFactory.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Service/StorageCacheAbstractServiceFactory.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,88 @@
+getConfig($services);
+ if (empty($config)) {
+ return false;
+ }
+
+ return (isset($config[$requestedName]) && is_array($config[$requestedName]));
+ }
+
+ /**
+ * @param ServiceLocatorInterface $services
+ * @param string $name
+ * @param string $requestedName
+ * @return \Zend\Cache\Storage\StorageInterface
+ */
+ public function createServiceWithName(ServiceLocatorInterface $services, $name, $requestedName)
+ {
+ $config = $this->getConfig($services);
+ $config = $config[$requestedName];
+ return StorageFactory::factory($config);
+ }
+
+ /**
+ * Retrieve cache configuration, if any
+ *
+ * @param ServiceLocatorInterface $services
+ * @return array
+ */
+ protected function getConfig(ServiceLocatorInterface $services)
+ {
+ if ($this->config !== null) {
+ return $this->config;
+ }
+
+ if (!$services->has('Config')) {
+ $this->config = array();
+ return $this->config;
+ }
+
+ $config = $services->get('Config');
+ if (!isset($config[$this->configKey])) {
+ $this->config = array();
+ return $this->config;
+ }
+
+ $this->config = $config[$this->configKey];
+ return $this->config;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Service/StorageCacheFactory.php zendframework-2.2.6/library/Zend/Cache/Service/StorageCacheFactory.php
--- zendframework-1.10.4/library/Zend/Cache/Service/StorageCacheFactory.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Service/StorageCacheFactory.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,30 @@
+get('Config');
+ $cacheConfig = isset($config['cache']) ? $config['cache'] : array();
+ $cache = StorageFactory::factory($cacheConfig);
+
+ return $cache;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/AbstractAdapter.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/AbstractAdapter.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/AbstractAdapter.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/AbstractAdapter.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,1580 @@
+setOptions($options);
+ }
+ }
+
+ /**
+ * Destructor
+ *
+ * detach all registered plugins to free
+ * event handles of event manager
+ *
+ * @return void
+ */
+ public function __destruct()
+ {
+ foreach ($this->getPluginRegistry() as $plugin) {
+ $this->removePlugin($plugin);
+ }
+
+ if ($this->eventHandles) {
+ $events = $this->getEventManager();
+ foreach ($this->eventHandles as $handle) {
+ $events->detach($handle);
+ }
+ }
+ }
+
+ /* configuration */
+
+ /**
+ * Set options.
+ *
+ * @param array|Traversable|AdapterOptions $options
+ * @return AbstractAdapter
+ * @see getOptions()
+ */
+ public function setOptions($options)
+ {
+ if ($this->options !== $options) {
+ if (!$options instanceof AdapterOptions) {
+ $options = new AdapterOptions($options);
+ }
+
+ if ($this->options) {
+ $this->options->setAdapter(null);
+ }
+ $options->setAdapter($this);
+ $this->options = $options;
+
+ $event = new Event('option', $this, new ArrayObject($options->toArray()));
+ $this->getEventManager()->trigger($event);
+ }
+ return $this;
+ }
+
+ /**
+ * Get options.
+ *
+ * @return AdapterOptions
+ * @see setOptions()
+ */
+ public function getOptions()
+ {
+ if (!$this->options) {
+ $this->setOptions(new AdapterOptions());
+ }
+ return $this->options;
+ }
+
+ /**
+ * Enable/Disable caching.
+ *
+ * Alias of setWritable and setReadable.
+ *
+ * @see setWritable()
+ * @see setReadable()
+ * @param bool $flag
+ * @return AbstractAdapter
+ */
+ public function setCaching($flag)
+ {
+ $flag = (bool) $flag;
+ $options = $this->getOptions();
+ $options->setWritable($flag);
+ $options->setReadable($flag);
+ return $this;
+ }
+
+ /**
+ * Get caching enabled.
+ *
+ * Alias of getWritable and getReadable.
+ *
+ * @see getWritable()
+ * @see getReadable()
+ * @return bool
+ */
+ public function getCaching()
+ {
+ $options = $this->getOptions();
+ return ($options->getWritable() && $options->getReadable());
+ }
+
+ /* Event/Plugin handling */
+
+ /**
+ * Get the event manager
+ *
+ * @return EventManagerInterface
+ */
+ public function getEventManager()
+ {
+ if ($this->events === null) {
+ $this->events = new EventManager(array(__CLASS__, get_class($this)));
+ }
+ return $this->events;
+ }
+
+ /**
+ * Trigger an pre event and return the event response collection
+ *
+ * @param string $eventName
+ * @param ArrayObject $args
+ * @return \Zend\EventManager\ResponseCollection All handler return values
+ */
+ protected function triggerPre($eventName, ArrayObject $args)
+ {
+ return $this->getEventManager()->trigger(new Event($eventName . '.pre', $this, $args));
+ }
+
+ /**
+ * Triggers the PostEvent and return the result value.
+ *
+ * @param string $eventName
+ * @param ArrayObject $args
+ * @param mixed $result
+ * @return mixed
+ */
+ protected function triggerPost($eventName, ArrayObject $args, & $result)
+ {
+ $postEvent = new PostEvent($eventName . '.post', $this, $args, $result);
+ $eventRs = $this->getEventManager()->trigger($postEvent);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ return $postEvent->getResult();
+ }
+
+ /**
+ * Trigger an exception event
+ *
+ * If the ExceptionEvent has the flag "throwException" enabled throw the
+ * exception after trigger else return the result.
+ *
+ * @param string $eventName
+ * @param ArrayObject $args
+ * @param mixed $result
+ * @param \Exception $exception
+ * @throws Exception\ExceptionInterface
+ * @return mixed
+ */
+ protected function triggerException($eventName, ArrayObject $args, & $result, \Exception $exception)
+ {
+ $exceptionEvent = new ExceptionEvent($eventName . '.exception', $this, $args, $result, $exception);
+ $eventRs = $this->getEventManager()->trigger($exceptionEvent);
+
+ if ($exceptionEvent->getThrowException()) {
+ throw $exceptionEvent->getException();
+ }
+
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ return $exceptionEvent->getResult();
+ }
+
+ /**
+ * Check if a plugin is registered
+ *
+ * @param Plugin\PluginInterface $plugin
+ * @return bool
+ */
+ public function hasPlugin(Plugin\PluginInterface $plugin)
+ {
+ $registry = $this->getPluginRegistry();
+ return $registry->contains($plugin);
+ }
+
+ /**
+ * Register a plugin
+ *
+ * @param Plugin\PluginInterface $plugin
+ * @param int $priority
+ * @return AbstractAdapter Fluent interface
+ * @throws Exception\LogicException
+ */
+ public function addPlugin(Plugin\PluginInterface $plugin, $priority = 1)
+ {
+ $registry = $this->getPluginRegistry();
+ if ($registry->contains($plugin)) {
+ throw new Exception\LogicException(sprintf(
+ 'Plugin of type "%s" already registered',
+ get_class($plugin)
+ ));
+ }
+
+ $plugin->attach($this->getEventManager(), $priority);
+ $registry->attach($plugin);
+
+ return $this;
+ }
+
+ /**
+ * Unregister an already registered plugin
+ *
+ * @param Plugin\PluginInterface $plugin
+ * @return AbstractAdapter Fluent interface
+ * @throws Exception\LogicException
+ */
+ public function removePlugin(Plugin\PluginInterface $plugin)
+ {
+ $registry = $this->getPluginRegistry();
+ if ($registry->contains($plugin)) {
+ $plugin->detach($this->getEventManager());
+ $registry->detach($plugin);
+ }
+ return $this;
+ }
+
+ /**
+ * Return registry of plugins
+ *
+ * @return SplObjectStorage
+ */
+ public function getPluginRegistry()
+ {
+ if (!$this->pluginRegistry instanceof SplObjectStorage) {
+ $this->pluginRegistry = new SplObjectStorage();
+ }
+ return $this->pluginRegistry;
+ }
+
+ /* reading */
+
+ /**
+ * Get an item.
+ *
+ * @param string $key
+ * @param bool $success
+ * @param mixed $casToken
+ * @return mixed Data on success, null on failure
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers getItem.pre(PreEvent)
+ * @triggers getItem.post(PostEvent)
+ * @triggers getItem.exception(ExceptionEvent)
+ */
+ public function getItem($key, & $success = null, & $casToken = null)
+ {
+ if (!$this->getOptions()->getReadable()) {
+ $success = false;
+ return null;
+ }
+
+ $this->normalizeKey($key);
+
+ $argn = func_num_args();
+ $args = array(
+ 'key' => & $key,
+ );
+ if ($argn > 1) {
+ $args['success'] = & $success;
+ }
+ if ($argn > 2) {
+ $args['casToken'] = & $casToken;
+ }
+ $args = new ArrayObject($args);
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ if ($args->offsetExists('success') && $args->offsetExists('casToken')) {
+ $result = $this->internalGetItem($args['key'], $args['success'], $args['casToken']);
+ } elseif ($args->offsetExists('success')) {
+ $result = $this->internalGetItem($args['key'], $args['success']);
+ } else {
+ $result = $this->internalGetItem($args['key']);
+ }
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = false;
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to get an item.
+ *
+ * @param string $normalizedKey
+ * @param bool $success
+ * @param mixed $casToken
+ * @return mixed Data on success, null on failure
+ * @throws Exception\ExceptionInterface
+ */
+ abstract protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null);
+
+ /**
+ * Get multiple items.
+ *
+ * @param array $keys
+ * @return array Associative array of keys and values
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers getItems.pre(PreEvent)
+ * @triggers getItems.post(PostEvent)
+ * @triggers getItems.exception(ExceptionEvent)
+ */
+ public function getItems(array $keys)
+ {
+ if (!$this->getOptions()->getReadable()) {
+ return array();
+ }
+
+ $this->normalizeKeys($keys);
+ $args = new ArrayObject(array(
+ 'keys' => & $keys,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalGetItems($args['keys']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = array();
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to get multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Associative array of keys and values
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItems(array & $normalizedKeys)
+ {
+ $success = null;
+ $result = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ $value = $this->internalGetItem($normalizedKey, $success);
+ if ($success) {
+ $result[$normalizedKey] = $value;
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Test if an item exists.
+ *
+ * @param string $key
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers hasItem.pre(PreEvent)
+ * @triggers hasItem.post(PostEvent)
+ * @triggers hasItem.exception(ExceptionEvent)
+ */
+ public function hasItem($key)
+ {
+ if (!$this->getOptions()->getReadable()) {
+ return false;
+ }
+
+ $this->normalizeKey($key);
+ $args = new ArrayObject(array(
+ 'key' => & $key,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalHasItem($args['key']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = false;
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to test if an item exists.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalHasItem(& $normalizedKey)
+ {
+ $success = null;
+ $this->internalGetItem($normalizedKey, $success);
+ return $success;
+ }
+
+ /**
+ * Test multiple items.
+ *
+ * @param array $keys
+ * @return array Array of found keys
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers hasItems.pre(PreEvent)
+ * @triggers hasItems.post(PostEvent)
+ * @triggers hasItems.exception(ExceptionEvent)
+ */
+ public function hasItems(array $keys)
+ {
+ if (!$this->getOptions()->getReadable()) {
+ return array();
+ }
+
+ $this->normalizeKeys($keys);
+ $args = new ArrayObject(array(
+ 'keys' => & $keys,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalHasItems($args['keys']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = array();
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to test multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Array of found keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalHasItems(array & $normalizedKeys)
+ {
+ $result = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ if ($this->internalHasItem($normalizedKey)) {
+ $result[] = $normalizedKey;
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * Get metadata of an item.
+ *
+ * @param string $key
+ * @return array|bool Metadata on success, false on failure
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers getMetadata.pre(PreEvent)
+ * @triggers getMetadata.post(PostEvent)
+ * @triggers getMetadata.exception(ExceptionEvent)
+ */
+ public function getMetadata($key)
+ {
+ if (!$this->getOptions()->getReadable()) {
+ return false;
+ }
+
+ $this->normalizeKey($key);
+ $args = new ArrayObject(array(
+ 'key' => & $key,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalGetMetadata($args['key']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = false;
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to get metadata of an item.
+ *
+ * @param string $normalizedKey
+ * @return array|bool Metadata on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetMetadata(& $normalizedKey)
+ {
+ if (!$this->internalHasItem($normalizedKey)) {
+ return false;
+ }
+
+ return array();
+ }
+
+ /**
+ * Get multiple metadata
+ *
+ * @param array $keys
+ * @return array Associative array of keys and metadata
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers getMetadatas.pre(PreEvent)
+ * @triggers getMetadatas.post(PostEvent)
+ * @triggers getMetadatas.exception(ExceptionEvent)
+ */
+ public function getMetadatas(array $keys)
+ {
+ if (!$this->getOptions()->getReadable()) {
+ return array();
+ }
+
+ $this->normalizeKeys($keys);
+ $args = new ArrayObject(array(
+ 'keys' => & $keys,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalGetMetadatas($args['keys']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = array();
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to get multiple metadata
+ *
+ * @param array $normalizedKeys
+ * @return array Associative array of keys and metadata
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetMetadatas(array & $normalizedKeys)
+ {
+ $result = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ $metadata = $this->internalGetMetadata($normalizedKey);
+ if ($metadata !== false) {
+ $result[$normalizedKey] = $metadata;
+ }
+ }
+ return $result;
+ }
+
+ /* writing */
+
+ /**
+ * Store an item.
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers setItem.pre(PreEvent)
+ * @triggers setItem.post(PostEvent)
+ * @triggers setItem.exception(ExceptionEvent)
+ */
+ public function setItem($key, $value)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return false;
+ }
+
+ $this->normalizeKey($key);
+ $args = new ArrayObject(array(
+ 'key' => & $key,
+ 'value' => & $value,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalSetItem($args['key'], $args['value']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = false;
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to store an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ abstract protected function internalSetItem(& $normalizedKey, & $value);
+
+ /**
+ * Store multiple items.
+ *
+ * @param array $keyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers setItems.pre(PreEvent)
+ * @triggers setItems.post(PostEvent)
+ * @triggers setItems.exception(ExceptionEvent)
+ */
+ public function setItems(array $keyValuePairs)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return array_keys($keyValuePairs);
+ }
+
+ $this->normalizeKeyValuePairs($keyValuePairs);
+ $args = new ArrayObject(array(
+ 'keyValuePairs' => & $keyValuePairs,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalSetItems($args['keyValuePairs']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = array_keys($keyValuePairs);
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to store multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItems(array & $normalizedKeyValuePairs)
+ {
+ $failedKeys = array();
+ foreach ($normalizedKeyValuePairs as $normalizedKey => $value) {
+ if (!$this->internalSetItem($normalizedKey, $value)) {
+ $failedKeys[] = $normalizedKey;
+ }
+ }
+ return $failedKeys;
+ }
+
+ /**
+ * Add an item.
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers addItem.pre(PreEvent)
+ * @triggers addItem.post(PostEvent)
+ * @triggers addItem.exception(ExceptionEvent)
+ */
+ public function addItem($key, $value)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return false;
+ }
+
+ $this->normalizeKey($key);
+ $args = new ArrayObject(array(
+ 'key' => & $key,
+ 'value' => & $value,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalAddItem($args['key'], $args['value']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = false;
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to add an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalAddItem(& $normalizedKey, & $value)
+ {
+ if ($this->internalHasItem($normalizedKey)) {
+ return false;
+ }
+ return $this->internalSetItem($normalizedKey, $value);
+ }
+
+ /**
+ * Add multiple items.
+ *
+ * @param array $keyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers addItems.pre(PreEvent)
+ * @triggers addItems.post(PostEvent)
+ * @triggers addItems.exception(ExceptionEvent)
+ */
+ public function addItems(array $keyValuePairs)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return array_keys($keyValuePairs);
+ }
+
+ $this->normalizeKeyValuePairs($keyValuePairs);
+ $args = new ArrayObject(array(
+ 'keyValuePairs' => & $keyValuePairs,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalAddItems($args['keyValuePairs']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = array_keys($keyValuePairs);
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to add multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalAddItems(array & $normalizedKeyValuePairs)
+ {
+ $result = array();
+ foreach ($normalizedKeyValuePairs as $normalizedKey => $value) {
+ if (!$this->internalAddItem($normalizedKey, $value)) {
+ $result[] = $normalizedKey;
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * Replace an existing item.
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers replaceItem.pre(PreEvent)
+ * @triggers replaceItem.post(PostEvent)
+ * @triggers replaceItem.exception(ExceptionEvent)
+ */
+ public function replaceItem($key, $value)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return false;
+ }
+
+ $this->normalizeKey($key);
+ $args = new ArrayObject(array(
+ 'key' => & $key,
+ 'value' => & $value,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalReplaceItem($args['key'], $args['value']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = false;
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to replace an existing item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalReplaceItem(& $normalizedKey, & $value)
+ {
+ if (!$this->internalhasItem($normalizedKey)) {
+ return false;
+ }
+
+ return $this->internalSetItem($normalizedKey, $value);
+ }
+
+ /**
+ * Replace multiple existing items.
+ *
+ * @param array $keyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers replaceItems.pre(PreEvent)
+ * @triggers replaceItems.post(PostEvent)
+ * @triggers replaceItems.exception(ExceptionEvent)
+ */
+ public function replaceItems(array $keyValuePairs)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return array_keys($keyValuePairs);
+ }
+
+ $this->normalizeKeyValuePairs($keyValuePairs);
+ $args = new ArrayObject(array(
+ 'keyValuePairs' => & $keyValuePairs,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalReplaceItems($args['keyValuePairs']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = array_keys($keyValuePairs);
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to replace multiple existing items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalReplaceItems(array & $normalizedKeyValuePairs)
+ {
+ $result = array();
+ foreach ($normalizedKeyValuePairs as $normalizedKey => $value) {
+ if (!$this->internalReplaceItem($normalizedKey, $value)) {
+ $result[] = $normalizedKey;
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * Set an item only if token matches
+ *
+ * It uses the token received from getItem() to check if the item has
+ * changed before overwriting it.
+ *
+ * @param mixed $token
+ * @param string $key
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ * @see getItem()
+ * @see setItem()
+ */
+ public function checkAndSetItem($token, $key, $value)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return false;
+ }
+
+ $this->normalizeKey($key);
+ $args = new ArrayObject(array(
+ 'token' => & $token,
+ 'key' => & $key,
+ 'value' => & $value,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalCheckAndSetItem($args['token'], $args['key'], $args['value']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = false;
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to set an item only if token matches
+ *
+ * @param mixed $token
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ * @see getItem()
+ * @see setItem()
+ */
+ protected function internalCheckAndSetItem(& $token, & $normalizedKey, & $value)
+ {
+ $oldValue = $this->internalGetItem($normalizedKey);
+ if ($oldValue !== $token) {
+ return false;
+ }
+
+ return $this->internalSetItem($normalizedKey, $value);
+ }
+
+ /**
+ * Reset lifetime of an item
+ *
+ * @param string $key
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers touchItem.pre(PreEvent)
+ * @triggers touchItem.post(PostEvent)
+ * @triggers touchItem.exception(ExceptionEvent)
+ */
+ public function touchItem($key)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return false;
+ }
+
+ $this->normalizeKey($key);
+ $args = new ArrayObject(array(
+ 'key' => & $key,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalTouchItem($args['key']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = false;
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to reset lifetime of an item
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalTouchItem(& $normalizedKey)
+ {
+ $success = null;
+ $value = $this->internalGetItem($normalizedKey, $success);
+ if (!$success) {
+ return false;
+ }
+
+ return $this->internalReplaceItem($normalizedKey, $value);
+ }
+
+ /**
+ * Reset lifetime of multiple items.
+ *
+ * @param array $keys
+ * @return array Array of not updated keys
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers touchItems.pre(PreEvent)
+ * @triggers touchItems.post(PostEvent)
+ * @triggers touchItems.exception(ExceptionEvent)
+ */
+ public function touchItems(array $keys)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return $keys;
+ }
+
+ $this->normalizeKeys($keys);
+ $args = new ArrayObject(array(
+ 'keys' => & $keys,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalTouchItems($args['keys']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ return $this->triggerException(__FUNCTION__, $args, $keys, $e);
+ }
+ }
+
+ /**
+ * Internal method to reset lifetime of multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Array of not updated keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalTouchItems(array & $normalizedKeys)
+ {
+ $result = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ if (!$this->internalTouchItem($normalizedKey)) {
+ $result[] = $normalizedKey;
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * Remove an item.
+ *
+ * @param string $key
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers removeItem.pre(PreEvent)
+ * @triggers removeItem.post(PostEvent)
+ * @triggers removeItem.exception(ExceptionEvent)
+ */
+ public function removeItem($key)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return false;
+ }
+
+ $this->normalizeKey($key);
+ $args = new ArrayObject(array(
+ 'key' => & $key,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalRemoveItem($args['key']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = false;
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to remove an item.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ abstract protected function internalRemoveItem(& $normalizedKey);
+
+ /**
+ * Remove multiple items.
+ *
+ * @param array $keys
+ * @return array Array of not removed keys
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers removeItems.pre(PreEvent)
+ * @triggers removeItems.post(PostEvent)
+ * @triggers removeItems.exception(ExceptionEvent)
+ */
+ public function removeItems(array $keys)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return $keys;
+ }
+
+ $this->normalizeKeys($keys);
+ $args = new ArrayObject(array(
+ 'keys' => & $keys,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalRemoveItems($args['keys']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ return $this->triggerException(__FUNCTION__, $args, $keys, $e);
+ }
+ }
+
+ /**
+ * Internal method to remove multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Array of not removed keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalRemoveItems(array & $normalizedKeys)
+ {
+ $result = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ if (!$this->internalRemoveItem($normalizedKey)) {
+ $result[] = $normalizedKey;
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * Increment an item.
+ *
+ * @param string $key
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers incrementItem.pre(PreEvent)
+ * @triggers incrementItem.post(PostEvent)
+ * @triggers incrementItem.exception(ExceptionEvent)
+ */
+ public function incrementItem($key, $value)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return false;
+ }
+
+ $this->normalizeKey($key);
+ $args = new ArrayObject(array(
+ 'key' => & $key,
+ 'value' => & $value,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalIncrementItem($args['key'], $args['value']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = false;
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to increment an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalIncrementItem(& $normalizedKey, & $value)
+ {
+ $success = null;
+ $value = (int) $value;
+ $get = (int) $this->internalGetItem($normalizedKey, $success);
+ $newValue = $get + $value;
+
+ if ($success) {
+ $this->internalReplaceItem($normalizedKey, $newValue);
+ } else {
+ $this->internalAddItem($normalizedKey, $newValue);
+ }
+
+ return $newValue;
+ }
+
+ /**
+ * Increment multiple items.
+ *
+ * @param array $keyValuePairs
+ * @return array Associative array of keys and new values
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers incrementItems.pre(PreEvent)
+ * @triggers incrementItems.post(PostEvent)
+ * @triggers incrementItems.exception(ExceptionEvent)
+ */
+ public function incrementItems(array $keyValuePairs)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return array();
+ }
+
+ $this->normalizeKeyValuePairs($keyValuePairs);
+ $args = new ArrayObject(array(
+ 'keyValuePairs' => & $keyValuePairs,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalIncrementItems($args['keyValuePairs']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = array();
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to increment multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Associative array of keys and new values
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalIncrementItems(array & $normalizedKeyValuePairs)
+ {
+ $result = array();
+ foreach ($normalizedKeyValuePairs as $normalizedKey => $value) {
+ $newValue = $this->internalIncrementItem($normalizedKey, $value);
+ if ($newValue !== false) {
+ $result[$normalizedKey] = $newValue;
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * Decrement an item.
+ *
+ * @param string $key
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers decrementItem.pre(PreEvent)
+ * @triggers decrementItem.post(PostEvent)
+ * @triggers decrementItem.exception(ExceptionEvent)
+ */
+ public function decrementItem($key, $value)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return false;
+ }
+
+ $this->normalizeKey($key);
+ $args = new ArrayObject(array(
+ 'key' => & $key,
+ 'value' => & $value,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalDecrementItem($args['key'], $args['value']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = false;
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to decrement an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalDecrementItem(& $normalizedKey, & $value)
+ {
+ $success = null;
+ $value = (int) $value;
+ $get = (int) $this->internalGetItem($normalizedKey, $success);
+ $newValue = $get - $value;
+
+ if ($success) {
+ $this->internalReplaceItem($normalizedKey, $newValue);
+ } else {
+ $this->internalAddItem($normalizedKey, $newValue);
+ }
+
+ return $newValue;
+ }
+
+ /**
+ * Decrement multiple items.
+ *
+ * @param array $keyValuePairs
+ * @return array Associative array of keys and new values
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers incrementItems.pre(PreEvent)
+ * @triggers incrementItems.post(PostEvent)
+ * @triggers incrementItems.exception(ExceptionEvent)
+ */
+ public function decrementItems(array $keyValuePairs)
+ {
+ if (!$this->getOptions()->getWritable()) {
+ return array();
+ }
+
+ $this->normalizeKeyValuePairs($keyValuePairs);
+ $args = new ArrayObject(array(
+ 'keyValuePairs' => & $keyValuePairs,
+ ));
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalDecrementItems($args['keyValuePairs']);
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = array();
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to decrement multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Associative array of keys and new values
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalDecrementItems(array & $normalizedKeyValuePairs)
+ {
+ $result = array();
+ foreach ($normalizedKeyValuePairs as $normalizedKey => $value) {
+ $newValue = $this->decrementItem($normalizedKey, $value);
+ if ($newValue !== false) {
+ $result[$normalizedKey] = $newValue;
+ }
+ }
+ return $result;
+ }
+
+ /* status */
+
+ /**
+ * Get capabilities of this adapter
+ *
+ * @return Capabilities
+ * @triggers getCapabilities.pre(PreEvent)
+ * @triggers getCapabilities.post(PostEvent)
+ * @triggers getCapabilities.exception(ExceptionEvent)
+ */
+ public function getCapabilities()
+ {
+ $args = new ArrayObject();
+
+ try {
+ $eventRs = $this->triggerPre(__FUNCTION__, $args);
+ if ($eventRs->stopped()) {
+ return $eventRs->last();
+ }
+
+ $result = $this->internalGetCapabilities();
+ return $this->triggerPost(__FUNCTION__, $args, $result);
+ } catch (\Exception $e) {
+ $result = false;
+ return $this->triggerException(__FUNCTION__, $args, $result, $e);
+ }
+ }
+
+ /**
+ * Internal method to get capabilities of this adapter
+ *
+ * @return Capabilities
+ */
+ protected function internalGetCapabilities()
+ {
+ if ($this->capabilities === null) {
+ $this->capabilityMarker = new stdClass();
+ $this->capabilities = new Capabilities($this, $this->capabilityMarker);
+ }
+ return $this->capabilities;
+ }
+
+ /* internal */
+
+ /**
+ * Validates and normalizes a key
+ *
+ * @param string $key
+ * @return void
+ * @throws Exception\InvalidArgumentException On an invalid key
+ */
+ protected function normalizeKey(& $key)
+ {
+ $key = (string) $key;
+
+ if ($key === '') {
+ throw new Exception\InvalidArgumentException(
+ "An empty key isn't allowed"
+ );
+ } elseif (($p = $this->getOptions()->getKeyPattern()) && !preg_match($p, $key)) {
+ throw new Exception\InvalidArgumentException(
+ "The key '{$key}' doesn't match agains pattern '{$p}'"
+ );
+ }
+ }
+
+ /**
+ * Validates and normalizes multiple keys
+ *
+ * @param array $keys
+ * @return void
+ * @throws Exception\InvalidArgumentException On an invalid key
+ */
+ protected function normalizeKeys(array & $keys)
+ {
+ if (!$keys) {
+ throw new Exception\InvalidArgumentException(
+ "An empty list of keys isn't allowed"
+ );
+ }
+
+ array_walk($keys, array($this, 'normalizeKey'));
+ $keys = array_values(array_unique($keys));
+ }
+
+ /**
+ * Validates and normalizes an array of key-value pairs
+ *
+ * @param array $keyValuePairs
+ * @return void
+ * @throws Exception\InvalidArgumentException On an invalid key
+ */
+ protected function normalizeKeyValuePairs(array & $keyValuePairs)
+ {
+ $normalizedKeyValuePairs = array();
+ foreach ($keyValuePairs as $key => $value) {
+ $this->normalizeKey($key);
+ $normalizedKeyValuePairs[$key] = $value;
+ }
+ $keyValuePairs = $normalizedKeyValuePairs;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/AbstractZendServer.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/AbstractZendServer.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/AbstractZendServer.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/AbstractZendServer.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,273 @@
+getOptions()->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . self::NAMESPACE_SEPARATOR;
+
+ $result = $this->zdcFetch($prefix . $normalizedKey);
+ if ($result === null) {
+ $success = false;
+ } else {
+ $success = true;
+ $casToken = $result;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to get multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Associative array of keys and values
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItems(array & $normalizedKeys)
+ {
+ $namespace = $this->getOptions()->getNamespace();
+ if ($namespace === '') {
+ return $this->zdcFetchMulti($normalizedKeys);
+ }
+
+ $prefix = $namespace . self::NAMESPACE_SEPARATOR;
+ $internalKeys = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ $internalKeys[] = $prefix . $normalizedKey;
+ }
+
+ $fetch = $this->zdcFetchMulti($internalKeys);
+ $result = array();
+ $prefixL = strlen($prefix);
+ foreach ($fetch as $k => & $v) {
+ $result[substr($k, $prefixL)] = $v;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to test if an item exists.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalHasItem(& $normalizedKey)
+ {
+ $namespace = $this->getOptions()->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . self::NAMESPACE_SEPARATOR;
+ return ($this->zdcFetch($prefix . $normalizedKey) !== false);
+ }
+
+ /**
+ * Internal method to test multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Array of found keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalHasItems(array & $normalizedKeys)
+ {
+ $namespace = $this->getOptions()->getNamespace();
+ if ($namespace === '') {
+ return array_keys($this->zdcFetchMulti($normalizedKeys));
+ }
+
+ $prefix = $namespace . self::NAMESPACE_SEPARATOR;
+ $internalKeys = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ $internalKeys[] = $prefix . $normalizedKey;
+ }
+
+ $fetch = $this->zdcFetchMulti($internalKeys);
+ $result = array();
+ $prefixL = strlen($prefix);
+ foreach ($fetch as $internalKey => & $value) {
+ $result[] = substr($internalKey, $prefixL);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Get metadata for multiple items
+ *
+ * @param array $normalizedKeys
+ * @return array Associative array of keys and metadata
+ *
+ * @triggers getMetadatas.pre(PreEvent)
+ * @triggers getMetadatas.post(PostEvent)
+ * @triggers getMetadatas.exception(ExceptionEvent)
+ */
+ protected function internalGetMetadatas(array & $normalizedKeys)
+ {
+ $namespace = $this->getOptions()->getNamespace();
+ if ($namespace === '') {
+ $result = $this->zdcFetchMulti($normalizedKeys);
+ return array_fill_keys(array_keys($result), array());
+ }
+
+ $prefix = $namespace . self::NAMESPACE_SEPARATOR;
+ $internalKeys = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ $internalKeys[] = $prefix . $normalizedKey;
+ }
+
+ $fetch = $this->zdcFetchMulti($internalKeys);
+ $result = array();
+ $prefixL = strlen($prefix);
+ foreach ($fetch as $internalKey => $value) {
+ $result[substr($internalKey, $prefixL)] = array();
+ }
+
+ return $result;
+ }
+
+ /* writing */
+
+ /**
+ * Internal method to store an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . self::NAMESPACE_SEPARATOR;
+ $this->zdcStore($prefix . $normalizedKey, $value, $options->getTtl());
+ return true;
+ }
+
+ /**
+ * Internal method to remove an item.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalRemoveItem(& $normalizedKey)
+ {
+ $namespace = $this->getOptions()->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . self::NAMESPACE_SEPARATOR;
+ return $this->zdcDelete($prefix . $normalizedKey);
+ }
+
+ /* status */
+
+ /**
+ * Internal method to get capabilities of this adapter
+ *
+ * @return Capabilities
+ */
+ protected function internalGetCapabilities()
+ {
+ if ($this->capabilities === null) {
+ $this->capabilityMarker = new stdClass();
+ $this->capabilities = new Capabilities(
+ $this,
+ $this->capabilityMarker,
+ array(
+ 'supportedDatatypes' => array(
+ 'NULL' => true,
+ 'boolean' => true,
+ 'integer' => true,
+ 'double' => true,
+ 'string' => true,
+ 'array' => true,
+ 'object' => 'object',
+ 'resource' => false,
+ ),
+ 'supportedMetadata' => array(),
+ 'maxTtl' => 0,
+ 'staticTtl' => true,
+ 'ttlPrecision' => 1,
+ 'useRequestTime' => false,
+ 'expiredRead' => false,
+ 'maxKeyLength' => 0,
+ 'namespaceIsPrefix' => true,
+ 'namespaceSeparator' => self::NAMESPACE_SEPARATOR,
+ )
+ );
+ }
+
+ return $this->capabilities;
+ }
+
+ /* internal wrapper of zend_[disk|shm]_cache_* functions */
+
+ /**
+ * Store data into Zend Data Cache (zdc)
+ *
+ * @param string $internalKey
+ * @param mixed $value
+ * @param int $ttl
+ * @return void
+ * @throws Exception\RuntimeException
+ */
+ abstract protected function zdcStore($internalKey, $value, $ttl);
+
+ /**
+ * Fetch a single item from Zend Data Cache (zdc)
+ *
+ * @param string $internalKey
+ * @return mixed The stored value or FALSE if item wasn't found
+ * @throws Exception\RuntimeException
+ */
+ abstract protected function zdcFetch($internalKey);
+
+ /**
+ * Fetch multiple items from Zend Data Cache (zdc)
+ *
+ * @param array $internalKeys
+ * @return array All found items
+ * @throws Exception\RuntimeException
+ */
+ abstract protected function zdcFetchMulti(array $internalKeys);
+
+ /**
+ * Delete data from Zend Data Cache (zdc)
+ *
+ * @param string $internalKey
+ * @return bool
+ * @throws Exception\RuntimeException
+ */
+ abstract protected function zdcDelete($internalKey);
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/AdapterOptions.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/AdapterOptions.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/AdapterOptions.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/AdapterOptions.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,265 @@
+adapter = $adapter;
+ return $this;
+ }
+
+ /**
+ * Set key pattern
+ *
+ * @param null|string $keyPattern
+ * @throws Exception\InvalidArgumentException
+ * @return AdapterOptions
+ */
+ public function setKeyPattern($keyPattern)
+ {
+ $keyPattern = (string) $keyPattern;
+ if ($this->keyPattern !== $keyPattern) {
+ // validate pattern
+ if ($keyPattern !== '') {
+ ErrorHandler::start(E_WARNING);
+ $result = preg_match($keyPattern, '');
+ $error = ErrorHandler::stop();
+ if ($result === false) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Invalid pattern "%s"%s',
+ $keyPattern,
+ ($error ? ': ' . $error->getMessage() : '')
+ ), 0, $error);
+ }
+ }
+
+ $this->triggerOptionEvent('key_pattern', $keyPattern);
+ $this->keyPattern = $keyPattern;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get key pattern
+ *
+ * @return string
+ */
+ public function getKeyPattern()
+ {
+ return $this->keyPattern;
+ }
+
+ /**
+ * Set namespace.
+ *
+ * @param string $namespace
+ * @return AdapterOptions
+ */
+ public function setNamespace($namespace)
+ {
+ $namespace = (string) $namespace;
+ if ($this->namespace !== $namespace) {
+ $this->triggerOptionEvent('namespace', $namespace);
+ $this->namespace = $namespace;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get namespace
+ *
+ * @return string
+ */
+ public function getNamespace()
+ {
+ return $this->namespace;
+ }
+
+ /**
+ * Enable/Disable reading data from cache.
+ *
+ * @param bool $readable
+ * @return AbstractAdapter
+ */
+ public function setReadable($readable)
+ {
+ $readable = (bool) $readable;
+ if ($this->readable !== $readable) {
+ $this->triggerOptionEvent('readable', $readable);
+ $this->readable = $readable;
+ }
+ return $this;
+ }
+
+ /**
+ * If reading data from cache enabled.
+ *
+ * @return bool
+ */
+ public function getReadable()
+ {
+ return $this->readable;
+ }
+
+ /**
+ * Set time to live.
+ *
+ * @param int|float $ttl
+ * @return AdapterOptions
+ */
+ public function setTtl($ttl)
+ {
+ $this->normalizeTtl($ttl);
+ if ($this->ttl !== $ttl) {
+ $this->triggerOptionEvent('ttl', $ttl);
+ $this->ttl = $ttl;
+ }
+ return $this;
+ }
+
+ /**
+ * Get time to live.
+ *
+ * @return float
+ */
+ public function getTtl()
+ {
+ return $this->ttl;
+ }
+
+ /**
+ * Enable/Disable writing data to cache.
+ *
+ * @param bool $writable
+ * @return AdapterOptions
+ */
+ public function setWritable($writable)
+ {
+ $writable = (bool) $writable;
+ if ($this->writable !== $writable) {
+ $this->triggerOptionEvent('writable', $writable);
+ $this->writable = $writable;
+ }
+ return $this;
+ }
+
+ /**
+ * If writing data to cache enabled.
+ *
+ * @return bool
+ */
+ public function getWritable()
+ {
+ return $this->writable;
+ }
+
+ /**
+ * Triggers an option event if this options instance has a connection to
+ * an adapter implements EventsCapableInterface.
+ *
+ * @param string $optionName
+ * @param mixed $optionValue
+ * @return void
+ */
+ protected function triggerOptionEvent($optionName, $optionValue)
+ {
+ if ($this->adapter instanceof EventsCapableInterface) {
+ $event = new Event('option', $this->adapter, new ArrayObject(array($optionName => $optionValue)));
+ $this->adapter->getEventManager()->trigger($event);
+ }
+ }
+
+ /**
+ * Validates and normalize a TTL.
+ *
+ * @param int|float $ttl
+ * @throws Exception\InvalidArgumentException
+ * @return void
+ */
+ protected function normalizeTtl(&$ttl)
+ {
+ if (!is_int($ttl)) {
+ $ttl = (float) $ttl;
+
+ // convert to int if possible
+ if ($ttl === (float) (int) $ttl) {
+ $ttl = (int) $ttl;
+ }
+ }
+
+ if ($ttl < 0) {
+ throw new Exception\InvalidArgumentException("TTL can't be negative");
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/ApcIterator.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/ApcIterator.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/ApcIterator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/ApcIterator.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,158 @@
+storage = $storage;
+ $this->baseIterator = $baseIterator;
+ $this->prefixLength = strlen($prefix);
+ }
+
+ /**
+ * Get storage instance
+ *
+ * @return Apc
+ */
+ public function getStorage()
+ {
+ return $this->storage;
+ }
+
+ /**
+ * Get iterator mode
+ *
+ * @return int Value of IteratorInterface::CURRENT_AS_*
+ */
+ public function getMode()
+ {
+ return $this->mode;
+ }
+
+ /**
+ * Set iterator mode
+ *
+ * @param int $mode
+ * @return ApcIterator Fluent interface
+ */
+ public function setMode($mode)
+ {
+ $this->mode = (int) $mode;
+ return $this;
+ }
+
+ /* Iterator */
+
+ /**
+ * Get current key, value or metadata.
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ if ($this->mode == IteratorInterface::CURRENT_AS_SELF) {
+ return $this;
+ }
+
+ $key = $this->key();
+
+ if ($this->mode == IteratorInterface::CURRENT_AS_VALUE) {
+ return $this->storage->getItem($key);
+ } elseif ($this->mode == IteratorInterface::CURRENT_AS_METADATA) {
+ return $this->storage->getMetadata($key);
+ }
+
+ return $key;
+ }
+
+ /**
+ * Get current key
+ *
+ * @return string
+ */
+ public function key()
+ {
+ $key = $this->baseIterator->key();
+
+ // remove namespace prefix
+ return substr($key, $this->prefixLength);
+ }
+
+ /**
+ * Move forward to next element
+ *
+ * @return void
+ */
+ public function next()
+ {
+ $this->baseIterator->next();
+ }
+
+ /**
+ * Checks if current position is valid
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return $this->baseIterator->valid();
+ }
+
+ /**
+ * Rewind the Iterator to the first element.
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ return $this->baseIterator->rewind();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/ApcOptions.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/ApcOptions.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/ApcOptions.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/ApcOptions.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,47 @@
+triggerOptionEvent('namespace_separator', $namespaceSeparator);
+ $this->namespaceSeparator = $namespaceSeparator;
+ return $this;
+ }
+
+ /**
+ * Get namespace separator
+ *
+ * @return string
+ */
+ public function getNamespaceSeparator()
+ {
+ return $this->namespaceSeparator;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Apc.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Apc.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Apc.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Apc.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,736 @@
+ 0) {
+ throw new Exception\ExtensionNotLoadedException("Missing ext/apc >= 3.1.6");
+ }
+
+ $enabled = ini_get('apc.enabled');
+ if (PHP_SAPI == 'cli') {
+ $enabled = $enabled && (bool) ini_get('apc.enable_cli');
+ }
+
+ if (!$enabled) {
+ throw new Exception\ExtensionNotLoadedException(
+ "ext/apc is disabled - see 'apc.enabled' and 'apc.enable_cli'"
+ );
+ }
+
+ parent::__construct($options);
+ }
+
+ /* options */
+
+ /**
+ * Set options.
+ *
+ * @param array|Traversable|ApcOptions $options
+ * @return Apc
+ * @see getOptions()
+ */
+ public function setOptions($options)
+ {
+ if (!$options instanceof ApcOptions) {
+ $options = new ApcOptions($options);
+ }
+
+ return parent::setOptions($options);
+ }
+
+ /**
+ * Get options.
+ *
+ * @return ApcOptions
+ * @see setOptions()
+ */
+ public function getOptions()
+ {
+ if (!$this->options) {
+ $this->setOptions(new ApcOptions());
+ }
+ return $this->options;
+ }
+
+ /* TotalSpaceCapableInterface */
+
+ /**
+ * Get total space in bytes
+ *
+ * @return int|float
+ */
+ public function getTotalSpace()
+ {
+ if ($this->totalSpace === null) {
+ $smaInfo = apc_sma_info(true);
+ $this->totalSpace = $smaInfo['num_seg'] * $smaInfo['seg_size'];
+ }
+
+ return $this->totalSpace;
+ }
+
+ /* AvailableSpaceCapableInterface */
+
+ /**
+ * Get available space in bytes
+ *
+ * @return int|float
+ */
+ public function getAvailableSpace()
+ {
+ $smaInfo = apc_sma_info(true);
+ return $smaInfo['avail_mem'];
+ }
+
+ /* IterableInterface */
+
+ /**
+ * Get the storage iterator
+ *
+ * @return ApcIterator
+ */
+ public function getIterator()
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = '';
+ $pattern = null;
+ if ($namespace !== '') {
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $pattern = '/^' . preg_quote($prefix, '/') . '/';
+ }
+
+ $baseIt = new BaseApcIterator('user', $pattern, 0, 1, APC_LIST_ACTIVE);
+ return new ApcIterator($this, $baseIt, $prefix);
+ }
+
+ /* FlushableInterface */
+
+ /**
+ * Flush the whole storage
+ *
+ * @return bool
+ */
+ public function flush()
+ {
+ return apc_clear_cache('user');
+ }
+
+ /* ClearByNamespaceInterface */
+
+ /**
+ * Remove items by given namespace
+ *
+ * @param string $namespace
+ * @return bool
+ */
+ public function clearByNamespace($namespace)
+ {
+ $namespace = (string) $namespace;
+ if ($namespace === '') {
+ throw new Exception\InvalidArgumentException('No namespace given');
+ }
+
+ $options = $this->getOptions();
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $pattern = '/^' . preg_quote($prefix, '/') . '/';
+ return apc_delete(new BaseApcIterator('user', $pattern, 0, 1, APC_LIST_ACTIVE));
+ }
+
+ /* ClearByPrefixInterface */
+
+ /**
+ * Remove items matching given prefix
+ *
+ * @param string $prefix
+ * @return bool
+ */
+ public function clearByPrefix($prefix)
+ {
+ $prefix = (string) $prefix;
+ if ($prefix === '') {
+ throw new Exception\InvalidArgumentException('No prefix given');
+ }
+
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $nsPrefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $pattern = '/^' . preg_quote($nsPrefix . $prefix, '/') . '/';
+ return apc_delete(new BaseApcIterator('user', $pattern, 0, 1, APC_LIST_ACTIVE));
+ }
+
+ /* reading */
+
+ /**
+ * Internal method to get an item.
+ *
+ * @param string $normalizedKey
+ * @param bool $success
+ * @param mixed $casToken
+ * @return mixed Data on success, null on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ $result = apc_fetch($internalKey, $success);
+
+ if (!$success) {
+ return null;
+ }
+
+ $casToken = $result;
+ return $result;
+ }
+
+ /**
+ * Internal method to get multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Associative array of keys and values
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItems(array & $normalizedKeys)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ if ($namespace === '') {
+ return apc_fetch($normalizedKeys);
+ }
+
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $internalKeys = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ $internalKeys[] = $prefix . $normalizedKey;
+ }
+
+ $fetch = apc_fetch($internalKeys);
+
+ // remove namespace prefix
+ $prefixL = strlen($prefix);
+ $result = array();
+ foreach ($fetch as $internalKey => & $value) {
+ $result[substr($internalKey, $prefixL)] = $value;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to test if an item exists.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalHasItem(& $normalizedKey)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ return apc_exists($prefix . $normalizedKey);
+ }
+
+ /**
+ * Internal method to test multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Array of found keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalHasItems(array & $normalizedKeys)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ if ($namespace === '') {
+ // array_filter with no callback will remove entries equal to FALSE
+ return array_keys(array_filter(apc_exists($normalizedKeys)));
+ }
+
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $internalKeys = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ $internalKeys[] = $prefix . $normalizedKey;
+ }
+
+ $exists = apc_exists($internalKeys);
+ $result = array();
+ $prefixL = strlen($prefix);
+ foreach ($exists as $internalKey => $bool) {
+ if ($bool === true) {
+ $result[] = substr($internalKey, $prefixL);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Get metadata of an item.
+ *
+ * @param string $normalizedKey
+ * @return array|bool Metadata on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetMetadata(& $normalizedKey)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+
+ // @see http://pecl.php.net/bugs/bug.php?id=22564
+ if (!apc_exists($internalKey)) {
+ $metadata = false;
+ } else {
+ $format = APC_ITER_ALL ^ APC_ITER_VALUE ^ APC_ITER_TYPE ^ APC_ITER_REFCOUNT;
+ $regexp = '/^' . preg_quote($internalKey, '/') . '$/';
+ $it = new BaseApcIterator('user', $regexp, $format, 100, APC_LIST_ACTIVE);
+ $metadata = $it->current();
+ }
+
+ if (!$metadata) {
+ return false;
+ }
+
+ $this->normalizeMetadata($metadata);
+ return $metadata;
+ }
+
+ /**
+ * Get metadata of multiple items
+ *
+ * @param array $normalizedKeys
+ * @return array Associative array of keys and metadata
+ *
+ * @triggers getMetadatas.pre(PreEvent)
+ * @triggers getMetadatas.post(PostEvent)
+ * @triggers getMetadatas.exception(ExceptionEvent)
+ */
+ protected function internalGetMetadatas(array & $normalizedKeys)
+ {
+ $keysRegExp = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ $keysRegExp[] = preg_quote($normalizedKey, '/');
+ }
+
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ if ($namespace === '') {
+ $pattern = '/^(' . implode('|', $keysRegExp) . ')' . '$/';
+ } else {
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $pattern = '/^' . preg_quote($prefix, '/') . '(' . implode('|', $keysRegExp) . ')' . '$/';
+ }
+ $format = APC_ITER_ALL ^ APC_ITER_VALUE ^ APC_ITER_TYPE ^ APC_ITER_REFCOUNT;
+ $it = new BaseApcIterator('user', $pattern, $format, 100, APC_LIST_ACTIVE);
+ $result = array();
+ $prefixL = strlen($prefix);
+ foreach ($it as $internalKey => $metadata) {
+ // @see http://pecl.php.net/bugs/bug.php?id=22564
+ if (!apc_exists($internalKey)) {
+ continue;
+ }
+
+ $this->normalizeMetadata($metadata);
+ $result[substr($internalKey, $prefixL)] = & $metadata;
+ }
+
+ return $result;
+ }
+
+ /* writing */
+
+ /**
+ * Internal method to store an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ $ttl = $options->getTtl();
+
+ if (!apc_store($internalKey, $value, $ttl)) {
+ $type = is_object($value) ? get_class($value) : gettype($value);
+ throw new Exception\RuntimeException(
+ "apc_store('{$internalKey}', <{$type}>, {$ttl}) failed"
+ );
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to store multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItems(array & $normalizedKeyValuePairs)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ if ($namespace === '') {
+ return array_keys(apc_store($normalizedKeyValuePairs, null, $options->getTtl()));
+ }
+
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $internalKeyValuePairs = array();
+ foreach ($normalizedKeyValuePairs as $normalizedKey => &$value) {
+ $internalKey = $prefix . $normalizedKey;
+ $internalKeyValuePairs[$internalKey] = &$value;
+ }
+
+ $failedKeys = apc_store($internalKeyValuePairs, null, $options->getTtl());
+ $failedKeys = array_keys($failedKeys);
+
+ // remove prefix
+ $prefixL = strlen($prefix);
+ foreach ($failedKeys as & $key) {
+ $key = substr($key, $prefixL);
+ }
+
+ return $failedKeys;
+ }
+
+ /**
+ * Add an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalAddItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ $ttl = $options->getTtl();
+
+ if (!apc_add($internalKey, $value, $ttl)) {
+ if (apc_exists($internalKey)) {
+ return false;
+ }
+
+ $type = is_object($value) ? get_class($value) : gettype($value);
+ throw new Exception\RuntimeException(
+ "apc_add('{$internalKey}', <{$type}>, {$ttl}) failed"
+ );
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to add multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalAddItems(array & $normalizedKeyValuePairs)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ if ($namespace === '') {
+ return array_keys(apc_add($normalizedKeyValuePairs, null, $options->getTtl()));
+ }
+
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $internalKeyValuePairs = array();
+ foreach ($normalizedKeyValuePairs as $normalizedKey => $value) {
+ $internalKey = $prefix . $normalizedKey;
+ $internalKeyValuePairs[$internalKey] = $value;
+ }
+
+ $failedKeys = apc_add($internalKeyValuePairs, null, $options->getTtl());
+ $failedKeys = array_keys($failedKeys);
+
+ // remove prefix
+ $prefixL = strlen($prefix);
+ foreach ($failedKeys as & $key) {
+ $key = substr($key, $prefixL);
+ }
+
+ return $failedKeys;
+ }
+
+ /**
+ * Internal method to replace an existing item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalReplaceItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+
+ if (!apc_exists($internalKey)) {
+ return false;
+ }
+
+ $ttl = $options->getTtl();
+ if (!apc_store($internalKey, $value, $ttl)) {
+ $type = is_object($value) ? get_class($value) : gettype($value);
+ throw new Exception\RuntimeException(
+ "apc_store('{$internalKey}', <{$type}>, {$ttl}) failed"
+ );
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to remove an item.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalRemoveItem(& $normalizedKey)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ return apc_delete($prefix . $normalizedKey);
+ }
+
+ /**
+ * Internal method to remove multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Array of not removed keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalRemoveItems(array & $normalizedKeys)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ if ($namespace === '') {
+ return apc_delete($normalizedKeys);
+ }
+
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $internalKeys = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ $internalKeys[] = $prefix . $normalizedKey;
+ }
+
+ $failedKeys = apc_delete($internalKeys);
+
+ // remove prefix
+ $prefixL = strlen($prefix);
+ foreach ($failedKeys as & $key) {
+ $key = substr($key, $prefixL);
+ }
+
+ return $failedKeys;
+ }
+
+ /**
+ * Internal method to increment an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalIncrementItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ $value = (int) $value;
+ $newValue = apc_inc($internalKey, $value);
+
+ // initial value
+ if ($newValue === false) {
+ $ttl = $options->getTtl();
+ $newValue = $value;
+ if (!apc_add($internalKey, $newValue, $ttl)) {
+ throw new Exception\RuntimeException(
+ "apc_add('{$internalKey}', {$newValue}, {$ttl}) failed"
+ );
+ }
+ }
+
+ return $newValue;
+ }
+
+ /**
+ * Internal method to decrement an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalDecrementItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ $value = (int) $value;
+ $newValue = apc_dec($internalKey, $value);
+
+ // initial value
+ if ($newValue === false) {
+ $ttl = $options->getTtl();
+ $newValue = -$value;
+ if (!apc_add($internalKey, $newValue, $ttl)) {
+ throw new Exception\RuntimeException(
+ "apc_add('{$internalKey}', {$newValue}, {$ttl}) failed"
+ );
+ }
+ }
+
+ return $newValue;
+ }
+
+ /* status */
+
+ /**
+ * Internal method to get capabilities of this adapter
+ *
+ * @return Capabilities
+ */
+ protected function internalGetCapabilities()
+ {
+ if ($this->capabilities === null) {
+ $marker = new stdClass();
+ $capabilities = new Capabilities(
+ $this,
+ $marker,
+ array(
+ 'supportedDatatypes' => array(
+ 'NULL' => true,
+ 'boolean' => true,
+ 'integer' => true,
+ 'double' => true,
+ 'string' => true,
+ 'array' => true,
+ 'object' => 'object',
+ 'resource' => false,
+ ),
+ 'supportedMetadata' => array(
+ 'internal_key',
+ 'atime', 'ctime', 'mtime', 'rtime',
+ 'size', 'hits', 'ttl',
+ ),
+ 'minTtl' => 1,
+ 'maxTtl' => 0,
+ 'staticTtl' => true,
+ 'ttlPrecision' => 1,
+ 'useRequestTime' => (bool) ini_get('apc.use_request_time'),
+ 'expiredRead' => false,
+ 'maxKeyLength' => 5182,
+ 'namespaceIsPrefix' => true,
+ 'namespaceSeparator' => $this->getOptions()->getNamespaceSeparator(),
+ )
+ );
+
+ // update namespace separator on change option
+ $this->getEventManager()->attach('option', function ($event) use ($capabilities, $marker) {
+ $params = $event->getParams();
+
+ if (isset($params['namespace_separator'])) {
+ $capabilities->setNamespaceSeparator($marker, $params['namespace_separator']);
+ }
+ });
+
+ $this->capabilities = $capabilities;
+ $this->capabilityMarker = $marker;
+ }
+
+ return $this->capabilities;
+ }
+
+ /* internal */
+
+ /**
+ * Normalize metadata to work with APC
+ *
+ * @param array $metadata
+ * @return void
+ */
+ protected function normalizeMetadata(array & $metadata)
+ {
+ $metadata['internal_key'] = $metadata['key'];
+ $metadata['ctime'] = $metadata['creation_time'];
+ $metadata['atime'] = $metadata['access_time'];
+ $metadata['rtime'] = $metadata['deletion_time'];
+ $metadata['size'] = $metadata['mem_size'];
+ $metadata['hits'] = $metadata['num_hits'];
+
+ unset(
+ $metadata['key'],
+ $metadata['creation_time'],
+ $metadata['access_time'],
+ $metadata['deletion_time'],
+ $metadata['mem_size'],
+ $metadata['num_hits']
+ );
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/DbaIterator.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/DbaIterator.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/DbaIterator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/DbaIterator.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,190 @@
+storage = $storage;
+ $this->handle = $handle;
+ $this->prefixLength = strlen($prefix);
+
+ $this->rewind();
+ }
+
+ /**
+ * Get storage instance
+ *
+ * @return Dba
+ */
+ public function getStorage()
+ {
+ return $this->storage;
+ }
+
+ /**
+ * Get iterator mode
+ *
+ * @return int Value of IteratorInterface::CURRENT_AS_*
+ */
+ public function getMode()
+ {
+ return $this->mode;
+ }
+
+ /**
+ * Set iterator mode
+ *
+ * @param int $mode
+ * @return ApcIterator Fluent interface
+ */
+ public function setMode($mode)
+ {
+ $this->mode = (int) $mode;
+ return $this;
+ }
+
+ /* Iterator */
+
+ /**
+ * Get current key, value or metadata.
+ *
+ * @return mixed
+ * @throws Exception\RuntimeException
+ */
+ public function current()
+ {
+ if ($this->mode == IteratorInterface::CURRENT_AS_SELF) {
+ return $this;
+ }
+
+ $key = $this->key();
+
+ if ($this->mode == IteratorInterface::CURRENT_AS_VALUE) {
+ return $this->storage->getItem($key);
+ } elseif ($this->mode == IteratorInterface::CURRENT_AS_METADATA) {
+ return $this->storage->getMetadata($key);
+ }
+
+ return $key;
+ }
+
+ /**
+ * Get current key
+ *
+ * @return string
+ * @throws Exception\RuntimeException
+ */
+ public function key()
+ {
+ if ($this->currentInternalKey === false) {
+ throw new Exception\RuntimeException("Iterator is on an invalid state");
+ }
+
+ // remove namespace prefix
+ return substr($this->currentInternalKey, $this->prefixLength);
+ }
+
+ /**
+ * Move forward to next element
+ *
+ * @return void
+ * @throws Exception\RuntimeException
+ */
+ public function next()
+ {
+ if ($this->currentInternalKey === false) {
+ throw new Exception\RuntimeException("Iterator is on an invalid state");
+ }
+
+ $this->currentInternalKey = dba_nextkey($this->handle);
+
+ // Workaround for PHP-Bug #62492
+ if ($this->currentInternalKey === null) {
+ $this->currentInternalKey = false;
+ }
+ }
+
+ /**
+ * Checks if current position is valid
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return ($this->currentInternalKey !== false);
+ }
+
+ /**
+ * Rewind the Iterator to the first element.
+ *
+ * @return void
+ * @throws Exception\RuntimeException
+ */
+ public function rewind()
+ {
+ if ($this->currentInternalKey === false) {
+ throw new Exception\RuntimeException("Iterator is on an invalid state");
+ }
+
+ $this->currentInternalKey = dba_firstkey($this->handle);
+
+ // Workaround for PHP-Bug #62492
+ if ($this->currentInternalKey === null) {
+ $this->currentInternalKey = false;
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/DbaOptions.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/DbaOptions.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/DbaOptions.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/DbaOptions.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,129 @@
+triggerOptionEvent('namespace_separator', $namespaceSeparator);
+ $this->namespaceSeparator = $namespaceSeparator;
+ return $this;
+ }
+
+ /**
+ * Get namespace separator
+ *
+ * @return string
+ */
+ public function getNamespaceSeparator()
+ {
+ return $this->namespaceSeparator;
+ }
+
+ /**
+ * Set pathname to database file
+ *
+ * @param string $pathname
+ * @return DbaOptions
+ */
+ public function setPathname($pathname)
+ {
+ $this->pathname = (string) $pathname;
+ $this->triggerOptionEvent('pathname', $pathname);
+ return $this;
+ }
+
+ /**
+ * Get pathname to database file
+ *
+ * @return string
+ */
+ public function getPathname()
+ {
+ return $this->pathname;
+ }
+
+ /**
+ *
+ *
+ * @param string $mode
+ * @return \Zend\Cache\Storage\Adapter\DbaOptions
+ */
+ public function setMode($mode)
+ {
+ $this->mode = (string) $mode;
+ $this->triggerOptionEvent('mode', $mode);
+ return $this;
+ }
+
+ public function getMode()
+ {
+ return $this->mode;
+ }
+
+ public function setHandler($handler)
+ {
+ $handler = (string) $handler;
+
+ if (!function_exists('dba_handlers') || !in_array($handler, dba_handlers())) {
+ throw new Exception\ExtensionNotLoadedException("DBA-Handler '{$handler}' not supported");
+ }
+
+ $this->triggerOptionEvent('handler', $handler);
+ $this->handler = $handler;
+ return $this;
+ }
+
+ public function getHandler()
+ {
+ return $this->handler;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Dba.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Dba.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Dba.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Dba.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,540 @@
+_close();
+
+ parent::__destruct();
+ }
+
+ /* options */
+
+ /**
+ * Set options.
+ *
+ * @param array|Traversable|DbaOptions $options
+ * @return Apc
+ * @see getOptions()
+ */
+ public function setOptions($options)
+ {
+ if (!$options instanceof DbaOptions) {
+ $options = new DbaOptions($options);
+ }
+
+ return parent::setOptions($options);
+ }
+
+ /**
+ * Get options.
+ *
+ * @return DbaOptions
+ * @see setOptions()
+ */
+ public function getOptions()
+ {
+ if (!$this->options) {
+ $this->setOptions(new DbaOptions());
+ }
+ return $this->options;
+ }
+
+ /* TotalSpaceCapableInterface */
+
+ /**
+ * Get total space in bytes
+ *
+ * @return int|float
+ */
+ public function getTotalSpace()
+ {
+ if ($this->totalSpace === null) {
+ $pathname = $this->getOptions()->getPathname();
+
+ if ($pathname === '') {
+ throw new Exception\LogicException('No pathname to database file');
+ }
+
+ ErrorHandler::start();
+ $total = disk_total_space(dirname($pathname));
+ $error = ErrorHandler::stop();
+ if ($total === false) {
+ throw new Exception\RuntimeException("Can't detect total space of '{$pathname}'", 0, $error);
+ }
+ $this->totalSpace = $total;
+
+ // clean total space buffer on change pathname
+ $events = $this->getEventManager();
+ $handle = null;
+ $totalSpace = & $this->totalSpace;
+ $callback = function ($event) use (& $events, & $handle, & $totalSpace) {
+ $params = $event->getParams();
+ if (isset($params['pathname'])) {
+ $totalSpace = null;
+ $events->detach($handle);
+ }
+ };
+ $events->attach('option', $callback);
+ }
+
+ return $this->totalSpace;
+ }
+
+ /* AvailableSpaceCapableInterface */
+
+ /**
+ * Get available space in bytes
+ *
+ * @return int|float
+ */
+ public function getAvailableSpace()
+ {
+ $pathname = $this->getOptions()->getPathname();
+
+ if ($pathname === '') {
+ throw new Exception\LogicException('No pathname to database file');
+ }
+
+ ErrorHandler::start();
+ $avail = disk_free_space(dirname($pathname));
+ $error = ErrorHandler::stop();
+ if ($avail === false) {
+ throw new Exception\RuntimeException("Can't detect free space of '{$pathname}'", 0, $error);
+ }
+
+ return $avail;
+ }
+
+ /* FlushableInterface */
+
+ /**
+ * Flush the whole storage
+ *
+ * @return bool
+ */
+ public function flush()
+ {
+ $pathname = $this->getOptions()->getPathname();
+
+ if ($pathname === '') {
+ throw new Exception\LogicException('No pathname to database file');
+ }
+
+ if (file_exists($pathname)) {
+
+ // close the dba file before delete
+ // and reopen (create) on next use
+ $this->_close();
+
+ ErrorHandler::start();
+ $result = unlink($pathname);
+ $error = ErrorHandler::stop();
+ if (!$result) {
+ throw new Exception\RuntimeException("unlink('{$pathname}') failed", 0, $error);
+ }
+ }
+
+ return true;
+ }
+
+ /* ClearByNamespaceInterface */
+
+ /**
+ * Remove items by given namespace
+ *
+ * @param string $namespace
+ * @return bool
+ */
+ public function clearByNamespace($namespace)
+ {
+ $namespace = (string) $namespace;
+ if ($namespace === '') {
+ throw new Exception\InvalidArgumentException('No namespace given');
+ }
+
+ $prefix = $namespace . $this->getOptions()->getNamespaceSeparator();
+ $prefixl = strlen($prefix);
+ $result = true;
+
+ $this->_open();
+
+ do { // Workaround for PHP-Bug #62491 & #62492
+ $recheck = false;
+ $internalKey = dba_firstkey($this->handle);
+ while ($internalKey !== false && $internalKey !== null) {
+ if (substr($internalKey, 0, $prefixl) === $prefix) {
+ $result = dba_delete($internalKey, $this->handle) && $result;
+ }
+
+ $internalKey = dba_nextkey($this->handle);
+ }
+ } while ($recheck);
+
+ return $result;
+ }
+
+ /* ClearByPrefixInterface */
+
+ /**
+ * Remove items matching given prefix
+ *
+ * @param string $prefix
+ * @return bool
+ */
+ public function clearByPrefix($prefix)
+ {
+ $prefix = (string) $prefix;
+ if ($prefix === '') {
+ throw new Exception\InvalidArgumentException('No prefix given');
+ }
+
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator() . $prefix;
+ $prefixL = strlen($prefix);
+ $result = true;
+
+ $this->_open();
+
+ do { // Workaround for PHP-Bug #62491 & #62492
+ $recheck = false;
+ $internalKey = dba_firstkey($this->handle);
+ while ($internalKey !== false && $internalKey !== null) {
+ if (substr($internalKey, 0, $prefixL) === $prefix) {
+ $result = dba_delete($internalKey, $this->handle) && $result;
+ $recheck = true;
+ }
+
+ $internalKey = dba_nextkey($this->handle);
+ }
+ } while ($recheck);
+
+ return $result;
+ }
+
+ /* IterableInterface */
+
+ /**
+ * Get the storage iterator
+ *
+ * @return ApcIterator
+ */
+ public function getIterator()
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+
+ return new DbaIterator($this, $this->handle, $prefix);
+ }
+
+ /* OptimizableInterface */
+
+ /**
+ * Optimize the storage
+ *
+ * @return bool
+ * @return Exception\RuntimeException
+ */
+ public function optimize()
+ {
+ $this->_open();
+ if (!dba_optimize($this->handle)) {
+ throw new Exception\RuntimeException('dba_optimize failed');
+ }
+ return true;
+ }
+
+ /* reading */
+
+ /**
+ * Internal method to get an item.
+ *
+ * @param string $normalizedKey
+ * @param bool $success
+ * @param mixed $casToken
+ * @return mixed Data on success, null on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+
+ $this->_open();
+ $value = dba_fetch($prefix . $normalizedKey, $this->handle);
+
+ if ($value === false) {
+ $success = false;
+ return null;
+ }
+
+ $success = true;
+ $casToken = $value;
+ return $value;
+ }
+
+ /**
+ * Internal method to test if an item exists.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalHasItem(& $normalizedKey)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+
+ $this->_open();
+ return dba_exists($prefix . $normalizedKey, $this->handle);
+ }
+
+ /* writing */
+
+ /**
+ * Internal method to store an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+
+ $this->_open();
+ if (!dba_replace($internalKey, $value, $this->handle)) {
+ throw new Exception\RuntimeException("dba_replace('{$internalKey}', ...) failed");
+ }
+
+ return true;
+ }
+
+ /**
+ * Add an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalAddItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+
+ $this->_open();
+
+ // Workaround for PHP-Bug #54242 & #62489
+ if (dba_exists($internalKey, $this->handle)) {
+ return false;
+ }
+
+ // Workaround for PHP-Bug #54242 & #62489
+ // dba_insert returns true if key already exists
+ ErrorHandler::start();
+ $result = dba_insert($internalKey, $value, $this->handle);
+ $error = ErrorHandler::stop();
+ if (!$result || $error) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to remove an item.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalRemoveItem(& $normalizedKey)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+
+ $this->_open();
+
+ // Workaround for PHP-Bug #62490
+ if (!dba_exists($internalKey, $this->handle)) {
+ return false;
+ }
+
+ return dba_delete($internalKey, $this->handle);
+ }
+
+ /* status */
+
+ /**
+ * Internal method to get capabilities of this adapter
+ *
+ * @return Capabilities
+ */
+ protected function internalGetCapabilities()
+ {
+ if ($this->capabilities === null) {
+ $marker = new stdClass();
+ $capabilities = new Capabilities(
+ $this,
+ $marker,
+ array(
+ 'supportedDatatypes' => array(
+ 'NULL' => 'string',
+ 'boolean' => 'string',
+ 'integer' => 'string',
+ 'double' => 'string',
+ 'string' => true,
+ 'array' => false,
+ 'object' => false,
+ 'resource' => false,
+ ),
+ 'minTtl' => 0,
+ 'supportedMetadata' => array(),
+ 'maxKeyLength' => 0, // TODO: maxKeyLength ????
+ 'namespaceIsPrefix' => true,
+ 'namespaceSeparator' => $this->getOptions()->getNamespaceSeparator(),
+ )
+ );
+
+ // update namespace separator on change option
+ $this->getEventManager()->attach('option', function ($event) use ($capabilities, $marker) {
+ $params = $event->getParams();
+
+ if (isset($params['namespace_separator'])) {
+ $capabilities->setNamespaceSeparator($marker, $params['namespace_separator']);
+ }
+ });
+
+ $this->capabilities = $capabilities;
+ $this->capabilityMarker = $marker;
+ }
+
+ return $this->capabilities;
+ }
+
+ /**
+ * Open the database if not already done.
+ *
+ * @return void
+ * @throws Exception\LogicException
+ * @throws Exception\RuntimeException
+ */
+ protected function _open()
+ {
+ if (!$this->handle) {
+ $options = $this->getOptions();
+ $pathname = $options->getPathname();
+ $mode = $options->getMode();
+ $handler = $options->getHandler();
+
+ if ($pathname === '') {
+ throw new Exception\LogicException('No pathname to database file');
+ }
+
+ ErrorHandler::start();
+ $dba = dba_open($pathname, $mode, $handler);
+ $err = ErrorHandler::stop();
+ if (!$dba) {
+ throw new Exception\RuntimeException(
+ "dba_open('{$pathname}', '{$mode}', '{$handler}') failed", 0, $err
+ );
+ }
+ $this->handle = $dba;
+ }
+ }
+
+ /**
+ * Close database file if opened
+ *
+ * @return void
+ */
+ protected function _close()
+ {
+ if ($this->handle) {
+ ErrorHandler::start(E_NOTICE);
+ dba_close($this->handle);
+ ErrorHandler::stop();
+ $this->handle = null;
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/FilesystemIterator.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/FilesystemIterator.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/FilesystemIterator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/FilesystemIterator.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,180 @@
+storage = $storage;
+ $this->globIterator = new GlobIterator($path, GlobIterator::KEY_AS_FILENAME);
+ $this->prefix = $prefix;
+ $this->prefixLength = strlen($prefix);
+ }
+
+ /**
+ * Get storage instance
+ *
+ * @return Filesystem
+ */
+ public function getStorage()
+ {
+ return $this->storage;
+ }
+
+ /**
+ * Get iterator mode
+ *
+ * @return int Value of IteratorInterface::CURRENT_AS_*
+ */
+ public function getMode()
+ {
+ return $this->mode;
+ }
+
+ /**
+ * Set iterator mode
+ *
+ * @param int $mode
+ * @return FilesystemIterator Fluent interface
+ */
+ public function setMode($mode)
+ {
+ $this->mode = (int) $mode;
+ return $this;
+ }
+
+ /* Iterator */
+
+ /**
+ * Get current key, value or metadata.
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ if ($this->mode == IteratorInterface::CURRENT_AS_SELF) {
+ return $this;
+ }
+
+ $key = $this->key();
+
+ if ($this->mode == IteratorInterface::CURRENT_AS_VALUE) {
+ return $this->storage->getItem($key);
+ } elseif ($this->mode == IteratorInterface::CURRENT_AS_METADATA) {
+ return $this->storage->getMetadata($key);
+ }
+
+ return $key;
+ }
+
+ /**
+ * Get current key
+ *
+ * @return string
+ */
+ public function key()
+ {
+ $filename = $this->globIterator->key();
+
+ // return without namespace prefix and file suffix
+ return substr($filename, $this->prefixLength, -4);
+ }
+
+ /**
+ * Move forward to next element
+ *
+ * @return void
+ */
+ public function next()
+ {
+ $this->globIterator->next();
+ }
+
+ /**
+ * Checks if current position is valid
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ try {
+ return $this->globIterator->valid();
+ } catch (\LogicException $e) {
+ // @link https://bugs.php.net/bug.php?id=55701
+ // GlobIterator throws LogicException with message
+ // 'The parent constructor was not called: the object is in an invalid state'
+ return false;
+ }
+ }
+
+ /**
+ * Rewind the Iterator to the first element.
+ *
+ * @return bool false if the operation failed.
+ */
+ public function rewind()
+ {
+ try {
+ return $this->globIterator->rewind();
+ } catch (\LogicException $e) {
+ // @link https://bugs.php.net/bug.php?id=55701
+ // GlobIterator throws LogicException with message
+ // 'The parent constructor was not called: the object is in an invalid state'
+ return false;
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/FilesystemOptions.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/FilesystemOptions.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/FilesystemOptions.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/FilesystemOptions.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,458 @@
+filePermission = false;
+ $this->dirPermission = false;
+ }
+
+ parent::__construct($options);
+ }
+
+ /**
+ * Set cache dir
+ *
+ * @param string $cacheDir
+ * @return FilesystemOptions
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setCacheDir($cacheDir)
+ {
+ if ($cacheDir !== null) {
+ if (!is_dir($cacheDir)) {
+ throw new Exception\InvalidArgumentException(
+ "Cache directory '{$cacheDir}' not found or not a directory"
+ );
+ } elseif (!is_writable($cacheDir)) {
+ throw new Exception\InvalidArgumentException(
+ "Cache directory '{$cacheDir}' not writable"
+ );
+ } elseif (!is_readable($cacheDir)) {
+ throw new Exception\InvalidArgumentException(
+ "Cache directory '{$cacheDir}' not readable"
+ );
+ }
+
+ $cacheDir = rtrim(realpath($cacheDir), DIRECTORY_SEPARATOR);
+ } else {
+ $cacheDir = sys_get_temp_dir();
+ }
+
+ $this->triggerOptionEvent('cache_dir', $cacheDir);
+ $this->cacheDir = $cacheDir;
+ return $this;
+ }
+
+ /**
+ * Get cache dir
+ *
+ * @return null|string
+ */
+ public function getCacheDir()
+ {
+ if ($this->cacheDir === null) {
+ $this->setCacheDir(null);
+ }
+
+ return $this->cacheDir;
+ }
+
+ /**
+ * Set clear stat cache
+ *
+ * @param bool $clearStatCache
+ * @return FilesystemOptions
+ */
+ public function setClearStatCache($clearStatCache)
+ {
+ $clearStatCache = (bool) $clearStatCache;
+ $this->triggerOptionEvent('clear_stat_cache', $clearStatCache);
+ $this->clearStatCache = $clearStatCache;
+ return $this;
+ }
+
+ /**
+ * Get clear stat cache
+ *
+ * @return bool
+ */
+ public function getClearStatCache()
+ {
+ return $this->clearStatCache;
+ }
+
+ /**
+ * Set dir level
+ *
+ * @param int $dirLevel
+ * @return FilesystemOptions
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setDirLevel($dirLevel)
+ {
+ $dirLevel = (int) $dirLevel;
+ if ($dirLevel < 0 || $dirLevel > 16) {
+ throw new Exception\InvalidArgumentException(
+ "Directory level '{$dirLevel}' must be between 0 and 16"
+ );
+ }
+ $this->triggerOptionEvent('dir_level', $dirLevel);
+ $this->dirLevel = $dirLevel;
+ return $this;
+ }
+
+ /**
+ * Get dir level
+ *
+ * @return int
+ */
+ public function getDirLevel()
+ {
+ return $this->dirLevel;
+ }
+
+ /**
+ * Set permission to create directories on unix systems
+ *
+ * @param false|string|int $dirPermission FALSE to disable explicit permission or an octal number
+ * @return FilesystemOptions
+ * @see setUmask
+ * @see setFilePermission
+ * @link http://php.net/manual/function.chmod.php
+ */
+ public function setDirPermission($dirPermission)
+ {
+ if ($dirPermission !== false) {
+ if (is_string($dirPermission)) {
+ $dirPermission = octdec($dirPermission);
+ } else {
+ $dirPermission = (int) $dirPermission;
+ }
+
+ // validate
+ if (($dirPermission & 0700) != 0700) {
+ throw new Exception\InvalidArgumentException(
+ 'Invalid directory permission: need permission to execute, read and write by owner'
+ );
+ }
+ }
+
+ if ($this->dirPermission !== $dirPermission) {
+ $this->triggerOptionEvent('dir_permission', $dirPermission);
+ $this->dirPermission = $dirPermission;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get permission to create directories on unix systems
+ *
+ * @return false|int
+ */
+ public function getDirPermission()
+ {
+ return $this->dirPermission;
+ }
+
+ /**
+ * Set file locking
+ *
+ * @param bool $fileLocking
+ * @return FilesystemOptions
+ */
+ public function setFileLocking($fileLocking)
+ {
+ $fileLocking = (bool) $fileLocking;
+ $this->triggerOptionEvent('file_locking', $fileLocking);
+ $this->fileLocking = $fileLocking;
+ return $this;
+ }
+
+ /**
+ * Get file locking
+ *
+ * @return bool
+ */
+ public function getFileLocking()
+ {
+ return $this->fileLocking;
+ }
+
+ /**
+ * Set permission to create files on unix systems
+ *
+ * @param false|string|int $filePermission FALSE to disable explicit permission or an octal number
+ * @return FilesystemOptions
+ * @see setUmask
+ * @see setDirPermission
+ * @link http://php.net/manual/function.chmod.php
+ */
+ public function setFilePermission($filePermission)
+ {
+ if ($filePermission !== false) {
+ if (is_string($filePermission)) {
+ $filePermission = octdec($filePermission);
+ } else {
+ $filePermission = (int) $filePermission;
+ }
+
+ // validate
+ if (($filePermission & 0600) != 0600) {
+ throw new Exception\InvalidArgumentException(
+ 'Invalid file permission: need permission to read and write by owner'
+ );
+ } elseif ($filePermission & 0111) {
+ throw new Exception\InvalidArgumentException(
+ "Invalid file permission: Cache files shoudn't be executable"
+ );
+ }
+ }
+
+ if ($this->filePermission !== $filePermission) {
+ $this->triggerOptionEvent('file_permission', $filePermission);
+ $this->filePermission = $filePermission;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get permission to create files on unix systems
+ *
+ * @return false|int
+ */
+ public function getFilePermission()
+ {
+ return $this->filePermission;
+ }
+
+ /**
+ * Set namespace separator
+ *
+ * @param string $namespaceSeparator
+ * @return FilesystemOptions
+ */
+ public function setNamespaceSeparator($namespaceSeparator)
+ {
+ $namespaceSeparator = (string) $namespaceSeparator;
+ $this->triggerOptionEvent('namespace_separator', $namespaceSeparator);
+ $this->namespaceSeparator = $namespaceSeparator;
+ return $this;
+ }
+
+ /**
+ * Get namespace separator
+ *
+ * @return string
+ */
+ public function getNamespaceSeparator()
+ {
+ return $this->namespaceSeparator;
+ }
+
+ /**
+ * Set no atime
+ *
+ * @param bool $noAtime
+ * @return FilesystemOptions
+ */
+ public function setNoAtime($noAtime)
+ {
+ $noAtime = (bool) $noAtime;
+ $this->triggerOptionEvent('no_atime', $noAtime);
+ $this->noAtime = $noAtime;
+ return $this;
+ }
+
+ /**
+ * Get no atime
+ *
+ * @return bool
+ */
+ public function getNoAtime()
+ {
+ return $this->noAtime;
+ }
+
+ /**
+ * Set no ctime
+ *
+ * @param bool $noCtime
+ * @return FilesystemOptions
+ */
+ public function setNoCtime($noCtime)
+ {
+ $noCtime = (bool) $noCtime;
+ $this->triggerOptionEvent('no_ctime', $noCtime);
+ $this->noCtime = $noCtime;
+ return $this;
+ }
+
+ /**
+ * Get no ctime
+ *
+ * @return bool
+ */
+ public function getNoCtime()
+ {
+ return $this->noCtime;
+ }
+
+ /**
+ * Set the umask to create files and directories on unix systems
+ *
+ * Note: On multithreaded webservers it's better to explicit set file and dir permission.
+ *
+ * @param false|string|int $umask FALSE to disable umask or an octal number
+ * @return FilesystemOptions
+ * @see setFilePermission
+ * @see setDirPermission
+ * @link http://php.net/manual/function.umask.php
+ * @link http://en.wikipedia.org/wiki/Umask
+ */
+ public function setUmask($umask)
+ {
+ if ($umask !== false) {
+ if (is_string($umask)) {
+ $umask = octdec($umask);
+ } else {
+ $umask = (int) $umask;
+ }
+
+ // validate
+ if ($umask & 0700) {
+ throw new Exception\InvalidArgumentException(
+ 'Invalid umask: need permission to execute, read and write by owner'
+ );
+ }
+
+ // normalize
+ $umask = $umask & 0777;
+ }
+
+ if ($this->umask !== $umask) {
+ $this->triggerOptionEvent('umask', $umask);
+ $this->umask = $umask;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get the umask to create files and directories on unix systems
+ *
+ * @return false|int
+ */
+ public function getUmask()
+ {
+ return $this->umask;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Filesystem.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Filesystem.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Filesystem.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Filesystem.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,1617 @@
+options) {
+ $this->setOptions(new FilesystemOptions());
+ }
+ return $this->options;
+ }
+
+ /* FlushableInterface */
+
+ /**
+ * Flush the whole storage
+ *
+ * @throws Exception\RuntimeException
+ * @return bool
+ */
+ public function flush()
+ {
+ $flags = GlobIterator::SKIP_DOTS | GlobIterator::CURRENT_AS_PATHNAME;
+ $dir = $this->getOptions()->getCacheDir();
+ $clearFolder = null;
+ $clearFolder = function ($dir) use (& $clearFolder, $flags) {
+ $it = new GlobIterator($dir . DIRECTORY_SEPARATOR . '*', $flags);
+ foreach ($it as $pathname) {
+ if ($it->isDir()) {
+ $clearFolder($pathname);
+ rmdir($pathname);
+ } else {
+ unlink($pathname);
+ }
+ }
+ };
+
+ ErrorHandler::start();
+ $clearFolder($dir);
+ $error = ErrorHandler::stop();
+ if ($error) {
+ throw new Exception\RuntimeException("Flushing directory '{$dir}' failed", 0, $error);
+ }
+
+ return true;
+ }
+
+ /* ClearExpiredInterface */
+
+ /**
+ * Remove expired items
+ *
+ * @return bool
+ */
+ public function clearExpired()
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+
+ $flags = GlobIterator::SKIP_DOTS | GlobIterator::CURRENT_AS_FILEINFO;
+ $path = $options->getCacheDir()
+ . str_repeat(DIRECTORY_SEPARATOR . $prefix . '*', $options->getDirLevel())
+ . DIRECTORY_SEPARATOR . $prefix . '*.dat';
+ $glob = new GlobIterator($path, $flags);
+ $time = time();
+ $ttl = $options->getTtl();
+
+ ErrorHandler::start();
+ foreach ($glob as $entry) {
+ $mtime = $entry->getMTime();
+ if ($time >= $mtime + $ttl) {
+ $pathname = $entry->getPathname();
+ unlink($pathname);
+
+ $tagPathname = substr($pathname, 0, -4) . '.tag';
+ if (file_exists($tagPathname)) {
+ unlink($tagPathname);
+ }
+ }
+ }
+ $error = ErrorHandler::stop();
+ if ($error) {
+ throw new Exception\RuntimeException("Failed to clear expired items", 0, $error);
+ }
+
+ return true;
+ }
+
+ /* ClearByNamespaceInterface */
+
+ /**
+ * Remove items by given namespace
+ *
+ * @param string $namespace
+ * @throws Exception\RuntimeException
+ * @return bool
+ */
+ public function clearByNamespace($namespace)
+ {
+ $namespace = (string) $namespace;
+ if ($namespace === '') {
+ throw new Exception\InvalidArgumentException('No namespace given');
+ }
+
+ $options = $this->getOptions();
+ $prefix = $namespace . $options->getNamespaceSeparator();
+
+ $flags = GlobIterator::SKIP_DOTS | GlobIterator::CURRENT_AS_PATHNAME;
+ $path = $options->getCacheDir()
+ . str_repeat(DIRECTORY_SEPARATOR . $prefix . '*', $options->getDirLevel())
+ . DIRECTORY_SEPARATOR . $prefix . '*';
+ $glob = new GlobIterator($path, $flags);
+
+ ErrorHandler::start();
+ foreach ($glob as $pathname) {
+ unlink($pathname);
+ }
+ $error = ErrorHandler::stop();
+ if ($error) {
+ throw new Exception\RuntimeException("Failed to remove files of '{$path}'", 0, $error);
+ }
+
+ return true;
+ }
+
+ /* ClearByPrefixInterface */
+
+ /**
+ * Remove items matching given prefix
+ *
+ * @param string $prefix
+ * @throws Exception\RuntimeException
+ * @return bool
+ */
+ public function clearByPrefix($prefix)
+ {
+ $prefix = (string) $prefix;
+ if ($prefix === '') {
+ throw new Exception\InvalidArgumentException('No prefix given');
+ }
+
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $nsPrefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+
+ $flags = GlobIterator::SKIP_DOTS | GlobIterator::CURRENT_AS_PATHNAME;
+ $path = $options->getCacheDir()
+ . str_repeat(DIRECTORY_SEPARATOR . $nsPrefix . '*', $options->getDirLevel())
+ . DIRECTORY_SEPARATOR . $nsPrefix . $prefix . '*';
+ $glob = new GlobIterator($path, $flags);
+
+ ErrorHandler::start();
+ foreach ($glob as $pathname) {
+ unlink($pathname);
+ }
+ $error = ErrorHandler::stop();
+ if ($error) {
+ throw new Exception\RuntimeException("Failed to remove files of '{$path}'", 0, $error);
+ }
+
+ return true;
+ }
+
+ /* TaggableInterface */
+
+ /**
+ * Set tags to an item by given key.
+ * An empty array will remove all tags.
+ *
+ * @param string $key
+ * @param string[] $tags
+ * @return bool
+ */
+ public function setTags($key, array $tags)
+ {
+ $this->normalizeKey($key);
+ if (!$this->internalHasItem($key)) {
+ return false;
+ }
+
+ $filespec = $this->getFileSpec($key);
+
+ if (!$tags) {
+ $this->unlink($filespec . '.tag');
+ return true;
+ }
+
+ $this->putFileContent($filespec . '.tag', implode("\n", $tags));
+ return true;
+ }
+
+ /**
+ * Get tags of an item by given key
+ *
+ * @param string $key
+ * @return string[]|FALSE
+ */
+ public function getTags($key)
+ {
+ $this->normalizeKey($key);
+ if (!$this->internalHasItem($key)) {
+ return false;
+ }
+
+ $filespec = $this->getFileSpec($key);
+ $tags = array();
+ if (file_exists($filespec . '.tag')) {
+ $tags = explode("\n", $this->getFileContent($filespec . '.tag'));
+ }
+
+ return $tags;
+ }
+
+ /**
+ * Remove items matching given tags.
+ *
+ * If $disjunction only one of the given tags must match
+ * else all given tags must match.
+ *
+ * @param string[] $tags
+ * @param bool $disjunction
+ * @return bool
+ */
+ public function clearByTags(array $tags, $disjunction = false)
+ {
+ if (!$tags) {
+ return true;
+ }
+
+ $tagCount = count($tags);
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+
+ $flags = GlobIterator::SKIP_DOTS | GlobIterator::CURRENT_AS_PATHNAME;
+ $path = $options->getCacheDir()
+ . str_repeat(DIRECTORY_SEPARATOR . $prefix . '*', $options->getDirLevel())
+ . DIRECTORY_SEPARATOR . $prefix . '*.tag';
+ $glob = new GlobIterator($path, $flags);
+
+ foreach ($glob as $pathname) {
+ $diff = array_diff($tags, explode("\n", $this->getFileContent($pathname)));
+
+ $rem = false;
+ if ($disjunction && count($diff) < $tagCount) {
+ $rem = true;
+ } elseif (!$disjunction && !$diff) {
+ $rem = true;
+ }
+
+ if ($rem) {
+ unlink($pathname);
+
+ $datPathname = substr($pathname, 0, -4) . '.dat';
+ if (file_exists($datPathname)) {
+ unlink($datPathname);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /* IterableInterface */
+
+ /**
+ * Get the storage iterator
+ *
+ * @return FilesystemIterator
+ */
+ public function getIterator()
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $path = $options->getCacheDir()
+ . str_repeat(DIRECTORY_SEPARATOR . $prefix . '*', $options->getDirLevel())
+ . DIRECTORY_SEPARATOR . $prefix . '*.dat';
+ return new FilesystemIterator($this, $path, $prefix);
+ }
+
+ /* OptimizableInterface */
+
+ /**
+ * Optimize the storage
+ *
+ * @return bool
+ * @return Exception\RuntimeException
+ */
+ public function optimize()
+ {
+ $options = $this->getOptions();
+ if ($options->getDirLevel()) {
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+
+ // removes only empty directories
+ $this->rmDir($options->getCacheDir(), $prefix);
+ }
+ return true;
+ }
+
+ /* TotalSpaceCapableInterface */
+
+ /**
+ * Get total space in bytes
+ *
+ * @throws Exception\RuntimeException
+ * @return int|float
+ */
+ public function getTotalSpace()
+ {
+ if ($this->totalSpace === null) {
+ $path = $this->getOptions()->getCacheDir();
+
+ ErrorHandler::start();
+ $total = disk_total_space($path);
+ $error = ErrorHandler::stop();
+ if ($total === false) {
+ throw new Exception\RuntimeException("Can't detect total space of '{$path}'", 0, $error);
+ }
+ $this->totalSpace = $total;
+
+ // clean total space buffer on change cache_dir
+ $events = $this->getEventManager();
+ $handle = null;
+ $totalSpace = & $this->totalSpace;
+ $callback = function ($event) use (& $events, & $handle, & $totalSpace) {
+ $params = $event->getParams();
+ if (isset($params['cache_dir'])) {
+ $totalSpace = null;
+ $events->detach($handle);
+ }
+ };
+ $events->attach('option', $callback);
+ }
+
+ return $this->totalSpace;
+ }
+
+ /* AvailableSpaceCapableInterface */
+
+ /**
+ * Get available space in bytes
+ *
+ * @throws Exception\RuntimeException
+ * @return int|float
+ */
+ public function getAvailableSpace()
+ {
+ $path = $this->getOptions()->getCacheDir();
+
+ ErrorHandler::start();
+ $avail = disk_free_space($path);
+ $error = ErrorHandler::stop();
+ if ($avail === false) {
+ throw new Exception\RuntimeException("Can't detect free space of '{$path}'", 0, $error);
+ }
+
+ return $avail;
+ }
+
+ /* reading */
+
+ /**
+ * Get an item.
+ *
+ * @param string $key
+ * @param bool $success
+ * @param mixed $casToken
+ * @return mixed Data on success, null on failure
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers getItem.pre(PreEvent)
+ * @triggers getItem.post(PostEvent)
+ * @triggers getItem.exception(ExceptionEvent)
+ */
+ public function getItem($key, & $success = null, & $casToken = null)
+ {
+ $options = $this->getOptions();
+ if ($options->getReadable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ $argn = func_num_args();
+ if ($argn > 2) {
+ return parent::getItem($key, $success, $casToken);
+ } elseif ($argn > 1) {
+ return parent::getItem($key, $success);
+ }
+
+ return parent::getItem($key);
+ }
+
+ /**
+ * Get multiple items.
+ *
+ * @param array $keys
+ * @return array Associative array of keys and values
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers getItems.pre(PreEvent)
+ * @triggers getItems.post(PostEvent)
+ * @triggers getItems.exception(ExceptionEvent)
+ */
+ public function getItems(array $keys)
+ {
+ $options = $this->getOptions();
+ if ($options->getReadable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::getItems($keys);
+ }
+
+ /**
+ * Internal method to get an item.
+ *
+ * @param string $normalizedKey
+ * @param bool $success
+ * @param mixed $casToken
+ * @return mixed Data on success, null on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
+ {
+ if (!$this->internalHasItem($normalizedKey)) {
+ $success = false;
+ return null;
+ }
+
+ try {
+ $filespec = $this->getFileSpec($normalizedKey);
+ $data = $this->getFileContent($filespec . '.dat');
+
+ // use filemtime + filesize as CAS token
+ if (func_num_args() > 2) {
+ $casToken = filemtime($filespec . '.dat') . filesize($filespec . '.dat');
+ }
+ $success = true;
+ return $data;
+
+ } catch (BaseException $e) {
+ $success = false;
+ throw $e;
+ }
+ }
+
+ /**
+ * Internal method to get multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Associative array of keys and values
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItems(array & $normalizedKeys)
+ {
+ $keys = $normalizedKeys; // Don't change argument passed by reference
+ $result = array();
+ while ($keys) {
+
+ // LOCK_NB if more than one items have to read
+ $nonBlocking = count($keys) > 1;
+ $wouldblock = null;
+
+ // read items
+ foreach ($keys as $i => $key) {
+ if (!$this->internalHasItem($key)) {
+ unset($keys[$i]);
+ continue;
+ }
+
+ $filespec = $this->getFileSpec($key);
+ $data = $this->getFileContent($filespec . '.dat', $nonBlocking, $wouldblock);
+ if ($nonBlocking && $wouldblock) {
+ continue;
+ } else {
+ unset($keys[$i]);
+ }
+
+ $result[$key] = $data;
+ }
+
+ // TODO: Don't check ttl after first iteration
+ // $options['ttl'] = 0;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Test if an item exists.
+ *
+ * @param string $key
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers hasItem.pre(PreEvent)
+ * @triggers hasItem.post(PostEvent)
+ * @triggers hasItem.exception(ExceptionEvent)
+ */
+ public function hasItem($key)
+ {
+ $options = $this->getOptions();
+ if ($options->getReadable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::hasItem($key);
+ }
+
+ /**
+ * Test multiple items.
+ *
+ * @param array $keys
+ * @return array Array of found keys
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers hasItems.pre(PreEvent)
+ * @triggers hasItems.post(PostEvent)
+ * @triggers hasItems.exception(ExceptionEvent)
+ */
+ public function hasItems(array $keys)
+ {
+ $options = $this->getOptions();
+ if ($options->getReadable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::hasItems($keys);
+ }
+
+ /**
+ * Internal method to test if an item exists.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalHasItem(& $normalizedKey)
+ {
+ $file = $this->getFileSpec($normalizedKey) . '.dat';
+ if (!file_exists($file)) {
+ return false;
+ }
+
+ $ttl = $this->getOptions()->getTtl();
+ if ($ttl) {
+ ErrorHandler::start();
+ $mtime = filemtime($file);
+ $error = ErrorHandler::stop();
+ if (!$mtime) {
+ throw new Exception\RuntimeException(
+ "Error getting mtime of file '{$file}'", 0, $error
+ );
+ }
+
+ if (time() >= ($mtime + $ttl)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Get metadata
+ *
+ * @param string $key
+ * @return array|bool Metadata on success, false on failure
+ */
+ public function getMetadata($key)
+ {
+ $options = $this->getOptions();
+ if ($options->getReadable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::getMetadata($key);
+ }
+
+ /**
+ * Get metadatas
+ *
+ * @param array $keys
+ * @param array $options
+ * @return array Associative array of keys and metadata
+ */
+ public function getMetadatas(array $keys, array $options = array())
+ {
+ $options = $this->getOptions();
+ if ($options->getReadable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::getMetadatas($keys);
+ }
+
+ /**
+ * Get info by key
+ *
+ * @param string $normalizedKey
+ * @return array|bool Metadata on success, false on failure
+ */
+ protected function internalGetMetadata(& $normalizedKey)
+ {
+ if (!$this->internalHasItem($normalizedKey)) {
+ return false;
+ }
+
+ $options = $this->getOptions();
+ $filespec = $this->getFileSpec($normalizedKey);
+ $file = $filespec . '.dat';
+
+ $metadata = array(
+ 'filespec' => $filespec,
+ 'mtime' => filemtime($file)
+ );
+
+ if (!$options->getNoCtime()) {
+ $metadata['ctime'] = filectime($file);
+ }
+
+ if (!$options->getNoAtime()) {
+ $metadata['atime'] = fileatime($file);
+ }
+
+ return $metadata;
+ }
+
+ /**
+ * Internal method to get multiple metadata
+ *
+ * @param array $normalizedKeys
+ * @return array Associative array of keys and metadata
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetMetadatas(array & $normalizedKeys)
+ {
+ $options = $this->getOptions();
+ $result = array();
+
+ foreach ($normalizedKeys as $normalizedKey) {
+ $filespec = $this->getFileSpec($normalizedKey);
+ $file = $filespec . '.dat';
+
+ $metadata = array(
+ 'filespec' => $filespec,
+ 'mtime' => filemtime($file),
+ );
+
+ if (!$options->getNoCtime()) {
+ $metadata['ctime'] = filectime($file);
+ }
+
+ if (!$options->getNoAtime()) {
+ $metadata['atime'] = fileatime($file);
+ }
+
+ $result[$normalizedKey] = $metadata;
+ }
+
+ return $result;
+ }
+
+ /* writing */
+
+ /**
+ * Store an item.
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers setItem.pre(PreEvent)
+ * @triggers setItem.post(PostEvent)
+ * @triggers setItem.exception(ExceptionEvent)
+ */
+ public function setItem($key, $value)
+ {
+ $options = $this->getOptions();
+ if ($options->getWritable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+ return parent::setItem($key, $value);
+ }
+
+ /**
+ * Store multiple items.
+ *
+ * @param array $keyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers setItems.pre(PreEvent)
+ * @triggers setItems.post(PostEvent)
+ * @triggers setItems.exception(ExceptionEvent)
+ */
+ public function setItems(array $keyValuePairs)
+ {
+ $options = $this->getOptions();
+ if ($options->getWritable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::setItems($keyValuePairs);
+ }
+
+ /**
+ * Add an item.
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers addItem.pre(PreEvent)
+ * @triggers addItem.post(PostEvent)
+ * @triggers addItem.exception(ExceptionEvent)
+ */
+ public function addItem($key, $value)
+ {
+ $options = $this->getOptions();
+ if ($options->getWritable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::addItem($key, $value);
+ }
+
+ /**
+ * Add multiple items.
+ *
+ * @param array $keyValuePairs
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers addItems.pre(PreEvent)
+ * @triggers addItems.post(PostEvent)
+ * @triggers addItems.exception(ExceptionEvent)
+ */
+ public function addItems(array $keyValuePairs)
+ {
+ $options = $this->getOptions();
+ if ($options->getWritable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::addItems($keyValuePairs);
+ }
+
+ /**
+ * Replace an existing item.
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers replaceItem.pre(PreEvent)
+ * @triggers replaceItem.post(PostEvent)
+ * @triggers replaceItem.exception(ExceptionEvent)
+ */
+ public function replaceItem($key, $value)
+ {
+ $options = $this->getOptions();
+ if ($options->getWritable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::replaceItem($key, $value);
+ }
+
+ /**
+ * Replace multiple existing items.
+ *
+ * @param array $keyValuePairs
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers replaceItems.pre(PreEvent)
+ * @triggers replaceItems.post(PostEvent)
+ * @triggers replaceItems.exception(ExceptionEvent)
+ */
+ public function replaceItems(array $keyValuePairs)
+ {
+ $options = $this->getOptions();
+ if ($options->getWritable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::replaceItems($keyValuePairs);
+ }
+
+ /**
+ * Internal method to store an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItem(& $normalizedKey, & $value)
+ {
+ $filespec = $this->getFileSpec($normalizedKey);
+ $this->prepareDirectoryStructure($filespec);
+
+ // write data in non-blocking mode
+ $wouldblock = null;
+ $this->putFileContent($filespec . '.dat', $value, true, $wouldblock);
+
+ // delete related tag file (if present)
+ $this->unlink($filespec . '.tag');
+
+ // Retry writing data in blocking mode if it was blocked before
+ if ($wouldblock) {
+ $this->putFileContent($filespec . '.dat', $value);
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to store multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItems(array & $normalizedKeyValuePairs)
+ {
+ $oldUmask = null;
+
+ // create an associated array of files and contents to write
+ $contents = array();
+ foreach ($normalizedKeyValuePairs as $key => & $value) {
+ $filespec = $this->getFileSpec($key);
+ $this->prepareDirectoryStructure($filespec);
+
+ // *.dat file
+ $contents[$filespec . '.dat'] = & $value;
+
+ // *.tag file
+ $this->unlink($filespec . '.tag');
+ }
+
+ // write to disk
+ while ($contents) {
+ $nonBlocking = count($contents) > 1;
+ $wouldblock = null;
+
+ foreach ($contents as $file => & $content) {
+ $this->putFileContent($file, $content, $nonBlocking, $wouldblock);
+ if (!$nonBlocking || !$wouldblock) {
+ unset($contents[$file]);
+ }
+ }
+ }
+
+ // return OK
+ return array();
+ }
+
+ /**
+ * Set an item only if token matches
+ *
+ * It uses the token received from getItem() to check if the item has
+ * changed before overwriting it.
+ *
+ * @param mixed $token
+ * @param string $key
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ * @see getItem()
+ * @see setItem()
+ */
+ public function checkAndSetItem($token, $key, $value)
+ {
+ $options = $this->getOptions();
+ if ($options->getWritable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::checkAndSetItem($token, $key, $value);
+ }
+
+ /**
+ * Internal method to set an item only if token matches
+ *
+ * @param mixed $token
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ * @see getItem()
+ * @see setItem()
+ */
+ protected function internalCheckAndSetItem(& $token, & $normalizedKey, & $value)
+ {
+ if (!$this->internalHasItem($normalizedKey)) {
+ return false;
+ }
+
+ // use filemtime + filesize as CAS token
+ $file = $this->getFileSpec($normalizedKey) . '.dat';
+ $check = filemtime($file) . filesize($file);
+ if ($token !== $check) {
+ return false;
+ }
+
+ return $this->internalSetItem($normalizedKey, $value);
+ }
+
+ /**
+ * Reset lifetime of an item
+ *
+ * @param string $key
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers touchItem.pre(PreEvent)
+ * @triggers touchItem.post(PostEvent)
+ * @triggers touchItem.exception(ExceptionEvent)
+ */
+ public function touchItem($key)
+ {
+ $options = $this->getOptions();
+ if ($options->getWritable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::touchItem($key);
+ }
+
+ /**
+ * Reset lifetime of multiple items.
+ *
+ * @param array $keys
+ * @return array Array of not updated keys
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers touchItems.pre(PreEvent)
+ * @triggers touchItems.post(PostEvent)
+ * @triggers touchItems.exception(ExceptionEvent)
+ */
+ public function touchItems(array $keys)
+ {
+ $options = $this->getOptions();
+ if ($options->getWritable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::touchItems($keys);
+ }
+
+ /**
+ * Internal method to reset lifetime of an item
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalTouchItem(& $normalizedKey)
+ {
+ if (!$this->internalHasItem($normalizedKey)) {
+ return false;
+ }
+
+ $filespec = $this->getFileSpec($normalizedKey);
+
+ ErrorHandler::start();
+ $touch = touch($filespec . '.dat');
+ $error = ErrorHandler::stop();
+ if (!$touch) {
+ throw new Exception\RuntimeException(
+ "Error touching file '{$filespec}.dat'", 0, $error
+ );
+ }
+
+ return true;
+ }
+
+ /**
+ * Remove an item.
+ *
+ * @param string $key
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers removeItem.pre(PreEvent)
+ * @triggers removeItem.post(PostEvent)
+ * @triggers removeItem.exception(ExceptionEvent)
+ */
+ public function removeItem($key)
+ {
+ $options = $this->getOptions();
+ if ($options->getWritable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::removeItem($key);
+ }
+
+ /**
+ * Remove multiple items.
+ *
+ * @param array $keys
+ * @return array Array of not removed keys
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers removeItems.pre(PreEvent)
+ * @triggers removeItems.post(PostEvent)
+ * @triggers removeItems.exception(ExceptionEvent)
+ */
+ public function removeItems(array $keys)
+ {
+ $options = $this->getOptions();
+ if ($options->getWritable() && $options->getClearStatCache()) {
+ clearstatcache();
+ }
+
+ return parent::removeItems($keys);
+ }
+
+ /**
+ * Internal method to remove an item.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalRemoveItem(& $normalizedKey)
+ {
+ $filespec = $this->getFileSpec($normalizedKey);
+ if (!file_exists($filespec . '.dat')) {
+ return false;
+ } else {
+ $this->unlink($filespec . '.dat');
+ $this->unlink($filespec . '.tag');
+ }
+ return true;
+ }
+
+ /* status */
+
+ /**
+ * Internal method to get capabilities of this adapter
+ *
+ * @return Capabilities
+ */
+ protected function internalGetCapabilities()
+ {
+ if ($this->capabilities === null) {
+ $marker = new stdClass();
+ $options = $this->getOptions();
+
+ // detect metadata
+ $metadata = array('mtime', 'filespec');
+ if (!$options->getNoAtime()) {
+ $metadata[] = 'atime';
+ }
+ if (!$options->getNoCtime()) {
+ $metadata[] = 'ctime';
+ }
+
+ $capabilities = new Capabilities(
+ $this,
+ $marker,
+ array(
+ 'supportedDatatypes' => array(
+ 'NULL' => 'string',
+ 'boolean' => 'string',
+ 'integer' => 'string',
+ 'double' => 'string',
+ 'string' => true,
+ 'array' => false,
+ 'object' => false,
+ 'resource' => false,
+ ),
+ 'supportedMetadata' => $metadata,
+ 'minTtl' => 1,
+ 'maxTtl' => 0,
+ 'staticTtl' => false,
+ 'ttlPrecision' => 1,
+ 'expiredRead' => true,
+ 'maxKeyLength' => 251, // 255 - strlen(.dat | .tag)
+ 'namespaceIsPrefix' => true,
+ 'namespaceSeparator' => $options->getNamespaceSeparator(),
+ )
+ );
+
+ // update capabilities on change options
+ $this->getEventManager()->attach('option', function ($event) use ($capabilities, $marker) {
+ $params = $event->getParams();
+
+ if (isset($params['namespace_separator'])) {
+ $capabilities->setNamespaceSeparator($marker, $params['namespace_separator']);
+ }
+
+ if (isset($params['no_atime']) || isset($params['no_ctime'])) {
+ $metadata = $capabilities->getSupportedMetadata();
+
+ if (isset($params['no_atime']) && !$params['no_atime']) {
+ $metadata[] = 'atime';
+ } elseif (isset($params['no_atime']) && ($index = array_search('atime', $metadata)) !== false) {
+ unset($metadata[$index]);
+ }
+
+ if (isset($params['no_ctime']) && !$params['no_ctime']) {
+ $metadata[] = 'ctime';
+ } elseif (isset($params['no_ctime']) && ($index = array_search('ctime', $metadata)) !== false) {
+ unset($metadata[$index]);
+ }
+
+ $capabilities->setSupportedMetadata($marker, $metadata);
+ }
+ });
+
+ $this->capabilityMarker = $marker;
+ $this->capabilities = $capabilities;
+ }
+
+ return $this->capabilities;
+ }
+
+ /* internal */
+
+ /**
+ * Removes directories recursive by namespace
+ *
+ * @param string $dir Directory to delete
+ * @param string $prefix Namespace + Separator
+ * @return bool
+ */
+ protected function rmDir($dir, $prefix)
+ {
+ $glob = glob(
+ $dir . DIRECTORY_SEPARATOR . $prefix . '*',
+ GLOB_ONLYDIR | GLOB_NOESCAPE | GLOB_NOSORT
+ );
+ if (!$glob) {
+ // On some systems glob returns false even on empty result
+ return true;
+ }
+
+ $ret = true;
+ foreach ($glob as $subdir) {
+ // skip removing current directory if removing of sub-directory failed
+ if ($this->rmDir($subdir, $prefix)) {
+ // ignore not empty directories
+ ErrorHandler::start();
+ $ret = rmdir($subdir) && $ret;
+ ErrorHandler::stop();
+ } else {
+ $ret = false;
+ }
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Get file spec of the given key and namespace
+ *
+ * @param string $normalizedKey
+ * @return string
+ */
+ protected function getFileSpec($normalizedKey)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $path = $options->getCacheDir() . DIRECTORY_SEPARATOR;
+ $level = $options->getDirLevel();
+
+ $fileSpecId = $path . $prefix . $normalizedKey . '/' . $level;
+ if ($this->lastFileSpecId !== $fileSpecId) {
+ if ($level > 0) {
+ // create up to 256 directories per directory level
+ $hash = md5($normalizedKey);
+ for ($i = 0, $max = ($level * 2); $i < $max; $i+= 2) {
+ $path .= $prefix . $hash[$i] . $hash[$i+1] . DIRECTORY_SEPARATOR;
+ }
+ }
+
+ $this->lastFileSpecId = $fileSpecId;
+ $this->lastFileSpec = $path . $prefix . $normalizedKey;
+ }
+
+ return $this->lastFileSpec;
+ }
+
+ /**
+ * Read info file
+ *
+ * @param string $file
+ * @param bool $nonBlocking Don't block script if file is locked
+ * @param bool $wouldblock The optional argument is set to TRUE if the lock would block
+ * @return array|bool The info array or false if file wasn't found
+ * @throws Exception\RuntimeException
+ */
+ protected function readInfoFile($file, $nonBlocking = false, & $wouldblock = null)
+ {
+ if (!file_exists($file)) {
+ return false;
+ }
+
+ $content = $this->getFileContent($file, $nonBlocking, $wouldblock);
+ if ($nonBlocking && $wouldblock) {
+ return false;
+ }
+
+ ErrorHandler::start();
+ $ifo = unserialize($content);
+ $err = ErrorHandler::stop();
+ if (!is_array($ifo)) {
+ throw new Exception\RuntimeException(
+ "Corrupted info file '{$file}'", 0, $err
+ );
+ }
+
+ return $ifo;
+ }
+
+ /**
+ * Read a complete file
+ *
+ * @param string $file File complete path
+ * @param bool $nonBlocking Don't block script if file is locked
+ * @param bool $wouldblock The optional argument is set to TRUE if the lock would block
+ * @return string
+ * @throws Exception\RuntimeException
+ */
+ protected function getFileContent($file, $nonBlocking = false, & $wouldblock = null)
+ {
+ $locking = $this->getOptions()->getFileLocking();
+ $wouldblock = null;
+
+ ErrorHandler::start();
+
+ // if file locking enabled -> file_get_contents can't be used
+ if ($locking) {
+ $fp = fopen($file, 'rb');
+ if ($fp === false) {
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "Error opening file '{$file}'", 0, $err
+ );
+ }
+
+ if ($nonBlocking) {
+ $lock = flock($fp, LOCK_SH | LOCK_NB, $wouldblock);
+ if ($wouldblock) {
+ fclose($fp);
+ ErrorHandler::stop();
+ return;
+ }
+ } else {
+ $lock = flock($fp, LOCK_SH);
+ }
+
+ if (!$lock) {
+ fclose($fp);
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "Error locking file '{$file}'", 0, $err
+ );
+ }
+
+ $res = stream_get_contents($fp);
+ if ($res === false) {
+ flock($fp, LOCK_UN);
+ fclose($fp);
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ 'Error getting stream contents', 0, $err
+ );
+ }
+
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ // if file locking disabled -> file_get_contents can be used
+ } else {
+ $res = file_get_contents($file, false);
+ if ($res === false) {
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "Error getting file contents for file '{$file}'", 0, $err
+ );
+ }
+ }
+
+ ErrorHandler::stop();
+ return $res;
+ }
+
+ /**
+ * Prepares a directory structure for the given file(spec)
+ * using the configured directory level.
+ *
+ * @param string $file
+ * @return void
+ * @throws Exception\RuntimeException
+ */
+ protected function prepareDirectoryStructure($file)
+ {
+ $options = $this->getOptions();
+ $level = $options->getDirLevel();
+
+ // Directory structure is required only if directory level > 0
+ if (!$level) {
+ return;
+ }
+
+ // Directory structure already exists
+ $pathname = dirname($file);
+ if (file_exists($pathname)) {
+ return;
+ }
+
+ $perm = $options->getDirPermission();
+ $umask = $options->getUmask();
+ if ($umask !== false && $perm !== false) {
+ $perm = $perm & ~$umask;
+ }
+
+ ErrorHandler::start();
+
+ if ($perm === false || $level == 1) {
+ // build-in mkdir function is enough
+
+ $umask = ($umask !== false) ? umask($umask) : false;
+ $res = mkdir($pathname, ($perm !== false) ? $perm : 0777, true);
+
+ if ($umask !== false) {
+ umask($umask);
+ }
+
+ if (!$res) {
+ $oct = ($perm === false) ? '777' : decoct($perm);
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "mkdir('{$pathname}', 0{$oct}, true) failed", 0, $err
+ );
+ }
+
+ if ($perm !== false && !chmod($pathname, $perm)) {
+ $oct = decoct($perm);
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "chmod('{$pathname}', 0{$oct}) failed", 0, $err
+ );
+ }
+
+ } else {
+ // build-in mkdir function sets permission together with current umask
+ // which doesn't work well on multo threaded webservers
+ // -> create directories one by one and set permissions
+
+ // find existing path and missing path parts
+ $parts = array();
+ $path = $pathname;
+ while (!file_exists($path)) {
+ array_unshift($parts, basename($path));
+ $nextPath = dirname($path);
+ if ($nextPath === $path) {
+ break;
+ }
+ $path = $nextPath;
+ }
+
+ // make all missing path parts
+ foreach ($parts as $part) {
+ $path.= DIRECTORY_SEPARATOR . $part;
+
+ // create a single directory, set and reset umask immediately
+ $umask = ($umask !== false) ? umask($umask) : false;
+ $res = mkdir($path, ($perm === false) ? 0777 : $perm, false);
+ if ($umask !== false) {
+ umask($umask);
+ }
+
+ if (!$res) {
+ $oct = ($perm === false) ? '777' : decoct($perm);
+ ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "mkdir('{$path}', 0{$oct}, false) failed"
+ );
+ }
+
+ if ($perm !== false && !chmod($path, $perm)) {
+ $oct = decoct($perm);
+ ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "chmod('{$path}', 0{$oct}) failed"
+ );
+ }
+ }
+ }
+
+ ErrorHandler::stop();
+ }
+
+ /**
+ * Write content to a file
+ *
+ * @param string $file File complete path
+ * @param string $data Data to write
+ * @param bool $nonBlocking Don't block script if file is locked
+ * @param bool $wouldblock The optional argument is set to TRUE if the lock would block
+ * @return void
+ * @throws Exception\RuntimeException
+ */
+ protected function putFileContent($file, $data, $nonBlocking = false, & $wouldblock = null)
+ {
+ $options = $this->getOptions();
+ $locking = $options->getFileLocking();
+ $nonBlocking = $locking && $nonBlocking;
+ $wouldblock = null;
+
+ $umask = $options->getUmask();
+ $perm = $options->getFilePermission();
+ if ($umask !== false && $perm !== false) {
+ $perm = $perm & ~$umask;
+ }
+
+ ErrorHandler::start();
+
+ // if locking and non blocking is enabled -> file_put_contents can't used
+ if ($locking && $nonBlocking) {
+
+ $umask = ($umask !== false) ? umask($umask) : false;
+
+ $fp = fopen($file, 'cb');
+
+ if ($umask) {
+ umask($umask);
+ }
+
+ if (!$fp) {
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "Error opening file '{$file}'", 0, $err
+ );
+ }
+
+ if ($perm !== false && !chmod($file, $perm)) {
+ fclose($fp);
+ $oct = decoct($perm);
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException("chmod('{$file}', 0{$oct}) failed", 0, $err);
+ }
+
+ if (!flock($fp, LOCK_EX | LOCK_NB, $wouldblock)) {
+ fclose($fp);
+ $err = ErrorHandler::stop();
+ if ($wouldblock) {
+ return;
+ } else {
+ throw new Exception\RuntimeException("Error locking file '{$file}'", 0, $err);
+ }
+ }
+
+ if (fwrite($fp, $data) === false) {
+ flock($fp, LOCK_UN);
+ fclose($fp);
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException("Error writing file '{$file}'", 0, $err);
+ }
+
+ if (!ftruncate($fp, strlen($data))) {
+ flock($fp, LOCK_UN);
+ fclose($fp);
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException("Error truncating file '{$file}'", 0, $err);
+ }
+
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ // else -> file_put_contents can be used
+ } else {
+ $flags = 0;
+ if ($locking) {
+ $flags = $flags | LOCK_EX;
+ }
+
+ $umask = ($umask !== false) ? umask($umask) : false;
+
+ $rs = file_put_contents($file, $data, $flags);
+
+ if ($umask) {
+ umask($umask);
+ }
+
+ if ($rs === false) {
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException(
+ "Error writing file '{$file}'", 0, $err
+ );
+ }
+
+ if ($perm !== false && !chmod($file, $perm)) {
+ $oct = decoct($perm);
+ $err = ErrorHandler::stop();
+ throw new Exception\RuntimeException("chmod('{$file}', 0{$oct}) failed", 0, $err);
+ }
+ }
+
+ ErrorHandler::stop();
+ }
+
+ /**
+ * Unlink a file
+ *
+ * @param string $file
+ * @return void
+ * @throws RuntimeException
+ */
+ protected function unlink($file)
+ {
+ ErrorHandler::start();
+ $res = unlink($file);
+ $err = ErrorHandler::stop();
+
+ // only throw exception if file still exists after deleting
+ if (!$res && file_exists($file)) {
+ throw new Exception\RuntimeException(
+ "Error unlinking file '{$file}'; file still exists", 0, $err
+ );
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/KeyListIterator.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/KeyListIterator.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/KeyListIterator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/KeyListIterator.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,170 @@
+storage = $storage;
+ $this->keys = $keys;
+ $this->count = count($keys);
+ }
+
+ /**
+ * Get storage instance
+ *
+ * @return StorageInterface
+ */
+ public function getStorage()
+ {
+ return $this->storage;
+ }
+
+ /**
+ * Get iterator mode
+ *
+ * @return int Value of IteratorInterface::CURRENT_AS_*
+ */
+ public function getMode()
+ {
+ return $this->mode;
+ }
+
+ /**
+ * Set iterator mode
+ *
+ * @param int $mode
+ * @return KeyListIterator Fluent interface
+ */
+ public function setMode($mode)
+ {
+ $this->mode = (int) $mode;
+ return $this;
+ }
+
+ /**
+ * Get current key, value or metadata.
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ if ($this->mode == IteratorInterface::CURRENT_AS_SELF) {
+ return $this;
+ }
+
+ $key = $this->key();
+
+ if ($this->mode == IteratorInterface::CURRENT_AS_METADATA) {
+ return $this->storage->getMetadata($key);
+ } elseif ($this->mode == IteratorInterface::CURRENT_AS_VALUE) {
+ return $this->storage->getItem($key);
+ }
+
+ return $key;
+ }
+
+ /**
+ * Get current key
+ *
+ * @return string
+ */
+ public function key()
+ {
+ return $this->keys[$this->position];
+ }
+
+ /**
+ * Checks if current position is valid
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return $this->position < $this->count;
+ }
+
+ /**
+ * Move forward to next element
+ *
+ * @return void
+ */
+ public function next()
+ {
+ $this->position++;
+ }
+
+ /**
+ * Rewind the Iterator to the first element.
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ $this->position = 0;
+ }
+
+ /**
+ * Count number of items
+ *
+ * @return int
+ */
+ public function count()
+ {
+ return $this->count;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/MemcachedOptions.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/MemcachedOptions.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/MemcachedOptions.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/MemcachedOptions.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,319 @@
+namespaceSeparator !== $namespaceSeparator) {
+ $this->triggerOptionEvent('namespace_separator', $namespaceSeparator);
+ $this->namespaceSeparator = $namespaceSeparator;
+ }
+ return $this;
+ }
+
+ /**
+ * Get namespace separator
+ *
+ * @return string
+ */
+ public function getNamespaceSeparator()
+ {
+ return $this->namespaceSeparator;
+ }
+
+ /**
+ * A memcached resource to share
+ *
+ * @param null|MemcachedResource $memcachedResource
+ * @return MemcachedOptions
+ * @deprecated Please use the resource manager instead
+ */
+ public function setMemcachedResource(MemcachedResource $memcachedResource = null)
+ {
+ trigger_error(
+ 'This method is deprecated and will be removed in the feature'
+ . ', please use the resource manager instead',
+ E_USER_DEPRECATED
+ );
+
+ if ($memcachedResource !== null) {
+ $this->triggerOptionEvent('memcached_resource', $memcachedResource);
+ $resourceManager = $this->getResourceManager();
+ $resourceId = $this->getResourceId();
+ $resourceManager->setResource($resourceId, $memcachedResource);
+ }
+ return $this;
+ }
+
+ /**
+ * Get memcached resource to share
+ *
+ * @return MemcachedResource
+ * @deprecated Please use the resource manager instead
+ */
+ public function getMemcachedResource()
+ {
+ trigger_error(
+ 'This method is deprecated and will be removed in the feature'
+ . ', please use the resource manager instead',
+ E_USER_DEPRECATED
+ );
+
+ return $this->resourceManager->getResource($this->getResourceId());
+ }
+
+ /**
+ * Set the memcached resource manager to use
+ *
+ * @param null|MemcachedResourceManager $resourceManager
+ * @return MemcachedOptions
+ */
+ public function setResourceManager(MemcachedResourceManager $resourceManager = null)
+ {
+ if ($this->resourceManager !== $resourceManager) {
+ $this->triggerOptionEvent('resource_manager', $resourceManager);
+ $this->resourceManager = $resourceManager;
+ }
+ return $this;
+ }
+
+ /**
+ * Get the memcached resource manager
+ *
+ * @return MemcachedResourceManager
+ */
+ public function getResourceManager()
+ {
+ if (!$this->resourceManager) {
+ $this->resourceManager = new MemcachedResourceManager();
+ }
+ return $this->resourceManager;
+ }
+
+ /**
+ * Get the memcached resource id
+ *
+ * @return string
+ */
+ public function getResourceId()
+ {
+ return $this->resourceId;
+ }
+
+ /**
+ * Set the memcached resource id
+ *
+ * @param string $resourceId
+ * @return MemcachedOptions
+ */
+ public function setResourceId($resourceId)
+ {
+ $resourceId = (string) $resourceId;
+ if ($this->resourceId !== $resourceId) {
+ $this->triggerOptionEvent('resource_id', $resourceId);
+ $this->resourceId = $resourceId;
+ }
+ return $this;
+ }
+
+ /**
+ * Get the persistent id
+ *
+ * @return string
+ */
+ public function getPersistentId()
+ {
+ return $this->getResourceManager()->getPersistentId($this->getResourceId());
+ }
+
+ /**
+ * Set the persistent id
+ *
+ * @param string $persistentId
+ * @return MemcachedOptions
+ */
+ public function setPersistentId($persistentId)
+ {
+ $this->triggerOptionEvent('persistent_id', $persistentId);
+ $this->getResourceManager()->setPersistentId($this->getResourceId(), $persistentId);
+ return $this;
+ }
+
+ /**
+ * Add a server to the list
+ *
+ * @param string $host
+ * @param int $port
+ * @param int $weight
+ * @return MemcachedOptions
+ * @deprecated Please use the resource manager instead
+ */
+ public function addServer($host, $port = 11211, $weight = 0)
+ {
+ trigger_error(
+ 'This method is deprecated and will be removed in the feature'
+ . ', please use the resource manager instead',
+ E_USER_DEPRECATED
+ );
+
+ $this->getResourceManager()->addServer($this->getResourceId(), array(
+ 'host' => $host,
+ 'port' => $port,
+ 'weight' => $weight
+ ));
+
+ return $this;
+ }
+
+ /**
+ * Set a list of memcached servers to add on initialize
+ *
+ * @param string|array $servers list of servers
+ * @return MemcachedOptions
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setServers($servers)
+ {
+ $this->getResourceManager()->setServers($this->getResourceId(), $servers);
+ return $this;
+ }
+
+ /**
+ * Get Servers
+ *
+ * @return array
+ */
+ public function getServers()
+ {
+ return $this->getResourceManager()->getServers($this->getResourceId());
+ }
+
+ /**
+ * Set libmemcached options
+ *
+ * @param array $libOptions
+ * @return MemcachedOptions
+ * @link http://php.net/manual/memcached.constants.php
+ */
+ public function setLibOptions(array $libOptions)
+ {
+ $this->getResourceManager()->setLibOptions($this->getResourceId(), $libOptions);
+ return $this;
+ }
+
+ /**
+ * Set libmemcached option
+ *
+ * @param string|int $key
+ * @param mixed $value
+ * @return MemcachedOptions
+ * @link http://php.net/manual/memcached.constants.php
+ * @deprecated Please use lib_options or the resource manager instead
+ */
+ public function setLibOption($key, $value)
+ {
+ trigger_error(
+ 'This method is deprecated and will be removed in the feature'
+ . ', please use "lib_options" or the resource manager instead',
+ E_USER_DEPRECATED
+ );
+
+ $this->getResourceManager()->setLibOption($this->getResourceId(), $key, $value);
+ return $this;
+ }
+
+ /**
+ * Get libmemcached options
+ *
+ * @return array
+ * @link http://php.net/manual/memcached.constants.php
+ */
+ public function getLibOptions()
+ {
+ return $this->getResourceManager()->getLibOptions($this->getResourceId());
+ }
+
+ /**
+ * Get libmemcached option
+ *
+ * @param string|int $key
+ * @return mixed
+ * @link http://php.net/manual/memcached.constants.php
+ * @deprecated Please use lib_options or the resource manager instead
+ */
+ public function getLibOption($key)
+ {
+ trigger_error(
+ 'This method is deprecated and will be removed in the feature'
+ . ', please use "lib_options" or the resource manager instead',
+ E_USER_DEPRECATED
+ );
+
+ return $this->getResourceManager()->getLibOption($this->getResourceId(), $key);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Memcached.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Memcached.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Memcached.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Memcached.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,704 @@
+= 1.0.0');
+ }
+
+ parent::__construct($options);
+
+ // reset initialized flag on update option(s)
+ $initialized = & $this->initialized;
+ $this->getEventManager()->attach('option', function ($event) use (& $initialized) {
+ $initialized = false;
+ });
+ }
+
+ /**
+ * Initialize the internal memcached resource
+ *
+ * @return MemcachedResource
+ */
+ protected function getMemcachedResource()
+ {
+ if (!$this->initialized) {
+ $options = $this->getOptions();
+
+ // get resource manager and resource id
+ $this->resourceManager = $options->getResourceManager();
+ $this->resourceId = $options->getResourceId();
+
+ // init namespace prefix
+ $namespace = $options->getNamespace();
+ if ($namespace !== '') {
+ $this->namespacePrefix = $namespace . $options->getNamespaceSeparator();
+ } else {
+ $this->namespacePrefix = '';
+ }
+
+ // update initialized flag
+ $this->initialized = true;
+ }
+
+ return $this->resourceManager->getResource($this->resourceId);
+ }
+
+ /* options */
+
+ /**
+ * Set options.
+ *
+ * @param array|Traversable|MemcachedOptions $options
+ * @return Memcached
+ * @see getOptions()
+ */
+ public function setOptions($options)
+ {
+ if (!$options instanceof MemcachedOptions) {
+ $options = new MemcachedOptions($options);
+ }
+
+ return parent::setOptions($options);
+ }
+
+ /**
+ * Get options.
+ *
+ * @return MemcachedOptions
+ * @see setOptions()
+ */
+ public function getOptions()
+ {
+ if (!$this->options) {
+ $this->setOptions(new MemcachedOptions());
+ }
+ return $this->options;
+ }
+
+ /* FlushableInterface */
+
+ /**
+ * Flush the whole storage
+ *
+ * @return bool
+ */
+ public function flush()
+ {
+ $memc = $this->getMemcachedResource();
+ if (!$memc->flush()) {
+ throw $this->getExceptionByResultCode($memc->getResultCode());
+ }
+ return true;
+ }
+
+ /* TotalSpaceCapableInterface */
+
+ /**
+ * Get total space in bytes
+ *
+ * @return int|float
+ */
+ public function getTotalSpace()
+ {
+ $memc = $this->getMemcachedResource();
+ $stats = $memc->getStats();
+ if ($stats === false) {
+ throw new Exception\RuntimeException($memc->getResultMessage());
+ }
+
+ $mem = array_pop($stats);
+ return $mem['limit_maxbytes'];
+ }
+
+ /* AvailableSpaceCapableInterface */
+
+ /**
+ * Get available space in bytes
+ *
+ * @return int|float
+ */
+ public function getAvailableSpace()
+ {
+ $memc = $this->getMemcachedResource();
+ $stats = $memc->getStats();
+ if ($stats === false) {
+ throw new Exception\RuntimeException($memc->getResultMessage());
+ }
+
+ $mem = array_pop($stats);
+ return $mem['limit_maxbytes'] - $mem['bytes'];
+ }
+
+ /* reading */
+
+ /**
+ * Internal method to get an item.
+ *
+ * @param string $normalizedKey
+ * @param bool $success
+ * @param mixed $casToken
+ * @return mixed Data on success, null on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
+ {
+ $memc = $this->getMemcachedResource();
+ $internalKey = $this->namespacePrefix . $normalizedKey;
+
+ if (func_num_args() > 2) {
+ $result = $memc->get($internalKey, null, $casToken);
+ } else {
+ $result = $memc->get($internalKey);
+ }
+
+ $success = true;
+ if ($result === false || $result === null) {
+ $rsCode = $memc->getResultCode();
+ if ($rsCode == MemcachedResource::RES_NOTFOUND) {
+ $result = null;
+ $success = false;
+ } elseif ($rsCode) {
+ $success = false;
+ throw $this->getExceptionByResultCode($rsCode);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to get multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Associative array of keys and values
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItems(array & $normalizedKeys)
+ {
+ $memc = $this->getMemcachedResource();
+
+ foreach ($normalizedKeys as & $normalizedKey) {
+ $normalizedKey = $this->namespacePrefix . $normalizedKey;
+ }
+
+ $result = $memc->getMulti($normalizedKeys);
+ if ($result === false) {
+ throw $this->getExceptionByResultCode($memc->getResultCode());
+ }
+
+ // remove namespace prefix from result
+ if ($result && $this->namespacePrefix !== '') {
+ $tmp = array();
+ $nsPrefixLength = strlen($this->namespacePrefix);
+ foreach ($result as $internalKey => & $value) {
+ $tmp[substr($internalKey, $nsPrefixLength)] = & $value;
+ }
+ $result = $tmp;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to test if an item exists.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalHasItem(& $normalizedKey)
+ {
+ $memc = $this->getMemcachedResource();
+ $value = $memc->get($this->namespacePrefix . $normalizedKey);
+ if ($value === false || $value === null) {
+ $rsCode = $memc->getResultCode();
+ if ($rsCode == MemcachedResource::RES_SUCCESS) {
+ return true;
+ } elseif ($rsCode == MemcachedResource::RES_NOTFOUND) {
+ return false;
+ } else {
+ throw $this->getExceptionByResultCode($rsCode);
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to test multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Array of found keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalHasItems(array & $normalizedKeys)
+ {
+ $memc = $this->getMemcachedResource();
+
+ foreach ($normalizedKeys as & $normalizedKey) {
+ $normalizedKey = $this->namespacePrefix . $normalizedKey;
+ }
+
+ $result = $memc->getMulti($normalizedKeys);
+ if ($result === false) {
+ throw $this->getExceptionByResultCode($memc->getResultCode());
+ }
+
+ // Convert to a simgle list
+ $result = array_keys($result);
+
+ // remove namespace prefix
+ if ($result && $this->namespacePrefix !== '') {
+ $nsPrefixLength = strlen($this->namespacePrefix);
+ foreach ($result as & $internalKey) {
+ $internalKey = substr($internalKey, $nsPrefixLength);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Get metadata of multiple items
+ *
+ * @param array $normalizedKeys
+ * @return array Associative array of keys and metadata
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetMetadatas(array & $normalizedKeys)
+ {
+ $memc = $this->getMemcachedResource();
+
+ foreach ($normalizedKeys as & $normalizedKey) {
+ $normalizedKey = $this->namespacePrefix . $normalizedKey;
+ }
+
+ $result = $memc->getMulti($normalizedKeys);
+ if ($result === false) {
+ throw $this->getExceptionByResultCode($memc->getResultCode());
+ }
+
+ // remove namespace prefix and use an empty array as metadata
+ if ($this->namespacePrefix !== '') {
+ $tmp = array();
+ $nsPrefixLength = strlen($this->namespacePrefix);
+ foreach (array_keys($result) as $internalKey) {
+ $tmp[substr($internalKey, $nsPrefixLength)] = array();
+ }
+ $result = $tmp;
+ } else {
+ foreach ($result as & $value) {
+ $value = array();
+ }
+ }
+
+ return $result;
+ }
+
+ /* writing */
+
+ /**
+ * Internal method to store an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItem(& $normalizedKey, & $value)
+ {
+ $memc = $this->getMemcachedResource();
+ $expiration = $this->expirationTime();
+ if (!$memc->set($this->namespacePrefix . $normalizedKey, $value, $expiration)) {
+ throw $this->getExceptionByResultCode($memc->getResultCode());
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to store multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItems(array & $normalizedKeyValuePairs)
+ {
+ $memc = $this->getMemcachedResource();
+ $expiration = $this->expirationTime();
+
+ $namespacedKeyValuePairs = array();
+ foreach ($normalizedKeyValuePairs as $normalizedKey => & $value) {
+ $namespacedKeyValuePairs[$this->namespacePrefix . $normalizedKey] = & $value;
+ }
+
+ if (!$memc->setMulti($namespacedKeyValuePairs, $expiration)) {
+ throw $this->getExceptionByResultCode($memc->getResultCode());
+ }
+
+ return array();
+ }
+
+ /**
+ * Add an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalAddItem(& $normalizedKey, & $value)
+ {
+ $memc = $this->getMemcachedResource();
+ $expiration = $this->expirationTime();
+ if (!$memc->add($this->namespacePrefix . $normalizedKey, $value, $expiration)) {
+ if ($memc->getResultCode() == MemcachedResource::RES_NOTSTORED) {
+ return false;
+ }
+ throw $this->getExceptionByResultCode($memc->getResultCode());
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to replace an existing item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalReplaceItem(& $normalizedKey, & $value)
+ {
+ $memc = $this->getMemcachedResource();
+ $expiration = $this->expirationTime();
+ if (!$memc->replace($this->namespacePrefix . $normalizedKey, $value, $expiration)) {
+ $rsCode = $memc->getResultCode();
+ if ($rsCode == MemcachedResource::RES_NOTSTORED) {
+ return false;
+ }
+ throw $this->getExceptionByResultCode($rsCode);
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to set an item only if token matches
+ *
+ * @param mixed $token
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ * @see getItem()
+ * @see setItem()
+ */
+ protected function internalCheckAndSetItem(& $token, & $normalizedKey, & $value)
+ {
+ $memc = $this->getMemcachedResource();
+ $expiration = $this->expirationTime();
+ $result = $memc->cas($token, $this->namespacePrefix . $normalizedKey, $value, $expiration);
+
+ if ($result === false) {
+ $rsCode = $memc->getResultCode();
+ if ($rsCode !== 0 && $rsCode != MemcachedResource::RES_DATA_EXISTS) {
+ throw $this->getExceptionByResultCode($rsCode);
+ }
+ }
+
+
+ return $result;
+ }
+
+ /**
+ * Internal method to remove an item.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalRemoveItem(& $normalizedKey)
+ {
+ $memc = $this->getMemcachedResource();
+ $result = $memc->delete($this->namespacePrefix . $normalizedKey);
+
+ if ($result === false) {
+ $rsCode = $memc->getResultCode();
+ if ($rsCode == MemcachedResource::RES_NOTFOUND) {
+ return false;
+ } elseif ($rsCode != MemcachedResource::RES_SUCCESS) {
+ throw $this->getExceptionByResultCode($rsCode);
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to remove multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Array of not removed keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalRemoveItems(array & $normalizedKeys)
+ {
+ // support for removing multiple items at once has been added in ext/memcached-2.0.0
+ if (static::$extMemcachedMajorVersion < 2) {
+ return parent::internalRemoveItems($normalizedKeys);
+ }
+
+ $memc = $this->getMemcachedResource();
+
+ foreach ($normalizedKeys as & $normalizedKey) {
+ $normalizedKey = $this->namespacePrefix . $normalizedKey;
+ }
+
+ $rsCodes = $memc->deleteMulti($normalizedKeys);
+
+ $missingKeys = array();
+ foreach ($rsCodes as $key => $rsCode) {
+ if ($rsCode !== true && $rsCode != MemcachedResource::RES_SUCCESS) {
+ if ($rsCode != MemcachedResource::RES_NOTFOUND) {
+ throw $this->getExceptionByResultCode($rsCode);
+ }
+ $missingKeys[] = $key;
+ }
+ }
+
+ // remove namespace prefix
+ if ($missingKeys && $this->namespacePrefix !== '') {
+ $nsPrefixLength = strlen($this->namespacePrefix);
+ foreach ($missingKeys as & $missingKey) {
+ $missingKey = substr($missingKey, $nsPrefixLength);
+ }
+ }
+
+ return $missingKeys;
+ }
+
+ /**
+ * Internal method to increment an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalIncrementItem(& $normalizedKey, & $value)
+ {
+ $memc = $this->getMemcachedResource();
+ $internalKey = $this->namespacePrefix . $normalizedKey;
+ $value = (int) $value;
+ $newValue = $memc->increment($internalKey, $value);
+
+ if ($newValue === false) {
+ $rsCode = $memc->getResultCode();
+
+ // initial value
+ if ($rsCode == MemcachedResource::RES_NOTFOUND) {
+ $newValue = $value;
+ $memc->add($internalKey, $newValue, $this->expirationTime());
+ $rsCode = $memc->getResultCode();
+ }
+
+ if ($rsCode) {
+ throw $this->getExceptionByResultCode($rsCode);
+ }
+ }
+
+ return $newValue;
+ }
+
+ /**
+ * Internal method to decrement an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalDecrementItem(& $normalizedKey, & $value)
+ {
+ $memc = $this->getMemcachedResource();
+ $internalKey = $this->namespacePrefix . $normalizedKey;
+ $value = (int) $value;
+ $newValue = $memc->decrement($internalKey, $value);
+
+ if ($newValue === false) {
+ $rsCode = $memc->getResultCode();
+
+ // initial value
+ if ($rsCode == MemcachedResource::RES_NOTFOUND) {
+ $newValue = -$value;
+ $memc->add($internalKey, $newValue, $this->expirationTime());
+ $rsCode = $memc->getResultCode();
+ }
+
+ if ($rsCode) {
+ throw $this->getExceptionByResultCode($rsCode);
+ }
+ }
+
+ return $newValue;
+ }
+
+ /* status */
+
+ /**
+ * Internal method to get capabilities of this adapter
+ *
+ * @return Capabilities
+ */
+ protected function internalGetCapabilities()
+ {
+ if ($this->capabilities === null) {
+ $this->capabilityMarker = new stdClass();
+ $this->capabilities = new Capabilities(
+ $this,
+ $this->capabilityMarker,
+ array(
+ 'supportedDatatypes' => array(
+ 'NULL' => true,
+ 'boolean' => true,
+ 'integer' => true,
+ 'double' => true,
+ 'string' => true,
+ 'array' => true,
+ 'object' => 'object',
+ 'resource' => false,
+ ),
+ 'supportedMetadata' => array(),
+ 'minTtl' => 1,
+ 'maxTtl' => 0,
+ 'staticTtl' => true,
+ 'ttlPrecision' => 1,
+ 'useRequestTime' => false,
+ 'expiredRead' => false,
+ 'maxKeyLength' => 255,
+ 'namespaceIsPrefix' => true,
+ )
+ );
+ }
+
+ return $this->capabilities;
+ }
+
+ /* internal */
+
+ /**
+ * Get expiration time by ttl
+ *
+ * Some storage commands involve sending an expiration value (relative to
+ * an item or to an operation requested by the client) to the server. In
+ * all such cases, the actual value sent may either be Unix time (number of
+ * seconds since January 1, 1970, as an integer), or a number of seconds
+ * starting from current time. In the latter case, this number of seconds
+ * may not exceed 60*60*24*30 (number of seconds in 30 days); if the
+ * expiration value is larger than that, the server will consider it to be
+ * real Unix time value rather than an offset from current time.
+ *
+ * @return int
+ */
+ protected function expirationTime()
+ {
+ $ttl = $this->getOptions()->getTtl();
+ if ($ttl > 2592000) {
+ return time() + $ttl;
+ }
+ return $ttl;
+ }
+
+ /**
+ * Generate exception based of memcached result code
+ *
+ * @param int $code
+ * @return Exception\RuntimeException
+ * @throws Exception\InvalidArgumentException On success code
+ */
+ protected function getExceptionByResultCode($code)
+ {
+ switch ($code) {
+ case MemcachedResource::RES_SUCCESS:
+ throw new Exception\InvalidArgumentException(
+ "The result code '{$code}' (SUCCESS) isn't an error"
+ );
+
+ default:
+ return new Exception\RuntimeException($this->getMemcachedResource()->getResultMessage());
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/MemcachedResourceManager.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/MemcachedResourceManager.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/MemcachedResourceManager.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/MemcachedResourceManager.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,549 @@
+resources[$id]);
+ }
+
+ /**
+ * Gets a memcached resource
+ *
+ * @param string $id
+ * @return MemcachedResource
+ * @throws Exception\RuntimeException
+ */
+ public function getResource($id)
+ {
+ if (!$this->hasResource($id)) {
+ throw new Exception\RuntimeException("No resource with id '{$id}'");
+ }
+
+ $resource = $this->resources[$id];
+ if ($resource instanceof MemcachedResource) {
+ return $resource;
+ }
+
+ if ($resource['persistent_id'] !== '') {
+ $memc = new MemcachedResource($resource['persistent_id']);
+ } else {
+ $memc = new MemcachedResource();
+ }
+
+ if (method_exists($memc, 'setOptions')) {
+ $memc->setOptions($resource['lib_options']);
+ } else {
+ foreach ($resource['lib_options'] as $k => $v) {
+ $memc->setOption($k, $v);
+ }
+ }
+
+ // merge and add servers (with persistence id servers could be added already)
+ $servers = array_udiff($resource['servers'], $memc->getServerList(), array($this, 'compareServers'));
+ if ($servers) {
+ $memc->addServers($servers);
+ }
+
+ // buffer and return
+ $this->resources[$id] = $memc;
+ return $memc;
+ }
+
+ /**
+ * Set a resource
+ *
+ * @param string $id
+ * @param array|Traversable|MemcachedResource $resource
+ * @return MemcachedResourceManager Fluent interface
+ */
+ public function setResource($id, $resource)
+ {
+ $id = (string) $id;
+
+ if (!($resource instanceof MemcachedResource)) {
+ if ($resource instanceof Traversable) {
+ $resource = ArrayUtils::iteratorToArray($resource);
+ } elseif (!is_array($resource)) {
+ throw new Exception\InvalidArgumentException(
+ 'Resource must be an instance of Memcached or an array or Traversable'
+ );
+ }
+
+ $resource = array_merge(array(
+ 'persistent_id' => '',
+ 'lib_options' => array(),
+ 'servers' => array(),
+ ), $resource);
+
+ // normalize and validate params
+ $this->normalizePersistentId($resource['persistent_id']);
+ $this->normalizeLibOptions($resource['lib_options']);
+ $this->normalizeServers($resource['servers']);
+ }
+
+ $this->resources[$id] = $resource;
+ return $this;
+ }
+
+ /**
+ * Remove a resource
+ *
+ * @param string $id
+ * @return MemcachedResourceManager Fluent interface
+ */
+ public function removeResource($id)
+ {
+ unset($this->resources[$id]);
+ return $this;
+ }
+
+ /**
+ * Set the persistent id
+ *
+ * @param string $id
+ * @param string $persistentId
+ * @return MemcachedResourceManager Fluent interface
+ * @throws Exception\RuntimeException
+ */
+ public function setPersistentId($id, $persistentId)
+ {
+ if (!$this->hasResource($id)) {
+ return $this->setResource($id, array(
+ 'persistent_id' => $persistentId
+ ));
+ }
+
+ $resource = & $this->resources[$id];
+ if ($resource instanceof MemcachedResource) {
+ throw new Exception\RuntimeException(
+ "Can't change persistent id of resource {$id} after instanziation"
+ );
+ }
+
+ $this->normalizePersistentId($persistentId);
+ $resource['persistent_id'] = $persistentId;
+
+ return $this;
+ }
+
+ /**
+ * Get the persistent id
+ *
+ * @param string $id
+ * @return string
+ * @throws Exception\RuntimeException
+ */
+ public function getPersistentId($id)
+ {
+ if (!$this->hasResource($id)) {
+ throw new Exception\RuntimeException("No resource with id '{$id}'");
+ }
+
+ $resource = & $this->resources[$id];
+
+ if ($resource instanceof MemcachedResource) {
+ throw new Exception\RuntimeException(
+ "Can't get persistent id of an instantiated memcached resource"
+ );
+ }
+
+ return $resource['persistent_id'];
+ }
+
+ /**
+ * Normalize the persistent id
+ *
+ * @param string $persistentId
+ */
+ protected function normalizePersistentId(& $persistentId)
+ {
+ $persistentId = (string) $persistentId;
+ }
+
+ /**
+ * Set Libmemcached options
+ *
+ * @param string $id
+ * @param array $libOptions
+ * @return MemcachedResourceManager Fluent interface
+ */
+ public function setLibOptions($id, array $libOptions)
+ {
+ if (!$this->hasResource($id)) {
+ return $this->setResource($id, array(
+ 'lib_options' => $libOptions
+ ));
+ }
+
+ $this->normalizeLibOptions($libOptions);
+
+ $resource = & $this->resources[$id];
+ if ($resource instanceof MemcachedResource) {
+ if (method_exists($resource, 'setOptions')) {
+ $resource->setOptions($libOptions);
+ } else {
+ foreach ($libOptions as $key => $value) {
+ $resource->setOption($key, $value);
+ }
+ }
+ } else {
+ $resource['lib_options'] = $libOptions;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get Libmemcached options
+ *
+ * @param string $id
+ * @return array
+ * @throws Exception\RuntimeException
+ */
+ public function getLibOptions($id)
+ {
+ if (!$this->hasResource($id)) {
+ throw new Exception\RuntimeException("No resource with id '{$id}'");
+ }
+
+ $resource = & $this->resources[$id];
+
+ if ($resource instanceof MemcachedResource) {
+ $libOptions = array();
+ $reflection = new ReflectionClass('Memcached');
+ $constants = $reflection->getConstants();
+ foreach ($constants as $constName => $constValue) {
+ if (substr($constName, 0, 4) == 'OPT_') {
+ $libOptions[$constValue] = $resource->getOption($constValue);
+ }
+ }
+ return $libOptions;
+ }
+ return $resource['lib_options'];
+ }
+
+ /**
+ * Set one Libmemcached option
+ *
+ * @param string $id
+ * @param string|int $key
+ * @param mixed $value
+ * @return MemcachedResourceManager Fluent interface
+ */
+ public function setLibOption($id, $key, $value)
+ {
+ return $this->setLibOptions($id, array($key => $value));
+ }
+
+ /**
+ * Get one Libmemcached option
+ *
+ * @param string $id
+ * @param string|int $key
+ * @return mixed
+ * @throws Exception\RuntimeException
+ */
+ public function getLibOption($id, $key)
+ {
+ if (!$this->hasResource($id)) {
+ throw new Exception\RuntimeException("No resource with id '{$id}'");
+ }
+
+ $this->normalizeLibOptionKey($key);
+ $resource = & $this->resources[$id];
+
+ if ($resource instanceof MemcachedResource) {
+ return $resource->getOption($key);
+ }
+
+ return isset($resource['lib_options'][$key]) ? $resource['lib_options'][$key] : null;
+ }
+
+ /**
+ * Normalize libmemcached options
+ *
+ * @param array|Traversable $libOptions
+ * @throws Exception\InvalidArgumentException
+ */
+ protected function normalizeLibOptions(& $libOptions)
+ {
+ if (!is_array($libOptions) && !($libOptions instanceof Traversable)) {
+ throw new Exception\InvalidArgumentException(
+ "Lib-Options must be an array or an instance of Traversable"
+ );
+ }
+
+ $result = array();
+ foreach ($libOptions as $key => $value) {
+ $this->normalizeLibOptionKey($key);
+ $result[$key] = $value;
+ }
+
+ $libOptions = $result;
+ }
+
+ /**
+ * Convert option name into it's constant value
+ *
+ * @param string|int $key
+ * @throws Exception\InvalidArgumentException
+ */
+ protected function normalizeLibOptionKey(& $key)
+ {
+ // convert option name into it's constant value
+ if (is_string($key)) {
+ $const = 'Memcached::OPT_' . str_replace(array(' ', '-'), '_', strtoupper($key));
+ if (!defined($const)) {
+ throw new Exception\InvalidArgumentException("Unknown libmemcached option '{$key}' ({$const})");
+ }
+ $key = constant($const);
+ } else {
+ $key = (int) $key;
+ }
+ }
+
+ /**
+ * Set servers
+ *
+ * $servers can be an array list or a comma separated list of servers.
+ * One server in the list can be descripted as follows:
+ * - URI: [tcp://][:][?weight=]
+ * - Assoc: array('host' => [, 'port' => ][, 'weight' => ])
+ * - List: array([, ][, ])
+ *
+ * @param string $id
+ * @param string|array $servers
+ * @return MemcachedResourceManager
+ */
+ public function setServers($id, $servers)
+ {
+ if (!$this->hasResource($id)) {
+ return $this->setResource($id, array(
+ 'servers' => $servers
+ ));
+ }
+
+ $this->normalizeServers($servers);
+
+ $resource = & $this->resources[$id];
+ if ($resource instanceof MemcachedResource) {
+ // don't add servers twice
+ $servers = array_udiff($servers, $resource->getServerList(), array($this, 'compareServers'));
+ if ($servers) {
+ $resource->addServers($servers);
+ }
+ } else {
+ $resource['servers'] = $servers;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get servers
+ * @param string $id
+ * @throws Exception\RuntimeException
+ * @return array array('host' => , 'port' => , 'weight' => )
+ */
+ public function getServers($id)
+ {
+ if (!$this->hasResource($id)) {
+ throw new Exception\RuntimeException("No resource with id '{$id}'");
+ }
+
+ $resource = & $this->resources[$id];
+
+ if ($resource instanceof MemcachedResource) {
+ return $resource->getServerList();
+ }
+ return $resource['servers'];
+ }
+
+ /**
+ * Add servers
+ *
+ * @param string $id
+ * @param string|array $servers
+ * @return MemcachedResourceManager
+ */
+ public function addServers($id, $servers)
+ {
+ if (!$this->hasResource($id)) {
+ return $this->setResource($id, array(
+ 'servers' => $servers
+ ));
+ }
+
+ $this->normalizeServers($servers);
+
+ $resource = & $this->resources[$id];
+ if ($resource instanceof MemcachedResource) {
+ // don't add servers twice
+ $servers = array_udiff($servers, $resource->getServerList(), array($this, 'compareServers'));
+ if ($servers) {
+ $resource->addServers($servers);
+ }
+ } else {
+ // don't add servers twice
+ $resource['servers'] = array_merge(
+ $resource['servers'],
+ array_udiff($servers, $resource['servers'], array($this, 'compareServers'))
+ );
+ }
+
+ return $this;
+ }
+
+ /**
+ * Add one server
+ *
+ * @param string $id
+ * @param string|array $server
+ * @return MemcachedResourceManager
+ */
+ public function addServer($id, $server)
+ {
+ return $this->addServers($id, array($server));
+ }
+
+ /**
+ * Normalize a list of servers into the following format:
+ * array(array('host' => , 'port' => , 'weight' => )[, ...])
+ *
+ * @param string|array $servers
+ */
+ protected function normalizeServers(& $servers)
+ {
+ if (!is_array($servers) && !$servers instanceof Traversable) {
+ // Convert string into a list of servers
+ $servers = explode(',', $servers);
+ }
+
+ $result = array();
+ foreach ($servers as $server) {
+ $this->normalizeServer($server);
+ $result[$server['host'] . ':' . $server['port']] = $server;
+ }
+
+ $servers = array_values($result);
+ }
+
+ /**
+ * Normalize one server into the following format:
+ * array('host' => , 'port' => , 'weight' => )
+ *
+ * @param string|array $server
+ * @throws Exception\InvalidArgumentException
+ */
+ protected function normalizeServer(& $server)
+ {
+ $host = null;
+ $port = 11211;
+ $weight = 0;
+
+ // convert a single server into an array
+ if ($server instanceof Traversable) {
+ $server = ArrayUtils::iteratorToArray($server);
+ }
+
+ if (is_array($server)) {
+ // array([, [, ]])
+ if (isset($server[0])) {
+ $host = (string) $server[0];
+ $port = isset($server[1]) ? (int) $server[1] : $port;
+ $weight = isset($server[2]) ? (int) $server[2] : $weight;
+ }
+
+ // array('host' => [, 'port' => [, 'weight' => ]])
+ if (!isset($server[0]) && isset($server['host'])) {
+ $host = (string) $server['host'];
+ $port = isset($server['port']) ? (int) $server['port'] : $port;
+ $weight = isset($server['weight']) ? (int) $server['weight'] : $weight;
+ }
+
+ } else {
+ // parse server from URI host{:?port}{?weight}
+ $server = trim($server);
+ if (strpos($server, '://') === false) {
+ $server = 'tcp://' . $server;
+ }
+
+ $server = parse_url($server);
+ if (!$server) {
+ throw new Exception\InvalidArgumentException("Invalid server given");
+ }
+
+ $host = $server['host'];
+ $port = isset($server['port']) ? (int) $server['port'] : $port;
+
+ if (isset($server['query'])) {
+ $query = null;
+ parse_str($server['query'], $query);
+ if (isset($query['weight'])) {
+ $weight = (int) $query['weight'];
+ }
+ }
+ }
+
+ if (!$host) {
+ throw new Exception\InvalidArgumentException('Missing required server host');
+ }
+
+ $server = array(
+ 'host' => $host,
+ 'port' => $port,
+ 'weight' => $weight,
+ );
+ }
+
+ /**
+ * Compare 2 normalized server arrays
+ * (Compares only the host and the port)
+ *
+ * @param array $serverA
+ * @param array $serverB
+ * @return int
+ */
+ protected function compareServers(array $serverA, array $serverB)
+ {
+ $keyA = $serverA['host'] . ':' . $serverA['port'];
+ $keyB = $serverB['host'] . ':' . $serverB['port'];
+ if ($keyA === $keyB) {
+ return 0;
+ }
+ return $keyA > $keyB ? 1 : -1;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/MemoryOptions.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/MemoryOptions.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/MemoryOptions.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/MemoryOptions.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,112 @@
+normalizeMemoryLimit($memoryLimit);
+
+ if ($this->memoryLimit != $memoryLimit) {
+ $this->triggerOptionEvent('memory_limit', $memoryLimit);
+ $this->memoryLimit = $memoryLimit;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get memory limit
+ *
+ * If the used memory of PHP exceeds this limit an OutOfSpaceException
+ * will be thrown.
+ *
+ * @return int
+ */
+ public function getMemoryLimit()
+ {
+ if ($this->memoryLimit === null) {
+ // By default use half of PHP's memory limit if possible
+ $memoryLimit = $this->normalizeMemoryLimit(ini_get('memory_limit'));
+ if ($memoryLimit >= 0) {
+ $this->memoryLimit = (int) ($memoryLimit / 2);
+ } else {
+ // disable memory limit
+ $this->memoryLimit = 0;
+ }
+ }
+
+ return $this->memoryLimit;
+ }
+
+ /**
+ * Normalized a given value of memory limit into the number of bytes
+ *
+ * @param string|int $value
+ * @throws Exception\InvalidArgumentException
+ * @return int
+ */
+ protected function normalizeMemoryLimit($value)
+ {
+ if (is_numeric($value)) {
+ return (int) $value;
+ }
+
+ if (!preg_match('/(\-?\d+)\s*(\w*)/', ini_get('memory_limit'), $matches)) {
+ throw new Exception\InvalidArgumentException("Invalid memory limit '{$value}'");
+ }
+
+ $value = (int) $matches[1];
+ if ($value <= 0) {
+ return 0;
+ }
+
+ switch (strtoupper($matches[2])) {
+ case 'G':
+ $value*= 1024;
+ // no break
+
+ case 'M':
+ $value*= 1024;
+ // no break
+
+ case 'K':
+ $value*= 1024;
+ // no break
+ }
+
+ return $value;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Memory.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Memory.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Memory.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Memory.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,757 @@
+ => array(
+ * => array(
+ * 0 =>
+ * 1 =>
+ * ['tags' => ]
+ * )
+ * )
+ * )
+ *
+ * @var array
+ */
+ protected $data = array();
+
+ /**
+ * Set options.
+ *
+ * @param array|\Traversable|MemoryOptions $options
+ * @return Memory
+ * @see getOptions()
+ */
+ public function setOptions($options)
+ {
+ if (!$options instanceof MemoryOptions) {
+ $options = new MemoryOptions($options);
+ }
+
+ return parent::setOptions($options);
+ }
+
+ /**
+ * Get options.
+ *
+ * @return MemoryOptions
+ * @see setOptions()
+ */
+ public function getOptions()
+ {
+ if (!$this->options) {
+ $this->setOptions(new MemoryOptions());
+ }
+ return $this->options;
+ }
+
+ /* TotalSpaceCapableInterface */
+
+ /**
+ * Get total space in bytes
+ *
+ * @return int|float
+ */
+ public function getTotalSpace()
+ {
+ return $this->getOptions()->getMemoryLimit();
+ }
+
+ /* AvailableSpaceCapableInterface */
+
+ /**
+ * Get available space in bytes
+ *
+ * @return int|float
+ */
+ public function getAvailableSpace()
+ {
+ $total = $this->getOptions()->getMemoryLimit();
+ $avail = $total - (float) memory_get_usage(true);
+ return ($avail > 0) ? $avail : 0;
+ }
+
+ /* IterableInterface */
+
+ /**
+ * Get the storage iterator
+ *
+ * @return KeyListIterator
+ */
+ public function getIterator()
+ {
+ $ns = $this->getOptions()->getNamespace();
+ $keys = array();
+
+ if (isset($this->data[$ns])) {
+ foreach ($this->data[$ns] as $key => & $tmp) {
+ if ($this->internalHasItem($key)) {
+ $keys[] = $key;
+ }
+ }
+ }
+
+ return new KeyListIterator($this, $keys);
+ }
+
+ /* FlushableInterface */
+
+ /**
+ * Flush the whole storage
+ *
+ * @return bool
+ */
+ public function flush()
+ {
+ $this->data = array();
+ return true;
+ }
+
+ /* ClearExpiredInterface */
+
+ /**
+ * Remove expired items
+ *
+ * @return bool
+ */
+ public function clearExpired()
+ {
+ $ttl = $this->getOptions()->getTtl();
+ if ($ttl <= 0) {
+ return true;
+ }
+
+ $ns = $this->getOptions()->getNamespace();
+ if (!isset($this->data[$ns])) {
+ return true;
+ }
+
+ $data = & $this->data[$ns];
+ foreach ($data as $key => & $item) {
+ if (microtime(true) >= $data[$key][1] + $ttl) {
+ unset($data[$key]);
+ }
+ }
+
+ return true;
+ }
+
+ /* ClearByNamespaceInterface */
+
+ public function clearByNamespace($namespace)
+ {
+ $namespace = (string) $namespace;
+ if ($namespace === '') {
+ throw new Exception\InvalidArgumentException('No namespace given');
+ }
+
+ unset($this->data[$namespace]);
+ return true;
+ }
+
+ /* ClearByPrefixInterface */
+
+ /**
+ * Remove items matching given prefix
+ *
+ * @param string $prefix
+ * @return bool
+ */
+ public function clearByPrefix($prefix)
+ {
+ $prefix = (string) $prefix;
+ if ($prefix === '') {
+ throw new Exception\InvalidArgumentException('No prefix given');
+ }
+
+ $ns = $this->getOptions()->getNamespace();
+ if (!isset($this->data[$ns])) {
+ return true;
+ }
+
+ $prefixL = strlen($prefix);
+ $data = & $this->data[$ns];
+ foreach ($data as $key => & $item) {
+ if (substr($key, 0, $prefixL) === $prefix) {
+ unset($data[$key]);
+ }
+ }
+
+ return true;
+ }
+
+ /* TaggableInterface */
+
+ /**
+ * Set tags to an item by given key.
+ * An empty array will remove all tags.
+ *
+ * @param string $key
+ * @param string[] $tags
+ * @return bool
+ */
+ public function setTags($key, array $tags)
+ {
+ $ns = $this->getOptions()->getNamespace();
+ if (!$this->data[$ns]) {
+ return false;
+ }
+
+ $data = & $this->data[$ns];
+ if (isset($data[$key])) {
+ $data[$key]['tags'] = $tags;
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Get tags of an item by given key
+ *
+ * @param string $key
+ * @return string[]|FALSE
+ */
+ public function getTags($key)
+ {
+ $ns = $this->getOptions()->getNamespace();
+ if (!$this->data[$ns]) {
+ return false;
+ }
+
+ $data = & $this->data[$ns];
+ if (!isset($data[$key])) {
+ return false;
+ }
+
+ return isset($data[$key]['tags']) ? $data[$key]['tags'] : array();
+ }
+
+ /**
+ * Remove items matching given tags.
+ *
+ * If $disjunction only one of the given tags must match
+ * else all given tags must match.
+ *
+ * @param string[] $tags
+ * @param bool $disjunction
+ * @return bool
+ */
+ public function clearByTags(array $tags, $disjunction = false)
+ {
+ $ns = $this->getOptions()->getNamespace();
+ if (!$this->data[$ns]) {
+ return true;
+ }
+
+ $tagCount = count($tags);
+ $data = & $this->data[$ns];
+ foreach ($data as $key => & $item) {
+ if (isset($item['tags'])) {
+ $diff = array_diff($tags, $item['tags']);
+ if (($disjunction && count($diff) < $tagCount) || (!$disjunction && !$diff)) {
+ unset($data[$key]);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /* reading */
+
+ /**
+ * Internal method to get an item.
+ *
+ * @param string $normalizedKey
+ * @param bool $success
+ * @param mixed $casToken
+ * @return mixed Data on success, null on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
+ {
+ $options = $this->getOptions();
+ $ns = $options->getNamespace();
+ $success = isset($this->data[$ns][$normalizedKey]);
+ if ($success) {
+ $data = & $this->data[$ns][$normalizedKey];
+ $ttl = $options->getTtl();
+ if ($ttl && microtime(true) >= ($data[1] + $ttl)) {
+ $success = false;
+ }
+ }
+
+ if (!$success) {
+ return null;
+ }
+
+ $casToken = $data[0];
+ return $data[0];
+ }
+
+ /**
+ * Internal method to get multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Associative array of keys and values
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItems(array & $normalizedKeys)
+ {
+ $options = $this->getOptions();
+ $ns = $options->getNamespace();
+ if (!isset($this->data[$ns])) {
+ return array();
+ }
+
+ $data = & $this->data[$ns];
+ $ttl = $options->getTtl();
+ $now = microtime(true);
+
+ $result = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ if (isset($data[$normalizedKey])) {
+ if (!$ttl || $now < ($data[$normalizedKey][1] + $ttl)) {
+ $result[$normalizedKey] = $data[$normalizedKey][0];
+ }
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to test if an item exists.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ */
+ protected function internalHasItem(& $normalizedKey)
+ {
+ $options = $this->getOptions();
+ $ns = $options->getNamespace();
+ if (!isset($this->data[$ns][$normalizedKey])) {
+ return false;
+ }
+
+ // check if expired
+ $ttl = $options->getTtl();
+ if ($ttl && microtime(true) >= ($this->data[$ns][$normalizedKey][1] + $ttl)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to test multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Array of found keys
+ */
+ protected function internalHasItems(array & $normalizedKeys)
+ {
+ $options = $this->getOptions();
+ $ns = $options->getNamespace();
+ if (!isset($this->data[$ns])) {
+ return array();
+ }
+
+ $data = & $this->data[$ns];
+ $ttl = $options->getTtl();
+ $now = microtime(true);
+
+ $result = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ if (isset($data[$normalizedKey])) {
+ if (!$ttl || $now < ($data[$normalizedKey][1] + $ttl)) {
+ $result[] = $normalizedKey;
+ }
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Get metadata of an item.
+ *
+ * @param string $normalizedKey
+ * @return array|bool Metadata on success, false on failure
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers getMetadata.pre(PreEvent)
+ * @triggers getMetadata.post(PostEvent)
+ * @triggers getMetadata.exception(ExceptionEvent)
+ */
+ protected function internalGetMetadata(& $normalizedKey)
+ {
+ if (!$this->internalHasItem($normalizedKey)) {
+ return false;
+ }
+
+ $ns = $this->getOptions()->getNamespace();
+ return array(
+ 'mtime' => $this->data[$ns][$normalizedKey][1],
+ );
+ }
+
+ /* writing */
+
+ /**
+ * Internal method to store an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+
+ if (!$this->hasAvailableSpace()) {
+ $memoryLimit = $options->getMemoryLimit();
+ throw new Exception\OutOfSpaceException(
+ "Memory usage exceeds limit ({$memoryLimit})."
+ );
+ }
+
+ $ns = $options->getNamespace();
+ $this->data[$ns][$normalizedKey] = array($value, microtime(true));
+
+ return true;
+ }
+
+ /**
+ * Internal method to store multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItems(array & $normalizedKeyValuePairs)
+ {
+ $options = $this->getOptions();
+
+ if (!$this->hasAvailableSpace()) {
+ $memoryLimit = $options->getMemoryLimit();
+ throw new Exception\OutOfSpaceException(
+ "Memory usage exceeds limit ({$memoryLimit})."
+ );
+ }
+
+ $ns = $options->getNamespace();
+ if (!isset($this->data[$ns])) {
+ $this->data[$ns] = array();
+ }
+
+ $data = & $this->data[$ns];
+ $now = microtime(true);
+ foreach ($normalizedKeyValuePairs as $normalizedKey => $value) {
+ $data[$normalizedKey] = array($value, $now);
+ }
+
+ return array();
+ }
+
+ /**
+ * Add an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalAddItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+
+ if (!$this->hasAvailableSpace()) {
+ $memoryLimit = $options->getMemoryLimit();
+ throw new Exception\OutOfSpaceException(
+ "Memory usage exceeds limit ({$memoryLimit})."
+ );
+ }
+
+ $ns = $options->getNamespace();
+ if (isset($this->data[$ns][$normalizedKey])) {
+ return false;
+ }
+
+ $this->data[$ns][$normalizedKey] = array($value, microtime(true));
+ return true;
+ }
+
+ /**
+ * Internal method to add multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalAddItems(array & $normalizedKeyValuePairs)
+ {
+ $options = $this->getOptions();
+
+ if (!$this->hasAvailableSpace()) {
+ $memoryLimit = $options->getMemoryLimit();
+ throw new Exception\OutOfSpaceException(
+ "Memory usage exceeds limit ({$memoryLimit})."
+ );
+ }
+
+ $ns = $options->getNamespace();
+ if (!isset($this->data[$ns])) {
+ $this->data[$ns] = array();
+ }
+
+ $result = array();
+ $data = & $this->data[$ns];
+ $now = microtime(true);
+ foreach ($normalizedKeyValuePairs as $normalizedKey => $value) {
+ if (isset($data[$normalizedKey])) {
+ $result[] = $normalizedKey;
+ } else {
+ $data[$normalizedKey] = array($value, $now);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to replace an existing item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalReplaceItem(& $normalizedKey, & $value)
+ {
+ $ns = $this->getOptions()->getNamespace();
+ if (!isset($this->data[$ns][$normalizedKey])) {
+ return false;
+ }
+ $this->data[$ns][$normalizedKey] = array($value, microtime(true));
+
+ return true;
+ }
+
+ /**
+ * Internal method to replace multiple existing items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalReplaceItems(array & $normalizedKeyValuePairs)
+ {
+ $ns = $this->getOptions()->getNamespace();
+ if (!isset($this->data[$ns])) {
+ return array_keys($normalizedKeyValuePairs);
+ }
+
+ $result = array();
+ $data = & $this->data[$ns];
+ foreach ($normalizedKeyValuePairs as $normalizedKey => $value) {
+ if (!isset($data[$normalizedKey])) {
+ $result[] = $normalizedKey;
+ } else {
+ $data[$normalizedKey] = array($value, microtime(true));
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to reset lifetime of an item
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalTouchItem(& $normalizedKey)
+ {
+ $ns = $this->getOptions()->getNamespace();
+
+ if (!isset($this->data[$ns][$normalizedKey])) {
+ return false;
+ }
+
+ $this->data[$ns][$normalizedKey][1] = microtime(true);
+ return true;
+ }
+
+ /**
+ * Internal method to remove an item.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalRemoveItem(& $normalizedKey)
+ {
+ $ns = $this->getOptions()->getNamespace();
+ if (!isset($this->data[$ns][$normalizedKey])) {
+ return false;
+ }
+
+ unset($this->data[$ns][$normalizedKey]);
+
+ // remove empty namespace
+ if (!$this->data[$ns]) {
+ unset($this->data[$ns]);
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to increment an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalIncrementItem(& $normalizedKey, & $value)
+ {
+ $ns = $this->getOptions()->getNamespace();
+ $data = & $this->data[$ns];
+ if (isset($data[$normalizedKey])) {
+ $data[$normalizedKey][0]+= $value;
+ $data[$normalizedKey][1] = microtime(true);
+ $newValue = $data[$normalizedKey][0];
+ } else {
+ // initial value
+ $newValue = $value;
+ $data[$normalizedKey] = array($newValue, microtime(true));
+ }
+
+ return $newValue;
+ }
+
+ /**
+ * Internal method to decrement an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalDecrementItem(& $normalizedKey, & $value)
+ {
+ $ns = $this->getOptions()->getNamespace();
+ $data = & $this->data[$ns];
+ if (isset($data[$normalizedKey])) {
+ $data[$normalizedKey][0]-= $value;
+ $data[$normalizedKey][1] = microtime(true);
+ $newValue = $data[$normalizedKey][0];
+ } else {
+ // initial value
+ $newValue = -$value;
+ $data[$normalizedKey] = array($newValue, microtime(true));
+ }
+
+ return $newValue;
+ }
+
+ /* status */
+
+ /**
+ * Internal method to get capabilities of this adapter
+ *
+ * @return Capabilities
+ */
+ protected function internalGetCapabilities()
+ {
+ if ($this->capabilities === null) {
+ $this->capabilityMarker = new stdClass();
+ $this->capabilities = new Capabilities(
+ $this,
+ $this->capabilityMarker,
+ array(
+ 'supportedDatatypes' => array(
+ 'NULL' => true,
+ 'boolean' => true,
+ 'integer' => true,
+ 'double' => true,
+ 'string' => true,
+ 'array' => true,
+ 'object' => true,
+ 'resource' => true,
+ ),
+ 'supportedMetadata' => array('mtime'),
+ 'minTtl' => 1,
+ 'maxTtl' => PHP_INT_MAX,
+ 'staticTtl' => false,
+ 'ttlPrecision' => 0.05,
+ 'expiredRead' => true,
+ 'maxKeyLength' => 0,
+ 'namespaceIsPrefix' => false,
+ 'namespaceSeparator' => '',
+ )
+ );
+ }
+
+ return $this->capabilities;
+ }
+
+ /* internal */
+
+ /**
+ * Has space available to store items?
+ *
+ * @return bool
+ */
+ protected function hasAvailableSpace()
+ {
+ $total = $this->getOptions()->getMemoryLimit();
+
+ // check memory limit disabled
+ if ($total <= 0) {
+ return true;
+ }
+
+ $free = $total - (float) memory_get_usage(true);
+ return ($free > 0);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/RedisOptions.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/RedisOptions.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/RedisOptions.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/RedisOptions.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,263 @@
+namespaceSeparator !== $namespaceSeparator) {
+ $this->triggerOptionEvent('namespace_separator', $namespaceSeparator);
+ $this->namespaceSeparator = $namespaceSeparator;
+ }
+ return $this;
+ }
+
+ /**
+ * Get namespace separator
+ *
+ * @return string
+ */
+ public function getNamespaceSeparator()
+ {
+ return $this->namespaceSeparator;
+ }
+
+ /**
+ * Set the redis resource manager to use
+ *
+ * @param null|RedisResourceManager $resourceManager
+ * @return RedisOptions
+ */
+ public function setResourceManager(RedisResourceManager $resourceManager = null)
+ {
+ if ($this->resourceManager !== $resourceManager) {
+ $this->triggerOptionEvent('resource_manager', $resourceManager);
+ $this->resourceManager = $resourceManager;
+ }
+ return $this;
+ }
+
+ /**
+ * Get the redis resource manager
+ *
+ * @return RedisResourceManager
+ */
+ public function getResourceManager()
+ {
+ if (!$this->resourceManager) {
+ $this->resourceManager = new RedisResourceManager();
+ }
+ return $this->resourceManager;
+ }
+
+ /**
+ * Get the redis resource id
+ *
+ * @return string
+ */
+ public function getResourceId()
+ {
+ return $this->resourceId;
+ }
+
+ /**
+ * Set the redis resource id
+ *
+ * @param string $resourceId
+ * @return RedisOptions
+ */
+ public function setResourceId($resourceId)
+ {
+ $resourceId = (string) $resourceId;
+ if ($this->resourceId !== $resourceId) {
+ $this->triggerOptionEvent('resource_id', $resourceId);
+ $this->resourceId = $resourceId;
+ }
+ return $this;
+ }
+
+ /**
+ * Get the persistent id
+ *
+ * @return string
+ */
+ public function getPersistentId()
+ {
+ return $this->getResourceManager()->getPersistentId($this->getResourceId());
+ }
+
+ /**
+ * Set the persistent id
+ *
+ * @param string $persistentId
+ * @return RedisOptions
+ */
+ public function setPersistentId($persistentId)
+ {
+ $this->triggerOptionEvent('persistent_id', $persistentId);
+ $this->getResourceManager()->setPersistentId($this->getResourceId(), $persistentId);
+ return $this;
+ }
+
+ /**
+ * Set redis options
+ *
+ * @param array $libOptions
+ * @return RedisOptions
+ * @link http://github.com/nicolasff/phpredis#setoption
+ */
+ public function setLibOptions(array $libOptions)
+ {
+ $this->triggerOptionEvent('lib_option', $libOptions);
+ $this->getResourceManager()->setLibOptions($this->getResourceId(), $libOptions);
+ return $this;
+ }
+
+ /**
+ * Get redis options
+ *
+ * @return array
+ * @link http://github.com/nicolasff/phpredis#setoption
+ */
+ public function getLibOptions()
+ {
+ return $this->getResourceManager()->getLibOptions($this->getResourceId());
+ }
+
+ /**
+ * Set server
+ *
+ * Server can be described as follows:
+ * - URI: /path/to/sock.sock
+ * - Assoc: array('host' => [, 'port' => [, 'timeout' => ]])
+ * - List: array([, , [, ]])
+ *
+ * @param string|array $server
+ *
+ * @return RedisOptions
+ */
+ public function setServer($server)
+ {
+ $this->getResourceManager()->setServer($this->getResourceId(), $server);
+ return $this;
+ }
+
+ /**
+ * Get server
+ *
+ * @return array array('host' => [, 'port' => [, 'timeout' => ]])
+ */
+ public function getServer()
+ {
+ return $this->getResourceManager()->getServer($this->getResourceId());
+ }
+
+ /**
+ * Set resource database number
+ *
+ * @param int $database Database number
+ *
+ * @return RedisOptions
+ */
+ public function setDatabase($database)
+ {
+ $this->getResourceManager()->setDatabase($this->getResourceId(), $database);
+ return $this;
+ }
+
+ /**
+ * Get resource database number
+ *
+ * @return int Database number
+ */
+ public function getDatabase()
+ {
+ return $this->getResourceManager()->getDatabase($this->getResourceId());
+ }
+
+ /**
+ * Set resource password
+ *
+ * @param string $password Password
+ *
+ * @return RedisOptions
+ */
+ public function setPassword($password)
+ {
+ $this->getResourceManager()->setPassword($this->getResourceId(), $password);
+ return $this;
+ }
+
+ /**
+ * Get resource password
+ *
+ * @return string
+ */
+ public function getPassword()
+ {
+ return $this->getResourceManager()->getPassword($this->getResourceId());
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Redis.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Redis.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Redis.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Redis.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,435 @@
+initialized;
+ $this->getEventManager()->attach('option', function ($event) use (& $initialized) {
+ $initialized = false;
+ });
+ }
+
+ /**
+ * Get Redis resource
+ *
+ * @return RedisResource
+ */
+ protected function getRedisResource()
+ {
+ if (!$this->initialized) {
+ $options = $this->getOptions();
+
+ // get resource manager and resource id
+ $this->resourceManager = $options->getResourceManager();
+ $this->resourceId = $options->getResourceId();
+
+ // init namespace prefix
+ $namespace = $options->getNamespace();
+ if ($namespace !== '') {
+ $this->namespacePrefix = $namespace . $options->getNamespaceSeparator();
+ } else {
+ $this->namespacePrefix = '';
+ }
+
+ // update initialized flag
+ $this->initialized = true;
+ }
+
+ return $this->resourceManager->getResource($this->resourceId);
+ }
+
+ /* options */
+
+ /**
+ * Set options.
+ *
+ * @param array|Traversable|RedisOptions $options
+ * @return Redis
+ * @see getOptions()
+ */
+ public function setOptions($options)
+ {
+ if (!$options instanceof RedisOptions) {
+ $options = new RedisOptions($options);
+ }
+ return parent::setOptions($options);
+ }
+
+ /**
+ * Get options.
+ *
+ * @return RedisOptions
+ * @see setOptions()
+ */
+ public function getOptions()
+ {
+ if (!$this->options) {
+ $this->setOptions(new RedisOptions());
+ }
+ return $this->options;
+ }
+
+ /**
+ * Internal method to get an item.
+ *
+ * @param string &$normalizedKey Key where to store data
+ * @param bool &$success If the operation was successfull
+ * @param mixed &$casToken Token
+ * @return mixed Data on success, false on key not found
+ * @throws Exception\RuntimeException
+ */
+ protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
+ {
+ $redis = $this->getRedisResource();
+ try {
+ $value = $redis->get($this->namespacePrefix . $normalizedKey);
+ } catch (RedisResourceException $e) {
+ throw new Exception\RuntimeException($redis->getLastError(), $e->getCode(), $e);
+ }
+
+ if ($value === false) {
+ $success = false;
+ return null;
+ }
+
+ $success = true;
+ $casToken = $value;
+ return $value;
+ }
+
+ /**
+ * Internal method to get multiple items.
+ *
+ * @param array &$normalizedKeys Array of keys to be obtained
+ *
+ * @return array Associative array of keys and values
+ * @throws Exception\RuntimeException
+ */
+ protected function internalGetItems(array & $normalizedKeys)
+ {
+ $redis = $this->getRedisResource();
+
+ $namespacedKeys = array();
+ foreach ($normalizedKeys as & $normalizedKey) {
+ $namespacedKeys[] = $this->namespacePrefix . $normalizedKey;
+ }
+
+ try {
+ $results = $redis->mGet($namespacedKeys);
+ } catch (RedisResourceException $e) {
+ throw new Exception\RuntimeException($redis->getLastError(), $e->getCode(), $e);
+ }
+ //combine the key => value pairs and remove all missing values
+ return array_filter(
+ array_combine($normalizedKeys, $results),
+ function ($value) {
+ return $value !== false;
+ }
+ );
+ }
+
+ /**
+ * Internal method to test if an item exists.
+ *
+ * @param string &$normalizedKey Normalized key which will be checked
+ *
+ * @return bool
+ * @throws Exception\RuntimeException
+ */
+ protected function internalHasItem(& $normalizedKey)
+ {
+ $redis = $this->getRedisResource();
+ try {
+ return $redis->exists($this->namespacePrefix . $normalizedKey);
+ } catch (RedisResourceException $e) {
+ throw new Exception\RuntimeException($redis->getLastError(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * Internal method to store an item.
+ *
+ * @param string &$normalizedKey Key in Redis under which value will be saved
+ * @param mixed &$value Value to store under cache key
+ *
+ * @return bool
+ * @throws Exception\RuntimeException
+ */
+ protected function internalSetItem(& $normalizedKey, & $value)
+ {
+ $redis = $this->getRedisResource();
+ $ttl = $this->getOptions()->getTtl();
+
+ try {
+ if ($ttl) {
+ if ($this->resourceManager->getMajorVersion($this->resourceId) < 2) {
+ throw new Exception\UnsupportedMethodCallException("To use ttl you need version >= 2.0.0");
+ }
+ $success = $redis->setex($this->namespacePrefix . $normalizedKey, $ttl, $value);
+ } else {
+ $success = $redis->set($this->namespacePrefix . $normalizedKey, $value);
+ }
+ } catch (RedisResourceException $e) {
+ throw new Exception\RuntimeException($redis->getLastError(), $e->getCode(), $e);
+ }
+
+ return $success;
+ }
+
+ /**
+ * Internal method to store multiple items.
+ *
+ * @param array &$normalizedKeyValuePairs An array of normalized key/value pairs
+ *
+ * @return array Array of not stored keys
+ * @throws Exception\RuntimeException
+ */
+ protected function internalSetItems(array & $normalizedKeyValuePairs)
+ {
+ $redis = $this->getRedisResource();
+ $ttl = $this->getOptions()->getTtl();
+
+ $namespacedKeyValuePairs = array();
+ foreach ($normalizedKeyValuePairs as $normalizedKey => & $value) {
+ $namespacedKeyValuePairs[$this->namespacePrefix . $normalizedKey] = & $value;
+ }
+ try {
+ if ($ttl > 0) {
+ //check if ttl is supported
+ if ($this->resourceManager->getMajorVersion($this->resourceId) < 2) {
+ throw new Exception\UnsupportedMethodCallException("To use ttl you need version >= 2.0.0");
+ }
+ //mSet does not allow ttl, so use transaction
+ $transaction = $redis->multi();
+ foreach ($namespacedKeyValuePairs as $key => $value) {
+ $transaction->setex($key, $ttl, $value);
+ }
+ $success = $transaction->exec();
+ } else {
+ $success = $redis->mSet($namespacedKeyValuePairs);
+ }
+
+ } catch (RedisResourceException $e) {
+ throw new Exception\RuntimeException($redis->getLastError(), $e->getCode(), $e);
+ }
+ if (!$success) {
+ throw new Exception\RuntimeException($redis->getLastError());
+ }
+
+ return array();
+ }
+
+ /**
+ * Add an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\RuntimeException
+ */
+ protected function internalAddItem(& $normalizedKey, & $value)
+ {
+ $redis = $this->getRedisResource();
+ try {
+ return $redis->setnx($this->namespacePrefix . $normalizedKey, $value);
+ } catch (RedisResourceException $e) {
+ throw new Exception\RuntimeException($redis->getLastError(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * Internal method to remove an item.
+ *
+ * @param string &$normalizedKey Key which will be removed
+ *
+ * @return bool
+ * @throws Exception\RuntimeException
+ */
+ protected function internalRemoveItem(& $normalizedKey)
+ {
+ $redis = $this->getRedisResource();
+ try {
+ return (bool) $redis->delete($this->namespacePrefix . $normalizedKey);
+ } catch (RedisResourceException $e) {
+ throw new Exception\RuntimeException($redis->getLastError(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * Internal method to increment an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\RuntimeException
+ */
+ protected function internalIncrementItem(& $normalizedKey, & $value)
+ {
+ $redis = $this->getRedisResource();
+ try {
+ return $redis->incrBy($this->namespacePrefix . $normalizedKey, $value);
+ } catch (RedisResourceException $e) {
+ throw new Exception\RuntimeException($redis->getLastError(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * Internal method to decrement an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\RuntimeException
+ */
+ protected function internalDecrementItem(& $normalizedKey, & $value)
+ {
+ $redis = $this->getRedisResource();
+ try {
+ return $redis->decrBy($this->namespacePrefix . $normalizedKey, $value);
+ } catch (RedisResourceException $e) {
+ throw new Exception\RuntimeException($redis->getLastError(), $e->getCode(), $e);
+ }
+ }
+
+ /**
+ * Flush currently set DB
+ *
+ * @return bool
+ * @throws Exception\RuntimeException
+ */
+ public function flush()
+ {
+ $redis = $this->getRedisResource();
+ try {
+ return $redis->flushDB();
+ } catch (RedisResourceException $e) {
+ throw new Exception\RuntimeException($redis->getLastError(), $e->getCode(), $e);
+ }
+ }
+
+ /* TotalSpaceCapableInterface */
+
+ /**
+ * Get total space in bytes
+ *
+ * @return int|float
+ */
+ public function getTotalSpace()
+ {
+ $redis = $this->getRedisResource();
+ try {
+ $info = $redis->info();
+ } catch (RedisResourceException $e) {
+ throw new Exception\RuntimeException($redis->getLastError(), $e->getCode(), $e);
+ }
+
+ return $info['used_memory'];
+
+ }
+
+ /* status */
+
+ /**
+ * Internal method to get capabilities of this adapter
+ *
+ * @return Capabilities
+ */
+ protected function internalGetCapabilities()
+ {
+ if ($this->capabilities === null) {
+ $this->capabilityMarker = new stdClass();
+ $minTtl = $this->resourceManager->getMajorVersion($this->resourceId) < 2 ? 0 : 1;
+ //without serialization redis supports only strings for simple
+ //get/set methods
+ $this->capabilities = new Capabilities(
+ $this,
+ $this->capabilityMarker,
+ array(
+ 'supportedDatatypes' => array(
+ 'NULL' => 'string',
+ 'boolean' => 'string',
+ 'integer' => 'string',
+ 'double' => 'string',
+ 'string' => true,
+ 'array' => false,
+ 'object' => false,
+ 'resource' => false,
+ ),
+ 'supportedMetadata' => array(),
+ 'minTtl' => $minTtl,
+ 'maxTtl' => 0,
+ 'staticTtl' => true,
+ 'ttlPrecision' => 1,
+ 'useRequestTime' => false,
+ 'expiredRead' => false,
+ 'maxKeyLength' => 255,
+ 'namespaceIsPrefix' => true,
+ )
+ );
+ }
+
+ return $this->capabilities;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/RedisResourceManager.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/RedisResourceManager.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/RedisResourceManager.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/RedisResourceManager.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,598 @@
+resources[$id]);
+ }
+
+ /**
+ * Gets a redis resource
+ *
+ * @param string $id
+ * @return RedisResource
+ * @throws Exception\RuntimeException
+ */
+ public function getResource($id)
+ {
+ if (!$this->hasResource($id)) {
+ throw new Exception\RuntimeException("No resource with id '{$id}'");
+ }
+
+ $resource = & $this->resources[$id];
+ if ($resource['resource'] instanceof RedisResource) {
+ //in case new server was set then connect
+ if (!$resource['initialized']) {
+ $this->connect($resource);
+ }
+ $info = $resource['resource']->info();
+ $resource['version'] = $info['redis_version'];
+ return $resource['resource'];
+ }
+
+ $redis = new RedisResource();
+
+ $resource['resource'] = $redis;
+ $this->connect($resource);
+
+ foreach ($resource['lib_options'] as $k => $v) {
+ $redis->setOption($k, $v);
+ }
+
+ $info = $redis->info();
+ $resource['version'] = $info['redis_version'];
+ $this->resources[$id]['resource'] = $redis;
+ return $redis;
+ }
+
+ /**
+ * Connects to redis server
+ *
+ *
+ * @param array & $resource
+ *
+ * @return null
+ * @throws Exception\RuntimeException
+ */
+ protected function connect(array & $resource)
+ {
+ $server = $resource['server'];
+ $redis = $resource['resource'];
+ if ($resource['persistent_id'] !== '') {
+ //connect or reuse persistent connection
+ $success = $redis->pconnect($server['host'], $server['port'], $server['timeout'], $server['persistent_id']);
+ } elseif ($server['port']) {
+ $success = $redis->connect($server['host'], $server['port'], $server['timeout']);
+ } elseif ($server['timeout']) {
+ //connect through unix domain socket
+ $success = $redis->connect($server['host'], $server['timeout']);
+ } else {
+ $success = $redis->connect($server['host']);
+ }
+
+ if (!$success) {
+ throw new Exception\RuntimeException('Could not estabilish connection with Redis instance');
+ }
+
+ $resource['initialized'] = true;
+ if ($resource['password']) {
+ $redis->auth($resource['password']);
+ }
+ $redis->select($resource['database']);
+ }
+
+ /**
+ * Set a resource
+ *
+ * @param string $id
+ * @param array|Traversable|RedisResource $resource
+ * @return RedisResourceManager Fluent interface
+ */
+ public function setResource($id, $resource)
+ {
+ $id = (string) $id;
+ //TODO: how to get back redis connection info from resource?
+ $defaults = array(
+ 'persistent_id' => '',
+ 'lib_options' => array(),
+ 'server' => array(),
+ 'password' => '',
+ 'database' => 0,
+ 'resource' => null,
+ 'initialized' => false,
+ 'version' => 0,
+ );
+ if (!$resource instanceof RedisResource) {
+ if ($resource instanceof Traversable) {
+ $resource = ArrayUtils::iteratorToArray($resource);
+ } elseif (!is_array($resource)) {
+ throw new Exception\InvalidArgumentException(
+ 'Resource must be an instance of an array or Traversable'
+ );
+ }
+
+ $resource = array_merge($defaults, $resource);
+ // normalize and validate params
+ $this->normalizePersistentId($resource['persistent_id']);
+ $this->normalizeLibOptions($resource['lib_options']);
+ $this->normalizeServer($resource['server']);
+ } else {
+ //there are two ways of determining if redis is already initialized
+ //with connect function:
+ //1) pinging server
+ //2) checking undocummented property socket which is available only
+ //after successfull connect
+ $resource = array_merge($defaults, array(
+ 'resource' => $resource,
+ 'initialized' => isset($resource->socket),
+ )
+ );
+ }
+ $this->resources[$id] = $resource;
+ return $this;
+ }
+
+ /**
+ * Remove a resource
+ *
+ * @param string $id
+ * @return RedisResourceManager Fluent interface
+ */
+ public function removeResource($id)
+ {
+ unset($this->resources[$id]);
+ return $this;
+ }
+
+ /**
+ * Set the persistent id
+ *
+ * @param string $id
+ * @param string $persistentId
+ * @return RedisResourceManager Fluent interface
+ * @throws Exception\RuntimeException
+ */
+ public function setPersistentId($id, $persistentId)
+ {
+ if (!$this->hasResource($id)) {
+ return $this->setResource($id, array(
+ 'persistent_id' => $persistentId
+ ));
+ }
+
+ $resource = & $this->resources[$id];
+ if ($resource instanceof RedisResource) {
+ throw new Exception\RuntimeException(
+ "Can't change persistent id of resource {$id} after instanziation"
+ );
+ }
+
+ $this->normalizePersistentId($persistentId);
+ $resource['persistent_id'] = $persistentId;
+
+ return $this;
+ }
+
+ /**
+ * Get the persistent id
+ *
+ * @param string $id
+ * @return string
+ * @throws Exception\RuntimeException
+ */
+ public function getPersistentId($id)
+ {
+ if (!$this->hasResource($id)) {
+ throw new Exception\RuntimeException("No resource with id '{$id}'");
+ }
+
+ $resource = & $this->resources[$id];
+
+ if ($resource instanceof RedisResource) {
+ throw new Exception\RuntimeException(
+ "Can't get persistent id of an instantiated redis resource"
+ );
+ }
+
+ return $resource['persistent_id'];
+ }
+
+ /**
+ * Normalize the persistent id
+ *
+ * @param string $persistentId
+ */
+ protected function normalizePersistentId(& $persistentId)
+ {
+ $persistentId = (string) $persistentId;
+ }
+
+ /**
+ * Set Redis options
+ *
+ * @param string $id
+ * @param array $libOptions
+ * @return RedisResourceManager Fluent interface
+ */
+ public function setLibOptions($id, array $libOptions)
+ {
+ if (!$this->hasResource($id)) {
+ return $this->setResource($id, array(
+ 'lib_options' => $libOptions
+ ));
+ }
+
+ $this->normalizeLibOptions($libOptions);
+ $resource = & $this->resources[$id];
+
+ $resource['lib_options'] = $libOptions;
+
+ if ($resource['resource'] instanceof RedisResource) {
+ $redis = & $resource['resource'];
+ if (method_exists($redis, 'setOptions')) {
+ $redis->setOptions($libOptions);
+ } else {
+ foreach ($libOptions as $key => $value) {
+ $redis->setOption($key, $value);
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get Redis options
+ *
+ * @param string $id
+ * @return array
+ * @throws Exception\RuntimeException
+ */
+ public function getLibOptions($id)
+ {
+ if (!$this->hasResource($id)) {
+ throw new Exception\RuntimeException("No resource with id '{$id}'");
+ }
+
+ $resource = & $this->resources[$id];
+
+ if ($resource instanceof RedisResource) {
+ $libOptions = array();
+ $reflection = new ReflectionClass('Redis');
+ $constants = $reflection->getConstants();
+ foreach ($constants as $constName => $constValue) {
+ if (substr($constName, 0, 4) == 'OPT_') {
+ $libOptions[$constValue] = $resource->getOption($constValue);
+ }
+ }
+ return $libOptions;
+ }
+ return $resource['lib_options'];
+ }
+
+ /**
+ * Set one Redis option
+ *
+ * @param string $id
+ * @param string|int $key
+ * @param mixed $value
+ * @return RedisResourceManager Fluent interface
+ */
+ public function setLibOption($id, $key, $value)
+ {
+ return $this->setLibOptions($id, array($key => $value));
+ }
+
+ /**
+ * Get one Redis option
+ *
+ * @param string $id
+ * @param string|int $key
+ * @return mixed
+ * @throws Exception\RuntimeException
+ */
+ public function getLibOption($id, $key)
+ {
+ if (!$this->hasResource($id)) {
+ throw new Exception\RuntimeException("No resource with id '{$id}'");
+ }
+
+ $this->normalizeLibOptionKey($key);
+ $resource = & $this->resources[$id];
+
+ if ($resource instanceof RedisResource) {
+ return $resource->getOption($key);
+ }
+
+ return isset($resource['lib_options'][$key]) ? $resource['lib_options'][$key] : null;
+ }
+
+ /**
+ * Normalize Redis options
+ *
+ * @param array|Traversable $libOptions
+ * @throws Exception\InvalidArgumentException
+ */
+ protected function normalizeLibOptions(& $libOptions)
+ {
+ if (!is_array($libOptions) && !($libOptions instanceof Traversable)) {
+ throw new Exception\InvalidArgumentException(
+ "Lib-Options must be an array or an instance of Traversable"
+ );
+ }
+
+ $result = array();
+ foreach ($libOptions as $key => $value) {
+ $this->normalizeLibOptionKey($key);
+ $result[$key] = $value;
+ }
+
+ $libOptions = $result;
+ }
+
+ /**
+ * Convert option name into it's constant value
+ *
+ * @param string|int $key
+ * @throws Exception\InvalidArgumentException
+ */
+ protected function normalizeLibOptionKey(& $key)
+ {
+ // convert option name into it's constant value
+ if (is_string($key)) {
+ $const = 'Redis::OPT_' . str_replace(array(' ', '-'), '_', strtoupper($key));
+ if (!defined($const)) {
+ throw new Exception\InvalidArgumentException("Unknown redis option '{$key}' ({$const})");
+ }
+ $key = constant($const);
+ } else {
+ $key = (int) $key;
+ }
+ }
+
+ /**
+ * Set server
+ *
+ * Server can be described as follows:
+ * - URI: /path/to/sock.sock
+ * - Assoc: array('host' => [, 'port' => [, 'timeout' => ]])
+ * - List: array([, , [, ]])
+ *
+ * @param string $id
+ * @param string|array $server
+ * @return RedisResourceManager
+ */
+ public function setServer($id, $server)
+ {
+ if (!$this->hasResource($id)) {
+ return $this->setResource($id, array(
+ 'server' => $server
+ ));
+ }
+
+ $this->normalizeServer($server);
+
+ $resource = & $this->resources[$id];
+ if ($resource['resource'] instanceof RedisResource) {
+ $this->setResource($id, array('server' => $server));
+ } else {
+ $resource['server'] = $server;
+ }
+ return $this;
+ }
+
+ /**
+ * Get server
+ * @param string $id
+ * @throws Exception\RuntimeException
+ * @return array array('host' => [, 'port' => [, 'timeout' => ]])
+ */
+ public function getServer($id)
+ {
+ if (!$this->hasResource($id)) {
+ throw new Exception\RuntimeException("No resource with id '{$id}'");
+ }
+
+ $resource = & $this->resources[$id];
+ return $resource['server'];
+ }
+
+ /**
+ * Set redis password
+ *
+ * @param string $id
+ * @param string $password
+ * @return RedisResource
+ */
+ public function setPassword($id, $password)
+ {
+ if (!$this->hasResource($id)) {
+ return $this->setResource($id, array(
+ 'password' => $password,
+ ));
+ }
+
+ $resource = & $this->resources[$id];
+ $resource['password'] = $password;
+ $resource['initialized'] = false;
+ return $this;
+ }
+
+ /**
+ * Get redis resource password
+ *
+ * @param string $id
+ * @return string
+ */
+ public function getPassword($id)
+ {
+ if (!$this->hasResource($id)) {
+ throw new Exception\RuntimeException("No resource with id '{$id}'");
+ }
+
+ $resource = & $this->resources[$id];
+ return $resource['password'];
+ }
+
+ /**
+ * Set redis database number
+ *
+ * @param string $id
+ * @param int $database
+ * @return RedisResource
+ */
+ public function setDatabase($id, $database)
+ {
+ if (!$this->hasResource($id)) {
+ return $this->setResource($id, array(
+ 'database' => (int) $database,
+ ));
+ }
+
+ $resource = & $this->resources[$id];
+ $resource['database'] = $database;
+ $resource['initialized'] = false;
+ return $this;
+ }
+
+ /**
+ * Get redis resource database
+ *
+ * @param string $id
+ * @return string
+ */
+ public function getDatabase($id)
+ {
+ if (!$this->hasResource($id)) {
+ throw new Exception\RuntimeException("No resource with id '{$id}'");
+ }
+
+ $resource = & $this->resources[$id];
+ return $resource['database'];
+ }
+
+ /**
+ * Get redis server version
+ *
+ * @deprecated 2.2.2 Use getMajorVersion instead
+ *
+ * @param string $id
+ * @return int
+ * @throws Exception\RuntimeException
+ */
+ public function getMayorVersion($id)
+ {
+ return $this->getMajorVersion($id);
+ }
+
+ /**
+ * Get redis server version
+ *
+ * @param string $id
+ * @return int
+ * @throws Exception\RuntimeException
+ */
+ public function getMajorVersion($id)
+ {
+ if (!$this->hasResource($id)) {
+ throw new Exception\RuntimeException("No resource with id '{$id}'");
+ }
+
+ $resource = & $this->resources[$id];
+ return (int) $resource['version'];
+ }
+
+ /**
+ * Normalize one server into the following format:
+ * array('host' => [, 'port' => [, 'timeout' => ]])
+ *
+ * @param string|array $server
+ * @throws Exception\InvalidArgumentException
+ */
+ protected function normalizeServer(& $server)
+ {
+ $host = null;
+ $port = null;
+ $timeout = 0;
+ // convert a single server into an array
+ if ($server instanceof Traversable) {
+ $server = ArrayUtils::iteratorToArray($server);
+ }
+
+ if (is_array($server)) {
+ // array([, [, ]])
+ if (isset($server[0])) {
+ $host = (string) $server[0];
+ $port = isset($server[1]) ? (int) $server[1] : $port;
+ $timeout = isset($server[2]) ? (int) $server[2] : $timeout;
+ }
+
+ // array('host' => [, 'port' => , ['timeout' => ]])
+ if (!isset($server[0]) && isset($server['host'])) {
+ $host = (string) $server['host'];
+ $port = isset($server['port']) ? (int) $server['port'] : $port;
+ $timeout = isset($server['timeout']) ? (int) $server['timeout'] : $timeout;
+ }
+
+ } else {
+ // parse server from URI host{:?port}
+ $server = trim($server);
+ if (!strpos($server, '/') === 0) {
+ //non unix domain socket connection
+ $server = parse_url($server);
+ } else {
+ $server = array('host' => $server);
+ }
+ if (!$server) {
+ throw new Exception\InvalidArgumentException("Invalid server given");
+ }
+
+ $host = $server['host'];
+ $port = isset($server['port']) ? (int) $server['port'] : $port;
+ $timeout = isset($server['timeout']) ? (int) $server['timeout'] : $timeout;
+ }
+
+ if (!$host) {
+ throw new Exception\InvalidArgumentException('Missing required server host');
+ }
+
+ $server = array(
+ 'host' => $host,
+ 'port' => $port,
+ 'timeout' => $timeout,
+ );
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/SessionOptions.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/SessionOptions.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/SessionOptions.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/SessionOptions.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,51 @@
+sessionContainer != $sessionContainer) {
+ $this->triggerOptionEvent('session_container', $sessionContainer);
+ $this->sessionContainer = $sessionContainer;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get the session container
+ *
+ * @return null|SessionContainer
+ */
+ public function getSessionContainer()
+ {
+ return $this->sessionContainer;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Session.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Session.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/Session.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/Session.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,547 @@
+options) {
+ $this->setOptions(new SessionOptions());
+ }
+ return $this->options;
+ }
+
+ /**
+ * Get the session container
+ *
+ * @return SessionContainer
+ */
+ protected function getSessionContainer()
+ {
+ $sessionContainer = $this->getOptions()->getSessionContainer();
+ if (!$sessionContainer) {
+ throw new Exception\RuntimeException("No session container configured");
+ }
+ return $sessionContainer;
+ }
+
+ /* IterableInterface */
+
+ /**
+ * Get the storage iterator
+ *
+ * @return KeyListIterator
+ */
+ public function getIterator()
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+
+ if ($cntr->offsetExists($ns)) {
+ $keys = array_keys($cntr->offsetGet($ns));
+ } else {
+ $keys = array();
+ }
+
+ return new KeyListIterator($this, $keys);
+ }
+
+ /* FlushableInterface */
+
+ /**
+ * Flush the whole session container
+ *
+ * @return bool
+ */
+ public function flush()
+ {
+ $this->getSessionContainer()->exchangeArray(array());
+ return true;
+ }
+
+ /* ClearByPrefixInterface */
+
+ /**
+ * Remove items matching given prefix
+ *
+ * @param string $prefix
+ * @return bool
+ */
+ public function clearByPrefix($prefix)
+ {
+ $prefix = (string) $prefix;
+ if ($prefix === '') {
+ throw new Exception\InvalidArgumentException('No prefix given');
+ }
+
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+
+ if (!$cntr->offsetExists($ns)) {
+ return true;
+ }
+
+ $data = $cntr->offsetGet($ns);
+ $prefixL = strlen($prefix);
+ foreach ($data as $key => & $item) {
+ if (substr($key, 0, $prefixL) === $prefix) {
+ unset($data[$key]);
+ }
+ }
+ $cntr->offsetSet($ns, $data);
+
+ return true;
+ }
+
+ /* reading */
+
+ /**
+ * Internal method to get an item.
+ *
+ * @param string $normalizedKey
+ * @param bool $success
+ * @param mixed $casToken
+ * @return mixed Data on success, null on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+
+ if (!$cntr->offsetExists($ns)) {
+ $success = false;
+ return null;
+ }
+
+ $data = $cntr->offsetGet($ns);
+ $success = array_key_exists($normalizedKey, $data);
+ if (!$success) {
+ return null;
+ }
+
+ $casToken = $value = $data[$normalizedKey];
+ return $value;
+ }
+
+ /**
+ * Internal method to get multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Associative array of keys and values
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItems(array & $normalizedKeys)
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+
+ if (!$cntr->offsetExists($ns)) {
+ return array();
+ }
+
+ $data = $cntr->offsetGet($ns);
+ $result = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ if (array_key_exists($normalizedKey, $data)) {
+ $result[$normalizedKey] = $data[$normalizedKey];
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to test if an item exists.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ */
+ protected function internalHasItem(& $normalizedKey)
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+
+ if (!$cntr->offsetExists($ns)) {
+ return false;
+ }
+
+ $data = $cntr->offsetGet($ns);
+ return array_key_exists($normalizedKey, $data);
+ }
+
+ /**
+ * Internal method to test multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Array of found keys
+ */
+ protected function internalHasItems(array & $normalizedKeys)
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+
+ if (!$cntr->offsetExists($ns)) {
+ return array();
+ }
+
+ $data = $cntr->offsetGet($ns);
+ $result = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ if (array_key_exists($normalizedKey, $data)) {
+ $result[] = $normalizedKey;
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Get metadata of an item.
+ *
+ * @param string $normalizedKey
+ * @return array|bool Metadata on success, false on failure
+ * @throws Exception\ExceptionInterface
+ *
+ * @triggers getMetadata.pre(PreEvent)
+ * @triggers getMetadata.post(PostEvent)
+ * @triggers getMetadata.exception(ExceptionEvent)
+ */
+ protected function internalGetMetadata(& $normalizedKey)
+ {
+ return $this->internalHasItem($normalizedKey) ? array() : false;
+ }
+
+ /* writing */
+
+ /**
+ * Internal method to store an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItem(& $normalizedKey, & $value)
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+ $data = $cntr->offsetExists($ns) ? $cntr->offsetGet($ns) : array();
+ $data[$normalizedKey] = $value;
+ $cntr->offsetSet($ns, $data);
+ return true;
+ }
+
+ /**
+ * Internal method to store multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItems(array & $normalizedKeyValuePairs)
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+
+ if ($cntr->offsetExists($ns)) {
+ $data = array_merge($cntr->offsetGet($ns), $normalizedKeyValuePairs);
+ } else {
+ $data = $normalizedKeyValuePairs;
+ }
+ $cntr->offsetSet($ns, $data);
+
+ return array();
+ }
+
+ /**
+ * Add an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalAddItem(& $normalizedKey, & $value)
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+
+ if ($cntr->offsetExists($ns)) {
+ $data = $cntr->offsetGet($ns);
+
+ if (array_key_exists($normalizedKey, $data)) {
+ return false;
+ }
+
+ $data[$normalizedKey] = $value;
+ } else {
+ $data = array($normalizedKey => $value);
+ }
+
+ $cntr->offsetSet($ns, $data);
+ return true;
+ }
+
+ /**
+ * Internal method to add multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalAddItems(array & $normalizedKeyValuePairs)
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+
+ $result = array();
+ if ($cntr->offsetExists($ns)) {
+ $data = $cntr->offsetGet($ns);
+
+ foreach ($normalizedKeyValuePairs as $normalizedKey => $value) {
+ if (array_key_exists($normalizedKey, $data)) {
+ $result[] = $normalizedKey;
+ } else {
+ $data[$normalizedKey] = $value;
+ }
+ }
+ } else {
+ $data = $normalizedKeyValuePairs;
+ }
+
+ $cntr->offsetSet($ns, $data);
+ return $result;
+ }
+
+ /**
+ * Internal method to replace an existing item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalReplaceItem(& $normalizedKey, & $value)
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+
+ if (!$cntr->offsetExists($ns)) {
+ return false;
+ }
+
+ $data = $cntr->offsetGet($ns);
+ if (!array_key_exists($normalizedKey, $data)) {
+ return false;
+ }
+ $data[$normalizedKey] = $value;
+ $cntr->offsetSet($ns, $data);
+
+ return true;
+ }
+
+ /**
+ * Internal method to replace multiple existing items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalReplaceItems(array & $normalizedKeyValuePairs)
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+ if (!$cntr->offsetExists($ns)) {
+ return array_keys($normalizedKeyValuePairs);
+ }
+
+ $data = $cntr->offsetGet($ns);
+ $result = array();
+ foreach ($normalizedKeyValuePairs as $normalizedKey => $value) {
+ if (!array_key_exists($normalizedKey, $data)) {
+ $result[] = $normalizedKey;
+ } else {
+ $data[$normalizedKey] = $value;
+ }
+ }
+ $cntr->offsetSet($ns, $data);
+
+ return $result;
+ }
+
+ /**
+ * Internal method to remove an item.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalRemoveItem(& $normalizedKey)
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+
+ if (!$cntr->offsetExists($ns)) {
+ return false;
+ }
+
+ $data = $cntr->offsetGet($ns);
+ if (!array_key_exists($normalizedKey, $data)) {
+ return false;
+ }
+
+ unset($data[$normalizedKey]);
+
+ if (!$data) {
+ $cntr->offsetUnset($ns);
+ } else {
+ $cntr->offsetSet($ns, $data);
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to increment an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalIncrementItem(& $normalizedKey, & $value)
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+
+ if ($cntr->offsetExists($ns)) {
+ $data = $cntr->offsetGet($ns);
+ } else {
+ $data = array();
+ }
+
+ if (array_key_exists($normalizedKey, $data)) {
+ $data[$normalizedKey]+= $value;
+ $newValue = $data[$normalizedKey];
+ } else {
+ // initial value
+ $newValue = $value;
+ $data[$normalizedKey] = $newValue;
+ }
+
+ $cntr->offsetSet($ns, $data);
+ return $newValue;
+ }
+
+ /**
+ * Internal method to decrement an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalDecrementItem(& $normalizedKey, & $value)
+ {
+ $cntr = $this->getSessionContainer();
+ $ns = $this->getOptions()->getNamespace();
+
+ if ($cntr->offsetExists($ns)) {
+ $data = $cntr->offsetGet($ns);
+ } else {
+ $data = array();
+ }
+
+ if (array_key_exists($normalizedKey, $data)) {
+ $data[$normalizedKey]-= $value;
+ $newValue = $data[$normalizedKey];
+ } else {
+ // initial value
+ $newValue = -$value;
+ $data[$normalizedKey] = $newValue;
+ }
+
+ $cntr->offsetSet($ns, $data);
+ return $newValue;
+ }
+
+ /* status */
+
+ /**
+ * Internal method to get capabilities of this adapter
+ *
+ * @return Capabilities
+ */
+ protected function internalGetCapabilities()
+ {
+ if ($this->capabilities === null) {
+ $this->capabilityMarker = new stdClass();
+ $this->capabilities = new Capabilities(
+ $this,
+ $this->capabilityMarker,
+ array(
+ 'supportedDatatypes' => array(
+ 'NULL' => true,
+ 'boolean' => true,
+ 'integer' => true,
+ 'double' => true,
+ 'string' => true,
+ 'array' => 'array',
+ 'object' => 'object',
+ 'resource' => false,
+ ),
+ 'supportedMetadata' => array(),
+ 'minTtl' => 0,
+ 'maxKeyLength' => 0,
+ 'namespaceIsPrefix' => false,
+ 'namespaceSeparator' => '',
+ )
+ );
+ }
+
+ return $this->capabilities;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/WinCacheOptions.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/WinCacheOptions.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/WinCacheOptions.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/WinCacheOptions.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,48 @@
+triggerOptionEvent('namespace_separator', $namespaceSeparator);
+ $this->namespaceSeparator = $namespaceSeparator;
+ return $this;
+ }
+
+ /**
+ * Get namespace separator
+ *
+ * @return string
+ */
+ public function getNamespaceSeparator()
+ {
+ return $this->namespaceSeparator;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/WinCache.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/WinCache.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/WinCache.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/WinCache.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,534 @@
+options) {
+ $this->setOptions(new WinCacheOptions());
+ }
+ return $this->options;
+ }
+
+ /* TotalSpaceCapableInterface */
+
+ /**
+ * Get total space in bytes
+ *
+ * @return int|float
+ */
+ public function getTotalSpace()
+ {
+ $mem = wincache_ucache_meminfo();
+ return $mem['memory_total'];
+ }
+
+ /* AvailableSpaceCapableInterface */
+
+ /**
+ * Get available space in bytes
+ *
+ * @return int|float
+ */
+ public function getAvailableSpace()
+ {
+ $mem = wincache_ucache_meminfo();
+ return $mem['memory_free'];
+ }
+
+ /* FlushableInterface */
+
+ /**
+ * Flush the whole storage
+ *
+ * @return bool
+ */
+ public function flush()
+ {
+ return wincache_ucache_clear();
+ }
+
+ /* reading */
+
+ /**
+ * Internal method to get an item.
+ *
+ * @param string $normalizedKey
+ * @param bool $success
+ * @param mixed $casToken
+ * @return mixed Data on success, null on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ $result = wincache_ucache_get($internalKey, $success);
+
+ if ($success) {
+ $casToken = $result;
+ } else {
+ $result = null;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to get multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Associative array of keys and values
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItems(array & $normalizedKeys)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ if ($namespace === '') {
+ return wincache_ucache_get($normalizedKeys);
+ }
+
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $internalKeys = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ $internalKeys[] = $prefix . $normalizedKey;
+ }
+
+ $fetch = wincache_ucache_get($internalKeys);
+
+ // remove namespace prefix
+ $prefixL = strlen($prefix);
+ $result = array();
+ foreach ($fetch as $internalKey => & $value) {
+ $result[substr($internalKey, $prefixL)] = & $value;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to test if an item exists.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalHasItem(& $normalizedKey)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ return wincache_ucache_exists($prefix . $normalizedKey);
+ }
+
+ /**
+ * Get metadata of an item.
+ *
+ * @param string $normalizedKey
+ * @return array|bool Metadata on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetMetadata(& $normalizedKey)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+
+ $info = wincache_ucache_info(true, $internalKey);
+ if (isset($info['ucache_entries'][1])) {
+ $metadata = $info['ucache_entries'][1];
+ $this->normalizeMetadata($metadata);
+ return $metadata;
+ }
+
+ return false;
+ }
+
+ /* writing */
+
+ /**
+ * Internal method to store an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ $ttl = $options->getTtl();
+
+ if (!wincache_ucache_set($internalKey, $value, $ttl)) {
+ $type = is_object($value) ? get_class($value) : gettype($value);
+ throw new Exception\RuntimeException(
+ "wincache_ucache_set('{$internalKey}', <{$type}>, {$ttl}) failed"
+ );
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to store multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItems(array & $normalizedKeyValuePairs)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ if ($namespace === '') {
+ return wincache_ucache_set($normalizedKeyValuePairs, null, $options->getTtl());
+ }
+
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $internalKeyValuePairs = array();
+ foreach ($normalizedKeyValuePairs as $normalizedKey => & $value) {
+ $internalKey = $prefix . $normalizedKey;
+ $internalKeyValuePairs[$internalKey] = & $value;
+ }
+
+ $result = wincache_ucache_set($internalKeyValuePairs, null, $options->getTtl());
+
+ // remove key prefic
+ $prefixL = strlen($prefix);
+ foreach ($result as & $key) {
+ $key = substr($key, $prefixL);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Add an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalAddItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ $ttl = $options->getTtl();
+
+ if (!wincache_ucache_add($internalKey, $value, $ttl)) {
+ $type = is_object($value) ? get_class($value) : gettype($value);
+ throw new Exception\RuntimeException(
+ "wincache_ucache_add('{$internalKey}', <{$type}>, {$ttl}) failed"
+ );
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to add multiple items.
+ *
+ * @param array $normalizedKeyValuePairs
+ * @return array Array of not stored keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalAddItems(array & $normalizedKeyValuePairs)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ if ($namespace === '') {
+ return wincache_ucache_add($normalizedKeyValuePairs, null, $options->getTtl());
+ }
+
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $internalKeyValuePairs = array();
+ foreach ($normalizedKeyValuePairs as $normalizedKey => $value) {
+ $internalKey = $prefix . $normalizedKey;
+ $internalKeyValuePairs[$internalKey] = $value;
+ }
+
+ $result = wincache_ucache_add($internalKeyValuePairs, null, $options->getTtl());
+
+ // remove key prefic
+ $prefixL = strlen($prefix);
+ foreach ($result as & $key) {
+ $key = substr($key, $prefixL);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to replace an existing item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalReplaceItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ if (!wincache_ucache_exists($internalKey)) {
+ return false;
+ }
+
+ $ttl = $options->getTtl();
+ if (!wincache_ucache_set($internalKey, $value, $ttl)) {
+ $type = is_object($value) ? get_class($value) : gettype($value);
+ throw new Exception\RuntimeException(
+ "wincache_ucache_set('{$internalKey}', <{$type}>, {$ttl}) failed"
+ );
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to remove an item.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalRemoveItem(& $normalizedKey)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ return wincache_ucache_delete($internalKey);
+ }
+
+ /**
+ * Internal method to remove multiple items.
+ *
+ * @param array $normalizedKeys
+ * @return array Array of not removed keys
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalRemoveItems(array & $normalizedKeys)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ if ($namespace === '') {
+ $result = wincache_ucache_delete($normalizedKeys);
+ return ($result === false) ? $normalizedKeys : $result;
+ }
+
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $internalKeys = array();
+ foreach ($normalizedKeys as $normalizedKey) {
+ $internalKeys[] = $prefix . $normalizedKey;
+ }
+
+ $result = wincache_ucache_delete($internalKeys);
+ if ($result === false) {
+ return $normalizedKeys;
+ } elseif ($result) {
+ // remove key prefix
+ $prefixL = strlen($prefix);
+ foreach ($result as & $key) {
+ $key = substr($key, $prefixL);
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to increment an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalIncrementItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ return wincache_ucache_inc($internalKey, (int) $value);
+ }
+
+ /**
+ * Internal method to decrement an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalDecrementItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ return wincache_ucache_dec($internalKey, (int) $value);
+ }
+
+ /* status */
+
+ /**
+ * Internal method to get capabilities of this adapter
+ *
+ * @return Capabilities
+ */
+ protected function internalGetCapabilities()
+ {
+ if ($this->capabilities === null) {
+ $marker = new stdClass();
+ $capabilities = new Capabilities(
+ $this,
+ $marker,
+ array(
+ 'supportedDatatypes' => array(
+ 'NULL' => true,
+ 'boolean' => true,
+ 'integer' => true,
+ 'double' => true,
+ 'string' => true,
+ 'array' => true,
+ 'object' => 'object',
+ 'resource' => false,
+ ),
+ 'supportedMetadata' => array(
+ 'internal_key', 'ttl', 'hits', 'size'
+ ),
+ 'minTtl' => 1,
+ 'maxTtl' => 0,
+ 'staticTtl' => true,
+ 'ttlPrecision' => 1,
+ 'useRequestTime' => false,
+ 'expiredRead' => false,
+ 'namespaceIsPrefix' => true,
+ 'namespaceSeparator' => $this->getOptions()->getNamespaceSeparator(),
+ )
+ );
+
+ // update namespace separator on change option
+ $this->getEventManager()->attach('option', function ($event) use ($capabilities, $marker) {
+ $params = $event->getParams();
+
+ if (isset($params['namespace_separator'])) {
+ $capabilities->setNamespaceSeparator($marker, $params['namespace_separator']);
+ }
+ });
+
+ $this->capabilities = $capabilities;
+ $this->capabilityMarker = $marker;
+ }
+
+ return $this->capabilities;
+ }
+
+ /* internal */
+
+ /**
+ * Normalize metadata to work with WinCache
+ *
+ * @param array $metadata
+ * @return void
+ */
+ protected function normalizeMetadata(array & $metadata)
+ {
+ $metadata['internal_key'] = $metadata['key_name'];
+ $metadata['hits'] = $metadata['hitcount'];
+ $metadata['ttl'] = $metadata['ttl_seconds'];
+ $metadata['size'] = $metadata['value_size'];
+
+ unset(
+ $metadata['key_name'],
+ $metadata['hitcount'],
+ $metadata['ttl_seconds'],
+ $metadata['value_size']
+ );
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/XCacheOptions.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/XCacheOptions.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/XCacheOptions.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/XCacheOptions.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,146 @@
+triggerOptionEvent('namespace_separator', $namespaceSeparator);
+ $this->namespaceSeparator = $namespaceSeparator;
+ return $this;
+ }
+
+ /**
+ * Get namespace separator
+ *
+ * @return string
+ */
+ public function getNamespaceSeparator()
+ {
+ return $this->namespaceSeparator;
+ }
+
+ /**
+ * Set username to call admin functions
+ *
+ * @param null|string $adminUser
+ * @return XCacheOptions
+ */
+ public function setAdminUser($adminUser)
+ {
+ $adminUser = ($adminUser === null) ? null : (string) $adminUser;
+ if ($this->adminUser !== $adminUser) {
+ $this->triggerOptionEvent('admin_user', $adminUser);
+ $this->adminUser = $adminUser;
+ }
+ return $this;
+ }
+
+ /**
+ * Get username to call admin functions
+ *
+ * @return string
+ */
+ public function getAdminUser()
+ {
+ return $this->adminUser;
+ }
+
+ /**
+ * Enable/Disable admin authentication handling
+ *
+ * @param bool $adminAuth
+ * @return XCacheOptions
+ */
+ public function setAdminAuth($adminAuth)
+ {
+ $adminAuth = (bool) $adminAuth;
+ if ($this->adminAuth !== $adminAuth) {
+ $this->triggerOptionEvent('admin_auth', $adminAuth);
+ $this->adminAuth = $adminAuth;
+ }
+ return $this;
+ }
+
+ /**
+ * Get admin authentication enabled
+ *
+ * @return bool
+ */
+ public function getAdminAuth()
+ {
+ return $this->adminAuth;
+ }
+
+ /**
+ * Set password to call admin functions
+ *
+ * @param null|string $adminPass
+ * @return XCacheOptions
+ */
+ public function setAdminPass($adminPass)
+ {
+ $adminPass = ($adminPass === null) ? null : (string) $adminPass;
+ if ($this->adminPass !== $adminPass) {
+ $this->triggerOptionEvent('admin_pass', $adminPass);
+ $this->adminPass = $adminPass;
+ }
+ return $this;
+ }
+
+ /**
+ * Get password to call admin functions
+ *
+ * @return string
+ */
+ public function getAdminPass()
+ {
+ return $this->adminPass;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/XCache.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/XCache.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/XCache.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/XCache.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,529 @@
+options) {
+ $this->setOptions(new XCacheOptions());
+ }
+ return $this->options;
+ }
+
+ /* TotalSpaceCapableInterface */
+
+ /**
+ * Get total space in bytes
+ *
+ * @return int|float
+ */
+ public function getTotalSpace()
+ {
+ if ($this->totalSpace === null) {
+ $this->totalSpace = 0;
+
+ $this->initAdminAuth();
+ $cnt = xcache_count(XC_TYPE_VAR);
+ for ($i=0; $i < $cnt; $i++) {
+ $info = xcache_info(XC_TYPE_VAR, $i);
+ $this->totalSpace+= $info['size'];
+ }
+ $this->resetAdminAuth();
+ }
+
+ return $this->totalSpace;
+ }
+
+ /* AvailableSpaceCapableInterface */
+
+ /**
+ * Get available space in bytes
+ *
+ * @return int|float
+ */
+ public function getAvailableSpace()
+ {
+ $availableSpace = 0;
+
+ $this->initAdminAuth();
+ $cnt = xcache_count(XC_TYPE_VAR);
+ for ($i = 0; $i < $cnt; $i++) {
+ $info = xcache_info(XC_TYPE_VAR, $i);
+ $availableSpace+= $info['avail'];
+ }
+ $this->resetAdminAuth();
+
+ return $availableSpace;
+ }
+
+
+ /* ClearByNamespaceInterface */
+
+ /**
+ * Remove items by given namespace
+ *
+ * @param string $namespace
+ * @return bool
+ */
+ public function clearByNamespace($namespace)
+ {
+ $namespace = (string) $namespace;
+ if ($namespace === '') {
+ throw new Exception\InvalidArgumentException('No namespace given');
+ }
+
+ $options = $this->getOptions();
+ $prefix = $namespace . $options->getNamespaceSeparator();
+
+ xcache_unset_by_prefix($prefix);
+ return true;
+ }
+
+ /* ClearByPrefixInterface */
+
+ /**
+ * Remove items matching given prefix
+ *
+ * @param string $prefix
+ * @return bool
+ */
+ public function clearByPrefix($prefix)
+ {
+ $prefix = (string) $prefix;
+ if ($prefix === '') {
+ throw new Exception\InvalidArgumentException('No prefix given');
+ }
+
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator() . $prefix;
+
+ xcache_unset_by_prefix($prefix);
+ return true;
+ }
+
+ /* FlushableInterface */
+
+ /**
+ * Flush the whole storage
+ *
+ * @return bool
+ */
+ public function flush()
+ {
+ $this->initAdminAuth();
+ $cnt = xcache_count(XC_TYPE_VAR);
+ for ($i = 0; $i < $cnt; $i++) {
+ xcache_clear_cache(XC_TYPE_VAR, $i);
+ }
+ $this->resetAdminAuth();
+
+ return true;
+ }
+
+ /* IterableInterface */
+
+ /**
+ * Get the storage iterator
+ *
+ * @return KeyListIterator
+ */
+ public function getIterator()
+ {
+
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $keys = array();
+
+ $this->initAdminAuth();
+
+ if ($namespace === '') {
+ $cnt = xcache_count(XC_TYPE_VAR);
+ for ($i=0; $i < $cnt; $i++) {
+ $list = xcache_list(XC_TYPE_VAR, $i);
+ foreach ($list['cache_list'] as & $item) {
+ $keys[] = $item['name'];
+ }
+ }
+ } else {
+
+ $prefix = $namespace . $options->getNamespaceSeparator();
+ $prefixL = strlen($prefix);
+
+ $cnt = xcache_count(XC_TYPE_VAR);
+ for ($i=0; $i < $cnt; $i++) {
+ $list = xcache_list(XC_TYPE_VAR, $i);
+ foreach ($list['cache_list'] as & $item) {
+ $keys[] = substr($item['name'], $prefixL);
+ }
+ }
+ }
+
+ $this->resetAdminAuth();
+
+ return new KeyListIterator($this, $keys);
+ }
+
+ /* reading */
+
+ /**
+ * Internal method to get an item.
+ *
+ * @param string $normalizedKey
+ * @param bool $success
+ * @param mixed $casToken
+ * @return mixed Data on success, null on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetItem(& $normalizedKey, & $success = null, & $casToken = null)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+
+ $result = xcache_get($internalKey);
+ $success = ($result !== null);
+
+ if ($success) {
+ $casToken = $result;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Internal method to test if an item exists.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalHasItem(& $normalizedKey)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ return xcache_isset($prefix . $normalizedKey);
+ }
+
+ /**
+ * Get metadata of an item.
+ *
+ * @param string $normalizedKey
+ * @return array|bool Metadata on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalGetMetadata(& $normalizedKey)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+
+ if (xcache_isset($internalKey)) {
+
+ $this->initAdminAuth();
+ $cnt = xcache_count(XC_TYPE_VAR);
+ for ($i=0; $i < $cnt; $i++) {
+ $list = xcache_list(XC_TYPE_VAR, $i);
+ foreach ($list['cache_list'] as & $metadata) {
+ if ($metadata['name'] === $internalKey) {
+ $this->normalizeMetadata($metadata);
+ return $metadata;
+ }
+ }
+ }
+ $this->resetAdminAuth();
+ }
+
+ return false;
+ }
+
+ /* writing */
+
+ /**
+ * Internal method to store an item.
+ *
+ * @param string $normalizedKey
+ * @param mixed $value
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalSetItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($options === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ $ttl = $options->getTtl();
+
+ if (!xcache_set($internalKey, $value, $ttl)) {
+ $type = is_object($value) ? get_class($value) : gettype($value);
+ throw new Exception\RuntimeException(
+ "xcache_set('{$internalKey}', <{$type}>, {$ttl}) failed"
+ );
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal method to remove an item.
+ *
+ * @param string $normalizedKey
+ * @return bool
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalRemoveItem(& $normalizedKey)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+
+ return xcache_unset($internalKey);
+ }
+
+ /**
+ * Internal method to increment an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalIncrementItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ $ttl = $options->getTtl();
+ $value = (int) $value;
+
+ return xcache_inc($internalKey, $value, $ttl);
+ }
+
+ /**
+ * Internal method to decrement an item.
+ *
+ * @param string $normalizedKey
+ * @param int $value
+ * @return int|bool The new value on success, false on failure
+ * @throws Exception\ExceptionInterface
+ */
+ protected function internalDecrementItem(& $normalizedKey, & $value)
+ {
+ $options = $this->getOptions();
+ $namespace = $options->getNamespace();
+ $prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator();
+ $internalKey = $prefix . $normalizedKey;
+ $ttl = $options->getTtl();
+ $value = (int) $value;
+
+ return xcache_dec($internalKey, $value, $ttl);
+ }
+
+ /* status */
+
+ /**
+ * Internal method to get capabilities of this adapter
+ *
+ * @return Capabilities
+ */
+ protected function internalGetCapabilities()
+ {
+ if ($this->capabilities === null) {
+ $marker = new stdClass();
+ $capabilities = new Capabilities(
+ $this,
+ $marker,
+ array(
+ 'supportedDatatypes' => array(
+ 'NULL' => false,
+ 'boolean' => true,
+ 'integer' => true,
+ 'double' => true,
+ 'string' => true,
+ 'array' => true,
+ 'object' => 'object',
+ 'resource' => false,
+ ),
+ 'supportedMetadata' => array(
+ 'internal_key',
+ 'size', 'refcount', 'hits',
+ 'ctime', 'atime', 'hvalue',
+ ),
+ 'minTtl' => 1,
+ 'maxTtl' => (int)ini_get('xcache.var_maxttl'),
+ 'staticTtl' => true,
+ 'ttlPrecision' => 1,
+ 'useRequestTime' => true,
+ 'expiredRead' => false,
+ 'maxKeyLength' => 5182,
+ 'namespaceIsPrefix' => true,
+ 'namespaceSeparator' => $this->getOptions()->getNamespaceSeparator(),
+ )
+ );
+
+ // update namespace separator on change option
+ $this->getEventManager()->attach('option', function ($event) use ($capabilities, $marker) {
+ $params = $event->getParams();
+
+ if (isset($params['namespace_separator'])) {
+ $capabilities->setNamespaceSeparator($marker, $params['namespace_separator']);
+ }
+ });
+
+ $this->capabilities = $capabilities;
+ $this->capabilityMarker = $marker;
+ }
+
+ return $this->capabilities;
+ }
+
+ /* internal */
+
+ /**
+ * Init authentication before calling admin functions
+ *
+ * @return void
+ */
+ protected function initAdminAuth()
+ {
+ $options = $this->getOptions();
+
+ if ($options->getAdminAuth()) {
+ $adminUser = $options->getAdminUser();
+ $adminPass = $options->getAdminPass();
+
+ // backup HTTP authentication properties
+ if (isset($_SERVER['PHP_AUTH_USER'])) {
+ $this->backupAuth['PHP_AUTH_USER'] = $_SERVER['PHP_AUTH_USER'];
+ }
+ if (isset($_SERVER['PHP_AUTH_PW'])) {
+ $this->backupAuth['PHP_AUTH_PW'] = $_SERVER['PHP_AUTH_PW'];
+ }
+
+ // set authentication
+ $_SERVER['PHP_AUTH_USER'] = $adminUser;
+ $_SERVER['PHP_AUTH_PW'] = $adminPass;
+ }
+ }
+
+ /**
+ * Reset authentication after calling admin functions
+ *
+ * @return void
+ */
+ protected function resetAdminAuth()
+ {
+ unset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
+ $_SERVER = $this->backupAuth + $_SERVER;
+ $this->backupAuth = array();
+ }
+
+ /**
+ * Normalize metadata to work with XCache
+ *
+ * @param array $metadata
+ */
+ protected function normalizeMetadata(array & $metadata)
+ {
+ $metadata['internal_key'] = &$metadata['name'];
+ unset($metadata['name']);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/ZendServerDisk.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/ZendServerDisk.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/ZendServerDisk.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/ZendServerDisk.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,187 @@
+totalSpace === null) {
+ $path = ini_get('zend_datacache.disk.save_path');
+
+ ErrorHandler::start();
+ $total = disk_total_space($path);
+ $error = ErrorHandler::stop();
+ if ($total === false) {
+ throw new Exception\RuntimeException("Can't detect total space of '{$path}'", 0, $error);
+ }
+
+ $this->totalSpace = $total;
+ }
+ return $this->totalSpace;
+ }
+
+ /* AvailableSpaceCapableInterface */
+
+ /**
+ * Get available space in bytes
+ *
+ * @throws Exception\RuntimeException
+ * @return int|float
+ */
+ public function getAvailableSpace()
+ {
+ $path = ini_get('zend_datacache.disk.save_path');
+
+ ErrorHandler::start();
+ $avail = disk_free_space($path);
+ $error = ErrorHandler::stop();
+ if ($avail === false) {
+ throw new Exception\RuntimeException("Can't detect free space of '{$path}'", 0, $error);
+ }
+
+ return $avail;
+ }
+
+ /* internal */
+
+ /**
+ * Store data into Zend Data Disk Cache
+ *
+ * @param string $internalKey
+ * @param mixed $value
+ * @param int $ttl
+ * @return void
+ * @throws Exception\RuntimeException
+ */
+ protected function zdcStore($internalKey, $value, $ttl)
+ {
+ if (!zend_disk_cache_store($internalKey, $value, $ttl)) {
+ $valueType = gettype($value);
+ throw new Exception\RuntimeException(
+ "zend_disk_cache_store($internalKey, <{$valueType}>, {$ttl}) failed"
+ );
+ }
+ }
+
+ /**
+ * Fetch a single item from Zend Data Disk Cache
+ *
+ * @param string $internalKey
+ * @return mixed The stored value or NULL if item wasn't found
+ * @throws Exception\RuntimeException
+ */
+ protected function zdcFetch($internalKey)
+ {
+ return zend_disk_cache_fetch((string) $internalKey);
+ }
+
+ /**
+ * Fetch multiple items from Zend Data Disk Cache
+ *
+ * @param array $internalKeys
+ * @return array All found items
+ * @throws Exception\RuntimeException
+ */
+ protected function zdcFetchMulti(array $internalKeys)
+ {
+ $items = zend_disk_cache_fetch($internalKeys);
+ if ($items === false) {
+ throw new Exception\RuntimeException("zend_disk_cache_fetch() failed");
+ }
+ return $items;
+ }
+
+ /**
+ * Delete data from Zend Data Disk Cache
+ *
+ * @param string $internalKey
+ * @return bool
+ * @throws Exception\RuntimeException
+ */
+ protected function zdcDelete($internalKey)
+ {
+ return zend_disk_cache_delete($internalKey);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/ZendServerShm.php zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/ZendServerShm.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Adapter/ZendServerShm.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Adapter/ZendServerShm.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,142 @@
+, {$ttl}) failed"
+ );
+ }
+ }
+
+ /**
+ * Fetch a single item from Zend Data SHM Cache
+ *
+ * @param string $internalKey
+ * @return mixed The stored value or NULL if item wasn't found
+ * @throws Exception\RuntimeException
+ */
+ protected function zdcFetch($internalKey)
+ {
+ return zend_shm_cache_fetch((string) $internalKey);
+ }
+
+ /**
+ * Fetch multiple items from Zend Data SHM Cache
+ *
+ * @param array $internalKeys
+ * @return array All found items
+ * @throws Exception\RuntimeException
+ */
+ protected function zdcFetchMulti(array $internalKeys)
+ {
+ $items = zend_shm_cache_fetch($internalKeys);
+ if ($items === false) {
+ throw new Exception\RuntimeException("zend_shm_cache_fetch() failed");
+ }
+ return $items;
+ }
+
+ /**
+ * Delete data from Zend Data SHM Cache
+ *
+ * @param string $internalKey
+ * @return bool
+ * @throws Exception\RuntimeException
+ */
+ protected function zdcDelete($internalKey)
+ {
+ return zend_shm_cache_delete($internalKey);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/AdapterPluginManager.php zendframework-2.2.6/library/Zend/Cache/Storage/AdapterPluginManager.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/AdapterPluginManager.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/AdapterPluginManager.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,72 @@
+ 'Zend\Cache\Storage\Adapter\Apc',
+ 'dba' => 'Zend\Cache\Storage\Adapter\Dba',
+ 'filesystem' => 'Zend\Cache\Storage\Adapter\Filesystem',
+ 'memcached' => 'Zend\Cache\Storage\Adapter\Memcached',
+ 'memory' => 'Zend\Cache\Storage\Adapter\Memory',
+ 'redis' => 'Zend\Cache\Storage\Adapter\Redis',
+ 'session' => 'Zend\Cache\Storage\Adapter\Session',
+ 'xcache' => 'Zend\Cache\Storage\Adapter\XCache',
+ 'wincache' => 'Zend\Cache\Storage\Adapter\WinCache',
+ 'zendserverdisk' => 'Zend\Cache\Storage\Adapter\ZendServerDisk',
+ 'zendservershm' => 'Zend\Cache\Storage\Adapter\ZendServerShm',
+ );
+
+ /**
+ * Do not share by default
+ *
+ * @var array
+ */
+ protected $shareByDefault = false;
+
+ /**
+ * Validate the plugin
+ *
+ * Checks that the adapter loaded is an instance of StorageInterface.
+ *
+ * @param mixed $plugin
+ * @return void
+ * @throws Exception\RuntimeException if invalid
+ */
+ public function validatePlugin($plugin)
+ {
+ if ($plugin instanceof StorageInterface) {
+ // we're okay
+ return;
+ }
+
+ throw new Exception\RuntimeException(sprintf(
+ 'Plugin of type %s is invalid; must implement %s\StorageInterface',
+ (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
+ __NAMESPACE__
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/AvailableSpaceCapableInterface.php zendframework-2.2.6/library/Zend/Cache/Storage/AvailableSpaceCapableInterface.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/AvailableSpaceCapableInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/AvailableSpaceCapableInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,20 @@
+storage = $storage;
+ $this->marker = $marker;
+ $this->baseCapabilities = $baseCapabilities;
+
+ foreach ($capabilities as $name => $value) {
+ $this->setCapability($marker, $name, $value);
+ }
+ }
+
+ /**
+ * Get the storage adapter
+ *
+ * @return StorageInterface
+ */
+ public function getAdapter()
+ {
+ return $this->storage;
+ }
+
+ /**
+ * Get supported datatypes
+ *
+ * @return array
+ */
+ public function getSupportedDatatypes()
+ {
+ return $this->getCapability('supportedDatatypes', array(
+ 'NULL' => false,
+ 'boolean' => false,
+ 'integer' => false,
+ 'double' => false,
+ 'string' => true,
+ 'array' => false,
+ 'object' => false,
+ 'resource' => false,
+ ));
+ }
+
+ /**
+ * Set supported datatypes
+ *
+ * @param stdClass $marker
+ * @param array $datatypes
+ * @throws Exception\InvalidArgumentException
+ * @return Capabilities Fluent interface
+ */
+ public function setSupportedDatatypes(stdClass $marker, array $datatypes)
+ {
+ $allTypes = array(
+ 'array',
+ 'boolean',
+ 'double',
+ 'integer',
+ 'NULL',
+ 'object',
+ 'resource',
+ 'string',
+ );
+
+ // check/normalize datatype values
+ foreach ($datatypes as $type => &$toType) {
+ if (!in_array($type, $allTypes)) {
+ throw new Exception\InvalidArgumentException("Unknown datatype '{$type}'");
+ }
+
+ if (is_string($toType)) {
+ $toType = strtolower($toType);
+ if (!in_array($toType, $allTypes)) {
+ throw new Exception\InvalidArgumentException("Unknown datatype '{$toType}'");
+ }
+ } else {
+ $toType = (bool) $toType;
+ }
+ }
+
+ // add missing datatypes as not supported
+ $missingTypes = array_diff($allTypes, array_keys($datatypes));
+ foreach ($missingTypes as $type) {
+ $datatypes[$type] = false;
+ }
+
+ return $this->setCapability($marker, 'supportedDatatypes', $datatypes);
+ }
+
+ /**
+ * Get supported metadata
+ *
+ * @return array
+ */
+ public function getSupportedMetadata()
+ {
+ return $this->getCapability('supportedMetadata', array());
+ }
+
+ /**
+ * Set supported metadata
+ *
+ * @param stdClass $marker
+ * @param string[] $metadata
+ * @throws Exception\InvalidArgumentException
+ * @return Capabilities Fluent interface
+ */
+ public function setSupportedMetadata(stdClass $marker, array $metadata)
+ {
+ foreach ($metadata as $name) {
+ if (!is_string($name)) {
+ throw new Exception\InvalidArgumentException('$metadata must be an array of strings');
+ }
+ }
+ return $this->setCapability($marker, 'supportedMetadata', $metadata);
+ }
+
+ /**
+ * Get minimum supported time-to-live
+ *
+ * @return int 0 means items never expire
+ */
+ public function getMinTtl()
+ {
+ return $this->getCapability('minTtl', 0);
+ }
+
+ /**
+ * Set minimum supported time-to-live
+ *
+ * @param stdClass $marker
+ * @param int $minTtl
+ * @throws Exception\InvalidArgumentException
+ * @return Capabilities Fluent interface
+ */
+ public function setMinTtl(stdClass $marker, $minTtl)
+ {
+ $minTtl = (int) $minTtl;
+ if ($minTtl < 0) {
+ throw new Exception\InvalidArgumentException('$minTtl must be greater or equal 0');
+ }
+ return $this->setCapability($marker, 'minTtl', $minTtl);
+ }
+
+ /**
+ * Get maximum supported time-to-live
+ *
+ * @return int 0 means infinite
+ */
+ public function getMaxTtl()
+ {
+ return $this->getCapability('maxTtl', 0);
+ }
+
+ /**
+ * Set maximum supported time-to-live
+ *
+ * @param stdClass $marker
+ * @param int $maxTtl
+ * @throws Exception\InvalidArgumentException
+ * @return Capabilities Fluent interface
+ */
+ public function setMaxTtl(stdClass $marker, $maxTtl)
+ {
+ $maxTtl = (int) $maxTtl;
+ if ($maxTtl < 0) {
+ throw new Exception\InvalidArgumentException('$maxTtl must be greater or equal 0');
+ }
+ return $this->setCapability($marker, 'maxTtl', $maxTtl);
+ }
+
+ /**
+ * Is the time-to-live handled static (on write)
+ * or dynamic (on read)
+ *
+ * @return bool
+ */
+ public function getStaticTtl()
+ {
+ return $this->getCapability('staticTtl', false);
+ }
+
+ /**
+ * Set if the time-to-live handled static (on write) or dynamic (on read)
+ *
+ * @param stdClass $marker
+ * @param bool $flag
+ * @return Capabilities Fluent interface
+ */
+ public function setStaticTtl(stdClass $marker, $flag)
+ {
+ return $this->setCapability($marker, 'staticTtl', (bool) $flag);
+ }
+
+ /**
+ * Get time-to-live precision
+ *
+ * @return float
+ */
+ public function getTtlPrecision()
+ {
+ return $this->getCapability('ttlPrecision', 1);
+ }
+
+ /**
+ * Set time-to-live precision
+ *
+ * @param stdClass $marker
+ * @param float $ttlPrecision
+ * @throws Exception\InvalidArgumentException
+ * @return Capabilities Fluent interface
+ */
+ public function setTtlPrecision(stdClass $marker, $ttlPrecision)
+ {
+ $ttlPrecision = (float) $ttlPrecision;
+ if ($ttlPrecision <= 0) {
+ throw new Exception\InvalidArgumentException('$ttlPrecision must be greater than 0');
+ }
+ return $this->setCapability($marker, 'ttlPrecision', $ttlPrecision);
+ }
+
+ /**
+ * Get use request time
+ *
+ * @return bool
+ */
+ public function getUseRequestTime()
+ {
+ return $this->getCapability('useRequestTime', false);
+ }
+
+ /**
+ * Set use request time
+ *
+ * @param stdClass $marker
+ * @param bool $flag
+ * @return Capabilities Fluent interface
+ */
+ public function setUseRequestTime(stdClass $marker, $flag)
+ {
+ return $this->setCapability($marker, 'useRequestTime', (bool) $flag);
+ }
+
+ /**
+ * Get if expired items are readable
+ *
+ * @return bool
+ */
+ public function getExpiredRead()
+ {
+ return $this->getCapability('expiredRead', false);
+ }
+
+ /**
+ * Set if expired items are readable
+ *
+ * @param stdClass $marker
+ * @param bool $flag
+ * @return Capabilities Fluent interface
+ */
+ public function setExpiredRead(stdClass $marker, $flag)
+ {
+ return $this->setCapability($marker, 'expiredRead', (bool) $flag);
+ }
+
+ /**
+ * Get maximum key lenth
+ *
+ * @return int -1 means unknown, 0 means infinite
+ */
+ public function getMaxKeyLength()
+ {
+ return $this->getCapability('maxKeyLength', -1);
+ }
+
+ /**
+ * Set maximum key length
+ *
+ * @param stdClass $marker
+ * @param int $maxKeyLength
+ * @throws Exception\InvalidArgumentException
+ * @return Capabilities Fluent interface
+ */
+ public function setMaxKeyLength(stdClass $marker, $maxKeyLength)
+ {
+ $maxKeyLength = (int) $maxKeyLength;
+ if ($maxKeyLength < -1) {
+ throw new Exception\InvalidArgumentException('$maxKeyLength must be greater or equal than -1');
+ }
+ return $this->setCapability($marker, 'maxKeyLength', $maxKeyLength);
+ }
+
+ /**
+ * Get if namespace support is implemented as prefix
+ *
+ * @return bool
+ */
+ public function getNamespaceIsPrefix()
+ {
+ return $this->getCapability('namespaceIsPrefix', true);
+ }
+
+ /**
+ * Set if namespace support is implemented as prefix
+ *
+ * @param stdClass $marker
+ * @param bool $flag
+ * @return Capabilities Fluent interface
+ */
+ public function setNamespaceIsPrefix(stdClass $marker, $flag)
+ {
+ return $this->setCapability($marker, 'namespaceIsPrefix', (bool) $flag);
+ }
+
+ /**
+ * Get namespace separator if namespace is implemented as prefix
+ *
+ * @return string
+ */
+ public function getNamespaceSeparator()
+ {
+ return $this->getCapability('namespaceSeparator', '');
+ }
+
+ /**
+ * Set the namespace separator if namespace is implemented as prefix
+ *
+ * @param stdClass $marker
+ * @param string $separator
+ * @return Capabilities Fluent interface
+ */
+ public function setNamespaceSeparator(stdClass $marker, $separator)
+ {
+ return $this->setCapability($marker, 'namespaceSeparator', (string) $separator);
+ }
+
+ /**
+ * Get a capability
+ *
+ * @param string $property
+ * @param mixed $default
+ * @return mixed
+ */
+ protected function getCapability($property, $default = null)
+ {
+ if ($this->$property !== null) {
+ return $this->$property;
+ } elseif ($this->baseCapabilities) {
+ $getMethod = 'get' . $property;
+ return $this->baseCapabilities->$getMethod();
+ }
+ return $default;
+ }
+
+ /**
+ * Change a capability
+ *
+ * @param stdClass $marker
+ * @param string $property
+ * @param mixed $value
+ * @return Capabilities Fluent interface
+ * @throws Exception\InvalidArgumentException
+ */
+ protected function setCapability(stdClass $marker, $property, $value)
+ {
+ if ($this->marker !== $marker) {
+ throw new Exception\InvalidArgumentException('Invalid marker');
+ }
+
+ if ($this->$property !== $value) {
+ $this->$property = $value;
+
+ // trigger event
+ if ($this->storage instanceof EventsCapableInterface) {
+ $this->storage->getEventManager()->trigger('capability', $this->storage, new ArrayObject(array(
+ $property => $value
+ )));
+ }
+ }
+
+ return $this;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/ClearByNamespaceInterface.php zendframework-2.2.6/library/Zend/Cache/Storage/ClearByNamespaceInterface.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/ClearByNamespaceInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/ClearByNamespaceInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,21 @@
+setStorage($target);
+ }
+
+ /**
+ * Alias of setTarget
+ *
+ * @param StorageInterface $storage
+ * @return Event
+ * @see Zend\EventManager\Event::setTarget()
+ */
+ public function setStorage(StorageInterface $storage)
+ {
+ $this->target = $storage;
+ return $this;
+ }
+
+ /**
+ * Alias of getTarget
+ *
+ * @return StorageInterface
+ */
+ public function getStorage()
+ {
+ return $this->getTarget();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/ExceptionEvent.php zendframework-2.2.6/library/Zend/Cache/Storage/ExceptionEvent.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/ExceptionEvent.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/ExceptionEvent.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,91 @@
+setException($exception);
+ }
+
+ /**
+ * Set the exception to be thrown
+ *
+ * @param Exception $exception
+ * @return ExceptionEvent
+ */
+ public function setException(Exception $exception)
+ {
+ $this->exception = $exception;
+ return $this;
+ }
+
+ /**
+ * Get the exception to be thrown
+ *
+ * @return Exception
+ */
+ public function getException()
+ {
+ return $this->exception;
+ }
+
+ /**
+ * Throw the exception or use the result
+ *
+ * @param bool $flag
+ * @return ExceptionEvent
+ */
+ public function setThrowException($flag)
+ {
+ $this->throwException = (bool) $flag;
+ return $this;
+ }
+
+ /**
+ * Throw the exception or use the result
+ *
+ * @return bool
+ */
+ public function getThrowException()
+ {
+ return $this->throwException;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/FlushableInterface.php zendframework-2.2.6/library/Zend/Cache/Storage/FlushableInterface.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/FlushableInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/FlushableInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,20 @@
+options = $options;
+ return $this;
+ }
+
+ /**
+ * Get all pattern options
+ *
+ * @return PluginOptions
+ */
+ public function getOptions()
+ {
+ if (null === $this->options) {
+ $this->setOptions(new PluginOptions());
+ }
+ return $this->options;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Plugin/ClearExpiredByFactor.php zendframework-2.2.6/library/Zend/Cache/Storage/Plugin/ClearExpiredByFactor.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Plugin/ClearExpiredByFactor.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Plugin/ClearExpiredByFactor.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,49 @@
+listeners[] = $events->attach('setItem.post', $callback, $priority);
+ $this->listeners[] = $events->attach('setItems.post', $callback, $priority);
+ $this->listeners[] = $events->attach('addItem.post', $callback, $priority);
+ $this->listeners[] = $events->attach('addItems.post', $callback, $priority);
+ }
+
+ /**
+ * Clear expired items by factor after writing new item(s)
+ *
+ * @param PostEvent $event
+ * @return void
+ */
+ public function clearExpiredByFactor(PostEvent $event)
+ {
+ $storage = $event->getStorage();
+ if (!($storage instanceof ClearExpiredInterface)) {
+ return;
+ }
+
+ $factor = $this->getOptions()->getClearingFactor();
+ if ($factor && mt_rand(1, $factor) == 1) {
+ $storage->clearExpired();
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Plugin/ExceptionHandler.php zendframework-2.2.6/library/Zend/Cache/Storage/Plugin/ExceptionHandler.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Plugin/ExceptionHandler.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Plugin/ExceptionHandler.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,77 @@
+listeners[] = $events->attach('getItem.exception', $callback, $priority);
+ $this->listeners[] = $events->attach('getItems.exception', $callback, $priority);
+
+ $this->listeners[] = $events->attach('hasItem.exception', $callback, $priority);
+ $this->listeners[] = $events->attach('hasItems.exception', $callback, $priority);
+
+ $this->listeners[] = $events->attach('getMetadata.exception', $callback, $priority);
+ $this->listeners[] = $events->attach('getMetadatas.exception', $callback, $priority);
+
+ // write
+ $this->listeners[] = $events->attach('setItem.exception', $callback, $priority);
+ $this->listeners[] = $events->attach('setItems.exception', $callback, $priority);
+
+ $this->listeners[] = $events->attach('addItem.exception', $callback, $priority);
+ $this->listeners[] = $events->attach('addItems.exception', $callback, $priority);
+
+ $this->listeners[] = $events->attach('replaceItem.exception', $callback, $priority);
+ $this->listeners[] = $events->attach('replaceItems.exception', $callback, $priority);
+
+ $this->listeners[] = $events->attach('touchItem.exception', $callback, $priority);
+ $this->listeners[] = $events->attach('touchItems.exception', $callback, $priority);
+
+ $this->listeners[] = $events->attach('removeItem.exception', $callback, $priority);
+ $this->listeners[] = $events->attach('removeItems.exception', $callback, $priority);
+
+ $this->listeners[] = $events->attach('checkAndSetItem.exception', $callback, $priority);
+
+ // increment / decrement item(s)
+ $this->listeners[] = $events->attach('incrementItem.exception', $callback, $priority);
+ $this->listeners[] = $events->attach('incrementItems.exception', $callback, $priority);
+
+ $this->listeners[] = $events->attach('decrementItem.exception', $callback, $priority);
+ $this->listeners[] = $events->attach('decrementItems.exception', $callback, $priority);
+ }
+
+ /**
+ * On exception
+ *
+ * @param ExceptionEvent $event
+ * @return void
+ */
+ public function onException(ExceptionEvent $event)
+ {
+ $options = $this->getOptions();
+ $callback = $options->getExceptionCallback();
+ if ($callback) {
+ call_user_func($callback, $event->getException());
+ }
+
+ $event->setThrowException($options->getThrowExceptions());
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Plugin/IgnoreUserAbort.php zendframework-2.2.6/library/Zend/Cache/Storage/Plugin/IgnoreUserAbort.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Plugin/IgnoreUserAbort.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Plugin/IgnoreUserAbort.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,118 @@
+listeners[] = $events->attach('setItem.pre', $cbOnBefore, $priority);
+ $this->listeners[] = $events->attach('setItem.post', $cbOnAfter, $priority);
+ $this->listeners[] = $events->attach('setItem.exception', $cbOnAfter, $priority);
+
+ $this->listeners[] = $events->attach('setItems.pre', $cbOnBefore, $priority);
+ $this->listeners[] = $events->attach('setItems.post', $cbOnAfter, $priority);
+ $this->listeners[] = $events->attach('setItems.exception', $cbOnAfter, $priority);
+
+ $this->listeners[] = $events->attach('addItem.pre', $cbOnBefore, $priority);
+ $this->listeners[] = $events->attach('addItem.post', $cbOnAfter, $priority);
+ $this->listeners[] = $events->attach('addItem.exception', $cbOnAfter, $priority);
+
+ $this->listeners[] = $events->attach('addItems.pre', $cbOnBefore, $priority);
+ $this->listeners[] = $events->attach('addItems.post', $cbOnAfter, $priority);
+ $this->listeners[] = $events->attach('addItems.exception', $cbOnAfter, $priority);
+
+ $this->listeners[] = $events->attach('replaceItem.pre', $cbOnBefore, $priority);
+ $this->listeners[] = $events->attach('replaceItem.post', $cbOnAfter, $priority);
+ $this->listeners[] = $events->attach('replaceItem.exception', $cbOnAfter, $priority);
+
+ $this->listeners[] = $events->attach('replaceItems.pre', $cbOnBefore, $priority);
+ $this->listeners[] = $events->attach('replaceItems.post', $cbOnAfter, $priority);
+ $this->listeners[] = $events->attach('replaceItems.exception', $cbOnAfter, $priority);
+
+ $this->listeners[] = $events->attach('checkAndSetItem.pre', $cbOnBefore, $priority);
+ $this->listeners[] = $events->attach('checkAndSetItem.post', $cbOnAfter, $priority);
+ $this->listeners[] = $events->attach('checkAndSetItem.exception', $cbOnAfter, $priority);
+
+ // increment / decrement item(s)
+ $this->listeners[] = $events->attach('incrementItem.pre', $cbOnBefore, $priority);
+ $this->listeners[] = $events->attach('incrementItem.post', $cbOnAfter, $priority);
+ $this->listeners[] = $events->attach('incrementItem.exception', $cbOnAfter, $priority);
+
+ $this->listeners[] = $events->attach('incrementItems.pre', $cbOnBefore, $priority);
+ $this->listeners[] = $events->attach('incrementItems.post', $cbOnAfter, $priority);
+ $this->listeners[] = $events->attach('incrementItems.exception', $cbOnAfter, $priority);
+
+ $this->listeners[] = $events->attach('decrementItem.pre', $cbOnBefore, $priority);
+ $this->listeners[] = $events->attach('decrementItem.post', $cbOnAfter, $priority);
+ $this->listeners[] = $events->attach('decrementItem.exception', $cbOnAfter, $priority);
+
+ $this->listeners[] = $events->attach('decrementItems.pre', $cbOnBefore, $priority);
+ $this->listeners[] = $events->attach('decrementItems.post', $cbOnAfter, $priority);
+ $this->listeners[] = $events->attach('decrementItems.exception', $cbOnAfter, $priority);
+ }
+
+ /**
+ * Activate ignore_user_abort if not already done
+ * and save the target who activated it.
+ *
+ * @param Event $event
+ * @return void
+ */
+ public function onBefore(Event $event)
+ {
+ if ($this->activatedTarget === null && !ignore_user_abort(true)) {
+ $this->activatedTarget = $event->getTarget();
+ }
+ }
+
+ /**
+ * Reset ignore_user_abort if it's activated and if it's the same target
+ * who activated it.
+ *
+ * If exit_on_abort is enabled and the connection has been aborted
+ * exit the script.
+ *
+ * @param Event $event
+ * @return void
+ */
+ public function onAfter(Event $event)
+ {
+ if ($this->activatedTarget === $event->getTarget()) {
+ // exit if connection aborted
+ if ($this->getOptions()->getExitOnAbort() && connection_aborted()) {
+ exit;
+ }
+
+ // reset ignore_user_abort
+ ignore_user_abort(false);
+
+ // remove activated target
+ $this->activatedTarget = null;
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Plugin/OptimizeByFactor.php zendframework-2.2.6/library/Zend/Cache/Storage/Plugin/OptimizeByFactor.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Plugin/OptimizeByFactor.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Plugin/OptimizeByFactor.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,46 @@
+listeners[] = $events->attach('removeItem.post', $callback, $priority);
+ $this->listeners[] = $events->attach('removeItems.post', $callback, $priority);
+ }
+
+ /**
+ * Optimize by factor on a success _RESULT_
+ *
+ * @param PostEvent $event
+ * @return void
+ */
+ public function optimizeByFactor(PostEvent $event)
+ {
+ $storage = $event->getStorage();
+ if (!($storage instanceof OptimizableInterface)) {
+ return;
+ }
+
+ $factor = $this->getOptions()->getOptimizingFactor();
+ if ($factor && mt_rand(1, $factor) == 1) {
+ $storage->optimize();
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Plugin/PluginInterface.php zendframework-2.2.6/library/Zend/Cache/Storage/Plugin/PluginInterface.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Plugin/PluginInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Plugin/PluginInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,30 @@
+clearingFactor = $this->normalizeFactor($clearingFactor);
+ return $this;
+ }
+
+ /**
+ * Get automatic clearing factor
+ *
+ * Used by:
+ * - ClearExpiredByFactor
+ *
+ * @return int
+ */
+ public function getClearingFactor()
+ {
+ return $this->clearingFactor;
+ }
+
+ /**
+ * Set callback to call on intercepted exception
+ *
+ * Used by:
+ * - ExceptionHandler
+ *
+ * @param callable $exceptionCallback
+ * @throws Exception\InvalidArgumentException
+ * @return PluginOptions
+ */
+ public function setExceptionCallback($exceptionCallback)
+ {
+ if ($exceptionCallback !== null && !is_callable($exceptionCallback, true)) {
+ throw new Exception\InvalidArgumentException('Not a valid callback');
+ }
+ $this->exceptionCallback = $exceptionCallback;
+ return $this;
+ }
+
+ /**
+ * Get callback to call on intercepted exception
+ *
+ * Used by:
+ * - ExceptionHandler
+ *
+ * @return null|callable
+ */
+ public function getExceptionCallback()
+ {
+ return $this->exceptionCallback;
+ }
+
+ /**
+ * Exit if connection aborted and ignore_user_abort is disabled.
+ *
+ * @param bool $exitOnAbort
+ * @return PluginOptions
+ */
+ public function setExitOnAbort($exitOnAbort)
+ {
+ $this->exitOnAbort = (bool) $exitOnAbort;
+ return $this;
+ }
+
+ /**
+ * Exit if connection aborted and ignore_user_abort is disabled.
+ *
+ * @return bool
+ */
+ public function getExitOnAbort()
+ {
+ return $this->exitOnAbort;
+ }
+
+ /**
+ * Set automatic optimizing factor
+ *
+ * Used by:
+ * - OptimizeByFactor
+ *
+ * @param int $optimizingFactor
+ * @return PluginOptions
+ */
+ public function setOptimizingFactor($optimizingFactor)
+ {
+ $this->optimizingFactor = $this->normalizeFactor($optimizingFactor);
+ return $this;
+ }
+
+ /**
+ * Set automatic optimizing factor
+ *
+ * Used by:
+ * - OptimizeByFactor
+ *
+ * @return int
+ */
+ public function getOptimizingFactor()
+ {
+ return $this->optimizingFactor;
+ }
+
+ /**
+ * Set serializer
+ *
+ * Used by:
+ * - Serializer
+ *
+ * @param string|SerializerAdapter $serializer
+ * @throws Exception\InvalidArgumentException
+ * @return Serializer
+ */
+ public function setSerializer($serializer)
+ {
+ if (!is_string($serializer) && !$serializer instanceof SerializerAdapter) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s expects either a string serializer name or Zend\Serializer\Adapter\AdapterInterface instance; '
+ . 'received "%s"',
+ __METHOD__,
+ (is_object($serializer) ? get_class($serializer) : gettype($serializer))
+ ));
+ }
+ $this->serializer = $serializer;
+ return $this;
+ }
+
+ /**
+ * Get serializer
+ *
+ * Used by:
+ * - Serializer
+ *
+ * @return SerializerAdapter
+ */
+ public function getSerializer()
+ {
+ if (!$this->serializer instanceof SerializerAdapter) {
+ // use default serializer
+ if (!$this->serializer) {
+ $this->setSerializer(SerializerFactory::getDefaultAdapter());
+ // instantiate by class name + serializer_options
+ } else {
+ $options = $this->getSerializerOptions();
+ $this->setSerializer(SerializerFactory::factory($this->serializer, $options));
+ }
+ }
+ return $this->serializer;
+ }
+
+ /**
+ * Set configuration options for instantiating a serializer adapter
+ *
+ * Used by:
+ * - Serializer
+ *
+ * @param mixed $serializerOptions
+ * @return PluginOptions
+ */
+ public function setSerializerOptions($serializerOptions)
+ {
+ $this->serializerOptions = $serializerOptions;
+ return $this;
+ }
+
+ /**
+ * Get configuration options for instantiating a serializer adapter
+ *
+ * Used by:
+ * - Serializer
+ *
+ * @return array
+ */
+ public function getSerializerOptions()
+ {
+ return $this->serializerOptions;
+ }
+
+ /**
+ * Set flag indicating we should re-throw exceptions
+ *
+ * Used by:
+ * - ExceptionHandler
+ *
+ * @param bool $throwExceptions
+ * @return PluginOptions
+ */
+ public function setThrowExceptions($throwExceptions)
+ {
+ $this->throwExceptions = (bool) $throwExceptions;
+ return $this;
+ }
+
+ /**
+ * Should we re-throw exceptions?
+ *
+ * Used by:
+ * - ExceptionHandler
+ *
+ * @return bool
+ */
+ public function getThrowExceptions()
+ {
+ return $this->throwExceptions;
+ }
+
+ /**
+ * Normalize a factor
+ *
+ * Cast to int and ensure we have a value greater than zero.
+ *
+ * @param int $factor
+ * @return int
+ * @throws Exception\InvalidArgumentException
+ */
+ protected function normalizeFactor($factor)
+ {
+ $factor = (int) $factor;
+ if ($factor < 0) {
+ throw new Exception\InvalidArgumentException(
+ "Invalid factor '{$factor}': must be greater or equal 0"
+ );
+ }
+ return $factor;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/Plugin/Serializer.php zendframework-2.2.6/library/Zend/Cache/Storage/Plugin/Serializer.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/Plugin/Serializer.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/Plugin/Serializer.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,259 @@
+listeners[] = $events->attach('getItem.post', array($this, 'onReadItemPost'), $postPriority);
+ $this->listeners[] = $events->attach('getItems.post', array($this, 'onReadItemsPost'), $postPriority);
+
+ // write
+ $this->listeners[] = $events->attach('setItem.pre', array($this, 'onWriteItemPre'), $prePriority);
+ $this->listeners[] = $events->attach('setItems.pre', array($this, 'onWriteItemsPre'), $prePriority);
+
+ $this->listeners[] = $events->attach('addItem.pre', array($this, 'onWriteItemPre'), $prePriority);
+ $this->listeners[] = $events->attach('addItems.pre', array($this, 'onWriteItemsPre'), $prePriority);
+
+ $this->listeners[] = $events->attach('replaceItem.pre', array($this, 'onWriteItemPre'), $prePriority);
+ $this->listeners[] = $events->attach('replaceItems.pre', array($this, 'onWriteItemsPre'), $prePriority);
+
+ $this->listeners[] = $events->attach('checkAndSetItem.pre', array($this, 'onWriteItemPre'), $prePriority);
+
+ // increment / decrement item(s)
+ $this->listeners[] = $events->attach('incrementItem.pre', array($this, 'onIncrementItemPre'), $prePriority);
+ $this->listeners[] = $events->attach('incrementItems.pre', array($this, 'onIncrementItemsPre'), $prePriority);
+
+ $this->listeners[] = $events->attach('decrementItem.pre', array($this, 'onDecrementItemPre'), $prePriority);
+ $this->listeners[] = $events->attach('decrementItems.pre', array($this, 'onDecrementItemsPre'), $prePriority);
+
+ // overwrite capabilities
+ $this->listeners[] = $events->attach('getCapabilities.post', array($this, 'onGetCapabilitiesPost'), $postPriority);
+ }
+
+ /**
+ * On read item post
+ *
+ * @param PostEvent $event
+ * @return void
+ */
+ public function onReadItemPost(PostEvent $event)
+ {
+ $serializer = $this->getOptions()->getSerializer();
+ $result = $event->getResult();
+ $result = $serializer->unserialize($result);
+ $event->setResult($result);
+ }
+
+ /**
+ * On read items post
+ *
+ * @param PostEvent $event
+ * @return void
+ */
+ public function onReadItemsPost(PostEvent $event)
+ {
+ $serializer = $this->getOptions()->getSerializer();
+ $result = $event->getResult();
+ foreach ($result as &$value) {
+ $value = $serializer->unserialize($value);
+ }
+ $event->setResult($result);
+ }
+
+ /**
+ * On write item pre
+ *
+ * @param Event $event
+ * @return void
+ */
+ public function onWriteItemPre(Event $event)
+ {
+ $serializer = $this->getOptions()->getSerializer();
+ $params = $event->getParams();
+ $params['value'] = $serializer->serialize($params['value']);
+ }
+
+ /**
+ * On write items pre
+ *
+ * @param Event $event
+ * @return void
+ */
+ public function onWriteItemsPre(Event $event)
+ {
+ $serializer = $this->getOptions()->getSerializer();
+ $params = $event->getParams();
+ foreach ($params['keyValuePairs'] as &$value) {
+ $value = $serializer->serialize($value);
+ }
+ }
+
+ /**
+ * On increment item pre
+ *
+ * @param Event $event
+ * @return mixed
+ */
+ public function onIncrementItemPre(Event $event)
+ {
+ $storage = $event->getTarget();
+ $params = $event->getParams();
+ $casToken = null;
+ $success = null;
+ $oldValue = $storage->getItem($params['key'], $success, $casToken);
+ $newValue = $oldValue + $params['value'];
+
+ if ($success) {
+ $storage->checkAndSetItem($casToken, $params['key'], $oldValue + $params['value']);
+ $result = $newValue;
+ } else {
+ $result = false;
+ }
+
+ $event->stopPropagation(true);
+ return $result;
+ }
+
+ /**
+ * On increment items pre
+ *
+ * @param Event $event
+ * @return mixed
+ */
+ public function onIncrementItemsPre(Event $event)
+ {
+ $storage = $event->getTarget();
+ $params = $event->getParams();
+ $keyValuePairs = $storage->getItems(array_keys($params['keyValuePairs']));
+ foreach ($params['keyValuePairs'] as $key => & $value) {
+ if (isset($keyValuePairs[$key])) {
+ $keyValuePairs[$key]+= $value;
+ } else {
+ $keyValuePairs[$key] = $value;
+ }
+ }
+
+ $failedKeys = $storage->setItems($keyValuePairs);
+ foreach ($failedKeys as $failedKey) {
+ unset($keyValuePairs[$failedKey]);
+ }
+
+ $event->stopPropagation(true);
+ return $keyValuePairs;
+ }
+
+ /**
+ * On decrement item pre
+ *
+ * @param Event $event
+ * @return mixed
+ */
+ public function onDecrementItemPre(Event $event)
+ {
+ $storage = $event->getTarget();
+ $params = $event->getParams();
+ $success = null;
+ $casToken = null;
+ $oldValue = $storage->getItem($params['key'], $success, $casToken);
+ $newValue = $oldValue - $params['value'];
+
+ if ($success) {
+ $storage->checkAndSetItem($casToken, $params['key'], $oldValue + $params['value']);
+ $result = $newValue;
+ } else {
+ $result = false;
+ }
+
+ $event->stopPropagation(true);
+ return $result;
+ }
+
+ /**
+ * On decrement items pre
+ *
+ * @param Event $event
+ * @return mixed
+ */
+ public function onDecrementItemsPre(Event $event)
+ {
+ $storage = $event->getTarget();
+ $params = $event->getParams();
+ $keyValuePairs = $storage->getItems(array_keys($params['keyValuePairs']));
+ foreach ($params['keyValuePairs'] as $key => &$value) {
+ if (isset($keyValuePairs[$key])) {
+ $keyValuePairs[$key]-= $value;
+ } else {
+ $keyValuePairs[$key] = -$value;
+ }
+ }
+
+ $failedKeys = $storage->setItems($keyValuePairs);
+ foreach ($failedKeys as $failedKey) {
+ unset($keyValuePairs[$failedKey]);
+ }
+
+ $event->stopPropagation(true);
+ return $keyValuePairs;
+ }
+
+ /**
+ * On get capabilities
+ *
+ * @param PostEvent $event
+ * @return void
+ */
+ public function onGetCapabilitiesPost(PostEvent $event)
+ {
+ $baseCapabilities = $event->getResult();
+ $index = spl_object_hash($baseCapabilities);
+
+ if (!isset($this->capabilities[$index])) {
+ $this->capabilities[$index] = new Capabilities(
+ $baseCapabilities->getAdapter(),
+ new stdClass(), // marker
+ array('supportedDatatypes' => array(
+ 'NULL' => true,
+ 'boolean' => true,
+ 'integer' => true,
+ 'double' => true,
+ 'string' => true,
+ 'array' => true,
+ 'object' => 'object',
+ 'resource' => false,
+ )),
+ $baseCapabilities
+ );
+ }
+
+ $event->setResult($this->capabilities[$index]);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/PluginManager.php zendframework-2.2.6/library/Zend/Cache/Storage/PluginManager.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/PluginManager.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/PluginManager.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,66 @@
+ 'Zend\Cache\Storage\Plugin\ClearExpiredByFactor',
+ 'exceptionhandler' => 'Zend\Cache\Storage\Plugin\ExceptionHandler',
+ 'ignoreuserabort' => 'Zend\Cache\Storage\Plugin\IgnoreUserAbort',
+ 'optimizebyfactor' => 'Zend\Cache\Storage\Plugin\OptimizeByFactor',
+ 'serializer' => 'Zend\Cache\Storage\Plugin\Serializer',
+ );
+
+ /**
+ * Do not share by default
+ *
+ * @var array
+ */
+ protected $shareByDefault = false;
+
+ /**
+ * Validate the plugin
+ *
+ * Checks that the plugin loaded is an instance of Plugin\PluginInterface.
+ *
+ * @param mixed $plugin
+ * @return void
+ * @throws Exception\RuntimeException if invalid
+ */
+ public function validatePlugin($plugin)
+ {
+ if ($plugin instanceof Plugin\PluginInterface) {
+ // we're okay
+ return;
+ }
+
+ throw new Exception\RuntimeException(sprintf(
+ 'Plugin of type %s is invalid; must implement %s\Plugin\PluginInterface',
+ (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
+ __NAMESPACE__
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/PostEvent.php zendframework-2.2.6/library/Zend/Cache/Storage/PostEvent.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/PostEvent.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/PostEvent.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,60 @@
+setResult($result);
+ }
+
+ /**
+ * Set the result/return value
+ *
+ * @param mixed $value
+ * @return PostEvent
+ */
+ public function setResult(& $value)
+ {
+ $this->result = & $value;
+ return $this;
+ }
+
+ /**
+ * Get the result/return value
+ *
+ * @return mixed
+ */
+ public function & getResult()
+ {
+ return $this->result;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache/Storage/StorageInterface.php zendframework-2.2.6/library/Zend/Cache/Storage/StorageInterface.php
--- zendframework-1.10.4/library/Zend/Cache/Storage/StorageInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache/Storage/StorageInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,246 @@
+ $v) {
+ $pluginPrio = 1; // default priority
+
+ if (is_string($k)) {
+ if (!is_array($v)) {
+ throw new Exception\InvalidArgumentException(
+ "'plugins.{$k}' needs to be an array"
+ );
+ }
+ $pluginName = $k;
+ $pluginOptions = $v;
+ } elseif (is_array($v)) {
+ if (!isset($v['name'])) {
+ throw new Exception\InvalidArgumentException("Invalid plugins[{$k}] or missing plugins[{$k}].name");
+ }
+ $pluginName = (string) $v['name'];
+
+ if (isset($v['options'])) {
+ $pluginOptions = $v['options'];
+ } else {
+ $pluginOptions = array();
+ }
+
+ if (isset($v['priority'])) {
+ $pluginPrio = $v['priority'];
+ }
+ } else {
+ $pluginName = $v;
+ $pluginOptions = array();
+ }
+
+ $plugin = static::pluginFactory($pluginName, $pluginOptions);
+ $adapter->addPlugin($plugin, $pluginPrio);
+ }
+ }
+
+ return $adapter;
+ }
+
+ /**
+ * Instantiate a storage adapter
+ *
+ * @param string|Storage\StorageInterface $adapterName
+ * @param array|Traversable|Storage\Adapter\AdapterOptions $options
+ * @return Storage\StorageInterface
+ * @throws Exception\RuntimeException
+ */
+ public static function adapterFactory($adapterName, $options = array())
+ {
+ if ($adapterName instanceof Storage\StorageInterface) {
+ // $adapterName is already an adapter object
+ $adapter = $adapterName;
+ } else {
+ $adapter = static::getAdapterPluginManager()->get($adapterName);
+ }
+
+ if ($options) {
+ $adapter->setOptions($options);
+ }
+
+ return $adapter;
+ }
+
+ /**
+ * Get the adapter plugin manager
+ *
+ * @return Storage\AdapterPluginManager
+ */
+ public static function getAdapterPluginManager()
+ {
+ if (static::$adapters === null) {
+ static::$adapters = new Storage\AdapterPluginManager();
+ }
+ return static::$adapters;
+ }
+
+ /**
+ * Change the adapter plugin manager
+ *
+ * @param Storage\AdapterPluginManager $adapters
+ * @return void
+ */
+ public static function setAdapterPluginManager(Storage\AdapterPluginManager $adapters)
+ {
+ static::$adapters = $adapters;
+ }
+
+ /**
+ * Resets the internal adapter plugin manager
+ *
+ * @return void
+ */
+ public static function resetAdapterPluginManager()
+ {
+ static::$adapters = null;
+ }
+
+ /**
+ * Instantiate a storage plugin
+ *
+ * @param string|Storage\Plugin\PluginInterface $pluginName
+ * @param array|Traversable|Storage\Plugin\PluginOptions $options
+ * @return Storage\Plugin\PluginInterface
+ * @throws Exception\RuntimeException
+ */
+ public static function pluginFactory($pluginName, $options = array())
+ {
+ if ($pluginName instanceof Storage\Plugin\PluginInterface) {
+ // $pluginName is already an plugin object
+ $plugin = $pluginName;
+ } else {
+ $plugin = static::getPluginManager()->get($pluginName);
+ }
+
+ if (!$options instanceof Storage\Plugin\PluginOptions) {
+ $options = new Storage\Plugin\PluginOptions($options);
+ }
+
+ if ($options) {
+ $plugin->setOptions($options);
+ }
+
+ return $plugin;
+ }
+
+ /**
+ * Get the plugin manager
+ *
+ * @return Storage\PluginManager
+ */
+ public static function getPluginManager()
+ {
+ if (static::$plugins === null) {
+ static::$plugins = new Storage\PluginManager();
+ }
+ return static::$plugins;
+ }
+
+ /**
+ * Change the plugin manager
+ *
+ * @param Storage\PluginManager $plugins
+ * @return void
+ */
+ public static function setPluginManager(Storage\PluginManager $plugins)
+ {
+ static::$plugins = $plugins;
+ }
+
+ /**
+ * Resets the internal plugin manager
+ *
+ * @return void
+ */
+ public static function resetPluginManager()
+ {
+ static::$plugins = null;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Cache.php zendframework-2.2.6/library/Zend/Cache.php
--- zendframework-1.10.4/library/Zend/Cache.php 2010-04-23 17:10:17.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Cache.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,250 +0,0 @@
-setBackend($backendObject);
- return $frontendObject;
- }
-
- /**
- * Frontend Constructor
- *
- * @param string $backend
- * @param array $backendOptions
- * @param boolean $customBackendNaming
- * @param boolean $autoload
- * @return Zend_Cache_Backend
- */
- public static function _makeBackend($backend, $backendOptions, $customBackendNaming = false, $autoload = false)
- {
- if (!$customBackendNaming) {
- $backend = self::_normalizeName($backend);
- }
- if (in_array($backend, Zend_Cache::$standardBackends)) {
- // we use a standard backend
- $backendClass = 'Zend_Cache_Backend_' . $backend;
- // security controls are explicit
- require_once str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php';
- } else {
- // we use a custom backend
- if (!preg_match('~^[\w]+$~D', $backend)) {
- Zend_Cache::throwException("Invalid backend name [$backend]");
- }
- if (!$customBackendNaming) {
- // we use this boolean to avoid an API break
- $backendClass = 'Zend_Cache_Backend_' . $backend;
- } else {
- $backendClass = $backend;
- }
- if (!$autoload) {
- $file = str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php';
- if (!(self::_isReadable($file))) {
- self::throwException("file $file not found in include_path");
- }
- require_once $file;
- }
- }
- return new $backendClass($backendOptions);
- }
-
- /**
- * Backend Constructor
- *
- * @param string $frontend
- * @param array $frontendOptions
- * @param boolean $customFrontendNaming
- * @param boolean $autoload
- * @return Zend_Cache_Core|Zend_Cache_Frontend
- */
- public static function _makeFrontend($frontend, $frontendOptions = array(), $customFrontendNaming = false, $autoload = false)
- {
- if (!$customFrontendNaming) {
- $frontend = self::_normalizeName($frontend);
- }
- if (in_array($frontend, self::$standardFrontends)) {
- // we use a standard frontend
- // For perfs reasons, with frontend == 'Core', we can interact with the Core itself
- $frontendClass = 'Zend_Cache_' . ($frontend != 'Core' ? 'Frontend_' : '') . $frontend;
- // security controls are explicit
- require_once str_replace('_', DIRECTORY_SEPARATOR, $frontendClass) . '.php';
- } else {
- // we use a custom frontend
- if (!preg_match('~^[\w]+$~D', $frontend)) {
- Zend_Cache::throwException("Invalid frontend name [$frontend]");
- }
- if (!$customFrontendNaming) {
- // we use this boolean to avoid an API break
- $frontendClass = 'Zend_Cache_Frontend_' . $frontend;
- } else {
- $frontendClass = $frontend;
- }
- if (!$autoload) {
- $file = str_replace('_', DIRECTORY_SEPARATOR, $frontendClass) . '.php';
- if (!(self::_isReadable($file))) {
- self::throwException("file $file not found in include_path");
- }
- require_once $file;
- }
- }
- return new $frontendClass($frontendOptions);
- }
-
- /**
- * Throw an exception
- *
- * Note : for perf reasons, the "load" of Zend/Cache/Exception is dynamic
- * @param string $msg Message for the exception
- * @throws Zend_Cache_Exception
- */
- public static function throwException($msg, Exception $e = null)
- {
- // For perfs reasons, we use this dynamic inclusion
- require_once 'Zend/Cache/Exception.php';
- throw new Zend_Cache_Exception($msg, 0, $e);
- }
-
- /**
- * Normalize frontend and backend names to allow multiple words TitleCased
- *
- * @param string $name Name to normalize
- * @return string
- */
- protected static function _normalizeName($name)
- {
- $name = ucfirst(strtolower($name));
- $name = str_replace(array('-', '_', '.'), ' ', $name);
- $name = ucwords($name);
- $name = str_replace(' ', '', $name);
- if (stripos($name, 'ZendServer') === 0) {
- $name = 'ZendServer_' . substr($name, strlen('ZendServer'));
- }
-
- return $name;
- }
-
- /**
- * Returns TRUE if the $filename is readable, or FALSE otherwise.
- * This function uses the PHP include_path, where PHP's is_readable()
- * does not.
- *
- * Note : this method comes from Zend_Loader (see #ZF-2891 for details)
- *
- * @param string $filename
- * @return boolean
- */
- private static function _isReadable($filename)
- {
- if (!$fh = @fopen($filename, 'r', true)) {
- return false;
- }
- @fclose($fh);
- return true;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Captcha/AbstractAdapter.php zendframework-2.2.6/library/Zend/Captcha/AbstractAdapter.php
--- zendframework-1.10.4/library/Zend/Captcha/AbstractAdapter.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Captcha/AbstractAdapter.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,135 @@
+name;
+ }
+
+ /**
+ * Set name
+ *
+ * @param string $name
+ * @return AbstractAdapter
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * Set single option for the object
+ *
+ * @param string $key
+ * @param string $value
+ * @return AbstractAdapter
+ */
+ public function setOption($key, $value)
+ {
+ if (in_array(strtolower($key), $this->skipOptions)) {
+ return $this;
+ }
+
+ $method = 'set' . ucfirst($key);
+ if (method_exists($this, $method)) {
+ // Setter exists; use it
+ $this->$method($value);
+ $this->options[$key] = $value;
+ } elseif (property_exists($this, $key)) {
+ // Assume it's metadata
+ $this->$key = $value;
+ $this->options[$key] = $value;
+ }
+ return $this;
+ }
+
+ /**
+ * Set object state from options array
+ *
+ * @param array|Traversable $options
+ * @throws Exception\InvalidArgumentException
+ * @return AbstractAdapter
+ */
+ public function setOptions($options = array())
+ {
+ if (!is_array($options) && !$options instanceof Traversable) {
+ throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable');
+ }
+
+ foreach ($options as $key => $value) {
+ $this->setOption($key, $value);
+ }
+ return $this;
+ }
+
+ /**
+ * Retrieve options representing object state
+ *
+ * @return array
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * Get helper name used to render captcha
+ *
+ * By default, return empty string, indicating no helper needed.
+ *
+ * @return string
+ */
+ public function getHelperName()
+ {
+ return '';
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Captcha/AbstractWord.php zendframework-2.2.6/library/Zend/Captcha/AbstractWord.php
--- zendframework-1.10.4/library/Zend/Captcha/AbstractWord.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Captcha/AbstractWord.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,407 @@
+ 'Empty captcha value',
+ self::MISSING_ID => 'Captcha ID field is missing',
+ self::BAD_CAPTCHA => 'Captcha value is wrong',
+ );
+
+ /**
+ * Length of the word to generate
+ *
+ * @var int
+ */
+ protected $wordlen = 8;
+
+ /**
+ * Retrieve session class to utilize
+ *
+ * @return string
+ */
+ public function getSessionClass()
+ {
+ return $this->sessionClass;
+ }
+
+ /**
+ * Set session class for persistence
+ *
+ * @param string $sessionClass
+ * @return AbstractWord
+ */
+ public function setSessionClass($sessionClass)
+ {
+ $this->sessionClass = $sessionClass;
+ return $this;
+ }
+
+ /**
+ * Retrieve word length to use when generating captcha
+ *
+ * @return int
+ */
+ public function getWordlen()
+ {
+ return $this->wordlen;
+ }
+
+ /**
+ * Set word length of captcha
+ *
+ * @param int $wordlen
+ * @return AbstractWord
+ */
+ public function setWordlen($wordlen)
+ {
+ $this->wordlen = $wordlen;
+ return $this;
+ }
+
+ /**
+ * Retrieve captcha ID
+ *
+ * @return string
+ */
+ public function getId()
+ {
+ if (null === $this->id) {
+ $this->setId($this->generateRandomId());
+ }
+ return $this->id;
+ }
+
+ /**
+ * Set captcha identifier
+ *
+ * @param string $id
+ * @return AbstractWord
+ */
+ protected function setId($id)
+ {
+ $this->id = $id;
+ return $this;
+ }
+
+ /**
+ * Set timeout for session token
+ *
+ * @param int $ttl
+ * @return AbstractWord
+ */
+ public function setTimeout($ttl)
+ {
+ $this->timeout = (int) $ttl;
+ return $this;
+ }
+
+ /**
+ * Get session token timeout
+ *
+ * @return int
+ */
+ public function getTimeout()
+ {
+ return $this->timeout;
+ }
+
+ /**
+ * Sets if session should be preserved on generate()
+ *
+ * @param bool $keepSession Should session be kept on generate()?
+ * @return AbstractWord
+ */
+ public function setKeepSession($keepSession)
+ {
+ $this->keepSession = $keepSession;
+ return $this;
+ }
+
+ /**
+ * Numbers should be included in the pattern?
+ *
+ * @return bool
+ */
+ public function getUseNumbers()
+ {
+ return $this->useNumbers;
+ }
+
+ /**
+ * Set if numbers should be included in the pattern
+ *
+ * @param bool $useNumbers numbers should be included in the pattern?
+ * @return AbstractWord
+ */
+ public function setUseNumbers($useNumbers)
+ {
+ $this->useNumbers = $useNumbers;
+ return $this;
+ }
+
+ /**
+ * Get session object
+ *
+ * @throws Exception\InvalidArgumentException
+ * @return Container
+ */
+ public function getSession()
+ {
+ if (!isset($this->session) || (null === $this->session)) {
+ $id = $this->getId();
+ if (!class_exists($this->sessionClass)) {
+ throw new Exception\InvalidArgumentException("Session class $this->sessionClass not found");
+ }
+ $this->session = new $this->sessionClass('Zend_Form_Captcha_' . $id);
+ $this->session->setExpirationHops(1, null);
+ $this->session->setExpirationSeconds($this->getTimeout());
+ }
+ return $this->session;
+ }
+
+ /**
+ * Set session namespace object
+ *
+ * @param Container $session
+ * @return AbstractWord
+ */
+ public function setSession(Container $session)
+ {
+ $this->session = $session;
+ if ($session) {
+ $this->keepSession = true;
+ }
+ return $this;
+ }
+
+ /**
+ * Get captcha word
+ *
+ * @return string
+ */
+ public function getWord()
+ {
+ if (empty($this->word)) {
+ $session = $this->getSession();
+ $this->word = $session->word;
+ }
+ return $this->word;
+ }
+
+ /**
+ * Set captcha word
+ *
+ * @param string $word
+ * @return AbstractWord
+ */
+ protected function setWord($word)
+ {
+ $session = $this->getSession();
+ $session->word = $word;
+ $this->word = $word;
+ return $this;
+ }
+
+ /**
+ * Generate new random word
+ *
+ * @return string
+ */
+ protected function generateWord()
+ {
+ $word = '';
+ $wordLen = $this->getWordLen();
+ $vowels = $this->useNumbers ? static::$VN : static::$V;
+ $consonants = $this->useNumbers ? static::$CN : static::$C;
+
+ for ($i=0; $i < $wordLen; $i = $i + 2) {
+ // generate word with mix of vowels and consonants
+ $consonant = $consonants[array_rand($consonants)];
+ $vowel = $vowels[array_rand($vowels)];
+ $word .= $consonant . $vowel;
+ }
+
+ if (strlen($word) > $wordLen) {
+ $word = substr($word, 0, $wordLen);
+ }
+
+ return $word;
+ }
+
+ /**
+ * Generate new session ID and new word
+ *
+ * @return string session ID
+ */
+ public function generate()
+ {
+ if (!$this->keepSession) {
+ $this->session = null;
+ }
+ $id = $this->generateRandomId();
+ $this->setId($id);
+ $word = $this->generateWord();
+ $this->setWord($word);
+ return $id;
+ }
+
+ /**
+ * Generate a random identifier
+ *
+ * @return string
+ */
+ protected function generateRandomId()
+ {
+ return md5(Rand::getBytes(32));
+ }
+
+ /**
+ * Validate the word
+ *
+ * @see Zend\Validator\ValidatorInterface::isValid()
+ * @param mixed $value
+ * @param mixed $context
+ * @return bool
+ */
+ public function isValid($value, $context = null)
+ {
+ if (!is_array($value)) {
+ if (!is_array($context)) {
+ $this->error(self::MISSING_VALUE);
+ return false;
+ }
+ $value = $context;
+ }
+
+ $name = $this->getName();
+
+ if (isset($value[$name])) {
+ $value = $value[$name];
+ }
+
+ if (!isset($value['input'])) {
+ $this->error(self::MISSING_VALUE);
+ return false;
+ }
+ $input = strtolower($value['input']);
+ $this->setValue($input);
+
+ if (!isset($value['id'])) {
+ $this->error(self::MISSING_ID);
+ return false;
+ }
+
+ $this->id = $value['id'];
+ if ($input !== $this->getWord()) {
+ $this->error(self::BAD_CAPTCHA);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Get helper name used to render captcha
+ *
+ * @return string
+ */
+ public function getHelperName()
+ {
+ return 'captcha/word';
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Captcha/AdapterInterface.php zendframework-2.2.6/library/Zend/Captcha/AdapterInterface.php
--- zendframework-1.10.4/library/Zend/Captcha/AdapterInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Captcha/AdapterInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,49 @@
+_name;
- }
-
- /**
- * Set name
- *
- * @param string $name
- */
- public function setName($name)
- {
- $this->_name = $name;
- return $this;
- }
-
- /**
- * Constructor
- *
- * @param array|Zend_Config $options
- * @return void
- */
- public function __construct($options = null)
- {
- // Set options
- if (is_array($options)) {
- $this->setOptions($options);
- } else if ($options instanceof Zend_Config) {
- $this->setConfig($options);
- }
- }
-
- /**
- * Set single option for the object
- *
- * @param string $key
- * @param string $value
- * @return Zend_Form_Element
- */
- public function setOption($key, $value)
- {
- if (in_array(strtolower($key), $this->_skipOptions)) {
- return $this;
- }
-
- $method = 'set' . ucfirst ($key);
- if (method_exists ($this, $method)) {
- // Setter exists; use it
- $this->$method ($value);
- $this->_options[$key] = $value;
- } elseif (property_exists($this, $key)) {
- // Assume it's metadata
- $this->$key = $value;
- $this->_options[$key] = $value;
- }
- return $this;
- }
-
- /**
- * Set object state from options array
- *
- * @param array $options
- * @return Zend_Form_Element
- */
- public function setOptions($options = null)
- {
- foreach ($options as $key => $value) {
- $this->setOption($key, $value);
- }
- return $this;
- }
-
- /**
- * Retrieve options representing object state
- *
- * @return array
- */
- public function getOptions()
- {
- return $this->_options;
- }
-
- /**
- * Set object state from config object
- *
- * @param Zend_Config $config
- * @return Zend_Captcha_Base
- */
- public function setConfig(Zend_Config $config)
- {
- return $this->setOptions($config->toArray());
- }
-
- /**
- * Get optional decorator
- *
- * By default, return null, indicating no extra decorator needed.
- *
- * @return null
- */
- public function getDecorator()
- {
- return null;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Captcha/composer.json zendframework-2.2.6/library/Zend/Captcha/composer.json
--- zendframework-1.10.4/library/Zend/Captcha/composer.json 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Captcha/composer.json 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,33 @@
+{
+ "name": "zendframework/zend-captcha",
+ "description": " ",
+ "license": "BSD-3-Clause",
+ "keywords": [
+ "zf2",
+ "captcha"
+ ],
+ "autoload": {
+ "psr-0": {
+ "Zend\\Captcha\\": ""
+ }
+ },
+ "target-dir": "Zend/Captcha",
+ "require": {
+ "php": ">=5.3.3",
+ "zendframework/zend-math": "self.version",
+ "zendframework/zend-stdlib": "self.version"
+ },
+ "require-dev": {
+ "zendframework/zendservice-recaptcha": "*"
+ },
+ "suggest": {
+ "zendframework/zendservice-recaptcha": "ZendService\\ReCaptcha component",
+ "zendframework/zend-resources": "Translations of captcha messages"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev",
+ "dev-develop": "2.3-dev"
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Captcha/Dumb.php zendframework-2.2.6/library/Zend/Captcha/Dumb.php
--- zendframework-1.10.4/library/Zend/Captcha/Dumb.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Captcha/Dumb.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,52 +1,54 @@
label = $label;
+ }
+
+ /**
+ * Retrieve the label for the CAPTCHA
+ * @return string
+ */
+ public function getLabel()
+ {
+ return $this->label;
+ }
+
+ /**
+ * Retrieve optional view helper name to use when rendering this captcha
*
- * @param Zend_View_Interface $view
- * @param mixed $element
* @return string
*/
- public function render(Zend_View_Interface $view = null, $element = null)
+ public function getHelperName()
{
- return 'Please type this word backwards: '
- . strrev($this->getWord())
- . '';
+ return 'captcha/dumb';
}
}
diff -Nru zendframework-1.10.4/library/Zend/Captcha/Exception/DomainException.php zendframework-2.2.6/library/Zend/Captcha/Exception/DomainException.php
--- zendframework-1.10.4/library/Zend/Captcha/Exception/DomainException.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Captcha/Exception/DomainException.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,14 @@
+ 'Zend\Captcha\Dumb',
+ 'figlet' => 'Zend\Captcha\Figlet',
+ 'image' => 'Zend\Captcha\Image',
+ 'recaptcha' => 'Zend\Captcha\ReCaptcha',
+ );
+
+ /**
+ * Create a captcha adapter instance
+ *
+ * @param array|Traversable $options
+ * @return AdapterInterface
+ * @throws Exception\InvalidArgumentException for a non-array, non-Traversable $options
+ * @throws Exception\DomainException if class is missing or invalid
+ */
+ public static function factory($options)
+ {
+ if ($options instanceof Traversable) {
+ $options = ArrayUtils::iteratorToArray($options);
+ }
+
+ if (!is_array($options)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s expects an array or Traversable argument; received "%s"',
+ __METHOD__,
+ (is_object($options) ? get_class($options) : gettype($options))
+ ));
+ }
+
+ if (!isset($options['class'])) {
+ throw new Exception\DomainException(sprintf(
+ '%s expects a "class" attribute in the options; none provided',
+ __METHOD__
+ ));
+ }
+
+ $class = $options['class'];
+ if (isset(static::$classMap[strtolower($class)])) {
+ $class = static::$classMap[strtolower($class)];
+ }
+ if (!class_exists($class)) {
+ throw new Exception\DomainException(sprintf(
+ '%s expects the "class" attribute to resolve to an existing class; received "%s"',
+ __METHOD__,
+ $class
+ ));
+ }
+
+ unset($options['class']);
+
+ if (isset($options['options'])) {
+ $options = $options['options'];
+ }
+ $captcha = new $class($options);
+
+ if (!$captcha instanceof AdapterInterface) {
+ throw new Exception\DomainException(sprintf(
+ '%s expects the "class" attribute to resolve to a valid Zend\Captcha\AdapterInterface instance; received "%s"',
+ __METHOD__,
+ $class
+ ));
+ }
+
+ return $captcha;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Captcha/Figlet.php zendframework-2.2.6/library/Zend/Captcha/Figlet.php
--- zendframework-1.10.4/library/Zend/Captcha/Figlet.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Captcha/Figlet.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,61 +1,49 @@
_figlet = new Zend_Text_Figlet($options);
+ $this->figlet = new FigletManager($options);
+ }
+
+ /**
+ * Retrieve the composed figlet manager
+ *
+ * @return FigletManager
+ */
+ public function getFiglet()
+ {
+ return $this->figlet;
}
/**
@@ -65,21 +53,17 @@
*/
public function generate()
{
- $this->_useNumbers = false;
+ $this->useNumbers = false;
return parent::generate();
}
/**
- * Display the captcha
+ * Get helper name used to render captcha
*
- * @param Zend_View_Interface $view
- * @param mixed $element
* @return string
*/
- public function render(Zend_View_Interface $view = null, $element = null)
+ public function getHelperName()
{
- return ''
- . $this->_figlet->render($this->getWord())
- . "
\n";
+ return 'captcha/figlet';
}
}
diff -Nru zendframework-1.10.4/library/Zend/Captcha/Image.php zendframework-2.2.6/library/Zend/Captcha/Image.php
--- zendframework-1.10.4/library/Zend/Captcha/Image.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Captcha/Image.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,96 +1,79 @@
_imgAlt;
+ return $this->imgAlt;
}
+
/**
* @return string
*/
- public function getStartImage ()
+ public function getStartImage()
{
- return $this->_startImage;
+ return $this->startImage;
}
+
/**
* @return int
*/
- public function getDotNoiseLevel ()
+ public function getDotNoiseLevel()
{
- return $this->_dotNoiseLevel;
+ return $this->dotNoiseLevel;
}
+
/**
* @return int
*/
- public function getLineNoiseLevel ()
+ public function getLineNoiseLevel()
{
- return $this->_lineNoiseLevel;
+ return $this->lineNoiseLevel;
}
+
/**
* Get captcha expiration
*
@@ -162,7 +175,7 @@
*/
public function getExpiration()
{
- return $this->_expiration;
+ return $this->expiration;
}
/**
@@ -172,8 +185,9 @@
*/
public function getGcFreq()
{
- return $this->_gcFreq;
+ return $this->gcFreq;
}
+
/**
* Get font to use when generating captcha
*
@@ -181,7 +195,7 @@
*/
public function getFont()
{
- return $this->_font;
+ return $this->font;
}
/**
@@ -191,7 +205,7 @@
*/
public function getFontSize()
{
- return $this->_fsize;
+ return $this->fsize;
}
/**
@@ -201,7 +215,7 @@
*/
public function getHeight()
{
- return $this->_height;
+ return $this->height;
}
/**
@@ -211,8 +225,9 @@
*/
public function getImgDir()
{
- return $this->_imgDir;
+ return $this->imgDir;
}
+
/**
* Get captcha image base URL
*
@@ -220,8 +235,9 @@
*/
public function getImgUrl()
{
- return $this->_imgUrl;
+ return $this->imgUrl;
}
+
/**
* Get captcha image file suffix
*
@@ -229,8 +245,9 @@
*/
public function getSuffix()
{
- return $this->_suffix;
+ return $this->suffix;
}
+
/**
* Get captcha image width
*
@@ -238,54 +255,60 @@
*/
public function getWidth()
{
- return $this->_width;
+ return $this->width;
}
+
/**
* @param string $startImage
+ * @return Image
*/
- public function setStartImage ($startImage)
+ public function setStartImage($startImage)
{
- $this->_startImage = $startImage;
+ $this->startImage = $startImage;
return $this;
}
+
/**
* @param int $dotNoiseLevel
+ * @return Image
*/
- public function setDotNoiseLevel ($dotNoiseLevel)
+ public function setDotNoiseLevel($dotNoiseLevel)
{
- $this->_dotNoiseLevel = $dotNoiseLevel;
+ $this->dotNoiseLevel = $dotNoiseLevel;
return $this;
}
- /**
+
+ /**
* @param int $lineNoiseLevel
+ * @return Image
*/
- public function setLineNoiseLevel ($lineNoiseLevel)
+ public function setLineNoiseLevel($lineNoiseLevel)
{
- $this->_lineNoiseLevel = $lineNoiseLevel;
+ $this->lineNoiseLevel = $lineNoiseLevel;
return $this;
}
/**
* Set captcha expiration
*
- * @param int $expiration
- * @return Zend_Captcha_Image
+ * @param int $expiration
+ * @return Image
*/
public function setExpiration($expiration)
{
- $this->_expiration = $expiration;
+ $this->expiration = $expiration;
return $this;
}
/**
* Set garbage collection frequency
*
- * @param int $gcFreq
- * @return Zend_Captcha_Image
+ * @param int $gcFreq
+ * @return Image
*/
public function setGcFreq($gcFreq)
{
- $this->_gcFreq = $gcFreq;
+ $this->gcFreq = $gcFreq;
return $this;
}
@@ -293,11 +316,11 @@
* Set captcha font
*
* @param string $font
- * @return Zend_Captcha_Image
+ * @return Image
*/
public function setFont($font)
{
- $this->_font = $font;
+ $this->font = $font;
return $this;
}
@@ -305,11 +328,11 @@
* Set captcha font size
*
* @param int $fsize
- * @return Zend_Captcha_Image
+ * @return Image
*/
public function setFontSize($fsize)
{
- $this->_fsize = $fsize;
+ $this->fsize = $fsize;
return $this;
}
@@ -317,11 +340,11 @@
* Set captcha image height
*
* @param int $height
- * @return Zend_Captcha_Image
+ * @return Image
*/
public function setHeight($height)
{
- $this->_height = $height;
+ $this->height = $height;
return $this;
}
@@ -329,11 +352,11 @@
* Set captcha image storage directory
*
* @param string $imgDir
- * @return Zend_Captcha_Image
+ * @return Image
*/
public function setImgDir($imgDir)
{
- $this->_imgDir = rtrim($imgDir, "/\\") . '/';
+ $this->imgDir = rtrim($imgDir, "/\\") . '/';
return $this;
}
@@ -341,31 +364,33 @@
* Set captcha image base URL
*
* @param string $imgUrl
- * @return Zend_Captcha_Image
+ * @return Image
*/
public function setImgUrl($imgUrl)
{
- $this->_imgUrl = rtrim($imgUrl, "/\\") . '/';
+ $this->imgUrl = rtrim($imgUrl, "/\\") . '/';
return $this;
}
+
/**
* @param string $imgAlt
+ * @return Image
*/
- public function setImgAlt ($imgAlt)
+ public function setImgAlt($imgAlt)
{
- $this->_imgAlt = $imgAlt;
+ $this->imgAlt = $imgAlt;
return $this;
}
/**
- * Set captch image filename suffix
+ * Set captcha image filename suffix
*
* @param string $suffix
- * @return Zend_Captcha_Image
+ * @return Image
*/
public function setSuffix($suffix)
{
- $this->_suffix = $suffix;
+ $this->suffix = $suffix;
return $this;
}
@@ -373,11 +398,11 @@
* Set captcha image width
*
* @param int $width
- * @return Zend_Captcha_Image
+ * @return Image
*/
public function setWidth($width)
{
- $this->_width = $width;
+ $this->width = $width;
return $this;
}
@@ -386,7 +411,7 @@
*
* @return float
*/
- protected function _randomFreq()
+ protected function randomFreq()
{
return mt_rand(700000, 1000000) / 15000000;
}
@@ -396,7 +421,7 @@
*
* @return float
*/
- protected function _randomPhase()
+ protected function randomPhase()
{
// random phase from 0 to pi
return mt_rand(0, 3141592) / 1000000;
@@ -407,7 +432,7 @@
*
* @return int
*/
- protected function _randomSize()
+ protected function randomSize()
{
return mt_rand(300, 700) / 100;
}
@@ -419,18 +444,20 @@
*/
public function generate()
{
- $id = parent::generate();
+ $id = parent::generate();
$tries = 5;
+
// If there's already such file, try creating a new ID
- while($tries-- && file_exists($this->getImgDir() . $id . $this->getSuffix())) {
- $id = $this->_generateRandomId();
- $this->_setId($id);
+ while ($tries-- && file_exists($this->getImgDir() . $id . $this->getSuffix())) {
+ $id = $this->generateRandomId();
+ $this->setId($id);
}
- $this->_generateImage($id, $this->getWord());
+ $this->generateImage($id, $this->getWord());
if (mt_rand(1, $this->getGcFreq()) == 1) {
- $this->_gc();
+ $this->gc();
}
+
return $id;
}
@@ -442,80 +469,73 @@
*
* @param string $id Captcha ID
* @param string $word Captcha word
+ * @throws Exception\NoFontProvidedException if no font was set
+ * @throws Exception\ImageNotLoadableException if start image cannot be loaded
*/
- protected function _generateImage($id, $word)
+ protected function generateImage($id, $word)
{
- if (!extension_loaded("gd")) {
- require_once 'Zend/Captcha/Exception.php';
- throw new Zend_Captcha_Exception("Image CAPTCHA requires GD extension");
- }
-
- if (!function_exists("imagepng")) {
- require_once 'Zend/Captcha/Exception.php';
- throw new Zend_Captcha_Exception("Image CAPTCHA requires PNG support");
- }
-
- if (!function_exists("imageftbbox")) {
- require_once 'Zend/Captcha/Exception.php';
- throw new Zend_Captcha_Exception("Image CAPTCHA requires FT fonts support");
- }
-
$font = $this->getFont();
if (empty($font)) {
- require_once 'Zend/Captcha/Exception.php';
- throw new Zend_Captcha_Exception("Image CAPTCHA requires font");
+ throw new Exception\NoFontProvidedException('Image CAPTCHA requires font');
}
$w = $this->getWidth();
$h = $this->getHeight();
$fsize = $this->getFontSize();
- $img_file = $this->getImgDir() . $id . $this->getSuffix();
- if(empty($this->_startImage)) {
- $img = imagecreatetruecolor($w, $h);
+ $imgFile = $this->getImgDir() . $id . $this->getSuffix();
+
+ if (empty($this->startImage)) {
+ $img = imagecreatetruecolor($w, $h);
} else {
- $img = imagecreatefrompng($this->_startImage);
- if(!$img) {
- require_once 'Zend/Captcha/Exception.php';
- throw new Zend_Captcha_Exception("Can not load start image");
+ // Potential error is change to exception
+ ErrorHandler::start();
+ $img = imagecreatefrompng($this->startImage);
+ $error = ErrorHandler::stop();
+ if (!$img || $error) {
+ throw new Exception\ImageNotLoadableException(
+ "Can not load start image '{$this->startImage}'", 0, $error
+ );
}
$w = imagesx($img);
$h = imagesy($img);
}
- $text_color = imagecolorallocate($img, 0, 0, 0);
- $bg_color = imagecolorallocate($img, 255, 255, 255);
- imagefilledrectangle($img, 0, 0, $w-1, $h-1, $bg_color);
+
+ $textColor = imagecolorallocate($img, 0, 0, 0);
+ $bgColor = imagecolorallocate($img, 255, 255, 255);
+ imagefilledrectangle($img, 0, 0, $w-1, $h-1, $bgColor);
$textbox = imageftbbox($fsize, 0, $font, $word);
$x = ($w - ($textbox[2] - $textbox[0])) / 2;
$y = ($h - ($textbox[7] - $textbox[1])) / 2;
- imagefttext($img, $fsize, 0, $x, $y, $text_color, $font, $word);
+ imagefttext($img, $fsize, 0, $x, $y, $textColor, $font, $word);
- // generate noise
- for ($i=0; $i<$this->_dotNoiseLevel; $i++) {
- imagefilledellipse($img, mt_rand(0,$w), mt_rand(0,$h), 2, 2, $text_color);
+ // generate noise
+ for ($i=0; $i < $this->dotNoiseLevel; $i++) {
+ imagefilledellipse($img, mt_rand(0, $w), mt_rand(0, $h), 2, 2, $textColor);
}
- for($i=0; $i<$this->_lineNoiseLevel; $i++) {
- imageline($img, mt_rand(0,$w), mt_rand(0,$h), mt_rand(0,$w), mt_rand(0,$h), $text_color);
+ for ($i=0; $i < $this->lineNoiseLevel; $i++) {
+ imageline($img, mt_rand(0, $w), mt_rand(0, $h), mt_rand(0, $w), mt_rand(0, $h), $textColor);
}
// transformed image
$img2 = imagecreatetruecolor($w, $h);
- $bg_color = imagecolorallocate($img2, 255, 255, 255);
- imagefilledrectangle($img2, 0, 0, $w-1, $h-1, $bg_color);
+ $bgColor = imagecolorallocate($img2, 255, 255, 255);
+ imagefilledrectangle($img2, 0, 0, $w-1, $h-1, $bgColor);
+
// apply wave transforms
- $freq1 = $this->_randomFreq();
- $freq2 = $this->_randomFreq();
- $freq3 = $this->_randomFreq();
- $freq4 = $this->_randomFreq();
-
- $ph1 = $this->_randomPhase();
- $ph2 = $this->_randomPhase();
- $ph3 = $this->_randomPhase();
- $ph4 = $this->_randomPhase();
+ $freq1 = $this->randomFreq();
+ $freq2 = $this->randomFreq();
+ $freq3 = $this->randomFreq();
+ $freq4 = $this->randomFreq();
+
+ $ph1 = $this->randomPhase();
+ $ph2 = $this->randomPhase();
+ $ph3 = $this->randomPhase();
+ $ph4 = $this->randomPhase();
- $szx = $this->_randomSize();
- $szy = $this->_randomSize();
+ $szx = $this->randomSize();
+ $szy = $this->randomSize();
for ($x = 0; $x < $w; $x++) {
for ($y = 0; $y < $h; $y++) {
@@ -525,42 +545,45 @@
if ($sx < 0 || $sy < 0 || $sx >= $w - 1 || $sy >= $h - 1) {
continue;
} else {
- $color = (imagecolorat($img, $sx, $sy) >> 16) & 0xFF;
- $color_x = (imagecolorat($img, $sx + 1, $sy) >> 16) & 0xFF;
- $color_y = (imagecolorat($img, $sx, $sy + 1) >> 16) & 0xFF;
- $color_xy = (imagecolorat($img, $sx + 1, $sy + 1) >> 16) & 0xFF;
+ $color = (imagecolorat($img, $sx, $sy) >> 16) & 0xFF;
+ $colorX = (imagecolorat($img, $sx + 1, $sy) >> 16) & 0xFF;
+ $colorY = (imagecolorat($img, $sx, $sy + 1) >> 16) & 0xFF;
+ $colorXY = (imagecolorat($img, $sx + 1, $sy + 1) >> 16) & 0xFF;
}
- if ($color == 255 && $color_x == 255 && $color_y == 255 && $color_xy == 255) {
+
+ if ($color == 255 && $colorX == 255 && $colorY == 255 && $colorXY == 255) {
// ignore background
continue;
- } elseif ($color == 0 && $color_x == 0 && $color_y == 0 && $color_xy == 0) {
+ } elseif ($color == 0 && $colorX == 0 && $colorY == 0 && $colorXY == 0) {
// transfer inside of the image as-is
$newcolor = 0;
} else {
// do antialiasing for border items
- $frac_x = $sx-floor($sx);
- $frac_y = $sy-floor($sy);
- $frac_x1 = 1-$frac_x;
- $frac_y1 = 1-$frac_y;
-
- $newcolor = $color * $frac_x1 * $frac_y1
- + $color_x * $frac_x * $frac_y1
- + $color_y * $frac_x1 * $frac_y
- + $color_xy * $frac_x * $frac_y;
+ $fracX = $sx - floor($sx);
+ $fracY = $sy - floor($sy);
+ $fracX1 = 1 - $fracX;
+ $fracY1 = 1 - $fracY;
+
+ $newcolor = $color * $fracX1 * $fracY1
+ + $colorX * $fracX * $fracY1
+ + $colorY * $fracX1 * $fracY
+ + $colorXY * $fracX * $fracY;
}
+
imagesetpixel($img2, $x, $y, imagecolorallocate($img2, $newcolor, $newcolor, $newcolor));
}
}
// generate noise
- for ($i=0; $i<$this->_dotNoiseLevel; $i++) {
- imagefilledellipse($img2, mt_rand(0,$w), mt_rand(0,$h), 2, 2, $text_color);
+ for ($i=0; $i<$this->dotNoiseLevel; $i++) {
+ imagefilledellipse($img2, mt_rand(0, $w), mt_rand(0, $h), 2, 2, $textColor);
}
- for ($i=0; $i<$this->_lineNoiseLevel; $i++) {
- imageline($img2, mt_rand(0,$w), mt_rand(0,$h), mt_rand(0,$w), mt_rand(0,$h), $text_color);
+
+ for ($i=0; $i<$this->lineNoiseLevel; $i++) {
+ imageline($img2, mt_rand(0, $w), mt_rand(0, $h), mt_rand(0, $w), mt_rand(0, $h), $textColor);
}
- imagepng($img2, $img_file);
+ imagepng($img2, $imgFile);
imagedestroy($img);
imagedestroy($img2);
}
@@ -569,32 +592,35 @@
* Remove old files from image directory
*
*/
- protected function _gc()
+ protected function gc()
{
$expire = time() - $this->getExpiration();
$imgdir = $this->getImgDir();
- if(!$imgdir || strlen($imgdir) < 2) {
+ if (!$imgdir || strlen($imgdir) < 2) {
// safety guard
return;
}
+
+ $suffixLength = strlen($this->suffix);
foreach (new DirectoryIterator($imgdir) as $file) {
if (!$file->isDot() && !$file->isDir()) {
- if ($file->getMTime() < $expire) {
- unlink($file->getPathname());
+ if (file_exists($file->getPathname()) && $file->getMTime() < $expire) {
+ // only deletes files ending with $this->suffix
+ if (substr($file->getFilename(), -($suffixLength)) == $this->suffix) {
+ unlink($file->getPathname());
+ }
}
}
}
}
/**
- * Display the captcha
+ * Get helper name used to render captcha
*
- * @param Zend_View_Interface $view
- * @param mixed $element
* @return string
*/
- public function render(Zend_View_Interface $view = null, $element = null)
+ public function getHelperName()
{
- return '
';
+ return 'captcha/image';
}
}
diff -Nru zendframework-1.10.4/library/Zend/Captcha/README.md zendframework-2.2.6/library/Zend/Captcha/README.md
--- zendframework-1.10.4/library/Zend/Captcha/README.md 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Captcha/README.md 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,15 @@
+Captcha Component from ZF2
+==========================
+
+This is the Captcha component for ZF2.
+
+- File issues at https://github.com/zendframework/zf2/issues
+- Create pull requests against https://github.com/zendframework/zf2
+- Documentation is at http://framework.zend.com/docs
+
+LICENSE
+-------
+
+The files in this archive are released under the [Zend Framework
+license](http://framework.zend.com/license), which is a 3-clause BSD license.
+
diff -Nru zendframework-1.10.4/library/Zend/Captcha/ReCaptcha.php zendframework-2.2.6/library/Zend/Captcha/ReCaptcha.php
--- zendframework-1.10.4/library/Zend/Captcha/ReCaptcha.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Captcha/ReCaptcha.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,29 +1,16 @@
'Missing captcha fields',
self::ERR_CAPTCHA => 'Failed to validate captcha',
self::BAD_CAPTCHA => 'Captcha value is wrong: %value%',
@@ -111,8 +91,8 @@
/**
* Set ReCaptcha Private key
*
- * @param string $privkey
- * @return Zend_Captcha_ReCaptcha
+ * @param string $privkey
+ * @return ReCaptcha
*/
public function setPrivkey($privkey)
{
@@ -123,8 +103,8 @@
/**
* Set ReCaptcha public key
*
- * @param string $pubkey
- * @return Zend_Captcha_ReCaptcha
+ * @param string $pubkey
+ * @return ReCaptcha
*/
public function setPubkey($pubkey)
{
@@ -135,21 +115,23 @@
/**
* Constructor
*
- * @param array|Zend_Config $options
- * @return void
+ * @param null|array|Traversable $options
*/
public function __construct($options = null)
{
- $this->setService(new Zend_Service_ReCaptcha());
- $this->_serviceParams = $this->getService()->getParams();
- $this->_serviceOptions = $this->getService()->getOptions();
+ $this->setService(new ReCaptchaService());
+ $this->serviceParams = $this->getService()->getParams();
+ $this->serviceOptions = $this->getService()->getOptions();
parent::__construct($options);
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- }
if (!empty($options)) {
+ if (array_key_exists('private_key', $options)) {
+ $this->getService()->setPrivateKey($options['private_key']);
+ }
+ if (array_key_exists('public_key', $options)) {
+ $this->getService()->setPublicKey($options['public_key']);
+ }
$this->setOptions($options);
}
}
@@ -157,23 +139,23 @@
/**
* Set service object
*
- * @param Zend_Service_ReCaptcha $service
- * @return Zend_Captcha_ReCaptcha
+ * @param ReCaptchaService $service
+ * @return ReCaptcha
*/
- public function setService(Zend_Service_ReCaptcha $service)
+ public function setService(ReCaptchaService $service)
{
- $this->_service = $service;
+ $this->service = $service;
return $this;
}
/**
* Retrieve ReCaptcha service object
*
- * @return Zend_Service_ReCaptcha
+ * @return ReCaptchaService
*/
public function getService()
{
- return $this->_service;
+ return $this->service;
}
/**
@@ -184,16 +166,16 @@
*
* @param string $key
* @param mixed $value
- * @return Zend_Captcha_ReCaptcha
+ * @return ReCaptcha
*/
public function setOption($key, $value)
{
$service = $this->getService();
- if (isset($this->_serviceParams[$key])) {
+ if (isset($this->serviceParams[$key])) {
$service->setParam($key, $value);
return $this;
}
- if (isset($this->_serviceOptions[$key])) {
+ if (isset($this->serviceOptions[$key])) {
$service->setOption($key, $value);
return $this;
}
@@ -203,7 +185,7 @@
/**
* Generate captcha
*
- * @see Zend_Form_Captcha_Adapter::generate()
+ * @see AbstractAdapter::generate()
* @return string
*/
public function generate()
@@ -214,14 +196,15 @@
/**
* Validate captcha
*
- * @see Zend_Validate_Interface::isValid()
+ * @see \Zend\Validator\ValidatorInterface::isValid()
* @param mixed $value
- * @return boolean
+ * @param mixed $context
+ * @return bool
*/
public function isValid($value, $context = null)
{
if (!is_array($value) && !is_array($context)) {
- $this->_error(self::MISSING_VALUE);
+ $this->error(self::MISSING_VALUE);
return false;
}
@@ -229,22 +212,22 @@
$value = $context;
}
- if (empty($value[$this->_CHALLENGE]) || empty($value[$this->_RESPONSE])) {
- $this->_error(self::MISSING_VALUE);
+ if (empty($value[$this->CHALLENGE]) || empty($value[$this->RESPONSE])) {
+ $this->error(self::MISSING_VALUE);
return false;
}
$service = $this->getService();
- $res = $service->verify($value[$this->_CHALLENGE], $value[$this->_RESPONSE]);
+ $res = $service->verify($value[$this->CHALLENGE], $value[$this->RESPONSE]);
if (!$res) {
- $this->_error(self::ERR_CAPTCHA);
+ $this->error(self::ERR_CAPTCHA);
return false;
}
if (!$res->isValid()) {
- $this->_error(self::BAD_CAPTCHA, $res->getErrorCode());
+ $this->error(self::BAD_CAPTCHA, $res->getErrorCode());
$service->setParam('error', $res->getErrorCode());
return false;
}
@@ -253,14 +236,12 @@
}
/**
- * Render captcha
+ * Get helper name used to render captcha
*
- * @param Zend_View_Interface $view
- * @param mixed $element
* @return string
*/
- public function render(Zend_View_Interface $view = null, $element = null)
+ public function getHelperName()
{
- return $this->getService()->getHTML();
+ return "captcha/recaptcha";
}
}
diff -Nru zendframework-1.10.4/library/Zend/Captcha/Word.php zendframework-2.2.6/library/Zend/Captcha/Word.php
--- zendframework-1.10.4/library/Zend/Captcha/Word.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Captcha/Word.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,396 +0,0 @@
- 'Empty captcha value',
- self::MISSING_ID => 'Captcha ID field is missing',
- self::BAD_CAPTCHA => 'Captcha value is wrong',
- );
-
- /**
- * Length of the word to generate
- *
- * @var integer
- */
- protected $_wordlen = 8;
-
- /**
- * Retrieve session class to utilize
- *
- * @return string
- */
- public function getSessionClass()
- {
- return $this->_sessionClass;
- }
-
- /**
- * Set session class for persistence
- *
- * @param string $_sessionClass
- * @return Zend_Captcha_Word
- */
- public function setSessionClass($_sessionClass)
- {
- $this->_sessionClass = $_sessionClass;
- return $this;
- }
-
- /**
- * Retrieve word length to use when genrating captcha
- *
- * @return integer
- */
- public function getWordlen()
- {
- return $this->_wordlen;
- }
-
- /**
- * Set word length of captcha
- *
- * @param integer $wordlen
- * @return Zend_Captcha_Word
- */
- public function setWordlen($wordlen)
- {
- $this->_wordlen = $wordlen;
- return $this;
- }
-
- /**
- * Retrieve captcha ID
- *
- * @return string
- */
- public function getId ()
- {
- if (null === $this->_id) {
- $this->_setId($this->_generateRandomId());
- }
- return $this->_id;
- }
-
- /**
- * Set captcha identifier
- *
- * @param string $id
- * return Zend_Captcha_Word
- */
- protected function _setId ($id)
- {
- $this->_id = $id;
- return $this;
- }
-
- /**
- * Set timeout for session token
- *
- * @param int $ttl
- * @return Zend_Captcha_Word
- */
- public function setTimeout($ttl)
- {
- $this->_timeout = (int) $ttl;
- return $this;
- }
-
- /**
- * Get session token timeout
- *
- * @return int
- */
- public function getTimeout()
- {
- return $this->_timeout;
- }
-
- /**
- * Sets if session should be preserved on generate()
- *
- * @param $keepSession Should session be kept on generate()?
- * @return Zend_Captcha_Word
- */
- public function setKeepSession($keepSession)
- {
- $this->_keepSession = $keepSession;
- return $this;
- }
-
- /**
- * Get session object
- *
- * @return Zend_Session_Namespace
- */
- public function getSession()
- {
- if (!isset($this->_session) || (null === $this->_session)) {
- $id = $this->getId();
- if (!class_exists($this->_sessionClass)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($this->_sessionClass);
- }
- $this->_session = new $this->_sessionClass('Zend_Form_Captcha_' . $id);
- $this->_session->setExpirationHops(1, null, true);
- $this->_session->setExpirationSeconds($this->getTimeout());
- }
- return $this->_session;
- }
-
- /**
- * Set session namespace object
- *
- * @param Zend_Session_Namespace $session
- * @return Zend_Captcha_Word
- */
- public function setSession(Zend_Session_Namespace $session)
- {
- $this->_session = $session;
- if($session) {
- $this->_keepSession = true;
- }
- return $this;
- }
-
- /**
- * Get captcha word
- *
- * @return string
- */
- public function getWord()
- {
- if (empty($this->_word)) {
- $session = $this->getSession();
- $this->_word = $session->word;
- }
- return $this->_word;
- }
-
- /**
- * Set captcha word
- *
- * @param string $word
- * @return Zend_Captcha_Word
- */
- protected function _setWord($word)
- {
- $session = $this->getSession();
- $session->word = $word;
- $this->_word = $word;
- return $this;
- }
-
- /**
- * Generate new random word
- *
- * @return string
- */
- protected function _generateWord()
- {
- $word = '';
- $wordLen = $this->getWordLen();
- $vowels = $this->_useNumbers ? self::$VN : self::$V;
- $consonants = $this->_useNumbers ? self::$CN : self::$C;
-
- for ($i=0; $i < $wordLen; $i = $i + 2) {
- // generate word with mix of vowels and consonants
- $consonant = $consonants[array_rand($consonants)];
- $vowel = $vowels[array_rand($vowels)];
- $word .= $consonant . $vowel;
- }
-
- if (strlen($word) > $wordLen) {
- $word = substr($word, 0, $wordLen);
- }
-
- return $word;
- }
-
- /**
- * Generate new session ID and new word
- *
- * @return string session ID
- */
- public function generate()
- {
- if(!$this->_keepSession) {
- $this->_session = null;
- }
- $id = $this->_generateRandomId();
- $this->_setId($id);
- $word = $this->_generateWord();
- $this->_setWord($word);
- return $id;
- }
-
- protected function _generateRandomId()
- {
- return md5(mt_rand(0, 1000) . microtime(true));
- }
-
- /**
- * Validate the word
- *
- * @see Zend_Validate_Interface::isValid()
- * @param mixed $value
- * @return boolean
- */
- public function isValid($value, $context = null)
- {
- if (!is_array($value) && !is_array($context)) {
- $this->_error(self::MISSING_VALUE);
- return false;
- }
- if (!is_array($value) && is_array($context)) {
- $value = $context;
- }
-
- $name = $this->getName();
-
- if (isset($value[$name])) {
- $value = $value[$name];
- }
-
- if (!isset($value['input'])) {
- $this->_error(self::MISSING_VALUE);
- return false;
- }
- $input = strtolower($value['input']);
- $this->_setValue($input);
-
- if (!isset($value['id'])) {
- $this->_error(self::MISSING_ID);
- return false;
- }
-
- $this->_id = $value['id'];
- if ($input !== $this->getWord()) {
- $this->_error(self::BAD_CAPTCHA);
- return false;
- }
-
- return true;
- }
-
- /**
- * Get captcha decorator
- *
- * @return string
- */
- public function getDecorator()
- {
- return "Captcha_Word";
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Code/Annotation/AnnotationCollection.php zendframework-2.2.6/library/Zend/Code/Annotation/AnnotationCollection.php
--- zendframework-1.10.4/library/Zend/Code/Annotation/AnnotationCollection.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Annotation/AnnotationCollection.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,32 @@
+setIdentifiers(array(
+ __CLASS__,
+ get_class($this),
+ ));
+ $this->events = $events;
+
+ return $this;
+ }
+
+ /**
+ * Retrieve event manager
+ *
+ * Lazy loads an instance if none registered.
+ *
+ * @return EventManagerInterface
+ */
+ public function getEventManager()
+ {
+ if (null === $this->events) {
+ $this->setEventManager(new EventManager());
+ }
+
+ return $this->events;
+ }
+
+ /**
+ * Attach a parser to listen to the createAnnotation event
+ *
+ * @param ParserInterface $parser
+ * @return AnnotationManager
+ */
+ public function attach(ParserInterface $parser)
+ {
+ $this->getEventManager()
+ ->attach(self::EVENT_CREATE_ANNOTATION, array($parser, 'onCreateAnnotation'));
+
+ return $this;
+ }
+
+ /**
+ * Create Annotation
+ *
+ * @param array $annotationData
+ * @return false|\stdClass
+ */
+ public function createAnnotation(array $annotationData)
+ {
+ $event = new Event();
+ $event->setName(self::EVENT_CREATE_ANNOTATION);
+ $event->setTarget($this);
+ $event->setParams(array(
+ 'class' => $annotationData[0],
+ 'content' => $annotationData[1],
+ 'raw' => $annotationData[2],
+ ));
+
+ $eventManager = $this->getEventManager();
+ $results = $eventManager->trigger($event, function ($r) {
+ return (is_object($r));
+ });
+
+ $annotation = $results->last();
+
+ return (is_object($annotation) ? $annotation : false);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Annotation/Parser/DoctrineAnnotationParser.php zendframework-2.2.6/library/Zend/Code/Annotation/Parser/DoctrineAnnotationParser.php
--- zendframework-1.10.4/library/Zend/Code/Annotation/Parser/DoctrineAnnotationParser.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Annotation/Parser/DoctrineAnnotationParser.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,153 @@
+docParser = $docParser;
+ return $this;
+ }
+
+ /**
+ * Retrieve the DocParser instance
+ *
+ * If none is registered, lazy-loads a new instance.
+ *
+ * @return DocParser
+ */
+ public function getDocParser()
+ {
+ if (!$this->docParser instanceof DocParser) {
+ $this->setDocParser(new DocParser());
+ }
+
+ return $this->docParser;
+ }
+
+ /**
+ * Handle annotation creation
+ *
+ * @param EventInterface $e
+ * @return false|\stdClass
+ */
+ public function onCreateAnnotation(EventInterface $e)
+ {
+ $annotationClass = $e->getParam('class', false);
+ if (!$annotationClass) {
+ return false;
+ }
+
+ if (!isset($this->allowedAnnotations[$annotationClass])) {
+ return false;
+ }
+
+ $annotationString = $e->getParam('raw', false);
+ if (!$annotationString) {
+ return false;
+ }
+
+ // Annotation classes provided by the AnnotationScanner are already
+ // resolved to fully-qualified class names. Adding the global namespace
+ // prefix allows the Doctrine annotation parser to locate the annotation
+ // class correctly.
+ $annotationString = preg_replace('/^(@)/', '$1\\', $annotationString);
+
+ $parser = $this->getDocParser();
+ $annotations = $parser->parse($annotationString);
+ if (empty($annotations)) {
+ return false;
+ }
+
+ $annotation = array_shift($annotations);
+ if (!is_object($annotation)) {
+ return false;
+ }
+
+ return $annotation;
+ }
+
+ /**
+ * Specify an allowed annotation class
+ *
+ * @param string $annotation
+ * @return DoctrineAnnotationParser
+ */
+ public function registerAnnotation($annotation)
+ {
+ $this->allowedAnnotations[$annotation] = true;
+ return $this;
+ }
+
+ /**
+ * Set many allowed annotations at once
+ *
+ * @param array|Traversable $annotations Array or traversable object of
+ * annotation class names
+ * @throws Exception\InvalidArgumentException
+ * @return DoctrineAnnotationParser
+ */
+ public function registerAnnotations($annotations)
+ {
+ if (!is_array($annotations) && !$annotations instanceof Traversable) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s: expects an array or Traversable; received "%s"',
+ __METHOD__,
+ (is_object($annotations) ? get_class($annotations) : gettype($annotations))
+ ));
+ }
+
+ foreach ($annotations as $annotation) {
+ $this->allowedAnnotations[$annotation] = true;
+ }
+
+ return $this;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Annotation/Parser/GenericAnnotationParser.php zendframework-2.2.6/library/Zend/Code/Annotation/Parser/GenericAnnotationParser.php
--- zendframework-1.10.4/library/Zend/Code/Annotation/Parser/GenericAnnotationParser.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Annotation/Parser/GenericAnnotationParser.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,224 @@
+getParam('class', false);
+ if (!$class || !$this->hasAnnotation($class)) {
+ return false;
+ }
+
+ $content = $e->getParam('content', '');
+ $content = trim($content, '()');
+
+ if ($this->hasAlias($class)) {
+ $class = $this->resolveAlias($class);
+ }
+
+ $index = array_search($class, $this->annotationNames);
+ $annotation = $this->annotations[$index];
+
+ $newAnnotation = clone $annotation;
+ if ($content) {
+ $newAnnotation->initialize($content);
+ }
+
+ return $newAnnotation;
+ }
+
+ /**
+ * Register annotations
+ *
+ * @param string|AnnotationInterface $annotation String class name of an
+ * AnnotationInterface implementation, or actual instance
+ * @return GenericAnnotationParser
+ * @throws Exception\InvalidArgumentException
+ */
+ public function registerAnnotation($annotation)
+ {
+ $class = false;
+ if (is_string($annotation) && class_exists($annotation)) {
+ $class = $annotation;
+ $annotation = new $annotation();
+ }
+
+ if (!$annotation instanceof AnnotationInterface) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s: expects an instance of %s\AnnotationInterface; received "%s"',
+ __METHOD__,
+ __NAMESPACE__,
+ (is_object($annotation) ? get_class($annotation) : gettype($annotation))
+ ));
+ }
+
+ $class = $class ?: get_class($annotation);
+
+ if (in_array($class, $this->annotationNames)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'An annotation for this class %s already exists',
+ $class
+ ));
+ }
+
+ $this->annotations[] = $annotation;
+ $this->annotationNames[] = $class;
+ }
+
+ /**
+ * Register many annotations at once
+ *
+ * @param array|Traversable $annotations
+ * @throws Exception\InvalidArgumentException
+ * @return GenericAnnotationParser
+ */
+ public function registerAnnotations($annotations)
+ {
+ if (!is_array($annotations) && !$annotations instanceof Traversable) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s: expects an array or Traversable; received "%s"',
+ __METHOD__,
+ (is_object($annotations) ? get_class($annotations) : gettype($annotations))
+ ));
+ }
+
+ foreach ($annotations as $annotation) {
+ $this->registerAnnotation($annotation);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Checks if the manager has annotations for a class
+ *
+ * @param string $class
+ * @return bool
+ */
+ public function hasAnnotation($class)
+ {
+ if (in_array($class, $this->annotationNames)) {
+ return true;
+ }
+
+ if ($this->hasAlias($class)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Alias an annotation name
+ *
+ * @param string $alias
+ * @param string $class May be either a registered annotation name or another alias
+ * @throws Exception\InvalidArgumentException
+ * @return GenericAnnotationParser
+ */
+ public function setAlias($alias, $class)
+ {
+ if (!in_array($class, $this->annotationNames) && !$this->hasAlias($class)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s: Cannot alias "%s" to "%s", as class "%s" is not currently a registered annotation or alias',
+ __METHOD__,
+ $alias,
+ $class,
+ $class
+ ));
+ }
+
+ $alias = $this->normalizeAlias($alias);
+ $this->aliases[$alias] = $class;
+
+ return $this;
+ }
+
+ /**
+ * Normalize an alias name
+ *
+ * @param string $alias
+ * @return string
+ */
+ protected function normalizeAlias($alias)
+ {
+ return strtolower(str_replace(array('-', '_', ' ', '\\', '/'), '', $alias));
+ }
+
+ /**
+ * Do we have an alias by the provided name?
+ *
+ * @param string $alias
+ * @return bool
+ */
+ protected function hasAlias($alias)
+ {
+ $alias = $this->normalizeAlias($alias);
+
+ return (isset($this->aliases[$alias]));
+ }
+
+ /**
+ * Resolve an alias to a class name
+ *
+ * @param string $alias
+ * @return string
+ */
+ protected function resolveAlias($alias)
+ {
+ do {
+ $normalized = $this->normalizeAlias($alias);
+ $class = $this->aliases[$normalized];
+ } while ($this->hasAlias($class));
+
+ return $class;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Annotation/Parser/ParserInterface.php zendframework-2.2.6/library/Zend/Code/Annotation/Parser/ParserInterface.php
--- zendframework-1.10.4/library/Zend/Code/Annotation/Parser/ParserInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Annotation/Parser/ParserInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,39 @@
+=5.3.3",
+ "zendframework/zend-eventmanager": "self.version"
+ },
+ "require-dev": {
+ "doctrine/common": ">=2.1"
+ },
+ "suggest": {
+ "doctrine/common": "Doctrine\\Common >=2.1 for annotation features"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev",
+ "dev-develop": "2.3-dev"
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Exception/BadMethodCallException.php zendframework-2.2.6/library/Zend/Code/Exception/BadMethodCallException.php
--- zendframework-1.10.4/library/Zend/Code/Exception/BadMethodCallException.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Exception/BadMethodCallException.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,14 @@
+setOptions($options);
+ }
+ }
+
+ /**
+ * @param bool $isSourceDirty
+ * @return AbstractGenerator
+ */
+ public function setSourceDirty($isSourceDirty = true)
+ {
+ $this->isSourceDirty = (bool) $isSourceDirty;
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isSourceDirty()
+ {
+ return $this->isSourceDirty;
+ }
+
+ /**
+ * @param string $indentation
+ * @return AbstractGenerator
+ */
+ public function setIndentation($indentation)
+ {
+ $this->indentation = (string) $indentation;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getIndentation()
+ {
+ return $this->indentation;
+ }
+
+ /**
+ * @param string $sourceContent
+ * @return AbstractGenerator
+ */
+ public function setSourceContent($sourceContent)
+ {
+ $this->sourceContent = (string) $sourceContent;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getSourceContent()
+ {
+ return $this->sourceContent;
+ }
+
+ /**
+ * @param array|Traversable $options
+ * @throws Exception\InvalidArgumentException
+ * @return AbstractGenerator
+ */
+ public function setOptions($options)
+ {
+ if (!is_array($options) && !$options instanceof Traversable) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s expects an array or Traversable object; received "%s"',
+ __METHOD__,
+ (is_object($options) ? get_class($options) : gettype($options))
+ ));
+ }
+
+ foreach ($options as $optionName => $optionValue) {
+ $methodName = 'set' . $optionName;
+ if (method_exists($this, $methodName)) {
+ $this->{$methodName}($optionValue);
+ }
+ }
+
+ return $this;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/AbstractMemberGenerator.php zendframework-2.2.6/library/Zend/Code/Generator/AbstractMemberGenerator.php
--- zendframework-1.10.4/library/Zend/Code/Generator/AbstractMemberGenerator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/AbstractMemberGenerator.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,225 @@
+flags = $flags;
+
+ return $this;
+ }
+
+ /**
+ * @param int $flag
+ * @return AbstractMemberGenerator
+ */
+ public function addFlag($flag)
+ {
+ $this->setFlags($this->flags | $flag);
+ return $this;
+ }
+
+ /**
+ * @param int $flag
+ * @return AbstractMemberGenerator
+ */
+ public function removeFlag($flag)
+ {
+ $this->setFlags($this->flags & ~$flag);
+ return $this;
+ }
+
+ /**
+ * @param bool $isAbstract
+ * @return AbstractMemberGenerator
+ */
+ public function setAbstract($isAbstract)
+ {
+ return (($isAbstract) ? $this->addFlag(self::FLAG_ABSTRACT) : $this->removeFlag(self::FLAG_ABSTRACT));
+ }
+
+ /**
+ * @return bool
+ */
+ public function isAbstract()
+ {
+ return (bool) ($this->flags & self::FLAG_ABSTRACT);
+ }
+
+ /**
+ * @param bool $isFinal
+ * @return AbstractMemberGenerator
+ */
+ public function setFinal($isFinal)
+ {
+ return (($isFinal) ? $this->addFlag(self::FLAG_FINAL) : $this->removeFlag(self::FLAG_FINAL));
+ }
+
+ /**
+ * @return bool
+ */
+ public function isFinal()
+ {
+ return (bool) ($this->flags & self::FLAG_FINAL);
+ }
+
+ /**
+ * @param bool $isStatic
+ * @return AbstractMemberGenerator
+ */
+ public function setStatic($isStatic)
+ {
+ return (($isStatic) ? $this->addFlag(self::FLAG_STATIC) : $this->removeFlag(self::FLAG_STATIC));
+ }
+
+ /**
+ * @return bool
+ */
+ public function isStatic()
+ {
+ return (bool) ($this->flags & self::FLAG_STATIC); // is FLAG_STATIC in flags
+ }
+
+ /**
+ * @param string $visibility
+ * @return AbstractMemberGenerator
+ */
+ public function setVisibility($visibility)
+ {
+ switch ($visibility) {
+ case self::VISIBILITY_PUBLIC:
+ $this->removeFlag(self::FLAG_PRIVATE | self::FLAG_PROTECTED); // remove both
+ $this->addFlag(self::FLAG_PUBLIC);
+ break;
+ case self::VISIBILITY_PROTECTED:
+ $this->removeFlag(self::FLAG_PUBLIC | self::FLAG_PRIVATE); // remove both
+ $this->addFlag(self::FLAG_PROTECTED);
+ break;
+ case self::VISIBILITY_PRIVATE:
+ $this->removeFlag(self::FLAG_PUBLIC | self::FLAG_PROTECTED); // remove both
+ $this->addFlag(self::FLAG_PRIVATE);
+ break;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getVisibility()
+ {
+ switch (true) {
+ case ($this->flags & self::FLAG_PROTECTED):
+ return self::VISIBILITY_PROTECTED;
+ case ($this->flags & self::FLAG_PRIVATE):
+ return self::VISIBILITY_PRIVATE;
+ default:
+ return self::VISIBILITY_PUBLIC;
+ }
+ }
+
+ /**
+ * @param string $name
+ * @return AbstractMemberGenerator
+ */
+ public function setName($name)
+ {
+ $this->name = (string) $name;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param DocBlockGenerator|string $docBlock
+ * @throws Exception\InvalidArgumentException
+ * @return AbstractMemberGenerator
+ */
+ public function setDocBlock($docBlock)
+ {
+ if (is_string($docBlock)) {
+ $docBlock = new DocBlockGenerator($docBlock);
+ } elseif (!$docBlock instanceof DocBlockGenerator) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s is expecting either a string, array or an instance of %s\DocBlockGenerator',
+ __METHOD__,
+ __NAMESPACE__
+ ));
+ }
+
+ $this->docBlock = $docBlock;
+
+ return $this;
+ }
+
+ /**
+ * @return DocBlockGenerator
+ */
+ public function getDocBlock()
+ {
+ return $this->docBlock;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/BodyGenerator.php zendframework-2.2.6/library/Zend/Code/Generator/BodyGenerator.php
--- zendframework-1.10.4/library/Zend/Code/Generator/BodyGenerator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/BodyGenerator.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,44 @@
+content = (string) $content;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getContent()
+ {
+ return $this->content;
+ }
+
+ /**
+ * @return string
+ */
+ public function generate()
+ {
+ return $this->getContent();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/ClassGenerator.php zendframework-2.2.6/library/Zend/Code/Generator/ClassGenerator.php
--- zendframework-1.10.4/library/Zend/Code/Generator/ClassGenerator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/ClassGenerator.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,736 @@
+getName());
+
+ $cg->setSourceContent($cg->getSourceContent());
+ $cg->setSourceDirty(false);
+
+ if ($classReflection->getDocComment() != '') {
+ $cg->setDocBlock(DocBlockGenerator::fromReflection($classReflection->getDocBlock()));
+ }
+
+ $cg->setAbstract($classReflection->isAbstract());
+
+ // set the namespace
+ if ($classReflection->inNamespace()) {
+ $cg->setNamespaceName($classReflection->getNamespaceName());
+ }
+
+ /* @var \Zend\Code\Reflection\ClassReflection $parentClass */
+ $parentClass = $classReflection->getParentClass();
+ if ($parentClass) {
+ $cg->setExtendedClass($parentClass->getName());
+ $interfaces = array_diff($classReflection->getInterfaces(), $parentClass->getInterfaces());
+ } else {
+ $interfaces = $classReflection->getInterfaces();
+ }
+
+ $interfaceNames = array();
+ foreach ($interfaces AS $interface) {
+ /* @var \Zend\Code\Reflection\ClassReflection $interface */
+ $interfaceNames[] = $interface->getName();
+ }
+
+ $cg->setImplementedInterfaces($interfaceNames);
+
+ $properties = array();
+ foreach ($classReflection->getProperties() as $reflectionProperty) {
+ if ($reflectionProperty->getDeclaringClass()->getName() == $classReflection->getName()) {
+ $properties[] = PropertyGenerator::fromReflection($reflectionProperty);
+ }
+ }
+ $cg->addProperties($properties);
+
+ $methods = array();
+ foreach ($classReflection->getMethods() as $reflectionMethod) {
+ $className = ($cg->getNamespaceName())? $cg->getNamespaceName() . "\\" . $cg->getName() : $cg->getName();
+ if ($reflectionMethod->getDeclaringClass()->getName() == $className) {
+ $methods[] = MethodGenerator::fromReflection($reflectionMethod);
+ }
+ }
+ $cg->addMethods($methods);
+
+ return $cg;
+ }
+
+ /**
+ * Generate from array
+ *
+ * @configkey name string [required] Class Name
+ * @configkey filegenerator FileGenerator File generator that holds this class
+ * @configkey namespacename string The namespace for this class
+ * @configkey docblock string The docblock information
+ * @configkey flags int Flags, one of ClassGenerator::FLAG_ABSTRACT ClassGenerator::FLAG_FINAL
+ * @configkey extendedclass string Class which this class is extending
+ * @configkey implementedinterfaces
+ * @configkey properties
+ * @configkey methods
+ *
+ * @throws Exception\InvalidArgumentException
+ * @param array $array
+ * @return ClassGenerator
+ */
+ public static function fromArray(array $array)
+ {
+ if (!isset($array['name'])) {
+ throw new Exception\InvalidArgumentException(
+ 'Class generator requires that a name is provided for this object'
+ );
+ }
+
+ $cg = new static($array['name']);
+ foreach ($array as $name => $value) {
+ // normalize key
+ switch (strtolower(str_replace(array('.', '-', '_'), '', $name))) {
+ case 'containingfile':
+ $cg->setContainingFileGenerator($value);
+ break;
+ case 'namespacename':
+ $cg->setNamespaceName($value);
+ break;
+ case 'docblock':
+ $docBlock = ($value instanceof DocBlockGenerator) ? $value : DocBlockGenerator::fromArray($value);
+ $cg->setDocBlock($docBlock);
+ break;
+ case 'flags':
+ $cg->setFlags($value);
+ break;
+ case 'extendedclass':
+ $cg->setExtendedClass($value);
+ break;
+ case 'implementedinterfaces':
+ $cg->setImplementedInterfaces($value);
+ break;
+ case 'properties':
+ $cg->addProperties($value);
+ break;
+ case 'methods':
+ $cg->addMethods($value);
+ break;
+ }
+ }
+
+ return $cg;
+ }
+
+ /**
+ * @param string $name
+ * @param string $namespaceName
+ * @param array|string $flags
+ * @param string $extends
+ * @param array $interfaces
+ * @param array $properties
+ * @param array $methods
+ * @param DocBlockGenerator $docBlock
+ */
+ public function __construct($name = null, $namespaceName = null, $flags = null, $extends = null,
+ $interfaces = array(), $properties = array(), $methods = array(), $docBlock = null)
+ {
+ if ($name !== null) {
+ $this->setName($name);
+ }
+ if ($namespaceName !== null) {
+ $this->setNamespaceName($namespaceName);
+ }
+ if ($flags !== null) {
+ $this->setFlags($flags);
+ }
+ if ($properties !== array()) {
+ $this->addProperties($properties);
+ }
+ if ($extends !== null) {
+ $this->setExtendedClass($extends);
+ }
+ if (is_array($interfaces)) {
+ $this->setImplementedInterfaces($interfaces);
+ }
+ if ($methods !== array()) {
+ $this->addMethods($methods);
+ }
+ if ($docBlock !== null) {
+ $this->setDocBlock($docBlock);
+ }
+ }
+
+ /**
+ * @param string $name
+ * @return ClassGenerator
+ */
+ public function setName($name)
+ {
+ if (strstr($name, '\\')) {
+ $namespace = substr($name, 0, strrpos($name, '\\'));
+ $name = substr($name, strrpos($name, '\\') + 1);
+ $this->setNamespaceName($namespace);
+ }
+
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param string $namespaceName
+ * @return ClassGenerator
+ */
+ public function setNamespaceName($namespaceName)
+ {
+ $this->namespaceName = $namespaceName;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getNamespaceName()
+ {
+ return $this->namespaceName;
+ }
+
+ /**
+ * @param FileGenerator $fileGenerator
+ * @return ClassGenerator
+ */
+ public function setContainingFileGenerator(FileGenerator $fileGenerator)
+ {
+ $this->containingFileGenerator = $fileGenerator;
+ return $this;
+ }
+
+ /**
+ * @return FileGenerator
+ */
+ public function getContainingFileGenerator()
+ {
+ return $this->containingFileGenerator;
+ }
+
+ /**
+ * @param DocBlockGenerator $docBlock
+ * @return ClassGenerator
+ */
+ public function setDocBlock(DocBlockGenerator $docBlock)
+ {
+ $this->docBlock = $docBlock;
+ return $this;
+ }
+
+ /**
+ * @return DocBlockGenerator
+ */
+ public function getDocBlock()
+ {
+ return $this->docBlock;
+ }
+
+ /**
+ * @param array|string $flags
+ * @return ClassGenerator
+ */
+ public function setFlags($flags)
+ {
+ if (is_array($flags)) {
+ $flagsArray = $flags;
+ $flags = 0x00;
+ foreach ($flagsArray as $flag) {
+ $flags |= $flag;
+ }
+ }
+ // check that visibility is one of three
+ $this->flags = $flags;
+
+ return $this;
+ }
+
+ /**
+ * @param string $flag
+ * @return ClassGenerator
+ */
+ public function addFlag($flag)
+ {
+ $this->setFlags($this->flags | $flag);
+ return $this;
+ }
+
+ /**
+ * @param string $flag
+ * @return ClassGenerator
+ */
+ public function removeFlag($flag)
+ {
+ $this->setFlags($this->flags & ~$flag);
+ return $this;
+ }
+
+ /**
+ * @param bool $isAbstract
+ * @return ClassGenerator
+ */
+ public function setAbstract($isAbstract)
+ {
+ return (($isAbstract) ? $this->addFlag(self::FLAG_ABSTRACT) : $this->removeFlag(self::FLAG_ABSTRACT));
+ }
+
+ /**
+ * @return bool
+ */
+ public function isAbstract()
+ {
+ return (bool) ($this->flags & self::FLAG_ABSTRACT);
+ }
+
+ /**
+ * @param bool $isFinal
+ * @return ClassGenerator
+ */
+ public function setFinal($isFinal)
+ {
+ return (($isFinal) ? $this->addFlag(self::FLAG_FINAL) : $this->removeFlag(self::FLAG_FINAL));
+ }
+
+ /**
+ * @return bool
+ */
+ public function isFinal()
+ {
+ return ($this->flags & self::FLAG_FINAL);
+ }
+
+ /**
+ * @param string $extendedClass
+ * @return ClassGenerator
+ */
+ public function setExtendedClass($extendedClass)
+ {
+ $this->extendedClass = $extendedClass;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getExtendedClass()
+ {
+ return $this->extendedClass;
+ }
+
+ /**
+ * @param array $implementedInterfaces
+ * @return ClassGenerator
+ */
+ public function setImplementedInterfaces(array $implementedInterfaces)
+ {
+ $this->implementedInterfaces = $implementedInterfaces;
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getImplementedInterfaces()
+ {
+ return $this->implementedInterfaces;
+ }
+
+ /**
+ * @param array $properties
+ * @return ClassGenerator
+ */
+ public function addProperties(array $properties)
+ {
+ foreach ($properties as $property) {
+ if ($property instanceof PropertyGenerator) {
+ $this->addPropertyFromGenerator($property);
+ } else {
+ if (is_string($property)) {
+ $this->addProperty($property);
+ } elseif (is_array($property)) {
+ call_user_func_array(array($this, 'addProperty'), $property);
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Add Property from scalars
+ *
+ * @param string $name
+ * @param string|array $defaultValue
+ * @param int $flags
+ * @throws Exception\InvalidArgumentException
+ * @return ClassGenerator
+ */
+ public function addProperty($name, $defaultValue = null, $flags = PropertyGenerator::FLAG_PUBLIC)
+ {
+ if (!is_string($name)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s expects string for name',
+ __METHOD__
+ ));
+ }
+
+ return $this->addPropertyFromGenerator(new PropertyGenerator($name, $defaultValue, $flags));
+ }
+
+ /**
+ * Add property from PropertyGenerator
+ *
+ * @param string|PropertyGenerator $property
+ * @throws Exception\InvalidArgumentException
+ * @return ClassGenerator
+ */
+ public function addPropertyFromGenerator(PropertyGenerator $property)
+ {
+ $propertyName = $property->getName();
+
+ if (isset($this->properties[$propertyName])) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'A property by name %s already exists in this class.',
+ $propertyName
+ ));
+ }
+
+ $this->properties[$propertyName] = $property;
+ return $this;
+ }
+
+ /**
+ * Add a class to "use" classes
+ *
+ * @param string $use
+ * @param string|null $useAlias
+ * @return ClassGenerator
+ */
+ public function addUse($use, $useAlias = null)
+ {
+ if (!empty($useAlias)) {
+ $use .= ' as ' . $useAlias;
+ }
+
+ $this->uses[$use] = $use;
+ return $this;
+ }
+
+ /**
+ * @return PropertyGenerator[]
+ */
+ public function getProperties()
+ {
+ return $this->properties;
+ }
+
+ /**
+ * @param string $propertyName
+ * @return PropertyGenerator|false
+ */
+ public function getProperty($propertyName)
+ {
+ foreach ($this->getProperties() as $property) {
+ if ($property->getName() == $propertyName) {
+ return $property;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns the "use" classes
+ *
+ * @return array
+ */
+ public function getUses()
+ {
+ return array_values($this->uses);
+ }
+
+ /**
+ * @param string $propertyName
+ * @return bool
+ */
+ public function hasProperty($propertyName)
+ {
+ return isset($this->properties[$propertyName]);
+ }
+
+ /**
+ * @param array $methods
+ * @return ClassGenerator
+ */
+ public function addMethods(array $methods)
+ {
+ foreach ($methods as $method) {
+ if ($method instanceof MethodGenerator) {
+ $this->addMethodFromGenerator($method);
+ } else {
+ if (is_string($method)) {
+ $this->addMethod($method);
+ } elseif (is_array($method)) {
+ call_user_func_array(array($this, 'addMethod'), $method);
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Add Method from scalars
+ *
+ * @param string $name
+ * @param array $parameters
+ * @param int $flags
+ * @param string $body
+ * @param string $docBlock
+ * @throws Exception\InvalidArgumentException
+ * @return ClassGenerator
+ */
+ public function addMethod($name = null, array $parameters = array(), $flags = MethodGenerator::FLAG_PUBLIC,
+ $body = null, $docBlock = null)
+ {
+ if (!is_string($name)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s expects string for name',
+ __METHOD__
+ ));
+ }
+
+ return $this->addMethodFromGenerator(new MethodGenerator($name, $parameters, $flags, $body, $docBlock));
+ }
+
+ /**
+ * Add Method from MethodGenerator
+ *
+ * @param MethodGenerator $method
+ * @throws Exception\InvalidArgumentException
+ * @return ClassGenerator
+ */
+ public function addMethodFromGenerator(MethodGenerator $method)
+ {
+ $methodName = $method->getName();
+
+ if ($this->hasMethod($methodName)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'A method by name %s already exists in this class.',
+ $methodName
+ ));
+ }
+
+ $this->methods[strtolower($methodName)] = $method;
+ return $this;
+ }
+
+ /**
+ * @return MethodGenerator[]
+ */
+ public function getMethods()
+ {
+ return $this->methods;
+ }
+
+ /**
+ * @param string $methodName
+ * @return MethodGenerator|false
+ */
+ public function getMethod($methodName)
+ {
+ return $this->hasMethod($methodName) ? $this->methods[strtolower($methodName)] : false;
+ }
+
+ /**
+ * @param string $methodName
+ * @return ClassGenerator
+ */
+ public function removeMethod($methodName)
+ {
+ if ($this->hasMethod($methodName)) {
+ unset($this->methods[strtolower($methodName)]);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param string $methodName
+ * @return bool
+ */
+ public function hasMethod($methodName)
+ {
+ return isset($this->methods[strtolower($methodName)]);
+ }
+
+ /**
+ * @return bool
+ */
+ public function isSourceDirty()
+ {
+ if (($docBlock = $this->getDocBlock()) && $docBlock->isSourceDirty()) {
+ return true;
+ }
+
+ foreach ($this->getProperties() as $property) {
+ if ($property->isSourceDirty()) {
+ return true;
+ }
+ }
+
+ foreach ($this->getMethods() as $method) {
+ if ($method->isSourceDirty()) {
+ return true;
+ }
+ }
+
+ return parent::isSourceDirty();
+ }
+
+ /**
+ * @return string
+ */
+ public function generate()
+ {
+ if (!$this->isSourceDirty()) {
+ $output = $this->getSourceContent();
+ if (!empty($output)) {
+ return $output;
+ }
+ }
+
+ $output = '';
+
+ if (null !== ($namespace = $this->getNamespaceName())) {
+ $output .= 'namespace ' . $namespace . ';' . self::LINE_FEED . self::LINE_FEED;
+ }
+
+ $uses = $this->getUses();
+ if (!empty($uses)) {
+ foreach ($uses as $use) {
+ $output .= 'use ' . $use . ';' . self::LINE_FEED;
+ }
+ $output .= self::LINE_FEED;
+ }
+
+ if (null !== ($docBlock = $this->getDocBlock())) {
+ $docBlock->setIndentation('');
+ $output .= $docBlock->generate();
+ }
+
+ if ($this->isAbstract()) {
+ $output .= 'abstract ';
+ }
+
+ $output .= 'class ' . $this->getName();
+
+ if (!empty($this->extendedClass)) {
+ $output .= ' extends ' . $this->extendedClass;
+ }
+
+ $implemented = $this->getImplementedInterfaces();
+ if (!empty($implemented)) {
+ $output .= ' implements ' . implode(', ', $implemented);
+ }
+
+ $output .= self::LINE_FEED . '{' . self::LINE_FEED . self::LINE_FEED;
+
+ $properties = $this->getProperties();
+ if (!empty($properties)) {
+ foreach ($properties as $property) {
+ $output .= $property->generate() . self::LINE_FEED . self::LINE_FEED;
+ }
+ }
+
+ $methods = $this->getMethods();
+ if (!empty($methods)) {
+ foreach ($methods as $method) {
+ $output .= $method->generate() . self::LINE_FEED;
+ }
+ }
+
+ $output .= self::LINE_FEED . '}' . self::LINE_FEED;
+
+ return $output;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/DocBlock/Tag/AuthorTag.php zendframework-2.2.6/library/Zend/Code/Generator/DocBlock/Tag/AuthorTag.php
--- zendframework-1.10.4/library/Zend/Code/Generator/DocBlock/Tag/AuthorTag.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/DocBlock/Tag/AuthorTag.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,92 @@
+setName('author')
+ ->setAuthorName($reflectionTagParam->getType()) // @todo rename
+ ->setAuthorEmail($reflectionTagParam->getVariableName())
+ ->setDescription($reflectionTagParam->getDescription());
+
+ return $authorTag;
+ }
+
+ /**
+ * @param string $datatype
+ * @return AuthorTag
+ */
+ public function setDatatype($datatype)
+ {
+ $this->datatype = (string) $datatype;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDatatype()
+ {
+ return $this->datatype;
+ }
+
+ /**
+ * @param string $paramName
+ * @return AuthorTag
+ */
+ public function setParamName($paramName)
+ {
+ $this->paramName = (string) $paramName;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getParamName()
+ {
+ return $this->paramName;
+ }
+
+ /**
+ * @return string
+ */
+ public function generate()
+ {
+ $output = '@param '
+ . (($this->datatype != null) ? $this->datatype : 'unknown')
+ . (($this->paramName != null) ? ' $' . $this->paramName : '')
+ . (($this->description != null) ? ' ' . $this->description : '');
+
+ return $output;
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/DocBlock/Tag/LicenseTag.php zendframework-2.2.6/library/Zend/Code/Generator/DocBlock/Tag/LicenseTag.php
--- zendframework-1.10.4/library/Zend/Code/Generator/DocBlock/Tag/LicenseTag.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/DocBlock/Tag/LicenseTag.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,106 @@
+setUrl($options['url']);
+ }
+
+ if (empty($this->name)) {
+ $this->setName('license');
+ }
+ }
+
+ /**
+ * @param ReflectionDocBlockTag $reflectionTagLicense
+ * @return LicenseTag
+ */
+ public static function fromReflection(ReflectionDocBlockTag $reflectionTagLicense)
+ {
+ $licenseTag = new static();
+ $licenseTag
+ ->setName('license')
+ ->setUrl($reflectionTagLicense->getUrl())
+ ->setLicenseName($reflectionTagLicense->getDescription());
+
+ return $licenseTag;
+ }
+
+ /**
+ * @param string $url
+ * @return LicenseTag
+ */
+ public function setUrl($url)
+ {
+ $this->url = $url;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getUrl()
+ {
+ return $this->url;
+ }
+
+ /**
+ * @param string $name
+ * @return LicenseTag
+ */
+ public function setLicenseName($name)
+ {
+ $this->licenseName = $name;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getLicenseName()
+ {
+ return $this->licenseName;
+ }
+
+ /**
+ * @return string
+ */
+ public function generate()
+ {
+ $output = '@license '
+ . (($this->url != null) ? $this->url : 'unknown')
+ . (($this->licenseName != null) ? ' ' . $this->licenseName : '')
+ . (($this->description != null) ? ' ' . $this->description : '');
+
+ return $output;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/DocBlock/Tag/ParamTag.php zendframework-2.2.6/library/Zend/Code/Generator/DocBlock/Tag/ParamTag.php
--- zendframework-1.10.4/library/Zend/Code/Generator/DocBlock/Tag/ParamTag.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/DocBlock/Tag/ParamTag.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,91 @@
+setName('param')
+ ->setDatatype($reflectionTagParam->getType()) // @todo rename
+ ->setParamName($reflectionTagParam->getVariableName())
+ ->setDescription($reflectionTagParam->getDescription());
+
+ return $paramTag;
+ }
+
+ /**
+ * @param string $datatype
+ * @return ParamTag
+ */
+ public function setDatatype($datatype)
+ {
+ $this->datatype = $datatype;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDatatype()
+ {
+ return $this->datatype;
+ }
+
+ /**
+ * @param string $paramName
+ * @return ParamTag
+ */
+ public function setParamName($paramName)
+ {
+ $this->paramName = $paramName;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getParamName()
+ {
+ return $this->paramName;
+ }
+
+ /**
+ * @return string
+ */
+ public function generate()
+ {
+ $output = '@param '
+ . (($this->datatype != null) ? $this->datatype : 'unknown')
+ . (($this->paramName != null) ? ' $' . $this->paramName : '')
+ . (($this->description != null) ? ' ' . $this->description : '');
+
+ return $output;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/DocBlock/Tag/ReturnTag.php zendframework-2.2.6/library/Zend/Code/Generator/DocBlock/Tag/ReturnTag.php
--- zendframework-1.10.4/library/Zend/Code/Generator/DocBlock/Tag/ReturnTag.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/DocBlock/Tag/ReturnTag.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,62 @@
+setName('return')
+ ->setDatatype($reflectionTagReturn->getType()) // @todo rename
+ ->setDescription($reflectionTagReturn->getDescription());
+
+ return $returnTag;
+ }
+
+ /**
+ * @param string $datatype
+ * @return ReturnTag
+ */
+ public function setDatatype($datatype)
+ {
+ $this->datatype = $datatype;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDatatype()
+ {
+ return $this->datatype;
+ }
+
+ /**
+ * @return string
+ */
+ public function generate()
+ {
+ return '@return ' . $this->datatype . ' ' . $this->description;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/DocBlock/Tag.php zendframework-2.2.6/library/Zend/Code/Generator/DocBlock/Tag.php
--- zendframework-1.10.4/library/Zend/Code/Generator/DocBlock/Tag.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/DocBlock/Tag.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,102 @@
+getName();
+
+ $codeGenDocBlockTag = new static();
+ $codeGenDocBlockTag->setName($tagName);
+
+ // transport any properties via accessors and mutators from reflection to codegen object
+ $reflectionClass = new ReflectionClass($reflectionTag);
+ foreach ($reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
+ if (substr($method->getName(), 0, 3) == 'get') {
+ $propertyName = substr($method->getName(), 3);
+ if (method_exists($codeGenDocBlockTag, 'set' . $propertyName)) {
+ $codeGenDocBlockTag->{'set' . $propertyName}($reflectionTag->{'get' . $propertyName}());
+ }
+ }
+ }
+
+ return $codeGenDocBlockTag;
+ }
+
+ /**
+ * @param string $name
+ * @return Tag
+ */
+ public function setName($name)
+ {
+ $this->name = ltrim($name, '@');
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param string $description
+ * @return Tag
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * @return string
+ */
+ public function generate()
+ {
+ $output = '@' . $this->name
+ . (($this->description != null) ? ' ' . $this->description : '');
+
+ return $output;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/DocBlockGenerator.php zendframework-2.2.6/library/Zend/Code/Generator/DocBlockGenerator.php
--- zendframework-1.10.4/library/Zend/Code/Generator/DocBlockGenerator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/DocBlockGenerator.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,260 @@
+setSourceContent($reflectionDocBlock->getContents());
+ $docBlock->setSourceDirty(false);
+
+ $docBlock->setShortDescription($reflectionDocBlock->getShortDescription());
+ $docBlock->setLongDescription($reflectionDocBlock->getLongDescription());
+
+ foreach ($reflectionDocBlock->getTags() as $tag) {
+ $docBlock->setTag(DocBlockTag::fromReflection($tag));
+ }
+
+ return $docBlock;
+ }
+
+ /**
+ * Generate from array
+ *
+ * @configkey shortdescription string The short description for this doc block
+ * @configkey longdescription string The long description for this doc block
+ * @configkey tags array
+ *
+ * @throws Exception\InvalidArgumentException
+ * @param array $array
+ * @return DocBlockGenerator
+ */
+ public static function fromArray(array $array)
+ {
+ $docBlock = new static();
+
+ foreach ($array as $name => $value) {
+ // normalize key
+ switch (strtolower(str_replace(array('.', '-', '_'), '', $name))) {
+ case 'shortdescription':
+ $docBlock->setShortDescription($value);
+ case 'longdescription':
+ $docBlock->setLongDescription($value);
+ break;
+ case 'tags':
+ $docBlock->setTags($value);
+ break;
+ }
+ }
+
+ return $docBlock;
+ }
+
+ /**
+ * @param string $shortDescription
+ * @param string $longDescription
+ * @param array $tags
+ */
+ public function __construct($shortDescription = null, $longDescription = null, array $tags = array())
+ {
+ if ($shortDescription) {
+ $this->setShortDescription($shortDescription);
+ }
+ if ($longDescription) {
+ $this->setLongDescription($longDescription);
+ }
+ if (is_array($tags) && $tags) {
+ $this->setTags($tags);
+ }
+ }
+
+ /**
+ * @param string $shortDescription
+ * @return DocBlockGenerator
+ */
+ public function setShortDescription($shortDescription)
+ {
+ $this->shortDescription = $shortDescription;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getShortDescription()
+ {
+ return $this->shortDescription;
+ }
+
+ /**
+ * @param string $longDescription
+ * @return DocBlockGenerator
+ */
+ public function setLongDescription($longDescription)
+ {
+ $this->longDescription = $longDescription;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getLongDescription()
+ {
+ return $this->longDescription;
+ }
+
+ /**
+ * @param array $tags
+ * @return DocBlockGenerator
+ */
+ public function setTags(array $tags)
+ {
+ foreach ($tags as $tag) {
+ $this->setTag($tag);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param array|DocBlockTag $tag
+ * @throws Exception\InvalidArgumentException
+ * @return DocBlockGenerator
+ */
+ public function setTag($tag)
+ {
+ if (is_array($tag)) {
+ $tag = new DocBlockTag($tag);
+ } elseif (!$tag instanceof DocBlockTag) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s expects either an array of method options or an instance of %s\DocBlock\Tag',
+ __METHOD__,
+ __NAMESPACE__
+ ));
+ }
+
+ $this->tags[] = $tag;
+ return $this;
+ }
+
+ /**
+ * @return DocBlockTag[]
+ */
+ public function getTags()
+ {
+ return $this->tags;
+ }
+
+ /**
+ * Set the word wrap
+ *
+ * @param bool $value
+ * @return \Zend\Code\Generator\DocBlockGenerator
+ */
+ public function setWordWrap($value)
+ {
+ $this->wordwrap = (bool) $value;
+ return $this;
+ }
+
+ /**
+ * Get the word wrap
+ *
+ * @return bool
+ */
+ public function getWordWrap()
+ {
+ return $this->wordwrap;
+ }
+
+ /**
+ * @return string
+ */
+ public function generate()
+ {
+ if (!$this->isSourceDirty()) {
+ return $this->docCommentize(trim($this->getSourceContent()));
+ }
+
+ $output = '';
+ if (null !== ($sd = $this->getShortDescription())) {
+ $output .= $sd . self::LINE_FEED . self::LINE_FEED;
+ }
+ if (null !== ($ld = $this->getLongDescription())) {
+ $output .= $ld . self::LINE_FEED . self::LINE_FEED;
+ }
+
+ foreach ($this->getTags() as $tag) {
+ $output .= $tag->generate() . self::LINE_FEED;
+ }
+
+ return $this->docCommentize(trim($output));
+ }
+
+ /**
+ * @param string $content
+ * @return string
+ */
+ protected function docCommentize($content)
+ {
+ $indent = $this->getIndentation();
+ $output = $indent . '/**' . self::LINE_FEED;
+ $content = $this->getWordWrap() == true ? wordwrap($content, 80, self::LINE_FEED) : $content;
+ $lines = explode(self::LINE_FEED, $content);
+ foreach ($lines as $line) {
+ $output .= $indent . ' *';
+ if ($line) {
+ $output .= " $line";
+ }
+ $output .= self::LINE_FEED;
+ }
+ $output .= $indent . ' */' . self::LINE_FEED;
+
+ return $output;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Code/Generator/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Code/Generator/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/Exception/ExceptionInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+setOptions($options);
+ }
+ }
+
+ /**
+ * Use this if you intend on generating code generation objects based on the same file.
+ * This will keep previous changes to the file in tact during the same PHP process
+ *
+ * @param string $filePath
+ * @param bool $includeIfNotAlreadyIncluded
+ * @throws ReflectionException\InvalidArgumentException If file does not exists
+ * @throws ReflectionException\RuntimeException If file exists but is not included or required
+ * @return FileGenerator
+ */
+ public static function fromReflectedFileName($filePath, $includeIfNotAlreadyIncluded = true)
+ {
+ $fileReflector = new FileReflection($filePath, $includeIfNotAlreadyIncluded);
+ $codeGenerator = static::fromReflection($fileReflector);
+
+ return $codeGenerator;
+ }
+
+ /**
+ * @param FileReflection $fileReflection
+ * @return FileGenerator
+ */
+ public static function fromReflection(FileReflection $fileReflection)
+ {
+ $file = new static();
+
+ $file->setSourceContent($fileReflection->getContents());
+ $file->setSourceDirty(false);
+
+ $body = $fileReflection->getContents();
+
+ $uses = $fileReflection->getUses();
+
+ foreach ($fileReflection->getClasses() as $class) {
+ $phpClass = ClassGenerator::fromReflection($class);
+ $phpClass->setContainingFileGenerator($file);
+
+ foreach ($uses as $fileUse) {
+ $phpClass->addUse($fileUse['use'], $fileUse['as']);
+ }
+
+ $file->setClass($phpClass);
+
+ $classStartLine = $class->getStartLine(true);
+ $classEndLine = $class->getEndLine();
+
+ $bodyLines = explode("\n", $body);
+ $bodyReturn = array();
+ for ($lineNum = 1, $count = count($bodyLines); $lineNum <= $count; $lineNum++) {
+ if ($lineNum == $classStartLine) {
+ $bodyReturn[] = str_replace(
+ '?',
+ $class->getName(),
+ '/* Zend_Code_Generator_Php_File-ClassMarker: {?} */'
+ );
+
+ $lineNum = $classEndLine;
+ } else {
+ $bodyReturn[] = $bodyLines[$lineNum - 1]; // adjust for index -> line conversion
+ }
+ }
+ $body = implode("\n", $bodyReturn);
+ unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine);
+ }
+
+ $namespace = $fileReflection->getNamespace();
+
+ if ($namespace != '') {
+ $file->setNamespace($namespace);
+ }
+
+ if ($uses) {
+ $file->setUses($uses);
+ }
+
+ if (($fileReflection->getDocComment() != '')) {
+ $docBlock = $fileReflection->getDocBlock();
+ $file->setDocBlock(DocBlockGenerator::fromReflection($docBlock));
+
+ $bodyLines = explode("\n", $body);
+ $bodyReturn = array();
+ for ($lineNum = 1, $count = count($bodyLines); $lineNum <= $count; $lineNum++) {
+ if ($lineNum == $docBlock->getStartLine()) {
+ $bodyReturn[] = str_replace(
+ '?',
+ $class->getName(),
+ '/* Zend_Code_Generator_FileGenerator-DocBlockMarker */'
+ );
+ $lineNum = $docBlock->getEndLine();
+ } else {
+ $bodyReturn[] = $bodyLines[$lineNum - 1]; // adjust for index -> line conversion
+ }
+ }
+ $body = implode("\n", $bodyReturn);
+ unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine);
+ }
+
+ $file->setBody($body);
+
+ return $file;
+ }
+
+ /**
+ * @param array $values
+ * @return FileGenerator
+ */
+ public static function fromArray(array $values)
+ {
+ $fileGenerator = new static;
+ foreach ($values as $name => $value) {
+ switch (strtolower(str_replace(array('.', '-', '_'), '', $name))) {
+ case 'filename':
+ $fileGenerator->setFilename($value);
+ continue;
+ case 'class':
+ $fileGenerator->setClass(($value instanceof ClassGenerator) ? $value : ClassGenerator::fromArray($value));
+ continue;
+ case 'requiredfiles':
+ $fileGenerator->setRequiredFiles($value);
+ continue;
+ default:
+ if (property_exists($fileGenerator, $name)) {
+ $fileGenerator->{$name} = $value;
+ } elseif (method_exists($fileGenerator, 'set' . $name)) {
+ $fileGenerator->{'set' . $name}($value);
+ }
+ }
+ }
+
+ return $fileGenerator;
+ }
+
+ /**
+ * @param DocBlockGenerator|string $docBlock
+ * @throws Exception\InvalidArgumentException
+ * @return FileGenerator
+ */
+ public function setDocBlock($docBlock)
+ {
+ if (is_string($docBlock)) {
+ $docBlock = array('shortDescription' => $docBlock);
+ }
+
+ if (is_array($docBlock)) {
+ $docBlock = new DocBlockGenerator($docBlock);
+ } elseif (!$docBlock instanceof DocBlockGenerator) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s is expecting either a string, array or an instance of %s\DocBlockGenerator',
+ __METHOD__,
+ __NAMESPACE__
+ ));
+ }
+
+ $this->docBlock = $docBlock;
+ return $this;
+ }
+
+ /**
+ * @return DocBlockGenerator
+ */
+ public function getDocBlock()
+ {
+ return $this->docBlock;
+ }
+
+ /**
+ * @param array $requiredFiles
+ * @return FileGenerator
+ */
+ public function setRequiredFiles(array $requiredFiles)
+ {
+ $this->requiredFiles = $requiredFiles;
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getRequiredFiles()
+ {
+ return $this->requiredFiles;
+ }
+
+ /**
+ * @param array $classes
+ * @return FileGenerator
+ */
+ public function setClasses(array $classes)
+ {
+ foreach ($classes as $class) {
+ $this->setClass($class);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getNamespace()
+ {
+ return $this->namespace;
+ }
+
+ /**
+ * @param string $namespace
+ * @return FileGenerator
+ */
+ public function setNamespace($namespace)
+ {
+ $this->namespace = (string) $namespace;
+ return $this;
+ }
+
+ /**
+ * Returns an array with the first element the use statement, second is the as part.
+ * If $withResolvedAs is set to true, there will be a third element that is the
+ * "resolved" as statement, as the second part is not required in use statements
+ *
+ * @param bool $withResolvedAs
+ * @return array
+ */
+ public function getUses($withResolvedAs = false)
+ {
+ $uses = $this->uses;
+ if ($withResolvedAs) {
+ for ($useIndex = 0, $count = count($uses); $useIndex < $count; $useIndex++) {
+ if ($uses[$useIndex][1] == '') {
+ if (($lastSeparator = strrpos($uses[$useIndex][0], '\\')) !== false) {
+ $uses[$useIndex][2] = substr($uses[$useIndex][0], $lastSeparator + 1);
+ } else {
+ $uses[$useIndex][2] = $uses[$useIndex][0];
+ }
+ } else {
+ $uses[$useIndex][2] = $uses[$useIndex][1];
+ }
+ }
+ }
+
+ return $uses;
+ }
+
+ /**
+ * @param array $uses
+ * @return FileGenerator
+ */
+ public function setUses(array $uses)
+ {
+ foreach ($uses as $use) {
+ $use = (array) $use;
+ if (array_key_exists('use', $use) && array_key_exists('as', $use)) {
+ $import = $use['use'];
+ $alias = $use['as'];
+ } elseif (count($use) == 2) {
+ list($import, $alias) = $use;
+ } else {
+ $import = current($use);
+ $alias = null;
+ }
+ $this->setUse($import, $alias);
+ }
+ return $this;
+ }
+
+ /**
+ * @param string $use
+ * @param null|string $as
+ * @return FileGenerator
+ */
+ public function setUse($use, $as = null)
+ {
+ if (!in_array(array($use, $as), $this->uses)) {
+ $this->uses[] = array($use, $as);
+ }
+ return $this;
+ }
+
+ /**
+ * @param string $name
+ * @return ClassGenerator
+ */
+ public function getClass($name = null)
+ {
+ if ($name == null) {
+ reset($this->classes);
+
+ return current($this->classes);
+ }
+
+ return $this->classes[(string) $name];
+ }
+
+ /**
+ * @param array|string|ClassGenerator $class
+ * @throws Exception\InvalidArgumentException
+ * @return FileGenerator
+ */
+ public function setClass($class)
+ {
+ if (is_array($class)) {
+ $class = ClassGenerator::fromArray($class);
+ } elseif (is_string($class)) {
+ $class = new ClassGenerator($class);
+ } elseif (!$class instanceof ClassGenerator) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s is expecting either a string, array or an instance of %s\ClassGenerator',
+ __METHOD__,
+ __NAMESPACE__
+ ));
+ }
+
+ // @todo check for dup here
+ $className = $class->getName();
+ $this->classes[$className] = $class;
+
+ return $this;
+ }
+
+ /**
+ * @param string $filename
+ * @return FileGenerator
+ */
+ public function setFilename($filename)
+ {
+ $this->filename = (string) $filename;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getFilename()
+ {
+ return $this->filename;
+ }
+
+ /**
+ * @return ClassGenerator[]
+ */
+ public function getClasses()
+ {
+ return $this->classes;
+ }
+
+ /**
+ * @param string $body
+ * @return FileGenerator
+ */
+ public function setBody($body)
+ {
+ $this->body = (string) $body;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getBody()
+ {
+ return $this->body;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isSourceDirty()
+ {
+ $docBlock = $this->getDocBlock();
+ if ($docBlock && $docBlock->isSourceDirty()) {
+ return true;
+ }
+
+ foreach ($this->classes as $class) {
+ if ($class->isSourceDirty()) {
+ return true;
+ }
+ }
+
+ return parent::isSourceDirty();
+ }
+
+ /**
+ * @return string
+ */
+ public function generate()
+ {
+ if ($this->isSourceDirty() === false) {
+ return $this->sourceContent;
+ }
+
+ $output = '';
+
+ // start with the body (if there), or open tag
+ $body = $this->getBody();
+ if (preg_match('#(?:\s*)<\?php#', $body) == false) {
+ $output = 'getDocBlock())) {
+ $docBlock->setIndentation('');
+
+ if (preg_match('#/* Zend_Code_Generator_FileGenerator-DocBlockMarker */#', $output)) {
+ $output = preg_replace('#/* Zend_CodeGenerator_Php_File-DocBlockMarker */#', $docBlock->generate(),
+ $output, 1);
+ } else {
+ $output .= $docBlock->generate() . self::LINE_FEED;
+ }
+ }
+
+ // newline
+ $output .= self::LINE_FEED;
+
+ // namespace, if any
+ $namespace = $this->getNamespace();
+ if ($namespace) {
+ $output .= sprintf('namespace %s;%s', $namespace, str_repeat(self::LINE_FEED, 2));
+ }
+
+ // process required files
+ // @todo marker replacement for required files
+ $requiredFiles = $this->getRequiredFiles();
+ if (!empty($requiredFiles)) {
+ foreach ($requiredFiles as $requiredFile) {
+ $output .= 'require_once \'' . $requiredFile . '\';' . self::LINE_FEED;
+ }
+
+ $output .= self::LINE_FEED;
+ }
+
+ // process import statements
+ $uses = $this->getUses();
+ if (!empty($uses)) {
+ foreach ($uses as $use) {
+ list($import, $alias) = $use;
+ if (null === $alias) {
+ $output .= sprintf('use %s;%s', $import, self::LINE_FEED);
+ } else {
+ $output .= sprintf('use %s as %s;%s', $import, $alias, self::LINE_FEED);
+ }
+ }
+ $output .= self::LINE_FEED;
+ }
+
+ // process classes
+ $classes = $this->getClasses();
+ if (!empty($classes)) {
+ foreach ($classes as $class) {
+ $regex = str_replace('?', $class->getName(),
+ '/* Zend_Code_Generator_FileGenerator-ClassMarker: {?} */');
+ $regex = preg_quote($regex, '#');
+ if (preg_match('#' . $regex . '#', $output)) {
+ $output = preg_replace('#' . $regex . '#', $class->generate(), $output, 1);
+ } else {
+ if ($namespace) {
+ $class->setNamespaceName(null);
+ }
+ $output .= $class->generate() . self::LINE_FEED;
+ }
+ }
+ }
+
+ if (!empty($body)) {
+ // add an extra space between classes and
+ if (!empty($classes)) {
+ $output .= self::LINE_FEED;
+ }
+
+ $output .= $body;
+ }
+
+ return $output;
+ }
+
+ /**
+ * @return FileGenerator
+ * @throws Exception\RuntimeException
+ */
+ public function write()
+ {
+ if ($this->filename == '' || !is_writable(dirname($this->filename))) {
+ throw new Exception\RuntimeException('This code generator object is not writable.');
+ }
+ file_put_contents($this->filename, $this->generate());
+
+ return $this;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/FileGeneratorRegistry.php zendframework-2.2.6/library/Zend/Code/Generator/FileGeneratorRegistry.php
--- zendframework-1.10.4/library/Zend/Code/Generator/FileGeneratorRegistry.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/FileGeneratorRegistry.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,44 @@
+getFilename();
+ }
+
+ if ($fileName == '') {
+ throw new RuntimeException('FileName does not exist.');
+ }
+
+ // cannot use realpath since the file might not exist, but we do need to have the index
+ // in the same DIRECTORY_SEPARATOR that realpath would use:
+ $fileName = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $fileName);
+
+ static::$fileCodeGenerators[$fileName] = $fileCodeGenerator;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/GeneratorInterface.php zendframework-2.2.6/library/Zend/Code/Generator/GeneratorInterface.php
--- zendframework-1.10.4/library/Zend/Code/Generator/GeneratorInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/GeneratorInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+setSourceContent($reflectionMethod->getContents(false));
+ $method->setSourceDirty(false);
+
+ if ($reflectionMethod->getDocComment() != '') {
+ $method->setDocBlock(DocBlockGenerator::fromReflection($reflectionMethod->getDocBlock()));
+ }
+
+ $method->setFinal($reflectionMethod->isFinal());
+
+ if ($reflectionMethod->isPrivate()) {
+ $method->setVisibility(self::VISIBILITY_PRIVATE);
+ } elseif ($reflectionMethod->isProtected()) {
+ $method->setVisibility(self::VISIBILITY_PROTECTED);
+ } else {
+ $method->setVisibility(self::VISIBILITY_PUBLIC);
+ }
+
+ $method->setStatic($reflectionMethod->isStatic());
+
+ $method->setName($reflectionMethod->getName());
+
+ foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
+ $method->setParameter(ParameterGenerator::fromReflection($reflectionParameter));
+ }
+
+ $method->setBody($reflectionMethod->getBody());
+
+ return $method;
+ }
+
+ /**
+ * Generate from array
+ *
+ * @configkey name string [required] Class Name
+ * @configkey docblock string The docblock information
+ * @configkey flags int Flags, one of MethodGenerator::FLAG_ABSTRACT MethodGenerator::FLAG_FINAL
+ * @configkey parameters string Class which this class is extending
+ * @configkey body string
+ * @configkey abstract bool
+ * @configkey final bool
+ * @configkey static bool
+ * @configkey visibility string
+ *
+ * @throws Exception\InvalidArgumentException
+ * @param array $array
+ * @return MethodGenerator
+ */
+ public static function fromArray(array $array)
+ {
+ if (!isset($array['name'])) {
+ throw new Exception\InvalidArgumentException(
+ 'Method generator requires that a name is provided for this object'
+ );
+ }
+
+ $method = new static($array['name']);
+ foreach ($array as $name => $value) {
+ // normalize key
+ switch (strtolower(str_replace(array('.', '-', '_'), '', $name))) {
+ case 'docblock':
+ $docBlock = ($value instanceof DocBlockGenerator) ? $value : DocBlockGenerator::fromArray($value);
+ $method->setDocBlock($docBlock);
+ break;
+ case 'flags':
+ $method->setFlags($value);
+ break;
+ case 'parameters':
+ $method->setParameters($value);
+ break;
+ case 'body':
+ $method->setBody($value);
+ break;
+ case 'abstract':
+ $method->setAbstract($value);
+ break;
+ case 'final':
+ $method->setFinal($value);
+ break;
+ case 'static':
+ $method->setStatic($value);
+ break;
+ case 'visibility':
+ $method->setVisibility($value);
+ break;
+ }
+ }
+
+ return $method;
+ }
+
+ /**
+ * @param string $name
+ * @param array $parameters
+ * @param int|array $flags
+ * @param string $body
+ * @param DocBlockGenerator|string $docBlock
+ */
+ public function __construct($name = null, array $parameters = array(), $flags = self::FLAG_PUBLIC, $body = null,
+ $docBlock = null)
+ {
+ if ($name) {
+ $this->setName($name);
+ }
+ if ($parameters) {
+ $this->setParameters($parameters);
+ }
+ if ($flags !== self::FLAG_PUBLIC) {
+ $this->setFlags($flags);
+ }
+ if ($body) {
+ $this->setBody($body);
+ }
+ if ($docBlock) {
+ $this->setDocBlock($docBlock);
+ }
+ }
+
+ /**
+ * @param array $parameters
+ * @return MethodGenerator
+ */
+ public function setParameters(array $parameters)
+ {
+ foreach ($parameters as $parameter) {
+ $this->setParameter($parameter);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param ParameterGenerator|string $parameter
+ * @throws Exception\InvalidArgumentException
+ * @return MethodGenerator
+ */
+ public function setParameter($parameter)
+ {
+ if (is_string($parameter)) {
+ $parameter = new ParameterGenerator($parameter);
+ } elseif (!$parameter instanceof ParameterGenerator) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s is expecting either a string, array or an instance of %s\ParameterGenerator',
+ __METHOD__,
+ __NAMESPACE__
+ ));
+ }
+
+ $parameterName = $parameter->getName();
+
+ $this->parameters[$parameterName] = $parameter;
+
+ return $this;
+ }
+
+ /**
+ * @return ParameterGenerator[]
+ */
+ public function getParameters()
+ {
+ return $this->parameters;
+ }
+
+ /**
+ * @param string $body
+ * @return MethodGenerator
+ */
+ public function setBody($body)
+ {
+ $this->body = $body;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getBody()
+ {
+ return $this->body;
+ }
+
+ /**
+ * @return string
+ */
+ public function generate()
+ {
+ $output = '';
+
+ $indent = $this->getIndentation();
+
+ if (($docBlock = $this->getDocBlock()) !== null) {
+ $docBlock->setIndentation($indent);
+ $output .= $docBlock->generate();
+ }
+
+ $output .= $indent;
+
+ if ($this->isAbstract()) {
+ $output .= 'abstract ';
+ } else {
+ $output .= (($this->isFinal()) ? 'final ' : '');
+ }
+
+ $output .= $this->getVisibility()
+ . (($this->isStatic()) ? ' static' : '')
+ . ' function ' . $this->getName() . '(';
+
+ $parameters = $this->getParameters();
+ if (!empty($parameters)) {
+ foreach ($parameters as $parameter) {
+ $parameterOutput[] = $parameter->generate();
+ }
+
+ $output .= implode(', ', $parameterOutput);
+ }
+
+ $output .= ')';
+
+ if ($this->isAbstract()) {
+ return $output . ';';
+ }
+
+ $output .= self::LINE_FEED . $indent . '{' . self::LINE_FEED;
+
+ if ($this->body) {
+ $output .= preg_replace('#^(.+?)$#m', $indent . $indent . '$1', trim($this->body))
+ . self::LINE_FEED;
+ }
+
+ $output .= $indent . '}' . self::LINE_FEED;
+
+ return $output;
+ }
+
+ public function __toString()
+ {
+ return $this->generate();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/ParameterGenerator.php zendframework-2.2.6/library/Zend/Code/Generator/ParameterGenerator.php
--- zendframework-1.10.4/library/Zend/Code/Generator/ParameterGenerator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/ParameterGenerator.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,296 @@
+setName($reflectionParameter->getName());
+
+ if ($reflectionParameter->isArray()) {
+ $param->setType('array');
+ } elseif (method_exists($reflectionParameter, 'isCallable') && $reflectionParameter->isCallable()) {
+ $param->setType('callable');
+ } else {
+ $typeClass = $reflectionParameter->getClass();
+ if ($typeClass) {
+ $parameterType = $typeClass->getName();
+ $currentNamespace = $reflectionParameter->getDeclaringClass()->getNamespaceName();
+
+ if (!empty($currentNamespace) && substr($parameterType, 0, strlen($currentNamespace)) == $currentNamespace) {
+ $parameterType = substr($parameterType, strlen($currentNamespace) + 1);
+ } else {
+ $parameterType = '\\' . trim($parameterType, '\\');
+ }
+
+ $param->setType($parameterType);
+ }
+ }
+
+ $param->setPosition($reflectionParameter->getPosition());
+
+ if ($reflectionParameter->isOptional()) {
+ $param->setDefaultValue($reflectionParameter->getDefaultValue());
+ }
+ $param->setPassedByReference($reflectionParameter->isPassedByReference());
+
+ return $param;
+ }
+
+ /**
+ * Generate from array
+ *
+ * @configkey name string [required] Class Name
+ * @configkey type string
+ * @configkey defaultvalue null|bool|string|int|float|array|ValueGenerator
+ * @configkey passedbyreference bool
+ * @configkey position int
+ * @configkey sourcedirty bool
+ * @configkey indentation string
+ * @configkey sourcecontent string
+ *
+ * @throws Exception\InvalidArgumentException
+ * @param array $array
+ * @return ParameterGenerator
+ */
+ public static function fromArray(array $array)
+ {
+ if (!isset($array['name'])) {
+ throw new Exception\InvalidArgumentException(
+ 'Paramerer generator requires that a name is provided for this object'
+ );
+ }
+
+ $param = new static($array['name']);
+ foreach ($array as $name => $value) {
+ // normalize key
+ switch (strtolower(str_replace(array('.', '-', '_'), '', $name))) {
+ case 'type':
+ $param->setType($value);
+ break;
+ case 'defaultvalue':
+ $param->setDefaultValue($value);
+ break;
+ case 'passedbyreference':
+ $param->setPassedByReference($value);
+ break;
+ case 'position':
+ $param->setPosition($value);
+ break;
+ case 'sourcedirty':
+ $param->setSourceDirty($value);
+ break;
+ case 'indentation':
+ $param->setIndentation($value);
+ break;
+ case 'sourcecontent':
+ $param->setSourceContent($value);
+ break;
+ }
+ }
+
+ return $param;
+ }
+
+ /**
+ * @param string $name
+ * @param string $type
+ * @param mixed $defaultValue
+ * @param int $position
+ * @param bool $passByReference
+ */
+ public function __construct($name = null, $type = null, $defaultValue = null, $position = null,
+ $passByReference = false)
+ {
+ if (null !== $name) {
+ $this->setName($name);
+ }
+ if (null !== $type) {
+ $this->setType($type);
+ }
+ if (null !== $defaultValue) {
+ $this->setDefaultValue($defaultValue);
+ }
+ if (null !== $position) {
+ $this->setPosition($position);
+ }
+ if (false !== $passByReference) {
+ $this->setPassedByReference(true);
+ }
+ }
+
+ /**
+ * @param string $type
+ * @return ParameterGenerator
+ */
+ public function setType($type)
+ {
+ $this->type = (string) $type;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * @param string $name
+ * @return ParameterGenerator
+ */
+ public function setName($name)
+ {
+ $this->name = (string) $name;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Set the default value of the parameter.
+ *
+ * Certain variables are difficult to express
+ *
+ * @param null|bool|string|int|float|array|ValueGenerator $defaultValue
+ * @return ParameterGenerator
+ */
+ public function setDefaultValue($defaultValue)
+ {
+ if (!($defaultValue instanceof ValueGenerator)) {
+ $defaultValue = new ValueGenerator($defaultValue);
+ }
+ $this->defaultValue = $defaultValue;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDefaultValue()
+ {
+ return $this->defaultValue;
+ }
+
+ /**
+ * @param int $position
+ * @return ParameterGenerator
+ */
+ public function setPosition($position)
+ {
+ $this->position = (int) $position;
+ return $this;
+ }
+
+ /**
+ * @return int
+ */
+ public function getPosition()
+ {
+ return $this->position;
+ }
+
+ /**
+ * @return bool
+ */
+ public function getPassedByReference()
+ {
+ return $this->passedByReference;
+ }
+
+ /**
+ * @param bool $passedByReference
+ * @return ParameterGenerator
+ */
+ public function setPassedByReference($passedByReference)
+ {
+ $this->passedByReference = (bool) $passedByReference;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function generate()
+ {
+ $output = '';
+
+ if ($this->type && !in_array($this->type, static::$simple)) {
+ $output .= $this->type . ' ';
+ }
+
+ if (true === $this->passedByReference) {
+ $output .= '&';
+ }
+
+ $output .= '$' . $this->name;
+
+ if ($this->defaultValue !== null) {
+ $output .= ' = ';
+ if (is_string($this->defaultValue)) {
+ $output .= ValueGenerator::escape($this->defaultValue);
+ } elseif ($this->defaultValue instanceof ValueGenerator) {
+ $this->defaultValue->setOutputMode(ValueGenerator::OUTPUT_SINGLE_LINE);
+ $output .= $this->defaultValue;
+ } else {
+ $output .= $this->defaultValue;
+ }
+ }
+
+ return $output;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/PropertyGenerator.php zendframework-2.2.6/library/Zend/Code/Generator/PropertyGenerator.php
--- zendframework-1.10.4/library/Zend/Code/Generator/PropertyGenerator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/PropertyGenerator.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,227 @@
+setName($reflectionProperty->getName());
+
+ $allDefaultProperties = $reflectionProperty->getDeclaringClass()->getDefaultProperties();
+
+ $property->setDefaultValue($allDefaultProperties[$reflectionProperty->getName()]);
+
+ if ($reflectionProperty->getDocComment() != '') {
+ $property->setDocBlock(DocBlockGenerator::fromReflection($reflectionProperty->getDocBlock()));
+ }
+
+ if ($reflectionProperty->isStatic()) {
+ $property->setStatic(true);
+ }
+
+ if ($reflectionProperty->isPrivate()) {
+ $property->setVisibility(self::VISIBILITY_PRIVATE);
+ } elseif ($reflectionProperty->isProtected()) {
+ $property->setVisibility(self::VISIBILITY_PROTECTED);
+ } else {
+ $property->setVisibility(self::VISIBILITY_PUBLIC);
+ }
+
+ $property->setSourceDirty(false);
+
+ return $property;
+ }
+
+ /**
+ * Generate from array
+ *
+ * @configkey name string [required] Class Name
+ * @configkey const bool
+ * @configkey defaultvalue null|bool|string|int|float|array|ValueGenerator
+ * @configkey flags int
+ * @configkey abstract bool
+ * @configkey final bool
+ * @configkey static bool
+ * @configkey visibility string
+ *
+ * @throws Exception\InvalidArgumentException
+ * @param array $array
+ * @return PropertyGenerator
+ */
+ public static function fromArray(array $array)
+ {
+ if (!isset($array['name'])) {
+ throw new Exception\InvalidArgumentException(
+ 'Property generator requires that a name is provided for this object'
+ );
+ }
+
+ $property = new static($array['name']);
+ foreach ($array as $name => $value) {
+ // normalize key
+ switch (strtolower(str_replace(array('.', '-', '_'), '', $name))) {
+ case 'const':
+ $property->setConst($value);
+ break;
+ case 'defaultvalue':
+ $property->setDefaultValue($value);
+ break;
+ case 'docblock':
+ $docBlock = ($value instanceof DocBlockGenerator) ? $value : DocBlockGenerator::fromArray($value);
+ $property->setDocBlock($docBlock);
+ break;
+ case 'flags':
+ $property->setFlags($value);
+ break;
+ case 'abstract':
+ $property->setAbstract($value);
+ break;
+ case 'final':
+ $property->setFinal($value);
+ break;
+ case 'static':
+ $property->setStatic($value);
+ break;
+ case 'visibility':
+ $property->setVisibility($value);
+ break;
+ }
+ }
+
+ return $property;
+ }
+
+ /**
+ * @param string $name
+ * @param PropertyValueGenerator|string|array $defaultValue
+ * @param int|array $flags
+ */
+ public function __construct($name = null, $defaultValue = null, $flags = self::FLAG_PUBLIC)
+ {
+ if (null !== $name) {
+ $this->setName($name);
+ }
+ if (null !== $defaultValue) {
+ $this->setDefaultValue($defaultValue);
+ }
+ if ($flags !== self::FLAG_PUBLIC) {
+ $this->setFlags($flags);
+ }
+ }
+
+ /**
+ * @param bool $const
+ * @return PropertyGenerator
+ */
+ public function setConst($const)
+ {
+ if ($const) {
+ $this->removeFlag(self::FLAG_PUBLIC | self::FLAG_PRIVATE | self::FLAG_PROTECTED);
+ $this->setFlags(self::FLAG_CONSTANT);
+ } else {
+ $this->removeFlag(self::FLAG_CONSTANT);
+ }
+
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isConst()
+ {
+ return (bool) ($this->flags & self::FLAG_CONSTANT);
+ }
+
+ /**
+ * @param PropertyValueGenerator|mixed $defaultValue
+ * @param string $defaultValueType
+ * @param string $defaultValueOutputMode
+ *
+ * @return PropertyGenerator
+ */
+ public function setDefaultValue($defaultValue, $defaultValueType = PropertyValueGenerator::TYPE_AUTO, $defaultValueOutputMode = PropertyValueGenerator::OUTPUT_MULTIPLE_LINE)
+ {
+ if (!($defaultValue instanceof PropertyValueGenerator)) {
+
+ $defaultValue = new PropertyValueGenerator($defaultValue, $defaultValueType, $defaultValueOutputMode);
+ }
+
+ $this->defaultValue = $defaultValue;
+
+ return $this;
+ }
+
+ /**
+ * @return PropertyValueGenerator
+ */
+ public function getDefaultValue()
+ {
+ return $this->defaultValue;
+ }
+
+ /**
+ * @throws Exception\RuntimeException
+ * @return string
+ */
+ public function generate()
+ {
+ $name = $this->getName();
+ $defaultValue = $this->getDefaultValue();
+
+ $output = '';
+
+ if (($docBlock = $this->getDocBlock()) !== null) {
+ $docBlock->setIndentation(' ');
+ $output .= $docBlock->generate();
+ }
+
+ if ($this->isConst()) {
+ if ($defaultValue != null && !$defaultValue->isValidConstantType()) {
+ throw new Exception\RuntimeException(sprintf(
+ 'The property %s is said to be '
+ . 'constant but does not have a valid constant value.',
+ $this->name
+ ));
+ }
+ $output .= $this->indentation . 'const ' . $name . ' = '
+ . (($defaultValue !== null) ? $defaultValue->generate() : 'null;');
+ } else {
+ $output .= $this->indentation
+ . $this->getVisibility()
+ . (($this->isStatic()) ? ' static' : '')
+ . ' $' . $name . ' = '
+ . (($defaultValue !== null) ? $defaultValue->generate() : 'null;');
+ }
+
+ return $output;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Generator/PropertyValueGenerator.php zendframework-2.2.6/library/Zend/Code/Generator/PropertyValueGenerator.php
--- zendframework-1.10.4/library/Zend/Code/Generator/PropertyValueGenerator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Generator/PropertyValueGenerator.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,21 @@
+setValue($value);
+ }
+ if ($type !== self::TYPE_AUTO) {
+ $this->setType($type);
+ }
+ if ($outputMode !== self::OUTPUT_MULTIPLE_LINE) {
+ $this->setOutputMode($outputMode);
+ }
+ if ($constants !== null) {
+ $this->constants = $constants;
+ } else {
+ $this->constants = new ArrayObject();
+ }
+
+ }
+
+ /**
+ * Init constant list by defined and magic constants
+ */
+ public function initEnvironmentConstants()
+ {
+ $constants = array(
+ '__DIR__',
+ '__FILE__',
+ '__LINE__',
+ '__CLASS__',
+ '__TRAIT__',
+ '__METHOD__',
+ '__FUNCTION__',
+ '__NAMESPACE__',
+ '::'
+ );
+ $constants = array_merge($constants, array_keys(get_defined_constants()), $this->constants->getArrayCopy());
+ $this->constants->exchangeArray($constants);
+ }
+
+ /**
+ * Add constant to list
+ *
+ * @param string $constant
+ *
+ * @return $this
+ */
+ public function addConstant($constant)
+ {
+ $this->constants->append($constant);
+
+ return $this;
+ }
+
+ /**
+ * Delete constant from constant list
+ *
+ * @param string $constant
+ *
+ * @return bool
+ */
+ public function deleteConstant($constant)
+ {
+ if (($index = array_search($constant, $this->constants->getArrayCopy())) !== false) {
+ $this->constants->offsetUnset($index);
+ }
+
+ return $index !== false;
+ }
+
+ /**
+ * Return constant list
+ *
+ * @return ArrayObject
+ */
+ public function getConstants()
+ {
+ return $this->constants;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isValidConstantType()
+ {
+ if ($this->type == self::TYPE_AUTO) {
+ $type = $this->getAutoDeterminedType($this->value);
+ } else {
+ $type = $this->type;
+ }
+
+ // valid types for constants
+ $scalarTypes = array(
+ self::TYPE_BOOLEAN,
+ self::TYPE_BOOL,
+ self::TYPE_NUMBER,
+ self::TYPE_INTEGER,
+ self::TYPE_INT,
+ self::TYPE_FLOAT,
+ self::TYPE_DOUBLE,
+ self::TYPE_STRING,
+ self::TYPE_CONSTANT,
+ self::TYPE_NULL
+ );
+
+ return in_array($type, $scalarTypes);
+ }
+
+ /**
+ * @param mixed $value
+ * @return ValueGenerator
+ */
+ public function setValue($value)
+ {
+ $this->value = $value;
+ return $this;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * @param string $type
+ * @return ValueGenerator
+ */
+ public function setType($type)
+ {
+ $this->type = (string) $type;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * @param int $arrayDepth
+ * @return ValueGenerator
+ */
+ public function setArrayDepth($arrayDepth)
+ {
+ $this->arrayDepth = (int) $arrayDepth;
+ return $this;
+ }
+
+ /**
+ * @return int
+ */
+ public function getArrayDepth()
+ {
+ return $this->arrayDepth;
+ }
+
+ /**
+ * @param string $type
+ * @return string
+ */
+ protected function getValidatedType($type)
+ {
+ $types = array(
+ self::TYPE_AUTO,
+ self::TYPE_BOOLEAN,
+ self::TYPE_BOOL,
+ self::TYPE_NUMBER,
+ self::TYPE_INTEGER,
+ self::TYPE_INT,
+ self::TYPE_FLOAT,
+ self::TYPE_DOUBLE,
+ self::TYPE_STRING,
+ self::TYPE_ARRAY,
+ self::TYPE_CONSTANT,
+ self::TYPE_NULL,
+ self::TYPE_OBJECT,
+ self::TYPE_OTHER
+ );
+
+ if (in_array($type, $types)) {
+ return $type;
+ }
+
+ return self::TYPE_AUTO;
+ }
+
+ /**
+ * @param mixed $value
+ * @return string
+ */
+ public function getAutoDeterminedType($value)
+ {
+ switch (gettype($value)) {
+ case 'boolean':
+ return self::TYPE_BOOLEAN;
+ case 'string':
+ foreach ($this->constants as $constant) {
+ if (strpos($value, $constant) !== false) {
+ return self::TYPE_CONSTANT;
+ }
+ }
+ return self::TYPE_STRING;
+ case 'double':
+ case 'float':
+ case 'integer':
+ return self::TYPE_NUMBER;
+ case 'array':
+ return self::TYPE_ARRAY;
+ case 'NULL':
+ return self::TYPE_NULL;
+ case 'object':
+ case 'resource':
+ case 'unknown type':
+ default:
+ return self::TYPE_OTHER;
+ }
+ }
+
+ /**
+ * @throws Exception\RuntimeException
+ * @return string
+ */
+ public function generate()
+ {
+ $type = $this->type;
+
+ if ($type != self::TYPE_AUTO) {
+ $type = $this->getValidatedType($type);
+ }
+
+ $value = $this->value;
+
+ if ($type == self::TYPE_AUTO) {
+ $type = $this->getAutoDeterminedType($value);
+
+ if ($type == self::TYPE_ARRAY) {
+ $rii = new \RecursiveIteratorIterator(
+ $it = new \RecursiveArrayIterator($value),
+ \RecursiveIteratorIterator::SELF_FIRST
+ );
+ foreach ($rii as $curKey => $curValue) {
+ if (!$curValue instanceof ValueGenerator) {
+ $curValue = new self($curValue, self::TYPE_AUTO, self::OUTPUT_MULTIPLE_LINE, $this->getConstants());
+ $rii->getSubIterator()->offsetSet($curKey, $curValue);
+ }
+ $curValue->setArrayDepth($rii->getDepth());
+ }
+ $value = $rii->getSubIterator()->getArrayCopy();
+ }
+
+ }
+
+ $output = '';
+
+ switch ($type) {
+ case self::TYPE_BOOLEAN:
+ case self::TYPE_BOOL:
+ $output .= ($value ? 'true' : 'false');
+ break;
+ case self::TYPE_STRING:
+ $output .= self::escape($value);
+ break;
+ case self::TYPE_NULL:
+ $output .= 'null';
+ break;
+ case self::TYPE_NUMBER:
+ case self::TYPE_INTEGER:
+ case self::TYPE_INT:
+ case self::TYPE_FLOAT:
+ case self::TYPE_DOUBLE:
+ case self::TYPE_CONSTANT:
+ $output .= $value;
+ break;
+ case self::TYPE_ARRAY:
+ $output .= 'array(';
+ $curArrayMultiblock = false;
+ if (count($value) > 1) {
+ $curArrayMultiblock = true;
+ if ($this->outputMode == self::OUTPUT_MULTIPLE_LINE) {
+ $output .= self::LINE_FEED . str_repeat($this->indentation, $this->arrayDepth + 1);
+ }
+ }
+ $outputParts = array();
+ $noKeyIndex = 0;
+ foreach ($value as $n => $v) {
+ /* @var $v ValueGenerator */
+ $v->setArrayDepth($this->arrayDepth + 1);
+ $partV = $v->generate();
+ $short = false;
+ if (is_int($n)) {
+ if ($n === $noKeyIndex) {
+ $short = true;
+ $noKeyIndex++;
+ } else {
+ $noKeyIndex = max($n + 1, $noKeyIndex);
+ }
+ }
+
+ if ($short) {
+ $outputParts[] = $partV;
+ } else {
+ $outputParts[] = (is_int($n) ? $n : self::escape($n)) . ' => ' . $partV;
+ }
+ }
+ $padding = ($this->outputMode == self::OUTPUT_MULTIPLE_LINE)
+ ? self::LINE_FEED . str_repeat($this->indentation, $this->arrayDepth + 1)
+ : ' ';
+ $output .= implode(',' . $padding, $outputParts);
+ if ($curArrayMultiblock == true && $this->outputMode == self::OUTPUT_MULTIPLE_LINE) {
+ $output .= self::LINE_FEED . str_repeat($this->indentation, $this->arrayDepth + 1);
+ }
+ $output .= ')';
+ break;
+ case self::TYPE_OTHER:
+ default:
+ throw new Exception\RuntimeException(sprintf(
+ 'Type "%s" is unknown or cannot be used as property default value.',
+ get_class($value)
+ ));
+ }
+
+ return $output;
+ }
+
+ /**
+ * Quotes value for PHP code.
+ *
+ * @param string $input Raw string.
+ * @param bool $quote Whether add surrounding quotes or not.
+ * @return string PHP-ready code.
+ */
+ public static function escape($input, $quote = true)
+ {
+ $output = addcslashes($input, "'");
+
+ // adds quoting strings
+ if ($quote) {
+ $output = "'" . $output . "'";
+ }
+
+ return $output;
+ }
+
+ /**
+ * @param string $outputMode
+ * @return ValueGenerator
+ */
+ public function setOutputMode($outputMode)
+ {
+ $this->outputMode = (string) $outputMode;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getOutputMode()
+ {
+ return $this->outputMode;
+ }
+
+ public function __toString()
+ {
+ return $this->generate();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/NameInformation.php zendframework-2.2.6/library/Zend/Code/NameInformation.php
--- zendframework-1.10.4/library/Zend/Code/NameInformation.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/NameInformation.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,157 @@
+setNamespace($namespace);
+ }
+ if ($uses) {
+ $this->setUses($uses);
+ }
+ }
+
+ /**
+ * @param string $namespace
+ * @return NameInformation
+ */
+ public function setNamespace($namespace)
+ {
+ $this->namespace = (string) $namespace;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getNamespace()
+ {
+ return $this->namespace;
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasNamespace()
+ {
+ return ($this->namespace != null);
+ }
+
+ /**
+ * @param array $uses
+ * @return NameInformation
+ */
+ public function setUses(array $uses)
+ {
+ $this->uses = array();
+ $this->addUses($uses);
+
+ return $this;
+ }
+
+ /**
+ * @param array $uses
+ * @return NameInformation
+ */
+ public function addUses(array $uses)
+ {
+ foreach ($uses as $use => $as) {
+ if (is_int($use)) {
+ $this->addUse($as);
+ } elseif (is_string($use)) {
+ $this->addUse($use, $as);
+ }
+
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param array|string $use
+ * @param string $as
+ */
+ public function addUse($use, $as = null)
+ {
+ if (is_array($use) && array_key_exists('use', $use) && array_key_exists('as', $use)) {
+ $uses = $use;
+ $use = $uses['use'];
+ $as = $uses['as'];
+ }
+
+ $use = trim($use, '\\');
+ if ($as === null) {
+ $as = trim($use, '\\');
+ $nsSeparatorPosition = strrpos($as, '\\');
+ if ($nsSeparatorPosition !== false && $nsSeparatorPosition !== 0 && $nsSeparatorPosition != strlen($as)) {
+ $as = substr($as, $nsSeparatorPosition + 1);
+ }
+ }
+
+ $this->uses[$use] = $as;
+ }
+
+ /**
+ * @return array
+ */
+ public function getUses()
+ {
+ return $this->uses;
+ }
+
+ /**
+ * @param string $name
+ * @return string
+ */
+ public function resolveName($name)
+ {
+ if ($this->namespace && !$this->uses && strlen($name) > 0 && $name{0} != '\\') {
+ return $this->namespace . '\\' . $name;
+ }
+
+ if (!$this->uses || strlen($name) <= 0 || $name{0} == '\\') {
+ return ltrim($name, '\\');
+ }
+
+ if ($this->namespace || $this->uses) {
+ $firstPart = $name;
+ if (($firstPartEnd = strpos($firstPart, '\\')) !== false) {
+ $firstPart = substr($firstPart, 0, $firstPartEnd);
+ } else {
+ $firstPartEnd = strlen($firstPart);
+ }
+ if (($fqns = array_search($firstPart, $this->uses)) !== false) {
+ return substr_replace($name, $fqns, 0, $firstPartEnd);
+ }
+ if ($this->namespace) {
+ return $this->namespace . '\\' . $name;
+ }
+ }
+
+ return $name;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/README.md zendframework-2.2.6/library/Zend/Code/README.md
--- zendframework-1.10.4/library/Zend/Code/README.md 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/README.md 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+Code Component from ZF2
+=======================
+
+This is the Code component for ZF2.
+
+- File issues at https://github.com/zendframework/zf2/issues
+- Create pull requests against https://github.com/zendframework/zf2
+- Documentation is at http://framework.zend.com/docs
+
+LICENSE
+-------
+
+The files in this archive are released under the [Zend Framework
+license](http://framework.zend.com/license), which is a 3-clause BSD license.
+
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/ClassReflection.php zendframework-2.2.6/library/Zend/Code/Reflection/ClassReflection.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/ClassReflection.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/ClassReflection.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,257 @@
+getFileName());
+
+ return $instance;
+ }
+
+ /**
+ * Return the classes DocBlock reflection object
+ *
+ * @return DocBlockReflection
+ * @throws Exception\ExceptionInterface for missing DocBock or invalid reflection class
+ */
+ public function getDocBlock()
+ {
+ if (isset($this->docBlock)) {
+ return $this->docBlock;
+ }
+
+ if ('' == $this->getDocComment()) {
+ return false;
+ }
+
+ $this->docBlock = new DocBlockReflection($this);
+
+ return $this->docBlock;
+ }
+
+ /**
+ * @param AnnotationManager $annotationManager
+ * @return AnnotationCollection
+ */
+ public function getAnnotations(AnnotationManager $annotationManager)
+ {
+ $docComment = $this->getDocComment();
+
+ if ($docComment == '') {
+ return false;
+ }
+
+ if ($this->annotations) {
+ return $this->annotations;
+ }
+
+ $fileScanner = $this->createFileScanner($this->getFileName());
+ $nameInformation = $fileScanner->getClassNameInformation($this->getName());
+
+ if (!$nameInformation) {
+ return false;
+ }
+
+ $this->annotations = new AnnotationScanner($annotationManager, $docComment, $nameInformation);
+
+ return $this->annotations;
+ }
+
+ /**
+ * Return the start line of the class
+ *
+ * @param bool $includeDocComment
+ * @return int
+ */
+ public function getStartLine($includeDocComment = false)
+ {
+ if ($includeDocComment && $this->getDocComment() != '') {
+ return $this->getDocBlock()->getStartLine();
+ }
+
+ return parent::getStartLine();
+ }
+
+ /**
+ * Return the contents of the class
+ *
+ * @param bool $includeDocBlock
+ * @return string
+ */
+ public function getContents($includeDocBlock = true)
+ {
+ $fileName = $this->getFileName();
+
+ if (false === $fileName || ! file_exists($fileName)) {
+ return '';
+ }
+
+ $filelines = file($fileName);
+ $startnum = $this->getStartLine($includeDocBlock);
+ $endnum = $this->getEndLine() - $this->getStartLine();
+
+ // Ensure we get between the open and close braces
+ $lines = array_slice($filelines, $startnum, $endnum);
+ array_unshift($lines, $filelines[$startnum-1]);
+
+ return strstr(implode('', $lines), '{');
+ }
+
+ /**
+ * Get all reflection objects of implemented interfaces
+ *
+ * @return ClassReflection[]
+ */
+ public function getInterfaces()
+ {
+ $phpReflections = parent::getInterfaces();
+ $zendReflections = array();
+ while ($phpReflections && ($phpReflection = array_shift($phpReflections))) {
+ $instance = new ClassReflection($phpReflection->getName());
+ $zendReflections[] = $instance;
+ unset($phpReflection);
+ }
+ unset($phpReflections);
+
+ return $zendReflections;
+ }
+
+ /**
+ * Return method reflection by name
+ *
+ * @param string $name
+ * @return MethodReflection
+ */
+ public function getMethod($name)
+ {
+ $method = new MethodReflection($this->getName(), parent::getMethod($name)->getName());
+
+ return $method;
+ }
+
+ /**
+ * Get reflection objects of all methods
+ *
+ * @param string $filter
+ * @return MethodReflection[]
+ */
+ public function getMethods($filter = -1)
+ {
+ $methods = array();
+ foreach (parent::getMethods($filter) as $method) {
+ $instance = new MethodReflection($this->getName(), $method->getName());
+ $methods[] = $instance;
+ }
+
+ return $methods;
+ }
+
+ /**
+ * Get parent reflection class of reflected class
+ *
+ * @return ClassReflection|bool
+ */
+ public function getParentClass()
+ {
+ $phpReflection = parent::getParentClass();
+ if ($phpReflection) {
+ $zendReflection = new ClassReflection($phpReflection->getName());
+ unset($phpReflection);
+
+ return $zendReflection;
+ }
+
+ return false;
+ }
+
+ /**
+ * Return reflection property of this class by name
+ *
+ * @param string $name
+ * @return PropertyReflection
+ */
+ public function getProperty($name)
+ {
+ $phpReflection = parent::getProperty($name);
+ $zendReflection = new PropertyReflection($this->getName(), $phpReflection->getName());
+ unset($phpReflection);
+
+ return $zendReflection;
+ }
+
+ /**
+ * Return reflection properties of this class
+ *
+ * @param int $filter
+ * @return PropertyReflection[]
+ */
+ public function getProperties($filter = -1)
+ {
+ $phpReflections = parent::getProperties($filter);
+ $zendReflections = array();
+ while ($phpReflections && ($phpReflection = array_shift($phpReflections))) {
+ $instance = new PropertyReflection($this->getName(), $phpReflection->getName());
+ $zendReflections[] = $instance;
+ unset($phpReflection);
+ }
+ unset($phpReflections);
+
+ return $zendReflections;
+ }
+
+ public function toString()
+ {
+ return parent::__toString();
+ }
+
+ public function __toString()
+ {
+ return parent::__toString();
+ }
+
+ /**
+ * Creates a new FileScanner instance.
+ *
+ * By having this as a seperate method it allows the method to be overridden
+ * if a different FileScanner is needed.
+ *
+ * @param string $filename
+ *
+ * @return FileScanner
+ */
+ protected function createFileScanner($filename)
+ {
+ return new FileScanner($filename);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/AuthorTag.php zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/AuthorTag.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/AuthorTag.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/AuthorTag.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,74 @@
+]*)\>)?(.*)$/u', $tagDocblockLine, $match)) {
+ return;
+ }
+
+ if ($match[1] !== '') {
+ $this->authorName = rtrim($match[1]);
+ }
+
+ if (isset($match[3]) && $match[3] !== '') {
+ $this->authorEmail = $match[3];
+ }
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getAuthorName()
+ {
+ return $this->authorName;
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getAuthorEmail()
+ {
+ return $this->authorEmail;
+ }
+
+ public function __toString()
+ {
+ return 'DocBlock Tag [ * @' . $this->getName() . ' ]' . PHP_EOL;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/GenericTag.php zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/GenericTag.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/GenericTag.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/GenericTag.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,107 @@
+contentSplitCharacter = $contentSplitCharacter;
+ }
+
+ /**
+ * @param string $tagDocBlockLine
+ * @return void
+ */
+ public function initialize($tagDocBlockLine)
+ {
+ $this->parse($tagDocBlockLine);
+ }
+
+ /**
+ * Get annotation tag name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param string $name
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * @return string
+ */
+ public function getContent()
+ {
+ return $this->content;
+ }
+
+ /**
+ * @param int $position
+ * @return string
+ */
+ public function returnValue($position)
+ {
+ return $this->values[$position];
+ }
+
+ /**
+ * Serialize to string
+ *
+ * Required by Reflector
+ *
+ * @todo What should this do?
+ * @return string
+ */
+ public function __toString()
+ {
+ return 'DocBlock Tag [ * @' . $this->name . ' ]' . PHP_EOL;
+ }
+
+ /**
+ * @param string $docBlockLine
+ */
+ protected function parse($docBlockLine)
+ {
+ $this->content = trim($docBlockLine);
+ $this->values = explode($this->contentSplitCharacter, $docBlockLine);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/LicenseTag.php zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/LicenseTag.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/LicenseTag.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/LicenseTag.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,74 @@
+url = trim($match[1]);
+ }
+
+ if (isset($match[2]) && $match[2] !== '') {
+ $this->licenseName = $match[2];
+ }
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getUrl()
+ {
+ return $this->url;
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getLicenseName()
+ {
+ return $this->licenseName;
+ }
+
+ public function __toString()
+ {
+ return 'DocBlock Tag [ * @' . $this->getName() . ' ]' . PHP_EOL;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/MethodTag.php zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/MethodTag.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/MethodTag.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/MethodTag.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,124 @@
+isStatic = true;
+ }
+
+ if ($match[2] !== '') {
+ $this->types = explode('|', rtrim($match[2]));
+ }
+
+ $this->methodName = $match[3];
+
+ if ($match[4] !== '') {
+ $this->description = $match[4];
+ }
+ }
+
+ /**
+ * Get return value type
+ *
+ * @return null|string
+ * @deprecated 2.0.4 use getTypes instead
+ */
+ public function getReturnType()
+ {
+ if (empty($this->types)) {
+ return null;
+ }
+
+ return $this->types[0];
+ }
+
+ public function getTypes()
+ {
+ return $this->types;
+ }
+
+ /**
+ * @return string
+ */
+ public function getMethodName()
+ {
+ return $this->methodName;
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Is method static
+ *
+ * @return bool
+ */
+ public function isStatic()
+ {
+ return $this->isStatic;
+ }
+
+ public function __toString()
+ {
+ return 'DocBlock Tag [ * @' . $this->getName() . ' ]' . PHP_EOL;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/ParamTag.php zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/ParamTag.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/ParamTag.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/ParamTag.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,98 @@
+types = explode('|', $matches[1]);
+
+ if (isset($matches[2])) {
+ $this->variableName = $matches[2];
+ }
+
+ if (isset($matches[3])) {
+ $this->description = trim(preg_replace('#\s+#', ' ', $matches[3]));
+ }
+ }
+
+ /**
+ * Get parameter variable type
+ *
+ * @return string
+ * @deprecated 2.0.4 use getTypes instead
+ */
+ public function getType()
+ {
+ if (empty($this->types)) {
+ return '';
+ }
+
+ return $this->types[0];
+ }
+
+ public function getTypes()
+ {
+ return $this->types;
+ }
+
+ /**
+ * Get parameter name
+ *
+ * @return string
+ */
+ public function getVariableName()
+ {
+ return $this->variableName;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/PhpDocTypedTagInterface.php zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/PhpDocTypedTagInterface.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/PhpDocTypedTagInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/PhpDocTypedTagInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,20 @@
+types = explode('|', rtrim($match[1]));
+ }
+
+ if ($match[2] !== '') {
+ $this->propertyName = $match[2];
+ }
+
+ if ($match[3] !== '') {
+ $this->description = $match[3];
+ }
+ }
+
+ /**
+ * @return null|string
+ * @deprecated 2.0.4 use getTypes instead
+ */
+ public function getType()
+ {
+ if (empty($this->types)) {
+ return null;
+ }
+
+ return $this->types[0];
+ }
+
+ public function getTypes()
+ {
+ return $this->types;
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getPropertyName()
+ {
+ return $this->propertyName;
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ public function __toString()
+ {
+ return 'DocBlock Tag [ * @' . $this->getName() . ' ]' . PHP_EOL;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/ReturnTag.php zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/ReturnTag.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/ReturnTag.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/ReturnTag.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,75 @@
+types = explode('|', $matches[1]);
+
+ if (isset($matches[2])) {
+ $this->description = trim(preg_replace('#\s+#', ' ', $matches[2]));
+ }
+ }
+
+ /**
+ * @return string
+ * @deprecated 2.0.4 use getTypes instead
+ */
+ public function getType()
+ {
+ if (empty($this->types)) {
+ return '';
+ }
+
+ return $this->types[0];
+ }
+
+ public function getTypes()
+ {
+ return $this->types;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/TagInterface.php zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/TagInterface.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/Tag/TagInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/Tag/TagInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,24 @@
+types = explode('|', $matches[1]);
+
+ if (isset($matches[2])) {
+ $this->description = $matches[2];
+ }
+ }
+
+ /**
+ * Get return variable type
+ *
+ * @return string
+ * @deprecated 2.0.4 use getTypes instead
+ */
+ public function getType()
+ {
+ return implode('|', $this->getTypes());
+ }
+
+ /**
+ * @return array
+ */
+ public function getTypes()
+ {
+ return $this->types;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/TagManager.php zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/TagManager.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/DocBlock/TagManager.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/DocBlock/TagManager.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,124 @@
+addTagPrototype($prototype);
+ }
+ } elseif ($prototypes === self::USE_DEFAULT_PROTOTYPES) {
+ $this->useDefaultPrototypes();
+ }
+ }
+
+ /**
+ * @return void
+ */
+ public function useDefaultPrototypes()
+ {
+ $this->addTagPrototype(new Tag\ParamTag());
+ $this->addTagPrototype(new Tag\ReturnTag());
+ $this->addTagPrototype(new Tag\MethodTag());
+ $this->addTagPrototype(new Tag\PropertyTag());
+ $this->addTagPrototype(new Tag\AuthorTag());
+ $this->addTagPrototype(new Tag\LicenseTag());
+ $this->addTagPrototype(new Tag\ThrowsTag());
+ $this->addTagPrototype(new Tag\GenericTag());
+ }
+
+ /**
+ * @param TagInterface $tag
+ * @throws Exception\InvalidArgumentException
+ */
+ public function addTagPrototype(TagInterface $tag)
+ {
+ $tagName = str_replace(array('-', '_'), '', $tag->getName());
+
+ if (in_array($tagName, $this->tagNames)) {
+ throw new Exception\InvalidArgumentException('A tag with this name already exists in this manager');
+ }
+
+ $this->tagNames[] = $tagName;
+ $this->tags[] = $tag;
+
+ if ($tag instanceof GenericTag) {
+ $this->genericTag = $tag;
+ }
+ }
+
+ /**
+ * @param string $tagName
+ * @return bool
+ */
+ public function hasTag($tagName)
+ {
+ // otherwise, only if its name exists as a key
+ return in_array(str_replace(array('-', '_'), '', $tagName), $this->tagNames);
+ }
+
+ /**
+ * @param string $tagName
+ * @param string $content
+ * @return GenericTag
+ * @throws Exception\RuntimeException
+ */
+ public function createTag($tagName, $content = null)
+ {
+ $tagName = str_replace(array('-', '_'), '', $tagName);
+
+ if (!$this->hasTag($tagName) && !isset($this->genericTag)) {
+ throw new Exception\RuntimeException('This tag name is not supported by this tag manager');
+ }
+
+ $index = array_search($tagName, $this->tagNames);
+
+ /* @var TagInterface $tag */
+ $tag = ($index !== false) ? $this->tags[$index] : $this->genericTag;
+
+ $newTag = clone $tag;
+ if ($content) {
+ $newTag->initialize($content);
+ }
+
+ if ($newTag instanceof GenericTag) {
+ $newTag->setName($tagName);
+ }
+
+ return $newTag;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/DocBlockReflection.php zendframework-2.2.6/library/Zend/Code/Reflection/DocBlockReflection.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/DocBlockReflection.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/DocBlockReflection.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,292 @@
+tagManager = $tagManager ? : new DocBlockTagManager(DocBlockTagManager::USE_DEFAULT_PROTOTYPES);
+
+ if ($commentOrReflector instanceof Reflector) {
+ $this->reflector = $commentOrReflector;
+ if (!method_exists($commentOrReflector, 'getDocComment')) {
+ throw new Exception\InvalidArgumentException('Reflector must contain method "getDocComment"');
+ }
+ /* @var MethodReflection $commentOrReflector */
+ $this->docComment = $commentOrReflector->getDocComment();
+
+ // determine line numbers
+ $lineCount = substr_count($this->docComment, "\n");
+ $this->startLine = $this->reflector->getStartLine() - $lineCount - 1;
+ $this->endLine = $this->reflector->getStartLine() - 1;
+
+ } elseif (is_string($commentOrReflector)) {
+ $this->docComment = $commentOrReflector;
+ } else {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s must have a (string) DocComment or a Reflector in the constructor',
+ get_class($this)
+ ));
+ }
+
+ if ($this->docComment == '') {
+ throw new Exception\InvalidArgumentException('DocComment cannot be empty');
+ }
+
+ $this->reflect();
+ }
+
+ /**
+ * Retrieve contents of DocBlock
+ *
+ * @return string
+ */
+ public function getContents()
+ {
+ $this->reflect();
+
+ return $this->cleanDocComment;
+ }
+
+ /**
+ * Get start line (position) of DocBlock
+ *
+ * @return int
+ */
+ public function getStartLine()
+ {
+ $this->reflect();
+
+ return $this->startLine;
+ }
+
+ /**
+ * Get last line (position) of DocBlock
+ *
+ * @return int
+ */
+ public function getEndLine()
+ {
+ $this->reflect();
+
+ return $this->endLine;
+ }
+
+ /**
+ * Get DocBlock short description
+ *
+ * @return string
+ */
+ public function getShortDescription()
+ {
+ $this->reflect();
+
+ return $this->shortDescription;
+ }
+
+ /**
+ * Get DocBlock long description
+ *
+ * @return string
+ */
+ public function getLongDescription()
+ {
+ $this->reflect();
+
+ return $this->longDescription;
+ }
+
+ /**
+ * Does the DocBlock contain the given annotation tag?
+ *
+ * @param string $name
+ * @return bool
+ */
+ public function hasTag($name)
+ {
+ $this->reflect();
+ foreach ($this->tags as $tag) {
+ if ($tag->getName() == $name) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Retrieve the given DocBlock tag
+ *
+ * @param string $name
+ * @return DocBlockTagInterface|false
+ */
+ public function getTag($name)
+ {
+ $this->reflect();
+ foreach ($this->tags as $tag) {
+ if ($tag->getName() == $name) {
+ return $tag;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Get all DocBlock annotation tags
+ *
+ * @param string $filter
+ * @return DocBlockTagInterface[]
+ */
+ public function getTags($filter = null)
+ {
+ $this->reflect();
+ if ($filter === null || !is_string($filter)) {
+ return $this->tags;
+ }
+
+ $returnTags = array();
+ foreach ($this->tags as $tag) {
+ if ($tag->getName() == $filter) {
+ $returnTags[] = $tag;
+ }
+ }
+
+ return $returnTags;
+ }
+
+ /**
+ * Parse the DocBlock
+ *
+ * @return void
+ */
+ protected function reflect()
+ {
+ if ($this->isReflected) {
+ return;
+ }
+
+ $docComment = $this->docComment; // localize variable
+
+ // create a clean docComment
+ $this->cleanDocComment = preg_replace("#[ \t]*(?:/\*\*|\*/|\*)[ ]{0,1}(.*)?#", '$1', $docComment);
+ $this->cleanDocComment = ltrim($this->cleanDocComment,
+ "\r\n"); // @todo should be changed to remove first and last empty line
+
+ $scanner = new DocBlockScanner($docComment);
+ $this->shortDescription = ltrim($scanner->getShortDescription());
+ $this->longDescription = ltrim($scanner->getLongDescription());
+
+ foreach ($scanner->getTags() as $tag) {
+ $this->tags[] = $this->tagManager->createTag(ltrim($tag['name'], '@'), ltrim($tag['value']));
+ }
+
+ $this->isReflected = true;
+ }
+
+ public function toString()
+ {
+ $str = "DocBlock [ /* DocBlock */ ] {" . PHP_EOL . PHP_EOL;
+ $str .= " - Tags [" . count($this->tags) . "] {" . PHP_EOL;
+
+ foreach ($this->tags AS $tag) {
+ $str .= " " . $tag;
+ }
+
+ $str .= " }" . PHP_EOL;
+ $str .= "}" . PHP_EOL;
+
+ return $str;
+ }
+
+ /**
+ * Serialize to string
+ *
+ * Required by the Reflector interface
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->toString();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/Exception/BadMethodCallException.php zendframework-2.2.6/library/Zend/Code/Reflection/Exception/BadMethodCallException.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/Exception/BadMethodCallException.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/Exception/BadMethodCallException.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,16 @@
+filePath = $fileRealPath;
+ $this->reflect();
+ }
+
+ /**
+ * Required by the Reflector interface.
+ *
+ * @todo What should this do?
+ * @return null
+ */
+ public static function export()
+ {
+ return null;
+ }
+
+ /**
+ * Return the file name of the reflected file
+ *
+ * @return string
+ */
+ public function getFileName()
+ {
+ // @todo get file name from path
+ return $this->filePath;
+ }
+
+ /**
+ * Get the start line - Always 1, staying consistent with the Reflection API
+ *
+ * @return int
+ */
+ public function getStartLine()
+ {
+ return $this->startLine;
+ }
+
+ /**
+ * Get the end line / number of lines
+ *
+ * @return int
+ */
+ public function getEndLine()
+ {
+ return $this->endLine;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDocComment()
+ {
+ return $this->docComment;
+ }
+
+ /**
+ * @return DocBlockReflection
+ */
+ public function getDocBlock()
+ {
+ if (!($docComment = $this->getDocComment())) {
+ return false;
+ }
+
+ $instance = new DocBlockReflection($docComment);
+
+ return $instance;
+ }
+
+ /**
+ * @return array
+ */
+ public function getNamespaces()
+ {
+ return $this->namespaces;
+ }
+
+ /**
+ * @return string
+ */
+ public function getNamespace()
+ {
+ if (count($this->namespaces) == 0) {
+ return null;
+ }
+
+ return $this->namespaces[0];
+ }
+
+ /**
+ * @return array
+ */
+ public function getUses()
+ {
+ return $this->uses;
+ }
+
+ /**
+ * Return the reflection classes of the classes found inside this file
+ *
+ * @return ClassReflection[]
+ */
+ public function getClasses()
+ {
+ $classes = array();
+ foreach ($this->classes as $class) {
+ $classes[] = new ClassReflection($class);
+ }
+
+ return $classes;
+ }
+
+ /**
+ * Return the reflection functions of the functions found inside this file
+ *
+ * @return FunctionReflection[]
+ */
+ public function getFunctions()
+ {
+ $functions = array();
+ foreach ($this->functions as $function) {
+ $functions[] = new FunctionReflection($function);
+ }
+
+ return $functions;
+ }
+
+ /**
+ * Retrieve the reflection class of a given class found in this file
+ *
+ * @param null|string $name
+ * @return ClassReflection
+ * @throws Exception\InvalidArgumentException for invalid class name or invalid reflection class
+ */
+ public function getClass($name = null)
+ {
+ if (null === $name) {
+ reset($this->classes);
+ $selected = current($this->classes);
+
+ return new ClassReflection($selected);
+ }
+
+ if (in_array($name, $this->classes)) {
+ return new ClassReflection($name);
+ }
+
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Class by name %s not found.',
+ $name
+ ));
+ }
+
+ /**
+ * Return the full contents of file
+ *
+ * @return string
+ */
+ public function getContents()
+ {
+ return file_get_contents($this->filePath);
+ }
+
+ public function toString()
+ {
+ return ''; // @todo
+ }
+
+ /**
+ * Serialize to string
+ *
+ * Required by the Reflector interface
+ *
+ * @todo What should this serialization look like?
+ * @return string
+ */
+ public function __toString()
+ {
+ return '';
+ }
+
+ /**
+ * This method does the work of "reflecting" the file
+ *
+ * Uses Zend\Code\Scanner\FileScanner to gather file information
+ *
+ * @return void
+ */
+ protected function reflect()
+ {
+ $scanner = new CachingFileScanner($this->filePath);
+ $this->docComment = $scanner->getDocComment();
+ $this->requiredFiles = $scanner->getIncludes();
+ $this->classes = $scanner->getClassNames();
+ $this->namespaces = $scanner->getNamespaces();
+ $this->uses = $scanner->getUses();
+ }
+
+ /**
+ * Validate / check a file level DocBlock
+ *
+ * @param array $tokens Array of tokenizer tokens
+ * @return void
+ */
+ protected function checkFileDocBlock($tokens)
+ {
+ foreach ($tokens as $token) {
+ $type = $token[0];
+ $value = $token[1];
+ $lineNum = $token[2];
+ if (($type == T_OPEN_TAG) || ($type == T_WHITESPACE)) {
+ continue;
+ } elseif ($type == T_DOC_COMMENT) {
+ $this->docComment = $value;
+ $this->startLine = $lineNum + substr_count($value, "\n") + 1;
+
+ return;
+ } else {
+ // Only whitespace is allowed before file DocBlocks
+ return;
+ }
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/FunctionReflection.php zendframework-2.2.6/library/Zend/Code/Reflection/FunctionReflection.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/FunctionReflection.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/FunctionReflection.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,130 @@
+getDocComment())) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s does not have a DocBlock',
+ $this->getName()
+ ));
+ }
+
+ $instance = new DocBlockReflection($comment);
+
+ return $instance;
+ }
+
+ /**
+ * Get start line (position) of function
+ *
+ * @param bool $includeDocComment
+ * @return int
+ */
+ public function getStartLine($includeDocComment = false)
+ {
+ if ($includeDocComment) {
+ if ($this->getDocComment() != '') {
+ return $this->getDocBlock()->getStartLine();
+ }
+ }
+
+ return parent::getStartLine();
+ }
+
+ /**
+ * Get contents of function
+ *
+ * @param bool $includeDocBlock
+ * @return string
+ */
+ public function getContents($includeDocBlock = true)
+ {
+ $fileName = $this->getFileName();
+
+ if (false === $fileName || ! file_exists($fileName)) {
+ return '';
+ }
+
+ return implode("\n",
+ array_splice(
+ file($fileName),
+ $this->getStartLine($includeDocBlock),
+ ($this->getEndLine() - $this->getStartLine()),
+ true
+ )
+ );
+ }
+
+ /**
+ * Get function parameters
+ *
+ * @return ParameterReflection[]
+ */
+ public function getParameters()
+ {
+ $phpReflections = parent::getParameters();
+ $zendReflections = array();
+ while ($phpReflections && ($phpReflection = array_shift($phpReflections))) {
+ $instance = new ParameterReflection($this->getName(), $phpReflection->getName());
+ $zendReflections[] = $instance;
+ unset($phpReflection);
+ }
+ unset($phpReflections);
+
+ return $zendReflections;
+ }
+
+ /**
+ * Get return type tag
+ *
+ * @throws Exception\InvalidArgumentException
+ * @return ReturnTag
+ */
+ public function getReturn()
+ {
+ $docBlock = $this->getDocBlock();
+ if (!$docBlock->hasTag('return')) {
+ throw new Exception\InvalidArgumentException(
+ 'Function does not specify an @return annotation tag; cannot determine return type'
+ );
+ }
+
+ $tag = $docBlock->getTag('return');
+ return new DocBlockReflection('@return ' . $tag->getDescription());
+ }
+
+ public function toString()
+ {
+ return $this->__toString();
+ }
+
+ /**
+ * Required due to bug in php
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return parent::__toString();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/MethodReflection.php zendframework-2.2.6/library/Zend/Code/Reflection/MethodReflection.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/MethodReflection.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/MethodReflection.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,201 @@
+getDocComment()) {
+ return false;
+ }
+
+ $instance = new DocBlockReflection($this);
+
+ return $instance;
+ }
+
+ /**
+ * @param AnnotationManager $annotationManager
+ * @return AnnotationScanner
+ */
+ public function getAnnotations(AnnotationManager $annotationManager)
+ {
+ if (($docComment = $this->getDocComment()) == '') {
+ return false;
+ }
+
+ if ($this->annotations) {
+ return $this->annotations;
+ }
+
+ $cachingFileScanner = $this->createFileScanner($this->getFileName());
+ $nameInformation = $cachingFileScanner->getClassNameInformation($this->getDeclaringClass()->getName());
+
+ if (!$nameInformation) {
+ return false;
+ }
+
+ $this->annotations = new AnnotationScanner($annotationManager, $docComment, $nameInformation);
+
+ return $this->annotations;
+ }
+
+ /**
+ * Get start line (position) of method
+ *
+ * @param bool $includeDocComment
+ * @return int
+ */
+ public function getStartLine($includeDocComment = false)
+ {
+ if ($includeDocComment) {
+ if ($this->getDocComment() != '') {
+ return $this->getDocBlock()->getStartLine();
+ }
+ }
+
+ return parent::getStartLine();
+ }
+
+ /**
+ * Get reflection of declaring class
+ *
+ * @return ClassReflection
+ */
+ public function getDeclaringClass()
+ {
+ $phpReflection = parent::getDeclaringClass();
+ $zendReflection = new ClassReflection($phpReflection->getName());
+ unset($phpReflection);
+
+ return $zendReflection;
+ }
+
+ /**
+ * Get all method parameter reflection objects
+ *
+ * @return ParameterReflection[]
+ */
+ public function getParameters()
+ {
+ $phpReflections = parent::getParameters();
+ $zendReflections = array();
+ while ($phpReflections && ($phpReflection = array_shift($phpReflections))) {
+ $instance = new ParameterReflection(array(
+ $this->getDeclaringClass()->getName(),
+ $this->getName()),
+ $phpReflection->getName()
+ );
+ $zendReflections[] = $instance;
+ unset($phpReflection);
+ }
+ unset($phpReflections);
+
+ return $zendReflections;
+ }
+
+ /**
+ * Get method contents
+ *
+ * @param bool $includeDocBlock
+ * @return string
+ */
+ public function getContents($includeDocBlock = true)
+ {
+ $fileName = $this->getFileName();
+
+ if ((class_exists($this->class) && !$fileName) || ! file_exists($fileName)) {
+ return ''; // probably from eval'd code, return empty
+ }
+
+ $fileContents = file($fileName);
+ $startNum = $this->getStartLine($includeDocBlock);
+ $endNum = ($this->getEndLine() - $this->getStartLine());
+
+ return implode("\n", array_splice($fileContents, $startNum, $endNum, true));
+ }
+
+ /**
+ * Get method body
+ *
+ * @return string
+ */
+ public function getBody()
+ {
+ $fileName = $this->getDeclaringClass()->getFileName();
+
+ if (false === $fileName || ! file_exists($fileName)) {
+ return '';
+ }
+
+ $lines = array_slice(
+ file($fileName, FILE_IGNORE_NEW_LINES),
+ $this->getStartLine(),
+ ($this->getEndLine() - $this->getStartLine()),
+ true
+ );
+
+ $firstLine = array_shift($lines);
+
+ if (trim($firstLine) !== '{') {
+ array_unshift($lines, $firstLine);
+ }
+
+ $lastLine = array_pop($lines);
+
+ if (trim($lastLine) !== '}') {
+ array_push($lines, $lastLine);
+ }
+
+ // just in case we had code on the bracket lines
+ return rtrim(ltrim(implode("\n", $lines), '{'), '}');
+ }
+
+ public function toString()
+ {
+ return parent::__toString();
+ }
+
+ public function __toString()
+ {
+ return parent::__toString();
+ }
+
+ /**
+ * Creates a new FileScanner instance.
+ *
+ * By having this as a seperate method it allows the method to be overridden
+ * if a different FileScanner is needed.
+ *
+ * @param string $filename
+ *
+ * @return FileScanner
+ */
+ protected function createFileScanner($filename)
+ {
+ return new CachingFileScanner($filename);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/ParameterReflection.php zendframework-2.2.6/library/Zend/Code/Reflection/ParameterReflection.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/ParameterReflection.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/ParameterReflection.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,110 @@
+getName());
+ unset($phpReflection);
+
+ return $zendReflection;
+ }
+
+ /**
+ * Get class reflection object
+ *
+ * @return ClassReflection
+ */
+ public function getClass()
+ {
+ $phpReflection = parent::getClass();
+ if ($phpReflection == null) {
+ return null;
+ }
+
+ $zendReflection = new ClassReflection($phpReflection->getName());
+ unset($phpReflection);
+
+ return $zendReflection;
+ }
+
+ /**
+ * Get declaring function reflection object
+ *
+ * @return FunctionReflection|MethodReflection
+ */
+ public function getDeclaringFunction()
+ {
+ $phpReflection = parent::getDeclaringFunction();
+ if ($phpReflection instanceof \ReflectionMethod) {
+ $zendReflection = new MethodReflection($this->getDeclaringClass()->getName(), $phpReflection->getName());
+ } else {
+ $zendReflection = new FunctionReflection($phpReflection->getName());
+ }
+ unset($phpReflection);
+
+ return $zendReflection;
+ }
+
+ /**
+ * Get parameter type
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ if ($this->isArray()) {
+ return 'array';
+ } elseif (method_exists($this, 'isCallable') && $this->isCallable()) {
+ return 'callable';
+ }
+
+ if (($class = $this->getClass()) instanceof \ReflectionClass) {
+ return $class->getName();
+ }
+
+ $docBlock = $this->getDeclaringFunction()->getDocBlock();
+ if (!$docBlock instanceof DocBlockReflection) {
+ return null;
+ }
+
+ $params = $docBlock->getTags('param');
+ if (isset($params[$this->getPosition()])) {
+ return $params[$this->getPosition()]->getType();
+ }
+
+ return null;
+ }
+
+ public function toString()
+ {
+ return parent::__toString();
+ }
+
+ public function __toString()
+ {
+ return parent::__toString();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/PropertyReflection.php zendframework-2.2.6/library/Zend/Code/Reflection/PropertyReflection.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/PropertyReflection.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/PropertyReflection.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,111 @@
+getName());
+ unset($phpReflection);
+
+ return $zendReflection;
+ }
+
+ /**
+ * Get DocBlock comment
+ *
+ * @return string|false False if no DocBlock defined
+ */
+ public function getDocComment()
+ {
+ return parent::getDocComment();
+ }
+
+ /**
+ * @return false|DocBlockReflection
+ */
+ public function getDocBlock()
+ {
+ if (!($docComment = $this->getDocComment())) {
+ return false;
+ }
+
+ $docBlockReflection = new DocBlockReflection($docComment);
+
+ return $docBlockReflection;
+ }
+
+ /**
+ * @param AnnotationManager $annotationManager
+ * @return AnnotationScanner
+ */
+ public function getAnnotations(AnnotationManager $annotationManager)
+ {
+ if (null !== $this->annotations) {
+ return $this->annotations;
+ }
+
+ if (($docComment = $this->getDocComment()) == '') {
+ return false;
+ }
+
+ $class = $this->getDeclaringClass();
+ $cachingFileScanner = $this->createFileScanner($class->getFileName());
+ $nameInformation = $cachingFileScanner->getClassNameInformation($class->getName());
+
+ if (!$nameInformation) {
+ return false;
+ }
+
+ $this->annotations = new AnnotationScanner($annotationManager, $docComment, $nameInformation);
+
+ return $this->annotations;
+ }
+
+ public function toString()
+ {
+ return $this->__toString();
+ }
+
+ /**
+ * Creates a new FileScanner instance.
+ *
+ * By having this as a seperate method it allows the method to be overridden
+ * if a different FileScanner is needed.
+ *
+ * @param string $filename
+ *
+ * @return FileScanner
+ */
+ protected function createFileScanner($filename)
+ {
+ return new CachingFileScanner($filename);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Reflection/ReflectionInterface.php zendframework-2.2.6/library/Zend/Code/Reflection/ReflectionInterface.php
--- zendframework-1.10.4/library/Zend/Code/Reflection/ReflectionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Reflection/ReflectionInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,17 @@
+directories as $scanner) {
+ $classes += $scanner->getClasses();
+ }
+ if ($returnScannerClass) {
+ foreach ($classes as $index => $class) {
+ $classes[$index] = $this->getClass($class, $returnScannerClass, $returnDerivedScannerClass);
+ }
+ }
+
+ return $classes;
+ }
+
+ /**
+ * @param string $class
+ * @return bool
+ */
+ public function hasClass($class)
+ {
+ foreach ($this->directories as $scanner) {
+ if ($scanner->hasClass($class)) {
+ break;
+ } else {
+ unset($scanner);
+ }
+ }
+
+ return (isset($scanner));
+ }
+
+ /**
+ * @param string $class
+ * @param bool $returnScannerClass
+ * @param bool $returnDerivedScannerClass
+ * @return ClassScanner|DerivedClassScanner
+ * @throws Exception\RuntimeException
+ */
+ public function getClass($class, $returnScannerClass = true, $returnDerivedScannerClass = false)
+ {
+ foreach ($this->directories as $scanner) {
+ if ($scanner->hasClass($class)) {
+ break;
+ } else {
+ unset($scanner);
+ }
+ }
+
+ if (!isset($scanner)) {
+ throw new Exception\RuntimeException('Class by that name was not found.');
+ }
+
+ $classScanner = $scanner->getClass($class);
+
+ return new DerivedClassScanner($classScanner, $this);
+ }
+
+ /**
+ * @param bool $returnScannerClass
+ */
+ public function getFunctions($returnScannerClass = false)
+ {
+ $this->scan();
+
+ if (!$returnScannerClass) {
+ $functions = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] == 'function') {
+ $functions[] = $info['name'];
+ }
+ }
+
+ return $functions;
+ }
+ $scannerClass = new FunctionScanner();
+ // @todo
+ }
+
+ /*
+ public static function export()
+ {
+ // @todo
+ }
+
+ public function __toString()
+ {
+ // @todo
+ }
+ */
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/AnnotationScanner.php zendframework-2.2.6/library/Zend/Code/Scanner/AnnotationScanner.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/AnnotationScanner.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/AnnotationScanner.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,337 @@
+annotationManager = $annotationManager;
+ $this->docComment = $docComment;
+ $this->nameInformation = $nameInformation;
+ $this->scan($this->tokenize());
+ }
+
+ /**
+ * @param NameInformation $nameInformation
+ */
+ public function setNameInformation(NameInformation $nameInformation)
+ {
+ $this->nameInformation = $nameInformation;
+ }
+
+ /**
+ * @param array $tokens
+ */
+ protected function scan(array $tokens)
+ {
+ $annotations = array();
+ $annotationIndex = -1;
+ $contentEnd = false;
+
+ reset($tokens);
+
+ SCANNER_TOP:
+ $token = current($tokens);
+
+ switch ($token[0]) {
+
+ case 'ANNOTATION_CLASS':
+
+ $contentEnd = false;
+ $annotationIndex++;
+ $class = substr($token[1], 1);
+ $class = $this->nameInformation->resolveName($class);
+ $annotations[$annotationIndex] = array($class, null);
+ goto SCANNER_CONTINUE;
+
+ case 'ANNOTATION_CONTENT_START':
+
+ $annotations[$annotationIndex][1] = '';
+
+ case 'ANNOTATION_CONTENT_END':
+ case 'ANNOTATION_CONTENT':
+ case 'ANNOTATION_WHITESPACE':
+ case 'ANNOTATION_NEWLINE':
+
+ if (!$contentEnd && isset($annotations[$annotationIndex]) && is_string($annotations[$annotationIndex][1])) {
+ $annotations[$annotationIndex][1] .= $token[1];
+ }
+
+ if ($token[0] === 'ANNOTATION_CONTENT_END') {
+ $contentEnd = true;
+ }
+
+ goto SCANNER_CONTINUE;
+ }
+
+ SCANNER_CONTINUE:
+ if (next($tokens) === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_TOP;
+
+ SCANNER_END:
+
+ foreach ($annotations as $annotation) {
+ $annotation[] = '@' . $annotation[0] . $annotation[1];
+ $annotationObject = $this->annotationManager->createAnnotation($annotation);
+ if ($annotationObject) {
+ $this->append($annotationObject);
+ }
+ }
+ }
+
+ /**
+ * @return array
+ */
+ protected function tokenize()
+ {
+ static $CONTEXT_DOCBLOCK = 0x01;
+ static $CONTEXT_ASTERISK = 0x02;
+ static $CONTEXT_CLASS = 0x04;
+ static $CONTEXT_CONTENT = 0x08;
+
+ $context = 0x00;
+ $stream = $this->docComment;
+ $streamIndex = null;
+ $tokens = array();
+ $tokenIndex = null;
+ $currentChar = null;
+ $currentWord = null;
+ $currentLine = null;
+
+ $annotationParentCount = 0;
+
+ $MACRO_STREAM_ADVANCE_CHAR = function ($positionsForward = 1) use (&$stream, &$streamIndex, &$currentChar, &$currentWord, &$currentLine) {
+ $positionsForward = ($positionsForward > 0) ? $positionsForward : 1;
+ $streamIndex = ($streamIndex === null) ? 0 : $streamIndex + $positionsForward;
+ if (!isset($stream[$streamIndex])) {
+ $currentChar = false;
+
+ return false;
+ }
+ $currentChar = $stream[$streamIndex];
+ $matches = array();
+ $currentLine = (preg_match('#(.*)\n#', $stream, $matches, null,
+ $streamIndex) === 1) ? $matches[1] : substr($stream, $streamIndex);
+ if ($currentChar === ' ') {
+ $currentWord = (preg_match('#( +)#', $currentLine, $matches) === 1) ? $matches[1] : $currentLine;
+ } else {
+ $currentWord = (($matches = strpos($currentLine, ' ')) !== false) ? substr($currentLine, 0,
+ $matches) : $currentLine;
+ }
+
+ return $currentChar;
+ };
+ $MACRO_STREAM_ADVANCE_WORD = function () use (&$currentWord, &$MACRO_STREAM_ADVANCE_CHAR) {
+ return $MACRO_STREAM_ADVANCE_CHAR(strlen($currentWord));
+ };
+ $MACRO_STREAM_ADVANCE_LINE = function () use (&$currentLine, &$MACRO_STREAM_ADVANCE_CHAR) {
+ return $MACRO_STREAM_ADVANCE_CHAR(strlen($currentLine));
+ };
+ $MACRO_TOKEN_ADVANCE = function () use (&$tokenIndex, &$tokens) {
+ $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1;
+ $tokens[$tokenIndex] = array('ANNOTATION_UNKNOWN', '');
+ };
+ $MACRO_TOKEN_SET_TYPE = function ($type) use (&$tokenIndex, &$tokens) {
+ $tokens[$tokenIndex][0] = $type;
+ };
+ $MACRO_TOKEN_APPEND_CHAR = function () use (&$currentChar, &$tokens, &$tokenIndex) {
+ $tokens[$tokenIndex][1] .= $currentChar;
+ };
+ $MACRO_TOKEN_APPEND_WORD = function () use (&$currentWord, &$tokens, &$tokenIndex) {
+ $tokens[$tokenIndex][1] .= $currentWord;
+ };
+ $MACRO_TOKEN_APPEND_LINE = function () use (&$currentLine, &$tokens, &$tokenIndex) {
+ $tokens[$tokenIndex][1] .= $currentLine;
+ };
+ $MACRO_HAS_CONTEXT = function ($which) use (&$context) {
+ return (($context & $which) === $which);
+ };
+
+ $MACRO_STREAM_ADVANCE_CHAR();
+ $MACRO_TOKEN_ADVANCE();
+
+ TOKENIZER_TOP:
+
+ if ($context === 0x00 && $currentChar === '/' && $currentWord === '/**') {
+ $MACRO_TOKEN_SET_TYPE('ANNOTATION_COMMENTSTART');
+ $MACRO_TOKEN_APPEND_WORD();
+ $MACRO_TOKEN_ADVANCE();
+ $context |= $CONTEXT_DOCBLOCK;
+ $context |= $CONTEXT_ASTERISK;
+ if ($MACRO_STREAM_ADVANCE_WORD() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ if ($MACRO_HAS_CONTEXT($CONTEXT_CLASS)) {
+ if (in_array($currentChar, array(' ', '(', "\n"))) {
+ $context &= ~$CONTEXT_CLASS;
+ $MACRO_TOKEN_ADVANCE();
+ } else {
+ $MACRO_TOKEN_APPEND_CHAR();
+ if ($MACRO_STREAM_ADVANCE_CHAR() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ }
+
+ if ($currentChar === "\n") {
+ $MACRO_TOKEN_SET_TYPE('ANNOTATION_NEWLINE');
+ $MACRO_TOKEN_APPEND_CHAR();
+ $MACRO_TOKEN_ADVANCE();
+ $context &= ~$CONTEXT_ASTERISK;
+ $context &= ~$CONTEXT_CLASS;
+ if ($MACRO_STREAM_ADVANCE_CHAR() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ if ($currentChar === ' ') {
+ $MACRO_TOKEN_SET_TYPE(($MACRO_HAS_CONTEXT($CONTEXT_ASTERISK)) ? 'ANNOTATION_WHITESPACE' : 'ANNOTATION_WHITESPACE_INDENT');
+ $MACRO_TOKEN_APPEND_WORD();
+ $MACRO_TOKEN_ADVANCE();
+ if ($MACRO_STREAM_ADVANCE_WORD() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ if ($MACRO_HAS_CONTEXT($CONTEXT_CONTENT) && $MACRO_HAS_CONTEXT($CONTEXT_ASTERISK)) {
+ $MACRO_TOKEN_SET_TYPE('ANNOTATION_CONTENT');
+ $annotationParentCount += substr_count($currentWord, '(');
+ $annotationParentCount -= substr_count($currentWord, ')');
+
+ if ($annotationParentCount === 0) {
+ $context &= ~$CONTEXT_CONTENT;
+ $MACRO_TOKEN_SET_TYPE('ANNOTATION_CONTENT_END');
+ }
+ $MACRO_TOKEN_APPEND_WORD();
+ $MACRO_TOKEN_ADVANCE();
+ if ($MACRO_STREAM_ADVANCE_WORD() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ if ($currentChar === '(' && $tokens[$tokenIndex - 1][0] === 'ANNOTATION_CLASS') {
+ $context |= $CONTEXT_CONTENT;
+ $annotationParentCount = 1;
+ $MACRO_TOKEN_SET_TYPE('ANNOTATION_CONTENT_START');
+ $MACRO_TOKEN_APPEND_CHAR();
+ $MACRO_TOKEN_ADVANCE();
+ if ($MACRO_STREAM_ADVANCE_CHAR() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ if ($MACRO_HAS_CONTEXT($CONTEXT_DOCBLOCK) && $currentWord === '*/') {
+ $MACRO_TOKEN_SET_TYPE('ANNOTATION_COMMENTEND');
+ $MACRO_TOKEN_APPEND_WORD();
+ $MACRO_TOKEN_ADVANCE();
+ $context &= ~$CONTEXT_DOCBLOCK;
+ if ($MACRO_STREAM_ADVANCE_WORD() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ if ($currentChar === '*') {
+ if ($MACRO_HAS_CONTEXT($CONTEXT_DOCBLOCK) && ($MACRO_HAS_CONTEXT($CONTEXT_ASTERISK))) {
+ $MACRO_TOKEN_SET_TYPE('ANNOTATION_IGNORE');
+ } else {
+ $MACRO_TOKEN_SET_TYPE('ANNOTATION_ASTERISK');
+ $context |= $CONTEXT_ASTERISK;
+ }
+ $MACRO_TOKEN_APPEND_CHAR();
+ $MACRO_TOKEN_ADVANCE();
+ if ($MACRO_STREAM_ADVANCE_CHAR() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ if ($currentChar === '@') {
+ $MACRO_TOKEN_SET_TYPE('ANNOTATION_CLASS');
+ $context |= $CONTEXT_CLASS;
+ $MACRO_TOKEN_APPEND_CHAR();
+ if ($MACRO_STREAM_ADVANCE_CHAR() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ TOKENIZER_CONTINUE:
+
+ if ($context && $CONTEXT_CONTENT) {
+ $MACRO_TOKEN_APPEND_CHAR();
+ if ($MACRO_STREAM_ADVANCE_CHAR() === false) {
+ goto TOKENIZER_END;
+ }
+ } else {
+ $MACRO_TOKEN_SET_TYPE('ANNOTATION_IGNORE');
+ $MACRO_TOKEN_APPEND_LINE();
+ $MACRO_TOKEN_ADVANCE();
+ if ($MACRO_STREAM_ADVANCE_LINE() === false) {
+ goto TOKENIZER_END;
+ }
+ }
+ goto TOKENIZER_TOP;
+
+ TOKENIZER_END:
+
+ array_pop($tokens);
+
+ return $tokens;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/CachingFileScanner.php zendframework-2.2.6/library/Zend/Code/Scanner/CachingFileScanner.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/CachingFileScanner.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/CachingFileScanner.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,160 @@
+fileScanner = static::$cache[$cacheId];
+ } else {
+ $this->fileScanner = new FileScanner($file, $annotationManager);
+ static::$cache[$cacheId] = $this->fileScanner;
+ }
+ }
+
+ /**
+ * @return void
+ */
+ public static function clearCache()
+ {
+ static::$cache = array();
+ }
+
+ /**
+ * @return AnnotationManager
+ */
+ public function getAnnotationManager()
+ {
+ return $this->fileScanner->getAnnotationManager();
+ }
+
+ /**
+ * @return array|null|string
+ */
+ public function getFile()
+ {
+ return $this->fileScanner->getFile();
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getDocComment()
+ {
+ return $this->fileScanner->getDocComment();
+ }
+
+ /**
+ * @return array
+ */
+ public function getNamespaces()
+ {
+ return $this->fileScanner->getNamespaces();
+ }
+
+ /**
+ * @param null|string $namespace
+ * @return array|null
+ */
+ public function getUses($namespace = null)
+ {
+ return $this->fileScanner->getUses($namespace);
+ }
+
+ /**
+ * @return array
+ */
+ public function getIncludes()
+ {
+ return $this->fileScanner->getIncludes();
+ }
+
+ /**
+ * @return array
+ */
+ public function getClassNames()
+ {
+ return $this->fileScanner->getClassNames();
+ }
+
+ /**
+ * @return array
+ */
+ public function getClasses()
+ {
+ return $this->fileScanner->getClasses();
+ }
+
+ /**
+ * @param int|string $className
+ * @return ClassScanner
+ */
+ public function getClass($className)
+ {
+ return $this->fileScanner->getClass($className);
+ }
+
+ /**
+ * @param string $className
+ * @return bool|null|NameInformation
+ */
+ public function getClassNameInformation($className)
+ {
+ return $this->fileScanner->getClassNameInformation($className);
+ }
+
+ /**
+ * @return array
+ */
+ public function getFunctionNames()
+ {
+ return $this->fileScanner->getFunctionNames();
+ }
+
+ /**
+ * @return array
+ */
+ public function getFunctions()
+ {
+ return $this->fileScanner->getFunctions();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/ClassScanner.php zendframework-2.2.6/library/Zend/Code/Scanner/ClassScanner.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/ClassScanner.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/ClassScanner.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,953 @@
+tokens = $classTokens;
+ $this->nameInformation = $nameInformation;
+ }
+
+ /**
+ * Get annotations
+ *
+ * @param Annotation\AnnotationManager $annotationManager
+ * @return Annotation\AnnotationCollection
+ */
+ public function getAnnotations(Annotation\AnnotationManager $annotationManager)
+ {
+ if (($docComment = $this->getDocComment()) == '') {
+ return false;
+ }
+
+ return new AnnotationScanner($annotationManager, $docComment, $this->nameInformation);
+ }
+
+ /**
+ * Return documentation comment
+ *
+ * @return null|string
+ */
+ public function getDocComment()
+ {
+ $this->scan();
+
+ return $this->docComment;
+ }
+
+ /**
+ * Return documentation block
+ *
+ * @return false|DocBlockScanner
+ */
+ public function getDocBlock()
+ {
+ if (!$docComment = $this->getDocComment()) {
+ return false;
+ }
+
+ return new DocBlockScanner($docComment);
+ }
+
+ /**
+ * Return a name of class
+ *
+ * @return null|string
+ */
+ public function getName()
+ {
+ $this->scan();
+ return $this->name;
+ }
+
+ /**
+ * Return short name of class
+ *
+ * @return null|string
+ */
+ public function getShortName()
+ {
+ $this->scan();
+ return $this->shortName;
+ }
+
+ /**
+ * Return number of first line
+ *
+ * @return int|null
+ */
+ public function getLineStart()
+ {
+ $this->scan();
+ return $this->lineStart;
+ }
+
+ /**
+ * Return number of last line
+ *
+ * @return int|null
+ */
+ public function getLineEnd()
+ {
+ $this->scan();
+ return $this->lineEnd;
+ }
+
+ /**
+ * Verify if class is final
+ *
+ * @return bool
+ */
+ public function isFinal()
+ {
+ $this->scan();
+ return $this->isFinal;
+ }
+
+ /**
+ * Verify if class is instantiable
+ *
+ * @return bool
+ */
+ public function isInstantiable()
+ {
+ $this->scan();
+ return (!$this->isAbstract && !$this->isInterface);
+ }
+
+ /**
+ * Verify if class is an abstract class
+ *
+ * @return bool
+ */
+ public function isAbstract()
+ {
+ $this->scan();
+ return $this->isAbstract;
+ }
+
+ /**
+ * Verify if class is an interface
+ *
+ * @return bool
+ */
+ public function isInterface()
+ {
+ $this->scan();
+ return $this->isInterface;
+ }
+
+ /**
+ * Verify if class has parent
+ *
+ * @return bool
+ */
+ public function hasParentClass()
+ {
+ $this->scan();
+ return ($this->parentClass != null);
+ }
+
+ /**
+ * Return a name of parent class
+ *
+ * @return null|string
+ */
+ public function getParentClass()
+ {
+ $this->scan();
+ return $this->parentClass;
+ }
+
+ /**
+ * Return a list of interface names
+ *
+ * @return array
+ */
+ public function getInterfaces()
+ {
+ $this->scan();
+ return $this->interfaces;
+ }
+
+ /**
+ * Return a list of constant names
+ *
+ * @return array
+ */
+ public function getConstantNames()
+ {
+ $this->scan();
+
+ $return = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] != 'constant') {
+ continue;
+ }
+
+ $return[] = $info['name'];
+ }
+
+ return $return;
+ }
+
+ /**
+ * Return a list of constants
+ *
+ * @param bool $namesOnly Set false to return instances of ConstantScanner
+ * @return array|ConstantScanner[]
+ */
+ public function getConstants($namesOnly = true)
+ {
+ if (true === $namesOnly) {
+ trigger_error('Use method getConstantNames() instead', E_USER_DEPRECATED);
+ return $this->getConstantNames();
+ }
+
+ $this->scan();
+
+ $return = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] != 'constant') {
+ continue;
+ }
+
+ $return[] = $this->getConstant($info['name']);
+ }
+
+ return $return;
+ }
+
+ /**
+ * Return a single constant by given name or index of info
+ *
+ * @param string|int $constantNameOrInfoIndex
+ * @throws Exception\InvalidArgumentException
+ * @return bool|ConstantScanner
+ */
+ public function getConstant($constantNameOrInfoIndex)
+ {
+ $this->scan();
+
+ if (is_int($constantNameOrInfoIndex)) {
+ $info = $this->infos[$constantNameOrInfoIndex];
+ if ($info['type'] != 'constant') {
+ throw new Exception\InvalidArgumentException('Index of info offset is not about a constant');
+ }
+ } elseif (is_string($constantNameOrInfoIndex)) {
+ $constantFound = false;
+ foreach ($this->infos as $info) {
+ if ($info['type'] === 'constant' && $info['name'] === $constantNameOrInfoIndex) {
+ $constantFound = true;
+ break;
+ }
+ }
+ if (!$constantFound) {
+ return false;
+ }
+ } else {
+ throw new Exception\InvalidArgumentException('Invalid constant name of info index type. Must be of type int or string');
+ }
+ if (!isset($info)) {
+ return false;
+ }
+ $p = new ConstantScanner(
+ array_slice($this->tokens, $info['tokenStart'], $info['tokenEnd'] - $info['tokenStart'] + 1),
+ $this->nameInformation
+ );
+ $p->setClass($this->name);
+ $p->setScannerClass($this);
+ return $p;
+ }
+
+ /**
+ * Verify if class has constant
+ *
+ * @param string $name
+ * @return bool
+ */
+ public function hasConstant($name)
+ {
+ $this->scan();
+
+ foreach ($this->infos as $info) {
+ if ($info['type'] === 'constant' && $info['name'] === $name) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Return a list of property names
+ *
+ * @return array
+ */
+ public function getPropertyNames()
+ {
+ $this->scan();
+
+ $return = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] != 'property') {
+ continue;
+ }
+
+ $return[] = $info['name'];
+ }
+
+ return $return;
+ }
+
+ /**
+ * Return a list of properties
+ *
+ * @return PropertyScanner
+ */
+ public function getProperties()
+ {
+ $this->scan();
+
+ $return = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] != 'property') {
+ continue;
+ }
+
+ $return[] = $this->getProperty($info['name']);
+ }
+
+ return $return;
+ }
+
+ /**
+ * Return a single property by given name or index of info
+ *
+ * @param string|int $propertyNameOrInfoIndex
+ * @throws Exception\InvalidArgumentException
+ * @return bool|PropertyScanner
+ */
+ public function getProperty($propertyNameOrInfoIndex)
+ {
+ $this->scan();
+
+ if (is_int($propertyNameOrInfoIndex)) {
+ $info = $this->infos[$propertyNameOrInfoIndex];
+ if ($info['type'] != 'property') {
+ throw new Exception\InvalidArgumentException('Index of info offset is not about a property');
+ }
+ } elseif (is_string($propertyNameOrInfoIndex)) {
+ $propertyFound = false;
+ foreach ($this->infos as $info) {
+ if ($info['type'] === 'property' && $info['name'] === $propertyNameOrInfoIndex) {
+ $propertyFound = true;
+ break;
+ }
+ }
+ if (!$propertyFound) {
+ return false;
+ }
+ } else {
+ throw new Exception\InvalidArgumentException('Invalid property name of info index type. Must be of type int or string');
+ }
+ if (!isset($info)) {
+ return false;
+ }
+ $p = new PropertyScanner(
+ array_slice($this->tokens, $info['tokenStart'], $info['tokenEnd'] - $info['tokenStart'] + 1),
+ $this->nameInformation
+ );
+ $p->setClass($this->name);
+ $p->setScannerClass($this);
+ return $p;
+ }
+
+ /**
+ * Verify if class has property
+ *
+ * @param string $name
+ * @return bool
+ */
+ public function hasProperty($name)
+ {
+ $this->scan();
+
+ foreach ($this->infos as $info) {
+ if ($info['type'] === 'property' && $info['name'] === $name) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Return a list of method names
+ *
+ * @return array
+ */
+ public function getMethodNames()
+ {
+ $this->scan();
+
+ $return = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] != 'method') {
+ continue;
+ }
+
+ $return[] = $info['name'];
+ }
+
+ return $return;
+ }
+
+ /**
+ * Return a list of methods
+ *
+ * @return MethodScanner[]
+ */
+ public function getMethods()
+ {
+ $this->scan();
+
+ $return = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] != 'method') {
+ continue;
+ }
+
+ $return[] = $this->getMethod($info['name']);
+ }
+
+ return $return;
+ }
+
+ /**
+ * Return a single method by given name or index of info
+ *
+ * @param string|int $methodNameOrInfoIndex
+ * @throws Exception\InvalidArgumentException
+ * @return MethodScanner
+ */
+ public function getMethod($methodNameOrInfoIndex)
+ {
+ $this->scan();
+
+ if (is_int($methodNameOrInfoIndex)) {
+ $info = $this->infos[$methodNameOrInfoIndex];
+ if ($info['type'] != 'method') {
+ throw new Exception\InvalidArgumentException('Index of info offset is not about a method');
+ }
+ } elseif (is_string($methodNameOrInfoIndex)) {
+ $methodFound = false;
+ foreach ($this->infos as $info) {
+ if ($info['type'] === 'method' && $info['name'] === $methodNameOrInfoIndex) {
+ $methodFound = true;
+ break;
+ }
+ }
+ if (!$methodFound) {
+ return false;
+ }
+ }
+ if (!isset($info)) {
+ // @todo find a way to test this
+ die('Massive Failure, test this');
+ }
+ $m = new MethodScanner(
+ array_slice($this->tokens, $info['tokenStart'], $info['tokenEnd'] - $info['tokenStart'] + 1),
+ $this->nameInformation
+ );
+ $m->setClass($this->name);
+ $m->setScannerClass($this);
+
+ return $m;
+ }
+
+ /**
+ * Verify if class has method by given name
+ *
+ * @param string $name
+ * @return bool
+ */
+ public function hasMethod($name)
+ {
+ $this->scan();
+
+ foreach ($this->infos as $info) {
+ if ($info['type'] === 'method' && $info['name'] === $name) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public static function export()
+ {
+ // @todo
+ }
+
+ public function __toString()
+ {
+ // @todo
+ }
+
+ /**
+ * Scan tokens
+ *
+ * @return void
+ * @throws Exception\RuntimeException
+ */
+ protected function scan()
+ {
+ if ($this->isScanned) {
+ return;
+ }
+
+ if (!$this->tokens) {
+ throw new Exception\RuntimeException('No tokens were provided');
+ }
+
+ /**
+ * Variables & Setup
+ */
+
+ $tokens = &$this->tokens; // localize
+ $infos = &$this->infos; // localize
+ $tokenIndex = null;
+ $token = null;
+ $tokenType = null;
+ $tokenContent = null;
+ $tokenLine = null;
+ $namespace = null;
+ $infoIndex = 0;
+ $braceCount = 0;
+
+ /*
+ * MACRO creation
+ */
+ $MACRO_TOKEN_ADVANCE = function () use (&$tokens, &$tokenIndex, &$token, &$tokenType, &$tokenContent, &$tokenLine) {
+ static $lastTokenArray = null;
+ $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1;
+ if (!isset($tokens[$tokenIndex])) {
+ $token = false;
+ $tokenContent = false;
+ $tokenType = false;
+ $tokenLine = false;
+
+ return false;
+ }
+ $token = $tokens[$tokenIndex];
+
+ if (is_string($token)) {
+ $tokenType = null;
+ $tokenContent = $token;
+ $tokenLine = $tokenLine + substr_count($lastTokenArray[1],
+ "\n"); // adjust token line by last known newline count
+ } else {
+ $lastTokenArray = $token;
+ list($tokenType, $tokenContent, $tokenLine) = $token;
+ }
+
+ return $tokenIndex;
+ };
+ $MACRO_INFO_ADVANCE = function () use (&$infoIndex, &$infos, &$tokenIndex, &$tokenLine) {
+ $infos[$infoIndex]['tokenEnd'] = $tokenIndex;
+ $infos[$infoIndex]['lineEnd'] = $tokenLine;
+ $infoIndex++;
+
+ return $infoIndex;
+ };
+
+ /**
+ * START FINITE STATE MACHINE FOR SCANNING TOKENS
+ */
+
+ // Initialize token
+ $MACRO_TOKEN_ADVANCE();
+
+ SCANNER_TOP:
+
+ switch ($tokenType) {
+
+ case T_DOC_COMMENT:
+
+ $this->docComment = $tokenContent;
+ goto SCANNER_CONTINUE;
+
+ case T_FINAL:
+ case T_ABSTRACT:
+ case T_CLASS:
+ case T_INTERFACE:
+
+ // CLASS INFORMATION
+
+ $classContext = null;
+ $classInterfaceIndex = 0;
+
+ SCANNER_CLASS_INFO_TOP:
+
+ if (is_string($tokens[$tokenIndex + 1]) && $tokens[$tokenIndex + 1] === '{') {
+ goto SCANNER_CLASS_INFO_END;
+ }
+
+ $this->lineStart = $tokenLine;
+
+ switch ($tokenType) {
+
+ case T_FINAL:
+ $this->isFinal = true;
+ goto SCANNER_CLASS_INFO_CONTINUE;
+
+ case T_ABSTRACT:
+ $this->isAbstract = true;
+ goto SCANNER_CLASS_INFO_CONTINUE;
+
+ case T_INTERFACE:
+ $this->isInterface = true;
+ case T_CLASS:
+ $this->shortName = $tokens[$tokenIndex + 2][1];
+ if ($this->nameInformation && $this->nameInformation->hasNamespace()) {
+ $this->name = $this->nameInformation->getNamespace() . '\\' . $this->shortName;
+ } else {
+ $this->name = $this->shortName;
+ }
+ goto SCANNER_CLASS_INFO_CONTINUE;
+
+ case T_NS_SEPARATOR:
+ case T_STRING:
+ switch ($classContext) {
+ case T_EXTENDS:
+ $this->shortParentClass .= $tokenContent;
+ break;
+ case T_IMPLEMENTS:
+ $this->shortInterfaces[$classInterfaceIndex] .= $tokenContent;
+ break;
+ }
+ goto SCANNER_CLASS_INFO_CONTINUE;
+
+ case T_EXTENDS:
+ case T_IMPLEMENTS:
+ $classContext = $tokenType;
+ if (($this->isInterface && $classContext === T_EXTENDS) || $classContext === T_IMPLEMENTS) {
+ $this->shortInterfaces[$classInterfaceIndex] = '';
+ } elseif (!$this->isInterface && $classContext === T_EXTENDS) {
+ $this->shortParentClass = '';
+ }
+ goto SCANNER_CLASS_INFO_CONTINUE;
+
+ case null:
+ if ($classContext == T_IMPLEMENTS && $tokenContent == ',') {
+ $classInterfaceIndex++;
+ $this->shortInterfaces[$classInterfaceIndex] = '';
+ }
+
+ }
+
+ SCANNER_CLASS_INFO_CONTINUE:
+
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_CLASS_INFO_TOP;
+
+ SCANNER_CLASS_INFO_END:
+
+ goto SCANNER_CONTINUE;
+
+ }
+
+ if ($tokenType === null && $tokenContent === '{' && $braceCount === 0) {
+
+ $braceCount++;
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+
+ SCANNER_CLASS_BODY_TOP:
+
+ if ($braceCount === 0) {
+ goto SCANNER_CLASS_BODY_END;
+ }
+
+ switch ($tokenType) {
+
+ case T_CONST:
+
+ $infos[$infoIndex] = array(
+ 'type' => 'constant',
+ 'tokenStart' => $tokenIndex,
+ 'tokenEnd' => null,
+ 'lineStart' => $tokenLine,
+ 'lineEnd' => null,
+ 'name' => null,
+ 'value' => null,
+ );
+
+ SCANNER_CLASS_BODY_CONST_TOP:
+
+ if ($tokenContent === ';') {
+ goto SCANNER_CLASS_BODY_CONST_END;
+ }
+
+ if ($tokenType === T_STRING && null === $infos[$infoIndex]['name']) {
+ $infos[$infoIndex]['name'] = $tokenContent;
+ }
+
+ SCANNER_CLASS_BODY_CONST_CONTINUE:
+
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_CLASS_BODY_CONST_TOP;
+
+ SCANNER_CLASS_BODY_CONST_END:
+
+ $MACRO_INFO_ADVANCE();
+ goto SCANNER_CLASS_BODY_CONTINUE;
+
+ case T_DOC_COMMENT:
+ case T_PUBLIC:
+ case T_PROTECTED:
+ case T_PRIVATE:
+ case T_ABSTRACT:
+ case T_FINAL:
+ case T_VAR:
+ case T_FUNCTION:
+
+ $infos[$infoIndex] = array(
+ 'type' => null,
+ 'tokenStart' => $tokenIndex,
+ 'tokenEnd' => null,
+ 'lineStart' => $tokenLine,
+ 'lineEnd' => null,
+ 'name' => null,
+ );
+
+ $memberContext = null;
+ $methodBodyStarted = false;
+
+ SCANNER_CLASS_BODY_MEMBER_TOP:
+
+ if ($memberContext === 'method') {
+ switch ($tokenContent) {
+ case '{':
+ $methodBodyStarted = true;
+ $braceCount++;
+ goto SCANNER_CLASS_BODY_MEMBER_CONTINUE;
+ case '}':
+ $braceCount--;
+ goto SCANNER_CLASS_BODY_MEMBER_CONTINUE;
+ }
+ }
+
+ if ($memberContext !== null) {
+ if (
+ ($memberContext === 'property' && $tokenContent === ';')
+ || ($memberContext === 'method' && $methodBodyStarted && $braceCount === 1)
+ || ($memberContext === 'method' && $this->isInterface && $tokenContent === ';')
+ ) {
+ goto SCANNER_CLASS_BODY_MEMBER_END;
+ }
+ }
+
+
+ switch ($tokenType) {
+
+ case T_CONST:
+ $memberContext = 'constant';
+ $infos[$infoIndex]['type'] = 'constant';
+ goto SCANNER_CLASS_BODY_CONST_CONTINUE;
+
+ case T_VARIABLE:
+ if ($memberContext === null) {
+ $memberContext = 'property';
+ $infos[$infoIndex]['type'] = 'property';
+ $infos[$infoIndex]['name'] = ltrim($tokenContent, '$');
+ }
+ goto SCANNER_CLASS_BODY_MEMBER_CONTINUE;
+
+ case T_FUNCTION:
+ $memberContext = 'method';
+ $infos[$infoIndex]['type'] = 'method';
+ goto SCANNER_CLASS_BODY_MEMBER_CONTINUE;
+
+ case T_STRING:
+ if ($memberContext === 'method' && null === $infos[$infoIndex]['name']) {
+ $infos[$infoIndex]['name'] = $tokenContent;
+ }
+ goto SCANNER_CLASS_BODY_MEMBER_CONTINUE;
+ }
+
+ SCANNER_CLASS_BODY_MEMBER_CONTINUE:
+
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_CLASS_BODY_MEMBER_TOP;
+
+ SCANNER_CLASS_BODY_MEMBER_END:
+
+ $memberContext = null;
+ $MACRO_INFO_ADVANCE();
+ goto SCANNER_CLASS_BODY_CONTINUE;
+
+ case null: // no type, is a string
+
+ switch ($tokenContent) {
+ case '{':
+ $braceCount++;
+ goto SCANNER_CLASS_BODY_CONTINUE;
+ case '}':
+ $braceCount--;
+ goto SCANNER_CLASS_BODY_CONTINUE;
+ }
+ }
+
+ SCANNER_CLASS_BODY_CONTINUE:
+
+ if ($braceCount === 0 || $MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_CONTINUE;
+ }
+ goto SCANNER_CLASS_BODY_TOP;
+
+ SCANNER_CLASS_BODY_END:
+
+ goto SCANNER_CONTINUE;
+
+ }
+
+ SCANNER_CONTINUE:
+
+ if ($tokenContent === '}') {
+ $this->lineEnd = $tokenLine;
+ }
+
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_TOP;
+
+ SCANNER_END:
+
+ // process short names
+ if ($this->nameInformation) {
+ if ($this->shortParentClass) {
+ $this->parentClass = $this->nameInformation->resolveName($this->shortParentClass);
+ }
+ if ($this->shortInterfaces) {
+ foreach ($this->shortInterfaces as $siIndex => $si) {
+ $this->interfaces[$siIndex] = $this->nameInformation->resolveName($si);
+ }
+ }
+ } else {
+ $this->parentClass = $this->shortParentClass;
+ $this->interfaces = $this->shortInterfaces;
+ }
+
+ $this->isScanned = true;
+
+ return;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/ConstantScanner.php zendframework-2.2.6/library/Zend/Code/Scanner/ConstantScanner.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/ConstantScanner.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/ConstantScanner.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,233 @@
+tokens = $constantTokens;
+ $this->nameInformation = $nameInformation;
+ }
+
+ /**
+ * @param string $class
+ */
+ public function setClass($class)
+ {
+ $this->class = $class;
+ }
+
+ /**
+ * @param ClassScanner $scannerClass
+ */
+ public function setScannerClass(ClassScanner $scannerClass)
+ {
+ $this->scannerClass = $scannerClass;
+ }
+
+ /**
+ * @return ClassScanner
+ */
+ public function getClassScanner()
+ {
+ return $this->scannerClass;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ $this->scan();
+ return $this->name;
+ }
+
+ /**
+ * @return string
+ */
+ public function getValue()
+ {
+ $this->scan();
+ return $this->value;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDocComment()
+ {
+ $this->scan();
+ return $this->docComment;
+ }
+
+ /**
+ * @param Annotation\AnnotationManager $annotationManager
+ * @return AnnotationScanner
+ */
+ public function getAnnotations(Annotation\AnnotationManager $annotationManager)
+ {
+ if (($docComment = $this->getDocComment()) == '') {
+ return false;
+ }
+
+ return new AnnotationScanner($annotationManager, $docComment, $this->nameInformation);
+ }
+
+ /**
+ * @return string
+ */
+ public function __toString()
+ {
+ $this->scan();
+ return var_export($this, true);
+ }
+
+ /**
+ * Scan tokens
+ *
+ * @throws Exception\RuntimeException
+ */
+ protected function scan()
+ {
+ if ($this->isScanned) {
+ return;
+ }
+
+ if (!$this->tokens) {
+ throw new Exception\RuntimeException('No tokens were provided');
+ }
+
+ /**
+ * Variables & Setup
+ */
+ $tokens = &$this->tokens;
+
+ reset($tokens);
+
+ SCANNER_TOP:
+
+ $token = current($tokens);
+
+ if (!is_string($token)) {
+ list($tokenType, $tokenContent, $tokenLine) = $token;
+
+ switch ($tokenType) {
+ case T_DOC_COMMENT:
+ if ($this->docComment === null && $this->name === null) {
+ $this->docComment = $tokenContent;
+ }
+ goto SCANNER_CONTINUE;
+
+ case T_STRING:
+ $string = (is_string($token)) ? $token : $tokenContent;
+
+ if (null === $this->name) {
+ $this->name = $string;
+ } else {
+ if ('self' == strtolower($string)) {
+ list($tokenNextType, $tokenNextContent, $tokenNextLine) = next($tokens);
+
+ if ('::' == $tokenNextContent) {
+ list($tokenNextType, $tokenNextContent, $tokenNextLine) = next($tokens);
+
+ if ($this->getClassScanner()->getConstant($tokenNextContent)) {
+ $this->value = $this->getClassScanner()->getConstant($tokenNextContent)->getValue();
+ }
+ }
+ }
+ }
+
+ goto SCANNER_CONTINUE;
+
+ case T_CONSTANT_ENCAPSED_STRING:
+ case T_DNUMBER:
+ case T_LNUMBER:
+ $string = (is_string($token)) ? $token : $tokenContent;
+
+ if (substr($string, 0, 1) === '"' || substr($string, 0, 1) === "'") {
+ $this->value = substr($string, 1, -1); // Remove quotes
+ } else {
+ $this->value = $string;
+ }
+ goto SCANNER_CONTINUE;
+
+ default:
+ goto SCANNER_CONTINUE;
+ }
+ }
+
+ SCANNER_CONTINUE:
+
+ if (next($this->tokens) === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_TOP;
+
+ SCANNER_END:
+
+ $this->isScanned = true;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/DerivedClassScanner.php zendframework-2.2.6/library/Zend/Code/Scanner/DerivedClassScanner.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/DerivedClassScanner.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/DerivedClassScanner.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,381 @@
+classScanner = $classScanner;
+ $this->directoryScanner = $directoryScanner;
+
+ $currentScannerClass = $classScanner;
+
+ while ($currentScannerClass && $currentScannerClass->hasParentClass()) {
+ $currentParentClassName = $currentScannerClass->getParentClass();
+ if ($directoryScanner->hasClass($currentParentClassName)) {
+ $currentParentClass = $directoryScanner->getClass($currentParentClassName);
+ $this->parentClassScanners[$currentParentClassName] = $currentParentClass;
+ $currentScannerClass = $currentParentClass;
+ } else {
+ $currentScannerClass = false;
+ }
+ }
+
+ foreach ($interfaces = $this->classScanner->getInterfaces() as $iName) {
+ if ($directoryScanner->hasClass($iName)) {
+ $this->interfaceClassScanners[$iName] = $directoryScanner->getClass($iName);
+ }
+ }
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getName()
+ {
+ return $this->classScanner->getName();
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getShortName()
+ {
+ return $this->classScanner->getShortName();
+ }
+
+ /**
+ * @return bool
+ */
+ public function isInstantiable()
+ {
+ return $this->classScanner->isInstantiable();
+ }
+
+ /**
+ * @return bool
+ */
+ public function isFinal()
+ {
+ return $this->classScanner->isFinal();
+ }
+
+ /**
+ * @return bool
+ */
+ public function isAbstract()
+ {
+ return $this->classScanner->isAbstract();
+ }
+
+ /**
+ * @return bool
+ */
+ public function isInterface()
+ {
+ return $this->classScanner->isInterface();
+ }
+
+ /**
+ * @return array
+ */
+ public function getParentClasses()
+ {
+ return array_keys($this->parentClassScanners);
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasParentClass()
+ {
+ return ($this->classScanner->getParentClass() != null);
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getParentClass()
+ {
+ return $this->classScanner->getParentClass();
+ }
+
+ /**
+ * @param bool $returnClassScanners
+ * @return array
+ */
+ public function getInterfaces($returnClassScanners = false)
+ {
+ if ($returnClassScanners) {
+ return $this->interfaceClassScanners;
+ }
+
+ $interfaces = $this->classScanner->getInterfaces();
+ foreach ($this->parentClassScanners as $pClassScanner) {
+ $interfaces = array_merge($interfaces, $pClassScanner->getInterfaces());
+ }
+
+ return $interfaces;
+ }
+
+ /**
+ * Return a list of constant names
+ *
+ * @return array
+ */
+ public function getConstantNames()
+ {
+ $constants = $this->classScanner->getConstantNames();
+ foreach ($this->parentClassScanners as $pClassScanner) {
+ $constants = array_merge($constants, $pClassScanner->getConstantNames());
+ }
+
+ return $constants;
+ }
+
+ /**
+ * Return a list of constants
+ *
+ * @param bool $namesOnly Set false to return instances of ConstantScanner
+ * @return array|ConstantScanner[]
+ */
+ public function getConstants($namesOnly = true)
+ {
+ if (true === $namesOnly) {
+ trigger_error('Use method getConstantNames() instead', E_USER_DEPRECATED);
+ return $this->getConstantNames();
+ }
+
+ $constants = $this->classScanner->getConstants();
+ foreach ($this->parentClassScanners as $pClassScanner) {
+ $constants = array_merge($constants, $pClassScanner->getConstants($namesOnly));
+ }
+
+ return $constants;
+ }
+
+ /**
+ * Return a single constant by given name or index of info
+ *
+ * @param string|int $constantNameOrInfoIndex
+ * @throws Exception\InvalidArgumentException
+ * @return bool|ConstantScanner
+ */
+ public function getConstant($constantNameOrInfoIndex)
+ {
+ if ($this->classScanner->hasConstant($constantNameOrInfoIndex)) {
+ return $this->classScanner->getConstant($constantNameOrInfoIndex);
+ }
+
+ foreach ($this->parentClassScanners as $pClassScanner) {
+ if ($pClassScanner->hasConstant($constantNameOrInfoIndex)) {
+ return $pClassScanner->getConstant($constantNameOrInfoIndex);
+ }
+ }
+
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Constant %s not found in %s',
+ $constantNameOrInfoIndex,
+ $this->classScanner->getName()
+ ));
+ }
+
+ /**
+ * Verify if class or parent class has constant
+ *
+ * @param string $name
+ * @return bool
+ */
+ public function hasConstant($name)
+ {
+ if ($this->classScanner->hasConstant($name)) {
+ return true;
+ }
+ foreach ($this->parentClassScanners as $pClassScanner) {
+ if ($pClassScanner->hasConstant($name)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Return a list of property names
+ *
+ * @return array
+ */
+ public function getPropertyNames()
+ {
+ $properties = $this->classScanner->getPropertyNames();
+ foreach ($this->parentClassScanners as $pClassScanner) {
+ $properties = array_merge($properties, $pClassScanner->getPropertyNames());
+ }
+
+ return $properties;
+ }
+
+ /**
+ * @param bool $returnScannerProperty
+ * @return array
+ */
+ public function getProperties($returnScannerProperty = false)
+ {
+ $properties = $this->classScanner->getProperties($returnScannerProperty);
+ foreach ($this->parentClassScanners as $pClassScanner) {
+ $properties = array_merge($properties, $pClassScanner->getProperties($returnScannerProperty));
+ }
+
+ return $properties;
+ }
+
+ /**
+ * Return a single property by given name or index of info
+ *
+ * @param string|int $propertyNameOrInfoIndex
+ * @throws Exception\InvalidArgumentException
+ * @return bool|PropertyScanner
+ */
+ public function getProperty($propertyNameOrInfoIndex)
+ {
+ if ($this->classScanner->hasProperty($propertyNameOrInfoIndex)) {
+ return $this->classScanner->getProperty($propertyNameOrInfoIndex);
+ }
+
+ foreach ($this->parentClassScanners as $pClassScanner) {
+ if ($pClassScanner->hasProperty($propertyNameOrInfoIndex)) {
+ return $pClassScanner->getProperty($propertyNameOrInfoIndex);
+ }
+ }
+
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Property %s not found in %s',
+ $propertyNameOrInfoIndex,
+ $this->classScanner->getName()
+ ));
+ }
+
+ /**
+ * Verify if class or parent class has property
+ *
+ * @param string $name
+ * @return bool
+ */
+ public function hasProperty($name)
+ {
+ if ($this->classScanner->hasProperty($name)) {
+ return true;
+ }
+ foreach ($this->parentClassScanners as $pClassScanner) {
+ if ($pClassScanner->hasProperty($name)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @return array
+ */
+ public function getMethodNames()
+ {
+ $methods = $this->classScanner->getMethodNames();
+ foreach ($this->parentClassScanners as $pClassScanner) {
+ $methods = array_merge($methods, $pClassScanner->getMethodNames());
+ }
+
+ return $methods;
+ }
+
+ /**
+ * @return MethodScanner[]
+ */
+ public function getMethods()
+ {
+ $methods = $this->classScanner->getMethods();
+ foreach ($this->parentClassScanners as $pClassScanner) {
+ $methods = array_merge($methods, $pClassScanner->getMethods());
+ }
+
+ return $methods;
+ }
+
+ /**
+ * @param int|string $methodNameOrInfoIndex
+ * @return MethodScanner
+ * @throws Exception\InvalidArgumentException
+ */
+ public function getMethod($methodNameOrInfoIndex)
+ {
+ if ($this->classScanner->hasMethod($methodNameOrInfoIndex)) {
+ return $this->classScanner->getMethod($methodNameOrInfoIndex);
+ }
+
+ foreach ($this->parentClassScanners as $pClassScanner) {
+ if ($pClassScanner->hasMethod($methodNameOrInfoIndex)) {
+ return $pClassScanner->getMethod($methodNameOrInfoIndex);
+ }
+ }
+
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Method %s not found in %s',
+ $methodNameOrInfoIndex,
+ $this->classScanner->getName()
+ ));
+ }
+
+ /**
+ * Verify if class or parent class has method by given name
+ *
+ * @param string $name
+ * @return bool
+ */
+ public function hasMethod($name)
+ {
+ if ($this->classScanner->hasMethod($name)) {
+ return true;
+ }
+ foreach ($this->parentClassScanners as $pClassScanner) {
+ if ($pClassScanner->hasMethod($name)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/DirectoryScanner.php zendframework-2.2.6/library/Zend/Code/Scanner/DirectoryScanner.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/DirectoryScanner.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/DirectoryScanner.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,272 @@
+addDirectory($directory);
+ } elseif (is_array($directory)) {
+ foreach ($directory as $d) {
+ $this->addDirectory($d);
+ }
+ }
+ }
+ }
+
+ /**
+ * @param DirectoryScanner|string $directory
+ * @return void
+ * @throws Exception\InvalidArgumentException
+ */
+ public function addDirectory($directory)
+ {
+ if ($directory instanceof DirectoryScanner) {
+ $this->directories[] = $directory;
+ } elseif (is_string($directory)) {
+ $realDir = realpath($directory);
+ if (!$realDir || !is_dir($realDir)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Directory "%s" does not exist',
+ $realDir
+ ));
+ }
+ $this->directories[] = $realDir;
+ } else {
+ throw new Exception\InvalidArgumentException(
+ 'The argument provided was neither a DirectoryScanner or directory path'
+ );
+ }
+ }
+
+ /**
+ * @param DirectoryScanner $directoryScanner
+ * @return void
+ */
+ public function addDirectoryScanner(DirectoryScanner $directoryScanner)
+ {
+ $this->addDirectory($directoryScanner);
+ }
+
+ /**
+ * @param FileScanner $fileScanner
+ * @return void
+ */
+ public function addFileScanner(FileScanner $fileScanner)
+ {
+ $this->fileScanners[] = $fileScanner;
+ }
+
+ /**
+ * @return void
+ */
+ protected function scan()
+ {
+ if ($this->isScanned) {
+ return;
+ }
+
+ // iterate directories creating file scanners
+ foreach ($this->directories as $directory) {
+ if ($directory instanceof DirectoryScanner) {
+ $directory->scan();
+ if ($directory->fileScanners) {
+ $this->fileScanners = array_merge($this->fileScanners, $directory->fileScanners);
+ }
+ } else {
+ $rdi = new RecursiveDirectoryIterator($directory);
+ foreach (new RecursiveIteratorIterator($rdi) as $item) {
+ if ($item->isFile() && pathinfo($item->getRealPath(), PATHINFO_EXTENSION) == 'php') {
+ $this->fileScanners[] = new FileScanner($item->getRealPath());
+ }
+ }
+ }
+ }
+
+ $this->isScanned = true;
+ }
+
+ /**
+ * @todo implement method
+ */
+ public function getNamespaces()
+ {
+ // @todo
+ }
+
+ /**
+ * @param bool $returnFileScanners
+ * @return array
+ */
+ public function getFiles($returnFileScanners = false)
+ {
+ $this->scan();
+
+ $return = array();
+ foreach ($this->fileScanners as $fileScanner) {
+ $return[] = ($returnFileScanners) ? $fileScanner : $fileScanner->getFile();
+ }
+
+ return $return;
+ }
+
+ /**
+ * @return array
+ */
+ public function getClassNames()
+ {
+ $this->scan();
+
+ if ($this->classToFileScanner === null) {
+ $this->createClassToFileScannerCache();
+ }
+
+ return array_keys($this->classToFileScanner);
+ }
+
+ /**
+ * @param bool $returnDerivedScannerClass
+ * @return array
+ */
+ public function getClasses($returnDerivedScannerClass = false)
+ {
+ $this->scan();
+
+ if ($this->classToFileScanner === null) {
+ $this->createClassToFileScannerCache();
+ }
+
+ $returnClasses = array();
+ foreach ($this->classToFileScanner as $className => $fsIndex) {
+ $classScanner = $this->fileScanners[$fsIndex]->getClass($className);
+ if ($returnDerivedScannerClass) {
+ $classScanner = new DerivedClassScanner($classScanner, $this);
+ }
+ $returnClasses[] = $classScanner;
+ }
+
+ return $returnClasses;
+ }
+
+ /**
+ * @param string $class
+ * @return bool
+ */
+ public function hasClass($class)
+ {
+ $this->scan();
+
+ if ($this->classToFileScanner === null) {
+ $this->createClassToFileScannerCache();
+ }
+
+ return (isset($this->classToFileScanner[$class]));
+ }
+
+ /**
+ * @param string $class
+ * @param bool $returnDerivedScannerClass
+ * @return ClassScanner|DerivedClassScanner
+ * @throws Exception\InvalidArgumentException
+ */
+ public function getClass($class, $returnDerivedScannerClass = false)
+ {
+ $this->scan();
+
+ if ($this->classToFileScanner === null) {
+ $this->createClassToFileScannerCache();
+ }
+
+ if (!isset($this->classToFileScanner[$class])) {
+ throw new Exception\InvalidArgumentException('Class not found.');
+ }
+
+ /** @var FileScanner $fs */
+ $fs = $this->fileScanners[$this->classToFileScanner[$class]];
+ $returnClass = $fs->getClass($class);
+
+ if (($returnClass instanceof ClassScanner) && $returnDerivedScannerClass) {
+ return new DerivedClassScanner($returnClass, $this);
+ }
+
+ return $returnClass;
+ }
+
+ /**
+ * Create class to file scanner cache
+ *
+ * @return void
+ */
+ protected function createClassToFileScannerCache()
+ {
+ if ($this->classToFileScanner !== null) {
+ return;
+ }
+
+ $this->classToFileScanner = array();
+ /** @var FileScanner $fileScanner */
+ foreach ($this->fileScanners as $fsIndex => $fileScanner) {
+ $fsClasses = $fileScanner->getClassNames();
+ foreach ($fsClasses as $fsClassName) {
+ $this->classToFileScanner[$fsClassName] = $fsIndex;
+ }
+ }
+ }
+
+ /**
+ * Export
+ *
+ * @todo implement method
+ */
+ public static function export()
+ {
+ // @todo
+ }
+
+ /**
+ * __ToString
+ *
+ * @todo implement method
+ */
+ public function __toString()
+ {
+ // @todo
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/DocBlockScanner.php zendframework-2.2.6/library/Zend/Code/Scanner/DocBlockScanner.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/DocBlockScanner.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/DocBlockScanner.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,324 @@
+docComment = $docComment;
+ $this->nameInformation = $nameInformation;
+ }
+
+ /**
+ * @return string
+ */
+ public function getShortDescription()
+ {
+ $this->scan();
+
+ return $this->shortDescription;
+ }
+
+ /**
+ * @return string
+ */
+ public function getLongDescription()
+ {
+ $this->scan();
+
+ return $this->longDescription;
+ }
+
+ /**
+ * @return array
+ */
+ public function getTags()
+ {
+ $this->scan();
+
+ return $this->tags;
+ }
+
+ /**
+ * @return array
+ */
+ public function getAnnotations()
+ {
+ $this->scan();
+
+ return $this->annotations;
+ }
+
+ /**
+ * @return void
+ */
+ protected function scan()
+ {
+ if ($this->isScanned) {
+ return;
+ }
+
+ $mode = 1;
+
+ $tokens = $this->tokenize();
+ $tagIndex = null;
+ reset($tokens);
+
+ SCANNER_TOP:
+ $token = current($tokens);
+
+ switch ($token[0]) {
+ case 'DOCBLOCK_NEWLINE':
+ if ($this->shortDescription != '' && $tagIndex === null) {
+ $mode = 2;
+ } else {
+ $this->longDescription .= $token[1];
+ }
+ goto SCANNER_CONTINUE;
+
+ case 'DOCBLOCK_WHITESPACE':
+ case 'DOCBLOCK_TEXT':
+ if ($tagIndex !== null) {
+ $this->tags[$tagIndex]['value'] .= ($this->tags[$tagIndex]['value'] == '') ? $token[1] : ' ' . $token[1];
+ goto SCANNER_CONTINUE;
+ } elseif ($mode <= 2) {
+ if ($mode == 1) {
+ $this->shortDescription .= $token[1];
+ } else {
+ $this->longDescription .= $token[1];
+ }
+ goto SCANNER_CONTINUE;
+ }
+ case 'DOCBLOCK_TAG':
+ array_push($this->tags, array('name' => $token[1],
+ 'value' => ''));
+ end($this->tags);
+ $tagIndex = key($this->tags);
+ $mode = 3;
+ goto SCANNER_CONTINUE;
+
+ case 'DOCBLOCK_COMMENTEND':
+ goto SCANNER_END;
+
+ }
+
+ SCANNER_CONTINUE:
+ if (next($tokens) === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_TOP;
+
+ SCANNER_END:
+
+ $this->shortDescription = trim($this->shortDescription);
+ $this->longDescription = trim($this->longDescription);
+ $this->isScanned = true;
+ }
+
+ /**
+ * @return array
+ */
+ protected function tokenize()
+ {
+ static $CONTEXT_INSIDE_DOCBLOCK = 0x01;
+ static $CONTEXT_INSIDE_ASTERISK = 0x02;
+
+ $context = 0x00;
+ $stream = $this->docComment;
+ $streamIndex = null;
+ $tokens = array();
+ $tokenIndex = null;
+ $currentChar = null;
+ $currentWord = null;
+ $currentLine = null;
+
+ $MACRO_STREAM_ADVANCE_CHAR = function ($positionsForward = 1) use (&$stream, &$streamIndex, &$currentChar, &$currentWord, &$currentLine) {
+ $positionsForward = ($positionsForward > 0) ? $positionsForward : 1;
+ $streamIndex = ($streamIndex === null) ? 0 : $streamIndex + $positionsForward;
+ if (!isset($stream[$streamIndex])) {
+ $currentChar = false;
+
+ return false;
+ }
+ $currentChar = $stream[$streamIndex];
+ $matches = array();
+ $currentLine = (preg_match('#(.*?)\r?\n#', $stream, $matches, null,
+ $streamIndex) === 1) ? $matches[1] : substr($stream, $streamIndex);
+ if ($currentChar === ' ') {
+ $currentWord = (preg_match('#( +)#', $currentLine, $matches) === 1) ? $matches[1] : $currentLine;
+ } else {
+ $currentWord = (($matches = strpos($currentLine, ' ')) !== false) ? substr($currentLine, 0, $matches) : $currentLine;
+ }
+
+ return $currentChar;
+ };
+ $MACRO_STREAM_ADVANCE_WORD = function () use (&$currentWord, &$MACRO_STREAM_ADVANCE_CHAR) {
+ return $MACRO_STREAM_ADVANCE_CHAR(strlen($currentWord));
+ };
+ $MACRO_STREAM_ADVANCE_LINE = function () use (&$currentLine, &$MACRO_STREAM_ADVANCE_CHAR) {
+ return $MACRO_STREAM_ADVANCE_CHAR(strlen($currentLine));
+ };
+ $MACRO_TOKEN_ADVANCE = function () use (&$tokenIndex, &$tokens) {
+ $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1;
+ $tokens[$tokenIndex] = array('DOCBLOCK_UNKNOWN', '');
+ };
+ $MACRO_TOKEN_SET_TYPE = function ($type) use (&$tokenIndex, &$tokens) {
+ $tokens[$tokenIndex][0] = $type;
+ };
+ $MACRO_TOKEN_APPEND_CHAR = function () use (&$currentChar, &$tokens, &$tokenIndex) {
+ $tokens[$tokenIndex][1] .= $currentChar;
+ };
+ $MACRO_TOKEN_APPEND_WORD = function () use (&$currentWord, &$tokens, &$tokenIndex) {
+ $tokens[$tokenIndex][1] .= $currentWord;
+ };
+ $MACRO_TOKEN_APPEND_WORD_PARTIAL = function ($length) use (&$currentWord, &$tokens, &$tokenIndex) {
+ $tokens[$tokenIndex][1] .= substr($currentWord, 0, $length);
+ };
+ $MACRO_TOKEN_APPEND_LINE = function () use (&$currentLine, &$tokens, &$tokenIndex) {
+ $tokens[$tokenIndex][1] .= $currentLine;
+ };
+
+ $MACRO_STREAM_ADVANCE_CHAR();
+ $MACRO_TOKEN_ADVANCE();
+
+ TOKENIZER_TOP:
+
+ if ($context === 0x00 && $currentChar === '/' && $currentWord === '/**') {
+ $MACRO_TOKEN_SET_TYPE('DOCBLOCK_COMMENTSTART');
+ $MACRO_TOKEN_APPEND_WORD();
+ $MACRO_TOKEN_ADVANCE();
+ $context |= $CONTEXT_INSIDE_DOCBLOCK;
+ $context |= $CONTEXT_INSIDE_ASTERISK;
+ if ($MACRO_STREAM_ADVANCE_WORD() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ if ($context & $CONTEXT_INSIDE_DOCBLOCK && $currentWord === '*/') {
+ $MACRO_TOKEN_SET_TYPE('DOCBLOCK_COMMENTEND');
+ $MACRO_TOKEN_APPEND_WORD();
+ $MACRO_TOKEN_ADVANCE();
+ $context &= ~$CONTEXT_INSIDE_DOCBLOCK;
+ if ($MACRO_STREAM_ADVANCE_WORD() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ if ($currentChar === ' ' || $currentChar === "\t") {
+ $MACRO_TOKEN_SET_TYPE(($context & $CONTEXT_INSIDE_ASTERISK) ? 'DOCBLOCK_WHITESPACE' : 'DOCBLOCK_WHITESPACE_INDENT');
+ $MACRO_TOKEN_APPEND_WORD();
+ $MACRO_TOKEN_ADVANCE();
+ if ($MACRO_STREAM_ADVANCE_WORD() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ if ($currentChar === '*') {
+ if (($context & $CONTEXT_INSIDE_DOCBLOCK) && ($context & $CONTEXT_INSIDE_ASTERISK)) {
+ $MACRO_TOKEN_SET_TYPE('DOCBLOCK_TEXT');
+ } else {
+ $MACRO_TOKEN_SET_TYPE('DOCBLOCK_ASTERISK');
+ $context |= $CONTEXT_INSIDE_ASTERISK;
+ }
+ $MACRO_TOKEN_APPEND_CHAR();
+ $MACRO_TOKEN_ADVANCE();
+ if ($MACRO_STREAM_ADVANCE_CHAR() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ if ($currentChar === '@') {
+ $MACRO_TOKEN_SET_TYPE('DOCBLOCK_TAG');
+ $MACRO_TOKEN_APPEND_WORD();
+ $MACRO_TOKEN_ADVANCE();
+ if ($MACRO_STREAM_ADVANCE_WORD() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ if ($currentChar === "\n") {
+ $MACRO_TOKEN_SET_TYPE('DOCBLOCK_NEWLINE');
+ $MACRO_TOKEN_APPEND_CHAR();
+ $MACRO_TOKEN_ADVANCE();
+ $context &= ~$CONTEXT_INSIDE_ASTERISK;
+ if ($MACRO_STREAM_ADVANCE_CHAR() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+ }
+
+ $MACRO_TOKEN_SET_TYPE('DOCBLOCK_TEXT');
+ $MACRO_TOKEN_APPEND_LINE();
+ $MACRO_TOKEN_ADVANCE();
+ if ($MACRO_STREAM_ADVANCE_LINE() === false) {
+ goto TOKENIZER_END;
+ }
+ goto TOKENIZER_TOP;
+
+ TOKENIZER_END:
+
+ array_pop($tokens);
+
+ return $tokens;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/FileScanner.php zendframework-2.2.6/library/Zend/Code/Scanner/FileScanner.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/FileScanner.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/FileScanner.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,46 @@
+file = $file;
+ if (!file_exists($file)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'File "%s" not found',
+ $file
+ ));
+ }
+ parent::__construct(token_get_all(file_get_contents($file)), $annotationManager);
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getFile()
+ {
+ return $this->file;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/FunctionScanner.php zendframework-2.2.6/library/Zend/Code/Scanner/FunctionScanner.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/FunctionScanner.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/FunctionScanner.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,16 @@
+tokens = $methodTokens;
+ $this->nameInformation = $nameInformation;
+ }
+
+ /**
+ * @param string $class
+ * @return MethodScanner
+ */
+ public function setClass($class)
+ {
+ $this->class = (string) $class;
+ return $this;
+ }
+
+ /**
+ * @param ClassScanner $scannerClass
+ * @return MethodScanner
+ */
+ public function setScannerClass(ClassScanner $scannerClass)
+ {
+ $this->scannerClass = $scannerClass;
+ return $this;
+ }
+
+ /**
+ * @return MethodScanner
+ */
+ public function getClassScanner()
+ {
+ return $this->scannerClass;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ $this->scan();
+
+ return $this->name;
+ }
+
+ /**
+ * @return int
+ */
+ public function getLineStart()
+ {
+ $this->scan();
+
+ return $this->lineStart;
+ }
+
+ /**
+ * @return int
+ */
+ public function getLineEnd()
+ {
+ $this->scan();
+
+ return $this->lineEnd;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDocComment()
+ {
+ $this->scan();
+
+ return $this->docComment;
+ }
+
+ /**
+ * @param AnnotationManager $annotationManager
+ * @return AnnotationScanner
+ */
+ public function getAnnotations(AnnotationManager $annotationManager)
+ {
+ if (($docComment = $this->getDocComment()) == '') {
+ return false;
+ }
+
+ return new AnnotationScanner($annotationManager, $docComment, $this->nameInformation);
+ }
+
+ /**
+ * @return bool
+ */
+ public function isFinal()
+ {
+ $this->scan();
+
+ return $this->isFinal;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isAbstract()
+ {
+ $this->scan();
+
+ return $this->isAbstract;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isPublic()
+ {
+ $this->scan();
+
+ return $this->isPublic;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isProtected()
+ {
+ $this->scan();
+
+ return $this->isProtected;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isPrivate()
+ {
+ $this->scan();
+
+ return $this->isPrivate;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isStatic()
+ {
+ $this->scan();
+
+ return $this->isStatic;
+ }
+
+ /**
+ * @return int
+ */
+ public function getNumberOfParameters()
+ {
+ return count($this->getParameters());
+ }
+
+ /**
+ * @param bool $returnScanner
+ * @return array
+ */
+ public function getParameters($returnScanner = false)
+ {
+ $this->scan();
+
+ $return = array();
+
+ foreach ($this->infos as $info) {
+ if ($info['type'] != 'parameter') {
+ continue;
+ }
+
+ if (!$returnScanner) {
+ $return[] = $info['name'];
+ } else {
+ $return[] = $this->getParameter($info['name']);
+ }
+ }
+
+ return $return;
+ }
+
+ /**
+ * @param int|string $parameterNameOrInfoIndex
+ * @return ParameterScanner
+ * @throws Exception\InvalidArgumentException
+ */
+ public function getParameter($parameterNameOrInfoIndex)
+ {
+ $this->scan();
+
+ if (is_int($parameterNameOrInfoIndex)) {
+ $info = $this->infos[$parameterNameOrInfoIndex];
+ if ($info['type'] != 'parameter') {
+ throw new Exception\InvalidArgumentException('Index of info offset is not about a parameter');
+ }
+ } elseif (is_string($parameterNameOrInfoIndex)) {
+ foreach ($this->infos as $info) {
+ if ($info['type'] === 'parameter' && $info['name'] === $parameterNameOrInfoIndex) {
+ break;
+ }
+ unset($info);
+ }
+ if (!isset($info)) {
+ throw new Exception\InvalidArgumentException('Index of info offset is not about a parameter');
+ }
+ }
+
+ $p = new ParameterScanner(
+ array_slice($this->tokens, $info['tokenStart'], $info['tokenEnd'] - $info['tokenStart']),
+ $this->nameInformation
+ );
+ $p->setDeclaringFunction($this->name);
+ $p->setDeclaringScannerFunction($this);
+ $p->setDeclaringClass($this->class);
+ $p->setDeclaringScannerClass($this->scannerClass);
+ $p->setPosition($info['position']);
+
+ return $p;
+ }
+
+ /**
+ * @return string
+ */
+ public function getBody()
+ {
+ $this->scan();
+
+ return $this->body;
+ }
+
+ public static function export()
+ {
+ // @todo
+ }
+
+ public function __toString()
+ {
+ $this->scan();
+
+ return var_export($this, true);
+ }
+
+ protected function scan()
+ {
+ if ($this->isScanned) {
+ return;
+ }
+
+ if (!$this->tokens) {
+ throw new Exception\RuntimeException('No tokens were provided');
+ }
+
+ /**
+ * Variables & Setup
+ */
+
+ $tokens = &$this->tokens; // localize
+ $infos = &$this->infos; // localize
+ $tokenIndex = null;
+ $token = null;
+ $tokenType = null;
+ $tokenContent = null;
+ $tokenLine = null;
+ $infoIndex = 0;
+ $parentCount = 0;
+
+ /*
+ * MACRO creation
+ */
+ $MACRO_TOKEN_ADVANCE = function () use (&$tokens, &$tokenIndex, &$token, &$tokenType, &$tokenContent, &$tokenLine) {
+ static $lastTokenArray = null;
+ $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1;
+ if (!isset($tokens[$tokenIndex])) {
+ $token = false;
+ $tokenContent = false;
+ $tokenType = false;
+ $tokenLine = false;
+
+ return false;
+ }
+ $token = $tokens[$tokenIndex];
+ if (is_string($token)) {
+ $tokenType = null;
+ $tokenContent = $token;
+ $tokenLine = $tokenLine + substr_count($lastTokenArray[1],
+ "\n"); // adjust token line by last known newline count
+ } else {
+ list($tokenType, $tokenContent, $tokenLine) = $token;
+ }
+
+ return $tokenIndex;
+ };
+ $MACRO_INFO_START = function () use (&$infoIndex, &$infos, &$tokenIndex, &$tokenLine) {
+ $infos[$infoIndex] = array(
+ 'type' => 'parameter',
+ 'tokenStart' => $tokenIndex,
+ 'tokenEnd' => null,
+ 'lineStart' => $tokenLine,
+ 'lineEnd' => $tokenLine,
+ 'name' => null,
+ 'position' => $infoIndex + 1, // position is +1 of infoIndex
+ );
+ };
+ $MACRO_INFO_ADVANCE = function () use (&$infoIndex, &$infos, &$tokenIndex, &$tokenLine) {
+ $infos[$infoIndex]['tokenEnd'] = $tokenIndex;
+ $infos[$infoIndex]['lineEnd'] = $tokenLine;
+ $infoIndex++;
+
+ return $infoIndex;
+ };
+
+ /**
+ * START FINITE STATE MACHINE FOR SCANNING TOKENS
+ */
+
+ // Initialize token
+ $MACRO_TOKEN_ADVANCE();
+
+ SCANNER_TOP:
+
+ $this->lineStart = ($this->lineStart) ? : $tokenLine;
+
+ switch ($tokenType) {
+ case T_DOC_COMMENT:
+ $this->lineStart = null;
+ if ($this->docComment === null && $this->name === null) {
+ $this->docComment = $tokenContent;
+ }
+ goto SCANNER_CONTINUE_SIGNATURE;
+
+ case T_FINAL:
+ $this->isFinal = true;
+ goto SCANNER_CONTINUE_SIGNATURE;
+
+ case T_ABSTRACT:
+ $this->isAbstract = true;
+ goto SCANNER_CONTINUE_SIGNATURE;
+
+ case T_PUBLIC:
+ // use defaults
+ goto SCANNER_CONTINUE_SIGNATURE;
+
+ case T_PROTECTED:
+ $this->isProtected = true;
+ $this->isPublic = false;
+ goto SCANNER_CONTINUE_SIGNATURE;
+
+ case T_PRIVATE:
+ $this->isPrivate = true;
+ $this->isPublic = false;
+ goto SCANNER_CONTINUE_SIGNATURE;
+
+ case T_STATIC:
+ $this->isStatic = true;
+ goto SCANNER_CONTINUE_SIGNATURE;
+
+ case T_VARIABLE:
+ case T_STRING:
+
+ if ($tokenType === T_STRING && $parentCount === 0) {
+ $this->name = $tokenContent;
+ }
+
+ if ($parentCount === 1) {
+ if (!isset($infos[$infoIndex])) {
+ $MACRO_INFO_START();
+ }
+ if ($tokenType === T_VARIABLE) {
+ $infos[$infoIndex]['name'] = ltrim($tokenContent, '$');
+ }
+ }
+
+ goto SCANNER_CONTINUE_SIGNATURE;
+
+ case null:
+
+ switch ($tokenContent) {
+ case '&':
+ if (!isset($infos[$infoIndex])) {
+ $MACRO_INFO_START();
+ }
+ goto SCANNER_CONTINUE_SIGNATURE;
+ case '(':
+ $parentCount++;
+ goto SCANNER_CONTINUE_SIGNATURE;
+ case ')':
+ $parentCount--;
+ if($parentCount > 0) {
+ goto SCANNER_CONTINUE_SIGNATURE;
+ }
+ if ($parentCount === 0) {
+ if ($infos) {
+ $MACRO_INFO_ADVANCE();
+ }
+ $context = 'body';
+ }
+ goto SCANNER_CONTINUE_BODY;
+ case ',':
+ if ($parentCount === 1) {
+ $MACRO_INFO_ADVANCE();
+ }
+ goto SCANNER_CONTINUE_SIGNATURE;
+ }
+ }
+
+ SCANNER_CONTINUE_SIGNATURE:
+
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_TOP;
+
+ SCANNER_CONTINUE_BODY:
+
+ $braceCount = 0;
+ while ($MACRO_TOKEN_ADVANCE() !== false) {
+ if ($tokenContent == '}') {
+ $braceCount--;
+ }
+ if ($braceCount > 0) {
+ $this->body .= $tokenContent;
+ }
+ if ($tokenContent == '{') {
+ $braceCount++;
+ }
+ $this->lineEnd = $tokenLine;
+ }
+
+ SCANNER_END:
+
+ $this->isScanned = true;
+
+ return;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/ParameterScanner.php zendframework-2.2.6/library/Zend/Code/Scanner/ParameterScanner.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/ParameterScanner.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/ParameterScanner.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,353 @@
+tokens = $parameterTokens;
+ $this->nameInformation = $nameInformation;
+ }
+
+ /**
+ * Set declaring class
+ *
+ * @param string $class
+ * @return void
+ */
+ public function setDeclaringClass($class)
+ {
+ $this->declaringClass = (string) $class;
+ }
+
+ /**
+ * Set declaring scanner class
+ *
+ * @param ClassScanner $scannerClass
+ * @return void
+ */
+ public function setDeclaringScannerClass(ClassScanner $scannerClass)
+ {
+ $this->declaringScannerClass = $scannerClass;
+ }
+
+ /**
+ * Set declaring function
+ *
+ * @param string $function
+ * @return void
+ */
+ public function setDeclaringFunction($function)
+ {
+ $this->declaringFunction = $function;
+ }
+
+ /**
+ * Set declaring scanner function
+ *
+ * @param MethodScanner $scannerFunction
+ * @return void
+ */
+ public function setDeclaringScannerFunction(MethodScanner $scannerFunction)
+ {
+ $this->declaringScannerFunction = $scannerFunction;
+ }
+
+ /**
+ * Set position
+ *
+ * @param int $position
+ * @return void
+ */
+ public function setPosition($position)
+ {
+ $this->position = $position;
+ }
+
+ /**
+ * Scan
+ *
+ * @return void
+ */
+ protected function scan()
+ {
+ if ($this->isScanned) {
+ return;
+ }
+
+ $tokens = &$this->tokens;
+
+ reset($tokens);
+
+ SCANNER_TOP:
+
+ $token = current($tokens);
+
+ if (is_string($token)) {
+ // check pass by ref
+ if ($token === '&') {
+ $this->isPassedByReference = true;
+ goto SCANNER_CONTINUE;
+ }
+ if ($token === '=') {
+ $this->isOptional = true;
+ $this->isDefaultValueAvailable = true;
+ goto SCANNER_CONTINUE;
+ }
+ } else {
+ if ($this->name === null && ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR)) {
+ $this->class .= $token[1];
+ goto SCANNER_CONTINUE;
+ }
+ if ($token[0] === T_VARIABLE) {
+ $this->name = ltrim($token[1], '$');
+ goto SCANNER_CONTINUE;
+ }
+
+ }
+
+ if ($this->name !== null) {
+ $this->defaultValue .= trim((is_string($token)) ? $token : $token[1]);
+ }
+
+ SCANNER_CONTINUE:
+
+ if (next($this->tokens) === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_TOP;
+
+ SCANNER_END:
+
+ if ($this->class && $this->nameInformation) {
+ $this->class = $this->nameInformation->resolveName($this->class);
+ }
+
+ $this->isScanned = true;
+ }
+
+ /**
+ * Get declaring scanner class
+ *
+ * @return ClassScanner
+ */
+ public function getDeclaringScannerClass()
+ {
+ return $this->declaringScannerClass;
+ }
+
+ /**
+ * Get declaring class
+ *
+ * @return string
+ */
+ public function getDeclaringClass()
+ {
+ return $this->declaringClass;
+ }
+
+ /**
+ * Get declaring scanner function
+ *
+ * @return MethodScanner
+ */
+ public function getDeclaringScannerFunction()
+ {
+ return $this->declaringScannerFunction;
+ }
+
+ /**
+ * Get declaring function
+ *
+ * @return string
+ */
+ public function getDeclaringFunction()
+ {
+ return $this->declaringFunction;
+ }
+
+ /**
+ * Get default value
+ *
+ * @return string
+ */
+ public function getDefaultValue()
+ {
+ $this->scan();
+
+ return $this->defaultValue;
+ }
+
+ /**
+ * Get class
+ *
+ * @return string
+ */
+ public function getClass()
+ {
+ $this->scan();
+
+ return $this->class;
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ $this->scan();
+
+ return $this->name;
+ }
+
+ /**
+ * Get position
+ *
+ * @return int
+ */
+ public function getPosition()
+ {
+ $this->scan();
+
+ return $this->position;
+ }
+
+ /**
+ * Check if is array
+ *
+ * @return bool
+ */
+ public function isArray()
+ {
+ $this->scan();
+
+ return $this->isArray;
+ }
+
+ /**
+ * Check if default value is available
+ *
+ * @return bool
+ */
+ public function isDefaultValueAvailable()
+ {
+ $this->scan();
+
+ return $this->isDefaultValueAvailable;
+ }
+
+ /**
+ * Check if is optional
+ *
+ * @return bool
+ */
+ public function isOptional()
+ {
+ $this->scan();
+
+ return $this->isOptional;
+ }
+
+ /**
+ * Check if is passed by reference
+ *
+ * @return bool
+ */
+ public function isPassedByReference()
+ {
+ $this->scan();
+
+ return $this->isPassedByReference;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/PropertyScanner.php zendframework-2.2.6/library/Zend/Code/Scanner/PropertyScanner.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/PropertyScanner.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/PropertyScanner.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,284 @@
+tokens = $propertyTokens;
+ $this->nameInformation = $nameInformation;
+ }
+
+ /**
+ * @param string $class
+ */
+ public function setClass($class)
+ {
+ $this->class = $class;
+ }
+
+ /**
+ * @param ClassScanner $scannerClass
+ */
+ public function setScannerClass(ClassScanner $scannerClass)
+ {
+ $this->scannerClass = $scannerClass;
+ }
+
+ /**
+ * @return ClassScanner
+ */
+ public function getClassScanner()
+ {
+ return $this->scannerClass;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ $this->scan();
+ return $this->name;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isPublic()
+ {
+ $this->scan();
+ return $this->isPublic;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isPrivate()
+ {
+ $this->scan();
+ return $this->isPrivate;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isProtected()
+ {
+ $this->scan();
+ return $this->isProtected;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isStatic()
+ {
+ $this->scan();
+ return $this->isStatic;
+ }
+
+ /**
+ * @return string
+ */
+ public function getValue()
+ {
+ $this->scan();
+ return $this->value;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDocComment()
+ {
+ $this->scan();
+ return $this->docComment;
+ }
+
+ /**
+ * @param Annotation\AnnotationManager $annotationManager
+ * @return AnnotationScanner
+ */
+ public function getAnnotations(Annotation\AnnotationManager $annotationManager)
+ {
+ if (($docComment = $this->getDocComment()) == '') {
+ return false;
+ }
+
+ return new AnnotationScanner($annotationManager, $docComment, $this->nameInformation);
+ }
+
+ /**
+ * @return string
+ */
+ public function __toString()
+ {
+ $this->scan();
+ return var_export($this, true);
+ }
+
+ /**
+ * Scan tokens
+ *
+ * @throws \Zend\Code\Exception\RuntimeException
+ */
+ protected function scan()
+ {
+ if ($this->isScanned) {
+ return;
+ }
+
+ if (!$this->tokens) {
+ throw new Exception\RuntimeException('No tokens were provided');
+ }
+
+ /**
+ * Variables & Setup
+ */
+ $tokens = &$this->tokens;
+
+ reset($tokens);
+
+ SCANNER_TOP:
+
+ $token = current($tokens);
+
+ if (!is_string($token)) {
+ list($tokenType, $tokenContent, $tokenLine) = $token;
+
+ switch ($tokenType) {
+ case T_DOC_COMMENT:
+ if ($this->docComment === null && $this->name === null) {
+ $this->docComment = $tokenContent;
+ }
+ goto SCANNER_CONTINUE;
+
+ case T_VARIABLE:
+ $this->name = ltrim($tokenContent, '$');
+ goto SCANNER_CONTINUE;
+
+ case T_PUBLIC:
+ // use defaults
+ goto SCANNER_CONTINUE;
+
+ case T_PROTECTED:
+ $this->isProtected = true;
+ $this->isPublic = false;
+ goto SCANNER_CONTINUE;
+
+ case T_PRIVATE:
+ $this->isPrivate = true;
+ $this->isPublic = false;
+ goto SCANNER_CONTINUE;
+
+ case T_STATIC:
+ $this->isStatic = true;
+ goto SCANNER_CONTINUE;
+
+ default:
+ if ($this->name !== null && trim($tokenContent) !== '') {
+ $this->value .= (is_string($token)) ? $token : $tokenContent;
+ if (substr($this->value, 0, 1) === '"' || substr($this->value, 0, 1) === "'") {
+ $this->value = substr($this->value, 1, -1); // Remove quotes
+ }
+ }
+ goto SCANNER_CONTINUE;
+ }
+ }
+
+ SCANNER_CONTINUE:
+
+ if (next($this->tokens) === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_TOP;
+
+ SCANNER_END:
+
+ $this->isScanned = true;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/ScannerInterface.php zendframework-2.2.6/library/Zend/Code/Scanner/ScannerInterface.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/ScannerInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/ScannerInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,16 @@
+tokens = $tokens;
+ $this->annotationManager = $annotationManager;
+ }
+
+ /**
+ * @return AnnotationManager
+ */
+ public function getAnnotationManager()
+ {
+ return $this->annotationManager;
+ }
+
+ /**
+ * Get doc comment
+ *
+ * @todo Assignment of $this->docComment should probably be done in scan()
+ * and then $this->getDocComment() just retrieves it.
+ *
+ * @return string
+ */
+ public function getDocComment()
+ {
+ foreach ($this->tokens as $token) {
+ $type = $token[0];
+ $value = $token[1];
+ if (($type == T_OPEN_TAG) || ($type == T_WHITESPACE)) {
+ continue;
+ } elseif ($type == T_DOC_COMMENT) {
+ $this->docComment = $value;
+
+ return $this->docComment;
+ } else {
+ // Only whitespace is allowed before file docblocks
+ return;
+ }
+ }
+ }
+
+ /**
+ * @return array
+ */
+ public function getNamespaces()
+ {
+ $this->scan();
+
+ $namespaces = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] == 'namespace') {
+ $namespaces[] = $info['namespace'];
+ }
+ }
+
+ return $namespaces;
+ }
+
+ /**
+ * @param null|string $namespace
+ * @return array|null
+ */
+ public function getUses($namespace = null)
+ {
+ $this->scan();
+
+ return $this->getUsesNoScan($namespace);
+ }
+
+ /**
+ * @return array
+ */
+ public function getIncludes()
+ {
+ $this->scan();
+ // @todo Implement getIncludes() in TokenArrayScanner
+ }
+
+ /**
+ * @return array
+ */
+ public function getClassNames()
+ {
+ $this->scan();
+
+ $return = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] != 'class') {
+ continue;
+ }
+
+ $return[] = $info['name'];
+ }
+
+ return $return;
+ }
+
+ /**
+ * @return ClassScanner[]
+ */
+ public function getClasses()
+ {
+ $this->scan();
+
+ $return = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] != 'class') {
+ continue;
+ }
+
+ $return[] = $this->getClass($info['name']);
+ }
+
+ return $return;
+ }
+
+ /**
+ * Return the class object from this scanner
+ *
+ * @param string|int $name
+ * @throws Exception\InvalidArgumentException
+ * @return ClassScanner
+ */
+ public function getClass($name)
+ {
+ $this->scan();
+
+ if (is_int($name)) {
+ $info = $this->infos[$name];
+ if ($info['type'] != 'class') {
+ throw new Exception\InvalidArgumentException('Index of info offset is not about a class');
+ }
+ } elseif (is_string($name)) {
+ $classFound = false;
+ foreach ($this->infos as $info) {
+ if ($info['type'] === 'class' && $info['name'] === $name) {
+ $classFound = true;
+ break;
+ }
+ }
+
+ if (!$classFound) {
+ return false;
+ }
+ }
+
+ return new ClassScanner(
+ array_slice(
+ $this->tokens,
+ $info['tokenStart'],
+ ($info['tokenEnd'] - $info['tokenStart'] + 1)
+ ), // zero indexed array
+ new NameInformation($info['namespace'], $info['uses'])
+ );
+ }
+
+ /**
+ * @param string $className
+ * @return bool|null|NameInformation
+ */
+ public function getClassNameInformation($className)
+ {
+ $this->scan();
+
+ $classFound = false;
+ foreach ($this->infos as $info) {
+ if ($info['type'] === 'class' && $info['name'] === $className) {
+ $classFound = true;
+ break;
+ }
+ }
+
+ if (!$classFound) {
+ return false;
+ }
+
+ if (!isset($info)) {
+ return null;
+ }
+
+ return new NameInformation($info['namespace'], $info['uses']);
+ }
+
+ /**
+ * @return array
+ */
+ public function getFunctionNames()
+ {
+ $this->scan();
+ $functionNames = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] == 'function') {
+ $functionNames[] = $info['name'];
+ }
+ }
+
+ return $functionNames;
+ }
+
+ /**
+ * @return array
+ */
+ public function getFunctions()
+ {
+ $this->scan();
+
+ $functions = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] == 'function') {
+ // @todo $functions[] = new FunctionScanner($info['name']);
+ }
+ }
+
+ return $functions;
+ }
+
+ /**
+ * Export
+ *
+ * @param $tokens
+ */
+ public static function export($tokens)
+ {
+ // @todo
+ }
+
+ public function __toString()
+ {
+ // @todo
+ }
+
+ /**
+ * Scan
+ *
+ * @todo: $this->docComment should be assigned for valid docblock during
+ * the scan instead of $this->getDocComment() (starting with
+ * T_DOC_COMMENT case)
+ *
+ * @throws Exception\RuntimeException
+ */
+ protected function scan()
+ {
+ if ($this->isScanned) {
+ return;
+ }
+
+ if (!$this->tokens) {
+ throw new Exception\RuntimeException('No tokens were provided');
+ }
+
+ /**
+ * Variables & Setup
+ */
+
+ $tokens = &$this->tokens; // localize
+ $infos = &$this->infos; // localize
+ $tokenIndex = null;
+ $token = null;
+ $tokenType = null;
+ $tokenContent = null;
+ $tokenLine = null;
+ $namespace = null;
+ $docCommentIndex = false;
+ $infoIndex = 0;
+
+ /*
+ * MACRO creation
+ */
+ $MACRO_TOKEN_ADVANCE = function () use (&$tokens, &$tokenIndex, &$token, &$tokenType, &$tokenContent, &$tokenLine) {
+ $tokenIndex = ($tokenIndex === null) ? 0 : $tokenIndex + 1;
+ if (!isset($tokens[$tokenIndex])) {
+ $token = false;
+ $tokenContent = false;
+ $tokenType = false;
+ $tokenLine = false;
+
+ return false;
+ }
+ if (is_string($tokens[$tokenIndex]) && $tokens[$tokenIndex] === '"') {
+ do {
+ $tokenIndex++;
+ } while (!(is_string($tokens[$tokenIndex]) && $tokens[$tokenIndex] === '"'));
+ }
+ $token = $tokens[$tokenIndex];
+ if (is_array($token)) {
+ list($tokenType, $tokenContent, $tokenLine) = $token;
+ } else {
+ $tokenType = null;
+ $tokenContent = $token;
+ }
+
+ return $tokenIndex;
+ };
+ $MACRO_TOKEN_LOGICAL_START_INDEX = function () use (&$tokenIndex, &$docCommentIndex) {
+ return ($docCommentIndex === false) ? $tokenIndex : $docCommentIndex;
+ };
+ $MACRO_DOC_COMMENT_START = function () use (&$tokenIndex, &$docCommentIndex) {
+ $docCommentIndex = $tokenIndex;
+
+ return $docCommentIndex;
+ };
+ $MACRO_DOC_COMMENT_VALIDATE = function () use (&$tokenType, &$docCommentIndex) {
+ static $validTrailingTokens = null;
+ if ($validTrailingTokens === null) {
+ $validTrailingTokens = array(T_WHITESPACE, T_FINAL, T_ABSTRACT, T_INTERFACE, T_CLASS, T_FUNCTION);
+ }
+ if ($docCommentIndex !== false && !in_array($tokenType, $validTrailingTokens)) {
+ $docCommentIndex = false;
+ }
+
+ return $docCommentIndex;
+ };
+ $MACRO_INFO_ADVANCE = function () use (&$infoIndex, &$infos, &$tokenIndex, &$tokenLine) {
+ $infos[$infoIndex]['tokenEnd'] = $tokenIndex;
+ $infos[$infoIndex]['lineEnd'] = $tokenLine;
+ $infoIndex++;
+
+ return $infoIndex;
+ };
+
+ /**
+ * START FINITE STATE MACHINE FOR SCANNING TOKENS
+ */
+
+ // Initialize token
+ $MACRO_TOKEN_ADVANCE();
+
+ SCANNER_TOP:
+
+ if ($token === false) {
+ goto SCANNER_END;
+ }
+
+ // Validate current doc comment index
+ $MACRO_DOC_COMMENT_VALIDATE();
+
+ switch ($tokenType) {
+
+ case T_DOC_COMMENT:
+
+ $MACRO_DOC_COMMENT_START();
+ goto SCANNER_CONTINUE;
+
+ case T_NAMESPACE:
+
+ $infos[$infoIndex] = array(
+ 'type' => 'namespace',
+ 'tokenStart' => $MACRO_TOKEN_LOGICAL_START_INDEX(),
+ 'tokenEnd' => null,
+ 'lineStart' => $token[2],
+ 'lineEnd' => null,
+ 'namespace' => null,
+ );
+
+ // start processing with next token
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+
+ SCANNER_NAMESPACE_TOP:
+
+ if ($tokenType === null && $tokenContent === ';' || $tokenContent === '{') {
+ goto SCANNER_NAMESPACE_END;
+ }
+
+ if ($tokenType === T_WHITESPACE) {
+ goto SCANNER_NAMESPACE_CONTINUE;
+ }
+
+ if ($tokenType === T_NS_SEPARATOR || $tokenType === T_STRING) {
+ $infos[$infoIndex]['namespace'] .= $tokenContent;
+ }
+
+ SCANNER_NAMESPACE_CONTINUE:
+
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_NAMESPACE_TOP;
+
+ SCANNER_NAMESPACE_END:
+
+ $namespace = $infos[$infoIndex]['namespace'];
+
+ $MACRO_INFO_ADVANCE();
+ goto SCANNER_CONTINUE;
+
+ case T_USE:
+
+ $infos[$infoIndex] = array(
+ 'type' => 'use',
+ 'tokenStart' => $MACRO_TOKEN_LOGICAL_START_INDEX(),
+ 'tokenEnd' => null,
+ 'lineStart' => $tokens[$tokenIndex][2],
+ 'lineEnd' => null,
+ 'namespace' => $namespace,
+ 'statements' => array(0 => array('use' => null,
+ 'as' => null)),
+ );
+
+ $useStatementIndex = 0;
+ $useAsContext = false;
+
+ // start processing with next token
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+
+ SCANNER_USE_TOP:
+
+ if ($tokenType === null) {
+ if ($tokenContent === ';') {
+ goto SCANNER_USE_END;
+ } elseif ($tokenContent === ',') {
+ $useAsContext = false;
+ $useStatementIndex++;
+ $infos[$infoIndex]['statements'][$useStatementIndex] = array('use' => null,
+ 'as' => null);
+ }
+ }
+
+ // ANALYZE
+ if ($tokenType !== null) {
+
+ if ($tokenType == T_AS) {
+ $useAsContext = true;
+ goto SCANNER_USE_CONTINUE;
+ }
+
+ if ($tokenType == T_NS_SEPARATOR || $tokenType == T_STRING) {
+ if ($useAsContext == false) {
+ $infos[$infoIndex]['statements'][$useStatementIndex]['use'] .= $tokenContent;
+ } else {
+ $infos[$infoIndex]['statements'][$useStatementIndex]['as'] = $tokenContent;
+ }
+ }
+
+ }
+
+ SCANNER_USE_CONTINUE:
+
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_USE_TOP;
+
+ SCANNER_USE_END:
+
+ $MACRO_INFO_ADVANCE();
+ goto SCANNER_CONTINUE;
+
+ case T_INCLUDE:
+ case T_INCLUDE_ONCE:
+ case T_REQUIRE:
+ case T_REQUIRE_ONCE:
+
+ // Static for performance
+ static $includeTypes = array(
+ T_INCLUDE => 'include',
+ T_INCLUDE_ONCE => 'include_once',
+ T_REQUIRE => 'require',
+ T_REQUIRE_ONCE => 'require_once'
+ );
+
+ $infos[$infoIndex] = array(
+ 'type' => 'include',
+ 'tokenStart' => $MACRO_TOKEN_LOGICAL_START_INDEX(),
+ 'tokenEnd' => null,
+ 'lineStart' => $tokens[$tokenIndex][2],
+ 'lineEnd' => null,
+ 'includeType' => $includeTypes[$tokens[$tokenIndex][0]],
+ 'path' => '',
+ );
+
+ // start processing with next token
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+
+ SCANNER_INCLUDE_TOP:
+
+ if ($tokenType === null && $tokenContent === ';') {
+ goto SCANNER_INCLUDE_END;
+ }
+
+ $infos[$infoIndex]['path'] .= $tokenContent;
+
+ SCANNER_INCLUDE_CONTINUE:
+
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_INCLUDE_TOP;
+
+ SCANNER_INCLUDE_END:
+
+ $MACRO_INFO_ADVANCE();
+ goto SCANNER_CONTINUE;
+
+ case T_FUNCTION:
+ case T_FINAL:
+ case T_ABSTRACT:
+ case T_CLASS:
+ case T_INTERFACE:
+
+ $infos[$infoIndex] = array(
+ 'type' => ($tokenType === T_FUNCTION) ? 'function' : 'class',
+ 'tokenStart' => $MACRO_TOKEN_LOGICAL_START_INDEX(),
+ 'tokenEnd' => null,
+ 'lineStart' => $tokens[$tokenIndex][2],
+ 'lineEnd' => null,
+ 'namespace' => $namespace,
+ 'uses' => $this->getUsesNoScan($namespace),
+ 'name' => null,
+ 'shortName' => null,
+ );
+
+ $classBraceCount = 0;
+
+ // start processing with current token
+
+ SCANNER_CLASS_TOP:
+
+ // process the name
+ if ($infos[$infoIndex]['shortName'] == ''
+ && (($tokenType === T_CLASS || $tokenType === T_INTERFACE) && $infos[$infoIndex]['type'] === 'class'
+ || ($tokenType === T_FUNCTION && $infos[$infoIndex]['type'] === 'function'))
+ ) {
+ $infos[$infoIndex]['shortName'] = $tokens[$tokenIndex + 2][1];
+ $infos[$infoIndex]['name'] = (($namespace != null) ? $namespace . '\\' : '') . $infos[$infoIndex]['shortName'];
+ }
+
+ if ($tokenType === null) {
+ if ($tokenContent == '{') {
+ $classBraceCount++;
+ }
+ if ($tokenContent == '}') {
+ $classBraceCount--;
+ if ($classBraceCount === 0) {
+ goto SCANNER_CLASS_END;
+ }
+ }
+ }
+
+ SCANNER_CLASS_CONTINUE:
+
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_CLASS_TOP;
+
+ SCANNER_CLASS_END:
+
+ $MACRO_INFO_ADVANCE();
+ goto SCANNER_CONTINUE;
+
+ }
+
+ SCANNER_CONTINUE:
+
+ if ($MACRO_TOKEN_ADVANCE() === false) {
+ goto SCANNER_END;
+ }
+ goto SCANNER_TOP;
+
+ SCANNER_END:
+
+ /**
+ * END FINITE STATE MACHINE FOR SCANNING TOKENS
+ */
+
+ $this->isScanned = true;
+ }
+
+ /**
+ * Check for namespace
+ *
+ * @param string $namespace
+ * @return bool
+ */
+ public function hasNamespace($namespace)
+ {
+ $this->scan();
+
+ foreach ($this->infos as $info) {
+ if ($info['type'] == 'namespace' && $info['namespace'] == $namespace) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param string $namespace
+ * @return null|array
+ * @throws Exception\InvalidArgumentException
+ */
+ protected function getUsesNoScan($namespace)
+ {
+ $namespaces = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] == 'namespace') {
+ $namespaces[] = $info['namespace'];
+ }
+ }
+
+ if ($namespace === null) {
+ $namespace = array_shift($namespaces);
+ } elseif (!is_string($namespace)) {
+ throw new Exception\InvalidArgumentException('Invalid namespace provided');
+ } elseif (!in_array($namespace, $namespaces)) {
+ return null;
+ }
+
+ $uses = array();
+ foreach ($this->infos as $info) {
+ if ($info['type'] !== 'use') {
+ continue;
+ }
+ foreach ($info['statements'] as $statement) {
+ if ($info['namespace'] == $namespace) {
+ $uses[] = $statement;
+ }
+ }
+ }
+
+ return $uses;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/Util.php zendframework-2.2.6/library/Zend/Code/Scanner/Util.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/Util.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/Util.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,74 @@
+namespace && !$data->uses && strlen($value) > 0 && $value{0} != '\\') {
+ $value = $data->namespace . '\\' . $value;
+
+ return;
+ }
+
+ if (!$data->uses || strlen($value) <= 0 || $value{0} == '\\') {
+ $value = ltrim($value, '\\');
+
+ return;
+ }
+
+ if ($data->namespace || $data->uses) {
+ $firstPart = $value;
+ if (($firstPartEnd = strpos($firstPart, '\\')) !== false) {
+ $firstPart = substr($firstPart, 0, $firstPartEnd);
+ } else {
+ $firstPartEnd = strlen($firstPart);
+ }
+
+ if (array_key_exists($firstPart, $data->uses)) {
+ $value = substr_replace($value, $data->uses[$firstPart], 0, $firstPartEnd);
+
+ return;
+ }
+
+ if ($data->namespace) {
+ $value = $data->namespace . '\\' . $value;
+
+ return;
+ }
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Code/Scanner/ValueScanner.php zendframework-2.2.6/library/Zend/Code/Scanner/ValueScanner.php
--- zendframework-1.10.4/library/Zend/Code/Scanner/ValueScanner.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Code/Scanner/ValueScanner.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+_init();
- if ($options != null) {
- // use Zend_Config objects if provided
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- }
- // pass arrays to setOptions
- if (is_array($options)) {
- $this->setOptions($options);
- }
- }
- $this->_prepare();
- }
-
- /**
- * setConfig()
- *
- * @param Zend_Config $config
- * @return Zend_CodeGenerator_Abstract
- */
- public function setConfig(Zend_Config $config)
- {
- $this->setOptions($config->toArray());
- return $this;
- }
-
- /**
- * setOptions()
- *
- * @param array $options
- * @return Zend_CodeGenerator_Abstract
- */
- public function setOptions(Array $options)
- {
- foreach ($options as $optionName => $optionValue) {
- $methodName = 'set' . $optionName;
- if (method_exists($this, $methodName)) {
- $this->{$methodName}($optionValue);
- }
- }
- return $this;
- }
-
- /**
- * setSourceContent()
- *
- * @param string $sourceContent
- */
- public function setSourceContent($sourceContent)
- {
- $this->_sourceContent = $sourceContent;
- return;
- }
-
- /**
- * getSourceContent()
- *
- * @return string
- */
- public function getSourceContent()
- {
- return $this->_sourceContent;
- }
-
- /**
- * _init() - this is called before the constuctor
- *
- */
- protected function _init()
- {
-
- }
-
- /**
- * _prepare() - this is called at construction completion
- *
- */
- protected function _prepare()
- {
-
- }
-
- /**
- * generate() - must be implemented by the child
- *
- */
- abstract public function generate();
-
- /**
- * __toString() - casting to a string will in turn call generate()
- *
- * @return string
- */
- final public function __toString()
- {
- return $this->generate();
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Exception.php zendframework-2.2.6/library/Zend/CodeGenerator/Exception.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,35 +0,0 @@
-_isSourceDirty = ($isSourceDirty) ? true : false;
- return $this;
- }
-
- /**
- * isSourceDirty()
- *
- * @return bool
- */
- public function isSourceDirty()
- {
- return $this->_isSourceDirty;
- }
-
- /**
- * setIndentation()
- *
- * @param string|int $indentation
- * @return Zend_CodeGenerator_Php_Abstract
- */
- public function setIndentation($indentation)
- {
- $this->_indentation = $indentation;
- return $this;
- }
-
- /**
- * getIndentation()
- *
- * @return string|int
- */
- public function getIndentation()
- {
- return $this->_indentation;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Body.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Body.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Body.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Body.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,73 +0,0 @@
-_content = $content;
- return $this;
- }
-
- /**
- * getContent()
- *
- * @return string
- */
- public function getContent()
- {
- return (string) $this->_content;
- }
-
- /**
- * generate()
- *
- * @return string
- */
- public function generate()
- {
- return $this->getContent();
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Class.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Class.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Class.php 2010-04-16 20:41:42.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Class.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,513 +0,0 @@
-setSourceContent($class->getSourceContent());
- $class->setSourceDirty(false);
-
- if ($reflectionClass->getDocComment() != '') {
- $class->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionClass->getDocblock()));
- }
-
- $class->setAbstract($reflectionClass->isAbstract());
- $class->setName($reflectionClass->getName());
-
- if ($parentClass = $reflectionClass->getParentClass()) {
- $class->setExtendedClass($parentClass->getName());
- $interfaces = array_diff($reflectionClass->getInterfaces(), $parentClass->getInterfaces());
- } else {
- $interfaces = $reflectionClass->getInterfaces();
- }
-
- $interfaceNames = array();
- foreach($interfaces AS $interface) {
- $interfaceNames[] = $interface->getName();
- }
-
- $class->setImplementedInterfaces($interfaceNames);
-
- $properties = array();
- foreach ($reflectionClass->getProperties() as $reflectionProperty) {
- if ($reflectionProperty->getDeclaringClass()->getName() == $class->getName()) {
- $properties[] = Zend_CodeGenerator_Php_Property::fromReflection($reflectionProperty);
- }
- }
- $class->setProperties($properties);
-
- $methods = array();
- foreach ($reflectionClass->getMethods() as $reflectionMethod) {
- if ($reflectionMethod->getDeclaringClass()->getName() == $class->getName()) {
- $methods[] = Zend_CodeGenerator_Php_Method::fromReflection($reflectionMethod);
- }
- }
- $class->setMethods($methods);
-
- return $class;
- }
-
- /**
- * setDocblock() Set the docblock
- *
- * @param Zend_CodeGenerator_Php_Docblock|array|string $docblock
- * @return Zend_CodeGenerator_Php_File
- */
- public function setDocblock($docblock)
- {
- if (is_string($docblock)) {
- $docblock = array('shortDescription' => $docblock);
- }
-
- if (is_array($docblock)) {
- $docblock = new Zend_CodeGenerator_Php_Docblock($docblock);
- } elseif (!$docblock instanceof Zend_CodeGenerator_Php_Docblock) {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('setDocblock() is expecting either a string, array or an instance of Zend_CodeGenerator_Php_Docblock');
- }
-
- $this->_docblock = $docblock;
- return $this;
- }
-
- /**
- * getDocblock()
- *
- * @return Zend_CodeGenerator_Php_Docblock
- */
- public function getDocblock()
- {
- return $this->_docblock;
- }
-
- /**
- * setName()
- *
- * @param string $name
- * @return Zend_CodeGenerator_Php_Class
- */
- public function setName($name)
- {
- $this->_name = $name;
- return $this;
- }
-
- /**
- * getName()
- *
- * @return string
- */
- public function getName()
- {
- return $this->_name;
- }
-
- /**
- * setAbstract()
- *
- * @param bool $isAbstract
- * @return Zend_CodeGenerator_Php_Class
- */
- public function setAbstract($isAbstract)
- {
- $this->_isAbstract = ($isAbstract) ? true : false;
- return $this;
- }
-
- /**
- * isAbstract()
- *
- * @return bool
- */
- public function isAbstract()
- {
- return $this->_isAbstract;
- }
-
- /**
- * setExtendedClass()
- *
- * @param string $extendedClass
- * @return Zend_CodeGenerator_Php_Class
- */
- public function setExtendedClass($extendedClass)
- {
- $this->_extendedClass = $extendedClass;
- return $this;
- }
-
- /**
- * getExtendedClass()
- *
- * @return string
- */
- public function getExtendedClass()
- {
- return $this->_extendedClass;
- }
-
- /**
- * setImplementedInterfaces()
- *
- * @param array $implementedInterfaces
- * @return Zend_CodeGenerator_Php_Class
- */
- public function setImplementedInterfaces(Array $implementedInterfaces)
- {
- $this->_implementedInterfaces = $implementedInterfaces;
- return $this;
- }
-
- /**
- * getImplementedInterfaces
- *
- * @return array
- */
- public function getImplementedInterfaces()
- {
- return $this->_implementedInterfaces;
- }
-
- /**
- * setProperties()
- *
- * @param array $properties
- * @return Zend_CodeGenerator_Php_Class
- */
- public function setProperties(Array $properties)
- {
- foreach ($properties as $property) {
- $this->setProperty($property);
- }
-
- return $this;
- }
-
- /**
- * setProperty()
- *
- * @param array|Zend_CodeGenerator_Php_Property $property
- * @return Zend_CodeGenerator_Php_Class
- */
- public function setProperty($property)
- {
- if (is_array($property)) {
- $property = new Zend_CodeGenerator_Php_Property($property);
- $propertyName = $property->getName();
- } elseif ($property instanceof Zend_CodeGenerator_Php_Property) {
- $propertyName = $property->getName();
- } else {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('setProperty() expects either an array of property options or an instance of Zend_CodeGenerator_Php_Property');
- }
-
- if (isset($this->_properties[$propertyName])) {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('A property by name ' . $propertyName . ' already exists in this class.');
- }
-
- $this->_properties[$propertyName] = $property;
- return $this;
- }
-
- /**
- * getProperties()
- *
- * @return array
- */
- public function getProperties()
- {
- return $this->_properties;
- }
-
- /**
- * getProperty()
- *
- * @param string $propertyName
- * @return Zend_CodeGenerator_Php_Property
- */
- public function getProperty($propertyName)
- {
- foreach ($this->_properties as $property) {
- if ($property->getName() == $propertyName) {
- return $property;
- }
- }
- return false;
- }
-
- /**
- * hasProperty()
- *
- * @param string $propertyName
- * @return bool
- */
- public function hasProperty($propertyName)
- {
- return isset($this->_properties[$propertyName]);
- }
-
- /**
- * setMethods()
- *
- * @param array $methods
- * @return Zend_CodeGenerator_Php_Class
- */
- public function setMethods(Array $methods)
- {
- foreach ($methods as $method) {
- $this->setMethod($method);
- }
- return $this;
- }
-
- /**
- * setMethod()
- *
- * @param array|Zend_CodeGenerator_Php_Method $method
- * @return Zend_CodeGenerator_Php_Class
- */
- public function setMethod($method)
- {
- if (is_array($method)) {
- $method = new Zend_CodeGenerator_Php_Method($method);
- $methodName = $method->getName();
- } elseif ($method instanceof Zend_CodeGenerator_Php_Method) {
- $methodName = $method->getName();
- } else {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('setMethod() expects either an array of method options or an instance of Zend_CodeGenerator_Php_Method');
- }
-
- if (isset($this->_methods[$methodName])) {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('A method by name ' . $methodName . ' already exists in this class.');
- }
-
- $this->_methods[$methodName] = $method;
- return $this;
- }
-
- /**
- * getMethods()
- *
- * @return array
- */
- public function getMethods()
- {
- return $this->_methods;
- }
-
- /**
- * getMethod()
- *
- * @param string $methodName
- * @return Zend_CodeGenerator_Php_Method
- */
- public function getMethod($methodName)
- {
- foreach ($this->_methods as $method) {
- if ($method->getName() == $methodName) {
- return $method;
- }
- }
- return false;
- }
-
- /**
- * hasMethod()
- *
- * @param string $methodName
- * @return bool
- */
- public function hasMethod($methodName)
- {
- return isset($this->_methods[$methodName]);
- }
-
- /**
- * isSourceDirty()
- *
- * @return bool
- */
- public function isSourceDirty()
- {
- if (($docblock = $this->getDocblock()) && $docblock->isSourceDirty()) {
- return true;
- }
-
- foreach ($this->_properties as $property) {
- if ($property->isSourceDirty()) {
- return true;
- }
- }
-
- foreach ($this->_methods as $method) {
- if ($method->isSourceDirty()) {
- return true;
- }
- }
-
- return parent::isSourceDirty();
- }
-
- /**
- * generate()
- *
- * @return string
- */
- public function generate()
- {
- if (!$this->isSourceDirty()) {
- return $this->getSourceContent();
- }
-
- $output = '';
-
- if (null !== ($docblock = $this->getDocblock())) {
- $docblock->setIndentation('');
- $output .= $docblock->generate();
- }
-
- if ($this->isAbstract()) {
- $output .= 'abstract ';
- }
-
- $output .= 'class ' . $this->getName();
-
- if ( !empty( $this->_extendedClass) ) {
- $output .= ' extends ' . $this->_extendedClass;
- }
-
- $implemented = $this->getImplementedInterfaces();
- if (!empty($implemented)) {
- $output .= ' implements ' . implode(', ', $implemented);
- }
-
- $output .= self::LINE_FEED . '{' . self::LINE_FEED . self::LINE_FEED;
-
- $properties = $this->getProperties();
- if (!empty($properties)) {
- foreach ($properties as $property) {
- $output .= $property->generate() . self::LINE_FEED . self::LINE_FEED;
- }
- }
-
- $methods = $this->getMethods();
- if (!empty($methods)) {
- foreach ($methods as $method) {
- $output .= $method->generate() . self::LINE_FEED;
- }
- }
-
- $output .= self::LINE_FEED . '}' . self::LINE_FEED;
-
- return $output;
- }
-
- /**
- * _init() - is called at construction time
- *
- */
- protected function _init()
- {
- $this->_properties = new Zend_CodeGenerator_Php_Member_Container(Zend_CodeGenerator_Php_Member_Container::TYPE_PROPERTY);
- $this->_methods = new Zend_CodeGenerator_Php_Member_Container(Zend_CodeGenerator_Php_Member_Container::TYPE_METHOD);
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Docblock/Tag/License.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Docblock/Tag/License.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Docblock/Tag/License.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Docblock/Tag/License.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,98 +0,0 @@
-setName('license');
- $returnTag->setUrl($reflectionTagLicense->getUrl());
- $returnTag->setDescription($reflectionTagLicense->getDescription());
-
- return $returnTag;
- }
-
- /**
- * setUrl()
- *
- * @param string $url
- * @return Zend_CodeGenerator_Php_Docblock_Tag_License
- */
- public function setUrl($url)
- {
- $this->_url = $url;
- return $this;
- }
-
- /**
- * getUrl()
- *
- * @return string
- */
- public function getUrl()
- {
- return $this->_url;
- }
-
-
- /**
- * generate()
- *
- * @return string
- */
- public function generate()
- {
- $output = '@license ' . $this->_url . ' ' . $this->_description . self::LINE_FEED;
- return $output;
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Docblock/Tag/Param.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Docblock/Tag/Param.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Docblock/Tag/Param.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Docblock/Tag/Param.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,128 +0,0 @@
-setName('param');
- $paramTag->setDatatype($reflectionTagParam->getType()); // @todo rename
- $paramTag->setParamName($reflectionTagParam->getVariableName());
- $paramTag->setDescription($reflectionTagParam->getDescription());
-
- return $paramTag;
- }
-
- /**
- * setDatatype()
- *
- * @param string $datatype
- * @return Zend_CodeGenerator_Php_Docblock_Tag_Param
- */
- public function setDatatype($datatype)
- {
- $this->_datatype = $datatype;
- return $this;
- }
-
- /**
- * getDatatype
- *
- * @return string
- */
- public function getDatatype()
- {
- return $this->_datatype;
- }
-
- /**
- * setParamName()
- *
- * @param string $paramName
- * @return Zend_CodeGenerator_Php_Docblock_Tag_Param
- */
- public function setParamName($paramName)
- {
- $this->_paramName = $paramName;
- return $this;
- }
-
- /**
- * getParamName()
- *
- * @return string
- */
- public function getParamName()
- {
- return $this->_paramName;
- }
-
- /**
- * generate()
- *
- * @return string
- */
- public function generate()
- {
- $output = '@param '
- . (($this->_datatype != null) ? $this->_datatype : 'unknown')
- . (($this->_paramName != null) ? ' $' . $this->_paramName : '')
- . (($this->_description != null) ? ' ' . $this->_description : '');
- return $output;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Docblock/Tag/Return.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Docblock/Tag/Return.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Docblock/Tag/Return.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Docblock/Tag/Return.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,98 +0,0 @@
-setName('return');
- $returnTag->setDatatype($reflectionTagReturn->getType()); // @todo rename
- $returnTag->setDescription($reflectionTagReturn->getDescription());
-
- return $returnTag;
- }
-
- /**
- * setDatatype()
- *
- * @param string $datatype
- * @return Zend_CodeGenerator_Php_Docblock_Tag_Return
- */
- public function setDatatype($datatype)
- {
- $this->_datatype = $datatype;
- return $this;
- }
-
- /**
- * getDatatype()
- *
- * @return string
- */
- public function getDatatype()
- {
- return $this->_datatype;
- }
-
-
- /**
- * generate()
- *
- * @return string
- */
- public function generate()
- {
- $output = '@return ' . $this->_datatype . ' ' . $this->_description;
- return $output;
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Docblock/Tag.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Docblock/Tag.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Docblock/Tag.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Docblock/Tag.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,184 +0,0 @@
-getName();
-
- $codeGenDocblockTag = self::factory($tagName);
-
- // transport any properties via accessors and mutators from reflection to codegen object
- $reflectionClass = new ReflectionClass($reflectionTag);
- foreach ($reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
- if (substr($method->getName(), 0, 3) == 'get') {
- $propertyName = substr($method->getName(), 3);
- if (method_exists($codeGenDocblockTag, 'set' . $propertyName)) {
- $codeGenDocblockTag->{'set' . $propertyName}($reflectionTag->{'get' . $propertyName}());
- }
- }
- }
-
- return $codeGenDocblockTag;
- }
-
- /**
- * setPluginLoader()
- *
- * @param Zend_Loader_PluginLoader $pluginLoader
- */
- public static function setPluginLoader(Zend_Loader_PluginLoader $pluginLoader)
- {
- self::$_pluginLoader = $pluginLoader;
- return;
- }
-
- /**
- * getPluginLoader()
- *
- * @return Zend_Loader_PluginLoader
- */
- public static function getPluginLoader()
- {
- if (self::$_pluginLoader == null) {
- require_once 'Zend/Loader/PluginLoader.php';
- self::setPluginLoader(new Zend_Loader_PluginLoader(array(
- 'Zend_CodeGenerator_Php_Docblock_Tag' => dirname(__FILE__) . '/Tag/'))
- );
- }
-
- return self::$_pluginLoader;
- }
-
- public static function factory($tagName)
- {
- $pluginLoader = self::getPluginLoader();
-
- try {
- $tagClass = $pluginLoader->load($tagName);
- } catch (Zend_Loader_Exception $exception) {
- $tagClass = 'Zend_CodeGenerator_Php_Docblock_Tag';
- }
-
- $tag = new $tagClass(array('name' => $tagName));
- return $tag;
- }
-
- /**
- * setName()
- *
- * @param string $name
- * @return Zend_CodeGenerator_Php_Docblock_Tag
- */
- public function setName($name)
- {
- $this->_name = ltrim($name, '@');
- return $this;
- }
-
- /**
- * getName()
- *
- * @return string
- */
- public function getName()
- {
- return $this->_name;
- }
-
- /**
- * setDescription()
- *
- * @param string $description
- * @return Zend_CodeGenerator_Php_Docblock_Tag
- */
- public function setDescription($description)
- {
- $this->_description = $description;
- return $this;
- }
-
- /**
- * getDescription()
- *
- * @return string
- */
- public function getDescription()
- {
- return $this->_description;
- }
-
- /**
- * generate()
- *
- * @return string
- */
- public function generate()
- {
- return '@' . $this->_name . ' ' . $this->_description;
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Docblock.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Docblock.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Docblock.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Docblock.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,220 +0,0 @@
-setSourceContent($reflectionDocblock->getContents());
- $docblock->setSourceDirty(false);
-
- $docblock->setShortDescription($reflectionDocblock->getShortDescription());
- $docblock->setLongDescription($reflectionDocblock->getLongDescription());
-
- foreach ($reflectionDocblock->getTags() as $tag) {
- $docblock->setTag(Zend_CodeGenerator_Php_Docblock_Tag::fromReflection($tag));
- }
-
- return $docblock;
- }
-
- /**
- * setShortDescription()
- *
- * @param string $shortDescription
- * @return Zend_CodeGenerator_Php_Docblock
- */
- public function setShortDescription($shortDescription)
- {
- $this->_shortDescription = $shortDescription;
- return $this;
- }
-
- /**
- * getShortDescription()
- *
- * @return string
- */
- public function getShortDescription()
- {
- return $this->_shortDescription;
- }
-
- /**
- * setLongDescription()
- *
- * @param string $longDescription
- * @return Zend_CodeGenerator_Php_Docblock
- */
- public function setLongDescription($longDescription)
- {
- $this->_longDescription = $longDescription;
- return $this;
- }
-
- /**
- * getLongDescription()
- *
- * @return string
- */
- public function getLongDescription()
- {
- return $this->_longDescription;
- }
-
- /**
- * setTags()
- *
- * @param array $tags
- * @return Zend_CodeGenerator_Php_Docblock
- */
- public function setTags(Array $tags)
- {
- foreach ($tags as $tag) {
- $this->setTag($tag);
- }
-
- return $this;
- }
-
- /**
- * setTag()
- *
- * @param array|Zend_CodeGenerator_Php_Docblock_Tag $tag
- * @return Zend_CodeGenerator_Php_Docblock
- */
- public function setTag($tag)
- {
- if (is_array($tag)) {
- $tag = new Zend_CodeGenerator_Php_Docblock_Tag($tag);
- } elseif (!$tag instanceof Zend_CodeGenerator_Php_Docblock_Tag) {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception(
- 'setTag() expects either an array of method options or an '
- . 'instance of Zend_CodeGenerator_Php_Docblock_Tag'
- );
- }
-
- $this->_tags[] = $tag;
- return $this;
- }
-
- /**
- * getTags
- *
- * @return array Array of Zend_CodeGenerator_Php_Docblock_Tag
- */
- public function getTags()
- {
- return $this->_tags;
- }
-
- /**
- * generate()
- *
- * @return string
- */
- public function generate()
- {
- if (!$this->isSourceDirty()) {
- return $this->_docCommentize($this->getSourceContent());
- }
-
- $output = '';
- if (null !== ($sd = $this->getShortDescription())) {
- $output .= $sd . self::LINE_FEED . self::LINE_FEED;
- }
- if (null !== ($ld = $this->getLongDescription())) {
- $output .= $ld . self::LINE_FEED . self::LINE_FEED;
- }
-
- foreach ($this->getTags() as $tag) {
- $output .= $tag->generate() . self::LINE_FEED;
- }
-
- return $this->_docCommentize(trim($output));
- }
-
- /**
- * _docCommentize()
- *
- * @param string $content
- * @return string
- */
- protected function _docCommentize($content)
- {
- $indent = $this->getIndentation();
- $output = $indent . '/**' . self::LINE_FEED;
- $content = wordwrap($content, 80, self::LINE_FEED);
- $lines = explode(self::LINE_FEED, $content);
- foreach ($lines as $line) {
- $output .= $indent . ' * ' . $line . self::LINE_FEED;
- }
- $output .= $indent . ' */' . self::LINE_FEED;
- return $output;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Exception.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Exception.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,37 +0,0 @@
-getFilename();
- }
-
- if ($fileName == '') {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('FileName does not exist.');
- }
-
- // cannot use realpath since the file might not exist, but we do need to have the index
- // in the same DIRECTORY_SEPARATOR that realpath would use:
- $fileName = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $fileName);
-
- self::$_fileCodeGenerators[$fileName] = $fileCodeGenerator;
-
- }
-
- /**
- * fromReflectedFilePath() - use this if you intend on generating code generation objects based on the same file.
- * This will keep previous changes to the file in tact during the same PHP process
- *
- * @param string $filePath
- * @param bool $usePreviousCodeGeneratorIfItExists
- * @param bool $includeIfNotAlreadyIncluded
- * @return Zend_CodeGenerator_Php_File
- */
- public static function fromReflectedFileName($filePath, $usePreviousCodeGeneratorIfItExists = true, $includeIfNotAlreadyIncluded = true)
- {
- $realpath = realpath($filePath);
-
- if ($realpath === false) {
- if ( ($realpath = Zend_Reflection_file::findRealpathInIncludePath($filePath)) === false) {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('No file for ' . $realpath . ' was found.');
- }
- }
-
- if ($usePreviousCodeGeneratorIfItExists && isset(self::$_fileCodeGenerators[$realpath])) {
- return self::$_fileCodeGenerators[$realpath];
- }
-
- if ($includeIfNotAlreadyIncluded && !in_array($realpath, get_included_files())) {
- include $realpath;
- }
-
- $codeGenerator = self::fromReflection(($fileReflector = new Zend_Reflection_File($realpath)));
-
- if (!isset(self::$_fileCodeGenerators[$fileReflector->getFileName()])) {
- self::$_fileCodeGenerators[$fileReflector->getFileName()] = $codeGenerator;
- }
-
- return $codeGenerator;
- }
-
- /**
- * fromReflection()
- *
- * @param Zend_Reflection_File $reflectionFile
- * @return Zend_CodeGenerator_Php_File
- */
- public static function fromReflection(Zend_Reflection_File $reflectionFile)
- {
- $file = new self();
-
- $file->setSourceContent($reflectionFile->getContents());
- $file->setSourceDirty(false);
-
- $body = $reflectionFile->getContents();
-
- // @todo this whole area needs to be reworked with respect to how body lines are processed
- foreach ($reflectionFile->getClasses() as $class) {
- $file->setClass(Zend_CodeGenerator_Php_Class::fromReflection($class));
- $classStartLine = $class->getStartLine(true);
- $classEndLine = $class->getEndLine();
-
- $bodyLines = explode("\n", $body);
- $bodyReturn = array();
- for ($lineNum = 1; $lineNum <= count($bodyLines); $lineNum++) {
- if ($lineNum == $classStartLine) {
- $bodyReturn[] = str_replace('?', $class->getName(), self::$_markerClass); //'/* Zend_CodeGenerator_Php_File-ClassMarker: {' . $class->getName() . '} */';
- $lineNum = $classEndLine;
- } else {
- $bodyReturn[] = $bodyLines[$lineNum - 1]; // adjust for index -> line conversion
- }
- }
- $body = implode("\n", $bodyReturn);
- unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine);
- }
-
- if (($reflectionFile->getDocComment() != '')) {
- $docblock = $reflectionFile->getDocblock();
- $file->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($docblock));
-
- $bodyLines = explode("\n", $body);
- $bodyReturn = array();
- for ($lineNum = 1; $lineNum <= count($bodyLines); $lineNum++) {
- if ($lineNum == $docblock->getStartLine()) {
- $bodyReturn[] = str_replace('?', $class->getName(), self::$_markerDocblock); //'/* Zend_CodeGenerator_Php_File-ClassMarker: {' . $class->getName() . '} */';
- $lineNum = $docblock->getEndLine();
- } else {
- $bodyReturn[] = $bodyLines[$lineNum - 1]; // adjust for index -> line conversion
- }
- }
- $body = implode("\n", $bodyReturn);
- unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine);
- }
-
- $file->setBody($body);
-
- return $file;
- }
-
- /**
- * setDocblock() Set the docblock
- *
- * @param Zend_CodeGenerator_Php_Docblock|array|string $docblock
- * @return Zend_CodeGenerator_Php_File
- */
- public function setDocblock($docblock)
- {
- if (is_string($docblock)) {
- $docblock = array('shortDescription' => $docblock);
- }
-
- if (is_array($docblock)) {
- $docblock = new Zend_CodeGenerator_Php_Docblock($docblock);
- } elseif (!$docblock instanceof Zend_CodeGenerator_Php_Docblock) {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('setDocblock() is expecting either a string, array or an instance of Zend_CodeGenerator_Php_Docblock');
- }
-
- $this->_docblock = $docblock;
- return $this;
- }
-
- /**
- * Get docblock
- *
- * @return Zend_CodeGenerator_Php_Docblock
- */
- public function getDocblock()
- {
- return $this->_docblock;
- }
-
- /**
- * setRequiredFiles
- *
- * @param array $requiredFiles
- * @return Zend_CodeGenerator_Php_File
- */
- public function setRequiredFiles($requiredFiles)
- {
- $this->_requiredFiles = $requiredFiles;
- return $this;
- }
-
- /**
- * getRequiredFiles()
- *
- * @return array
- */
- public function getRequiredFiles()
- {
- return $this->_requiredFiles;
- }
-
- /**
- * setClasses()
- *
- * @param array $classes
- * @return Zend_CodeGenerator_Php_File
- */
- public function setClasses(Array $classes)
- {
- foreach ($classes as $class) {
- $this->setClass($class);
- }
- return $this;
- }
-
- /**
- * getClass()
- *
- * @param string $name
- * @return Zend_CodeGenerator_Php_Class
- */
- public function getClass($name = null)
- {
- if ($name == null) {
- reset($this->_classes);
- return current($this->_classes);
- }
-
- return $this->_classes[$name];
- }
-
- /**
- * setClass()
- *
- * @param Zend_CodeGenerator_Php_Class|array $class
- * @return Zend_CodeGenerator_Php_File
- */
- public function setClass($class)
- {
- if (is_array($class)) {
- $class = new Zend_CodeGenerator_Php_Class($class);
- $className = $class->getName();
- } elseif ($class instanceof Zend_CodeGenerator_Php_Class) {
- $className = $class->getName();
- } else {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('Expecting either an array or an instance of Zend_CodeGenerator_Php_Class');
- }
-
- // @todo check for dup here
-
- $this->_classes[$className] = $class;
- return $this;
- }
-
- /**
- * setFilename()
- *
- * @param string $filename
- * @return Zend_CodeGenerator_Php_File
- */
- public function setFilename($filename)
- {
- $this->_filename = $filename;
- return $this;
- }
-
- /**
- * getFilename()
- *
- * @return string
- */
- public function getFilename()
- {
- return $this->_filename;
- }
-
- /**
- * getClasses()
- *
- * @return array Array of Zend_CodeGenerator_Php_Class
- */
- public function getClasses()
- {
- return $this->_classes;
- }
-
- /**
- * setBody()
- *
- * @param string $body
- * @return Zend_CodeGenerator_Php_File
- */
- public function setBody($body)
- {
- $this->_body = $body;
- return $this;
- }
-
- /**
- * getBody()
- *
- * @return string
- */
- public function getBody()
- {
- return $this->_body;
- }
-
- /**
- * isSourceDirty()
- *
- * @return bool
- */
- public function isSourceDirty()
- {
- if (($docblock = $this->getDocblock()) && $docblock->isSourceDirty()) {
- return true;
- }
-
- foreach ($this->_classes as $class) {
- if ($class->isSourceDirty()) {
- return true;
- }
- }
-
- return parent::isSourceDirty();
- }
-
- /**
- * generate()
- *
- * @return string
- */
- public function generate()
- {
- if ($this->isSourceDirty() === false) {
- return $this->_sourceContent;
- }
-
- $output = '';
-
- // start with the body (if there), or open tag
- if (preg_match('#(?:\s*)<\?php#', $this->getBody()) == false) {
- $output = 'getBody();
- if (preg_match('#/\* Zend_CodeGenerator_Php_File-(.*?)Marker:#', $body)) {
- $output .= $body;
- $body = '';
- }
-
- // Add file docblock, if any
- if (null !== ($docblock = $this->getDocblock())) {
- $docblock->setIndentation('');
- $regex = preg_quote(self::$_markerDocblock, '#');
- if (preg_match('#'.$regex.'#', $output)) {
- $output = preg_replace('#'.$regex.'#', $docblock->generate(), $output, 1);
- } else {
- $output .= $docblock->generate() . self::LINE_FEED;
- }
- }
-
- // newline
- $output .= self::LINE_FEED;
-
- // process required files
- // @todo marker replacement for required files
- $requiredFiles = $this->getRequiredFiles();
- if (!empty($requiredFiles)) {
- foreach ($requiredFiles as $requiredFile) {
- $output .= 'require_once \'' . $requiredFile . '\';' . self::LINE_FEED;
- }
-
- $output .= self::LINE_FEED;
- }
-
- // process classes
- $classes = $this->getClasses();
- if (!empty($classes)) {
- foreach ($classes as $class) {
- $regex = str_replace('?', $class->getName(), self::$_markerClass);
- $regex = preg_quote($regex, '#');
- if (preg_match('#'.$regex.'#', $output)) {
- $output = preg_replace('#'.$regex.'#', $class->generate(), $output, 1);
- } else {
- $output .= $class->generate() . self::LINE_FEED;
- }
- }
-
- }
-
- if (!empty($body)) {
-
- // add an extra space betwee clsses and
- if (!empty($classes)) {
- $output .= self::LINE_FEED;
- }
-
- $output .= $body;
- }
-
- return $output;
- }
-
- public function write()
- {
- if ($this->_filename == '' || !is_writable(dirname($this->_filename))) {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('This code generator object is not writable.');
- }
- file_put_contents($this->_filename, $this->generate());
- return $this;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Member/Abstract.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Member/Abstract.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Member/Abstract.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Member/Abstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,222 +0,0 @@
- $docblock);
- }
-
- if (is_array($docblock)) {
- $docblock = new Zend_CodeGenerator_Php_Docblock($docblock);
- } elseif (!$docblock instanceof Zend_CodeGenerator_Php_Docblock) {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('setDocblock() is expecting either a string, array or an instance of Zend_CodeGenerator_Php_Docblock');
- }
-
- $this->_docblock = $docblock;
- return $this;
- }
-
- /**
- * getDocblock()
- *
- * @return Zend_CodeGenerator_Php_Docblock
- */
- public function getDocblock()
- {
- return $this->_docblock;
- }
-
- /**
- * setAbstract()
- *
- * @param bool $isAbstract
- * @return Zend_CodeGenerator_Php_Member_Abstract
- */
- public function setAbstract($isAbstract)
- {
- $this->_isAbstract = ($isAbstract) ? true : false;
- return $this;
- }
-
- /**
- * isAbstract()
- *
- * @return bool
- */
- public function isAbstract()
- {
- return $this->_isAbstract;
- }
-
- /**
- * setFinal()
- *
- * @param bool $isFinal
- * @return Zend_CodeGenerator_Php_Member_Abstract
- */
- public function setFinal($isFinal)
- {
- $this->_isFinal = ($isFinal) ? true : false;
- return $this;
- }
-
- /**
- * isFinal()
- *
- * @return bool
- */
- public function isFinal()
- {
- return $this->_isFinal;
- }
-
- /**
- * setStatic()
- *
- * @param bool $isStatic
- * @return Zend_CodeGenerator_Php_Member_Abstract
- */
- public function setStatic($isStatic)
- {
- $this->_isStatic = ($isStatic) ? true : false;
- return $this;
- }
-
- /**
- * isStatic()
- *
- * @return bool
- */
- public function isStatic()
- {
- return $this->_isStatic;
- }
-
- /**
- * setVisitibility()
- *
- * @param const $visibility
- * @return Zend_CodeGenerator_Php_Member_Abstract
- */
- public function setVisibility($visibility)
- {
- $this->_visibility = $visibility;
- return $this;
- }
-
- /**
- * getVisibility()
- *
- * @return const
- */
- public function getVisibility()
- {
- return $this->_visibility;
- }
-
- /**
- * setName()
- *
- * @param string $name
- * @return Zend_CodeGenerator_Php_Member_Abstract
- */
- public function setName($name)
- {
- $this->_name = $name;
- return $this;
- }
-
- /**
- * getName()
- *
- * @return string
- */
- public function getName()
- {
- return $this->_name;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Member/Container.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Member/Container.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Member/Container.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Member/Container.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,55 +0,0 @@
-_type = $type;
- parent::__construct(array(), self::ARRAY_AS_PROPS);
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Method.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Method.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Method.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Method.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,234 +0,0 @@
-setSourceContent($reflectionMethod->getContents(false));
- $method->setSourceDirty(false);
-
- if ($reflectionMethod->getDocComment() != '') {
- $method->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionMethod->getDocblock()));
- }
-
- $method->setFinal($reflectionMethod->isFinal());
-
- if ($reflectionMethod->isPrivate()) {
- $method->setVisibility(self::VISIBILITY_PRIVATE);
- } elseif ($reflectionMethod->isProtected()) {
- $method->setVisibility(self::VISIBILITY_PROTECTED);
- } else {
- $method->setVisibility(self::VISIBILITY_PUBLIC);
- }
-
- $method->setStatic($reflectionMethod->isStatic());
-
- $method->setName($reflectionMethod->getName());
-
- foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
- $method->setParameter(Zend_CodeGenerator_Php_Parameter::fromReflection($reflectionParameter));
- }
-
- $method->setBody($reflectionMethod->getBody());
-
- return $method;
- }
-
- /**
- * setFinal()
- *
- * @param bool $isFinal
- */
- public function setFinal($isFinal)
- {
- $this->_isFinal = ($isFinal) ? true : false;
- }
-
- /**
- * setParameters()
- *
- * @param array $parameters
- * @return Zend_CodeGenerator_Php_Method
- */
- public function setParameters(Array $parameters)
- {
- foreach ($parameters as $parameter) {
- $this->setParameter($parameter);
- }
- return $this;
- }
-
- /**
- * setParameter()
- *
- * @param Zend_CodeGenerator_Php_Parameter|array $parameter
- * @return Zend_CodeGenerator_Php_Method
- */
- public function setParameter($parameter)
- {
- if (is_array($parameter)) {
- $parameter = new Zend_CodeGenerator_Php_Parameter($parameter);
- $parameterName = $parameter->getName();
- } elseif ($parameter instanceof Zend_CodeGenerator_Php_Parameter) {
- $parameterName = $parameter->getName();
- } else {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('setParameter() expects either an array of method options or an instance of Zend_CodeGenerator_Php_Parameter');
- }
-
- $this->_parameters[$parameterName] = $parameter;
- return $this;
- }
-
- /**
- * getParameters()
- *
- * @return array Array of Zend_CodeGenerator_Php_Parameter
- */
- public function getParameters()
- {
- return $this->_parameters;
- }
-
- /**
- * setBody()
- *
- * @param string $body
- * @return Zend_CodeGenerator_Php_Method
- */
- public function setBody($body)
- {
- $this->_body = $body;
- return $this;
- }
-
- /**
- * getBody()
- *
- * @return string
- */
- public function getBody()
- {
- return $this->_body;
- }
-
- /**
- * generate()
- *
- * @return string
- */
- public function generate()
- {
- $output = '';
-
- $indent = $this->getIndentation();
-
- if (($docblock = $this->getDocblock()) !== null) {
- $docblock->setIndentation($indent);
- $output .= $docblock->generate();
- }
-
- $output .= $indent;
-
- if ($this->isAbstract()) {
- $output .= 'abstract ';
- } else {
- $output .= (($this->isFinal()) ? 'final ' : '');
- }
-
- $output .= $this->getVisibility()
- . (($this->isStatic()) ? ' static' : '')
- . ' function ' . $this->getName() . '(';
-
- $parameters = $this->getParameters();
- if (!empty($parameters)) {
- foreach ($parameters as $parameter) {
- $parameterOuput[] = $parameter->generate();
- }
-
- $output .= implode(', ', $parameterOuput);
- }
-
- $output .= ')' . self::LINE_FEED . $indent . '{' . self::LINE_FEED;
-
- if ($this->_body) {
- $output .= ' '
- . str_replace(self::LINE_FEED, self::LINE_FEED . $indent . $indent, trim($this->_body))
- . self::LINE_FEED;
- }
-
- $output .= $indent . '}' . self::LINE_FEED;
-
- return $output;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Parameter/DefaultValue.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Parameter/DefaultValue.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Parameter/DefaultValue.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Parameter/DefaultValue.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,60 +0,0 @@
-_defaultValue = $defaultValue;
- }
-
- public function __toString()
- {
- return $this->_defaultValue;
- }
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Parameter.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Parameter.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Parameter.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Parameter.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,250 +0,0 @@
-setName($reflectionParameter->getName());
-
- if($reflectionParameter->isArray()) {
- $param->setType('array');
- } else {
- $typeClass = $reflectionParameter->getClass();
- if($typeClass !== null) {
- $param->setType($typeClass->getName());
- }
- }
-
- $param->setPosition($reflectionParameter->getPosition());
-
- if($reflectionParameter->isOptional()) {
- $param->setDefaultValue($reflectionParameter->getDefaultValue());
- }
- $param->setPassedByReference($reflectionParameter->isPassedByReference());
-
- return $param;
- }
-
- /**
- * setType()
- *
- * @param string $type
- * @return Zend_CodeGenerator_Php_Parameter
- */
- public function setType($type)
- {
- $this->_type = $type;
- return $this;
- }
-
- /**
- * getType()
- *
- * @return string
- */
- public function getType()
- {
- return $this->_type;
- }
-
- /**
- * setName()
- *
- * @param string $name
- * @return Zend_CodeGenerator_Php_Parameter
- */
- public function setName($name)
- {
- $this->_name = $name;
- return $this;
- }
-
- /**
- * getName()
- *
- * @return string
- */
- public function getName()
- {
- return $this->_name;
- }
-
- /**
- * Set the default value of the parameter.
- *
- * Certain variables are difficult to expres
- *
- * @param null|bool|string|int|float|Zend_CodeGenerator_Php_Parameter_DefaultValue $defaultValue
- * @return Zend_CodeGenerator_Php_Parameter
- */
- public function setDefaultValue($defaultValue)
- {
- if($defaultValue === null) {
- $this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue("null");
- } else if(is_array($defaultValue)) {
- $defaultValue = str_replace(array("\r", "\n"), "", var_export($defaultValue, true));
- $this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue($defaultValue);
- } else if(is_bool($defaultValue)) {
- if($defaultValue == true) {
- $this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue("true");
- } else {
- $this->_defaultValue = new Zend_CodeGenerator_Php_Parameter_DefaultValue("false");
- }
- } else {
- $this->_defaultValue = $defaultValue;
- }
- return $this;
- }
-
- /**
- * getDefaultValue()
- *
- * @return string
- */
- public function getDefaultValue()
- {
- return $this->_defaultValue;
- }
-
- /**
- * setPosition()
- *
- * @param int $position
- * @return Zend_CodeGenerator_Php_Parameter
- */
- public function setPosition($position)
- {
- $this->_position = $position;
- return $this;
- }
-
- /**
- * getPosition()
- *
- * @return int
- */
- public function getPosition()
- {
- return $this->_position;
- }
-
- /**
- * @return bool
- */
- public function getPassedByReference()
- {
- return $this->_passedByReference;
- }
-
- /**
- * @param bool $passedByReference
- * @return Zend_CodeGenerator_Php_Parameter
- */
- public function setPassedByReference($passedByReference)
- {
- $this->_passedByReference = $passedByReference;
- return $this;
- }
-
- /**
- * generate()
- *
- * @return string
- */
- public function generate()
- {
- $output = '';
-
- if ($this->_type) {
- $output .= $this->_type . ' ';
- }
-
- if($this->_passedByReference === true) {
- $output .= '&';
- }
-
- $output .= '$' . $this->_name;
-
- if ($this->_defaultValue !== null) {
- $output .= ' = ';
- if (is_string($this->_defaultValue)) {
- $output .= '\'' . $this->_defaultValue . '\'';
- } else if($this->_defaultValue instanceof Zend_CodeGenerator_Php_ParameterDefaultValue) {
- $output .= (string)$this->_defaultValue;
- } else {
- $output .= $this->_defaultValue;
- }
- }
-
- return $output;
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Property/DefaultValue.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Property/DefaultValue.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Property/DefaultValue.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Property/DefaultValue.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,323 +0,0 @@
-getConstants();
- unset($reflect);
- }
- }
-
- /**
- * isValidConstantType()
- *
- * @return bool
- */
- public function isValidConstantType()
- {
- if ($this->_type == self::TYPE_AUTO) {
- $type = $this->_getAutoDeterminedType($this->_value);
- }
-
- // valid types for constants
- $scalarTypes = array(
- self::TYPE_BOOLEAN,
- self::TYPE_BOOL,
- self::TYPE_NUMBER,
- self::TYPE_INTEGER,
- self::TYPE_INT,
- self::TYPE_FLOAT,
- self::TYPE_DOUBLE,
- self::TYPE_STRING,
- self::TYPE_CONSTANT,
- self::TYPE_NULL
- );
-
- return in_array($type, $scalarTypes);
- }
-
- /**
- * setValue()
- *
- * @param mixed $value
- * @return Zend_CodeGenerator_Php_Property_DefaultValue
- */
- public function setValue($value)
- {
- $this->_value = $value;
- return $this;
- }
-
- /**
- * getValue()
- *
- * @return mixed
- */
- public function getValue()
- {
- return $this->_value;
- }
-
- /**
- * setType()
- *
- * @param string $type
- * @return Zend_CodeGenerator_Php_Property_DefaultValue
- */
- public function setType($type)
- {
- $this->_type = $type;
- return $this;
- }
-
- /**
- * getType()
- *
- * @return string
- */
- public function getType()
- {
- return $this->_type;
- }
-
- /**
- * setArrayDepth()
- *
- * @param int $arrayDepth
- * @return Zend_CodeGenerator_Php_Property_DefaultValue
- */
- public function setArrayDepth($arrayDepth)
- {
- $this->_arrayDepth = $arrayDepth;
- return $this;
- }
-
- /**
- * getArrayDepth()
- *
- * @return int
- */
- public function getArrayDepth()
- {
- return $this->_arrayDepth;
- }
-
- /**
- * _getValidatedType()
- *
- * @param string $type
- * @return string
- */
- protected function _getValidatedType($type)
- {
- if (($constName = array_search($type, self::$_constants)) !== false) {
- return $type;
- }
-
- return self::TYPE_AUTO;
- }
-
- /**
- * _getAutoDeterminedType()
- *
- * @param mixed $value
- * @return string
- */
- public function _getAutoDeterminedType($value)
- {
- switch (gettype($value)) {
- case 'boolean':
- return self::TYPE_BOOLEAN;
- case 'integer':
- return self::TYPE_INT;
- case 'string':
- return self::TYPE_STRING;
- case 'double':
- case 'float':
- case 'integer':
- return self::TYPE_NUMBER;
- case 'array':
- return self::TYPE_ARRAY;
- case 'NULL':
- return self::TYPE_NULL;
- case 'object':
- case 'resource':
- case 'unknown type':
- default:
- return self::TYPE_OTHER;
- }
- }
-
- /**
- * generate()
- *
- * @return string
- */
- public function generate()
- {
- $type = $this->_type;
-
- if ($type != self::TYPE_AUTO) {
- $type = $this->_getValidatedType($type);
- }
-
- $value = $this->_value;
-
- if ($type == self::TYPE_AUTO) {
- $type = $this->_getAutoDeterminedType($value);
-
- if ($type == self::TYPE_ARRAY) {
- $rii = new RecursiveIteratorIterator(
- $it = new RecursiveArrayIterator($value),
- RecursiveIteratorIterator::SELF_FIRST
- );
- foreach ($rii as $curKey => $curValue) {
- if (!$curValue instanceof Zend_CodeGenerator_Php_Property_DefaultValue) {
- $curValue = new self(array('value' => $curValue));
- $rii->getSubIterator()->offsetSet($curKey, $curValue);
- }
- $curValue->setArrayDepth($rii->getDepth());
- }
- $value = $rii->getSubIterator()->getArrayCopy();
- }
-
- }
-
- $output = '';
-
- switch ($type) {
- case self::TYPE_BOOLEAN:
- case self::TYPE_BOOL:
- $output .= ( $value ? 'true' : 'false' );
- break;
- case self::TYPE_STRING:
- $output .= "'" . addcslashes($value, "'") . "'";
- break;
- case self::TYPE_NULL:
- $output .= 'null';
- break;
- case self::TYPE_NUMBER:
- case self::TYPE_INTEGER:
- case self::TYPE_INT:
- case self::TYPE_FLOAT:
- case self::TYPE_DOUBLE:
- case self::TYPE_CONSTANT:
- $output .= $value;
- break;
- case self::TYPE_ARRAY:
- $output .= 'array(';
- $curArrayMultiblock = false;
- if (count($value) > 1) {
- $curArrayMultiblock = true;
- $output .= PHP_EOL . str_repeat($this->_indentation, $this->_arrayDepth+1);
- }
- $outputParts = array();
- $noKeyIndex = 0;
- foreach ($value as $n => $v) {
- $v->setArrayDepth($this->_arrayDepth + 1);
- $partV = $v->generate();
- $partV = substr($partV, 0, strlen($partV)-1);
- if ($n === $noKeyIndex) {
- $outputParts[] = $partV;
- $noKeyIndex++;
- } else {
- $outputParts[] = (is_int($n) ? $n : "'" . addcslashes($n, "'") . "'") . ' => ' . $partV;
- }
-
- }
- $output .= implode(',' . PHP_EOL . str_repeat($this->_indentation, $this->_arrayDepth+1), $outputParts);
- if ($curArrayMultiblock == true) {
- $output .= PHP_EOL . str_repeat($this->_indentation, $this->_arrayDepth+1);
- }
- $output .= ')';
- break;
- case self::TYPE_OTHER:
- default:
- require_once "Zend/CodeGenerator/Php/Exception.php";
- throw new Zend_CodeGenerator_Php_Exception(
- "Type '".get_class($value)."' is unknown or cannot be used as property default value."
- );
- }
-
- $output .= ';';
-
- return $output;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/CodeGenerator/Php/Property.php zendframework-2.2.6/library/Zend/CodeGenerator/Php/Property.php
--- zendframework-1.10.4/library/Zend/CodeGenerator/Php/Property.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/CodeGenerator/Php/Property.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,179 +0,0 @@
-setName($reflectionProperty->getName());
-
- $allDefaultProperties = $reflectionProperty->getDeclaringClass()->getDefaultProperties();
-
- $property->setDefaultValue($allDefaultProperties[$reflectionProperty->getName()]);
-
- if ($reflectionProperty->getDocComment() != '') {
- $property->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionProperty->getDocComment()));
- }
-
- if ($reflectionProperty->isStatic()) {
- $property->setStatic(true);
- }
-
- if ($reflectionProperty->isPrivate()) {
- $property->setVisibility(self::VISIBILITY_PRIVATE);
- } elseif ($reflectionProperty->isProtected()) {
- $property->setVisibility(self::VISIBILITY_PROTECTED);
- } else {
- $property->setVisibility(self::VISIBILITY_PUBLIC);
- }
-
- $property->setSourceDirty(false);
-
- return $property;
- }
-
- /**
- * setConst()
- *
- * @param bool $const
- * @return Zend_CodeGenerator_Php_Property
- */
- public function setConst($const)
- {
- $this->_isConst = $const;
- return $this;
- }
-
- /**
- * isConst()
- *
- * @return bool
- */
- public function isConst()
- {
- return ($this->_isConst) ? true : false;
- }
-
- /**
- * setDefaultValue()
- *
- * @param Zend_CodeGenerator_Php_Property_DefaultValue|string|array $defaultValue
- * @return Zend_CodeGenerator_Php_Property
- */
- public function setDefaultValue($defaultValue)
- {
- // if it looks like
- if (is_array($defaultValue)
- && array_key_exists('value', $defaultValue)
- && array_key_exists('type', $defaultValue)) {
- $defaultValue = new Zend_CodeGenerator_Php_Property_DefaultValue($defaultValue);
- }
-
- if (!($defaultValue instanceof Zend_CodeGenerator_Php_Property_DefaultValue)) {
- $defaultValue = new Zend_CodeGenerator_Php_Property_DefaultValue(array('value' => $defaultValue));
- }
-
- $this->_defaultValue = $defaultValue;
- return $this;
- }
-
- /**
- * getDefaultValue()
- *
- * @return Zend_CodeGenerator_Php_Property_DefaultValue
- */
- public function getDefaultValue()
- {
- return $this->_defaultValue;
- }
-
- /**
- * generate()
- *
- * @return string
- */
- public function generate()
- {
- $name = $this->getName();
- $defaultValue = $this->getDefaultValue();
-
- $output = '';
-
- if (($docblock = $this->getDocblock()) !== null) {
- $docblock->setIndentation(' ');
- $output .= $docblock->generate();
- }
-
- if ($this->isConst()) {
- if ($defaultValue != null && !$defaultValue->isValidConstantType()) {
- require_once 'Zend/CodeGenerator/Php/Exception.php';
- throw new Zend_CodeGenerator_Php_Exception('The property ' . $this->_name . ' is said to be '
- . 'constant but does not have a valid constant value.');
- }
- $output .= $this->_indentation . 'const ' . $name . ' = '
- . (($defaultValue !== null) ? $defaultValue->generate() : 'null;');
- } else {
- $output .= $this->_indentation
- . $this->getVisibility()
- . (($this->isStatic()) ? ' static' : '')
- . ' $' . $name . ' = '
- . (($defaultValue !== null) ? $defaultValue->generate() : 'null;');
- }
- return $output;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Config/composer.json zendframework-2.2.6/library/Zend/Config/composer.json
--- zendframework-1.10.4/library/Zend/Config/composer.json 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/composer.json 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,29 @@
+{
+ "name": "zendframework/zend-config",
+ "description": "provides a nested object property based user interface for accessing this configuration data within application code",
+ "license": "BSD-3-Clause",
+ "keywords": [
+ "zf2",
+ "config"
+ ],
+ "autoload": {
+ "psr-0": {
+ "Zend\\Config\\": ""
+ }
+ },
+ "target-dir": "Zend/Config",
+ "require": {
+ "php": ">=5.3.3",
+ "zendframework/zend-stdlib": "self.version"
+ },
+ "suggest": {
+ "zendframework/zend-json": "Zend\\Json to use the Json reader or writer classes",
+ "zendframework/zend-servicemanager": "Zend\\ServiceManager for use with the Config Factory to retrieve reader and writer instances"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev",
+ "dev-develop": "2.3-dev"
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Config.php zendframework-2.2.6/library/Zend/Config/Config.php
--- zendframework-1.10.4/library/Zend/Config/Config.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Config.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,401 @@
+allowModifications = (bool) $allowModifications;
+
+ foreach ($array as $key => $value) {
+ if (is_array($value)) {
+ $this->data[$key] = new static($value, $this->allowModifications);
+ } else {
+ $this->data[$key] = $value;
+ }
+
+ $this->count++;
+ }
+ }
+
+ /**
+ * Retrieve a value and return $default if there is no element set.
+ *
+ * @param string $name
+ * @param mixed $default
+ * @return mixed
+ */
+ public function get($name, $default = null)
+ {
+ if (array_key_exists($name, $this->data)) {
+ return $this->data[$name];
+ }
+
+ return $default;
+ }
+
+ /**
+ * Magic function so that $obj->value will work.
+ *
+ * @param string $name
+ * @return mixed
+ */
+ public function __get($name)
+ {
+ return $this->get($name);
+ }
+
+ /**
+ * Set a value in the config.
+ *
+ * Only allow setting of a property if $allowModifications was set to true
+ * on construction. Otherwise, throw an exception.
+ *
+ * @param string $name
+ * @param mixed $value
+ * @return void
+ * @throws Exception\RuntimeException
+ */
+ public function __set($name, $value)
+ {
+ if ($this->allowModifications) {
+
+ if (is_array($value)) {
+ $value = new static($value, true);
+ }
+
+ if (null === $name) {
+ $this->data[] = $value;
+ } else {
+ $this->data[$name] = $value;
+ }
+
+ $this->count++;
+ } else {
+ throw new Exception\RuntimeException('Config is read only');
+ }
+ }
+
+ /**
+ * Deep clone of this instance to ensure that nested Zend\Configs are also
+ * cloned.
+ *
+ * @return void
+ */
+ public function __clone()
+ {
+ $array = array();
+
+ foreach ($this->data as $key => $value) {
+ if ($value instanceof self) {
+ $array[$key] = clone $value;
+ } else {
+ $array[$key] = $value;
+ }
+ }
+
+ $this->data = $array;
+ }
+
+ /**
+ * Return an associative array of the stored data.
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ $array = array();
+ $data = $this->data;
+
+ /** @var self $value */
+ foreach ($data as $key => $value) {
+ if ($value instanceof self) {
+ $array[$key] = $value->toArray();
+ } else {
+ $array[$key] = $value;
+ }
+ }
+
+ return $array;
+ }
+
+ /**
+ * isset() overloading
+ *
+ * @param string $name
+ * @return bool
+ */
+ public function __isset($name)
+ {
+ return isset($this->data[$name]);
+ }
+
+ /**
+ * unset() overloading
+ *
+ * @param string $name
+ * @return void
+ * @throws Exception\InvalidArgumentException
+ */
+ public function __unset($name)
+ {
+ if (!$this->allowModifications) {
+ throw new Exception\InvalidArgumentException('Config is read only');
+ } elseif (isset($this->data[$name])) {
+ unset($this->data[$name]);
+ $this->count--;
+ $this->skipNextIteration = true;
+ }
+ }
+
+ /**
+ * count(): defined by Countable interface.
+ *
+ * @see Countable::count()
+ * @return int
+ */
+ public function count()
+ {
+ return $this->count;
+ }
+
+ /**
+ * current(): defined by Iterator interface.
+ *
+ * @see Iterator::current()
+ * @return mixed
+ */
+ public function current()
+ {
+ $this->skipNextIteration = false;
+ return current($this->data);
+ }
+
+ /**
+ * key(): defined by Iterator interface.
+ *
+ * @see Iterator::key()
+ * @return mixed
+ */
+ public function key()
+ {
+ return key($this->data);
+ }
+
+ /**
+ * next(): defined by Iterator interface.
+ *
+ * @see Iterator::next()
+ * @return void
+ */
+ public function next()
+ {
+ if ($this->skipNextIteration) {
+ $this->skipNextIteration = false;
+ return;
+ }
+
+ next($this->data);
+ }
+
+ /**
+ * rewind(): defined by Iterator interface.
+ *
+ * @see Iterator::rewind()
+ * @return void
+ */
+ public function rewind()
+ {
+ $this->skipNextIteration = false;
+ reset($this->data);
+ }
+
+ /**
+ * valid(): defined by Iterator interface.
+ *
+ * @see Iterator::valid()
+ * @return bool
+ */
+ public function valid()
+ {
+ return ($this->key() !== null);
+ }
+
+ /**
+ * offsetExists(): defined by ArrayAccess interface.
+ *
+ * @see ArrayAccess::offsetExists()
+ * @param mixed $offset
+ * @return bool
+ */
+ public function offsetExists($offset)
+ {
+ return $this->__isset($offset);
+ }
+
+ /**
+ * offsetGet(): defined by ArrayAccess interface.
+ *
+ * @see ArrayAccess::offsetGet()
+ * @param mixed $offset
+ * @return mixed
+ */
+ public function offsetGet($offset)
+ {
+ return $this->__get($offset);
+ }
+
+ /**
+ * offsetSet(): defined by ArrayAccess interface.
+ *
+ * @see ArrayAccess::offsetSet()
+ * @param mixed $offset
+ * @param mixed $value
+ * @return void
+ */
+ public function offsetSet($offset, $value)
+ {
+ $this->__set($offset, $value);
+ }
+
+ /**
+ * offsetUnset(): defined by ArrayAccess interface.
+ *
+ * @see ArrayAccess::offsetUnset()
+ * @param mixed $offset
+ * @return void
+ */
+ public function offsetUnset($offset)
+ {
+ $this->__unset($offset);
+ }
+
+ /**
+ * Merge another Config with this one.
+ *
+ * For duplicate keys, the following will be performed:
+ * - Nested Configs will be recursively merged.
+ * - Items in $merge with INTEGER keys will be appended.
+ * - Items in $merge with STRING keys will overwrite current values.
+ *
+ * @param Config $merge
+ * @return Config
+ */
+ public function merge(Config $merge)
+ {
+ /** @var Config $value */
+ foreach ($merge as $key => $value) {
+ if (array_key_exists($key, $this->data)) {
+ if (is_int($key)) {
+ $this->data[] = $value;
+ } elseif ($value instanceof self && $this->data[$key] instanceof self) {
+ $this->data[$key]->merge($value);
+ } else {
+ if ($value instanceof self) {
+ $this->data[$key] = new static($value->toArray(), $this->allowModifications);
+ } else {
+ $this->data[$key] = $value;
+ }
+ }
+ } else {
+ if ($value instanceof self) {
+ $this->data[$key] = new static($value->toArray(), $this->allowModifications);
+ } else {
+ $this->data[$key] = $value;
+ }
+
+ $this->count++;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Prevent any more modifications being made to this instance.
+ *
+ * Useful after merge() has been used to merge multiple Config objects
+ * into one object which should then not be modified again.
+ *
+ * @return void
+ */
+ public function setReadOnly()
+ {
+ $this->allowModifications = false;
+
+ /** @var Config $value */
+ foreach ($this->data as $value) {
+ if ($value instanceof self) {
+ $value->setReadOnly();
+ }
+ }
+ }
+
+ /**
+ * Returns whether this Config object is read only or not.
+ *
+ * @return bool
+ */
+ public function isReadOnly()
+ {
+ return !$this->allowModifications;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Config/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Config/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Exception/ExceptionInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,13 @@
+ 'ini',
+ 'json' => 'json',
+ 'xml' => 'xml',
+ 'yaml' => 'yaml',
+ );
+
+ /**
+ * Register config file extensions for writing
+ * key is extension, value is writer instance or plugin name
+ *
+ * @var array
+ */
+ protected static $writerExtensions = array(
+ 'php' => 'php',
+ 'ini' => 'ini',
+ 'json' => 'json',
+ 'xml' => 'xml',
+ 'yaml' => 'yaml',
+ );
+
+ /**
+ * Read a config from a file.
+ *
+ * @param string $filename
+ * @param bool $returnConfigObject
+ * @return array|Config
+ * @throws Exception\InvalidArgumentException
+ * @throws Exception\RuntimeException
+ */
+ public static function fromFile($filename, $returnConfigObject = false)
+ {
+ $pathinfo = pathinfo($filename);
+
+ if (!isset($pathinfo['extension'])) {
+ throw new Exception\RuntimeException(sprintf(
+ 'Filename "%s" is missing an extension and cannot be auto-detected',
+ $filename
+ ));
+ }
+
+ $extension = strtolower($pathinfo['extension']);
+
+ if ($extension === 'php') {
+ if (!is_file($filename) || !is_readable($filename)) {
+ throw new Exception\RuntimeException(sprintf(
+ "File '%s' doesn't exist or not readable",
+ $filename
+ ));
+ }
+
+ $config = include $filename;
+ } elseif (isset(static::$extensions[$extension])) {
+ $reader = static::$extensions[$extension];
+ if (!$reader instanceof Reader\ReaderInterface) {
+ $reader = static::getReaderPluginManager()->get($reader);
+ static::$extensions[$extension] = $reader;
+ }
+
+ /** @var Reader\ReaderInterface $reader */
+ $config = $reader->fromFile($filename);
+ } else {
+ throw new Exception\RuntimeException(sprintf(
+ 'Unsupported config file extension: .%s',
+ $pathinfo['extension']
+ ));
+ }
+
+ return ($returnConfigObject) ? new Config($config) : $config;
+ }
+
+ /**
+ * Read configuration from multiple files and merge them.
+ *
+ * @param array $files
+ * @param bool $returnConfigObject
+ * @return array|Config
+ */
+ public static function fromFiles(array $files, $returnConfigObject = false)
+ {
+ $config = array();
+
+ foreach ($files as $file) {
+ $config = ArrayUtils::merge($config, static::fromFile($file));
+ }
+
+ return ($returnConfigObject) ? new Config($config) : $config;
+ }
+
+ /**
+ * Writes a config to a file
+ *
+ * @param string $filename
+ * @param array|Config $config
+ * @return bool TRUE on success | FALSE on failure
+ * @throws Exception\RuntimeException
+ * @throws Exception\InvalidArgumentException
+ */
+ public static function toFile($filename, $config)
+ {
+ if (
+ (is_object($config) && !($config instanceOf Config)) ||
+ (!is_object($config) && !is_array($config))
+ ) {
+ throw new Exception\InvalidArgumentException(
+ __METHOD__." \$config should be an array or instance of Zend\\Config\\Config"
+ );
+ }
+
+ $extension = substr(strrchr($filename, '.'), 1);
+ $directory = dirname($filename);
+
+ if (!is_dir($directory)) {
+ throw new Exception\RuntimeException(
+ "Directory '{$directory}' does not exists!"
+ );
+ }
+
+ if (!is_writable($directory)) {
+ throw new Exception\RuntimeException(
+ "Cannot write in directory '{$directory}'"
+ );
+ }
+
+ if (!isset(static::$writerExtensions[$extension])) {
+ throw new Exception\RuntimeException(
+ "Unsupported config file extension: '.{$extension}' for writing."
+ );
+ }
+
+ $writer = static::$writerExtensions[$extension];
+ if (($writer instanceOf Writer\AbstractWriter) === false) {
+ $writer = self::getWriterPluginManager()->get($writer);
+ static::$writerExtensions[$extension] = $writer;
+ }
+
+ if (is_object($config)) {
+ $config = $config->toArray();
+ }
+
+ $content = $writer->processConfig($config);
+
+ return (bool) (file_put_contents($filename, $content) !== false);
+ }
+
+ /**
+ * Set reader plugin manager
+ *
+ * @param ReaderPluginManager $readers
+ * @return void
+ */
+ public static function setReaderPluginManager(ReaderPluginManager $readers)
+ {
+ static::$readers = $readers;
+ }
+
+ /**
+ * Get the reader plugin manager
+ *
+ * @return ReaderPluginManager
+ */
+ public static function getReaderPluginManager()
+ {
+ if (static::$readers === null) {
+ static::$readers = new ReaderPluginManager();
+ }
+ return static::$readers;
+ }
+
+ /**
+ * Set writer plugin manager
+ *
+ * @param WriterPluginManager $writers
+ * @return void
+ */
+ public static function setWriterPluginManager(WriterPluginManager $writers)
+ {
+ static::$writers = $writers;
+ }
+
+ /**
+ * Get the writer plugin manager
+ *
+ * @return WriterPluginManager
+ */
+ public static function getWriterPluginManager()
+ {
+ if (static::$writers === null) {
+ static::$writers = new WriterPluginManager();
+ }
+
+ return static::$writers;
+ }
+
+ /**
+ * Set config reader for file extension
+ *
+ * @param string $extension
+ * @param string|Reader\ReaderInterface $reader
+ * @throws Exception\InvalidArgumentException
+ * @return void
+ */
+ public static function registerReader($extension, $reader)
+ {
+ $extension = strtolower($extension);
+
+ if (!is_string($reader) && !$reader instanceof Reader\ReaderInterface) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Reader should be plugin name, class name or ' .
+ 'instance of %s\Reader\ReaderInterface; received "%s"',
+ __NAMESPACE__,
+ (is_object($reader) ? get_class($reader) : gettype($reader))
+ ));
+ }
+
+ static::$extensions[$extension] = $reader;
+ }
+
+ /**
+ * Set config writer for file extension
+ *
+ * @param string $extension
+ * @param string|Writer\AbstractWriter $writer
+ * @throws Exception\InvalidArgumentException
+ * @return void
+ */
+ public static function registerWriter($extension, $writer)
+ {
+ $extension = strtolower($extension);
+
+ if (!is_string($writer) && !$writer instanceof Writer\AbstractWriter) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Writer should be plugin name, class name or ' .
+ 'instance of %s\Writer\AbstractWriter; received "%s"',
+ __NAMESPACE__,
+ (is_object($writer) ? get_class($writer) : gettype($writer))
+ ));
+ }
+
+ static::$writerExtensions[$extension] = $writer;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Ini.php zendframework-2.2.6/library/Zend/Config/Ini.php
--- zendframework-1.10.4/library/Zend/Config/Ini.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Ini.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,308 +0,0 @@
-hostname === "staging"
- * $data->db->connection === "database"
- *
- * The $options parameter may be provided as either a boolean or an array.
- * If provided as a boolean, this sets the $allowModifications option of
- * Zend_Config. If provided as an array, there are two configuration
- * directives that may be set. For example:
- *
- * $options = array(
- * 'allowModifications' => false,
- * 'nestSeparator' => '->'
- * );
- *
- * @param string $filename
- * @param string|null $section
- * @param boolean|array $options
- * @throws Zend_Config_Exception
- * @return void
- */
- public function __construct($filename, $section = null, $options = false)
- {
- if (empty($filename)) {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Filename is not set');
- }
-
- $allowModifications = false;
- if (is_bool($options)) {
- $allowModifications = $options;
- } elseif (is_array($options)) {
- if (isset($options['allowModifications'])) {
- $allowModifications = (bool) $options['allowModifications'];
- }
- if (isset($options['nestSeparator'])) {
- $this->_nestSeparator = (string) $options['nestSeparator'];
- }
- if (isset($options['skipExtends'])) {
- $this->_skipExtends = (bool) $options['skipExtends'];
- }
- }
-
- $iniArray = $this->_loadIniFile($filename);
-
- if (null === $section) {
- // Load entire file
- $dataArray = array();
- foreach ($iniArray as $sectionName => $sectionData) {
- if(!is_array($sectionData)) {
- $dataArray = $this->_arrayMergeRecursive($dataArray, $this->_processKey(array(), $sectionName, $sectionData));
- } else {
- $dataArray[$sectionName] = $this->_processSection($iniArray, $sectionName);
- }
- }
- parent::__construct($dataArray, $allowModifications);
- } else {
- // Load one or more sections
- if (!is_array($section)) {
- $section = array($section);
- }
- $dataArray = array();
- foreach ($section as $sectionName) {
- if (!isset($iniArray[$sectionName])) {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Section '$sectionName' cannot be found in $filename");
- }
- $dataArray = $this->_arrayMergeRecursive($this->_processSection($iniArray, $sectionName), $dataArray);
-
- }
- parent::__construct($dataArray, $allowModifications);
- }
-
- $this->_loadedSection = $section;
- }
-
- /**
- * Load the INI file from disk using parse_ini_file(). Use a private error
- * handler to convert any loading errors into a Zend_Config_Exception
- *
- * @param string $filename
- * @throws Zend_Config_Exception
- * @return array
- */
- protected function _parseIniFile($filename)
- {
- set_error_handler(array($this, '_loadFileErrorHandler'));
- $iniArray = parse_ini_file($filename, true); // Warnings and errors are suppressed
- restore_error_handler();
-
- // Check if there was a error while loading file
- if ($this->_loadFileErrorStr !== null) {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception($this->_loadFileErrorStr);
- }
-
- return $iniArray;
- }
-
- /**
- * Load the ini file and preprocess the section separator (':' in the
- * section name (that is used for section extension) so that the resultant
- * array has the correct section names and the extension information is
- * stored in a sub-key called ';extends'. We use ';extends' as this can
- * never be a valid key name in an INI file that has been loaded using
- * parse_ini_file().
- *
- * @param string $filename
- * @throws Zend_Config_Exception
- * @return array
- */
- protected function _loadIniFile($filename)
- {
- $loaded = $this->_parseIniFile($filename);
- $iniArray = array();
- foreach ($loaded as $key => $data)
- {
- $pieces = explode($this->_sectionSeparator, $key);
- $thisSection = trim($pieces[0]);
- switch (count($pieces)) {
- case 1:
- $iniArray[$thisSection] = $data;
- break;
-
- case 2:
- $extendedSection = trim($pieces[1]);
- $iniArray[$thisSection] = array_merge(array(';extends'=>$extendedSection), $data);
- break;
-
- default:
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Section '$thisSection' may not extend multiple sections in $filename");
- }
- }
-
- return $iniArray;
- }
-
- /**
- * Process each element in the section and handle the ";extends" inheritance
- * key. Passes control to _processKey() to handle the nest separator
- * sub-property syntax that may be used within the key name.
- *
- * @param array $iniArray
- * @param string $section
- * @param array $config
- * @throws Zend_Config_Exception
- * @return array
- */
- protected function _processSection($iniArray, $section, $config = array())
- {
- $thisSection = $iniArray[$section];
-
- foreach ($thisSection as $key => $value) {
- if (strtolower($key) == ';extends') {
- if (isset($iniArray[$value])) {
- $this->_assertValidExtend($section, $value);
-
- if (!$this->_skipExtends) {
- $config = $this->_processSection($iniArray, $value, $config);
- }
- } else {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Parent section '$section' cannot be found");
- }
- } else {
- $config = $this->_processKey($config, $key, $value);
- }
- }
- return $config;
- }
-
- /**
- * Assign the key's value to the property list. Handles the
- * nest separator for sub-properties.
- *
- * @param array $config
- * @param string $key
- * @param string $value
- * @throws Zend_Config_Exception
- * @return array
- */
- protected function _processKey($config, $key, $value)
- {
- if (strpos($key, $this->_nestSeparator) !== false) {
- $pieces = explode($this->_nestSeparator, $key, 2);
- if (strlen($pieces[0]) && strlen($pieces[1])) {
- if (!isset($config[$pieces[0]])) {
- if ($pieces[0] === '0' && !empty($config)) {
- // convert the current values in $config into an array
- $config = array($pieces[0] => $config);
- } else {
- $config[$pieces[0]] = array();
- }
- } elseif (!is_array($config[$pieces[0]])) {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Cannot create sub-key for '{$pieces[0]}' as key already exists");
- }
- $config[$pieces[0]] = $this->_processKey($config[$pieces[0]], $pieces[1], $value);
- } else {
- /**
- * @see Zend_Config_Exception
- */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Invalid key '$key'");
- }
- } else {
- $config[$key] = $value;
- }
- return $config;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Config/Processor/Constant.php zendframework-2.2.6/library/Zend/Config/Processor/Constant.php
--- zendframework-1.10.4/library/Zend/Config/Processor/Constant.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Processor/Constant.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,83 @@
+setUserOnly($userOnly);
+ $this->setPrefix($prefix);
+ $this->setSuffix($suffix);
+
+ $this->loadConstants();
+ }
+
+ /**
+ * @return bool
+ */
+ public function getUserOnly()
+ {
+ return $this->userOnly;
+ }
+
+ /**
+ * Should we use only user-defined constants?
+ *
+ * @param bool $userOnly
+ * @return Constant
+ */
+ public function setUserOnly($userOnly)
+ {
+ $this->userOnly = (bool) $userOnly;
+ return $this;
+ }
+
+ /**
+ * Load all currently defined constants into parser.
+ *
+ * @return void
+ */
+ public function loadConstants()
+ {
+ if ($this->userOnly) {
+ $constants = get_defined_constants(true);
+ $constants = isset($constants['user']) ? $constants['user'] : array();
+ $this->setTokens($constants);
+ } else {
+ $this->setTokens(get_defined_constants());
+ }
+ }
+
+ /**
+ * Get current token registry.
+ * @return array
+ */
+ public function getTokens()
+ {
+ return $this->tokens;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Processor/Filter.php zendframework-2.2.6/library/Zend/Config/Processor/Filter.php
--- zendframework-1.10.4/library/Zend/Config/Processor/Filter.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Processor/Filter.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,88 @@
+setFilter($filter);
+ }
+
+ /**
+ * @param ZendFilter $filter
+ * @return Filter
+ */
+ public function setFilter(ZendFilter $filter)
+ {
+ $this->filter = $filter;
+ return $this;
+ }
+
+ /**
+ * @return ZendFilter
+ */
+ public function getFilter()
+ {
+ return $this->filter;
+ }
+
+ /**
+ * Process
+ *
+ * @param Config $config
+ * @return Config
+ * @throws Exception\InvalidArgumentException
+ */
+ public function process(Config $config)
+ {
+ if ($config->isReadOnly()) {
+ throw new Exception\InvalidArgumentException('Cannot process config because it is read-only');
+ }
+
+ /**
+ * Walk through config and replace values
+ */
+ foreach ($config as $key => $val) {
+ if ($val instanceof Config) {
+ $this->process($val);
+ } else {
+ $config->$key = $this->filter->filter($val);
+ }
+ }
+
+ return $config;
+ }
+
+ /**
+ * Process a single value
+ *
+ * @param mixed $value
+ * @return mixed
+ */
+ public function processValue($value)
+ {
+ return $this->filter->filter($value);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Processor/ProcessorInterface.php zendframework-2.2.6/library/Zend/Config/Processor/ProcessorInterface.php
--- zendframework-1.10.4/library/Zend/Config/Processor/ProcessorInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Processor/ProcessorInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,31 @@
+isReadOnly()) {
+ throw new Exception\InvalidArgumentException('Cannot process config because it is read-only');
+ }
+
+ foreach ($this as $parser) {
+ /** @var $parser ProcessorInterface */
+ $parser->process($config);
+ }
+ }
+
+ /**
+ * Process a single value
+ *
+ * @param mixed $value
+ * @return mixed
+ */
+ public function processValue($value)
+ {
+ foreach ($this as $parser) {
+ /** @var $parser ProcessorInterface */
+ $value = $parser->processValue($value);
+ }
+
+ return $value;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Processor/Token.php zendframework-2.2.6/library/Zend/Config/Processor/Token.php
--- zendframework-1.10.4/library/Zend/Config/Processor/Token.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Processor/Token.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,274 @@
+ value
+ * to replace it with
+ * @param string $prefix
+ * @param string $suffix
+ * @internal param array $options
+ * @return Token
+ */
+ public function __construct($tokens = array(), $prefix = '', $suffix = '')
+ {
+ $this->setTokens($tokens);
+ $this->setPrefix($prefix);
+ $this->setSuffix($suffix);
+ }
+
+ /**
+ * @param string $prefix
+ * @return Token
+ */
+ public function setPrefix($prefix)
+ {
+ // reset map
+ $this->map = null;
+ $this->prefix = $prefix;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getPrefix()
+ {
+ return $this->prefix;
+ }
+
+ /**
+ * @param string $suffix
+ * @return Token
+ */
+ public function setSuffix($suffix)
+ {
+ // reset map
+ $this->map = null;
+ $this->suffix = $suffix;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getSuffix()
+ {
+ return $this->suffix;
+ }
+
+ /**
+ * Set token registry.
+ *
+ * @param array|Config|Traversable $tokens Associative array of TOKEN => value
+ * to replace it with
+ * @return Token
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setTokens($tokens)
+ {
+ if (is_array($tokens)) {
+ $this->tokens = $tokens;
+ } elseif ($tokens instanceof Config) {
+ $this->tokens = $tokens->toArray();
+ } elseif ($tokens instanceof Traversable) {
+ $this->tokens = array();
+ foreach ($tokens as $key => $val) {
+ $this->tokens[$key] = $val;
+ }
+ } else {
+ throw new Exception\InvalidArgumentException('Cannot use ' . gettype($tokens) . ' as token registry.');
+ }
+
+ // reset map
+ $this->map = null;
+
+ return $this;
+ }
+
+ /**
+ * Get current token registry.
+ *
+ * @return array
+ */
+ public function getTokens()
+ {
+ return $this->tokens;
+ }
+
+ /**
+ * Add new token.
+ *
+ * @param string $token
+ * @param mixed $value
+ * @return Token
+ * @throws Exception\InvalidArgumentException
+ */
+ public function addToken($token, $value)
+ {
+ if (!is_scalar($token)) {
+ throw new Exception\InvalidArgumentException('Cannot use ' . gettype($token) . ' as token name.');
+ }
+ $this->tokens[$token] = $value;
+
+ // reset map
+ $this->map = null;
+
+ return $this;
+ }
+
+ /**
+ * Add new token.
+ *
+ * @param string $token
+ * @param mixed $value
+ * @return Token
+ */
+ public function setToken($token, $value)
+ {
+ return $this->addToken($token, $value);
+ }
+
+ /**
+ * Build replacement map
+ *
+ * @return array
+ */
+ protected function buildMap()
+ {
+ if (null === $this->map) {
+ if (!$this->suffix && !$this->prefix) {
+ $this->map = $this->tokens;
+ } else {
+ $this->map = array();
+
+ foreach ($this->tokens as $token => $value) {
+ $this->map[$this->prefix . $token . $this->suffix] = $value;
+ }
+ }
+
+ foreach (array_keys($this->map) as $key) {
+ if (empty($key)) {
+ unset($this->map[$key]);
+ }
+ }
+ }
+
+ return $this->map;
+ }
+
+ /**
+ * Process
+ *
+ * @param Config $config
+ * @return Config
+ * @throws Exception\InvalidArgumentException
+ */
+ public function process(Config $config)
+ {
+ return $this->doProcess($config, $this->buildMap());
+ }
+
+ /**
+ * Process a single value
+ *
+ * @param $value
+ * @return mixed
+ */
+ public function processValue($value)
+ {
+ return $this->doProcess($value, $this->buildMap());
+ }
+
+ /**
+ * Applies replacement map to the given value by modifying the value itself
+ *
+ * @param mixed $value
+ * @param array $replacements
+ *
+ * @return mixed
+ *
+ * @throws Exception\InvalidArgumentException if the provided value is a read-only {@see Config}
+ */
+ private function doProcess($value, array $replacements)
+ {
+ if ($value instanceof Config) {
+ if ($value->isReadOnly()) {
+ throw new Exception\InvalidArgumentException('Cannot process config because it is read-only');
+ }
+
+ foreach ($value as $key => $val) {
+ $value->$key = $this->doProcess($val, $replacements);
+ }
+
+ return $value;
+ }
+
+ if ($value instanceof Traversable || is_array($value)) {
+ foreach ($value as & $val) {
+ $val = $this->doProcess($val, $replacements);
+ }
+
+ return $value;
+ }
+
+ if (!is_string($value) && (is_bool($value) || is_numeric($value))) {
+ $stringVal = (string) $value;
+ $changedVal = strtr($value, $this->map);
+
+ // replace the value only if a string replacement occurred
+ if ($changedVal !== $stringVal) {
+ return $changedVal;
+ }
+
+ return $value;
+ }
+
+ return strtr((string) $value, $this->map);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Processor/Translator.php zendframework-2.2.6/library/Zend/Config/Processor/Translator.php
--- zendframework-1.10.4/library/Zend/Config/Processor/Translator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Processor/Translator.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,139 @@
+setTranslator($translator);
+ $this->setTextDomain($textDomain);
+ $this->setLocale($locale);
+ }
+
+ /**
+ * @param ZendTranslator $translator
+ * @return Translator
+ */
+ public function setTranslator(ZendTranslator $translator)
+ {
+ $this->translator = $translator;
+ return $this;
+ }
+
+ /**
+ * @return ZendTranslator
+ */
+ public function getTranslator()
+ {
+ return $this->translator;
+ }
+
+ /**
+ * @param string|null $locale
+ * @return Translator
+ */
+ public function setLocale($locale)
+ {
+ $this->locale = $locale;
+ return $this;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getLocale()
+ {
+ return $this->locale;
+ }
+
+ /**
+ * @param string $textDomain
+ * @return Translator
+ */
+ public function setTextDomain($textDomain)
+ {
+ $this->textDomain = $textDomain;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTextDomain()
+ {
+ return $this->textDomain;
+ }
+
+ /**
+ * Process
+ *
+ * @param Config $config
+ * @return Config
+ * @throws Exception\InvalidArgumentException
+ */
+ public function process(Config $config)
+ {
+ if ($config->isReadOnly()) {
+ throw new Exception\InvalidArgumentException('Cannot process config because it is read-only');
+ }
+
+ /**
+ * Walk through config and replace values
+ */
+ foreach ($config as $key => $val) {
+ if ($val instanceof Config) {
+ $this->process($val);
+ } else {
+ $config->{$key} = $this->translator->translate($val, $this->textDomain, $this->locale);
+ }
+ }
+
+ return $config;
+ }
+
+ /**
+ * Process a single value
+ *
+ * @param $value
+ * @return mixed
+ */
+ public function processValue($value)
+ {
+ return $this->translator->translate($value, $this->textDomain, $this->locale);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Reader/Ini.php zendframework-2.2.6/library/Zend/Config/Reader/Ini.php
--- zendframework-1.10.4/library/Zend/Config/Reader/Ini.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Reader/Ini.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,223 @@
+nestSeparator = $separator;
+ return $this;
+ }
+
+ /**
+ * Get nest separator.
+ *
+ * @return string
+ */
+ public function getNestSeparator()
+ {
+ return $this->nestSeparator;
+ }
+
+ /**
+ * fromFile(): defined by Reader interface.
+ *
+ * @see ReaderInterface::fromFile()
+ * @param string $filename
+ * @return array
+ * @throws Exception\RuntimeException
+ */
+ public function fromFile($filename)
+ {
+ if (!is_file($filename) || !is_readable($filename)) {
+ throw new Exception\RuntimeException(sprintf(
+ "File '%s' doesn't exist or not readable",
+ $filename
+ ));
+ }
+
+ $this->directory = dirname($filename);
+
+ set_error_handler(
+ function ($error, $message = '', $file = '', $line = 0) use ($filename) {
+ throw new Exception\RuntimeException(sprintf(
+ 'Error reading INI file "%s": %s',
+ $filename, $message
+ ), $error);
+ }, E_WARNING
+ );
+ $ini = parse_ini_file($filename, true);
+ restore_error_handler();
+
+ return $this->process($ini);
+ }
+
+ /**
+ * fromString(): defined by Reader interface.
+ *
+ * @param string $string
+ * @return array|bool
+ * @throws Exception\RuntimeException
+ */
+ public function fromString($string)
+ {
+ if (empty($string)) {
+ return array();
+ }
+ $this->directory = null;
+
+ set_error_handler(
+ function ($error, $message = '', $file = '', $line = 0) {
+ throw new Exception\RuntimeException(sprintf(
+ 'Error reading INI string: %s',
+ $message
+ ), $error);
+ }, E_WARNING
+ );
+ $ini = parse_ini_string($string, true);
+ restore_error_handler();
+
+ return $this->process($ini);
+ }
+
+ /**
+ * Process data from the parsed ini file.
+ *
+ * @param array $data
+ * @return array
+ */
+ protected function process(array $data)
+ {
+ $config = array();
+
+ foreach ($data as $section => $value) {
+ if (is_array($value)) {
+ if (strpos($section, $this->nestSeparator) !== false) {
+ $sections = explode($this->nestSeparator, $section);
+ $config = array_merge_recursive($config, $this->buildNestedSection($sections, $value));
+ } else {
+ $config[$section] = $this->processSection($value);
+ }
+ } else {
+ $this->processKey($section, $value, $config);
+ }
+ }
+
+ return $config;
+ }
+
+ /**
+ * Process a nested section
+ *
+ * @param array $sections
+ * @param mixed $value
+ * @return array
+ */
+ private function buildNestedSection($sections, $value)
+ {
+ if (count($sections) == 0) {
+ return $this->processSection($value);
+ }
+
+ $nestedSection = array();
+
+ $first = array_shift($sections);
+ $nestedSection[$first] = $this->buildNestedSection($sections, $value);
+
+ return $nestedSection;
+ }
+
+ /**
+ * Process a section.
+ *
+ * @param array $section
+ * @return array
+ */
+ protected function processSection(array $section)
+ {
+ $config = array();
+
+ foreach ($section as $key => $value) {
+ $this->processKey($key, $value, $config);
+ }
+
+ return $config;
+ }
+
+ /**
+ * Process a key.
+ *
+ * @param string $key
+ * @param string $value
+ * @param array $config
+ * @return array
+ * @throws Exception\RuntimeException
+ */
+ protected function processKey($key, $value, array &$config)
+ {
+ if (strpos($key, $this->nestSeparator) !== false) {
+ $pieces = explode($this->nestSeparator, $key, 2);
+
+ if (!strlen($pieces[0]) || !strlen($pieces[1])) {
+ throw new Exception\RuntimeException(sprintf('Invalid key "%s"', $key));
+ } elseif (!isset($config[$pieces[0]])) {
+ if ($pieces[0] === '0' && !empty($config)) {
+ $config = array($pieces[0] => $config);
+ } else {
+ $config[$pieces[0]] = array();
+ }
+ } elseif (!is_array($config[$pieces[0]])) {
+ throw new Exception\RuntimeException(sprintf(
+ 'Cannot create sub-key for "%s", as key already exists', $pieces[0]
+ ));
+ }
+
+ $this->processKey($pieces[1], $value, $config[$pieces[0]]);
+ } else {
+ if ($key === '@include') {
+ if ($this->directory === null) {
+ throw new Exception\RuntimeException('Cannot process @include statement for a string config');
+ }
+
+ $reader = clone $this;
+ $include = $reader->fromFile($this->directory . '/' . $value);
+ $config = array_replace_recursive($config, $include);
+ } else {
+ $config[$key] = $value;
+ }
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Reader/Json.php zendframework-2.2.6/library/Zend/Config/Reader/Json.php
--- zendframework-1.10.4/library/Zend/Config/Reader/Json.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Reader/Json.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,105 @@
+directory = dirname($filename);
+
+ try {
+ $config = JsonFormat::decode(file_get_contents($filename), JsonFormat::TYPE_ARRAY);
+ } catch (JsonException\RuntimeException $e) {
+ throw new Exception\RuntimeException($e->getMessage());
+ }
+
+ return $this->process($config);
+ }
+
+ /**
+ * fromString(): defined by Reader interface.
+ *
+ * @see ReaderInterface::fromString()
+ * @param string $string
+ * @return array|bool
+ * @throws Exception\RuntimeException
+ */
+ public function fromString($string)
+ {
+ if (empty($string)) {
+ return array();
+ }
+
+ $this->directory = null;
+
+ try {
+ $config = JsonFormat::decode($string, JsonFormat::TYPE_ARRAY);
+ } catch (JsonException\RuntimeException $e) {
+ throw new Exception\RuntimeException($e->getMessage());
+ }
+
+ return $this->process($config);
+ }
+
+ /**
+ * Process the array for @include
+ *
+ * @param array $data
+ * @return array
+ * @throws Exception\RuntimeException
+ */
+ protected function process(array $data)
+ {
+ foreach ($data as $key => $value) {
+ if (is_array($value)) {
+ $data[$key] = $this->process($value);
+ }
+ if (trim($key) === '@include') {
+ if ($this->directory === null) {
+ throw new Exception\RuntimeException('Cannot process @include statement for a JSON string');
+ }
+ $reader = clone $this;
+ unset($data[$key]);
+ $data = array_replace_recursive($data, $reader->fromFile($this->directory . '/' . $value));
+ }
+ }
+ return $data;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Reader/ReaderInterface.php zendframework-2.2.6/library/Zend/Config/Reader/ReaderInterface.php
--- zendframework-1.10.4/library/Zend/Config/Reader/ReaderInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Reader/ReaderInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,29 @@
+reader = new XMLReader();
+ $this->reader->open($filename, null, LIBXML_XINCLUDE);
+
+ $this->directory = dirname($filename);
+
+ set_error_handler(
+ function ($error, $message = '', $file = '', $line = 0) use ($filename) {
+ throw new Exception\RuntimeException(sprintf(
+ 'Error reading XML file "%s": %s',
+ $filename, $message
+ ), $error);
+ }, E_WARNING
+ );
+ $return = $this->process();
+ restore_error_handler();
+
+ return $return;
+ }
+
+ /**
+ * fromString(): defined by Reader interface.
+ *
+ * @see ReaderInterface::fromString()
+ * @param string $string
+ * @return array|bool
+ * @throws Exception\RuntimeException
+ */
+ public function fromString($string)
+ {
+ if (empty($string)) {
+ return array();
+ }
+ $this->reader = new XMLReader();
+
+ $this->reader->xml($string, null, LIBXML_XINCLUDE);
+
+ $this->directory = null;
+
+ set_error_handler(
+ function ($error, $message = '', $file = '', $line = 0) {
+ throw new Exception\RuntimeException(sprintf(
+ 'Error reading XML string: %s',
+ $message
+ ), $error);
+ }, E_WARNING
+ );
+ $return = $this->process();
+ restore_error_handler();
+
+ return $return;
+ }
+
+ /**
+ * Process data from the created XMLReader.
+ *
+ * @return array
+ */
+ protected function process()
+ {
+ return $this->processNextElement();
+ }
+
+ /**
+ * Process the next inner element.
+ *
+ * @return mixed
+ */
+ protected function processNextElement()
+ {
+ $children = array();
+ $text = '';
+
+ while ($this->reader->read()) {
+ if ($this->reader->nodeType === XMLReader::ELEMENT) {
+ if ($this->reader->depth === 0) {
+ return $this->processNextElement();
+ }
+
+ $attributes = $this->getAttributes();
+ $name = $this->reader->name;
+
+ if ($this->reader->isEmptyElement) {
+ $child = array();
+ } else {
+ $child = $this->processNextElement();
+ }
+
+ if ($attributes) {
+ if (!is_array($child)) {
+ $child = array();
+ }
+
+ $child = array_merge($child, $attributes);
+ }
+
+ if (isset($children[$name])) {
+ if (!is_array($children[$name]) || !array_key_exists(0, $children[$name])) {
+ $children[$name] = array($children[$name]);
+ }
+
+ $children[$name][] = $child;
+ } else {
+ $children[$name] = $child;
+ }
+ } elseif ($this->reader->nodeType === XMLReader::END_ELEMENT) {
+ break;
+ } elseif (in_array($this->reader->nodeType, $this->textNodes)) {
+ $text .= $this->reader->value;
+ }
+ }
+
+ return $children ?: $text;
+ }
+
+ /**
+ * Get all attributes on the current node.
+ *
+ * @return array
+ */
+ protected function getAttributes()
+ {
+ $attributes = array();
+
+ if ($this->reader->hasAttributes) {
+ while ($this->reader->moveToNextAttribute()) {
+ $attributes[$this->reader->localName] = $this->reader->value;
+ }
+
+ $this->reader->moveToElement();
+ }
+
+ return $attributes;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Reader/Yaml.php zendframework-2.2.6/library/Zend/Config/Reader/Yaml.php
--- zendframework-1.10.4/library/Zend/Config/Reader/Yaml.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Reader/Yaml.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,159 @@
+setYamlDecoder($yamlDecoder);
+ } else {
+ if (function_exists('yaml_parse')) {
+ $this->setYamlDecoder('yaml_parse');
+ }
+ }
+ }
+
+ /**
+ * Set callback for decoding YAML
+ *
+ * @param string|callable $yamlDecoder the decoder to set
+ * @return Yaml
+ * @throws Exception\RuntimeException
+ */
+ public function setYamlDecoder($yamlDecoder)
+ {
+ if (!is_callable($yamlDecoder)) {
+ throw new Exception\RuntimeException(
+ 'Invalid parameter to setYamlDecoder() - must be callable'
+ );
+ }
+ $this->yamlDecoder = $yamlDecoder;
+ return $this;
+ }
+
+ /**
+ * Get callback for decoding YAML
+ *
+ * @return callable
+ */
+ public function getYamlDecoder()
+ {
+ return $this->yamlDecoder;
+ }
+
+ /**
+ * fromFile(): defined by Reader interface.
+ *
+ * @see ReaderInterface::fromFile()
+ * @param string $filename
+ * @return array
+ * @throws Exception\RuntimeException
+ */
+ public function fromFile($filename)
+ {
+ if (!is_file($filename) || !is_readable($filename)) {
+ throw new Exception\RuntimeException(sprintf(
+ "File '%s' doesn't exist or not readable",
+ $filename
+ ));
+ }
+
+ if (null === $this->getYamlDecoder()) {
+ throw new Exception\RuntimeException("You didn't specify a Yaml callback decoder");
+ }
+
+ $this->directory = dirname($filename);
+
+ $config = call_user_func($this->getYamlDecoder(), file_get_contents($filename));
+ if (null === $config) {
+ throw new Exception\RuntimeException("Error parsing YAML data");
+ }
+
+ return $this->process($config);
+ }
+
+ /**
+ * fromString(): defined by Reader interface.
+ *
+ * @see ReaderInterface::fromString()
+ * @param string $string
+ * @return array|bool
+ * @throws Exception\RuntimeException
+ */
+ public function fromString($string)
+ {
+ if (null === $this->getYamlDecoder()) {
+ throw new Exception\RuntimeException("You didn't specify a Yaml callback decoder");
+ }
+ if (empty($string)) {
+ return array();
+ }
+
+ $this->directory = null;
+
+ $config = call_user_func($this->getYamlDecoder(), $string);
+ if (null === $config) {
+ throw new Exception\RuntimeException("Error parsing YAML data");
+ }
+
+ return $this->process($config);
+ }
+
+ /**
+ * Process the array for @include
+ *
+ * @param array $data
+ * @return array
+ * @throws Exception\RuntimeException
+ */
+ protected function process(array $data)
+ {
+ foreach ($data as $key => $value) {
+ if (is_array($value)) {
+ $data[$key] = $this->process($value);
+ }
+ if (trim($key) === '@include') {
+ if ($this->directory === null) {
+ throw new Exception\RuntimeException('Cannot process @include statement for a json string');
+ }
+ $reader = clone $this;
+ unset($data[$key]);
+ $data = array_replace_recursive($data, $reader->fromFile($this->directory . '/' . $value));
+ }
+ }
+ return $data;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/ReaderPluginManager.php zendframework-2.2.6/library/Zend/Config/ReaderPluginManager.php
--- zendframework-1.10.4/library/Zend/Config/ReaderPluginManager.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/ReaderPluginManager.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,49 @@
+ 'Zend\Config\Reader\Ini',
+ 'json' => 'Zend\Config\Reader\Json',
+ 'xml' => 'Zend\Config\Reader\Xml',
+ 'yaml' => 'Zend\Config\Reader\Yaml',
+ );
+
+ /**
+ * Validate the plugin
+ * Checks that the reader loaded is an instance of Reader\ReaderInterface.
+ *
+ * @param Reader\ReaderInterface $plugin
+ * @return void
+ * @throws Exception\InvalidArgumentException if invalid
+ */
+ public function validatePlugin($plugin)
+ {
+ if ($plugin instanceof Reader\ReaderInterface) {
+ // we're okay
+ return;
+ }
+
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Plugin of type %s is invalid; must implement %s\Reader\ReaderInterface',
+ (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
+ __NAMESPACE__
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/README.md zendframework-2.2.6/library/Zend/Config/README.md
--- zendframework-1.10.4/library/Zend/Config/README.md 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/README.md 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,15 @@
+Config Component from ZF2
+=========================
+
+This is the Config component for ZF2.
+
+- File issues at https://github.com/zendframework/zf2/issues
+- Create pull requests against https://github.com/zendframework/zf2
+- Documentation is at http://framework.zend.com/docs
+
+LICENSE
+-------
+
+The files in this archive are released under the [Zend Framework
+license](http://framework.zend.com/license), which is a 3-clause BSD license.
+
diff -Nru zendframework-1.10.4/library/Zend/Config/Writer/AbstractWriter.php zendframework-2.2.6/library/Zend/Config/Writer/AbstractWriter.php
--- zendframework-1.10.4/library/Zend/Config/Writer/AbstractWriter.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Writer/AbstractWriter.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,83 @@
+toString($config), $flags);
+ } catch (\Exception $e) {
+ restore_error_handler();
+ throw $e;
+ }
+
+ restore_error_handler();
+ }
+
+ /**
+ * toString(): defined by Writer interface.
+ *
+ * @see WriterInterface::toString()
+ * @param mixed $config
+ * @return string
+ * @throws Exception\InvalidArgumentException
+ */
+ public function toString($config)
+ {
+ if ($config instanceof Traversable) {
+ $config = ArrayUtils::iteratorToArray($config);
+ } elseif (!is_array($config)) {
+ throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable config');
+ }
+
+ return $this->processConfig($config);
+ }
+
+ /**
+ * @param array $config
+ * @return string
+ */
+ abstract protected function processConfig(array $config);
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Writer/Array.php zendframework-2.2.6/library/Zend/Config/Writer/Array.php
--- zendframework-1.10.4/library/Zend/Config/Writer/Array.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Writer/Array.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,55 +0,0 @@
-_config->toArray();
- $sectionName = $this->_config->getSectionName();
-
- if (is_string($sectionName)) {
- $data = array($sectionName => $data);
- }
-
- $arrayString = "_filename = $filename;
-
- return $this;
- }
-
- /**
- * Set wether to exclusively lock the file or not
- *
- * @param boolean $exclusiveLock
- * @return Zend_Config_Writer_Array
- */
- public function setExclusiveLock($exclusiveLock)
- {
- $this->_exclusiveLock = $exclusiveLock;
-
- return $this;
- }
-
- /**
- * Write configuration to file.
- *
- * @param string $filename
- * @param Zend_Config $config
- * @param bool $exclusiveLock
- * @return void
- */
- public function write($filename = null, Zend_Config $config = null, $exclusiveLock = null)
- {
- if ($filename !== null) {
- $this->setFilename($filename);
- }
-
- if ($config !== null) {
- $this->setConfig($config);
- }
-
- if ($exclusiveLock !== null) {
- $this->setExclusiveLock($exclusiveLock);
- }
-
- if ($this->_filename === null) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('No filename was set');
- }
-
- if ($this->_config === null) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('No config was set');
- }
-
- $configString = $this->render();
-
- $flags = 0;
-
- if ($this->_exclusiveLock) {
- $flags |= LOCK_EX;
- }
-
- $result = @file_put_contents($this->_filename, $configString, $flags);
-
- if ($result === false) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"');
- }
- }
-
- /**
- * Render a Zend_Config into a config file string.
- *
- * @since 1.10
- * @todo For 2.0 this should be redone into an abstract method.
- * @return string
- */
- public function render()
- {
- return "";
- }
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Config/Writer/Ini.php zendframework-2.2.6/library/Zend/Config/Writer/Ini.php
--- zendframework-1.10.4/library/Zend/Config/Writer/Ini.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Writer/Ini.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,111 +1,104 @@
_nestSeparator = $separator;
-
+ $this->nestSeparator = $separator;
return $this;
}
/**
- * Set if rendering should occour without sections or not.
+ * Get nest separator.
+ *
+ * @return string
+ */
+ public function getNestSeparator()
+ {
+ return $this->nestSeparator;
+ }
+
+ /**
+ * Set if rendering should occur without sections or not.
*
* If set to true, the INI file is rendered without sections completely
* into the global namespace of the INI file.
*
* @param bool $withoutSections
- * @return Zend_Config_Writer_Ini
+ * @return Ini
*/
- public function setRenderWithoutSections($withoutSections=true)
+ public function setRenderWithoutSectionsFlags($withoutSections)
{
- $this->_renderWithoutSections = (bool)$withoutSections;
+ $this->renderWithoutSections = (bool) $withoutSections;
return $this;
}
/**
- * Render a Zend_Config into a INI config string.
+ * Return whether the writer should render without sections.
*
- * @since 1.10
+ * @return bool
+ */
+ public function shouldRenderWithoutSections()
+ {
+ return $this->renderWithoutSections;
+ }
+
+ /**
+ * processConfig(): defined by AbstractWriter.
+ *
+ * @param array $config
* @return string
*/
- public function render()
+ public function processConfig(array $config)
{
- $iniString = '';
- $extends = $this->_config->getExtends();
- $sectionName = $this->_config->getSectionName();
-
- if($this->_renderWithoutSections == true) {
- $iniString .= $this->_addBranch($this->_config);
- } else if (is_string($sectionName)) {
- $iniString .= '[' . $sectionName . ']' . "\n"
- . $this->_addBranch($this->_config)
- . "\n";
+ $iniString = '';
+
+ if ($this->shouldRenderWithoutSections()) {
+ $iniString .= $this->addBranch($config);
} else {
- foreach ($this->_config as $sectionName => $data) {
- if (!($data instanceof Zend_Config)) {
+ $config = $this->sortRootElements($config);
+
+ foreach ($config as $sectionName => $data) {
+ if (!is_array($data)) {
$iniString .= $sectionName
. ' = '
- . $this->_prepareValue($data)
+ . $this->prepareValue($data)
. "\n";
} else {
- if (isset($extends[$sectionName])) {
- $sectionName .= ' : ' . $extends[$sectionName];
- }
-
$iniString .= '[' . $sectionName . ']' . "\n"
- . $this->_addBranch($data)
+ . $this->addBranch($data)
. "\n";
}
}
@@ -115,24 +108,25 @@
}
/**
- * Add a branch to an INI string recursively
+ * Add a branch to an INI string recursively.
*
- * @param Zend_Config $config
- * @return void
+ * @param array $config
+ * @param array $parents
+ * @return string
*/
- protected function _addBranch(Zend_Config $config, $parents = array())
+ protected function addBranch(array $config, $parents = array())
{
$iniString = '';
foreach ($config as $key => $value) {
$group = array_merge($parents, array($key));
- if ($value instanceof Zend_Config) {
- $iniString .= $this->_addBranch($value, $group);
+ if (is_array($value)) {
+ $iniString .= $this->addBranch($value, $group);
} else {
- $iniString .= implode($this->_nestSeparator, $group)
+ $iniString .= implode($this->nestSeparator, $group)
. ' = '
- . $this->_prepareValue($value)
+ . $this->prepareValue($value)
. "\n";
}
}
@@ -141,23 +135,49 @@
}
/**
- * Prepare a value for INI
+ * Prepare a value for INI.
*
* @param mixed $value
* @return string
+ * @throws Exception\RuntimeException
*/
- protected function _prepareValue($value)
+ protected function prepareValue($value)
{
- if (is_integer($value) || is_float($value)) {
+ if (is_int($value) || is_float($value)) {
return $value;
} elseif (is_bool($value)) {
return ($value ? 'true' : 'false');
- } elseif (strpos($value, '"') === false) {
+ } elseif (false === strpos($value, '"')) {
return '"' . $value . '"';
} else {
- /** @see Zend_Config_Exception */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Value can not contain double quotes "');
+ throw new Exception\RuntimeException('Value can not contain double quotes');
}
}
+
+ /**
+ * Root elements that are not assigned to any section needs to be on the
+ * top of config.
+ *
+ * @param array $config
+ * @return array
+ */
+ protected function sortRootElements(array $config)
+ {
+ $sections = array();
+
+ // Remove sections from config array.
+ foreach ($config as $key => $value) {
+ if (is_array($value)) {
+ $sections[$key] = $value;
+ unset($config[$key]);
+ }
+ }
+
+ // Read sections to the end.
+ foreach ($sections as $key => $value) {
+ $config[$key] = $value;
+ }
+
+ return $config;
+ }
}
diff -Nru zendframework-1.10.4/library/Zend/Config/Writer/Json.php zendframework-2.2.6/library/Zend/Config/Writer/Json.php
--- zendframework-1.10.4/library/Zend/Config/Writer/Json.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Writer/Json.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,26 @@
+');
- $extends = $this->_config->getExtends();
- $sectionName = $this->_config->getSectionName();
-
- if (is_string($sectionName)) {
- $child = $xml->addChild($sectionName);
-
- $this->_addBranch($this->_config, $child, $xml);
- } else {
- foreach ($this->_config as $sectionName => $data) {
- if (!($data instanceof Zend_Config)) {
- $xml->addChild($sectionName, (string) $data);
- } else {
- $child = $xml->addChild($sectionName);
-
- if (isset($extends[$sectionName])) {
- $child->addAttribute('zf:extends', $extends[$sectionName], Zend_Config_Xml::XML_NAMESPACE);
- }
-
- $this->_addBranch($data, $child, $xml);
- }
+ $writer = new XMLWriter('UTF-8');
+ $writer->openMemory();
+ $writer->setIndent(true);
+ $writer->setIndentString(str_repeat(' ', 4));
+
+ $writer->startDocument('1.0', 'UTF-8');
+ $writer->startElement('zend-config');
+
+ foreach ($config as $sectionName => $data) {
+ if (!is_array($data)) {
+ $writer->writeElement($sectionName, (string) $data);
+ } else {
+ $this->addBranch($sectionName, $data, $writer);
}
}
- $dom = dom_import_simplexml($xml)->ownerDocument;
- $dom->formatOutput = true;
+ $writer->endElement();
+ $writer->endDocument();
- $xmlString = $dom->saveXML();
-
- return $xmlString;
+ return $writer->outputMemory();
}
/**
- * Add a branch to an XML object recursively
+ * Add a branch to an XML object recursively.
*
- * @param Zend_Config $config
- * @param SimpleXMLElement $xml
- * @param SimpleXMLElement $parent
+ * @param string $branchName
+ * @param array $config
+ * @param XMLWriter $writer
* @return void
+ * @throws Exception\RuntimeException
*/
- protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, SimpleXMLElement $parent)
+ protected function addBranch($branchName, array $config, XMLWriter $writer)
{
$branchType = null;
@@ -93,35 +61,31 @@
if ($branchType === null) {
if (is_numeric($key)) {
$branchType = 'numeric';
- $branchName = $xml->getName();
- $xml = $parent;
-
- unset($parent->{$branchName});
} else {
+ $writer->startElement($branchName);
$branchType = 'string';
}
- } else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
+ } elseif ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
+ throw new Exception\RuntimeException('Mixing of string and numeric keys is not allowed');
}
if ($branchType === 'numeric') {
- if ($value instanceof Zend_Config) {
- $child = $parent->addChild($branchName);
-
- $this->_addBranch($value, $child, $parent);
+ if (is_array($value)) {
+ $this->addBranch($value, $value, $writer);
} else {
- $parent->addChild($branchName, (string) $value);
+ $writer->writeElement($branchName, (string) $value);
}
} else {
- if ($value instanceof Zend_Config) {
- $child = $xml->addChild($key);
-
- $this->_addBranch($value, $child, $xml);
+ if (is_array($value)) {
+ $this->addBranch($key, $value, $writer);
} else {
- $xml->addChild($key, (string) $value);
+ $writer->writeElement($key, (string) $value);
}
}
}
+
+ if ($branchType === 'string') {
+ $writer->endElement();
+ }
}
}
diff -Nru zendframework-1.10.4/library/Zend/Config/Writer/Yaml.php zendframework-2.2.6/library/Zend/Config/Writer/Yaml.php
--- zendframework-1.10.4/library/Zend/Config/Writer/Yaml.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Writer/Yaml.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,85 @@
+setYamlEncoder($yamlEncoder);
+ } else {
+ if (function_exists('yaml_emit')) {
+ $this->setYamlEncoder('yaml_emit');
+ }
+ }
+ }
+
+ /**
+ * Get callback for decoding YAML
+ *
+ * @return callable
+ */
+ public function getYamlEncoder()
+ {
+ return $this->yamlEncoder;
+ }
+
+ /**
+ * Set callback for decoding YAML
+ *
+ * @param callable $yamlEncoder the decoder to set
+ * @return Yaml
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setYamlEncoder($yamlEncoder)
+ {
+ if (!is_callable($yamlEncoder)) {
+ throw new Exception\InvalidArgumentException('Invalid parameter to setYamlEncoder() - must be callable');
+ }
+ $this->yamlEncoder = $yamlEncoder;
+ return $this;
+ }
+
+ /**
+ * processConfig(): defined by AbstractWriter.
+ *
+ * @param array $config
+ * @return string
+ * @throws Exception\RuntimeException
+ */
+ public function processConfig(array $config)
+ {
+ if (null === $this->getYamlEncoder()) {
+ throw new Exception\RuntimeException("You didn't specify a Yaml callback encoder");
+ }
+
+ $config = call_user_func($this->getYamlEncoder(), $config);
+ if (null === $config) {
+ throw new Exception\RuntimeException("Error generating YAML data");
+ }
+
+ return $config;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Writer.php zendframework-2.2.6/library/Zend/Config/Writer.php
--- zendframework-1.10.4/library/Zend/Config/Writer.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Writer.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,101 +0,0 @@
-setOptions($options);
- }
- }
-
- /**
- * Set options via a Zend_Config instance
- *
- * @param Zend_Config $config
- * @return Zend_Config_Writer
- */
- public function setConfig(Zend_Config $config)
- {
- $this->_config = $config;
-
- return $this;
- }
-
- /**
- * Set options via an array
- *
- * @param array $options
- * @return Zend_Config_Writer
- */
- public function setOptions(array $options)
- {
- foreach ($options as $key => $value) {
- if (in_array(strtolower($key), $this->_skipOptions)) {
- continue;
- }
-
- $method = 'set' . ucfirst($key);
- if (method_exists($this, $method)) {
- $this->$method($value);
- }
- }
-
- return $this;
- }
-
- /**
- * Write a Zend_Config object to it's target
- *
- * @return void
- */
- abstract public function write();
-}
diff -Nru zendframework-1.10.4/library/Zend/Config/WriterPluginManager.php zendframework-2.2.6/library/Zend/Config/WriterPluginManager.php
--- zendframework-1.10.4/library/Zend/Config/WriterPluginManager.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/WriterPluginManager.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,37 @@
+ 'Zend\Config\Writer\Ini',
+ 'json' => 'Zend\Config\Writer\Json',
+ 'php' => 'Zend\Config\Writer\PhpArray',
+ 'yaml' => 'Zend\Config\Writer\Yaml',
+ 'xml' => 'Zend\Config\Writer\Xml',
+ );
+
+ public function validatePlugin($plugin)
+ {
+ if ($plugin instanceOf Writer\AbstractWriter) {
+ return;
+ }
+
+ $type = is_object($plugin) ? get_class($plugin) : gettype($plugin);
+
+ throw new Exception\InvalidArgumentException(
+ "Plugin of type {$type} is invalid. Plugin must extend ".
+ __NAMESPACE__.'\Writer\AbstractWriter'
+ );
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Config/Xml.php zendframework-2.2.6/library/Zend/Config/Xml.php
--- zendframework-1.10.4/library/Zend/Config/Xml.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config/Xml.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,286 +0,0 @@
-_skipExtends = (bool) $options['skipExtends'];
- }
- }
-
- set_error_handler(array($this, '_loadFileErrorHandler')); // Warnings and errors are suppressed
- if (strstr($xml, '_loadFileErrorStr !== null) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception($this->_loadFileErrorStr);
- }
-
- if ($section === null) {
- $dataArray = array();
- foreach ($config as $sectionName => $sectionData) {
- $dataArray[$sectionName] = $this->_processExtends($config, $sectionName);
- }
-
- parent::__construct($dataArray, $allowModifications);
- } else if (is_array($section)) {
- $dataArray = array();
- foreach ($section as $sectionName) {
- if (!isset($config->$sectionName)) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Section '$sectionName' cannot be found in $xml");
- }
-
- $dataArray = array_merge($this->_processExtends($config, $sectionName), $dataArray);
- }
-
- parent::__construct($dataArray, $allowModifications);
- } else {
- if (!isset($config->$section)) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Section '$section' cannot be found in $xml");
- }
-
- $dataArray = $this->_processExtends($config, $section);
- if (!is_array($dataArray)) {
- // Section in the XML file contains just one top level string
- $dataArray = array($section => $dataArray);
- }
-
- parent::__construct($dataArray, $allowModifications);
- }
-
- $this->_loadedSection = $section;
- }
-
- /**
- * Helper function to process each element in the section and handle
- * the "extends" inheritance attribute.
- *
- * @param SimpleXMLElement $element XML Element to process
- * @param string $section Section to process
- * @param array $config Configuration which was parsed yet
- * @throws Zend_Config_Exception When $section cannot be found
- * @return array
- */
- protected function _processExtends(SimpleXMLElement $element, $section, array $config = array())
- {
- if (!isset($element->$section)) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Section '$section' cannot be found");
- }
-
- $thisSection = $element->$section;
- $nsAttributes = $thisSection->attributes(self::XML_NAMESPACE);
-
- if (isset($thisSection['extends']) || isset($nsAttributes['extends'])) {
- $extendedSection = (string) (isset($nsAttributes['extends']) ? $nsAttributes['extends'] : $thisSection['extends']);
- $this->_assertValidExtend($section, $extendedSection);
-
- if (!$this->_skipExtends) {
- $config = $this->_processExtends($element, $extendedSection, $config);
- }
- }
-
- $config = $this->_arrayMergeRecursive($config, $this->_toArray($thisSection));
-
- return $config;
- }
-
- /**
- * Returns a string or an associative and possibly multidimensional array from
- * a SimpleXMLElement.
- *
- * @param SimpleXMLElement $xmlObject Convert a SimpleXMLElement into an array
- * @return array|string
- */
- protected function _toArray(SimpleXMLElement $xmlObject)
- {
- $config = array();
- $nsAttributes = $xmlObject->attributes(self::XML_NAMESPACE);
-
- // Search for parent node values
- if (count($xmlObject->attributes()) > 0) {
- foreach ($xmlObject->attributes() as $key => $value) {
- if ($key === 'extends') {
- continue;
- }
-
- $value = (string) $value;
-
- if (array_key_exists($key, $config)) {
- if (!is_array($config[$key])) {
- $config[$key] = array($config[$key]);
- }
-
- $config[$key][] = $value;
- } else {
- $config[$key] = $value;
- }
- }
- }
-
- // Search for local 'const' nodes and replace them
- if (count($xmlObject->children(self::XML_NAMESPACE)) > 0) {
- if (count($xmlObject->children()) > 0) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("A node with a 'const' childnode may not have any other children");
- }
-
- $dom = dom_import_simplexml($xmlObject);
- $namespaceChildNodes = array();
-
- // We have to store them in an array, as replacing nodes will
- // confuse the DOMNodeList later
- foreach ($dom->childNodes as $node) {
- if ($node instanceof DOMElement && $node->namespaceURI === self::XML_NAMESPACE) {
- $namespaceChildNodes[] = $node;
- }
- }
-
- foreach ($namespaceChildNodes as $node) {
- switch ($node->localName) {
- case 'const':
- if (!$node->hasAttributeNS(self::XML_NAMESPACE, 'name')) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Misssing 'name' attribute in 'const' node");
- }
-
- $constantName = $node->getAttributeNS(self::XML_NAMESPACE, 'name');
-
- if (!defined($constantName)) {
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Constant with name '$constantName' was not defined");
- }
-
- $constantValue = constant($constantName);
-
- $dom->replaceChild($dom->ownerDocument->createTextNode($constantValue), $node);
- break;
-
- default:
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception("Unknown node with name '$node->localName' found");
- }
- }
-
- return (string) simplexml_import_dom($dom);
- }
-
- // Search for children
- if (count($xmlObject->children()) > 0) {
- foreach ($xmlObject->children() as $key => $value) {
- if (count($value->children()) > 0 || count($value->children(self::XML_NAMESPACE)) > 0) {
- $value = $this->_toArray($value);
- } else if (count($value->attributes()) > 0) {
- $attributes = $value->attributes();
- if (isset($attributes['value'])) {
- $value = (string) $attributes['value'];
- } else {
- $value = $this->_toArray($value);
- }
- } else {
- $value = (string) $value;
- }
-
- if (array_key_exists($key, $config)) {
- if (!is_array($config[$key]) || !array_key_exists(0, $config[$key])) {
- $config[$key] = array($config[$key]);
- }
-
- $config[$key][] = $value;
- } else {
- $config[$key] = $value;
- }
- }
- } else if (!isset($xmlObject['extends']) && !isset($nsAttributes['extends']) && (count($config) === 0)) {
- // Object has no children nor attributes and doesn't use the extends
- // attribute: it's a string
- $config = (string) $xmlObject;
- }
-
- return $config;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Config.php zendframework-2.2.6/library/Zend/Config.php
--- zendframework-1.10.4/library/Zend/Config.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Config.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,484 +0,0 @@
-_allowModifications = (boolean) $allowModifications;
- $this->_loadedSection = null;
- $this->_index = 0;
- $this->_data = array();
- foreach ($array as $key => $value) {
- if (is_array($value)) {
- $this->_data[$key] = new self($value, $this->_allowModifications);
- } else {
- $this->_data[$key] = $value;
- }
- }
- $this->_count = count($this->_data);
- }
-
- /**
- * Retrieve a value and return $default if there is no element set.
- *
- * @param string $name
- * @param mixed $default
- * @return mixed
- */
- public function get($name, $default = null)
- {
- $result = $default;
- if (array_key_exists($name, $this->_data)) {
- $result = $this->_data[$name];
- }
- return $result;
- }
-
- /**
- * Magic function so that $obj->value will work.
- *
- * @param string $name
- * @return mixed
- */
- public function __get($name)
- {
- return $this->get($name);
- }
-
- /**
- * Only allow setting of a property if $allowModifications
- * was set to true on construction. Otherwise, throw an exception.
- *
- * @param string $name
- * @param mixed $value
- * @throws Zend_Config_Exception
- * @return void
- */
- public function __set($name, $value)
- {
- if ($this->_allowModifications) {
- if (is_array($value)) {
- $this->_data[$name] = new self($value, true);
- } else {
- $this->_data[$name] = $value;
- }
- $this->_count = count($this->_data);
- } else {
- /** @see Zend_Config_Exception */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Zend_Config is read only');
- }
- }
-
- /**
- * Deep clone of this instance to ensure that nested Zend_Configs
- * are also cloned.
- *
- * @return void
- */
- public function __clone()
- {
- $array = array();
- foreach ($this->_data as $key => $value) {
- if ($value instanceof Zend_Config) {
- $array[$key] = clone $value;
- } else {
- $array[$key] = $value;
- }
- }
- $this->_data = $array;
- }
-
- /**
- * Return an associative array of the stored data.
- *
- * @return array
- */
- public function toArray()
- {
- $array = array();
- $data = $this->_data;
- foreach ($data as $key => $value) {
- if ($value instanceof Zend_Config) {
- $array[$key] = $value->toArray();
- } else {
- $array[$key] = $value;
- }
- }
- return $array;
- }
-
- /**
- * Support isset() overloading on PHP 5.1
- *
- * @param string $name
- * @return boolean
- */
- public function __isset($name)
- {
- return isset($this->_data[$name]);
- }
-
- /**
- * Support unset() overloading on PHP 5.1
- *
- * @param string $name
- * @throws Zend_Config_Exception
- * @return void
- */
- public function __unset($name)
- {
- if ($this->_allowModifications) {
- unset($this->_data[$name]);
- $this->_count = count($this->_data);
- $this->_skipNextIteration = true;
- } else {
- /** @see Zend_Config_Exception */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Zend_Config is read only');
- }
-
- }
-
- /**
- * Defined by Countable interface
- *
- * @return int
- */
- public function count()
- {
- return $this->_count;
- }
-
- /**
- * Defined by Iterator interface
- *
- * @return mixed
- */
- public function current()
- {
- $this->_skipNextIteration = false;
- return current($this->_data);
- }
-
- /**
- * Defined by Iterator interface
- *
- * @return mixed
- */
- public function key()
- {
- return key($this->_data);
- }
-
- /**
- * Defined by Iterator interface
- *
- */
- public function next()
- {
- if ($this->_skipNextIteration) {
- $this->_skipNextIteration = false;
- return;
- }
- next($this->_data);
- $this->_index++;
- }
-
- /**
- * Defined by Iterator interface
- *
- */
- public function rewind()
- {
- $this->_skipNextIteration = false;
- reset($this->_data);
- $this->_index = 0;
- }
-
- /**
- * Defined by Iterator interface
- *
- * @return boolean
- */
- public function valid()
- {
- return $this->_index < $this->_count;
- }
-
- /**
- * Returns the section name(s) loaded.
- *
- * @return mixed
- */
- public function getSectionName()
- {
- if(is_array($this->_loadedSection) && count($this->_loadedSection) == 1) {
- $this->_loadedSection = $this->_loadedSection[0];
- }
- return $this->_loadedSection;
- }
-
- /**
- * Returns true if all sections were loaded
- *
- * @return boolean
- */
- public function areAllSectionsLoaded()
- {
- return $this->_loadedSection === null;
- }
-
-
- /**
- * Merge another Zend_Config with this one. The items
- * in $merge will override the same named items in
- * the current config.
- *
- * @param Zend_Config $merge
- * @return Zend_Config
- */
- public function merge(Zend_Config $merge)
- {
- foreach($merge as $key => $item) {
- if(array_key_exists($key, $this->_data)) {
- if($item instanceof Zend_Config && $this->$key instanceof Zend_Config) {
- $this->$key = $this->$key->merge(new Zend_Config($item->toArray(), !$this->readOnly()));
- } else {
- $this->$key = $item;
- }
- } else {
- if($item instanceof Zend_Config) {
- $this->$key = new Zend_Config($item->toArray(), !$this->readOnly());
- } else {
- $this->$key = $item;
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Prevent any more modifications being made to this instance. Useful
- * after merge() has been used to merge multiple Zend_Config objects
- * into one object which should then not be modified again.
- *
- */
- public function setReadOnly()
- {
- $this->_allowModifications = false;
- foreach ($this->_data as $key => $value) {
- if ($value instanceof Zend_Config) {
- $value->setReadOnly();
- }
- }
- }
-
- /**
- * Returns if this Zend_Config object is read only or not.
- *
- * @return boolean
- */
- public function readOnly()
- {
- return !$this->_allowModifications;
- }
-
- /**
- * Get the current extends
- *
- * @return array
- */
- public function getExtends()
- {
- return $this->_extends;
- }
-
- /**
- * Set an extend for Zend_Config_Writer
- *
- * @param string $extendingSection
- * @param string $extendedSection
- * @return void
- */
- public function setExtend($extendingSection, $extendedSection = null)
- {
- if ($extendedSection === null && isset($this->_extends[$extendingSection])) {
- unset($this->_extends[$extendingSection]);
- } else if ($extendedSection !== null) {
- $this->_extends[$extendingSection] = $extendedSection;
- }
- }
-
- /**
- * Throws an exception if $extendingSection may not extend $extendedSection,
- * and tracks the section extension if it is valid.
- *
- * @param string $extendingSection
- * @param string $extendedSection
- * @throws Zend_Config_Exception
- * @return void
- */
- protected function _assertValidExtend($extendingSection, $extendedSection)
- {
- // detect circular section inheritance
- $extendedSectionCurrent = $extendedSection;
- while (array_key_exists($extendedSectionCurrent, $this->_extends)) {
- if ($this->_extends[$extendedSectionCurrent] == $extendingSection) {
- /** @see Zend_Config_Exception */
- require_once 'Zend/Config/Exception.php';
- throw new Zend_Config_Exception('Illegal circular inheritance detected');
- }
- $extendedSectionCurrent = $this->_extends[$extendedSectionCurrent];
- }
- // remember that this section extends another section
- $this->_extends[$extendingSection] = $extendedSection;
- }
-
- /**
- * Handle any errors from simplexml_load_file or parse_ini_file
- *
- * @param integer $errno
- * @param string $errstr
- * @param string $errfile
- * @param integer $errline
- */
- protected function _loadFileErrorHandler($errno, $errstr, $errfile, $errline)
- {
- if ($this->_loadFileErrorStr === null) {
- $this->_loadFileErrorStr = $errstr;
- } else {
- $this->_loadFileErrorStr .= (PHP_EOL . $errstr);
- }
- }
-
- /**
- * Merge two arrays recursively, overwriting keys of the same name
- * in $firstArray with the value in $secondArray.
- *
- * @param mixed $firstArray First array
- * @param mixed $secondArray Second array to merge into first array
- * @return array
- */
- protected function _arrayMergeRecursive($firstArray, $secondArray)
- {
- if (is_array($firstArray) && is_array($secondArray)) {
- foreach ($secondArray as $key => $value) {
- if (isset($firstArray[$key])) {
- $firstArray[$key] = $this->_arrayMergeRecursive($firstArray[$key], $value);
- } else {
- if($key === 0) {
- $firstArray= array(0=>$this->_arrayMergeRecursive($firstArray, $value));
- } else {
- $firstArray[$key] = $value;
- }
- }
- }
- } else {
- $firstArray = $secondArray;
- }
-
- return $firstArray;
- }
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Console/Adapter/AbstractAdapter.php zendframework-2.2.6/library/Zend/Console/Adapter/AbstractAdapter.php
--- zendframework-1.10.4/library/Zend/Console/Adapter/AbstractAdapter.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Adapter/AbstractAdapter.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,500 @@
+colorize($text, $color, $bgColor);
+ } else {
+ echo $text;
+ }
+ }
+
+ /**
+ * Alias for write()
+ *
+ * @param string $text
+ * @param null|int $color
+ * @param null|int $bgColor
+ */
+ public function writeText($text, $color = null, $bgColor = null)
+ {
+ return $this->write($text, $color, $bgColor);
+ }
+
+ /**
+ * Write a single line of text to console and advance cursor to the next line.
+ *
+ * @param string $text
+ * @param null|int $color
+ * @param null|int $bgColor
+ */
+ public function writeLine($text = "", $color = null, $bgColor = null)
+ {
+ $this->write($text . PHP_EOL, $color, $bgColor);
+ }
+
+ /**
+ * Write a piece of text at the coordinates of $x and $y
+ *
+ *
+ * @param string $text Text to write
+ * @param int $x Console X coordinate (column)
+ * @param int $y Console Y coordinate (row)
+ * @param null|int $color
+ * @param null|int $bgColor
+ */
+ public function writeAt($text, $x, $y, $color = null, $bgColor = null)
+ {
+ $this->setPos($x, $y);
+ $this->write($text, $color, $bgColor);
+ }
+
+ /**
+ * Write a box at the specified coordinates.
+ * If X or Y coordinate value is negative, it will be calculated as the distance from far right or bottom edge
+ * of the console (respectively).
+ *
+ * @param int $x1 Top-left corner X coordinate (column)
+ * @param int $y1 Top-left corner Y coordinate (row)
+ * @param int $x2 Bottom-right corner X coordinate (column)
+ * @param int $y2 Bottom-right corner Y coordinate (row)
+ * @param int $lineStyle (optional) Box border style.
+ * @param int $fillStyle (optional) Box fill style or a single character to fill it with.
+ * @param int $color (optional) Foreground color
+ * @param int $bgColor (optional) Background color
+ * @param null|int $fillColor (optional) Foreground color of box fill
+ * @param null|int $fillBgColor (optional) Background color of box fill
+ * @throws Exception\BadMethodCallException if coordinates are invalid
+ */
+ public function writeBox(
+ $x1,
+ $y1,
+ $x2,
+ $y2,
+ $lineStyle = self::LINE_SINGLE,
+ $fillStyle = self::FILL_NONE,
+ $color = null,
+ $bgColor = null,
+ $fillColor = null,
+ $fillBgColor = null
+ ) {
+ // Sanitize coordinates
+ $x1 = (int) $x1;
+ $y1 = (int) $y1;
+ $x2 = (int) $x2;
+ $y2 = (int) $y2;
+
+ // Translate negative coordinates
+ if ($x2 < 0) {
+ $x2 = $this->getWidth() - $x2;
+ }
+
+ if ($y2 < 0) {
+ $y2 = $this->getHeight() - $y2;
+ }
+
+ // Validate coordinates
+ if ($x1 < 0
+ || $y1 < 0
+ || $x2 < $x1
+ || $y2 < $y1
+ ) {
+ throw new Exception\BadMethodCallException('Supplied X,Y coordinates are invalid.');
+ }
+
+ // Determine charset and dimensions
+ $charset = $this->getCharset();
+ $width = $x2 - $x1 + 1;
+ $height = $y2 - $y1 + 1;
+
+ if ($width <= 2) {
+ $lineStyle = static::LINE_NONE;
+ }
+
+ // Activate line drawing
+ $this->write($charset::ACTIVATE);
+
+ // Draw horizontal lines
+ if ($lineStyle !== static::LINE_NONE) {
+ switch ($lineStyle) {
+ case static::LINE_SINGLE:
+ $lineChar = $charset::LINE_SINGLE_EW;
+ break;
+
+ case static::LINE_DOUBLE:
+ $lineChar = $charset::LINE_DOUBLE_EW;
+ break;
+
+ case static::LINE_BLOCK:
+ default:
+ $lineChar = $charset::LINE_BLOCK_EW;
+ break;
+ }
+
+ $this->setPos($x1 + 1, $y1);
+ $this->write(str_repeat($lineChar, $width - 2), $color, $bgColor);
+ $this->setPos($x1 + 1, $y2);
+ $this->write(str_repeat($lineChar, $width - 2), $color, $bgColor);
+ }
+
+ // Draw vertical lines and fill
+ if (is_numeric($fillStyle)
+ && $fillStyle !== static::FILL_NONE) {
+
+ switch ($fillStyle) {
+ case static::FILL_SHADE_LIGHT:
+ $fillChar = $charset::SHADE_LIGHT;
+ break;
+ case static::FILL_SHADE_MEDIUM:
+ $fillChar = $charset::SHADE_MEDIUM;
+ break;
+ case static::FILL_SHADE_DARK:
+ $fillChar = $charset::SHADE_DARK;
+ break;
+ case static::FILL_BLOCK:
+ default:
+ $fillChar = $charset::BLOCK;
+ break;
+ }
+
+ } elseif ($fillStyle) {
+ $fillChar = StringUtils::getWrapper()->substr($fillStyle, 0, 1);
+ } else {
+ $fillChar = ' ';
+ }
+
+ if ($lineStyle === static::LINE_NONE) {
+ for ($y = $y1; $y <= $y2; $y++) {
+ $this->setPos($x1, $y);
+ $this->write(str_repeat($fillChar, $width), $fillColor, $fillBgColor);
+ }
+ } else {
+ switch ($lineStyle) {
+ case static::LINE_DOUBLE:
+ $lineChar = $charset::LINE_DOUBLE_NS;
+ break;
+ case static::LINE_BLOCK:
+ $lineChar = $charset::LINE_BLOCK_NS;
+ break;
+ case static::LINE_SINGLE:
+ default:
+ $lineChar = $charset::LINE_SINGLE_NS;
+ break;
+ }
+
+ for ($y = $y1 + 1; $y < $y2; $y++) {
+ $this->setPos($x1, $y);
+ $this->write($lineChar, $color, $bgColor);
+ $this->write(str_repeat($fillChar, $width - 2), $fillColor, $fillBgColor);
+ $this->write($lineChar, $color, $bgColor);
+ }
+ }
+
+
+ // Draw corners
+ if ($lineStyle !== static::LINE_NONE) {
+ if ($color !== null) {
+ $this->setColor($color);
+ }
+ if ($bgColor !== null) {
+ $this->setBgColor($bgColor);
+ }
+ if ($lineStyle === static::LINE_SINGLE) {
+ $this->writeAt($charset::LINE_SINGLE_NW, $x1, $y1);
+ $this->writeAt($charset::LINE_SINGLE_NE, $x2, $y1);
+ $this->writeAt($charset::LINE_SINGLE_SE, $x2, $y2);
+ $this->writeAt($charset::LINE_SINGLE_SW, $x1, $y2);
+ } elseif ($lineStyle === static::LINE_DOUBLE) {
+ $this->writeAt($charset::LINE_DOUBLE_NW, $x1, $y1);
+ $this->writeAt($charset::LINE_DOUBLE_NE, $x2, $y1);
+ $this->writeAt($charset::LINE_DOUBLE_SE, $x2, $y2);
+ $this->writeAt($charset::LINE_DOUBLE_SW, $x1, $y2);
+ } elseif ($lineStyle === static::LINE_BLOCK) {
+ $this->writeAt($charset::LINE_BLOCK_NW, $x1, $y1);
+ $this->writeAt($charset::LINE_BLOCK_NE, $x2, $y1);
+ $this->writeAt($charset::LINE_BLOCK_SE, $x2, $y2);
+ $this->writeAt($charset::LINE_BLOCK_SW, $x1, $y2);
+ }
+ }
+
+ // Deactivate line drawing and reset colors
+ $this->write($charset::DEACTIVATE);
+ $this->resetColor();
+ }
+
+ /**
+ * Write a block of text at the given coordinates, matching the supplied width and height.
+ * In case a line of text does not fit desired width, it will be wrapped to the next line.
+ * In case the whole text does not fit in desired height, it will be truncated.
+ *
+ * @param string $text Text to write
+ * @param int $width Maximum block width. Negative value means distance from right edge.
+ * @param int|null $height Maximum block height. Negative value means distance from bottom edge.
+ * @param int $x Block X coordinate (column)
+ * @param int $y Block Y coordinate (row)
+ * @param null|int $color (optional) Text color
+ * @param null|int $bgColor (optional) Text background color
+ */
+ public function writeTextBlock(
+ $text,
+ $width,
+ $height = null,
+ $x = 0,
+ $y = 0,
+ $color = null,
+ $bgColor = null
+ ) {
+ }
+
+ /**
+ * Determine and return current console width.
+ *
+ * @return int
+ */
+ public function getWidth()
+ {
+ return 80;
+ }
+
+ /**
+ * Determine and return current console height.
+ *
+ * @return int
+ */
+ public function getHeight()
+ {
+ return 25;
+ }
+
+ /**
+ * Determine and return current console width and height.
+ *
+ * @return array array($width, $height)
+ */
+ public function getSize()
+ {
+ return array(
+ $this->getWidth(),
+ $this->getHeight(),
+ );
+ }
+
+ /**
+ * Check if console is UTF-8 compatible
+ *
+ * @return bool
+ */
+ public function isUtf8()
+ {
+ return true;
+ }
+
+ /**
+ * Set cursor position
+ *
+ * @param int $x
+ * @param int $y
+ */
+ public function setPos($x, $y)
+ {
+ }
+
+ /**
+ * Show console cursor
+ */
+ public function showCursor()
+ {
+ }
+
+ /**
+ * Hide console cursor
+ */
+ public function hideCursor()
+ {
+ }
+
+ /**
+ * Return current console window title.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return '';
+ }
+
+ /**
+ * Prepare a string that will be rendered in color.
+ *
+ * @param string $string
+ * @param int $color
+ * @param null|int $bgColor
+ * @return string
+ */
+ public function colorize($string, $color = null, $bgColor = null)
+ {
+ return $string;
+ }
+
+ /**
+ * Change current drawing color.
+ *
+ * @param int $color
+ */
+ public function setColor($color)
+ {
+ }
+
+ /**
+ * Change current drawing background color
+ *
+ * @param int $color
+ */
+ public function setBgColor($color)
+ {
+ }
+
+ /**
+ * Reset color to console default.
+ */
+ public function resetColor()
+ {
+ }
+
+ /**
+ * Set Console charset to use.
+ *
+ * @param Charset\CharsetInterface $charset
+ */
+ public function setCharset(Charset\CharsetInterface $charset)
+ {
+ $this->charset = $charset;
+ }
+
+ /**
+ * Get charset currently in use by this adapter.
+ *
+ * @return Charset\CharsetInterface $charset
+ */
+ public function getCharset()
+ {
+ if ($this->charset === null) {
+ $this->charset = $this->getDefaultCharset();
+ }
+
+ return $this->charset;
+ }
+
+ /**
+ * @return Charset\Utf8
+ */
+ public function getDefaultCharset()
+ {
+ return new Charset\Utf8;
+ }
+
+ /**
+ * Clear console screen
+ */
+ public function clear()
+ {
+ echo "\f";
+ }
+
+ /**
+ * Clear line at cursor position
+ */
+ public function clearLine()
+ {
+ echo "\r" . str_repeat(" ", $this->getWidth()) . "\r";
+ }
+
+ /**
+ * Clear console screen
+ */
+ public function clearScreen()
+ {
+ return $this->clear();
+ }
+
+ /**
+ * Read a single line from the console input
+ *
+ * @param int $maxLength Maximum response length
+ * @return string
+ */
+ public function readLine($maxLength = 2048)
+ {
+ $f = fopen('php://stdin','r');
+ $line = stream_get_line($f, $maxLength, PHP_EOL);
+ fclose($f);
+ return rtrim($line,"\n\r");
+ }
+
+ /**
+ * Read a single character from the console input
+ *
+ * @param string|null $mask A list of allowed chars
+ * @return string
+ */
+ public function readChar($mask = null)
+ {
+ $f = fopen('php://stdin','r');
+ do {
+ $char = fread($f,1);
+ } while ("" === $char || ($mask !== null && false === strstr($mask, $char)));
+ fclose($f);
+ return $char;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Adapter/AdapterInterface.php zendframework-2.2.6/library/Zend/Console/Adapter/AdapterInterface.php
--- zendframework-1.10.4/library/Zend/Console/Adapter/AdapterInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Adapter/AdapterInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,249 @@
+ array(
+ Color::NORMAL => '22;39',
+ Color::RESET => '22;39',
+
+ Color::BLACK => '0;30',
+ Color::RED => '0;31',
+ Color::GREEN => '0;32',
+ Color::YELLOW => '0;33',
+ Color::BLUE => '0;34',
+ Color::MAGENTA => '0;35',
+ Color::CYAN => '0;36',
+ Color::WHITE => '0;37',
+
+ Color::GRAY => '1;30',
+ Color::LIGHT_RED => '1;31',
+ Color::LIGHT_GREEN => '1;32',
+ Color::LIGHT_YELLOW => '1;33',
+ Color::LIGHT_BLUE => '1;34',
+ Color::LIGHT_MAGENTA => '1;35',
+ Color::LIGHT_CYAN => '1;36',
+ Color::LIGHT_WHITE => '1;37',
+ ),
+ 'bg' => array(
+ Color::NORMAL => '0;49',
+ Color::RESET => '0;49',
+
+ Color::BLACK => '40',
+ Color::RED => '41',
+ Color::GREEN => '42',
+ Color::YELLOW => '43',
+ Color::BLUE => '44',
+ Color::MAGENTA => '45',
+ Color::CYAN => '46',
+ Color::WHITE => '47',
+
+ Color::GRAY => '40',
+ Color::LIGHT_RED => '41',
+ Color::LIGHT_GREEN => '42',
+ Color::LIGHT_YELLOW => '43',
+ Color::LIGHT_BLUE => '44',
+ Color::LIGHT_MAGENTA => '45',
+ Color::LIGHT_CYAN => '46',
+ Color::LIGHT_WHITE => '47',
+ ),
+ );
+
+ /**
+ * Last fetched TTY mode
+ *
+ * @var string|null
+ */
+ protected $lastTTYMode = null;
+
+ /**
+ * Write a single line of text to console and advance cursor to the next line.
+ *
+ * This override works around a bug in some terminals that cause the background color
+ * to fill the next line after EOL. To remedy this, we are sending the colored string with
+ * appropriate color reset sequences before sending EOL character.
+ *
+ * @link https://github.com/zendframework/zf2/issues/4167
+ * @param string $text
+ * @param null|int $color
+ * @param null|int $bgColor
+ */
+ public function writeLine($text = "", $color = null, $bgColor = null)
+ {
+ $this->write($text, $color, $bgColor);
+ $this->write(PHP_EOL);
+ }
+
+ /**
+ * Determine and return current console width.
+ *
+ * @return int
+ */
+ public function getWidth()
+ {
+ static $width;
+ if ($width > 0) {
+ return $width;
+ }
+
+ /**
+ * Try to read env variable
+ */
+ if (($result = getenv('COLUMNS')) !== false) {
+ return $width = (int) $result;
+ }
+
+ /**
+ * Try to read console size from "tput" command
+ */
+ $result = exec('tput cols', $output, $return);
+ if (!$return && is_numeric($result)) {
+ return $width = (int) $result;
+ }
+
+ return $width = parent::getWidth();
+ }
+
+ /**
+ * Determine and return current console height.
+ *
+ * @return false|int
+ */
+ public function getHeight()
+ {
+ static $height;
+ if ($height > 0) {
+ return $height;
+ }
+
+ // Try to read env variable
+ if (($result = getenv('LINES')) !== false) {
+ return $height = (int) $result;
+ }
+
+ // Try to read console size from "tput" command
+ $result = exec('tput lines', $output, $return);
+ if (!$return && is_numeric($result)) {
+ return $height = (int) $result;
+ }
+
+ return $height = parent::getHeight();
+ }
+
+ /**
+ * Run a mode command and store results
+ *
+ * @return void
+ */
+ protected function runModeCommand()
+ {
+ exec('mode', $output, $return);
+ if ($return || !count($output)) {
+ $this->modeResult = '';
+ } else {
+ $this->modeResult = trim(implode('', $output));
+ }
+ }
+
+ /**
+ * Check if console is UTF-8 compatible
+ *
+ * @return bool
+ */
+ public function isUtf8()
+ {
+ // Try to retrieve it from LANG env variable
+ if (($lang = getenv('LANG')) !== false) {
+ return stristr($lang, 'utf-8') || stristr($lang, 'utf8');
+ }
+
+ return false;
+ }
+
+ /**
+ * Show console cursor
+ */
+ public function showCursor()
+ {
+ echo "\x1b[?25h";
+ }
+
+ /**
+ * Hide console cursor
+ */
+ public function hideCursor()
+ {
+ echo "\x1b[?25l";
+ }
+
+ /**
+ * Set cursor position
+ * @param int $x
+ * @param int $y
+ */
+ public function setPos($x, $y)
+ {
+ echo "\x1b[" . $y . ';' . $x . 'f';
+ }
+
+ /**
+ * Prepare a string that will be rendered in color.
+ *
+ * @param string $string
+ * @param int $color
+ * @param null|int $bgColor
+ * @throws Exception\BadMethodCallException
+ * @return string
+ */
+ public function colorize($string, $color = null, $bgColor = null)
+ {
+ $color = $this->getColorCode($color, 'fg');
+ $bgColor = $this->getColorCode($bgColor, 'bg');
+ return ($color !== null ? "\x1b[" . $color . 'm' : '')
+ . ($bgColor !== null ? "\x1b[" . $bgColor . 'm' : '')
+ . $string
+ . "\x1b[22;39m\x1b[0;49m";
+ }
+
+ /**
+ * Change current drawing color.
+ *
+ * @param int $color
+ * @throws Exception\BadMethodCallException
+ */
+ public function setColor($color)
+ {
+ $color = $this->getColorCode($color, 'fg');
+ echo "\x1b[" . $color . 'm';
+ }
+
+ /**
+ * Change current drawing background color
+ *
+ * @param int $bgColor
+ * @throws Exception\BadMethodCallException
+ */
+ public function setBgColor($bgColor)
+ {
+ $bgColor = $this->getColorCode($bgColor, 'bg');
+ echo "\x1b[" . ($bgColor) . 'm';
+ }
+
+ /**
+ * Reset color to console default.
+ */
+ public function resetColor()
+ {
+ echo "\x1b[0;49m"; // reset bg color
+ echo "\x1b[22;39m"; // reset fg bold, bright and faint
+ echo "\x1b[25;39m"; // reset fg blink
+ echo "\x1b[24;39m"; // reset fg underline
+ }
+
+ /**
+ * Set Console charset to use.
+ *
+ * @param Charset\CharsetInterface $charset
+ */
+ public function setCharset(Charset\CharsetInterface $charset)
+ {
+ $this->charset = $charset;
+ }
+
+ /**
+ * Get charset currently in use by this adapter.
+ *
+ * @return Charset\CharsetInterface $charset
+ */
+ public function getCharset()
+ {
+ if ($this->charset === null) {
+ $this->charset = $this->getDefaultCharset();
+ }
+
+ return $this->charset;
+ }
+
+ /**
+ * @return Charset\CharsetInterface
+ */
+ public function getDefaultCharset()
+ {
+ if ($this->isUtf8()) {
+ return new Charset\Utf8;
+ }
+ return new Charset\DECSG();
+ }
+
+ /**
+ * Read a single character from the console input
+ *
+ * @param string|null $mask A list of allowed chars
+ * @return string
+ */
+ public function readChar($mask = null)
+ {
+ $this->setTTYMode('-icanon -echo');
+
+ $stream = fopen('php://stdin', 'rb');
+ do {
+ $char = fgetc($stream);
+ } while (strlen($char) !== 1 || ($mask !== null && false === strstr($mask, $char)));
+ fclose($stream);
+
+ $this->restoreTTYMode();
+ return $char;
+ }
+
+ /**
+ * Reset color to console default.
+ */
+ public function clear()
+ {
+ echo "\x1b[2J"; // reset bg color
+ $this->setPos(1, 1); // reset cursor position
+ }
+
+ /**
+ * Restore TTY (Console) mode to previous value.
+ *
+ * @return void
+ */
+ protected function restoreTTYMode()
+ {
+ if ($this->lastTTYMode === null) {
+ return;
+ }
+
+ shell_exec('stty ' . escapeshellarg($this->lastTTYMode));
+ }
+
+ /**
+ * Change TTY (Console) mode
+ *
+ * @link http://en.wikipedia.org/wiki/Stty
+ * @param $mode
+ */
+ protected function setTTYMode($mode)
+ {
+ // Store last mode
+ $this->lastTTYMode = trim(`stty -g`);
+
+ // Set new mode
+ shell_exec('stty '.escapeshellcmd($mode));
+ }
+
+ /**
+ * Get the final color code and throw exception on error
+ *
+ * @param null|int|Xterm256 $color
+ * @throws Exception\BadMethodCallException
+ * @return string
+ */
+ protected function getColorCode($color, $type = 'fg')
+ {
+ if ($color instanceof Xterm256) {
+ $r = new ReflectionClass($color);
+ $code = $r->getStaticPropertyValue('color');
+ if ($type == 'fg') {
+ $code = sprintf($code, $color::FOREGROUND);
+ } else {
+ $code = sprintf($code, $color::BACKGROUND);
+ }
+ return $code;
+ }
+
+ if ($color !== null) {
+ if (!isset(static::$ansiColorMap[$type][$color])) {
+ throw new Exception\BadMethodCallException(sprintf(
+ 'Unknown color "%s". Please use one of the Zend\Console\ColorInterface constants or use Zend\Console\Color\Xterm256::calculate',
+ $color
+ ));
+ }
+
+ return static::$ansiColorMap[$type][$color];
+ }
+
+ return null;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Adapter/Virtual.php zendframework-2.2.6/library/Zend/Console/Adapter/Virtual.php
--- zendframework-1.10.4/library/Zend/Console/Adapter/Virtual.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Adapter/Virtual.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,176 @@
+ 0) {
+ return $width;
+ }
+
+ // Try to read console size from "mode" command
+ if ($this->modeResult === null) {
+ $this->runProbeCommand();
+ }
+
+ if (preg_match('/Columns\:\s+(\d+)/', $this->modeResult, $matches)) {
+ $width = $matches[1];
+ } else {
+ $width = parent::getWidth();
+ }
+
+ return $width;
+ }
+
+ /**
+ * Determine and return current console height.
+ *
+ * @return false|int
+ */
+ public function getHeight()
+ {
+ static $height;
+ if ($height > 0) {
+ return $height;
+ }
+
+ // Try to read console size from "mode" command
+ if ($this->modeResult === null) {
+ $this->runProbeCommand();
+ }
+
+ if (preg_match('/Rows\:\s+(\d+)/', $this->modeResult, $matches)) {
+ $height = $matches[1];
+ } else {
+ $height = parent::getHeight();
+ }
+
+ return $height;
+ }
+
+ /**
+ * Run and store the results of mode command
+ *
+ * @return void
+ */
+ protected function runProbeCommand()
+ {
+ exec('mode', $output, $return);
+ if ($return || !count($output)) {
+ $this->modeResult = '';
+ } else {
+ $this->modeResult = trim(implode('', $output));
+ }
+ }
+
+ /**
+ * Check if console is UTF-8 compatible
+ *
+ * @return bool
+ */
+ public function isUtf8()
+ {
+ // Try to read code page info from "mode" command
+ if ($this->modeResult === null) {
+ $this->runProbeCommand();
+ }
+
+ if (preg_match('/Code page\:\s+(\d+)/', $this->modeResult, $matches)) {
+ return (int) $matches[1] == 65001;
+ }
+
+ return false;
+ }
+
+ /**
+ * Return current console window title.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ // Try to use powershell to retrieve console window title
+ exec('powershell -command "write $Host.UI.RawUI.WindowTitle"', $output, $result);
+ if ($result || !$output) {
+ return '';
+ }
+
+ return trim($output, "\r\n");
+ }
+
+ /**
+ * Set Console charset to use.
+ *
+ * @param Charset\CharsetInterface $charset
+ */
+ public function setCharset(Charset\CharsetInterface $charset)
+ {
+ $this->charset = $charset;
+ }
+
+ /**
+ * Get charset currently in use by this adapter.
+ *
+ * @return Charset\CharsetInterface $charset
+ */
+ public function getCharset()
+ {
+ if ($this->charset === null) {
+ $this->charset = $this->getDefaultCharset();
+ }
+
+ return $this->charset;
+ }
+
+ /**
+ * @return Charset\AsciiExtended
+ */
+ public function getDefaultCharset()
+ {
+ return new Charset\AsciiExtended;
+ }
+
+ /**
+ * Switch to UTF mode
+ *
+ * @return void
+ */
+ protected function switchToUtf8()
+ {
+ shell_exec('mode con cp select=65001');
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Adapter/WindowsAnsicon.php zendframework-2.2.6/library/Zend/Console/Adapter/WindowsAnsicon.php
--- zendframework-1.10.4/library/Zend/Console/Adapter/WindowsAnsicon.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Adapter/WindowsAnsicon.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,302 @@
+ 0) {
+ return $width;
+ }
+
+ // Try to read console size from ANSICON env var
+ if (preg_match('/\((\d+)x/', getenv('ANSICON'), $matches)) {
+ $width = $matches[1];
+ } else {
+ $width = AbstractAdapter::getWidth();
+ }
+
+ return $width;
+ }
+
+ /**
+ * Determine and return current console height.
+ *
+ * @return false|int
+ */
+ public function getHeight()
+ {
+ static $height;
+ if ($height > 0) {
+ return $height;
+ }
+
+ // Try to read console size from ANSICON env var
+ if (preg_match('/\(\d+x(\d+)/', getenv('ANSICON'), $matches)) {
+ $height = $matches[1];
+ } else {
+ $height = AbstractAdapter::getHeight();
+ }
+ return $height;
+ }
+
+ /**
+ * Run and cache results of mode command
+ *
+ * @return void
+ */
+ protected function runModeCommand()
+ {
+ exec('mode', $output, $return);
+ if ($return || !count($output)) {
+ $this->modeResult = '';
+ } else {
+ $this->modeResult = trim(implode('', $output));
+ }
+ }
+
+ /**
+ * Check if console is UTF-8 compatible
+ *
+ * @return bool
+ */
+ public function isUtf8()
+ {
+ // Try to read code page info from "mode" command
+ if ($this->modeResult === null) {
+ $this->runModeCommand();
+ }
+
+ if (preg_match('/Code page\:\s+(\d+)/', $this->modeResult, $matches)) {
+ return (int) $matches[1] == 65001;
+ }
+
+ return false;
+ }
+
+ /**
+ * Return current console window title.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ // Try to use powershell to retrieve console window title
+ exec('powershell -command "write $Host.UI.RawUI.WindowTitle"', $output, $result);
+ if ($result || !$output) {
+ return '';
+ }
+
+ return trim($output, "\r\n");
+ }
+
+ /**
+ * Clear console screen
+ */
+ public function clear()
+ {
+ echo chr(27) . '[1J' . chr(27) . '[u';
+ }
+
+ /**
+ * Clear line at cursor position
+ */
+ public function clearLine()
+ {
+ echo chr(27) . '[1K';
+ }
+
+ /**
+ * Set Console charset to use.
+ *
+ * @param CharsetInterface $charset
+ */
+ public function setCharset(CharsetInterface $charset)
+ {
+ $this->charset = $charset;
+ }
+
+ /**
+ * Get charset currently in use by this adapter.
+ *
+
+ * @return CharsetInterface $charset
+ */
+ public function getCharset()
+ {
+ if ($this->charset === null) {
+ $this->charset = $this->getDefaultCharset();
+ }
+
+ return $this->charset;
+ }
+
+ /**
+ * @return Charset\AsciiExtended
+ */
+ public function getDefaultCharset()
+ {
+ return new Charset\AsciiExtended();
+ }
+
+ /**
+ * Read a single character from the console input
+ *
+ * @param string|null $mask A list of allowed chars
+ * @return string
+ * @throws Exception\RuntimeException
+ */
+ public function readChar($mask = null)
+ {
+ // Decide if we can use `choice` tool
+ $useChoice = $mask !== null && preg_match('/^[a-zA-Z0-9]+$/D', $mask);
+
+ if ($useChoice) {
+ // Use Windows 98+ "choice" command, which allows for reading a
+ // single character matching a mask, but is limited to lower ASCII
+ // range.
+ do {
+ exec('choice /n /cs /c:' . $mask, $output, $return);
+ if ($return == 255 || $return < 1 || $return > strlen($mask)) {
+ throw new Exception\RuntimeException('"choice" command failed to run. Are you using Windows XP or newer?');
+ }
+
+ // Fetch the char from mask
+ $char = substr($mask, $return - 1, 1);
+ } while ("" === $char || ($mask !== null && false === strstr($mask, $char)));
+
+ return $char;
+ }
+
+ // Try to use PowerShell, giving it console access. Because PowersShell
+ // interpreter can take a short while to load, we are emptying the
+ // whole keyboard buffer and picking the last key that has been pressed
+ // before or after PowerShell command has started. The ASCII code for
+ // that key is then converted to a character.
+ if ($mask === null) {
+ exec(
+ 'powershell -NonInteractive -NoProfile -NoLogo -OutputFormat Text -Command "'
+ . 'while ($Host.UI.RawUI.KeyAvailable) {$key = $Host.UI.RawUI.ReadKey(\'NoEcho,IncludeKeyDown\');}'
+ . 'write $key.VirtualKeyCode;'
+ . '"',
+ $result,
+ $return
+ );
+
+ // Retrieve char from the result.
+ $char = !empty($result) ? implode('', $result) : null;
+
+ if (!empty($char) && !$return) {
+ // We have obtained an ASCII code, convert back to a char ...
+ $char = chr($char);
+
+ // ... and return it...
+ return $char;
+ }
+ } else {
+ // Windows and DOS will return carriage-return char (ASCII 13) when
+ // the user presses [ENTER] key, but Console Adapter user might
+ // have provided a \n Newline (ASCII 10) in the mask, to allow
+ // [ENTER]. We are going to replace all CR with NL to conform.
+ $mask = strtr($mask, "\n", "\r");
+
+ // Prepare a list of ASCII codes from mask chars
+ $asciiMask = array_map(function ($char) {
+ return ord($char);
+ }, str_split($mask));
+ $asciiMask = array_unique($asciiMask);
+
+ // Char mask filtering is now handled by the PowerShell itself,
+ // because it's a much faster method than invoking PS interpreter
+ // after each mismatch. The command should return ASCII code of a
+ // matching key.
+ $result = $return = null;
+ exec(
+ 'powershell -NonInteractive -NoProfile -NoLogo -OutputFormat Text -Command "'
+ . '[int[]] $mask = '.join(',', $asciiMask).';'
+ . 'do {'
+ . '$key = $Host.UI.RawUI.ReadKey(\'NoEcho,IncludeKeyDown\').VirtualKeyCode;'
+ . '} while( !($mask -contains $key) );'
+ . 'write $key;'
+ . '"',
+ $result,
+ $return
+ );
+
+ $char = !empty($result) ? trim(implode('', $result)) : null;
+
+ if (!$return && $char && ($mask === null || in_array($char, $asciiMask))) {
+ // We have obtained an ASCII code, check if it is a carriage
+ // return and normalize it as needed
+ if ($char == 13) {
+ $char = 10;
+ }
+
+ // Convert to a character
+ $char = chr($char);
+
+ // ... and return it...
+ return $char;
+ }
+ }
+
+ // Fall back to standard input, which on Windows does not allow reading
+ // a single character. This is a limitation of Windows streams
+ // implementation (not PHP) and this behavior cannot be changed with a
+ // command like "stty", known to POSIX systems.
+ $stream = fopen('php://stdin', 'rb');
+ do {
+ $char = fgetc($stream);
+ $char = substr(trim($char), 0, 1);
+ } while (!$char || ($mask !== null && !stristr($mask, $char)));
+ fclose($stream);
+
+ return $char;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Adapter/Windows.php zendframework-2.2.6/library/Zend/Console/Adapter/Windows.php
--- zendframework-1.10.4/library/Zend/Console/Adapter/Windows.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Adapter/Windows.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,356 @@
+ 0) {
+ return $width;
+ }
+
+ // Try to read console size from "mode" command
+ if ($this->probeResult === null) {
+ $this->runProbeCommand();
+ }
+
+ if (count($this->probeResult) && (int) $this->probeResult[0]) {
+ $width = (int) $this->probeResult[0];
+ } else {
+ $width = parent::getWidth();
+ }
+
+ return $width;
+ }
+
+ /**
+ * Determine and return current console height.
+ *
+ * @return false|int
+ */
+ public function getHeight()
+ {
+ static $height;
+ if ($height > 0) {
+ return $height;
+ }
+
+ // Try to read console size from "mode" command
+ if ($this->probeResult === null) {
+ $this->runProbeCommand();
+ }
+
+ if (count($this->probeResult) && (int) $this->probeResult[1]) {
+ $height = (int) $this->probeResult[1];
+ } else {
+ $height = parent::getheight();
+ }
+
+ return $height;
+ }
+
+ /**
+ * Probe for system capabilities and cache results
+ *
+ * Run a Windows Powershell command that determines parameters of console window. The command is fed through
+ * standard input (with echo) to prevent Powershell from creating a sub-thread and hanging PHP when run through
+ * a debugger/IDE.
+ *
+ * @return void
+ */
+ protected function runProbeCommand()
+ {
+ exec(
+ 'echo $size = $Host.ui.rawui.windowsize; write $($size.width) $($size.height) | powershell -NonInteractive -NoProfile -NoLogo -OutputFormat Text -Command -',
+ $output,
+ $return
+ );
+ if ($return || empty($output)) {
+ $this->probeResult = '';
+ } else {
+ $this->probeResult = $output;
+ }
+ }
+
+ /**
+ * Run and cache results of mode command
+ *
+ * @return void
+ */
+ protected function runModeCommand()
+ {
+ exec('mode', $output, $return);
+ if ($return || !count($output)) {
+ $this->modeResult = '';
+ } else {
+ $this->modeResult = trim(implode('', $output));
+ }
+ }
+
+ /**
+ * Check if console is UTF-8 compatible
+ *
+ * @return bool
+ */
+ public function isUtf8()
+ {
+ // Try to read code page info from "mode" command
+ if ($this->modeResult === null) {
+ $this->runModeCommand();
+ }
+
+ if (preg_match('/Code page\:\s+(\d+)/', $this->modeResult, $matches)) {
+ return (int) $matches[1] == 65001;
+ }
+
+ return false;
+ }
+
+ /**
+ * Return current console window title.
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ // Try to use powershell to retrieve console window title
+ exec('powershell -command "write $Host.UI.RawUI.WindowTitle"', $output, $result);
+ if ($result || !$output) {
+ return '';
+ }
+
+ return trim($output, "\r\n");
+ }
+
+ /**
+ * Set Console charset to use.
+ *
+ * @param Charset\CharsetInterface $charset
+ */
+ public function setCharset(Charset\CharsetInterface $charset)
+ {
+ $this->charset = $charset;
+ }
+
+ /**
+ * Get charset currently in use by this adapter.
+ *
+ * @return Charset\CharsetInterface $charset
+ */
+ public function getCharset()
+ {
+ if ($this->charset === null) {
+ $this->charset = $this->getDefaultCharset();
+ }
+
+ return $this->charset;
+ }
+
+ /**
+ * @return Charset\AsciiExtended
+ */
+ public function getDefaultCharset()
+ {
+ return new Charset\AsciiExtended;
+ }
+
+ /**
+ * Switch to utf-8 encoding
+ *
+ * @return void
+ */
+ protected function switchToUtf8()
+ {
+ shell_exec('mode con cp select=65001');
+ }
+
+ /**
+ * Clear console screen
+ */
+ public function clear()
+ {
+ // Attempt to clear the screen using PowerShell command
+ exec("powershell -NonInteractive -NoProfile -NoLogo -OutputFormat Text -Command Clear-Host", $output, $return);
+
+ if ($return) {
+ // Could not run powershell... fall back to filling the buffer with newlines
+ echo str_repeat("\r\n", $this->getHeight());
+ }
+ }
+
+ /**
+ * Clear line at cursor position
+ */
+ public function clearLine()
+ {
+ echo "\r" . str_repeat(' ', $this->getWidth()) . "\r";
+ }
+
+ /**
+ * Read a single character from the console input
+ *
+ * @param string|null $mask A list of allowed chars
+ * @throws Exception\RuntimeException
+ * @return string
+ */
+ public function readChar($mask = null)
+ {
+ // Decide if we can use `choice` tool
+ $useChoice = $mask !== null && preg_match('/^[a-zA-Z0-9]+$/D', $mask);
+
+ if ($useChoice) {
+ // Use Windows 95+ "choice" command, which allows for reading a
+ // single character matching a mask, but is limited to lower ASCII
+ // range.
+ do {
+ exec('choice /n /cs /c:' . $mask, $output, $return);
+ if ($return == 255 || $return < 1 || $return > strlen($mask)) {
+ throw new Exception\RuntimeException('"choice" command failed to run. Are you using Windows XP or newer?');
+ }
+
+ // Fetch the char from mask
+ $char = substr($mask, $return - 1, 1);
+ } while ("" === $char || ($mask !== null && false === strstr($mask, $char)));
+
+ return $char;
+ }
+
+ // Try to use PowerShell, giving it console access. Because PowersShell
+ // interpreter can take a short while to load, we are emptying the
+ // whole keyboard buffer and picking the last key that has been pressed
+ // before or after PowerShell command has started. The ASCII code for
+ // that key is then converted to a character.
+ if ($mask === null) {
+ exec(
+ 'powershell -NonInteractive -NoProfile -NoLogo -OutputFormat Text -Command "'
+ . 'while ($Host.UI.RawUI.KeyAvailable) {$key = $Host.UI.RawUI.ReadKey(\'NoEcho,IncludeKeyDown\');}'
+ . 'write $key.VirtualKeyCode;'
+ . '"',
+ $result,
+ $return
+ );
+
+ // Retrieve char from the result.
+ $char = !empty($result) ? implode('', $result) : null;
+
+ if (!empty($char) && !$return) {
+ // We have obtained an ASCII code, convert back to a char ...
+ $char = chr($char);
+
+ // ... and return it...
+ return $char;
+ }
+ } else {
+ // Windows and DOS will return carriage-return char (ASCII 13) when
+ // the user presses [ENTER] key, but Console Adapter user might
+ // have provided a \n Newline (ASCII 10) in the mask, to allow [ENTER].
+ // We are going to replace all CR with NL to conform.
+ $mask = strtr($mask, "\n", "\r");
+
+ // Prepare a list of ASCII codes from mask chars
+ $asciiMask = array_map(function ($char) {
+ return ord($char);
+ }, str_split($mask));
+ $asciiMask = array_unique($asciiMask);
+
+ // Char mask filtering is now handled by the PowerShell itself,
+ // because it's a much faster method than invoking PS interpreter
+ // after each mismatch. The command should return ASCII code of a
+ // matching key.
+ $result = $return = null;
+
+ exec(
+ 'powershell -NonInteractive -NoProfile -NoLogo -OutputFormat Text -Command "'
+ . '[int[]] $mask = ' . join(',', $asciiMask) . ';'
+ . 'do {'
+ . '$key = $Host.UI.RawUI.ReadKey(\'NoEcho,IncludeKeyDown\').VirtualKeyCode;'
+ . '} while( !($mask -contains $key) );'
+ . 'write $key;'
+ . '"',
+ $result,
+ $return
+ );
+
+ $char = !empty($result) ? trim(implode('', $result)) : null;
+
+ if (!$return && $char && ($mask === null || in_array($char, $asciiMask))) {
+ // Normalize CR to LF
+ if ($char == 13) {
+ $char = 10;
+ }
+
+ // Convert to a char
+ $char = chr($char);
+
+ // ... and return it...
+ return $char;
+ }
+ }
+
+ // Fall back to standard input, which on Windows does not allow reading
+ // a single character. This is a limitation of Windows streams
+ // implementation (not PHP) and this behavior cannot be changed with a
+ // command like "stty", known to POSIX systems.
+ $stream = fopen('php://stdin', 'rb');
+ do {
+ $char = fgetc($stream);
+ $char = substr(trim($char), 0, 1);
+ } while (!$char || ($mask !== null && !stristr($mask, $char)));
+ fclose($stream);
+
+ return $char;
+ }
+
+ /**
+ * Read a single line from the console input.
+ *
+ * @param int $maxLength Maximum response length
+ * @return string
+ */
+ public function readLine($maxLength = 2048)
+ {
+ $f = fopen('php://stdin','r');
+ $line = rtrim(fread($f, $maxLength),"\r\n");
+ fclose($f);
+
+ return $line;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Charset/AsciiExtended.php zendframework-2.2.6/library/Zend/Console/Charset/AsciiExtended.php
--- zendframework-1.10.4/library/Zend/Console/Charset/AsciiExtended.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Charset/AsciiExtended.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,51 @@
+ 0 ? (int) $val : 0;
+ }, $hex);
+
+ $dhex = array_map('hexdec', $hex);
+
+ if (array_fill(0, 3, $dhex[0]) === $dhex && (int) substr($dhex[0], -1) === 8) {
+ $x11 = 232 + (int) floor($dhex[0]/10);
+ return new static($x11);
+ }
+
+ $x11 = $ahex[0] * 36 + $ahex[1] * 6 + $ahex[2] + 16;
+
+ return new static($x11);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/ColorInterface.php zendframework-2.2.6/library/Zend/Console/ColorInterface.php
--- zendframework-1.10.4/library/Zend/Console/ColorInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/ColorInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,34 @@
+=5.3.3",
+ "zendframework/zend-stdlib": "self.version"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev",
+ "dev-develop": "2.3-dev"
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Console.php zendframework-2.2.6/library/Zend/Console/Console.php
--- zendframework-1.10.4/library/Zend/Console/Console.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Console.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,204 @@
+setCharset(new $className());
+ }
+
+ return static::$instance;
+ }
+
+ /**
+ * Reset the console instance
+ */
+ public static function resetInstance()
+ {
+ static::$instance = null;
+ }
+
+ /**
+ * Check if currently running under MS Windows
+ *
+ * @see http://stackoverflow.com/questions/738823/possible-values-for-php-os
+ * @return bool
+ */
+ public static function isWindows()
+ {
+ return
+ (defined('PHP_OS') && (substr_compare(PHP_OS, 'win', 0, 3, true) === 0)) ||
+ (getenv('OS') != false && substr_compare(getenv('OS'), 'windows', 0, 7, true))
+ ;
+ }
+
+ /**
+ * Check if running under MS Windows Ansicon
+ *
+ * @return bool
+ */
+ public static function isAnsicon()
+ {
+ return getenv('ANSICON') !== false;
+ }
+
+ /**
+ * Check if running in a console environment (CLI)
+ *
+ * By default, returns value of PHP_SAPI global constant. If $isConsole is
+ * set, and a boolean value, that value will be returned.
+ *
+ * @return bool
+ */
+ public static function isConsole()
+ {
+ if (null === static::$isConsole) {
+ static::$isConsole = (PHP_SAPI == 'cli');
+ }
+ return static::$isConsole;
+ }
+
+ /**
+ * Override the "is console environment" flag
+ *
+ * @param null|bool $flag
+ */
+ public static function overrideIsConsole($flag)
+ {
+ if (null != $flag) {
+ $flag = (bool) $flag;
+ }
+ static::$isConsole = $flag;
+ }
+
+ /**
+ * Try to detect best matching adapter
+ * @return string|null
+ */
+ public static function detectBestAdapter()
+ {
+ // Check if we are in a console environment
+ if (!static::isConsole()) {
+ return null;
+ }
+
+ // Check if we're on windows
+ if (static::isWindows()) {
+ if (static::isAnsicon()) {
+ $className = __NAMESPACE__ . '\Adapter\WindowsAnsicon';
+ } else {
+ $className = __NAMESPACE__ . '\Adapter\Windows';
+ }
+
+ return $className;
+ }
+
+ // Default is a Posix console
+ $className = __NAMESPACE__ . '\Adapter\Posix';
+ return $className;
+ }
+
+ /**
+ * Pass-thru static call to current AdapterInterface instance.
+ *
+ * @param $funcName
+ * @param $arguments
+ * @return mixed
+ */
+ public static function __callStatic($funcName, $arguments)
+ {
+ $instance = static::getInstance();
+ return call_user_func_array(array($instance, $funcName), $arguments);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Exception/BadMethodCallException.php zendframework-2.2.6/library/Zend/Console/Exception/BadMethodCallException.php
--- zendframework-1.10.4/library/Zend/Console/Exception/BadMethodCallException.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Exception/BadMethodCallException.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,15 @@
+usage = $usage;
+ parent::__construct($message);
+ }
+
+ /**
+ * Returns the usage
+ *
+ * @return string
+ */
+ public function getUsageMessage()
+ {
+ return $this->usage;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Getopt/Exception.php zendframework-2.2.6/library/Zend/Console/Getopt/Exception.php
--- zendframework-1.10.4/library/Zend/Console/Getopt/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Getopt/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,66 +0,0 @@
-usage = $usage;
- parent::__construct($message);
- }
-
- /**
- * Returns the usage
- *
- * @return string
- */
- public function getUsageMessage()
- {
- return $this->usage;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Console/Getopt.php zendframework-2.2.6/library/Zend/Console/Getopt.php
--- zendframework-1.10.4/library/Zend/Console/Getopt.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Getopt.php 2014-03-07 00:22:10.000000000 +0000
@@ -1,27 +1,16 @@
self::MODE_ZEND,
- self::CONFIG_DASHDASH => true,
- self::CONFIG_IGNORECASE => false,
- self::CONFIG_PARSEALL => true,
+ * parseAll is enabled,
+ * cumulative parameters are disabled,
+ * this means that subsequent options overwrite the parameter value,
+ * cumulative flags are disable,
+ * freeform flags are disable.
+ */
+ protected $getoptConfig = array(
+ self::CONFIG_RULEMODE => self::MODE_ZEND,
+ self::CONFIG_DASHDASH => true,
+ self::CONFIG_IGNORECASE => false,
+ self::CONFIG_PARSEALL => true,
+ self::CONFIG_CUMULATIVE_PARAMETERS => false,
+ self::CONFIG_CUMULATIVE_FLAGS => false,
+ self::CONFIG_PARAMETER_SEPARATOR => null,
+ self::CONFIG_FREEFORM_FLAGS => false,
+ self::CONFIG_NUMERIC_FLAGS => false
);
/**
- * Stores the command-line arguments for the calling applicaion.
+ * Stores the command-line arguments for the calling application.
*
* @var array
*/
- protected $_argv = array();
+ protected $argv = array();
/**
- * Stores the name of the calling applicaion.
+ * Stores the name of the calling application.
*
* @var string
*/
- protected $_progname = '';
+ protected $progname = '';
/**
* Stores the list of legal options for this application.
*
* @var array
*/
- protected $_rules = array();
+ protected $rules = array();
/**
* Stores alternate spellings of legal options.
*
* @var array
*/
- protected $_ruleMap = array();
+ protected $ruleMap = array();
/**
* Stores options given by the user in the current invocation
@@ -206,21 +175,21 @@
*
* @var array
*/
- protected $_options = array();
+ protected $options = array();
/**
* Stores the command-line arguments other than options.
*
* @var array
*/
- protected $_remainingArgs = array();
+ protected $remainingArgs = array();
/**
* State of the options: parsed or not yet parsed?
*
- * @var boolean
+ * @var bool
*/
- protected $_parsed = false;
+ protected $parsed = false;
/**
* The constructor takes one to three parameters.
@@ -237,31 +206,25 @@
* @param array $rules
* @param array $argv
* @param array $getoptConfig
- * @return void
+ * @throws Exception\InvalidArgumentException
*/
public function __construct($rules, $argv = null, $getoptConfig = array())
{
if (!isset($_SERVER['argv'])) {
- require_once 'Zend/Console/Getopt/Exception.php';
- if (ini_get('register_argc_argv') == false) {
- throw new Zend_Console_Getopt_Exception(
- "argv is not available, because ini option 'register_argc_argv' is set Off"
- );
- } else {
- throw new Zend_Console_Getopt_Exception(
- '$_SERVER["argv"] is not set, but Zend_Console_Getopt cannot work without this information.'
- );
- }
+ $errorDescription = (ini_get('register_argc_argv') == false)
+ ? "argv is not available, because ini option 'register_argc_argv' is set Off"
+ : '$_SERVER["argv"] is not set, but Zend_Console_Getopt cannot work without this information.';
+ throw new Exception\InvalidArgumentException($errorDescription);
}
- $this->_progname = $_SERVER['argv'][0];
+ $this->progname = $_SERVER['argv'][0];
$this->setOptions($getoptConfig);
$this->addRules($rules);
if (!is_array($argv)) {
$argv = array_slice($_SERVER['argv'], 1);
}
if (isset($argv)) {
- $this->addArguments((array)$argv);
+ $this->addArguments((array) $argv);
}
}
@@ -286,14 +249,14 @@
* Test whether a given option has been seen.
*
* @param string $key
- * @return boolean
+ * @return bool
*/
public function __isset($key)
{
$this->parse();
- if (isset($this->_ruleMap[$key])) {
- $key = $this->_ruleMap[$key];
- return isset($this->_options[$key]);
+ if (isset($this->ruleMap[$key])) {
+ $key = $this->ruleMap[$key];
+ return isset($this->options[$key]);
}
return false;
}
@@ -308,9 +271,9 @@
public function __set($key, $value)
{
$this->parse();
- if (isset($this->_ruleMap[$key])) {
- $key = $this->_ruleMap[$key];
- $this->_options[$key] = $value;
+ if (isset($this->ruleMap[$key])) {
+ $key = $this->ruleMap[$key];
+ $this->options[$key] = $value;
}
}
@@ -333,9 +296,9 @@
public function __unset($key)
{
$this->parse();
- if (isset($this->_ruleMap[$key])) {
- $key = $this->_ruleMap[$key];
- unset($this->_options[$key]);
+ if (isset($this->ruleMap[$key])) {
+ $key = $this->ruleMap[$key];
+ unset($this->options[$key]);
}
}
@@ -344,18 +307,16 @@
* These are appended to those defined when the constructor was called.
*
* @param array $argv
- * @throws Zend_Console_Getopt_Exception When not given an array as parameter
- * @return Zend_Console_Getopt Provides a fluent interface
+ * @throws \Zend\Console\Exception\InvalidArgumentException When not given an array as parameter
+ * @return \Zend\Console\Getopt Provides a fluent interface
*/
public function addArguments($argv)
{
- if(!is_array($argv)) {
- require_once 'Zend/Console/Getopt/Exception.php';
- throw new Zend_Console_Getopt_Exception(
- "Parameter #1 to addArguments should be an array");
+ if (!is_array($argv)) {
+ throw new Exception\InvalidArgumentException("Parameter #1 to addArguments should be an array");
}
- $this->_argv = array_merge($this->_argv, $argv);
- $this->_parsed = false;
+ $this->argv = array_merge($this->argv, $argv);
+ $this->parsed = false;
return $this;
}
@@ -364,28 +325,26 @@
* These replace any currently defined.
*
* @param array $argv
- * @throws Zend_Console_Getopt_Exception When not given an array as parameter
- * @return Zend_Console_Getopt Provides a fluent interface
+ * @throws \Zend\Console\Exception\InvalidArgumentException When not given an array as parameter
+ * @return \Zend\Console\Getopt Provides a fluent interface
*/
public function setArguments($argv)
{
- if(!is_array($argv)) {
- require_once 'Zend/Console/Getopt/Exception.php';
- throw new Zend_Console_Getopt_Exception(
- "Parameter #1 to setArguments should be an array");
+ if (!is_array($argv)) {
+ throw new Exception\InvalidArgumentException("Parameter #1 to setArguments should be an array");
}
- $this->_argv = $argv;
- $this->_parsed = false;
+ $this->argv = $argv;
+ $this->parsed = false;
return $this;
}
/**
* Define multiple configuration options from an associative array.
* These are not program options, but properties to configure
- * the behavior of Zend_Console_Getopt.
+ * the behavior of Zend\Console\Getopt.
*
* @param array $getoptConfig
- * @return Zend_Console_Getopt Provides a fluent interface
+ * @return \Zend\Console\Getopt Provides a fluent interface
*/
public function setOptions($getoptConfig)
{
@@ -400,16 +359,16 @@
/**
* Define one configuration option as a key/value pair.
* These are not program options, but properties to configure
- * the behavior of Zend_Console_Getopt.
+ * the behavior of Zend\Console\Getopt.
*
* @param string $configKey
* @param string $configValue
- * @return Zend_Console_Getopt Provides a fluent interface
+ * @return \Zend\Console\Getopt Provides a fluent interface
*/
public function setOption($configKey, $configValue)
{
if ($configKey !== null) {
- $this->_getoptConfig[$configKey] = $configValue;
+ $this->getoptConfig[$configKey] = $configValue;
}
return $this;
}
@@ -419,12 +378,12 @@
* These are appended to the rules defined when the constructor was called.
*
* @param array $rules
- * @return Zend_Console_Getopt Provides a fluent interface
+ * @return \Zend\Console\Getopt Provides a fluent interface
*/
public function addRules($rules)
{
- $ruleMode = $this->_getoptConfig['ruleMode'];
- switch ($this->_getoptConfig['ruleMode']) {
+ $ruleMode = $this->getoptConfig['ruleMode'];
+ switch ($this->getoptConfig['ruleMode']) {
case self::MODE_ZEND:
if (is_array($rules)) {
$this->_addRulesModeZend($rules);
@@ -443,7 +402,7 @@
$method = '_addRulesMode' . ucfirst($ruleMode);
$this->$method($rules);
}
- $this->_parsed = false;
+ $this->parsed = false;
return $this;
}
@@ -456,7 +415,7 @@
{
$this->parse();
$s = array();
- foreach ($this->_options as $flag => $value) {
+ foreach ($this->options as $flag => $value) {
$s[] = $flag . '=' . ($value === true ? 'true' : $value);
}
return implode(' ', $s);
@@ -475,7 +434,7 @@
{
$this->parse();
$s = array();
- foreach ($this->_options as $flag => $value) {
+ foreach ($this->options as $flag => $value) {
$s[] = $flag;
if ($value !== true) {
$s[] = $value;
@@ -493,7 +452,7 @@
{
$this->parse();
$j = array();
- foreach ($this->_options as $flag => $value) {
+ foreach ($this->options as $flag => $value) {
$j['options'][] = array(
'option' => array(
'flag' => $flag,
@@ -502,12 +461,7 @@
);
}
- /**
- * @see Zend_Json
- */
- require_once 'Zend/Json.php';
- $json = Zend_Json::encode($j);
-
+ $json = \Zend\Json\Json::encode($j);
return $json;
}
@@ -519,10 +473,10 @@
public function toXml()
{
$this->parse();
- $doc = new DomDocument('1.0', 'utf-8');
+ $doc = new \DomDocument('1.0', 'utf-8');
$optionsNode = $doc->createElement('options');
$doc->appendChild($optionsNode);
- foreach ($this->_options as $flag => $value) {
+ foreach ($this->options as $flag => $value) {
$optionNode = $doc->createElement('option');
$optionNode->setAttribute('flag', utf8_encode($flag));
if ($value !== true) {
@@ -542,7 +496,7 @@
public function getOptions()
{
$this->parse();
- return array_keys($this->_options);
+ return array_keys($this->options);
}
/**
@@ -558,13 +512,13 @@
public function getOption($flag)
{
$this->parse();
- if ($this->_getoptConfig[self::CONFIG_IGNORECASE]) {
+ if ($this->getoptConfig[self::CONFIG_IGNORECASE]) {
$flag = strtolower($flag);
}
- if (isset($this->_ruleMap[$flag])) {
- $flag = $this->_ruleMap[$flag];
- if (isset($this->_options[$flag])) {
- return $this->_options[$flag];
+ if (isset($this->ruleMap[$flag])) {
+ $flag = $this->ruleMap[$flag];
+ if (isset($this->options[$flag])) {
+ return $this->options[$flag];
}
}
return null;
@@ -578,7 +532,16 @@
public function getRemainingArgs()
{
$this->parse();
- return $this->_remainingArgs;
+ return $this->remainingArgs;
+ }
+
+ public function getArguments()
+ {
+ $result = $this->getRemainingArgs();
+ foreach ($this->getOptions() as $option) {
+ $result[$option] = $this->getOption($option);
+ }
+ return $result;
}
/**
@@ -592,9 +555,13 @@
*/
public function getUsageMessage()
{
- $usage = "Usage: {$this->_progname} [ options ]\n";
+ $usage = "Usage: {$this->progname} [ options ]\n";
$maxLen = 20;
- foreach ($this->_rules as $rule) {
+ $lines = array();
+ foreach ($this->rules as $rule) {
+ if (isset($rule['isFreeformFlag'])) {
+ continue;
+ }
$flags = array();
if (is_array($rule['alias'])) {
foreach ($rule['alias'] as $flag) {
@@ -637,29 +604,26 @@
* mapping option name (short or long) to an alias.
*
* @param array $aliasMap
- * @throws Zend_Console_Getopt_Exception
- * @return Zend_Console_Getopt Provides a fluent interface
+ * @throws \Zend\Console\Exception\ExceptionInterface
+ * @return \Zend\Console\Getopt Provides a fluent interface
*/
public function setAliases($aliasMap)
{
- foreach ($aliasMap as $flag => $alias)
- {
- if ($this->_getoptConfig[self::CONFIG_IGNORECASE]) {
+ foreach ($aliasMap as $flag => $alias) {
+ if ($this->getoptConfig[self::CONFIG_IGNORECASE]) {
$flag = strtolower($flag);
$alias = strtolower($alias);
}
- if (!isset($this->_ruleMap[$flag])) {
+ if (!isset($this->ruleMap[$flag])) {
continue;
}
- $flag = $this->_ruleMap[$flag];
- if (isset($this->_rules[$alias]) || isset($this->_ruleMap[$alias])) {
+ $flag = $this->ruleMap[$flag];
+ if (isset($this->rules[$alias]) || isset($this->ruleMap[$alias])) {
$o = (strlen($alias) == 1 ? '-' : '--') . $alias;
- require_once 'Zend/Console/Getopt/Exception.php';
- throw new Zend_Console_Getopt_Exception(
- "Option \"$o\" is being defined more than once.");
+ throw new Exception\InvalidArgumentException("Option \"$o\" is being defined more than once.");
}
- $this->_rules[$flag]['alias'][] = $alias;
- $this->_ruleMap[$alias] = $flag;
+ $this->rules[$flag]['alias'][] = $alias;
+ $this->ruleMap[$alias] = $flag;
}
return $this;
}
@@ -667,21 +631,20 @@
/**
* Define help messages for options.
*
- * The parameter $help_map is an associative array
+ * The parameter $helpMap is an associative array
* mapping option name (short or long) to the help string.
*
* @param array $helpMap
- * @return Zend_Console_Getopt Provides a fluent interface
+ * @return \Zend\Console\Getopt Provides a fluent interface
*/
public function setHelp($helpMap)
{
- foreach ($helpMap as $flag => $help)
- {
- if (!isset($this->_ruleMap[$flag])) {
+ foreach ($helpMap as $flag => $help) {
+ if (!isset($this->ruleMap[$flag])) {
continue;
}
- $flag = $this->_ruleMap[$flag];
- $this->_rules[$flag]['help'] = $help;
+ $flag = $this->ruleMap[$flag];
+ $this->rules[$flag]['help'] = $help;
}
return $this;
}
@@ -693,40 +656,40 @@
* Also find option parameters, and remaining arguments after
* all options have been parsed.
*
- * @return Zend_Console_Getopt|null Provides a fluent interface
+ * @return \Zend\Console\Getopt|null Provides a fluent interface
*/
public function parse()
{
- if ($this->_parsed === true) {
+ if ($this->parsed === true) {
return;
}
- $argv = $this->_argv;
- $this->_options = array();
- $this->_remainingArgs = array();
+ $argv = $this->argv;
+ $this->options = array();
+ $this->remainingArgs = array();
while (count($argv) > 0) {
if ($argv[0] == '--') {
array_shift($argv);
- if ($this->_getoptConfig[self::CONFIG_DASHDASH]) {
- $this->_remainingArgs = array_merge($this->_remainingArgs, $argv);
+ if ($this->getoptConfig[self::CONFIG_DASHDASH]) {
+ $this->remainingArgs = array_merge($this->remainingArgs, $argv);
break;
}
}
if (substr($argv[0], 0, 2) == '--') {
$this->_parseLongOption($argv);
- } else if (substr($argv[0], 0, 1) == '-' && ('-' != $argv[0] || count($argv) >1)) {
+ } elseif (substr($argv[0], 0, 1) == '-' && ('-' != $argv[0] || count($argv) >1)) {
$this->_parseShortOptionCluster($argv);
- } else if($this->_getoptConfig[self::CONFIG_PARSEALL]) {
- $this->_remainingArgs[] = array_shift($argv);
+ } elseif ($this->getoptConfig[self::CONFIG_PARSEALL]) {
+ $this->remainingArgs[] = array_shift($argv);
} else {
/*
- * We should put all other arguments in _remainingArgs and stop parsing
+ * We should put all other arguments in remainingArgs and stop parsing
* since CONFIG_PARSEALL is false.
*/
- $this->_remainingArgs = array_merge($this->_remainingArgs, $argv);
+ $this->remainingArgs = array_merge($this->remainingArgs, $argv);
break;
}
}
- $this->_parsed = true;
+ $this->parsed = true;
return $this;
}
@@ -771,31 +734,50 @@
*
* @param string $flag
* @param mixed $argv
- * @throws Zend_Console_Getopt_Exception
+ * @throws \Zend\Console\Exception\ExceptionInterface
* @return void
*/
protected function _parseSingleOption($flag, &$argv)
{
- if ($this->_getoptConfig[self::CONFIG_IGNORECASE]) {
+ if ($this->getoptConfig[self::CONFIG_IGNORECASE]) {
$flag = strtolower($flag);
}
- if (!isset($this->_ruleMap[$flag])) {
- require_once 'Zend/Console/Getopt/Exception.php';
- throw new Zend_Console_Getopt_Exception(
- "Option \"$flag\" is not recognized.",
- $this->getUsageMessage());
+
+ // Check if this option is numeric one
+ if (preg_match('/^\d+$/', $flag)) {
+ return $this->_setNumericOptionValue($flag);
+ }
+
+ if (!isset($this->ruleMap[$flag])) {
+ // Don't throw Exception for flag-like param in case when freeform flags are allowed
+ if (!$this->getoptConfig[self::CONFIG_FREEFORM_FLAGS]) {
+ throw new Exception\RuntimeException(
+ "Option \"$flag\" is not recognized.",
+ $this->getUsageMessage()
+ );
+ }
+
+ // Magic methods in future will use this mark as real flag value
+ $this->ruleMap[$flag] = $flag;
+ $realFlag = $flag;
+ $this->rules[$realFlag] = array(
+ 'param' => 'optional',
+ 'isFreeformFlag' => true
+ );
+ } else {
+ $realFlag = $this->ruleMap[$flag];
}
- $realFlag = $this->_ruleMap[$flag];
- switch ($this->_rules[$realFlag]['param']) {
+
+ switch ($this->rules[$realFlag]['param']) {
case 'required':
if (count($argv) > 0) {
$param = array_shift($argv);
$this->_checkParameterType($realFlag, $param);
} else {
- require_once 'Zend/Console/Getopt/Exception.php';
- throw new Zend_Console_Getopt_Exception(
+ throw new Exception\RuntimeException(
"Option \"$flag\" requires a parameter.",
- $this->getUsageMessage());
+ $this->getUsageMessage()
+ );
}
break;
case 'optional':
@@ -809,7 +791,81 @@
default:
$param = true;
}
- $this->_options[$realFlag] = $param;
+
+ $this->_setSingleOptionValue($realFlag, $param);
+ }
+
+
+ /**
+ * Set given value as value of numeric option
+ *
+ * Throw runtime exception if this action is deny by configuration
+ * or no one numeric option handlers is defined
+ *
+ * @param int $value
+ * @throws Exception\RuntimeException
+ * @return void
+ */
+ protected function _setNumericOptionValue($value)
+ {
+ if (!$this->getoptConfig[self::CONFIG_NUMERIC_FLAGS]) {
+ throw new Exception\RuntimeException("Using of numeric flags are deny by configuration");
+ }
+
+ if (empty($this->getoptConfig['numericFlagsOption'])) {
+ throw new Exception\RuntimeException("Any option for handling numeric flags are specified");
+ }
+
+ return $this->_setSingleOptionValue($this->getoptConfig['numericFlagsOption'], $value);
+ }
+
+ /**
+ * Add relative to options' flag value
+ *
+ * If options list already has current flag as key
+ * and parser should follow cumulative params by configuration,
+ * we should to add new param to array, not to overwrite
+ *
+ * @param string $flag
+ * @param string $value
+ * @return null
+ */
+ protected function _setSingleOptionValue($flag, $value)
+ {
+ if (true === $value && $this->getoptConfig[self::CONFIG_CUMULATIVE_FLAGS]) {
+ // For boolean values we have to create new flag, or increase number of flags' usage count
+ return $this->_setBooleanFlagValue($flag);
+ }
+
+ // Split multiple values, if necessary
+ // Filter empty values from splited array
+ $separator = $this->getoptConfig[self::CONFIG_PARAMETER_SEPARATOR];
+ if (is_string($value) && !empty($separator) && is_string($separator) && substr_count($value, $separator)) {
+ $value = array_filter(explode($separator, $value));
+ }
+
+ if (!array_key_exists($flag, $this->options)) {
+ $this->options[$flag] = $value;
+ } elseif ($this->getoptConfig[self::CONFIG_CUMULATIVE_PARAMETERS]) {
+ $this->options[$flag] = (array) $this->options[$flag];
+ array_push($this->options[$flag], $value);
+ } else {
+ $this->options[$flag] = $value;
+ }
+ }
+
+ /**
+ * Set TRUE value to given flag, if this option does not exist yet
+ * In other case increase value to show count of flags' usage
+ *
+ * @param string $flag
+ * @return null
+ */
+ protected function _setBooleanFlagValue($flag)
+ {
+ $this->options[$flag] = array_key_exists($flag, $this->options)
+ ? (int) $this->options[$flag] + 1
+ : true;
}
/**
@@ -819,28 +875,26 @@
*
* @param string $flag
* @param string $param
- * @throws Zend_Console_Getopt_Exception
+ * @throws \Zend\Console\Exception\ExceptionInterface
* @return bool
*/
protected function _checkParameterType($flag, $param)
{
$type = 'string';
- if (isset($this->_rules[$flag]['paramType'])) {
- $type = $this->_rules[$flag]['paramType'];
+ if (isset($this->rules[$flag]['paramType'])) {
+ $type = $this->rules[$flag]['paramType'];
}
switch ($type) {
case 'word':
if (preg_match('/\W/', $param)) {
- require_once 'Zend/Console/Getopt/Exception.php';
- throw new Zend_Console_Getopt_Exception(
+ throw new Exception\RuntimeException(
"Option \"$flag\" requires a single-word parameter, but was given \"$param\".",
$this->getUsageMessage());
}
break;
case 'integer':
if (preg_match('/\D/', $param)) {
- require_once 'Zend/Console/Getopt/Exception.php';
- throw new Zend_Console_Getopt_Exception(
+ throw new Exception\RuntimeException(
"Option \"$flag\" requires an integer parameter, but was given \"$param\".",
$this->getUsageMessage());
}
@@ -871,7 +925,7 @@
foreach ($ruleArray[1] as $rule) {
$r = array();
$flag = substr($rule, 0, 1);
- if ($this->_getoptConfig[self::CONFIG_IGNORECASE]) {
+ if ($this->getoptConfig[self::CONFIG_IGNORECASE]) {
$flag = strtolower($flag);
}
$r['alias'][] = $flag;
@@ -881,8 +935,8 @@
} else {
$r['param'] = 'none';
}
- $this->_rules[$flag] = $r;
- $this->_ruleMap[$flag] = $flag;
+ $this->rules[$flag] = $r;
+ $this->ruleMap[$flag] = $flag;
}
}
@@ -890,13 +944,12 @@
* Define legal options using the Zend-style format.
*
* @param array $rules
- * @throws Zend_Console_Getopt_Exception
+ * @throws \Zend\Console\Exception\ExceptionInterface
* @return void
*/
protected function _addRulesModeZend($rules)
{
- foreach ($rules as $ruleCode => $helpMessage)
- {
+ foreach ($rules as $ruleCode => $helpMessage) {
// this may have to translate the long parm type if there
// are any complaints that =string will not work (even though that use
// case is not documented)
@@ -908,7 +961,7 @@
$flagList = $ruleCode;
$delimiter = $paramType = null;
}
- if ($this->_getoptConfig[self::CONFIG_IGNORECASE]) {
+ if ($this->getoptConfig[self::CONFIG_IGNORECASE]) {
$flagList = strtolower($flagList);
}
$flags = explode('|', $flagList);
@@ -916,25 +969,21 @@
$mainFlag = $flags[0];
foreach ($flags as $flag) {
if (empty($flag)) {
- require_once 'Zend/Console/Getopt/Exception.php';
- throw new Zend_Console_Getopt_Exception(
- "Blank flag not allowed in rule \"$ruleCode\".");
+ throw new Exception\InvalidArgumentException("Blank flag not allowed in rule \"$ruleCode\".");
}
if (strlen($flag) == 1) {
- if (isset($this->_ruleMap[$flag])) {
- require_once 'Zend/Console/Getopt/Exception.php';
- throw new Zend_Console_Getopt_Exception(
+ if (isset($this->ruleMap[$flag])) {
+ throw new Exception\InvalidArgumentException(
"Option \"-$flag\" is being defined more than once.");
}
- $this->_ruleMap[$flag] = $mainFlag;
+ $this->ruleMap[$flag] = $mainFlag;
$rule['alias'][] = $flag;
} else {
- if (isset($this->_rules[$flag]) || isset($this->_ruleMap[$flag])) {
- require_once 'Zend/Console/Getopt/Exception.php';
- throw new Zend_Console_Getopt_Exception(
+ if (isset($this->rules[$flag]) || isset($this->ruleMap[$flag])) {
+ throw new Exception\InvalidArgumentException(
"Option \"--$flag\" is being defined more than once.");
}
- $this->_ruleMap[$flag] = $mainFlag;
+ $this->ruleMap[$flag] = $mainFlag;
$rule['alias'][] = $flag;
}
}
@@ -954,6 +1003,10 @@
case self::TYPE_INTEGER:
$rule['paramType'] = 'integer';
break;
+ case self::TYPE_NUMERIC_FLAG:
+ $rule['paramType'] = 'numericFlag';
+ $this->getoptConfig['numericFlagsOption'] = $mainFlag;
+ break;
case self::TYPE_STRING:
default:
$rule['paramType'] = 'string';
@@ -962,8 +1015,7 @@
$rule['param'] = 'none';
}
$rule['help'] = $helpMessage;
- $this->_rules[$mainFlag] = $rule;
+ $this->rules[$mainFlag] = $rule;
}
}
-
}
diff -Nru zendframework-1.10.4/library/Zend/Console/Prompt/AbstractPrompt.php zendframework-2.2.6/library/Zend/Console/Prompt/AbstractPrompt.php
--- zendframework-1.10.4/library/Zend/Console/Prompt/AbstractPrompt.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Prompt/AbstractPrompt.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,85 @@
+lastResponse;
+ }
+
+ /**
+ * Return console adapter to use when showing prompt.
+ *
+ * @return ConsoleAdapter
+ */
+ public function getConsole()
+ {
+ if (!$this->console) {
+ $this->console = Console::getInstance();
+ }
+
+ return $this->console;
+ }
+
+ /**
+ * Set console adapter to use when showing prompt.
+ *
+ * @param ConsoleAdapter $adapter
+ */
+ public function setConsole(ConsoleAdapter $adapter)
+ {
+ $this->console = $adapter;
+ }
+
+ /**
+ * Create an instance of this prompt, show it and return response.
+ *
+ * This is a convenience method for creating statically creating prompts, i.e.:
+ *
+ * $name = Zend\Console\Prompt\Line::prompt("Enter your name: ");
+ *
+ * @return mixed
+ * @throws Exception\BadMethodCallException
+ */
+ public static function prompt()
+ {
+ if (get_called_class() === __CLASS__) {
+ throw new Exception\BadMethodCallException(
+ 'Cannot call prompt() on AbstractPrompt class. Use one of the Zend\Console\Prompt\ subclasses.'
+ );
+ }
+
+ $refl = new ReflectionClass(get_called_class());
+ $instance = $refl->newInstanceArgs(func_get_args());
+ return $instance->show();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Prompt/Char.php zendframework-2.2.6/library/Zend/Console/Prompt/Char.php
--- zendframework-1.10.4/library/Zend/Console/Prompt/Char.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Prompt/Char.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,187 @@
+setPromptText($promptText);
+ $this->setAllowEmpty($allowEmpty);
+ $this->setIgnoreCase($ignoreCase);
+
+ if (null != $allowedChars) {
+ if ($this->ignoreCase) {
+ $this->setAllowedChars(strtolower($allowedChars));
+ } else {
+ $this->setAllowedChars($allowedChars);
+ }
+ }
+
+ $this->setEcho($echo);
+ }
+
+ /**
+ * Show the prompt to user and return a single char.
+ *
+ * @return string
+ */
+ public function show()
+ {
+ $this->getConsole()->write($this->promptText);
+ $mask = $this->getAllowedChars();
+
+ /**
+ * Normalize the mask if case is irrelevant
+ */
+ if ($this->ignoreCase) {
+ $mask = strtolower($mask); // lowercase all
+ $mask .= strtoupper($mask); // uppercase and append
+ $mask = str_split($mask); // convert to array
+ $mask = array_unique($mask); // remove duplicates
+ $mask = implode("", $mask); // convert back to string
+ }
+
+ /**
+ * Read char from console
+ */
+ $char = $this->getConsole()->readChar($mask);
+
+ if ($this->echo) {
+ echo trim($char)."\n";
+ } else {
+ if ($this->promptText) {
+ echo "\n"; // skip to next line but only if we had any prompt text
+ }
+ }
+
+ return $this->lastResponse = $char;
+ }
+
+ /**
+ * @param bool $allowEmpty
+ */
+ public function setAllowEmpty($allowEmpty)
+ {
+ $this->allowEmpty = (bool) $allowEmpty;
+ }
+
+ /**
+ * @return bool
+ */
+ public function getAllowEmpty()
+ {
+ return $this->allowEmpty;
+ }
+
+ /**
+ * @param string $promptText
+ */
+ public function setPromptText($promptText)
+ {
+ $this->promptText = $promptText;
+ }
+
+ /**
+ * @return string
+ */
+ public function getPromptText()
+ {
+ return $this->promptText;
+ }
+
+ /**
+ * @param string $allowedChars
+ */
+ public function setAllowedChars($allowedChars)
+ {
+ $this->allowedChars = $allowedChars;
+ }
+
+ /**
+ * @return string
+ */
+ public function getAllowedChars()
+ {
+ return $this->allowedChars;
+ }
+
+ /**
+ * @param bool $ignoreCase
+ */
+ public function setIgnoreCase($ignoreCase)
+ {
+ $this->ignoreCase = (bool) $ignoreCase;
+ }
+
+ /**
+ * @return bool
+ */
+ public function getIgnoreCase()
+ {
+ return $this->ignoreCase;
+ }
+
+ /**
+ * @param bool $echo
+ */
+ public function setEcho($echo)
+ {
+ $this->echo = (bool) $echo;
+ }
+
+ /**
+ * @return bool
+ */
+ public function getEcho()
+ {
+ return $this->echo;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Prompt/Confirm.php zendframework-2.2.6/library/Zend/Console/Prompt/Confirm.php
--- zendframework-1.10.4/library/Zend/Console/Prompt/Confirm.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Prompt/Confirm.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,114 @@
+setPromptText($promptText);
+ }
+
+ if ($yesChar !== null) {
+ $this->setYesChar($yesChar);
+ }
+
+ if ($noChar !== null) {
+ $this->setNoChar($noChar);
+ }
+ }
+
+ /**
+ * Show the confirmation message and return result.
+ *
+ * @return bool
+ */
+ public function show()
+ {
+ $char = parent::show();
+ if ($this->ignoreCase) {
+ $response = strtolower($char) === strtolower($this->yesChar);
+ } else {
+ $response = $char === $this->yesChar;
+ }
+ return $this->lastResponse = $response;
+ }
+
+
+ /**
+ * @param string $noChar
+ */
+ public function setNoChar($noChar)
+ {
+ $this->noChar = $noChar;
+ $this->setAllowedChars($this->yesChar . $this->noChar);
+ }
+
+ /**
+ * @return string
+ */
+ public function getNoChar()
+ {
+ return $this->noChar;
+ }
+
+ /**
+ * @param string $yesChar
+ */
+ public function setYesChar($yesChar)
+ {
+ $this->yesChar = $yesChar;
+ $this->setAllowedChars($this->yesChar . $this->noChar);
+ }
+
+ /**
+ * @return string
+ */
+ public function getYesChar()
+ {
+ return $this->yesChar;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Prompt/Line.php zendframework-2.2.6/library/Zend/Console/Prompt/Line.php
--- zendframework-1.10.4/library/Zend/Console/Prompt/Line.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Prompt/Line.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,113 @@
+setPromptText($promptText);
+ }
+
+ if ($allowEmpty !== null) {
+ $this->setAllowEmpty($allowEmpty);
+ }
+
+ if ($maxLength !== null) {
+ $this->setMaxLength($maxLength);
+ }
+ }
+
+ /**
+ * Show the prompt to user and return the answer.
+ *
+ * @return mixed
+ */
+ public function show()
+ {
+ do {
+ $this->getConsole()->write($this->promptText);
+ $line = $this->getConsole()->readLine($this->maxLength);
+ } while (!$this->allowEmpty && !$line);
+
+ return $this->lastResponse = $line;
+ }
+
+ /**
+ * @param bool $allowEmpty
+ */
+ public function setAllowEmpty($allowEmpty)
+ {
+ $this->allowEmpty = $allowEmpty;
+ }
+
+ /**
+ * @return bool
+ */
+ public function getAllowEmpty()
+ {
+ return $this->allowEmpty;
+ }
+
+ /**
+ * @param int $maxLength
+ */
+ public function setMaxLength($maxLength)
+ {
+ $this->maxLength = $maxLength;
+ }
+
+ /**
+ * @return int
+ */
+ public function getMaxLength()
+ {
+ return $this->maxLength;
+ }
+
+ /**
+ * @param string $promptText
+ */
+ public function setPromptText($promptText)
+ {
+ $this->promptText = $promptText;
+ }
+
+ /**
+ * @return string
+ */
+ public function getPromptText()
+ {
+ return $this->promptText;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Prompt/Number.php zendframework-2.2.6/library/Zend/Console/Prompt/Number.php
--- zendframework-1.10.4/library/Zend/Console/Prompt/Number.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Prompt/Number.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,208 @@
+setPromptText($promptText);
+ }
+
+ if ($allowEmpty !== null) {
+ $this->setAllowEmpty($allowEmpty);
+ }
+
+ if ($min !== null) {
+ $this->setMin($min);
+ }
+
+ if ($max !== null) {
+ $this->setMax($max);
+ }
+
+ if ($allowFloat !== null) {
+ $this->setAllowFloat($allowFloat);
+ }
+ }
+
+ /**
+ * Show the prompt to user and return the answer.
+ *
+ * @return mixed
+ */
+ public function show()
+ {
+ /**
+ * Ask for a number and validate it.
+ */
+ do {
+ $valid = true;
+ $number = parent::show();
+ if ($number === "" && !$this->allowEmpty) {
+ $valid = false;
+ } elseif ($number === "") {
+ $number = null;
+ } elseif (!is_numeric($number)) {
+ $this->getConsole()->writeLine("$number is not a number\n");
+ $valid = false;
+ } elseif (!$this->allowFloat && (round($number) != $number)) {
+ $this->getConsole()->writeLine("Please enter a non-floating number, i.e. " . round($number) . "\n");
+ $valid = false;
+ } elseif ($this->max !== null && $number > $this->max) {
+ $this->getConsole()->writeLine("Please enter a number not greater than " . $this->max . "\n");
+ $valid = false;
+ } elseif ($this->min !== null && $number < $this->min) {
+ $this->getConsole()->writeLine("Please enter a number not smaller than " . $this->min . "\n");
+ $valid = false;
+ }
+ } while (!$valid);
+
+ /**
+ * Cast proper type
+ */
+ if ($number !== null) {
+ $number = $this->allowFloat ? (double) $number : (int) $number;
+ }
+
+ return $this->lastResponse = $number;
+ }
+
+ /**
+ * @param bool $allowEmpty
+ */
+ public function setAllowEmpty($allowEmpty)
+ {
+ $this->allowEmpty = $allowEmpty;
+ }
+
+ /**
+ * @return bool
+ */
+ public function getAllowEmpty()
+ {
+ return $this->allowEmpty;
+ }
+
+ /**
+ * @param int $maxLength
+ */
+ public function setMaxLength($maxLength)
+ {
+ $this->maxLength = $maxLength;
+ }
+
+ /**
+ * @return int
+ */
+ public function getMaxLength()
+ {
+ return $this->maxLength;
+ }
+
+ /**
+ * @param string $promptText
+ */
+ public function setPromptText($promptText)
+ {
+ $this->promptText = $promptText;
+ }
+
+ /**
+ * @return string
+ */
+ public function getPromptText()
+ {
+ return $this->promptText;
+ }
+
+ /**
+ * @param int $max
+ */
+ public function setMax($max)
+ {
+ $this->max = $max;
+ }
+
+ /**
+ * @return int
+ */
+ public function getMax()
+ {
+ return $this->max;
+ }
+
+ /**
+ * @param int $min
+ */
+ public function setMin($min)
+ {
+ $this->min = $min;
+ }
+
+ /**
+ * @return int
+ */
+ public function getMin()
+ {
+ return $this->min;
+ }
+
+ /**
+ * @param bool $allowFloat
+ */
+ public function setAllowFloat($allowFloat)
+ {
+ $this->allowFloat = $allowFloat;
+ }
+
+ /**
+ * @return bool
+ */
+ public function getAllowFloat()
+ {
+ return $this->allowFloat;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Prompt/PromptInterface.php zendframework-2.2.6/library/Zend/Console/Prompt/PromptInterface.php
--- zendframework-1.10.4/library/Zend/Console/Prompt/PromptInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Prompt/PromptInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,43 @@
+setPromptText($promptText);
+ }
+
+ if (!count($options)) {
+ throw new Exception\BadMethodCallException(
+ 'Cannot construct a "select" prompt without any options'
+ );
+ }
+
+ $this->setOptions($options);
+
+ if ($allowEmpty !== null) {
+ $this->setAllowEmpty($allowEmpty);
+ }
+
+ if ($echo !== null) {
+ $this->setEcho($echo);
+ }
+
+ }
+
+ /**
+ * Show a list of options and prompt the user to select one of them.
+ *
+ * @return string Selected option
+ */
+ public function show()
+ {
+ // Show prompt text and available options
+ $console = $this->getConsole();
+ $console->writeLine($this->promptText);
+ foreach ($this->options as $k => $v) {
+ $console->writeLine(' ' . $k . ') ' . $v);
+ }
+
+ // Prepare mask
+ $mask = implode("", array_keys($this->options));
+ if ($this->allowEmpty) {
+ $mask .= "\r\n";
+ }
+
+ // Prepare other params for parent class
+ $this->setAllowedChars($mask);
+ $oldPrompt = $this->promptText;
+ $oldEcho = $this->echo;
+ $this->echo = false;
+ $this->promptText = null;
+
+ // Retrieve a single character
+ $response = parent::show();
+
+ // Restore old params
+ $this->promptText = $oldPrompt;
+ $this->echo = $oldEcho;
+
+ // Display selected option if echo is enabled
+ if ($this->echo) {
+ if (isset($this->options[$response])) {
+ $console->writeLine($this->options[$response]);
+ } else {
+ $console->writeLine();
+ }
+ }
+
+ $this->lastResponse = $response;
+ return $response;
+ }
+
+ /**
+ * Set allowed options
+ *
+ * @param array|\Traversable $options
+ * @throws Exception\BadMethodCallException
+ */
+ public function setOptions($options)
+ {
+ if (!is_array($options) && !$options instanceof \Traversable) {
+ throw new Exception\BadMethodCallException(
+ 'Please specify an array or Traversable object as options'
+ );
+ }
+
+ if (!is_array($options)) {
+ $this->options = array();
+ foreach ($options as $k => $v) {
+ $this->options[$k] = $v;
+ }
+ } else {
+ $this->options = $options;
+ }
+ }
+
+ /**
+ * @return array
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/README.md zendframework-2.2.6/library/Zend/Console/README.md
--- zendframework-1.10.4/library/Zend/Console/README.md 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/README.md 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,15 @@
+Console Component from ZF2
+==========================
+
+This is the Console component for ZF2.
+
+- File issues at https://github.com/zendframework/zf2/issues
+- Create pull requests against https://github.com/zendframework/zf2
+- Documentation is at http://framework.zend.com/docs
+
+LICENSE
+-------
+
+The files in this archive are released under the [Zend Framework
+license](http://framework.zend.com/license), which is a 3-clause BSD license.
+
diff -Nru zendframework-1.10.4/library/Zend/Console/Request.php zendframework-2.2.6/library/Zend/Console/Request.php
--- zendframework-1.10.4/library/Zend/Console/Request.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Request.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,197 @@
+ 0) {
+ $this->setScriptName(array_shift($args));
+ }
+
+ /**
+ * Store runtime params
+ */
+ $this->params()->fromArray($args);
+ $this->setContent($args);
+
+ /**
+ * Store environment data
+ */
+ $this->env()->fromArray($env);
+ }
+
+ /**
+ * Exchange parameters object
+ *
+ * @param \Zend\Stdlib\Parameters $params
+ * @return Request
+ */
+ public function setParams(Parameters $params)
+ {
+ $this->params = $params;
+ $this->setContent($params);
+ return $this;
+ }
+
+ /**
+ * Return the container responsible for parameters
+ *
+ * @return \Zend\Stdlib\Parameters
+ */
+ public function getParams()
+ {
+ if ($this->params === null) {
+ $this->params = new Parameters();
+ }
+
+ return $this->params;
+ }
+
+ /**
+ * Return a single parameter.
+ * Shortcut for $request->params()->get()
+ *
+ * @param string $name Parameter name
+ * @param string $default (optional) default value in case the parameter does not exist
+ * @return mixed
+ */
+ public function getParam($name, $default = null)
+ {
+ return $this->params()->get($name, $default);
+ }
+
+ /**
+ * Return the container responsible for parameters
+ *
+ * @return \Zend\Stdlib\Parameters
+ */
+ public function params()
+ {
+ return $this->getParams();
+ }
+
+ /**
+ * Provide an alternate Parameter Container implementation for env parameters in this object, (this is NOT the
+ * primary API for value setting, for that see env())
+ *
+ * @param \Zend\Stdlib\Parameters $env
+ * @return \Zend\Console\Request
+ */
+ public function setEnv(Parameters $env)
+ {
+ $this->envParams = $env;
+ return $this;
+ }
+
+ /**
+ * Return a single parameter container responsible for env parameters
+ *
+ * @param string $name Parameter name
+ * @param string $default (optional) default value in case the parameter does not exist
+ * @return \Zend\Stdlib\Parameters
+ */
+ public function getEnv($name, $default = null)
+ {
+ return $this->env()->get($name, $default);
+ }
+
+ /**
+ * Return the parameter container responsible for env parameters
+ *
+ * @return \Zend\Stdlib\Parameters
+ */
+ public function env()
+ {
+ if ($this->envParams === null) {
+ $this->envParams = new Parameters();
+ }
+
+ return $this->envParams;
+ }
+
+ /**
+ * @return string
+ */
+ public function toString()
+ {
+ return trim(implode(' ', $this->params()->toArray()));
+ }
+
+ /**
+ * Allow PHP casting of this object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->toString();
+ }
+
+ /**
+ * @param string $scriptName
+ */
+ public function setScriptName($scriptName)
+ {
+ $this->scriptName = $scriptName;
+ }
+
+ /**
+ * @return string
+ */
+ public function getScriptName()
+ {
+ return $this->scriptName;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Console/Response.php zendframework-2.2.6/library/Zend/Console/Response.php
--- zendframework-1.10.4/library/Zend/Console/Response.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Console/Response.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,82 @@
+contentSent;
+ }
+
+ /**
+ * Set the error level that will be returned to shell.
+ *
+ * @param int $errorLevel
+ * @return Response
+ */
+ public function setErrorLevel($errorLevel)
+ {
+ $this->setMetadata('errorLevel', $errorLevel);
+ return $this;
+ }
+
+ /**
+ * Get response error level that will be returned to shell.
+ *
+ * @return int|0
+ */
+ public function getErrorLevel()
+ {
+ return $this->getMetadata('errorLevel', 0);
+ }
+
+ /**
+ * Send content
+ *
+ * @return Response
+ * @deprecated
+ */
+ public function sendContent()
+ {
+ if ($this->contentSent()) {
+ return $this;
+ }
+ echo $this->getContent();
+ $this->contentSent = true;
+ return $this;
+ }
+
+ /**
+ * @deprecated
+ */
+ public function send()
+ {
+ $this->sendContent();
+ $errorLevel = (int) $this->getMetadata('errorLevel',0);
+ exit($errorLevel);
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Exception.php zendframework-2.2.6/library/Zend/Controller/Action/Exception.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,38 +0,0 @@
-_actionController = $actionController;
- return $this;
- }
-
- /**
- * Retrieve current action controller
- *
- * @return Zend_Controller_Action
- */
- public function getActionController()
- {
- return $this->_actionController;
- }
-
- /**
- * Retrieve front controller instance
- *
- * @return Zend_Controller_Front
- */
- public function getFrontController()
- {
- return Zend_Controller_Front::getInstance();
- }
-
- /**
- * Hook into action controller initialization
- *
- * @return void
- */
- public function init()
- {
- }
-
- /**
- * Hook into action controller preDispatch() workflow
- *
- * @return void
- */
- public function preDispatch()
- {
- }
-
- /**
- * Hook into action controller postDispatch() workflow
- *
- * @return void
- */
- public function postDispatch()
- {
- }
-
- /**
- * getRequest() -
- *
- * @return Zend_Controller_Request_Abstract $request
- */
- public function getRequest()
- {
- $controller = $this->getActionController();
- if (null === $controller) {
- $controller = $this->getFrontController();
- }
-
- return $controller->getRequest();
- }
-
- /**
- * getResponse() -
- *
- * @return Zend_Controller_Response_Abstract $response
- */
- public function getResponse()
- {
- $controller = $this->getActionController();
- if (null === $controller) {
- $controller = $this->getFrontController();
- }
-
- return $controller->getResponse();
- }
-
- /**
- * getName()
- *
- * @return string
- */
- public function getName()
- {
- $full_class_name = get_class($this);
-
- if (strpos($full_class_name, '_') !== false) {
- $helper_name = strrchr($full_class_name, '_');
- return ltrim($helper_name, '_');
- } else {
- return $full_class_name;
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Helper/ActionStack.php zendframework-2.2.6/library/Zend/Controller/Action/Helper/ActionStack.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Helper/ActionStack.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Helper/ActionStack.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,138 +0,0 @@
-hasPlugin('Zend_Controller_Plugin_ActionStack')) {
- /**
- * @see Zend_Controller_Plugin_ActionStack
- */
- require_once 'Zend/Controller/Plugin/ActionStack.php';
- $this->_actionStack = new Zend_Controller_Plugin_ActionStack();
- $front->registerPlugin($this->_actionStack, 97);
- } else {
- $this->_actionStack = $front->getPlugin('Zend_Controller_Plugin_ActionStack');
- }
- }
-
- /**
- * Push onto the stack
- *
- * @param Zend_Controller_Request_Abstract $next
- * @return Zend_Controller_Action_Helper_ActionStack Provides a fluent interface
- */
- public function pushStack(Zend_Controller_Request_Abstract $next)
- {
- $this->_actionStack->pushStack($next);
- return $this;
- }
-
- /**
- * Push a new action onto the stack
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @throws Zend_Controller_Action_Exception
- * @return Zend_Controller_Action_Helper_ActionStack
- */
- public function actionToStack($action, $controller = null, $module = null, array $params = array())
- {
- if ($action instanceof Zend_Controller_Request_Abstract) {
- return $this->pushStack($action);
- } elseif (!is_string($action)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('ActionStack requires either a request object or minimally a string action');
- }
-
- $request = $this->getRequest();
-
- if ($request instanceof Zend_Controller_Request_Abstract === false){
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Request object not set yet');
- }
-
- $controller = (null === $controller) ? $request->getControllerName() : $controller;
- $module = (null === $module) ? $request->getModuleName() : $module;
-
- /**
- * @see Zend_Controller_Request_Simple
- */
- require_once 'Zend/Controller/Request/Simple.php';
- $newRequest = new Zend_Controller_Request_Simple($action, $controller, $module, $params);
-
- return $this->pushStack($newRequest);
- }
-
- /**
- * Perform helper when called as $this->_helper->actionStack() from an action controller
- *
- * Proxies to {@link simple()}
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @return boolean
- */
- public function direct($action, $controller = null, $module = null, array $params = array())
- {
- return $this->actionToStack($action, $controller, $module, $params);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Helper/AjaxContext.php zendframework-2.2.6/library/Zend/Controller/Action/Helper/AjaxContext.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Helper/AjaxContext.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Helper/AjaxContext.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,77 +0,0 @@
-addContext('html', array('suffix' => 'ajax'));
- }
-
- /**
- * Initialize AJAX context switching
- *
- * Checks for XHR requests; if detected, attempts to perform context switch.
- *
- * @param string $format
- * @return void
- */
- public function initContext($format = null)
- {
- $this->_currentContext = null;
-
- if (!$this->getRequest()->isXmlHttpRequest()) {
- return;
- }
-
- return parent::initContext($format);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Helper/AutoComplete/Abstract.php zendframework-2.2.6/library/Zend/Controller/Action/Helper/AutoComplete/Abstract.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Helper/AutoComplete/Abstract.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Helper/AutoComplete/Abstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,149 +0,0 @@
-disableLayout();
- }
-
- Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
-
- return $this;
- }
-
- /**
- * Encode data to JSON
- *
- * @param mixed $data
- * @param bool $keepLayouts
- * @throws Zend_Controller_Action_Exception
- * @return string
- */
- public function encodeJson($data, $keepLayouts = false)
- {
- if ($this->validateData($data)) {
- return Zend_Controller_Action_HelperBroker::getStaticHelper('Json')->encodeJson($data, $keepLayouts);
- }
-
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Invalid data passed for autocompletion');
- }
-
- /**
- * Send autocompletion data
- *
- * Calls prepareAutoCompletion, populates response body with this
- * information, and sends response.
- *
- * @param mixed $data
- * @param bool $keepLayouts
- * @return string|void
- */
- public function sendAutoCompletion($data, $keepLayouts = false)
- {
- $data = $this->prepareAutoCompletion($data, $keepLayouts);
-
- $response = $this->getResponse();
- $response->setBody($data);
-
- if (!$this->suppressExit) {
- $response->sendResponse();
- exit;
- }
-
- return $data;
- }
-
- /**
- * Strategy pattern: allow calling helper as broker method
- *
- * Prepares autocompletion data and, if $sendNow is true, immediately sends
- * response.
- *
- * @param mixed $data
- * @param bool $sendNow
- * @param bool $keepLayouts
- * @return string|void
- */
- public function direct($data, $sendNow = true, $keepLayouts = false)
- {
- if ($sendNow) {
- return $this->sendAutoCompletion($data, $keepLayouts);
- }
-
- return $this->prepareAutoCompletion($data, $keepLayouts);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Helper/AutoCompleteDojo.php zendframework-2.2.6/library/Zend/Controller/Action/Helper/AutoCompleteDojo.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Helper/AutoCompleteDojo.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Helper/AutoCompleteDojo.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,87 +0,0 @@
- $value) {
- $items[] = array('label' => $value, 'name' => $value);
- }
- $data = new Zend_Dojo_Data('name', $items);
- }
-
- if (!$keepLayouts) {
- require_once 'Zend/Controller/Action/HelperBroker.php';
- Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
-
- require_once 'Zend/Layout.php';
- $layout = Zend_Layout::getMvcInstance();
- if ($layout instanceof Zend_Layout) {
- $layout->disableLayout();
- }
- }
-
- $response = Zend_Controller_Front::getInstance()->getResponse();
- $response->setHeader('Content-Type', 'application/json');
-
- return $data->toJson();
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Helper/AutoCompleteScriptaculous.php zendframework-2.2.6/library/Zend/Controller/Action/Helper/AutoCompleteScriptaculous.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Helper/AutoCompleteScriptaculous.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Helper/AutoCompleteScriptaculous.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,82 +0,0 @@
-validateData($data)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Invalid data passed for autocompletion');
- }
-
- $data = (array) $data;
- $data = '- ' . implode('
- ', $data) . '
';
-
- if (!$keepLayouts) {
- $this->disableLayouts();
- }
-
- return $data;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Helper/Cache.php zendframework-2.2.6/library/Zend/Controller/Action/Helper/Cache.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Helper/Cache.php 2010-01-27 18:36:28.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Helper/Cache.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,279 +0,0 @@
-getRequest()->getControllerName();
- $actions = array_unique($actions);
- if (!isset($this->_caching[$controller])) {
- $this->_caching[$controller] = array();
- }
- if (!empty($tags)) {
- $tags = array_unique($tags);
- if (!isset($this->_tags[$controller])) {
- $this->_tags[$controller] = array();
- }
- }
- foreach ($actions as $action) {
- $this->_caching[$controller][] = $action;
- if (!empty($tags)) {
- $this->_tags[$controller][$action] = array();
- foreach ($tags as $tag) {
- $this->_tags[$controller][$action][] = $tag;
- }
- }
- }
- if ($extension) {
- if (!isset($this->_extensions[$controller])) {
- $this->_extensions[$controller] = array();
- }
- foreach ($actions as $action) {
- $this->_extensions[$controller][$action] = $extension;
- }
- }
- }
-
- /**
- * Remove a specific page cache static file based on its
- * relative URL from the application's public directory.
- * The file extension is not required here; usually matches
- * the original REQUEST_URI that was cached.
- *
- * @param string $relativeUrl
- * @param bool $recursive
- * @return mixed
- */
- public function removePage($relativeUrl, $recursive = false)
- {
- $cache = $this->getCache(Zend_Cache_Manager::PAGECACHE);
- if ($recursive) {
- $backend = $cache->getBackend();
- if (($backend instanceof Zend_Cache_Backend)
- && method_exists($backend, 'removeRecursively')
- ) {
- return $backend->removeRecursively($relativeUrl);
- }
- }
-
- return $cache->remove($relativeUrl);
- }
-
- /**
- * Remove a specific page cache static file based on its
- * relative URL from the application's public directory.
- * The file extension is not required here; usually matches
- * the original REQUEST_URI that was cached.
- *
- * @param array $tags
- * @return mixed
- */
- public function removePagesTagged(array $tags)
- {
- return $this->getCache(Zend_Cache_Manager::PAGECACHE)
- ->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, $tags);
- }
-
- /**
- * Commence page caching for any cacheable actions
- *
- * @return void
- */
- public function preDispatch()
- {
- $controller = $this->getRequest()->getControllerName();
- $action = $this->getRequest()->getActionName();
- $stats = ob_get_status(true);
- foreach ($stats as $status) {
- if ($status['name'] == 'Zend_Cache_Frontend_Page::_flush'
- || $status['name'] == 'Zend_Cache_Frontend_Capture::_flush') {
- $obStarted = true;
- }
- }
- if (!isset($obStarted) && isset($this->_caching[$controller]) &&
- in_array($action, $this->_caching[$controller])) {
- $reqUri = $this->getRequest()->getRequestUri();
- $tags = array();
- if (isset($this->_tags[$controller][$action])
- && !empty($this->_tags[$controller][$action])) {
- $tags = array_unique($this->_tags[$controller][$action]);
- }
- $extension = null;
- if (isset($this->_extensions[$controller][$action])) {
- $extension = $this->_extensions[$controller][$action];
- }
- $this->getCache(Zend_Cache_Manager::PAGECACHE)
- ->start($this->_encodeCacheId($reqUri), $tags, $extension);
- }
- }
-
- /**
- * Encode a Cache ID as hexadecimal. This is a workaround because Backend ID validation
- * is trapped in the Frontend classes. Will try to get this reversed for ZF 2.0
- * because it's a major annoyance to have IDs so restricted!
- *
- * @return string
- * @param string $requestUri
- */
- protected function _encodeCacheId($requestUri)
- {
- return bin2hex($requestUri);
- }
-
- /**
- * Set an instance of the Cache Manager for this helper
- *
- * @param Zend_Cache_Manager $manager
- * @return void
- */
- public function setManager(Zend_Cache_Manager $manager)
- {
- $this->_manager = $manager;
- return $this;
- }
-
- /**
- * Get the Cache Manager instance or instantiate the object if not
- * exists. Attempts to load from bootstrap if available.
- *
- * @return Zend_Cache_Manager
- */
- public function getManager()
- {
- if (!is_null($this->_manager)) {
- return $this->_manager;
- }
- $front = Zend_Controller_Front::getInstance();
- if ($front->getParam('bootstrap')
- && $front->getParam('bootstrap')->getResource('CacheManager')) {
- return $front->getParam('bootstrap')
- ->getResource('CacheManager');
- }
- $this->_manager = new Zend_Cache_Manager;
- return $this->_manager;
- }
-
- /**
- * Return a list of actions for the current Controller marked for
- * caching
- *
- * @return array
- */
- public function getCacheableActions()
- {
- return $this->_caching;
- }
-
- /**
- * Return a list of tags set for all cacheable actions
- *
- * @return array
- */
- public function getCacheableTags()
- {
- return $this->_tags;
- }
-
- /**
- * Proxy non-matched methods back to Zend_Cache_Manager where
- * appropriate
- *
- * @param string $method
- * @param array $args
- * @return mixed
- */
- public function __call($method, $args)
- {
- if (method_exists($this->getManager(), $method)) {
- return call_user_func_array(
- array($this->getManager(), $method), $args
- );
- }
- throw new Zend_Controller_Action_Exception('Method does not exist:'
- . $method);
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Helper/ContextSwitch.php zendframework-2.2.6/library/Zend/Controller/Action/Helper/ContextSwitch.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Helper/ContextSwitch.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Helper/ContextSwitch.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,1394 +0,0 @@
-setConfig($options);
- } elseif (is_array($options)) {
- $this->setOptions($options);
- }
-
- if (empty($this->_contexts)) {
- $this->addContexts(array(
- 'json' => array(
- 'suffix' => 'json',
- 'headers' => array('Content-Type' => 'application/json'),
- 'callbacks' => array(
- 'init' => 'initJsonContext',
- 'post' => 'postJsonContext'
- )
- ),
- 'xml' => array(
- 'suffix' => 'xml',
- 'headers' => array('Content-Type' => 'application/xml'),
- )
- ));
- }
-
- $this->init();
- }
-
- /**
- * Initialize at start of action controller
- *
- * Reset the view script suffix to the original state, or store the
- * original state.
- *
- * @return void
- */
- public function init()
- {
- if (null === $this->_viewSuffixOrig) {
- $this->_viewSuffixOrig = $this->_getViewRenderer()->getViewSuffix();
- } else {
- $this->_getViewRenderer()->setViewSuffix($this->_viewSuffixOrig);
- }
- }
-
- /**
- * Configure object from array of options
- *
- * @param array $options
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setOptions(array $options)
- {
- if (isset($options['contexts'])) {
- $this->setContexts($options['contexts']);
- unset($options['contexts']);
- }
-
- foreach ($options as $key => $value) {
- $method = 'set' . ucfirst($key);
- if (in_array($method, $this->_unconfigurable)) {
- continue;
- }
-
- if (in_array($method, $this->_specialConfig)) {
- $method = '_' . $method;
- }
-
- if (method_exists($this, $method)) {
- $this->$method($value);
- }
- }
- return $this;
- }
-
- /**
- * Set object state from config object
- *
- * @param Zend_Config $config
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setConfig(Zend_Config $config)
- {
- return $this->setOptions($config->toArray());
- }
-
- /**
- * Strategy pattern: return object
- *
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function direct()
- {
- return $this;
- }
-
- /**
- * Initialize context detection and switching
- *
- * @param mixed $format
- * @throws Zend_Controller_Action_Exception
- * @return void
- */
- public function initContext($format = null)
- {
- $this->_currentContext = null;
-
- $controller = $this->getActionController();
- $request = $this->getRequest();
- $action = $request->getActionName();
-
- // Return if no context switching enabled, or no context switching
- // enabled for this action
- $contexts = $this->getActionContexts($action);
- if (empty($contexts)) {
- return;
- }
-
- // Return if no context parameter provided
- if (!$context = $request->getParam($this->getContextParam())) {
- if ($format === null) {
- return;
- }
- $context = $format;
- $format = null;
- }
-
- // Check if context allowed by action controller
- if (!$this->hasActionContext($action, $context)) {
- return;
- }
-
- // Return if invalid context parameter provided and no format or invalid
- // format provided
- if (!$this->hasContext($context)) {
- if (empty($format) || !$this->hasContext($format)) {
-
- return;
- }
- }
-
- // Use provided format if passed
- if (!empty($format) && $this->hasContext($format)) {
- $context = $format;
- }
-
- $suffix = $this->getSuffix($context);
-
- $this->_getViewRenderer()->setViewSuffix($suffix);
-
- $headers = $this->getHeaders($context);
- if (!empty($headers)) {
- $response = $this->getResponse();
- foreach ($headers as $header => $content) {
- $response->setHeader($header, $content);
- }
- }
-
- if ($this->getAutoDisableLayout()) {
- /**
- * @see Zend_Layout
- */
- require_once 'Zend/Layout.php';
- $layout = Zend_Layout::getMvcInstance();
- if (null !== $layout) {
- $layout->disableLayout();
- }
- }
-
- if (null !== ($callback = $this->getCallback($context, self::TRIGGER_INIT))) {
- if (is_string($callback) && method_exists($this, $callback)) {
- $this->$callback();
- } elseif (is_string($callback) && function_exists($callback)) {
- $callback();
- } elseif (is_array($callback)) {
- call_user_func($callback);
- } else {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Invalid context callback registered for context "%s"', $context));
- }
- }
-
- $this->_currentContext = $context;
- }
-
- /**
- * JSON context extra initialization
- *
- * Turns off viewRenderer auto-rendering
- *
- * @return void
- */
- public function initJsonContext()
- {
- if (!$this->getAutoJsonSerialization()) {
- return;
- }
-
- $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
- $view = $viewRenderer->view;
- if ($view instanceof Zend_View_Interface) {
- $viewRenderer->setNoRender(true);
- }
- }
-
- /**
- * Should JSON contexts auto-serialize?
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setAutoJsonSerialization($flag)
- {
- $this->_autoJsonSerialization = (bool) $flag;
- return $this;
- }
-
- /**
- * Get JSON context auto-serialization flag
- *
- * @return boolean
- */
- public function getAutoJsonSerialization()
- {
- return $this->_autoJsonSerialization;
- }
-
- /**
- * Set suffix from array
- *
- * @param array $spec
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- protected function _setSuffix(array $spec)
- {
- foreach ($spec as $context => $suffixInfo) {
- if (!is_string($context)) {
- $context = null;
- }
-
- if (is_string($suffixInfo)) {
- $this->setSuffix($context, $suffixInfo);
- continue;
- } elseif (is_array($suffixInfo)) {
- if (isset($suffixInfo['suffix'])) {
- $suffix = $suffixInfo['suffix'];
- $prependViewRendererSuffix = true;
-
- if ((null === $context) && isset($suffixInfo['context'])) {
- $context = $suffixInfo['context'];
- }
-
- if (isset($suffixInfo['prependViewRendererSuffix'])) {
- $prependViewRendererSuffix = $suffixInfo['prependViewRendererSuffix'];
- }
-
- $this->setSuffix($context, $suffix, $prependViewRendererSuffix);
- continue;
- }
-
- $count = count($suffixInfo);
- switch (true) {
- case (($count < 2) && (null === $context)):
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Invalid suffix information provided in config');
- case ($count < 2):
- $suffix = array_shift($suffixInfo);
- $this->setSuffix($context, $suffix);
- break;
- case (($count < 3) && (null === $context)):
- $context = array_shift($suffixInfo);
- $suffix = array_shift($suffixInfo);
- $this->setSuffix($context, $suffix);
- break;
- case (($count == 3) && (null === $context)):
- $context = array_shift($suffixInfo);
- $suffix = array_shift($suffixInfo);
- $prependViewRendererSuffix = array_shift($suffixInfo);
- $this->setSuffix($context, $suffix, $prependViewRendererSuffix);
- break;
- case ($count >= 2):
- $suffix = array_shift($suffixInfo);
- $prependViewRendererSuffix = array_shift($suffixInfo);
- $this->setSuffix($context, $suffix, $prependViewRendererSuffix);
- break;
- }
- }
- }
- return $this;
- }
-
- /**
- * Customize view script suffix to use when switching context.
- *
- * Passing an empty suffix value to the setters disables the view script
- * suffix change.
- *
- * @param string $context Context type for which to set suffix
- * @param string $suffix Suffix to use
- * @param boolean $prependViewRendererSuffix Whether or not to prepend the new suffix to the viewrenderer suffix
- * @throws Zend_Controller_Action_Exception
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setSuffix($context, $suffix, $prependViewRendererSuffix = true)
- {
- if (!isset($this->_contexts[$context])) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Cannot set suffix; invalid context type "%s"', $context));
- }
-
- if (empty($suffix)) {
- $suffix = '';
- }
-
- if (is_array($suffix)) {
- if (isset($suffix['prependViewRendererSuffix'])) {
- $prependViewRendererSuffix = $suffix['prependViewRendererSuffix'];
- }
- if (isset($suffix['suffix'])) {
- $suffix = $suffix['suffix'];
- } else {
- $suffix = '';
- }
- }
-
- $suffix = (string) $suffix;
-
- if ($prependViewRendererSuffix) {
- if (empty($suffix)) {
- $suffix = $this->_getViewRenderer()->getViewSuffix();
- } else {
- $suffix .= '.' . $this->_getViewRenderer()->getViewSuffix();
- }
- }
-
- $this->_contexts[$context]['suffix'] = $suffix;
- return $this;
- }
-
- /**
- * Retrieve suffix for given context type
- *
- * @param string $type Context type
- * @throws Zend_Controller_Action_Exception
- * @return string
- */
- public function getSuffix($type)
- {
- if (!isset($this->_contexts[$type])) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Cannot retrieve suffix; invalid context type "%s"', $type));
- }
-
- return $this->_contexts[$type]['suffix'];
- }
-
- /**
- * Does the given context exist?
- *
- * @param string $context
- * @param boolean $throwException
- * @throws Zend_Controller_Action_Exception if context does not exist and throwException is true
- * @return bool
- */
- public function hasContext($context, $throwException = false)
- {
- if (is_string($context)) {
- if (isset($this->_contexts[$context])) {
- return true;
- }
- } elseif (is_array($context)) {
- $error = false;
- foreach ($context as $test) {
- if (!isset($this->_contexts[$test])) {
- $error = (string) $test;
- break;
- }
- }
- if (false === $error) {
- return true;
- }
- $context = $error;
- } elseif (true === $context) {
- return true;
- }
-
- if ($throwException) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Context "%s" does not exist', $context));
- }
-
- return false;
- }
-
- /**
- * Add header to context
- *
- * @param string $context
- * @param string $header
- * @param string $content
- * @throws Zend_Controller_Action_Exception
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function addHeader($context, $header, $content)
- {
- $context = (string) $context;
- $this->hasContext($context, true);
-
- $header = (string) $header;
- $content = (string) $content;
-
- if (isset($this->_contexts[$context]['headers'][$header])) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Cannot add "%s" header to context "%s": already exists', $header, $context));
- }
-
- $this->_contexts[$context]['headers'][$header] = $content;
- return $this;
- }
-
- /**
- * Customize response header to use when switching context
- *
- * Passing an empty header value to the setters disables the response
- * header.
- *
- * @param string $type Context type for which to set suffix
- * @param string $header Header to set
- * @param string $content Header content
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setHeader($context, $header, $content)
- {
- $this->hasContext($context, true);
- $context = (string) $context;
- $header = (string) $header;
- $content = (string) $content;
-
- $this->_contexts[$context]['headers'][$header] = $content;
- return $this;
- }
-
- /**
- * Add multiple headers at once for a given context
- *
- * @param string $context
- * @param array $headers
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function addHeaders($context, array $headers)
- {
- foreach ($headers as $header => $content) {
- $this->addHeader($context, $header, $content);
- }
-
- return $this;
- }
-
- /**
- * Set headers from context => headers pairs
- *
- * @param array $options
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- protected function _setHeaders(array $options)
- {
- foreach ($options as $context => $headers) {
- if (!is_array($headers)) {
- continue;
- }
- $this->setHeaders($context, $headers);
- }
-
- return $this;
- }
-
- /**
- * Set multiple headers at once for a given context
- *
- * @param string $context
- * @param array $headers
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setHeaders($context, array $headers)
- {
- $this->clearHeaders($context);
- foreach ($headers as $header => $content) {
- $this->setHeader($context, $header, $content);
- }
-
- return $this;
- }
-
- /**
- * Retrieve context header
- *
- * Returns the value of a given header for a given context type
- *
- * @param string $context
- * @param string $header
- * @return string|null
- */
- public function getHeader($context, $header)
- {
- $this->hasContext($context, true);
- $context = (string) $context;
- $header = (string) $header;
- if (isset($this->_contexts[$context]['headers'][$header])) {
- return $this->_contexts[$context]['headers'][$header];
- }
-
- return null;
- }
-
- /**
- * Retrieve context headers
- *
- * Returns all headers for a context as key/value pairs
- *
- * @param string $context
- * @return array
- */
- public function getHeaders($context)
- {
- $this->hasContext($context, true);
- $context = (string) $context;
- return $this->_contexts[$context]['headers'];
- }
-
- /**
- * Remove a single header from a context
- *
- * @param string $context
- * @param string $header
- * @return boolean
- */
- public function removeHeader($context, $header)
- {
- $this->hasContext($context, true);
- $context = (string) $context;
- $header = (string) $header;
- if (isset($this->_contexts[$context]['headers'][$header])) {
- unset($this->_contexts[$context]['headers'][$header]);
- return true;
- }
-
- return false;
- }
-
- /**
- * Clear all headers for a given context
- *
- * @param string $context
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function clearHeaders($context)
- {
- $this->hasContext($context, true);
- $context = (string) $context;
- $this->_contexts[$context]['headers'] = array();
- return $this;
- }
-
- /**
- * Validate trigger and return in normalized form
- *
- * @param string $trigger
- * @throws Zend_Controller_Action_Exception
- * @return string
- */
- protected function _validateTrigger($trigger)
- {
- $trigger = strtoupper($trigger);
- if ('TRIGGER_' !== substr($trigger, 0, 8)) {
- $trigger = 'TRIGGER_' . $trigger;
- }
-
- if (!in_array($trigger, array(self::TRIGGER_INIT, self::TRIGGER_POST))) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Invalid trigger "%s"', $trigger));
- }
-
- return $trigger;
- }
-
- /**
- * Set a callback for a given context and trigger
- *
- * @param string $context
- * @param string $trigger
- * @param string|array $callback
- * @throws Zend_Controller_Action_Exception
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setCallback($context, $trigger, $callback)
- {
- $this->hasContext($context, true);
- $trigger = $this->_validateTrigger($trigger);
-
- if (!is_string($callback)) {
- if (!is_array($callback) || (2 != count($callback))) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Invalid callback specified');
- }
- }
-
- $this->_contexts[$context]['callbacks'][$trigger] = $callback;
- return $this;
- }
-
- /**
- * Set callbacks from array of context => callbacks pairs
- *
- * @param array $options
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- protected function _setCallbacks(array $options)
- {
- foreach ($options as $context => $callbacks) {
- if (!is_array($callbacks)) {
- continue;
- }
-
- $this->setCallbacks($context, $callbacks);
- }
- return $this;
- }
-
- /**
- * Set callbacks for a given context
- *
- * Callbacks should be in trigger/callback pairs.
- *
- * @param string $context
- * @param array $callbacks
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setCallbacks($context, array $callbacks)
- {
- $this->hasContext($context, true);
- $context = (string) $context;
- if (!isset($this->_contexts[$context]['callbacks'])) {
- $this->_contexts[$context]['callbacks'] = array();
- }
-
- foreach ($callbacks as $trigger => $callback) {
- $this->setCallback($context, $trigger, $callback);
- }
- return $this;
- }
-
- /**
- * Get a single callback for a given context and trigger
- *
- * @param string $context
- * @param string $trigger
- * @return string|array|null
- */
- public function getCallback($context, $trigger)
- {
- $this->hasContext($context, true);
- $trigger = $this->_validateTrigger($trigger);
- if (isset($this->_contexts[$context]['callbacks'][$trigger])) {
- return $this->_contexts[$context]['callbacks'][$trigger];
- }
-
- return null;
- }
-
- /**
- * Get all callbacks for a given context
- *
- * @param string $context
- * @return array
- */
- public function getCallbacks($context)
- {
- $this->hasContext($context, true);
- return $this->_contexts[$context]['callbacks'];
- }
-
- /**
- * Clear a callback for a given context and trigger
- *
- * @param string $context
- * @param string $trigger
- * @return boolean
- */
- public function removeCallback($context, $trigger)
- {
- $this->hasContext($context, true);
- $trigger = $this->_validateTrigger($trigger);
- if (isset($this->_contexts[$context]['callbacks'][$trigger])) {
- unset($this->_contexts[$context]['callbacks'][$trigger]);
- return true;
- }
-
- return false;
- }
-
- /**
- * Clear all callbacks for a given context
- *
- * @param string $context
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function clearCallbacks($context)
- {
- $this->hasContext($context, true);
- $this->_contexts[$context]['callbacks'] = array();
- return $this;
- }
-
- /**
- * Set name of parameter to use when determining context format
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setContextParam($name)
- {
- $this->_contextParam = (string) $name;
- return $this;
- }
-
- /**
- * Return context format request parameter name
- *
- * @return string
- */
- public function getContextParam()
- {
- return $this->_contextParam;
- }
-
- /**
- * Indicate default context to use when no context format provided
- *
- * @param string $type
- * @throws Zend_Controller_Action_Exception
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setDefaultContext($type)
- {
- if (!isset($this->_contexts[$type])) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Cannot set default context; invalid context type "%s"', $type));
- }
-
- $this->_defaultContext = $type;
- return $this;
- }
-
- /**
- * Return default context
- *
- * @return string
- */
- public function getDefaultContext()
- {
- return $this->_defaultContext;
- }
-
- /**
- * Set flag indicating if layout should be disabled
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setAutoDisableLayout($flag)
- {
- $this->_disableLayout = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve auto layout disable flag
- *
- * @return boolean
- */
- public function getAutoDisableLayout()
- {
- return $this->_disableLayout;
- }
-
- /**
- * Add new context
- *
- * @param string $context Context type
- * @param array $spec Context specification
- * @throws Zend_Controller_Action_Exception
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function addContext($context, array $spec)
- {
- if ($this->hasContext($context)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Cannot add context "%s"; already exists', $context));
- }
- $context = (string) $context;
-
- $this->_contexts[$context] = array();
-
- $this->setSuffix($context, (isset($spec['suffix']) ? $spec['suffix'] : ''))
- ->setHeaders($context, (isset($spec['headers']) ? $spec['headers'] : array()))
- ->setCallbacks($context, (isset($spec['callbacks']) ? $spec['callbacks'] : array()));
- return $this;
- }
-
- /**
- * Overwrite existing context
- *
- * @param string $context Context type
- * @param array $spec Context specification
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setContext($context, array $spec)
- {
- $this->removeContext($context);
- return $this->addContext($context, $spec);
- }
-
- /**
- * Add multiple contexts
- *
- * @param array $contexts
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function addContexts(array $contexts)
- {
- foreach ($contexts as $context => $spec) {
- $this->addContext($context, $spec);
- }
- return $this;
- }
-
- /**
- * Set multiple contexts, after first removing all
- *
- * @param array $contexts
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setContexts(array $contexts)
- {
- $this->clearContexts();
- foreach ($contexts as $context => $spec) {
- $this->addContext($context, $spec);
- }
- return $this;
- }
-
- /**
- * Retrieve context specification
- *
- * @param string $context
- * @return array|null
- */
- public function getContext($context)
- {
- if ($this->hasContext($context)) {
- return $this->_contexts[(string) $context];
- }
- return null;
- }
-
- /**
- * Retrieve context definitions
- *
- * @return array
- */
- public function getContexts()
- {
- return $this->_contexts;
- }
-
- /**
- * Remove a context
- *
- * @param string $context
- * @return boolean
- */
- public function removeContext($context)
- {
- if ($this->hasContext($context)) {
- unset($this->_contexts[(string) $context]);
- return true;
- }
- return false;
- }
-
- /**
- * Remove all contexts
- *
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function clearContexts()
- {
- $this->_contexts = array();
- return $this;
- }
-
- /**
- * Return current context, if any
- *
- * @return null|string
- */
- public function getCurrentContext()
- {
- return $this->_currentContext;
- }
-
- /**
- * Post dispatch processing
- *
- * Execute postDispatch callback for current context, if available
- *
- * @throws Zend_Controller_Action_Exception
- * @return void
- */
- public function postDispatch()
- {
- $context = $this->getCurrentContext();
- if (null !== $context) {
- if (null !== ($callback = $this->getCallback($context, self::TRIGGER_POST))) {
- if (is_string($callback) && method_exists($this, $callback)) {
- $this->$callback();
- } elseif (is_string($callback) && function_exists($callback)) {
- $callback();
- } elseif (is_array($callback)) {
- call_user_func($callback);
- } else {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Invalid postDispatch context callback registered for context "%s"', $context));
- }
- }
- }
- }
-
- /**
- * JSON post processing
- *
- * JSON serialize view variables to response body
- *
- * @return void
- */
- public function postJsonContext()
- {
- if (!$this->getAutoJsonSerialization()) {
- return;
- }
-
- $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
- $view = $viewRenderer->view;
- if ($view instanceof Zend_View_Interface) {
- /**
- * @see Zend_Json
- */
- if(method_exists($view, 'getVars')) {
- require_once 'Zend/Json.php';
- $vars = Zend_Json::encode($view->getVars());
- $this->getResponse()->setBody($vars);
- } else {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('View does not implement the getVars() method needed to encode the view into JSON');
- }
- }
- }
-
- /**
- * Add one or more contexts to an action
- *
- * @param string $action
- * @param string|array $context
- * @return Zend_Controller_Action_Helper_ContextSwitch|void Provides a fluent interface
- */
- public function addActionContext($action, $context)
- {
- $this->hasContext($context, true);
- $controller = $this->getActionController();
- if (null === $controller) {
- return;
- }
- $action = (string) $action;
- $contextKey = $this->_contextKey;
-
- if (!isset($controller->$contextKey)) {
- $controller->$contextKey = array();
- }
-
- if (true === $context) {
- $contexts = $this->getContexts();
- $controller->{$contextKey}[$action] = array_keys($contexts);
- return $this;
- }
-
- $context = (array) $context;
- if (!isset($controller->{$contextKey}[$action])) {
- $controller->{$contextKey}[$action] = $context;
- } else {
- $controller->{$contextKey}[$action] = array_merge(
- $controller->{$contextKey}[$action],
- $context
- );
- }
-
- return $this;
- }
-
- /**
- * Set a context as available for a given controller action
- *
- * @param string $action
- * @param string|array $context
- * @return Zend_Controller_Action_Helper_ContextSwitch|void Provides a fluent interface
- */
- public function setActionContext($action, $context)
- {
- $this->hasContext($context, true);
- $controller = $this->getActionController();
- if (null === $controller) {
- return;
- }
- $action = (string) $action;
- $contextKey = $this->_contextKey;
-
- if (!isset($controller->$contextKey)) {
- $controller->$contextKey = array();
- }
-
- if (true === $context) {
- $contexts = $this->getContexts();
- $controller->{$contextKey}[$action] = array_keys($contexts);
- } else {
- $controller->{$contextKey}[$action] = (array) $context;
- }
-
- return $this;
- }
-
- /**
- * Add multiple action/context pairs at once
- *
- * @param array $contexts
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function addActionContexts(array $contexts)
- {
- foreach ($contexts as $action => $context) {
- $this->addActionContext($action, $context);
- }
- return $this;
- }
-
- /**
- * Overwrite and set multiple action contexts at once
- *
- * @param array $contexts
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function setActionContexts(array $contexts)
- {
- foreach ($contexts as $action => $context) {
- $this->setActionContext($action, $context);
- }
- return $this;
- }
-
- /**
- * Does a particular controller action have the given context(s)?
- *
- * @param string $action
- * @param string|array $context
- * @throws Zend_Controller_Action_Exception
- * @return boolean
- */
- public function hasActionContext($action, $context)
- {
- $this->hasContext($context, true);
- $controller = $this->getActionController();
- if (null === $controller) {
- return false;
- }
- $action = (string) $action;
- $contextKey = $this->_contextKey;
-
- if (!isset($controller->{$contextKey})) {
- return false;
- }
-
- $allContexts = $controller->{$contextKey};
-
- if (!is_array($allContexts)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception("Invalid contexts found for controller");
- }
-
- if (!isset($allContexts[$action])) {
- return false;
- }
-
- if (true === $allContexts[$action]) {
- return true;
- }
-
- $contexts = $allContexts[$action];
-
- if (!is_array($contexts)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf("Invalid contexts found for action '%s'", $action));
- }
-
- if (is_string($context) && in_array($context, $contexts)) {
- return true;
- } elseif (is_array($context)) {
- $found = true;
- foreach ($context as $test) {
- if (!in_array($test, $contexts)) {
- $found = false;
- break;
- }
- }
- return $found;
- }
-
- return false;
- }
-
- /**
- * Get contexts for a given action or all actions in the controller
- *
- * @param string $action
- * @return array
- */
- public function getActionContexts($action = null)
- {
- $controller = $this->getActionController();
- if (null === $controller) {
- return array();
- }
- $action = (string) $action;
- $contextKey = $this->_contextKey;
-
- if (!isset($controller->$contextKey)) {
- return array();
- }
-
- if (null !== $action) {
- if (isset($controller->{$contextKey}[$action])) {
- return $controller->{$contextKey}[$action];
- } else {
- return array();
- }
- }
-
- return $controller->$contextKey;
- }
-
- /**
- * Remove one or more contexts for a given controller action
- *
- * @param string $action
- * @param string|array $context
- * @return boolean
- */
- public function removeActionContext($action, $context)
- {
- if ($this->hasActionContext($action, $context)) {
- $controller = $this->getActionController();
- $contextKey = $this->_contextKey;
- $action = (string) $action;
- $contexts = $controller->$contextKey;
- $actionContexts = $contexts[$action];
- $contexts = (array) $context;
- foreach ($contexts as $context) {
- $index = array_search($context, $actionContexts);
- if (false !== $index) {
- unset($controller->{$contextKey}[$action][$index]);
- }
- }
- return true;
- }
- return false;
- }
-
- /**
- * Clear all contexts for a given controller action or all actions
- *
- * @param string $action
- * @return Zend_Controller_Action_Helper_ContextSwitch Provides a fluent interface
- */
- public function clearActionContexts($action = null)
- {
- $controller = $this->getActionController();
- $contextKey = $this->_contextKey;
-
- if (!isset($controller->$contextKey) || empty($controller->$contextKey)) {
- return $this;
- }
-
- if (null === $action) {
- $controller->$contextKey = array();
- return $this;
- }
-
- $action = (string) $action;
- if (isset($controller->{$contextKey}[$action])) {
- unset($controller->{$contextKey}[$action]);
- }
-
- return $this;
- }
-
- /**
- * Retrieve ViewRenderer
- *
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- protected function _getViewRenderer()
- {
- if (null === $this->_viewRenderer) {
- $this->_viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
- }
-
- return $this->_viewRenderer;
- }
-}
-
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Helper/FlashMessenger.php zendframework-2.2.6/library/Zend/Controller/Action/Helper/FlashMessenger.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Helper/FlashMessenger.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Helper/FlashMessenger.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,266 +0,0 @@
-getName());
- foreach (self::$_session as $namespace => $messages) {
- self::$_messages[$namespace] = $messages;
- unset(self::$_session->{$namespace});
- }
- }
- }
-
- /**
- * postDispatch() - runs after action is dispatched, in this
- * case, it is resetting the namespace in case we have forwarded to a different
- * action, Flashmessage will be 'clean' (default namespace)
- *
- * @return Zend_Controller_Action_Helper_FlashMessenger Provides a fluent interface
- */
- public function postDispatch()
- {
- $this->resetNamespace();
- return $this;
- }
-
- /**
- * setNamespace() - change the namespace messages are added to, useful for
- * per action controller messaging between requests
- *
- * @param string $namespace
- * @return Zend_Controller_Action_Helper_FlashMessenger Provides a fluent interface
- */
- public function setNamespace($namespace = 'default')
- {
- $this->_namespace = $namespace;
- return $this;
- }
-
- /**
- * resetNamespace() - reset the namespace to the default
- *
- * @return Zend_Controller_Action_Helper_FlashMessenger Provides a fluent interface
- */
- public function resetNamespace()
- {
- $this->setNamespace();
- return $this;
- }
-
- /**
- * addMessage() - Add a message to flash message
- *
- * @param string $message
- * @return Zend_Controller_Action_Helper_FlashMessenger Provides a fluent interface
- */
- public function addMessage($message)
- {
- if (self::$_messageAdded === false) {
- self::$_session->setExpirationHops(1, null, true);
- }
-
- if (!is_array(self::$_session->{$this->_namespace})) {
- self::$_session->{$this->_namespace} = array();
- }
-
- self::$_session->{$this->_namespace}[] = $message;
-
- return $this;
- }
-
- /**
- * hasMessages() - Wether a specific namespace has messages
- *
- * @return boolean
- */
- public function hasMessages()
- {
- return isset(self::$_messages[$this->_namespace]);
- }
-
- /**
- * getMessages() - Get messages from a specific namespace
- *
- * @return array
- */
- public function getMessages()
- {
- if ($this->hasMessages()) {
- return self::$_messages[$this->_namespace];
- }
-
- return array();
- }
-
- /**
- * Clear all messages from the previous request & current namespace
- *
- * @return boolean True if messages were cleared, false if none existed
- */
- public function clearMessages()
- {
- if ($this->hasMessages()) {
- unset(self::$_messages[$this->_namespace]);
- return true;
- }
-
- return false;
- }
-
- /**
- * hasCurrentMessages() - check to see if messages have been added to current
- * namespace within this request
- *
- * @return boolean
- */
- public function hasCurrentMessages()
- {
- return isset(self::$_session->{$this->_namespace});
- }
-
- /**
- * getCurrentMessages() - get messages that have been added to the current
- * namespace within this request
- *
- * @return array
- */
- public function getCurrentMessages()
- {
- if ($this->hasCurrentMessages()) {
- return self::$_session->{$this->_namespace};
- }
-
- return array();
- }
-
- /**
- * clear messages from the current request & current namespace
- *
- * @return boolean
- */
- public function clearCurrentMessages()
- {
- if ($this->hasCurrentMessages()) {
- unset(self::$_session->{$this->_namespace});
- return true;
- }
-
- return false;
- }
-
- /**
- * getIterator() - complete the IteratorAggregate interface, for iterating
- *
- * @return ArrayObject
- */
- public function getIterator()
- {
- if ($this->hasMessages()) {
- return new ArrayObject($this->getMessages());
- }
-
- return new ArrayObject();
- }
-
- /**
- * count() - Complete the countable interface
- *
- * @return int
- */
- public function count()
- {
- if ($this->hasMessages()) {
- return count($this->getMessages());
- }
-
- return 0;
- }
-
- /**
- * Strategy pattern: proxy to addMessage()
- *
- * @param string $message
- * @return void
- */
- public function direct($message)
- {
- return $this->addMessage($message);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Helper/Json.php zendframework-2.2.6/library/Zend/Controller/Action/Helper/Json.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Helper/Json.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Helper/Json.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,130 +0,0 @@
-true|false
- * if $keepLayouts and parmas for Zend_Json::encode are required
- * then, the array can contains a 'keepLayout'=>true|false
- * that will not be passed to Zend_Json::encode method but will be passed
- * to Zend_View_Helper_Json
- * @throws Zend_Controller_Action_Helper_Json
- * @return string
- */
- public function encodeJson($data, $keepLayouts = false)
- {
- /**
- * @see Zend_View_Helper_Json
- */
- require_once 'Zend/View/Helper/Json.php';
- $jsonHelper = new Zend_View_Helper_Json();
- $data = $jsonHelper->json($data, $keepLayouts);
-
- if (!$keepLayouts) {
- /**
- * @see Zend_Controller_Action_HelperBroker
- */
- require_once 'Zend/Controller/Action/HelperBroker.php';
- Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
- }
-
- return $data;
- }
-
- /**
- * Encode JSON response and immediately send
- *
- * @param mixed $data
- * @param boolean|array $keepLayouts
- * NOTE: if boolean, establish $keepLayouts to true|false
- * if array, admit params for Zend_Json::encode as enableJsonExprFinder=>true|false
- * if $keepLayouts and parmas for Zend_Json::encode are required
- * then, the array can contains a 'keepLayout'=>true|false
- * that will not be passed to Zend_Json::encode method but will be passed
- * to Zend_View_Helper_Json
- * @return string|void
- */
- public function sendJson($data, $keepLayouts = false)
- {
- $data = $this->encodeJson($data, $keepLayouts);
- $response = $this->getResponse();
- $response->setBody($data);
-
- if (!$this->suppressExit) {
- $response->sendResponse();
- exit;
- }
-
- return $data;
- }
-
- /**
- * Strategy pattern: call helper as helper broker method
- *
- * Allows encoding JSON. If $sendNow is true, immediately sends JSON
- * response.
- *
- * @param mixed $data
- * @param boolean $sendNow
- * @param boolean $keepLayouts
- * @return string|void
- */
- public function direct($data, $sendNow = true, $keepLayouts = false)
- {
- if ($sendNow) {
- return $this->sendJson($data, $keepLayouts);
- }
- return $this->encodeJson($data, $keepLayouts);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Helper/Redirector.php zendframework-2.2.6/library/Zend/Controller/Action/Helper/Redirector.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Helper/Redirector.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Helper/Redirector.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,531 +0,0 @@
-_code;
- }
-
- /**
- * Validate HTTP status redirect code
- *
- * @param int $code
- * @throws Zend_Controller_Action_Exception on invalid HTTP status code
- * @return true
- */
- protected function _checkCode($code)
- {
- $code = (int)$code;
- if ((300 > $code) || (307 < $code) || (304 == $code) || (306 == $code)) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Invalid redirect HTTP status code (' . $code . ')');
- }
-
- return true;
- }
-
- /**
- * Retrieve HTTP status code for {@link _redirect()} behaviour
- *
- * @param int $code
- * @return Zend_Controller_Action_Helper_Redirector Provides a fluent interface
- */
- public function setCode($code)
- {
- $this->_checkCode($code);
- $this->_code = $code;
- return $this;
- }
-
- /**
- * Retrieve flag for whether or not {@link _redirect()} will exit when finished.
- *
- * @return boolean
- */
- public function getExit()
- {
- return $this->_exit;
- }
-
- /**
- * Retrieve exit flag for {@link _redirect()} behaviour
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_Redirector Provides a fluent interface
- */
- public function setExit($flag)
- {
- $this->_exit = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve flag for whether or not {@link _redirect()} will prepend the
- * base URL on relative URLs
- *
- * @return boolean
- */
- public function getPrependBase()
- {
- return $this->_prependBase;
- }
-
- /**
- * Retrieve 'prepend base' flag for {@link _redirect()} behaviour
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_Redirector Provides a fluent interface
- */
- public function setPrependBase($flag)
- {
- $this->_prependBase = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve flag for whether or not {@link redirectAndExit()} shall close the session before
- * exiting.
- *
- * @return boolean
- */
- public function getCloseSessionOnExit()
- {
- return $this->_closeSessionOnExit;
- }
-
- /**
- * Set flag for whether or not {@link redirectAndExit()} shall close the session before exiting.
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_Redirector Provides a fluent interface
- */
- public function setCloseSessionOnExit($flag)
- {
- $this->_closeSessionOnExit = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Return use absolute URI flag
- *
- * @return boolean
- */
- public function getUseAbsoluteUri()
- {
- return $this->_useAbsoluteUri;
- }
-
- /**
- * Set use absolute URI flag
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_Redirector Provides a fluent interface
- */
- public function setUseAbsoluteUri($flag = true)
- {
- $this->_useAbsoluteUri = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Set redirect in response object
- *
- * @return void
- */
- protected function _redirect($url)
- {
- if ($this->getUseAbsoluteUri() && !preg_match('#^(https?|ftp)://#', $url)) {
- $host = (isset($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:'');
- $proto = (isset($_SERVER['HTTPS'])&&$_SERVER['HTTPS']!=="off") ? 'https' : 'http';
- $port = (isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:80);
- $uri = $proto . '://' . $host;
- if ((('http' == $proto) && (80 != $port)) || (('https' == $proto) && (443 != $port))) {
- $uri .= ':' . $port;
- }
- $url = $uri . '/' . ltrim($url, '/');
- }
- $this->_redirectUrl = $url;
- $this->getResponse()->setRedirect($url, $this->getCode());
- }
-
- /**
- * Retrieve currently set URL for redirect
- *
- * @return string
- */
- public function getRedirectUrl()
- {
- return $this->_redirectUrl;
- }
-
- /**
- * Determine if the baseUrl should be prepended, and prepend if necessary
- *
- * @param string $url
- * @return string
- */
- protected function _prependBase($url)
- {
- if ($this->getPrependBase()) {
- $request = $this->getRequest();
- if ($request instanceof Zend_Controller_Request_Http) {
- $base = rtrim($request->getBaseUrl(), '/');
- if (!empty($base) && ('/' != $base)) {
- $url = $base . '/' . ltrim($url, '/');
- } else {
- $url = '/' . ltrim($url, '/');
- }
- }
- }
-
- return $url;
- }
-
- /**
- * Set a redirect URL of the form /module/controller/action/params
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @return void
- */
- public function setGotoSimple($action, $controller = null, $module = null, array $params = array())
- {
- $dispatcher = $this->getFrontController()->getDispatcher();
- $request = $this->getRequest();
- $curModule = $request->getModuleName();
- $useDefaultController = false;
-
- if (null === $controller && null !== $module) {
- $useDefaultController = true;
- }
-
- if (null === $module) {
- $module = $curModule;
- }
-
- if ($module == $dispatcher->getDefaultModule()) {
- $module = '';
- }
-
- if (null === $controller && !$useDefaultController) {
- $controller = $request->getControllerName();
- if (empty($controller)) {
- $controller = $dispatcher->getDefaultControllerName();
- }
- }
-
- $params['module'] = $module;
- $params['controller'] = $controller;
- $params['action'] = $action;
-
- $router = $this->getFrontController()->getRouter();
- $url = $router->assemble($params, 'default', true);
-
- $this->_redirect($url);
- }
-
- /**
- * Build a URL based on a route
- *
- * @param array $urlOptions
- * @param string $name Route name
- * @param boolean $reset
- * @param boolean $encode
- * @return void
- */
- public function setGotoRoute(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
- {
- $router = $this->getFrontController()->getRouter();
- $url = $router->assemble($urlOptions, $name, $reset, $encode);
-
- $this->_redirect($url);
- }
-
- /**
- * Set a redirect URL string
- *
- * By default, emits a 302 HTTP status header, prepends base URL as defined
- * in request object if url is relative, and halts script execution by
- * calling exit().
- *
- * $options is an optional associative array that can be used to control
- * redirect behaviour. The available option keys are:
- * - exit: boolean flag indicating whether or not to halt script execution when done
- * - prependBase: boolean flag indicating whether or not to prepend the base URL when a relative URL is provided
- * - code: integer HTTP status code to use with redirect. Should be between 300 and 307.
- *
- * _redirect() sets the Location header in the response object. If you set
- * the exit flag to false, you can override this header later in code
- * execution.
- *
- * If the exit flag is true (true by default), _redirect() will write and
- * close the current session, if any.
- *
- * @param string $url
- * @param array $options
- * @return void
- */
- public function setGotoUrl($url, array $options = array())
- {
- // prevent header injections
- $url = str_replace(array("\n", "\r"), '', $url);
-
- if (null !== $options) {
- if (isset($options['exit'])) {
- $this->setExit(($options['exit']) ? true : false);
- }
- if (isset($options['prependBase'])) {
- $this->setPrependBase(($options['prependBase']) ? true : false);
- }
- if (isset($options['code'])) {
- $this->setCode($options['code']);
- }
- }
-
- // If relative URL, decide if we should prepend base URL
- if (!preg_match('|^[a-z]+://|', $url)) {
- $url = $this->_prependBase($url);
- }
-
- $this->_redirect($url);
- }
-
- /**
- * Perform a redirect to an action/controller/module with params
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @return void
- */
- public function gotoSimple($action, $controller = null, $module = null, array $params = array())
- {
- $this->setGotoSimple($action, $controller, $module, $params);
-
- if ($this->getExit()) {
- $this->redirectAndExit();
- }
- }
-
- /**
- * Perform a redirect to an action/controller/module with params, forcing an immdiate exit
- *
- * @param mixed $action
- * @param mixed $controller
- * @param mixed $module
- * @param array $params
- * @return void
- */
- public function gotoSimpleAndExit($action, $controller = null, $module = null, array $params = array())
- {
- $this->setGotoSimple($action, $controller, $module, $params);
- $this->redirectAndExit();
- }
-
- /**
- * Redirect to a route-based URL
- *
- * Uses route's assemble method tobuild the URL; route is specified by $name;
- * default route is used if none provided.
- *
- * @param array $urlOptions Array of key/value pairs used to assemble URL
- * @param string $name
- * @param boolean $reset
- * @param boolean $encode
- * @return void
- */
- public function gotoRoute(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
- {
- $this->setGotoRoute($urlOptions, $name, $reset, $encode);
-
- if ($this->getExit()) {
- $this->redirectAndExit();
- }
- }
-
- /**
- * Redirect to a route-based URL, and immediately exit
- *
- * Uses route's assemble method tobuild the URL; route is specified by $name;
- * default route is used if none provided.
- *
- * @param array $urlOptions Array of key/value pairs used to assemble URL
- * @param string $name
- * @param boolean $reset
- * @return void
- */
- public function gotoRouteAndExit(array $urlOptions = array(), $name = null, $reset = false)
- {
- $this->setGotoRoute($urlOptions, $name, $reset);
- $this->redirectAndExit();
- }
-
- /**
- * Perform a redirect to a url
- *
- * @param string $url
- * @param array $options
- * @return void
- */
- public function gotoUrl($url, array $options = array())
- {
- $this->setGotoUrl($url, $options);
-
- if ($this->getExit()) {
- $this->redirectAndExit();
- }
- }
-
- /**
- * Set a URL string for a redirect, perform redirect, and immediately exit
- *
- * @param string $url
- * @param array $options
- * @return void
- */
- public function gotoUrlAndExit($url, array $options = array())
- {
- $this->gotoUrl($url, $options);
- $this->redirectAndExit();
- }
-
- /**
- * exit(): Perform exit for redirector
- *
- * @return void
- */
- public function redirectAndExit()
- {
- if ($this->getCloseSessionOnExit()) {
- // Close session, if started
- if (class_exists('Zend_Session', false) && Zend_Session::isStarted()) {
- Zend_Session::writeClose();
- } elseif (isset($_SESSION)) {
- session_write_close();
- }
- }
-
- $this->getResponse()->sendHeaders();
- exit();
- }
-
- /**
- * direct(): Perform helper when called as
- * $this->_helper->redirector($action, $controller, $module, $params)
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @return void
- */
- public function direct($action, $controller = null, $module = null, array $params = array())
- {
- $this->gotoSimple($action, $controller, $module, $params);
- }
-
- /**
- * Overloading
- *
- * Overloading for old 'goto', 'setGoto', and 'gotoAndExit' methods
- *
- * @param string $method
- * @param array $args
- * @return mixed
- * @throws Zend_Controller_Action_Exception for invalid methods
- */
- public function __call($method, $args)
- {
- $method = strtolower($method);
- if ('goto' == $method) {
- return call_user_func_array(array($this, 'gotoSimple'), $args);
- }
- if ('setgoto' == $method) {
- return call_user_func_array(array($this, 'setGotoSimple'), $args);
- }
- if ('gotoandexit' == $method) {
- return call_user_func_array(array($this, 'gotoSimpleAndExit'), $args);
- }
-
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception(sprintf('Invalid method "%s" called on redirector', $method));
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Helper/Url.php zendframework-2.2.6/library/Zend/Controller/Action/Helper/Url.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Helper/Url.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Helper/Url.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,117 +0,0 @@
-getRequest();
-
- if (null === $controller) {
- $controller = $request->getControllerName();
- }
-
- if (null === $module) {
- $module = $request->getModuleName();
- }
-
- $url = $controller . '/' . $action;
- if ($module != $this->getFrontController()->getDispatcher()->getDefaultModule()) {
- $url = $module . '/' . $url;
- }
-
- if ('' !== ($baseUrl = $this->getFrontController()->getBaseUrl())) {
- $url = $baseUrl . '/' . $url;
- }
-
- if (null !== $params) {
- $paramPairs = array();
- foreach ($params as $key => $value) {
- $paramPairs[] = urlencode($key) . '/' . urlencode($value);
- }
- $paramString = implode('/', $paramPairs);
- $url .= '/' . $paramString;
- }
-
- $url = '/' . ltrim($url, '/');
-
- return $url;
- }
-
- /**
- * Assembles a URL based on a given route
- *
- * This method will typically be used for more complex operations, as it
- * ties into the route objects registered with the router.
- *
- * @param array $urlOptions Options passed to the assemble method of the Route object.
- * @param mixed $name The name of a Route to use. If null it will use the current Route
- * @param boolean $reset
- * @param boolean $encode
- * @return string Url for the link href attribute.
- */
- public function url($urlOptions = array(), $name = null, $reset = false, $encode = true)
- {
- $router = $this->getFrontController()->getRouter();
- return $router->assemble($urlOptions, $name, $reset, $encode);
- }
-
- /**
- * Perform helper when called as $this->_helper->url() from an action controller
- *
- * Proxies to {@link simple()}
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @return string
- */
- public function direct($action, $controller = null, $module = null, array $params = null)
- {
- return $this->simple($action, $controller, $module, $params);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Helper/ViewRenderer.php zendframework-2.2.6/library/Zend/Controller/Action/Helper/ViewRenderer.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Helper/ViewRenderer.php 2010-01-13 18:55:25.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Helper/ViewRenderer.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,989 +0,0 @@
-
- * // In your bootstrap:
- * Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_ViewRenderer());
- *
- * // In your action controller methods:
- * $viewHelper = $this->_helper->getHelper('view');
- *
- * // Don't use controller subdirectories
- * $viewHelper->setNoController(true);
- *
- * // Specify a different script to render:
- * $this->_helper->viewRenderer('form');
- *
- *
- *
- * @uses Zend_Controller_Action_Helper_Abstract
- * @package Zend_Controller
- * @subpackage Zend_Controller_Action_Helper
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-class Zend_Controller_Action_Helper_ViewRenderer extends Zend_Controller_Action_Helper_Abstract
-{
- /**
- * @var Zend_View_Interface
- */
- public $view;
-
- /**
- * Word delimiters
- * @var array
- */
- protected $_delimiters;
-
- /**
- * @var Zend_Filter_Inflector
- */
- protected $_inflector;
-
- /**
- * Inflector target
- * @var string
- */
- protected $_inflectorTarget = '';
-
- /**
- * Current module directory
- * @var string
- */
- protected $_moduleDir = '';
-
- /**
- * Whether or not to autorender using controller name as subdirectory;
- * global setting (not reset at next invocation)
- * @var boolean
- */
- protected $_neverController = false;
-
- /**
- * Whether or not to autorender postDispatch; global setting (not reset at
- * next invocation)
- * @var boolean
- */
- protected $_neverRender = false;
-
- /**
- * Whether or not to use a controller name as a subdirectory when rendering
- * @var boolean
- */
- protected $_noController = false;
-
- /**
- * Whether or not to autorender postDispatch; per controller/action setting (reset
- * at next invocation)
- * @var boolean
- */
- protected $_noRender = false;
-
- /**
- * Characters representing path delimiters in the controller
- * @var string|array
- */
- protected $_pathDelimiters;
-
- /**
- * Which named segment of the response to utilize
- * @var string
- */
- protected $_responseSegment = null;
-
- /**
- * Which action view script to render
- * @var string
- */
- protected $_scriptAction = null;
-
- /**
- * View object basePath
- * @var string
- */
- protected $_viewBasePathSpec = ':moduleDir/views';
-
- /**
- * View script path specification string
- * @var string
- */
- protected $_viewScriptPathSpec = ':controller/:action.:suffix';
-
- /**
- * View script path specification string, minus controller segment
- * @var string
- */
- protected $_viewScriptPathNoControllerSpec = ':action.:suffix';
-
- /**
- * View script suffix
- * @var string
- */
- protected $_viewSuffix = 'phtml';
-
- /**
- * Constructor
- *
- * Optionally set view object and options.
- *
- * @param Zend_View_Interface $view
- * @param array $options
- * @return void
- */
- public function __construct(Zend_View_Interface $view = null, array $options = array())
- {
- if (null !== $view) {
- $this->setView($view);
- }
-
- if (!empty($options)) {
- $this->_setOptions($options);
- }
- }
-
- /**
- * Clone - also make sure the view is cloned.
- *
- * @return void
- */
- public function __clone()
- {
- if (isset($this->view) && $this->view instanceof Zend_View_Interface) {
- $this->view = clone $this->view;
-
- }
- }
-
- /**
- * Set the view object
- *
- * @param Zend_View_Interface $view
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setView(Zend_View_Interface $view)
- {
- $this->view = $view;
- return $this;
- }
-
- /**
- * Get current module name
- *
- * @return string
- */
- public function getModule()
- {
- $request = $this->getRequest();
- $module = $request->getModuleName();
- if (null === $module) {
- $module = $this->getFrontController()->getDispatcher()->getDefaultModule();
- }
-
- return $module;
- }
-
- /**
- * Get module directory
- *
- * @throws Zend_Controller_Action_Exception
- * @return string
- */
- public function getModuleDirectory()
- {
- $module = $this->getModule();
- $moduleDir = $this->getFrontController()->getControllerDirectory($module);
- if ((null === $moduleDir) || is_array($moduleDir)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('ViewRenderer cannot locate module directory for module "' . $module . '"');
- }
- $this->_moduleDir = dirname($moduleDir);
- return $this->_moduleDir;
- }
-
- /**
- * Get inflector
- *
- * @return Zend_Filter_Inflector
- */
- public function getInflector()
- {
- if (null === $this->_inflector) {
- /**
- * @see Zend_Filter_Inflector
- */
- require_once 'Zend/Filter/Inflector.php';
- /**
- * @see Zend_Filter_PregReplace
- */
- require_once 'Zend/Filter/PregReplace.php';
- /**
- * @see Zend_Filter_Word_UnderscoreToSeparator
- */
- require_once 'Zend/Filter/Word/UnderscoreToSeparator.php';
- $this->_inflector = new Zend_Filter_Inflector();
- $this->_inflector->setStaticRuleReference('moduleDir', $this->_moduleDir) // moduleDir must be specified before the less specific 'module'
- ->addRules(array(
- ':module' => array('Word_CamelCaseToDash', 'StringToLower'),
- ':controller' => array('Word_CamelCaseToDash', new Zend_Filter_Word_UnderscoreToSeparator('/'), 'StringToLower', new Zend_Filter_PregReplace('/\./', '-')),
- ':action' => array('Word_CamelCaseToDash', new Zend_Filter_PregReplace('#[^a-z0-9' . preg_quote('/', '#') . ']+#i', '-'), 'StringToLower'),
- ))
- ->setStaticRuleReference('suffix', $this->_viewSuffix)
- ->setTargetReference($this->_inflectorTarget);
- }
-
- // Ensure that module directory is current
- $this->getModuleDirectory();
-
- return $this->_inflector;
- }
-
- /**
- * Set inflector
- *
- * @param Zend_Filter_Inflector $inflector
- * @param boolean $reference Whether the moduleDir, target, and suffix should be set as references to ViewRenderer properties
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setInflector(Zend_Filter_Inflector $inflector, $reference = false)
- {
- $this->_inflector = $inflector;
- if ($reference) {
- $this->_inflector->setStaticRuleReference('suffix', $this->_viewSuffix)
- ->setStaticRuleReference('moduleDir', $this->_moduleDir)
- ->setTargetReference($this->_inflectorTarget);
- }
- return $this;
- }
-
- /**
- * Set inflector target
- *
- * @param string $target
- * @return void
- */
- protected function _setInflectorTarget($target)
- {
- $this->_inflectorTarget = (string) $target;
- }
-
- /**
- * Set internal module directory representation
- *
- * @param string $dir
- * @return void
- */
- protected function _setModuleDir($dir)
- {
- $this->_moduleDir = (string) $dir;
- }
-
- /**
- * Get internal module directory representation
- *
- * @return string
- */
- protected function _getModuleDir()
- {
- return $this->_moduleDir;
- }
-
- /**
- * Generate a class prefix for helper and filter classes
- *
- * @return string
- */
- protected function _generateDefaultPrefix()
- {
- $default = 'Zend_View';
- if (null === $this->_actionController) {
- return $default;
- }
-
- $class = get_class($this->_actionController);
-
- if (!strstr($class, '_')) {
- return $default;
- }
-
- $module = $this->getModule();
- if ('default' == $module) {
- return $default;
- }
-
- $prefix = substr($class, 0, strpos($class, '_')) . '_View';
-
- return $prefix;
- }
-
- /**
- * Retrieve base path based on location of current action controller
- *
- * @return string
- */
- protected function _getBasePath()
- {
- if (null === $this->_actionController) {
- return './views';
- }
-
- $inflector = $this->getInflector();
- $this->_setInflectorTarget($this->getViewBasePathSpec());
-
- $dispatcher = $this->getFrontController()->getDispatcher();
- $request = $this->getRequest();
-
- $parts = array(
- 'module' => (($moduleName = $request->getModuleName()) != '') ? $dispatcher->formatModuleName($moduleName) : $moduleName,
- 'controller' => $request->getControllerName(),
- 'action' => $dispatcher->formatActionName($request->getActionName())
- );
-
- $path = $inflector->filter($parts);
- return $path;
- }
-
- /**
- * Set options
- *
- * @param array $options
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- protected function _setOptions(array $options)
- {
- foreach ($options as $key => $value)
- {
- switch ($key) {
- case 'neverRender':
- case 'neverController':
- case 'noController':
- case 'noRender':
- $property = '_' . $key;
- $this->{$property} = ($value) ? true : false;
- break;
- case 'responseSegment':
- case 'scriptAction':
- case 'viewBasePathSpec':
- case 'viewScriptPathSpec':
- case 'viewScriptPathNoControllerSpec':
- case 'viewSuffix':
- $property = '_' . $key;
- $this->{$property} = (string) $value;
- break;
- default:
- break;
- }
- }
-
- return $this;
- }
-
- /**
- * Initialize the view object
- *
- * $options may contain the following keys:
- * - neverRender - flag dis/enabling postDispatch() autorender (affects all subsequent calls)
- * - noController - flag indicating whether or not to look for view scripts in subdirectories named after the controller
- * - noRender - flag indicating whether or not to autorender postDispatch()
- * - responseSegment - which named response segment to render a view script to
- * - scriptAction - what action script to render
- * - viewBasePathSpec - specification to use for determining view base path
- * - viewScriptPathSpec - specification to use for determining view script paths
- * - viewScriptPathNoControllerSpec - specification to use for determining view script paths when noController flag is set
- * - viewSuffix - what view script filename suffix to use
- *
- * @param string $path
- * @param string $prefix
- * @param array $options
- * @throws Zend_Controller_Action_Exception
- * @return void
- */
- public function initView($path = null, $prefix = null, array $options = array())
- {
- if (null === $this->view) {
- $this->setView(new Zend_View());
- }
-
- // Reset some flags every time
- $options['noController'] = (isset($options['noController'])) ? $options['noController'] : false;
- $options['noRender'] = (isset($options['noRender'])) ? $options['noRender'] : false;
- $this->_scriptAction = null;
- $this->_responseSegment = null;
-
- // Set options first; may be used to determine other initializations
- $this->_setOptions($options);
-
- // Get base view path
- if (empty($path)) {
- $path = $this->_getBasePath();
- if (empty($path)) {
- /**
- * @see Zend_Controller_Action_Exception
- */
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('ViewRenderer initialization failed: retrieved view base path is empty');
- }
- }
-
- if (null === $prefix) {
- $prefix = $this->_generateDefaultPrefix();
- }
-
- // Determine if this path has already been registered
- $currentPaths = $this->view->getScriptPaths();
- $path = str_replace(array('/', '\\'), '/', $path);
- $pathExists = false;
- foreach ($currentPaths as $tmpPath) {
- $tmpPath = str_replace(array('/', '\\'), '/', $tmpPath);
- if (strstr($tmpPath, $path)) {
- $pathExists = true;
- break;
- }
- }
- if (!$pathExists) {
- $this->view->addBasePath($path, $prefix);
- }
-
- // Register view with action controller (unless already registered)
- if ((null !== $this->_actionController) && (null === $this->_actionController->view)) {
- $this->_actionController->view = $this->view;
- $this->_actionController->viewSuffix = $this->_viewSuffix;
- }
- }
-
- /**
- * init - initialize view
- *
- * @return void
- */
- public function init()
- {
- if ($this->getFrontController()->getParam('noViewRenderer')) {
- return;
- }
-
- $this->initView();
- }
-
- /**
- * Set view basePath specification
- *
- * Specification can contain one or more of the following:
- * - :moduleDir - current module directory
- * - :controller - name of current controller in the request
- * - :action - name of current action in the request
- * - :module - name of current module in the request
- *
- * @param string $path
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setViewBasePathSpec($path)
- {
- $this->_viewBasePathSpec = (string) $path;
- return $this;
- }
-
- /**
- * Retrieve the current view basePath specification string
- *
- * @return string
- */
- public function getViewBasePathSpec()
- {
- return $this->_viewBasePathSpec;
- }
-
- /**
- * Set view script path specification
- *
- * Specification can contain one or more of the following:
- * - :moduleDir - current module directory
- * - :controller - name of current controller in the request
- * - :action - name of current action in the request
- * - :module - name of current module in the request
- *
- * @param string $path
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setViewScriptPathSpec($path)
- {
- $this->_viewScriptPathSpec = (string) $path;
- return $this;
- }
-
- /**
- * Retrieve the current view script path specification string
- *
- * @return string
- */
- public function getViewScriptPathSpec()
- {
- return $this->_viewScriptPathSpec;
- }
-
- /**
- * Set view script path specification (no controller variant)
- *
- * Specification can contain one or more of the following:
- * - :moduleDir - current module directory
- * - :controller - name of current controller in the request
- * - :action - name of current action in the request
- * - :module - name of current module in the request
- *
- * :controller will likely be ignored in this variant.
- *
- * @param string $path
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setViewScriptPathNoControllerSpec($path)
- {
- $this->_viewScriptPathNoControllerSpec = (string) $path;
- return $this;
- }
-
- /**
- * Retrieve the current view script path specification string (no controller variant)
- *
- * @return string
- */
- public function getViewScriptPathNoControllerSpec()
- {
- return $this->_viewScriptPathNoControllerSpec;
- }
-
- /**
- * Get a view script based on an action and/or other variables
- *
- * Uses values found in current request if no values passed in $vars.
- *
- * If {@link $_noController} is set, uses {@link $_viewScriptPathNoControllerSpec};
- * otherwise, uses {@link $_viewScriptPathSpec}.
- *
- * @param string $action
- * @param array $vars
- * @return string
- */
- public function getViewScript($action = null, array $vars = array())
- {
- $request = $this->getRequest();
- if ((null === $action) && (!isset($vars['action']))) {
- $action = $this->getScriptAction();
- if (null === $action) {
- $action = $request->getActionName();
- }
- $vars['action'] = $action;
- } elseif (null !== $action) {
- $vars['action'] = $action;
- }
-
- $inflector = $this->getInflector();
- if ($this->getNoController() || $this->getNeverController()) {
- $this->_setInflectorTarget($this->getViewScriptPathNoControllerSpec());
- } else {
- $this->_setInflectorTarget($this->getViewScriptPathSpec());
- }
- return $this->_translateSpec($vars);
- }
-
- /**
- * Set the neverRender flag (i.e., globally dis/enable autorendering)
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setNeverRender($flag = true)
- {
- $this->_neverRender = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve neverRender flag value
- *
- * @return boolean
- */
- public function getNeverRender()
- {
- return $this->_neverRender;
- }
-
- /**
- * Set the noRender flag (i.e., whether or not to autorender)
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setNoRender($flag = true)
- {
- $this->_noRender = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve noRender flag value
- *
- * @return boolean
- */
- public function getNoRender()
- {
- return $this->_noRender;
- }
-
- /**
- * Set the view script to use
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setScriptAction($name)
- {
- $this->_scriptAction = (string) $name;
- return $this;
- }
-
- /**
- * Retrieve view script name
- *
- * @return string
- */
- public function getScriptAction()
- {
- return $this->_scriptAction;
- }
-
- /**
- * Set the response segment name
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setResponseSegment($name)
- {
- if (null === $name) {
- $this->_responseSegment = null;
- } else {
- $this->_responseSegment = (string) $name;
- }
-
- return $this;
- }
-
- /**
- * Retrieve named response segment name
- *
- * @return string
- */
- public function getResponseSegment()
- {
- return $this->_responseSegment;
- }
-
- /**
- * Set the noController flag (i.e., whether or not to render into controller subdirectories)
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setNoController($flag = true)
- {
- $this->_noController = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve noController flag value
- *
- * @return boolean
- */
- public function getNoController()
- {
- return $this->_noController;
- }
-
- /**
- * Set the neverController flag (i.e., whether or not to render into controller subdirectories)
- *
- * @param boolean $flag
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setNeverController($flag = true)
- {
- $this->_neverController = ($flag) ? true : false;
- return $this;
- }
-
- /**
- * Retrieve neverController flag value
- *
- * @return boolean
- */
- public function getNeverController()
- {
- return $this->_neverController;
- }
-
- /**
- * Set view script suffix
- *
- * @param string $suffix
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setViewSuffix($suffix)
- {
- $this->_viewSuffix = (string) $suffix;
- return $this;
- }
-
- /**
- * Get view script suffix
- *
- * @return string
- */
- public function getViewSuffix()
- {
- return $this->_viewSuffix;
- }
-
- /**
- * Set options for rendering a view script
- *
- * @param string $action View script to render
- * @param string $name Response named segment to render to
- * @param boolean $noController Whether or not to render within a subdirectory named after the controller
- * @return Zend_Controller_Action_Helper_ViewRenderer Provides a fluent interface
- */
- public function setRender($action = null, $name = null, $noController = null)
- {
- if (null !== $action) {
- $this->setScriptAction($action);
- }
-
- if (null !== $name) {
- $this->setResponseSegment($name);
- }
-
- if (null !== $noController) {
- $this->setNoController($noController);
- }
-
- return $this;
- }
-
- /**
- * Inflect based on provided vars
- *
- * Allowed variables are:
- * - :moduleDir - current module directory
- * - :module - current module name
- * - :controller - current controller name
- * - :action - current action name
- * - :suffix - view script file suffix
- *
- * @param array $vars
- * @return string
- */
- protected function _translateSpec(array $vars = array())
- {
- $inflector = $this->getInflector();
- $request = $this->getRequest();
- $dispatcher = $this->getFrontController()->getDispatcher();
- $module = $dispatcher->formatModuleName($request->getModuleName());
- $controller = $request->getControllerName();
- $action = $dispatcher->formatActionName($request->getActionName());
-
- $params = compact('module', 'controller', 'action');
- foreach ($vars as $key => $value) {
- switch ($key) {
- case 'module':
- case 'controller':
- case 'action':
- case 'moduleDir':
- case 'suffix':
- $params[$key] = (string) $value;
- break;
- default:
- break;
- }
- }
-
- if (isset($params['suffix'])) {
- $origSuffix = $this->getViewSuffix();
- $this->setViewSuffix($params['suffix']);
- }
- if (isset($params['moduleDir'])) {
- $origModuleDir = $this->_getModuleDir();
- $this->_setModuleDir($params['moduleDir']);
- }
-
- $filtered = $inflector->filter($params);
-
- if (isset($params['suffix'])) {
- $this->setViewSuffix($origSuffix);
- }
- if (isset($params['moduleDir'])) {
- $this->_setModuleDir($origModuleDir);
- }
-
- return $filtered;
- }
-
- /**
- * Render a view script (optionally to a named response segment)
- *
- * Sets the noRender flag to true when called.
- *
- * @param string $script
- * @param string $name
- * @return void
- */
- public function renderScript($script, $name = null)
- {
- if (null === $name) {
- $name = $this->getResponseSegment();
- }
-
- $this->getResponse()->appendBody(
- $this->view->render($script),
- $name
- );
-
- $this->setNoRender();
- }
-
- /**
- * Render a view based on path specifications
- *
- * Renders a view based on the view script path specifications.
- *
- * @param string $action
- * @param string $name
- * @param boolean $noController
- * @return void
- */
- public function render($action = null, $name = null, $noController = null)
- {
- $this->setRender($action, $name, $noController);
- $path = $this->getViewScript();
- $this->renderScript($path, $name);
- }
-
- /**
- * Render a script based on specification variables
- *
- * Pass an action, and one or more specification variables (view script suffix)
- * to determine the view script path, and render that script.
- *
- * @param string $action
- * @param array $vars
- * @param string $name
- * @return void
- */
- public function renderBySpec($action = null, array $vars = array(), $name = null)
- {
- if (null !== $name) {
- $this->setResponseSegment($name);
- }
-
- $path = $this->getViewScript($action, $vars);
-
- $this->renderScript($path);
- }
-
- /**
- * postDispatch - auto render a view
- *
- * Only autorenders if:
- * - _noRender is false
- * - action controller is present
- * - request has not been re-dispatched (i.e., _forward() has not been called)
- * - response is not a redirect
- *
- * @return void
- */
- public function postDispatch()
- {
- if ($this->_shouldRender()) {
- $this->render();
- }
- }
-
- /**
- * Should the ViewRenderer render a view script?
- *
- * @return boolean
- */
- protected function _shouldRender()
- {
- return (!$this->getFrontController()->getParam('noViewRenderer')
- && !$this->_neverRender
- && !$this->_noRender
- && (null !== $this->_actionController)
- && $this->getRequest()->isDispatched()
- && !$this->getResponse()->isRedirect()
- );
- }
-
- /**
- * Use this helper as a method; proxies to setRender()
- *
- * @param string $action
- * @param string $name
- * @param boolean $noController
- * @return void
- */
- public function direct($action = null, $name = null, $noController = null)
- {
- $this->setRender($action, $name, $noController);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/HelperBroker/PriorityStack.php zendframework-2.2.6/library/Zend/Controller/Action/HelperBroker/PriorityStack.php
--- zendframework-1.10.4/library/Zend/Controller/Action/HelperBroker/PriorityStack.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/HelperBroker/PriorityStack.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,280 +0,0 @@
-_helpersByNameRef)) {
- return false;
- }
-
- return $this->_helpersByNameRef[$helperName];
- }
-
- /**
- * Magic property overloading for returning if helper is set by name
- *
- * @param string $helperName The helper name
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public function __isset($helperName)
- {
- return array_key_exists($helperName, $this->_helpersByNameRef);
- }
-
- /**
- * Magic property overloading for unsetting if helper is exists by name
- *
- * @param string $helperName The helper name
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public function __unset($helperName)
- {
- return $this->offsetUnset($helperName);
- }
-
- /**
- * push helper onto the stack
- *
- * @param Zend_Controller_Action_Helper_Abstract $helper
- * @return Zend_Controller_Action_HelperBroker_PriorityStack
- */
- public function push(Zend_Controller_Action_Helper_Abstract $helper)
- {
- $this->offsetSet($this->getNextFreeHigherPriority(), $helper);
- return $this;
- }
-
- /**
- * Return something iterable
- *
- * @return array
- */
- public function getIterator()
- {
- return new ArrayObject($this->_helpersByPriority);
- }
-
- /**
- * offsetExists()
- *
- * @param int|string $priorityOrHelperName
- * @return Zend_Controller_Action_HelperBroker_PriorityStack
- */
- public function offsetExists($priorityOrHelperName)
- {
- if (is_string($priorityOrHelperName)) {
- return array_key_exists($priorityOrHelperName, $this->_helpersByNameRef);
- } else {
- return array_key_exists($priorityOrHelperName, $this->_helpersByPriority);
- }
- }
-
- /**
- * offsetGet()
- *
- * @param int|string $priorityOrHelperName
- * @return Zend_Controller_Action_HelperBroker_PriorityStack
- */
- public function offsetGet($priorityOrHelperName)
- {
- if (!$this->offsetExists($priorityOrHelperName)) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('A helper with priority ' . $priorityOrHelperName . ' does not exist.');
- }
-
- if (is_string($priorityOrHelperName)) {
- return $this->_helpersByNameRef[$priorityOrHelperName];
- } else {
- return $this->_helpersByPriority[$priorityOrHelperName];
- }
- }
-
- /**
- * offsetSet()
- *
- * @param int $priority
- * @param Zend_Controller_Action_Helper_Abstract $helper
- * @return Zend_Controller_Action_HelperBroker_PriorityStack
- */
- public function offsetSet($priority, $helper)
- {
- $priority = (int) $priority;
-
- if (!$helper instanceof Zend_Controller_Action_Helper_Abstract) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('$helper must extend Zend_Controller_Action_Helper_Abstract.');
- }
-
- if (array_key_exists($helper->getName(), $this->_helpersByNameRef)) {
- // remove any object with the same name to retain BC compailitbility
- // @todo At ZF 2.0 time throw an exception here.
- $this->offsetUnset($helper->getName());
- }
-
- if (array_key_exists($priority, $this->_helpersByPriority)) {
- $priority = $this->getNextFreeHigherPriority($priority); // ensures LIFO
- trigger_error("A helper with the same priority already exists, reassigning to $priority", E_USER_WARNING);
- }
-
- $this->_helpersByPriority[$priority] = $helper;
- $this->_helpersByNameRef[$helper->getName()] = $helper;
-
- if ($priority == ($nextFreeDefault = $this->getNextFreeHigherPriority($this->_nextDefaultPriority))) {
- $this->_nextDefaultPriority = $nextFreeDefault;
- }
-
- krsort($this->_helpersByPriority); // always make sure priority and LIFO are both enforced
- return $this;
- }
-
- /**
- * offsetUnset()
- *
- * @param int|string $priorityOrHelperName Priority integer or the helper name
- * @return Zend_Controller_Action_HelperBroker_PriorityStack
- */
- public function offsetUnset($priorityOrHelperName)
- {
- if (!$this->offsetExists($priorityOrHelperName)) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('A helper with priority or name ' . $priorityOrHelperName . ' does not exist.');
- }
-
- if (is_string($priorityOrHelperName)) {
- $helperName = $priorityOrHelperName;
- $helper = $this->_helpersByNameRef[$helperName];
- $priority = array_search($helper, $this->_helpersByPriority, true);
- } else {
- $priority = $priorityOrHelperName;
- $helperName = $this->_helpersByPriority[$priorityOrHelperName]->getName();
- }
-
- unset($this->_helpersByNameRef[$helperName]);
- unset($this->_helpersByPriority[$priority]);
- return $this;
- }
-
- /**
- * return the count of helpers
- *
- * @return int
- */
- public function count()
- {
- return count($this->_helpersByPriority);
- }
-
- /**
- * Find the next free higher priority. If an index is given, it will
- * find the next free highest priority after it.
- *
- * @param int $indexPriority OPTIONAL
- * @return int
- */
- public function getNextFreeHigherPriority($indexPriority = null)
- {
- if ($indexPriority == null) {
- $indexPriority = $this->_nextDefaultPriority;
- }
-
- $priorities = array_keys($this->_helpersByPriority);
-
- while (in_array($indexPriority, $priorities)) {
- $indexPriority++;
- }
-
- return $indexPriority;
- }
-
- /**
- * Find the next free lower priority. If an index is given, it will
- * find the next free lower priority before it.
- *
- * @param int $indexPriority
- * @return int
- */
- public function getNextFreeLowerPriority($indexPriority = null)
- {
- if ($indexPriority == null) {
- $indexPriority = $this->_nextDefaultPriority;
- }
-
- $priorities = array_keys($this->_helpersByPriority);
-
- while (in_array($indexPriority, $priorities)) {
- $indexPriority--;
- }
-
- return $indexPriority;
- }
-
- /**
- * return the highest priority
- *
- * @return int
- */
- public function getHighestPriority()
- {
- return max(array_keys($this->_helpersByPriority));
- }
-
- /**
- * return the lowest priority
- *
- * @return int
- */
- public function getLowestPriority()
- {
- return min(array_keys($this->_helpersByPriority));
- }
-
- /**
- * return the helpers referenced by name
- *
- * @return array
- */
- public function getHelpersByName()
- {
- return $this->_helpersByNameRef;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/HelperBroker.php zendframework-2.2.6/library/Zend/Controller/Action/HelperBroker.php
--- zendframework-1.10.4/library/Zend/Controller/Action/HelperBroker.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/HelperBroker.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,381 +0,0 @@
- 'Zend/Controller/Action/Helper/',
- ));
- }
- return self::$_pluginLoader;
- }
-
- /**
- * addPrefix() - Add repository of helpers by prefix
- *
- * @param string $prefix
- */
- static public function addPrefix($prefix)
- {
- $prefix = rtrim($prefix, '_');
- $path = str_replace('_', DIRECTORY_SEPARATOR, $prefix);
- self::getPluginLoader()->addPrefixPath($prefix, $path);
- }
-
- /**
- * addPath() - Add path to repositories where Action_Helpers could be found.
- *
- * @param string $path
- * @param string $prefix Optional; defaults to 'Zend_Controller_Action_Helper'
- * @return void
- */
- static public function addPath($path, $prefix = 'Zend_Controller_Action_Helper')
- {
- self::getPluginLoader()->addPrefixPath($prefix, $path);
- }
-
- /**
- * addHelper() - Add helper objects
- *
- * @param Zend_Controller_Action_Helper_Abstract $helper
- * @return void
- */
- static public function addHelper(Zend_Controller_Action_Helper_Abstract $helper)
- {
- self::getStack()->push($helper);
- return;
- }
-
- /**
- * resetHelpers()
- *
- * @return void
- */
- static public function resetHelpers()
- {
- self::$_stack = null;
- return;
- }
-
- /**
- * Retrieve or initialize a helper statically
- *
- * Retrieves a helper object statically, loading on-demand if the helper
- * does not already exist in the stack. Always returns a helper, unless
- * the helper class cannot be found.
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public static function getStaticHelper($name)
- {
- $name = self::_normalizeHelperName($name);
- $stack = self::getStack();
-
- if (!isset($stack->{$name})) {
- self::_loadHelper($name);
- }
-
- return $stack->{$name};
- }
-
- /**
- * getExistingHelper() - get helper by name
- *
- * Static method to retrieve helper object. Only retrieves helpers already
- * initialized with the broker (either via addHelper() or on-demand loading
- * via getHelper()).
- *
- * Throws an exception if the referenced helper does not exist in the
- * stack; use {@link hasHelper()} to check if the helper is registered
- * prior to retrieving it.
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_Abstract
- * @throws Zend_Controller_Action_Exception
- */
- public static function getExistingHelper($name)
- {
- $name = self::_normalizeHelperName($name);
- $stack = self::getStack();
-
- if (!isset($stack->{$name})) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Action helper "' . $name . '" has not been registered with the helper broker');
- }
-
- return $stack->{$name};
- }
-
- /**
- * Return all registered helpers as helper => object pairs
- *
- * @return array
- */
- public static function getExistingHelpers()
- {
- return self::getStack()->getHelpersByName();
- }
-
- /**
- * Is a particular helper loaded in the broker?
- *
- * @param string $name
- * @return boolean
- */
- public static function hasHelper($name)
- {
- $name = self::_normalizeHelperName($name);
- return isset(self::getStack()->{$name});
- }
-
- /**
- * Remove a particular helper from the broker
- *
- * @param string $name
- * @return boolean
- */
- public static function removeHelper($name)
- {
- $name = self::_normalizeHelperName($name);
- $stack = self::getStack();
- if (isset($stack->{$name})) {
- unset($stack->{$name});
- }
-
- return false;
- }
-
- /**
- * Lazy load the priority stack and return it
- *
- * @return Zend_Controller_Action_HelperBroker_PriorityStack
- */
- public static function getStack()
- {
- if (self::$_stack == null) {
- self::$_stack = new Zend_Controller_Action_HelperBroker_PriorityStack();
- }
-
- return self::$_stack;
- }
-
- /**
- * Constructor
- *
- * @param Zend_Controller_Action $actionController
- * @return void
- */
- public function __construct(Zend_Controller_Action $actionController)
- {
- $this->_actionController = $actionController;
- foreach (self::getStack() as $helper) {
- $helper->setActionController($actionController);
- $helper->init();
- }
- }
-
- /**
- * notifyPreDispatch() - called by action controller dispatch method
- *
- * @return void
- */
- public function notifyPreDispatch()
- {
- foreach (self::getStack() as $helper) {
- $helper->preDispatch();
- }
- }
-
- /**
- * notifyPostDispatch() - called by action controller dispatch method
- *
- * @return void
- */
- public function notifyPostDispatch()
- {
- foreach (self::getStack() as $helper) {
- $helper->postDispatch();
- }
- }
-
- /**
- * getHelper() - get helper by name
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public function getHelper($name)
- {
- $name = self::_normalizeHelperName($name);
- $stack = self::getStack();
-
- if (!isset($stack->{$name})) {
- self::_loadHelper($name);
- }
-
- $helper = $stack->{$name};
-
- $initialize = false;
- if (null === ($actionController = $helper->getActionController())) {
- $initialize = true;
- } elseif ($actionController !== $this->_actionController) {
- $initialize = true;
- }
-
- if ($initialize) {
- $helper->setActionController($this->_actionController)
- ->init();
- }
-
- return $helper;
- }
-
- /**
- * Method overloading
- *
- * @param string $method
- * @param array $args
- * @return mixed
- * @throws Zend_Controller_Action_Exception if helper does not have a direct() method
- */
- public function __call($method, $args)
- {
- $helper = $this->getHelper($method);
- if (!method_exists($helper, 'direct')) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Helper "' . $method . '" does not support overloading via direct()');
- }
- return call_user_func_array(array($helper, 'direct'), $args);
- }
-
- /**
- * Retrieve helper by name as object property
- *
- * @param string $name
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public function __get($name)
- {
- return $this->getHelper($name);
- }
-
- /**
- * Normalize helper name for lookups
- *
- * @param string $name
- * @return string
- */
- protected static function _normalizeHelperName($name)
- {
- if (strpos($name, '_') !== false) {
- $name = str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
- }
-
- return ucfirst($name);
- }
-
- /**
- * Load a helper
- *
- * @param string $name
- * @return void
- */
- protected static function _loadHelper($name)
- {
- try {
- $class = self::getPluginLoader()->load($name);
- } catch (Zend_Loader_PluginLoader_Exception $e) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Action Helper by name ' . $name . ' not found', 0, $e);
- }
-
- $helper = new $class();
-
- if (!$helper instanceof Zend_Controller_Action_Helper_Abstract) {
- require_once 'Zend/Controller/Action/Exception.php';
- throw new Zend_Controller_Action_Exception('Helper name ' . $name . ' -> class ' . $class . ' is not of type Zend_Controller_Action_Helper_Abstract');
- }
-
- self::getStack()->push($helper);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Action/Interface.php zendframework-2.2.6/library/Zend/Controller/Action/Interface.php
--- zendframework-1.10.4/library/Zend/Controller/Action/Interface.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Action/Interface.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,69 +0,0 @@
-setRequest($request)
- ->setResponse($response)
- ->_setInvokeArgs($invokeArgs);
- $this->_helper = new Zend_Controller_Action_HelperBroker($this);
- $this->init();
- }
-
- /**
- * Initialize object
- *
- * Called from {@link __construct()} as final step of object instantiation.
- *
- * @return void
- */
- public function init()
- {
- }
-
- /**
- * Initialize View object
- *
- * Initializes {@link $view} if not otherwise a Zend_View_Interface.
- *
- * If {@link $view} is not otherwise set, instantiates a new Zend_View
- * object, using the 'views' subdirectory at the same level as the
- * controller directory for the current module as the base directory.
- * It uses this to set the following:
- * - script path = views/scripts/
- * - helper path = views/helpers/
- * - filter path = views/filters/
- *
- * @return Zend_View_Interface
- * @throws Zend_Controller_Exception if base view directory does not exist
- */
- public function initView()
- {
- if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) {
- return $this->view;
- }
-
- require_once 'Zend/View/Interface.php';
- if (isset($this->view) && ($this->view instanceof Zend_View_Interface)) {
- return $this->view;
- }
-
- $request = $this->getRequest();
- $module = $request->getModuleName();
- $dirs = $this->getFrontController()->getControllerDirectory();
- if (empty($module) || !isset($dirs[$module])) {
- $module = $this->getFrontController()->getDispatcher()->getDefaultModule();
- }
- $baseDir = dirname($dirs[$module]) . DIRECTORY_SEPARATOR . 'views';
- if (!file_exists($baseDir) || !is_dir($baseDir)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Missing base view directory ("' . $baseDir . '")');
- }
-
- require_once 'Zend/View.php';
- $this->view = new Zend_View(array('basePath' => $baseDir));
-
- return $this->view;
- }
-
- /**
- * Render a view
- *
- * Renders a view. By default, views are found in the view script path as
- * /.phtml. You may change the script suffix by
- * resetting {@link $viewSuffix}. You may omit the controller directory
- * prefix by specifying boolean true for $noController.
- *
- * By default, the rendered contents are appended to the response. You may
- * specify the named body content segment to set by specifying a $name.
- *
- * @see Zend_Controller_Response_Abstract::appendBody()
- * @param string|null $action Defaults to action registered in request object
- * @param string|null $name Response object named path segment to use; defaults to null
- * @param bool $noController Defaults to false; i.e. use controller name as subdir in which to search for view script
- * @return void
- */
- public function render($action = null, $name = null, $noController = false)
- {
- if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) {
- return $this->_helper->viewRenderer->render($action, $name, $noController);
- }
-
- $view = $this->initView();
- $script = $this->getViewScript($action, $noController);
-
- $this->getResponse()->appendBody(
- $view->render($script),
- $name
- );
- }
-
- /**
- * Render a given view script
- *
- * Similar to {@link render()}, this method renders a view script. Unlike render(),
- * however, it does not autodetermine the view script via {@link getViewScript()},
- * but instead renders the script passed to it. Use this if you know the
- * exact view script name and path you wish to use, or if using paths that do not
- * conform to the spec defined with getViewScript().
- *
- * By default, the rendered contents are appended to the response. You may
- * specify the named body content segment to set by specifying a $name.
- *
- * @param string $script
- * @param string $name
- * @return void
- */
- public function renderScript($script, $name = null)
- {
- if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) {
- return $this->_helper->viewRenderer->renderScript($script, $name);
- }
-
- $view = $this->initView();
- $this->getResponse()->appendBody(
- $view->render($script),
- $name
- );
- }
-
- /**
- * Construct view script path
- *
- * Used by render() to determine the path to the view script.
- *
- * @param string $action Defaults to action registered in request object
- * @param bool $noController Defaults to false; i.e. use controller name as subdir in which to search for view script
- * @return string
- * @throws Zend_Controller_Exception with bad $action
- */
- public function getViewScript($action = null, $noController = null)
- {
- if (!$this->getInvokeArg('noViewRenderer') && $this->_helper->hasHelper('viewRenderer')) {
- $viewRenderer = $this->_helper->getHelper('viewRenderer');
- if (null !== $noController) {
- $viewRenderer->setNoController($noController);
- }
- return $viewRenderer->getViewScript($action);
- }
-
- $request = $this->getRequest();
- if (null === $action) {
- $action = $request->getActionName();
- } elseif (!is_string($action)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid action specifier for view render');
- }
-
- if (null === $this->_delimiters) {
- $dispatcher = Zend_Controller_Front::getInstance()->getDispatcher();
- $wordDelimiters = $dispatcher->getWordDelimiter();
- $pathDelimiters = $dispatcher->getPathDelimiter();
- $this->_delimiters = array_unique(array_merge($wordDelimiters, (array) $pathDelimiters));
- }
-
- $action = str_replace($this->_delimiters, '-', $action);
- $script = $action . '.' . $this->viewSuffix;
-
- if (!$noController) {
- $controller = $request->getControllerName();
- $controller = str_replace($this->_delimiters, '-', $controller);
- $script = $controller . DIRECTORY_SEPARATOR . $script;
- }
-
- return $script;
- }
-
- /**
- * Return the Request object
- *
- * @return Zend_Controller_Request_Abstract
- */
- public function getRequest()
- {
- return $this->_request;
- }
-
- /**
- * Set the Request object
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return Zend_Controller_Action
- */
- public function setRequest(Zend_Controller_Request_Abstract $request)
- {
- $this->_request = $request;
- return $this;
- }
-
- /**
- * Return the Response object
- *
- * @return Zend_Controller_Response_Abstract
- */
- public function getResponse()
- {
- return $this->_response;
- }
-
- /**
- * Set the Response object
- *
- * @param Zend_Controller_Response_Abstract $response
- * @return Zend_Controller_Action
- */
- public function setResponse(Zend_Controller_Response_Abstract $response)
- {
- $this->_response = $response;
- return $this;
- }
-
- /**
- * Set invocation arguments
- *
- * @param array $args
- * @return Zend_Controller_Action
- */
- protected function _setInvokeArgs(array $args = array())
- {
- $this->_invokeArgs = $args;
- return $this;
- }
-
- /**
- * Return the array of constructor arguments (minus the Request object)
- *
- * @return array
- */
- public function getInvokeArgs()
- {
- return $this->_invokeArgs;
- }
-
- /**
- * Return a single invocation argument
- *
- * @param string $key
- * @return mixed
- */
- public function getInvokeArg($key)
- {
- if (isset($this->_invokeArgs[$key])) {
- return $this->_invokeArgs[$key];
- }
-
- return null;
- }
-
- /**
- * Get a helper by name
- *
- * @param string $helperName
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public function getHelper($helperName)
- {
- return $this->_helper->{$helperName};
- }
-
- /**
- * Get a clone of a helper by name
- *
- * @param string $helperName
- * @return Zend_Controller_Action_Helper_Abstract
- */
- public function getHelperCopy($helperName)
- {
- return clone $this->_helper->{$helperName};
- }
-
- /**
- * Set the front controller instance
- *
- * @param Zend_Controller_Front $front
- * @return Zend_Controller_Action
- */
- public function setFrontController(Zend_Controller_Front $front)
- {
- $this->_frontController = $front;
- return $this;
- }
-
- /**
- * Retrieve Front Controller
- *
- * @return Zend_Controller_Front
- */
- public function getFrontController()
- {
- // Used cache version if found
- if (null !== $this->_frontController) {
- return $this->_frontController;
- }
-
- // Grab singleton instance, if class has been loaded
- if (class_exists('Zend_Controller_Front')) {
- $this->_frontController = Zend_Controller_Front::getInstance();
- return $this->_frontController;
- }
-
- // Throw exception in all other cases
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Front controller class has not been loaded');
- }
-
- /**
- * Pre-dispatch routines
- *
- * Called before action method. If using class with
- * {@link Zend_Controller_Front}, it may modify the
- * {@link $_request Request object} and reset its dispatched flag in order
- * to skip processing the current action.
- *
- * @return void
- */
- public function preDispatch()
- {
- }
-
- /**
- * Post-dispatch routines
- *
- * Called after action method execution. If using class with
- * {@link Zend_Controller_Front}, it may modify the
- * {@link $_request Request object} and reset its dispatched flag in order
- * to process an additional action.
- *
- * Common usages for postDispatch() include rendering content in a sitewide
- * template, link url correction, setting headers, etc.
- *
- * @return void
- */
- public function postDispatch()
- {
- }
-
- /**
- * Proxy for undefined methods. Default behavior is to throw an
- * exception on undefined methods, however this function can be
- * overridden to implement magic (dynamic) actions, or provide run-time
- * dispatching.
- *
- * @param string $methodName
- * @param array $args
- * @return void
- * @throws Zend_Controller_Action_Exception
- */
- public function __call($methodName, $args)
- {
- require_once 'Zend/Controller/Action/Exception.php';
- if ('Action' == substr($methodName, -6)) {
- $action = substr($methodName, 0, strlen($methodName) - 6);
- throw new Zend_Controller_Action_Exception(sprintf('Action "%s" does not exist and was not trapped in __call()', $action), 404);
- }
-
- throw new Zend_Controller_Action_Exception(sprintf('Method "%s" does not exist and was not trapped in __call()', $methodName), 500);
- }
-
- /**
- * Dispatch the requested action
- *
- * @param string $action Method name of action
- * @return void
- */
- public function dispatch($action)
- {
- // Notify helpers of action preDispatch state
- $this->_helper->notifyPreDispatch();
-
- $this->preDispatch();
- if ($this->getRequest()->isDispatched()) {
- if (null === $this->_classMethods) {
- $this->_classMethods = get_class_methods($this);
- }
-
- // preDispatch() didn't change the action, so we can continue
- if ($this->getInvokeArg('useCaseSensitiveActions') || in_array($action, $this->_classMethods)) {
- if ($this->getInvokeArg('useCaseSensitiveActions')) {
- trigger_error('Using case sensitive actions without word separators is deprecated; please do not rely on this "feature"');
- }
- $this->$action();
- } else {
- $this->__call($action, array());
- }
- $this->postDispatch();
- }
-
- // whats actually important here is that this action controller is
- // shutting down, regardless of dispatching; notify the helpers of this
- // state
- $this->_helper->notifyPostDispatch();
- }
-
- /**
- * Call the action specified in the request object, and return a response
- *
- * Not used in the Action Controller implementation, but left for usage in
- * Page Controller implementations. Dispatches a method based on the
- * request.
- *
- * Returns a Zend_Controller_Response_Abstract object, instantiating one
- * prior to execution if none exists in the controller.
- *
- * {@link preDispatch()} is called prior to the action,
- * {@link postDispatch()} is called following it.
- *
- * @param null|Zend_Controller_Request_Abstract $request Optional request
- * object to use
- * @param null|Zend_Controller_Response_Abstract $response Optional response
- * object to use
- * @return Zend_Controller_Response_Abstract
- */
- public function run(Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null)
- {
- if (null !== $request) {
- $this->setRequest($request);
- } else {
- $request = $this->getRequest();
- }
-
- if (null !== $response) {
- $this->setResponse($response);
- }
-
- $action = $request->getActionName();
- if (empty($action)) {
- $action = 'index';
- }
- $action = $action . 'Action';
-
- $request->setDispatched(true);
- $this->dispatch($action);
-
- return $this->getResponse();
- }
-
- /**
- * Gets a parameter from the {@link $_request Request object}. If the
- * parameter does not exist, NULL will be returned.
- *
- * If the parameter does not exist and $default is set, then
- * $default will be returned instead of NULL.
- *
- * @param string $paramName
- * @param mixed $default
- * @return mixed
- */
- protected function _getParam($paramName, $default = null)
- {
- $value = $this->getRequest()->getParam($paramName);
- if ((null === $value) && (null !== $default)) {
- $value = $default;
- }
-
- return $value;
- }
-
- /**
- * Set a parameter in the {@link $_request Request object}.
- *
- * @param string $paramName
- * @param mixed $value
- * @return Zend_Controller_Action
- */
- protected function _setParam($paramName, $value)
- {
- $this->getRequest()->setParam($paramName, $value);
-
- return $this;
- }
-
- /**
- * Determine whether a given parameter exists in the
- * {@link $_request Request object}.
- *
- * @param string $paramName
- * @return boolean
- */
- protected function _hasParam($paramName)
- {
- return null !== $this->getRequest()->getParam($paramName);
- }
-
- /**
- * Return all parameters in the {@link $_request Request object}
- * as an associative array.
- *
- * @return array
- */
- protected function _getAllParams()
- {
- return $this->getRequest()->getParams();
- }
-
-
- /**
- * Forward to another controller/action.
- *
- * It is important to supply the unformatted names, i.e. "article"
- * rather than "ArticleController". The dispatcher will do the
- * appropriate formatting when the request is received.
- *
- * If only an action name is provided, forwards to that action in this
- * controller.
- *
- * If an action and controller are specified, forwards to that action and
- * controller in this module.
- *
- * Specifying an action, controller, and module is the most specific way to
- * forward.
- *
- * A fourth argument, $params, will be used to set the request parameters.
- * If either the controller or module are unnecessary for forwarding,
- * simply pass null values for them before specifying the parameters.
- *
- * @param string $action
- * @param string $controller
- * @param string $module
- * @param array $params
- * @return void
- */
- final protected function _forward($action, $controller = null, $module = null, array $params = null)
- {
- $request = $this->getRequest();
-
- if (null !== $params) {
- $request->setParams($params);
- }
-
- if (null !== $controller) {
- $request->setControllerName($controller);
-
- // Module should only be reset if controller has been specified
- if (null !== $module) {
- $request->setModuleName($module);
- }
- }
-
- $request->setActionName($action)
- ->setDispatched(false);
- }
-
- /**
- * Redirect to another URL
- *
- * Proxies to {@link Zend_Controller_Action_Helper_Redirector::gotoUrl()}.
- *
- * @param string $url
- * @param array $options Options to be used when redirecting
- * @return void
- */
- protected function _redirect($url, array $options = array())
- {
- $this->_helper->redirector->gotoUrl($url, $options);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Dispatcher/Abstract.php zendframework-2.2.6/library/Zend/Controller/Dispatcher/Abstract.php
--- zendframework-1.10.4/library/Zend/Controller/Dispatcher/Abstract.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Dispatcher/Abstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,440 +0,0 @@
-setParams($params);
- }
-
- /**
- * Formats a string into a controller name. This is used to take a raw
- * controller name, such as one stored inside a Zend_Controller_Request_Abstract
- * object, and reformat it to a proper class name that a class extending
- * Zend_Controller_Action would use.
- *
- * @param string $unformatted
- * @return string
- */
- public function formatControllerName($unformatted)
- {
- return ucfirst($this->_formatName($unformatted)) . 'Controller';
- }
-
- /**
- * Formats a string into an action name. This is used to take a raw
- * action name, such as one that would be stored inside a Zend_Controller_Request_Abstract
- * object, and reformat into a proper method name that would be found
- * inside a class extending Zend_Controller_Action.
- *
- * @param string $unformatted
- * @return string
- */
- public function formatActionName($unformatted)
- {
- $formatted = $this->_formatName($unformatted, true);
- return strtolower(substr($formatted, 0, 1)) . substr($formatted, 1) . 'Action';
- }
-
- /**
- * Verify delimiter
- *
- * Verify a delimiter to use in controllers or actions. May be a single
- * string or an array of strings.
- *
- * @param string|array $spec
- * @return array
- * @throws Zend_Controller_Dispatcher_Exception with invalid delimiters
- */
- public function _verifyDelimiter($spec)
- {
- if (is_string($spec)) {
- return (array) $spec;
- } elseif (is_array($spec)) {
- $allStrings = true;
- foreach ($spec as $delim) {
- if (!is_string($delim)) {
- $allStrings = false;
- break;
- }
- }
-
- if (!$allStrings) {
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception('Word delimiter array must contain only strings');
- }
-
- return $spec;
- }
-
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception('Invalid word delimiter');
- }
-
- /**
- * Retrieve the word delimiter character(s) used in
- * controller or action names
- *
- * @return array
- */
- public function getWordDelimiter()
- {
- return $this->_wordDelimiter;
- }
-
- /**
- * Set word delimiter
- *
- * Set the word delimiter to use in controllers and actions. May be a
- * single string or an array of strings.
- *
- * @param string|array $spec
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setWordDelimiter($spec)
- {
- $spec = $this->_verifyDelimiter($spec);
- $this->_wordDelimiter = $spec;
-
- return $this;
- }
-
- /**
- * Retrieve the path delimiter character(s) used in
- * controller names
- *
- * @return array
- */
- public function getPathDelimiter()
- {
- return $this->_pathDelimiter;
- }
-
- /**
- * Set path delimiter
- *
- * Set the path delimiter to use in controllers. May be a single string or
- * an array of strings.
- *
- * @param string $spec
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setPathDelimiter($spec)
- {
- if (!is_string($spec)) {
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception('Invalid path delimiter');
- }
- $this->_pathDelimiter = $spec;
-
- return $this;
- }
-
- /**
- * Formats a string from a URI into a PHP-friendly name.
- *
- * By default, replaces words separated by the word separator character(s)
- * with camelCaps. If $isAction is false, it also preserves replaces words
- * separated by the path separation character with an underscore, making
- * the following word Title cased. All non-alphanumeric characters are
- * removed.
- *
- * @param string $unformatted
- * @param boolean $isAction Defaults to false
- * @return string
- */
- protected function _formatName($unformatted, $isAction = false)
- {
- // preserve directories
- if (!$isAction) {
- $segments = explode($this->getPathDelimiter(), $unformatted);
- } else {
- $segments = (array) $unformatted;
- }
-
- foreach ($segments as $key => $segment) {
- $segment = str_replace($this->getWordDelimiter(), ' ', strtolower($segment));
- $segment = preg_replace('/[^a-z0-9 ]/', '', $segment);
- $segments[$key] = str_replace(' ', '', ucwords($segment));
- }
-
- return implode('_', $segments);
- }
-
- /**
- * Retrieve front controller instance
- *
- * @return Zend_Controller_Front
- */
- public function getFrontController()
- {
- if (null === $this->_frontController) {
- require_once 'Zend/Controller/Front.php';
- $this->_frontController = Zend_Controller_Front::getInstance();
- }
-
- return $this->_frontController;
- }
-
- /**
- * Set front controller instance
- *
- * @param Zend_Controller_Front $controller
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setFrontController(Zend_Controller_Front $controller)
- {
- $this->_frontController = $controller;
- return $this;
- }
-
- /**
- * Add or modify a parameter to use when instantiating an action controller
- *
- * @param string $name
- * @param mixed $value
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setParam($name, $value)
- {
- $name = (string) $name;
- $this->_invokeParams[$name] = $value;
- return $this;
- }
-
- /**
- * Set parameters to pass to action controller constructors
- *
- * @param array $params
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setParams(array $params)
- {
- $this->_invokeParams = array_merge($this->_invokeParams, $params);
- return $this;
- }
-
- /**
- * Retrieve a single parameter from the controller parameter stack
- *
- * @param string $name
- * @return mixed
- */
- public function getParam($name)
- {
- if(isset($this->_invokeParams[$name])) {
- return $this->_invokeParams[$name];
- }
-
- return null;
- }
-
- /**
- * Retrieve action controller instantiation parameters
- *
- * @return array
- */
- public function getParams()
- {
- return $this->_invokeParams;
- }
-
- /**
- * Clear the controller parameter stack
- *
- * By default, clears all parameters. If a parameter name is given, clears
- * only that parameter; if an array of parameter names is provided, clears
- * each.
- *
- * @param null|string|array single key or array of keys for params to clear
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function clearParams($name = null)
- {
- if (null === $name) {
- $this->_invokeParams = array();
- } elseif (is_string($name) && isset($this->_invokeParams[$name])) {
- unset($this->_invokeParams[$name]);
- } elseif (is_array($name)) {
- foreach ($name as $key) {
- if (is_string($key) && isset($this->_invokeParams[$key])) {
- unset($this->_invokeParams[$key]);
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Set response object to pass to action controllers
- *
- * @param Zend_Controller_Response_Abstract|null $response
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setResponse(Zend_Controller_Response_Abstract $response = null)
- {
- $this->_response = $response;
- return $this;
- }
-
- /**
- * Return the registered response object
- *
- * @return Zend_Controller_Response_Abstract|null
- */
- public function getResponse()
- {
- return $this->_response;
- }
-
- /**
- * Set the default controller (minus any formatting)
- *
- * @param string $controller
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setDefaultControllerName($controller)
- {
- $this->_defaultController = (string) $controller;
- return $this;
- }
-
- /**
- * Retrieve the default controller name (minus formatting)
- *
- * @return string
- */
- public function getDefaultControllerName()
- {
- return $this->_defaultController;
- }
-
- /**
- * Set the default action (minus any formatting)
- *
- * @param string $action
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setDefaultAction($action)
- {
- $this->_defaultAction = (string) $action;
- return $this;
- }
-
- /**
- * Retrieve the default action name (minus formatting)
- *
- * @return string
- */
- public function getDefaultAction()
- {
- return $this->_defaultAction;
- }
-
- /**
- * Set the default module
- *
- * @param string $module
- * @return Zend_Controller_Dispatcher_Abstract
- */
- public function setDefaultModule($module)
- {
- $this->_defaultModule = (string) $module;
- return $this;
- }
-
- /**
- * Retrieve the default module
- *
- * @return string
- */
- public function getDefaultModule()
- {
- return $this->_defaultModule;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Dispatcher/Exception.php zendframework-2.2.6/library/Zend/Controller/Dispatcher/Exception.php
--- zendframework-1.10.4/library/Zend/Controller/Dispatcher/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Dispatcher/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,37 +0,0 @@
-_curModule = $this->getDefaultModule();
- }
-
- /**
- * Add a single path to the controller directory stack
- *
- * @param string $path
- * @param string $module
- * @return Zend_Controller_Dispatcher_Standard
- */
- public function addControllerDirectory($path, $module = null)
- {
- if (null === $module) {
- $module = $this->_defaultModule;
- }
-
- $module = (string) $module;
- $path = rtrim((string) $path, '/\\');
-
- $this->_controllerDirectory[$module] = $path;
- return $this;
- }
-
- /**
- * Set controller directory
- *
- * @param array|string $directory
- * @return Zend_Controller_Dispatcher_Standard
- */
- public function setControllerDirectory($directory, $module = null)
- {
- $this->_controllerDirectory = array();
-
- if (is_string($directory)) {
- $this->addControllerDirectory($directory, $module);
- } elseif (is_array($directory)) {
- foreach ((array) $directory as $module => $path) {
- $this->addControllerDirectory($path, $module);
- }
- } else {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Controller directory spec must be either a string or an array');
- }
-
- return $this;
- }
-
- /**
- * Return the currently set directories for Zend_Controller_Action class
- * lookup
- *
- * If a module is specified, returns just that directory.
- *
- * @param string $module Module name
- * @return array|string Returns array of all directories by default, single
- * module directory if module argument provided
- */
- public function getControllerDirectory($module = null)
- {
- if (null === $module) {
- return $this->_controllerDirectory;
- }
-
- $module = (string) $module;
- if (array_key_exists($module, $this->_controllerDirectory)) {
- return $this->_controllerDirectory[$module];
- }
-
- return null;
- }
-
- /**
- * Remove a controller directory by module name
- *
- * @param string $module
- * @return bool
- */
- public function removeControllerDirectory($module)
- {
- $module = (string) $module;
- if (array_key_exists($module, $this->_controllerDirectory)) {
- unset($this->_controllerDirectory[$module]);
- return true;
- }
- return false;
- }
-
- /**
- * Format the module name.
- *
- * @param string $unformatted
- * @return string
- */
- public function formatModuleName($unformatted)
- {
- if (($this->_defaultModule == $unformatted) && !$this->getParam('prefixDefaultModule')) {
- return $unformatted;
- }
-
- return ucfirst($this->_formatName($unformatted));
- }
-
- /**
- * Format action class name
- *
- * @param string $moduleName Name of the current module
- * @param string $className Name of the action class
- * @return string Formatted class name
- */
- public function formatClassName($moduleName, $className)
- {
- return $this->formatModuleName($moduleName) . '_' . $className;
- }
-
- /**
- * Convert a class name to a filename
- *
- * @param string $class
- * @return string
- */
- public function classToFilename($class)
- {
- return str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
- }
-
- /**
- * Returns TRUE if the Zend_Controller_Request_Abstract object can be
- * dispatched to a controller.
- *
- * Use this method wisely. By default, the dispatcher will fall back to the
- * default controller (either in the module specified or the global default)
- * if a given controller does not exist. This method returning false does
- * not necessarily indicate the dispatcher will not still dispatch the call.
- *
- * @param Zend_Controller_Request_Abstract $action
- * @return boolean
- */
- public function isDispatchable(Zend_Controller_Request_Abstract $request)
- {
- $className = $this->getControllerClass($request);
- if (!$className) {
- return false;
- }
-
- if (class_exists($className, false)) {
- return true;
- }
-
- $fileSpec = $this->classToFilename($className);
- $dispatchDir = $this->getDispatchDirectory();
- $test = $dispatchDir . DIRECTORY_SEPARATOR . $fileSpec;
- return Zend_Loader::isReadable($test);
- }
-
- /**
- * Dispatch to a controller/action
- *
- * By default, if a controller is not dispatchable, dispatch() will throw
- * an exception. If you wish to use the default controller instead, set the
- * param 'useDefaultControllerAlways' via {@link setParam()}.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @param Zend_Controller_Response_Abstract $response
- * @return void
- * @throws Zend_Controller_Dispatcher_Exception
- */
- public function dispatch(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response)
- {
- $this->setResponse($response);
-
- /**
- * Get controller class
- */
- if (!$this->isDispatchable($request)) {
- $controller = $request->getControllerName();
- if (!$this->getParam('useDefaultControllerAlways') && !empty($controller)) {
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception('Invalid controller specified (' . $request->getControllerName() . ')');
- }
-
- $className = $this->getDefaultControllerClass($request);
- } else {
- $className = $this->getControllerClass($request);
- if (!$className) {
- $className = $this->getDefaultControllerClass($request);
- }
- }
-
- /**
- * Load the controller class file
- */
- $className = $this->loadClass($className);
-
- /**
- * Instantiate controller with request, response, and invocation
- * arguments; throw exception if it's not an action controller
- */
- $controller = new $className($request, $this->getResponse(), $this->getParams());
- if (!($controller instanceof Zend_Controller_Action_Interface) &&
- !($controller instanceof Zend_Controller_Action)) {
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception(
- 'Controller "' . $className . '" is not an instance of Zend_Controller_Action_Interface'
- );
- }
-
- /**
- * Retrieve the action name
- */
- $action = $this->getActionMethod($request);
-
- /**
- * Dispatch the method call
- */
- $request->setDispatched(true);
-
- // by default, buffer output
- $disableOb = $this->getParam('disableOutputBuffering');
- $obLevel = ob_get_level();
- if (empty($disableOb)) {
- ob_start();
- }
-
- try {
- $controller->dispatch($action);
- } catch (Exception $e) {
- // Clean output buffer on error
- $curObLevel = ob_get_level();
- if ($curObLevel > $obLevel) {
- do {
- ob_get_clean();
- $curObLevel = ob_get_level();
- } while ($curObLevel > $obLevel);
- }
- throw $e;
- }
-
- if (empty($disableOb)) {
- $content = ob_get_clean();
- $response->appendBody($content);
- }
-
- // Destroy the page controller instance and reflection objects
- $controller = null;
- }
-
- /**
- * Load a controller class
- *
- * Attempts to load the controller class file from
- * {@link getControllerDirectory()}. If the controller belongs to a
- * module, looks for the module prefix to the controller class.
- *
- * @param string $className
- * @return string Class name loaded
- * @throws Zend_Controller_Dispatcher_Exception if class not loaded
- */
- public function loadClass($className)
- {
- $finalClass = $className;
- if (($this->_defaultModule != $this->_curModule)
- || $this->getParam('prefixDefaultModule'))
- {
- $finalClass = $this->formatClassName($this->_curModule, $className);
- }
- if (class_exists($finalClass, false)) {
- return $finalClass;
- }
-
- $dispatchDir = $this->getDispatchDirectory();
- $loadFile = $dispatchDir . DIRECTORY_SEPARATOR . $this->classToFilename($className);
-
- if (Zend_Loader::isReadable($loadFile)) {
- include_once $loadFile;
- } else {
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception('Cannot load controller class "' . $className . '" from file "' . $loadFile . "'");
- }
-
- if (!class_exists($finalClass, false)) {
- require_once 'Zend/Controller/Dispatcher/Exception.php';
- throw new Zend_Controller_Dispatcher_Exception('Invalid controller class ("' . $finalClass . '")');
- }
-
- return $finalClass;
- }
-
- /**
- * Get controller class name
- *
- * Try request first; if not found, try pulling from request parameter;
- * if still not found, fallback to default
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return string|false Returns class name on success
- */
- public function getControllerClass(Zend_Controller_Request_Abstract $request)
- {
- $controllerName = $request->getControllerName();
- if (empty($controllerName)) {
- if (!$this->getParam('useDefaultControllerAlways')) {
- return false;
- }
- $controllerName = $this->getDefaultControllerName();
- $request->setControllerName($controllerName);
- }
-
- $className = $this->formatControllerName($controllerName);
-
- $controllerDirs = $this->getControllerDirectory();
- $module = $request->getModuleName();
- if ($this->isValidModule($module)) {
- $this->_curModule = $module;
- $this->_curDirectory = $controllerDirs[$module];
- } elseif ($this->isValidModule($this->_defaultModule)) {
- $request->setModuleName($this->_defaultModule);
- $this->_curModule = $this->_defaultModule;
- $this->_curDirectory = $controllerDirs[$this->_defaultModule];
- } else {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('No default module defined for this application');
- }
-
- return $className;
- }
-
- /**
- * Determine if a given module is valid
- *
- * @param string $module
- * @return bool
- */
- public function isValidModule($module)
- {
- if (!is_string($module)) {
- return false;
- }
-
- $module = strtolower($module);
- $controllerDir = $this->getControllerDirectory();
- foreach (array_keys($controllerDir) as $moduleName) {
- if ($module == strtolower($moduleName)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Retrieve default controller class
- *
- * Determines whether the default controller to use lies within the
- * requested module, or if the global default should be used.
- *
- * By default, will only use the module default unless that controller does
- * not exist; if this is the case, it falls back to the default controller
- * in the default module.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return string
- */
- public function getDefaultControllerClass(Zend_Controller_Request_Abstract $request)
- {
- $controller = $this->getDefaultControllerName();
- $default = $this->formatControllerName($controller);
- $request->setControllerName($controller)
- ->setActionName(null);
-
- $module = $request->getModuleName();
- $controllerDirs = $this->getControllerDirectory();
- $this->_curModule = $this->_defaultModule;
- $this->_curDirectory = $controllerDirs[$this->_defaultModule];
- if ($this->isValidModule($module)) {
- $found = false;
- if (class_exists($default, false)) {
- $found = true;
- } else {
- $moduleDir = $controllerDirs[$module];
- $fileSpec = $moduleDir . DIRECTORY_SEPARATOR . $this->classToFilename($default);
- if (Zend_Loader::isReadable($fileSpec)) {
- $found = true;
- $this->_curDirectory = $moduleDir;
- }
- }
- if ($found) {
- $request->setModuleName($module);
- $this->_curModule = $this->formatModuleName($module);
- }
- } else {
- $request->setModuleName($this->_defaultModule);
- }
-
- return $default;
- }
-
- /**
- * Return the value of the currently selected dispatch directory (as set by
- * {@link getController()})
- *
- * @return string
- */
- public function getDispatchDirectory()
- {
- return $this->_curDirectory;
- }
-
- /**
- * Determine the action name
- *
- * First attempt to retrieve from request; then from request params
- * using action key; default to default action
- *
- * Returns formatted action name
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return string
- */
- public function getActionMethod(Zend_Controller_Request_Abstract $request)
- {
- $action = $request->getActionName();
- if (empty($action)) {
- $action = $this->getDefaultAction();
- $request->setActionName($action);
- }
-
- return $this->formatActionName($action);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Exception.php zendframework-2.2.6/library/Zend/Controller/Exception.php
--- zendframework-1.10.4/library/Zend/Controller/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,35 +0,0 @@
-_plugins = new Zend_Controller_Plugin_Broker();
- }
-
- /**
- * Enforce singleton; disallow cloning
- *
- * @return void
- */
- private function __clone()
- {
- }
-
- /**
- * Singleton instance
- *
- * @return Zend_Controller_Front
- */
- public static function getInstance()
- {
- if (null === self::$_instance) {
- self::$_instance = new self();
- }
-
- return self::$_instance;
- }
-
- /**
- * Resets all object properties of the singleton instance
- *
- * Primarily used for testing; could be used to chain front controllers.
- *
- * Also resets action helper broker, clearing all registered helpers.
- *
- * @return void
- */
- public function resetInstance()
- {
- $reflection = new ReflectionObject($this);
- foreach ($reflection->getProperties() as $property) {
- $name = $property->getName();
- switch ($name) {
- case '_instance':
- break;
- case '_controllerDir':
- case '_invokeParams':
- $this->{$name} = array();
- break;
- case '_plugins':
- $this->{$name} = new Zend_Controller_Plugin_Broker();
- break;
- case '_throwExceptions':
- case '_returnResponse':
- $this->{$name} = false;
- break;
- case '_moduleControllerDirectoryName':
- $this->{$name} = 'controllers';
- break;
- default:
- $this->{$name} = null;
- break;
- }
- }
- Zend_Controller_Action_HelperBroker::resetHelpers();
- }
-
- /**
- * Convenience feature, calls setControllerDirectory()->setRouter()->dispatch()
- *
- * In PHP 5.1.x, a call to a static method never populates $this -- so run()
- * may actually be called after setting up your front controller.
- *
- * @param string|array $controllerDirectory Path to Zend_Controller_Action
- * controller classes or array of such paths
- * @return void
- * @throws Zend_Controller_Exception if called from an object instance
- */
- public static function run($controllerDirectory)
- {
- self::getInstance()
- ->setControllerDirectory($controllerDirectory)
- ->dispatch();
- }
-
- /**
- * Add a controller directory to the controller directory stack
- *
- * If $args is presented and is a string, uses it for the array key mapping
- * to the directory specified.
- *
- * @param string $directory
- * @param string $module Optional argument; module with which to associate directory. If none provided, assumes 'default'
- * @return Zend_Controller_Front
- * @throws Zend_Controller_Exception if directory not found or readable
- */
- public function addControllerDirectory($directory, $module = null)
- {
- $this->getDispatcher()->addControllerDirectory($directory, $module);
- return $this;
- }
-
- /**
- * Set controller directory
- *
- * Stores controller directory(ies) in dispatcher. May be an array of
- * directories or a string containing a single directory.
- *
- * @param string|array $directory Path to Zend_Controller_Action controller
- * classes or array of such paths
- * @param string $module Optional module name to use with string $directory
- * @return Zend_Controller_Front
- */
- public function setControllerDirectory($directory, $module = null)
- {
- $this->getDispatcher()->setControllerDirectory($directory, $module);
- return $this;
- }
-
- /**
- * Retrieve controller directory
- *
- * Retrieves:
- * - Array of all controller directories if no $name passed
- * - String path if $name passed and exists as a key in controller directory array
- * - null if $name passed but does not exist in controller directory keys
- *
- * @param string $name Default null
- * @return array|string|null
- */
- public function getControllerDirectory($name = null)
- {
- return $this->getDispatcher()->getControllerDirectory($name);
- }
-
- /**
- * Remove a controller directory by module name
- *
- * @param string $module
- * @return bool
- */
- public function removeControllerDirectory($module)
- {
- return $this->getDispatcher()->removeControllerDirectory($module);
- }
-
- /**
- * Specify a directory as containing modules
- *
- * Iterates through the directory, adding any subdirectories as modules;
- * the subdirectory within each module named after {@link $_moduleControllerDirectoryName}
- * will be used as the controller directory path.
- *
- * @param string $path
- * @return Zend_Controller_Front
- */
- public function addModuleDirectory($path)
- {
- try{
- $dir = new DirectoryIterator($path);
- } catch(Exception $e) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception("Directory $path not readable", 0, $e);
- }
- foreach ($dir as $file) {
- if ($file->isDot() || !$file->isDir()) {
- continue;
- }
-
- $module = $file->getFilename();
-
- // Don't use SCCS directories as modules
- if (preg_match('/^[^a-z]/i', $module) || ('CVS' == $module)) {
- continue;
- }
-
- $moduleDir = $file->getPathname() . DIRECTORY_SEPARATOR . $this->getModuleControllerDirectoryName();
- $this->addControllerDirectory($moduleDir, $module);
- }
-
- return $this;
- }
-
- /**
- * Return the path to a module directory (but not the controllers directory within)
- *
- * @param string $module
- * @return string|null
- */
- public function getModuleDirectory($module = null)
- {
- if (null === $module) {
- $request = $this->getRequest();
- if (null !== $request) {
- $module = $this->getRequest()->getModuleName();
- }
- if (empty($module)) {
- $module = $this->getDispatcher()->getDefaultModule();
- }
- }
-
- $controllerDir = $this->getControllerDirectory($module);
-
- if ((null === $controllerDir) || !is_string($controllerDir)) {
- return null;
- }
-
- return dirname($controllerDir);
- }
-
- /**
- * Set the directory name within a module containing controllers
- *
- * @param string $name
- * @return Zend_Controller_Front
- */
- public function setModuleControllerDirectoryName($name = 'controllers')
- {
- $this->_moduleControllerDirectoryName = (string) $name;
-
- return $this;
- }
-
- /**
- * Return the directory name within a module containing controllers
- *
- * @return string
- */
- public function getModuleControllerDirectoryName()
- {
- return $this->_moduleControllerDirectoryName;
- }
-
- /**
- * Set the default controller (unformatted string)
- *
- * @param string $controller
- * @return Zend_Controller_Front
- */
- public function setDefaultControllerName($controller)
- {
- $dispatcher = $this->getDispatcher();
- $dispatcher->setDefaultControllerName($controller);
- return $this;
- }
-
- /**
- * Retrieve the default controller (unformatted string)
- *
- * @return string
- */
- public function getDefaultControllerName()
- {
- return $this->getDispatcher()->getDefaultControllerName();
- }
-
- /**
- * Set the default action (unformatted string)
- *
- * @param string $action
- * @return Zend_Controller_Front
- */
- public function setDefaultAction($action)
- {
- $dispatcher = $this->getDispatcher();
- $dispatcher->setDefaultAction($action);
- return $this;
- }
-
- /**
- * Retrieve the default action (unformatted string)
- *
- * @return string
- */
- public function getDefaultAction()
- {
- return $this->getDispatcher()->getDefaultAction();
- }
-
- /**
- * Set the default module name
- *
- * @param string $module
- * @return Zend_Controller_Front
- */
- public function setDefaultModule($module)
- {
- $dispatcher = $this->getDispatcher();
- $dispatcher->setDefaultModule($module);
- return $this;
- }
-
- /**
- * Retrieve the default module
- *
- * @return string
- */
- public function getDefaultModule()
- {
- return $this->getDispatcher()->getDefaultModule();
- }
-
- /**
- * Set request class/object
- *
- * Set the request object. The request holds the request environment.
- *
- * If a class name is provided, it will instantiate it
- *
- * @param string|Zend_Controller_Request_Abstract $request
- * @throws Zend_Controller_Exception if invalid request class
- * @return Zend_Controller_Front
- */
- public function setRequest($request)
- {
- if (is_string($request)) {
- if (!class_exists($request)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($request);
- }
- $request = new $request();
- }
- if (!$request instanceof Zend_Controller_Request_Abstract) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid request class');
- }
-
- $this->_request = $request;
-
- return $this;
- }
-
- /**
- * Return the request object.
- *
- * @return null|Zend_Controller_Request_Abstract
- */
- public function getRequest()
- {
- return $this->_request;
- }
-
- /**
- * Set router class/object
- *
- * Set the router object. The router is responsible for mapping
- * the request to a controller and action.
- *
- * If a class name is provided, instantiates router with any parameters
- * registered via {@link setParam()} or {@link setParams()}.
- *
- * @param string|Zend_Controller_Router_Interface $router
- * @throws Zend_Controller_Exception if invalid router class
- * @return Zend_Controller_Front
- */
- public function setRouter($router)
- {
- if (is_string($router)) {
- if (!class_exists($router)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($router);
- }
- $router = new $router();
- }
-
- if (!$router instanceof Zend_Controller_Router_Interface) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid router class');
- }
-
- $router->setFrontController($this);
- $this->_router = $router;
-
- return $this;
- }
-
- /**
- * Return the router object.
- *
- * Instantiates a Zend_Controller_Router_Rewrite object if no router currently set.
- *
- * @return Zend_Controller_Router_Interface
- */
- public function getRouter()
- {
- if (null == $this->_router) {
- require_once 'Zend/Controller/Router/Rewrite.php';
- $this->setRouter(new Zend_Controller_Router_Rewrite());
- }
-
- return $this->_router;
- }
-
- /**
- * Set the base URL used for requests
- *
- * Use to set the base URL segment of the REQUEST_URI to use when
- * determining PATH_INFO, etc. Examples:
- * - /admin
- * - /myapp
- * - /subdir/index.php
- *
- * Note that the URL should not include the full URI. Do not use:
- * - http://example.com/admin
- * - http://example.com/myapp
- * - http://example.com/subdir/index.php
- *
- * If a null value is passed, this can be used as well for autodiscovery (default).
- *
- * @param string $base
- * @return Zend_Controller_Front
- * @throws Zend_Controller_Exception for non-string $base
- */
- public function setBaseUrl($base = null)
- {
- if (!is_string($base) && (null !== $base)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Rewrite base must be a string');
- }
-
- $this->_baseUrl = $base;
-
- if ((null !== ($request = $this->getRequest())) && (method_exists($request, 'setBaseUrl'))) {
- $request->setBaseUrl($base);
- }
-
- return $this;
- }
-
- /**
- * Retrieve the currently set base URL
- *
- * @return string
- */
- public function getBaseUrl()
- {
- $request = $this->getRequest();
- if ((null !== $request) && method_exists($request, 'getBaseUrl')) {
- return $request->getBaseUrl();
- }
-
- return $this->_baseUrl;
- }
-
- /**
- * Set the dispatcher object. The dispatcher is responsible for
- * taking a Zend_Controller_Dispatcher_Token object, instantiating the controller, and
- * call the action method of the controller.
- *
- * @param Zend_Controller_Dispatcher_Interface $dispatcher
- * @return Zend_Controller_Front
- */
- public function setDispatcher(Zend_Controller_Dispatcher_Interface $dispatcher)
- {
- $this->_dispatcher = $dispatcher;
- return $this;
- }
-
- /**
- * Return the dispatcher object.
- *
- * @return Zend_Controller_Dispatcher_Interface
- */
- public function getDispatcher()
- {
- /**
- * Instantiate the default dispatcher if one was not set.
- */
- if (!$this->_dispatcher instanceof Zend_Controller_Dispatcher_Interface) {
- require_once 'Zend/Controller/Dispatcher/Standard.php';
- $this->_dispatcher = new Zend_Controller_Dispatcher_Standard();
- }
- return $this->_dispatcher;
- }
-
- /**
- * Set response class/object
- *
- * Set the response object. The response is a container for action
- * responses and headers. Usage is optional.
- *
- * If a class name is provided, instantiates a response object.
- *
- * @param string|Zend_Controller_Response_Abstract $response
- * @throws Zend_Controller_Exception if invalid response class
- * @return Zend_Controller_Front
- */
- public function setResponse($response)
- {
- if (is_string($response)) {
- if (!class_exists($response)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($response);
- }
- $response = new $response();
- }
- if (!$response instanceof Zend_Controller_Response_Abstract) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid response class');
- }
-
- $this->_response = $response;
-
- return $this;
- }
-
- /**
- * Return the response object.
- *
- * @return null|Zend_Controller_Response_Abstract
- */
- public function getResponse()
- {
- return $this->_response;
- }
-
- /**
- * Add or modify a parameter to use when instantiating an action controller
- *
- * @param string $name
- * @param mixed $value
- * @return Zend_Controller_Front
- */
- public function setParam($name, $value)
- {
- $name = (string) $name;
- $this->_invokeParams[$name] = $value;
- return $this;
- }
-
- /**
- * Set parameters to pass to action controller constructors
- *
- * @param array $params
- * @return Zend_Controller_Front
- */
- public function setParams(array $params)
- {
- $this->_invokeParams = array_merge($this->_invokeParams, $params);
- return $this;
- }
-
- /**
- * Retrieve a single parameter from the controller parameter stack
- *
- * @param string $name
- * @return mixed
- */
- public function getParam($name)
- {
- if(isset($this->_invokeParams[$name])) {
- return $this->_invokeParams[$name];
- }
-
- return null;
- }
-
- /**
- * Retrieve action controller instantiation parameters
- *
- * @return array
- */
- public function getParams()
- {
- return $this->_invokeParams;
- }
-
- /**
- * Clear the controller parameter stack
- *
- * By default, clears all parameters. If a parameter name is given, clears
- * only that parameter; if an array of parameter names is provided, clears
- * each.
- *
- * @param null|string|array single key or array of keys for params to clear
- * @return Zend_Controller_Front
- */
- public function clearParams($name = null)
- {
- if (null === $name) {
- $this->_invokeParams = array();
- } elseif (is_string($name) && isset($this->_invokeParams[$name])) {
- unset($this->_invokeParams[$name]);
- } elseif (is_array($name)) {
- foreach ($name as $key) {
- if (is_string($key) && isset($this->_invokeParams[$key])) {
- unset($this->_invokeParams[$key]);
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Register a plugin.
- *
- * @param Zend_Controller_Plugin_Abstract $plugin
- * @param int $stackIndex Optional; stack index for plugin
- * @return Zend_Controller_Front
- */
- public function registerPlugin(Zend_Controller_Plugin_Abstract $plugin, $stackIndex = null)
- {
- $this->_plugins->registerPlugin($plugin, $stackIndex);
- return $this;
- }
-
- /**
- * Unregister a plugin.
- *
- * @param string|Zend_Controller_Plugin_Abstract $plugin Plugin class or object to unregister
- * @return Zend_Controller_Front
- */
- public function unregisterPlugin($plugin)
- {
- $this->_plugins->unregisterPlugin($plugin);
- return $this;
- }
-
- /**
- * Is a particular plugin registered?
- *
- * @param string $class
- * @return bool
- */
- public function hasPlugin($class)
- {
- return $this->_plugins->hasPlugin($class);
- }
-
- /**
- * Retrieve a plugin or plugins by class
- *
- * @param string $class
- * @return false|Zend_Controller_Plugin_Abstract|array
- */
- public function getPlugin($class)
- {
- return $this->_plugins->getPlugin($class);
- }
-
- /**
- * Retrieve all plugins
- *
- * @return array
- */
- public function getPlugins()
- {
- return $this->_plugins->getPlugins();
- }
-
- /**
- * Set the throwExceptions flag and retrieve current status
- *
- * Set whether exceptions encounted in the dispatch loop should be thrown
- * or caught and trapped in the response object.
- *
- * Default behaviour is to trap them in the response object; call this
- * method to have them thrown.
- *
- * Passing no value will return the current value of the flag; passing a
- * boolean true or false value will set the flag and return the current
- * object instance.
- *
- * @param boolean $flag Defaults to null (return flag state)
- * @return boolean|Zend_Controller_Front Used as a setter, returns object; as a getter, returns boolean
- */
- public function throwExceptions($flag = null)
- {
- if ($flag !== null) {
- $this->_throwExceptions = (bool) $flag;
- return $this;
- }
-
- return $this->_throwExceptions;
- }
-
- /**
- * Set whether {@link dispatch()} should return the response without first
- * rendering output. By default, output is rendered and dispatch() returns
- * nothing.
- *
- * @param boolean $flag
- * @return boolean|Zend_Controller_Front Used as a setter, returns object; as a getter, returns boolean
- */
- public function returnResponse($flag = null)
- {
- if (true === $flag) {
- $this->_returnResponse = true;
- return $this;
- } elseif (false === $flag) {
- $this->_returnResponse = false;
- return $this;
- }
-
- return $this->_returnResponse;
- }
-
- /**
- * Dispatch an HTTP request to a controller/action.
- *
- * @param Zend_Controller_Request_Abstract|null $request
- * @param Zend_Controller_Response_Abstract|null $response
- * @return void|Zend_Controller_Response_Abstract Returns response object if returnResponse() is true
- */
- public function dispatch(Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null)
- {
- if (!$this->getParam('noErrorHandler') && !$this->_plugins->hasPlugin('Zend_Controller_Plugin_ErrorHandler')) {
- // Register with stack index of 100
- require_once 'Zend/Controller/Plugin/ErrorHandler.php';
- $this->_plugins->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(), 100);
- }
-
- if (!$this->getParam('noViewRenderer') && !Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) {
- require_once 'Zend/Controller/Action/Helper/ViewRenderer.php';
- Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-80, new Zend_Controller_Action_Helper_ViewRenderer());
- }
-
- /**
- * Instantiate default request object (HTTP version) if none provided
- */
- if (null !== $request) {
- $this->setRequest($request);
- } elseif ((null === $request) && (null === ($request = $this->getRequest()))) {
- require_once 'Zend/Controller/Request/Http.php';
- $request = new Zend_Controller_Request_Http();
- $this->setRequest($request);
- }
-
- /**
- * Set base URL of request object, if available
- */
- if (is_callable(array($this->_request, 'setBaseUrl'))) {
- if (null !== $this->_baseUrl) {
- $this->_request->setBaseUrl($this->_baseUrl);
- }
- }
-
- /**
- * Instantiate default response object (HTTP version) if none provided
- */
- if (null !== $response) {
- $this->setResponse($response);
- } elseif ((null === $this->_response) && (null === ($this->_response = $this->getResponse()))) {
- require_once 'Zend/Controller/Response/Http.php';
- $response = new Zend_Controller_Response_Http();
- $this->setResponse($response);
- }
-
- /**
- * Register request and response objects with plugin broker
- */
- $this->_plugins
- ->setRequest($this->_request)
- ->setResponse($this->_response);
-
- /**
- * Initialize router
- */
- $router = $this->getRouter();
- $router->setParams($this->getParams());
-
- /**
- * Initialize dispatcher
- */
- $dispatcher = $this->getDispatcher();
- $dispatcher->setParams($this->getParams())
- ->setResponse($this->_response);
-
- // Begin dispatch
- try {
- /**
- * Route request to controller/action, if a router is provided
- */
-
- /**
- * Notify plugins of router startup
- */
- $this->_plugins->routeStartup($this->_request);
-
- try {
- $router->route($this->_request);
- } catch (Exception $e) {
- if ($this->throwExceptions()) {
- throw $e;
- }
-
- $this->_response->setException($e);
- }
-
- /**
- * Notify plugins of router completion
- */
- $this->_plugins->routeShutdown($this->_request);
-
- /**
- * Notify plugins of dispatch loop startup
- */
- $this->_plugins->dispatchLoopStartup($this->_request);
-
- /**
- * Attempt to dispatch the controller/action. If the $this->_request
- * indicates that it needs to be dispatched, move to the next
- * action in the request.
- */
- do {
- $this->_request->setDispatched(true);
-
- /**
- * Notify plugins of dispatch startup
- */
- $this->_plugins->preDispatch($this->_request);
-
- /**
- * Skip requested action if preDispatch() has reset it
- */
- if (!$this->_request->isDispatched()) {
- continue;
- }
-
- /**
- * Dispatch request
- */
- try {
- $dispatcher->dispatch($this->_request, $this->_response);
- } catch (Exception $e) {
- if ($this->throwExceptions()) {
- throw $e;
- }
- $this->_response->setException($e);
- }
-
- /**
- * Notify plugins of dispatch completion
- */
- $this->_plugins->postDispatch($this->_request);
- } while (!$this->_request->isDispatched());
- } catch (Exception $e) {
- if ($this->throwExceptions()) {
- throw $e;
- }
-
- $this->_response->setException($e);
- }
-
- /**
- * Notify plugins of dispatch loop completion
- */
- try {
- $this->_plugins->dispatchLoopShutdown();
- } catch (Exception $e) {
- if ($this->throwExceptions()) {
- throw $e;
- }
-
- $this->_response->setException($e);
- }
-
- if ($this->returnResponse()) {
- return $this->_response;
- }
-
- $this->_response->sendResponse();
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Plugin/Abstract.php zendframework-2.2.6/library/Zend/Controller/Plugin/Abstract.php
--- zendframework-1.10.4/library/Zend/Controller/Plugin/Abstract.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Plugin/Abstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,151 +0,0 @@
-_request = $request;
- return $this;
- }
-
- /**
- * Get request object
- *
- * @return Zend_Controller_Request_Abstract $request
- */
- public function getRequest()
- {
- return $this->_request;
- }
-
- /**
- * Set response object
- *
- * @param Zend_Controller_Response_Abstract $response
- * @return Zend_Controller_Plugin_Abstract
- */
- public function setResponse(Zend_Controller_Response_Abstract $response)
- {
- $this->_response = $response;
- return $this;
- }
-
- /**
- * Get response object
- *
- * @return Zend_Controller_Response_Abstract $response
- */
- public function getResponse()
- {
- return $this->_response;
- }
-
- /**
- * Called before Zend_Controller_Front begins evaluating the
- * request against its routes.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function routeStartup(Zend_Controller_Request_Abstract $request)
- {}
-
- /**
- * Called after Zend_Controller_Router exits.
- *
- * Called after Zend_Controller_Front exits from the router.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function routeShutdown(Zend_Controller_Request_Abstract $request)
- {}
-
- /**
- * Called before Zend_Controller_Front enters its dispatch loop.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
- {}
-
- /**
- * Called before an action is dispatched by Zend_Controller_Dispatcher.
- *
- * This callback allows for proxy or filter behavior. By altering the
- * request and resetting its dispatched flag (via
- * {@link Zend_Controller_Request_Abstract::setDispatched() setDispatched(false)}),
- * the current action may be skipped.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function preDispatch(Zend_Controller_Request_Abstract $request)
- {}
-
- /**
- * Called after an action is dispatched by Zend_Controller_Dispatcher.
- *
- * This callback allows for proxy or filter behavior. By altering the
- * request and resetting its dispatched flag (via
- * {@link Zend_Controller_Request_Abstract::setDispatched() setDispatched(false)}),
- * a new action may be specified for dispatching.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function postDispatch(Zend_Controller_Request_Abstract $request)
- {}
-
- /**
- * Called before Zend_Controller_Front exits its dispatch loop.
- *
- * @return void
- */
- public function dispatchLoopShutdown()
- {}
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Plugin/ActionStack.php zendframework-2.2.6/library/Zend/Controller/Plugin/ActionStack.php
--- zendframework-1.10.4/library/Zend/Controller/Plugin/ActionStack.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Plugin/ActionStack.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,280 +0,0 @@
-setRegistry($registry);
-
- if (null !== $key) {
- $this->setRegistryKey($key);
- } else {
- $key = $this->getRegistryKey();
- }
-
- $registry[$key] = array();
- }
-
- /**
- * Set registry object
- *
- * @param Zend_Registry $registry
- * @return Zend_Controller_Plugin_ActionStack
- */
- public function setRegistry(Zend_Registry $registry)
- {
- $this->_registry = $registry;
- return $this;
- }
-
- /**
- * Retrieve registry object
- *
- * @return Zend_Registry
- */
- public function getRegistry()
- {
- return $this->_registry;
- }
-
- /**
- * Retrieve registry key
- *
- * @return string
- */
- public function getRegistryKey()
- {
- return $this->_registryKey;
- }
-
- /**
- * Set registry key
- *
- * @param string $key
- * @return Zend_Controller_Plugin_ActionStack
- */
- public function setRegistryKey($key)
- {
- $this->_registryKey = (string) $key;
- return $this;
- }
-
- /**
- * Set clearRequestParams flag
- *
- * @param bool $clearRequestParams
- * @return Zend_Controller_Plugin_ActionStack
- */
- public function setClearRequestParams($clearRequestParams)
- {
- $this->_clearRequestParams = (bool) $clearRequestParams;
- return $this;
- }
-
- /**
- * Retrieve clearRequestParams flag
- *
- * @return bool
- */
- public function getClearRequestParams()
- {
- return $this->_clearRequestParams;
- }
-
- /**
- * Retrieve action stack
- *
- * @return array
- */
- public function getStack()
- {
- $registry = $this->getRegistry();
- $stack = $registry[$this->getRegistryKey()];
- return $stack;
- }
-
- /**
- * Save stack to registry
- *
- * @param array $stack
- * @return Zend_Controller_Plugin_ActionStack
- */
- protected function _saveStack(array $stack)
- {
- $registry = $this->getRegistry();
- $registry[$this->getRegistryKey()] = $stack;
- return $this;
- }
-
- /**
- * Push an item onto the stack
- *
- * @param Zend_Controller_Request_Abstract $next
- * @return Zend_Controller_Plugin_ActionStack
- */
- public function pushStack(Zend_Controller_Request_Abstract $next)
- {
- $stack = $this->getStack();
- array_push($stack, $next);
- return $this->_saveStack($stack);
- }
-
- /**
- * Pop an item off the action stack
- *
- * @return false|Zend_Controller_Request_Abstract
- */
- public function popStack()
- {
- $stack = $this->getStack();
- if (0 == count($stack)) {
- return false;
- }
-
- $next = array_pop($stack);
- $this->_saveStack($stack);
-
- if (!$next instanceof Zend_Controller_Request_Abstract) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('ArrayStack should only contain request objects');
- }
- $action = $next->getActionName();
- if (empty($action)) {
- return $this->popStack($stack);
- }
-
- $request = $this->getRequest();
- $controller = $next->getControllerName();
- if (empty($controller)) {
- $next->setControllerName($request->getControllerName());
- }
-
- $module = $next->getModuleName();
- if (empty($module)) {
- $next->setModuleName($request->getModuleName());
- }
-
- return $next;
- }
-
- /**
- * postDispatch() plugin hook -- check for actions in stack, and dispatch if any found
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function postDispatch(Zend_Controller_Request_Abstract $request)
- {
- // Don't move on to next request if this is already an attempt to
- // forward
- if (!$request->isDispatched()) {
- return;
- }
-
- $this->setRequest($request);
- $stack = $this->getStack();
- if (empty($stack)) {
- return;
- }
- $next = $this->popStack();
- if (!$next) {
- return;
- }
-
- $this->forward($next);
- }
-
- /**
- * Forward request with next action
- *
- * @param array $next
- * @return void
- */
- public function forward(Zend_Controller_Request_Abstract $next)
- {
- $request = $this->getRequest();
- if ($this->getClearRequestParams()) {
- $request->clearParams();
- }
-
- $request->setModuleName($next->getModuleName())
- ->setControllerName($next->getControllerName())
- ->setActionName($next->getActionName())
- ->setParams($next->getParams())
- ->setDispatched(false);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Plugin/Broker.php zendframework-2.2.6/library/Zend/Controller/Plugin/Broker.php
--- zendframework-1.10.4/library/Zend/Controller/Plugin/Broker.php 2010-01-13 13:23:36.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Plugin/Broker.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,363 +0,0 @@
-_plugins, true)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Plugin already registered');
- }
-
- $stackIndex = (int) $stackIndex;
-
- if ($stackIndex) {
- if (isset($this->_plugins[$stackIndex])) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Plugin with stackIndex "' . $stackIndex . '" already registered');
- }
- $this->_plugins[$stackIndex] = $plugin;
- } else {
- $stackIndex = count($this->_plugins);
- while (isset($this->_plugins[$stackIndex])) {
- ++$stackIndex;
- }
- $this->_plugins[$stackIndex] = $plugin;
- }
-
- $request = $this->getRequest();
- if ($request) {
- $this->_plugins[$stackIndex]->setRequest($request);
- }
- $response = $this->getResponse();
- if ($response) {
- $this->_plugins[$stackIndex]->setResponse($response);
- }
-
- ksort($this->_plugins);
-
- return $this;
- }
-
- /**
- * Unregister a plugin.
- *
- * @param string|Zend_Controller_Plugin_Abstract $plugin Plugin object or class name
- * @return Zend_Controller_Plugin_Broker
- */
- public function unregisterPlugin($plugin)
- {
- if ($plugin instanceof Zend_Controller_Plugin_Abstract) {
- // Given a plugin object, find it in the array
- $key = array_search($plugin, $this->_plugins, true);
- if (false === $key) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Plugin never registered.');
- }
- unset($this->_plugins[$key]);
- } elseif (is_string($plugin)) {
- // Given a plugin class, find all plugins of that class and unset them
- foreach ($this->_plugins as $key => $_plugin) {
- $type = get_class($_plugin);
- if ($plugin == $type) {
- unset($this->_plugins[$key]);
- }
- }
- }
- return $this;
- }
-
- /**
- * Is a plugin of a particular class registered?
- *
- * @param string $class
- * @return bool
- */
- public function hasPlugin($class)
- {
- foreach ($this->_plugins as $plugin) {
- $type = get_class($plugin);
- if ($class == $type) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Retrieve a plugin or plugins by class
- *
- * @param string $class Class name of plugin(s) desired
- * @return false|Zend_Controller_Plugin_Abstract|array Returns false if none found, plugin if only one found, and array of plugins if multiple plugins of same class found
- */
- public function getPlugin($class)
- {
- $found = array();
- foreach ($this->_plugins as $plugin) {
- $type = get_class($plugin);
- if ($class == $type) {
- $found[] = $plugin;
- }
- }
-
- switch (count($found)) {
- case 0:
- return false;
- case 1:
- return $found[0];
- default:
- return $found;
- }
- }
-
- /**
- * Retrieve all plugins
- *
- * @return array
- */
- public function getPlugins()
- {
- return $this->_plugins;
- }
-
- /**
- * Set request object, and register with each plugin
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return Zend_Controller_Plugin_Broker
- */
- public function setRequest(Zend_Controller_Request_Abstract $request)
- {
- $this->_request = $request;
-
- foreach ($this->_plugins as $plugin) {
- $plugin->setRequest($request);
- }
-
- return $this;
- }
-
- /**
- * Get request object
- *
- * @return Zend_Controller_Request_Abstract $request
- */
- public function getRequest()
- {
- return $this->_request;
- }
-
- /**
- * Set response object
- *
- * @param Zend_Controller_Response_Abstract $response
- * @return Zend_Controller_Plugin_Broker
- */
- public function setResponse(Zend_Controller_Response_Abstract $response)
- {
- $this->_response = $response;
-
- foreach ($this->_plugins as $plugin) {
- $plugin->setResponse($response);
- }
-
-
- return $this;
- }
-
- /**
- * Get response object
- *
- * @return Zend_Controller_Response_Abstract $response
- */
- public function getResponse()
- {
- return $this->_response;
- }
-
-
- /**
- * Called before Zend_Controller_Front begins evaluating the
- * request against its routes.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function routeStartup(Zend_Controller_Request_Abstract $request)
- {
- foreach ($this->_plugins as $plugin) {
- try {
- $plugin->routeStartup($request);
- } catch (Exception $e) {
- if (Zend_Controller_Front::getInstance()->throwExceptions()) {
- throw $e;
- } else {
- $this->getResponse()->setException($e);
- }
- }
- }
- }
-
-
- /**
- * Called before Zend_Controller_Front exits its iterations over
- * the route set.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function routeShutdown(Zend_Controller_Request_Abstract $request)
- {
- foreach ($this->_plugins as $plugin) {
- try {
- $plugin->routeShutdown($request);
- } catch (Exception $e) {
- if (Zend_Controller_Front::getInstance()->throwExceptions()) {
- throw $e;
- } else {
- $this->getResponse()->setException($e);
- }
- }
- }
- }
-
-
- /**
- * Called before Zend_Controller_Front enters its dispatch loop.
- *
- * During the dispatch loop, Zend_Controller_Front keeps a
- * Zend_Controller_Request_Abstract object, and uses
- * Zend_Controller_Dispatcher to dispatch the
- * Zend_Controller_Request_Abstract object to controllers/actions.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
- {
- foreach ($this->_plugins as $plugin) {
- try {
- $plugin->dispatchLoopStartup($request);
- } catch (Exception $e) {
- if (Zend_Controller_Front::getInstance()->throwExceptions()) {
- throw $e;
- } else {
- $this->getResponse()->setException($e);
- }
- }
- }
- }
-
-
- /**
- * Called before an action is dispatched by Zend_Controller_Dispatcher.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function preDispatch(Zend_Controller_Request_Abstract $request)
- {
- foreach ($this->_plugins as $plugin) {
- try {
- $plugin->preDispatch($request);
- } catch (Exception $e) {
- if (Zend_Controller_Front::getInstance()->throwExceptions()) {
- throw $e;
- } else {
- $this->getResponse()->setException($e);
- }
- }
- }
- }
-
-
- /**
- * Called after an action is dispatched by Zend_Controller_Dispatcher.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function postDispatch(Zend_Controller_Request_Abstract $request)
- {
- foreach ($this->_plugins as $plugin) {
- try {
- $plugin->postDispatch($request);
- } catch (Exception $e) {
- if (Zend_Controller_Front::getInstance()->throwExceptions()) {
- throw $e;
- } else {
- $this->getResponse()->setException($e);
- }
- }
- }
- }
-
-
- /**
- * Called before Zend_Controller_Front exits its dispatch loop.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- public function dispatchLoopShutdown()
- {
- foreach ($this->_plugins as $plugin) {
- try {
- $plugin->dispatchLoopShutdown();
- } catch (Exception $e) {
- if (Zend_Controller_Front::getInstance()->throwExceptions()) {
- throw $e;
- } else {
- $this->getResponse()->setException($e);
- }
- }
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Plugin/ErrorHandler.php zendframework-2.2.6/library/Zend/Controller/Plugin/ErrorHandler.php
--- zendframework-1.10.4/library/Zend/Controller/Plugin/ErrorHandler.php 2010-01-12 21:36:08.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Plugin/ErrorHandler.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,289 +0,0 @@
-setErrorHandler($options);
- }
-
- /**
- * setErrorHandler() - setup the error handling options
- *
- * @param array $options
- * @return Zend_Controller_Plugin_ErrorHandler
- */
- public function setErrorHandler(Array $options = array())
- {
- if (isset($options['module'])) {
- $this->setErrorHandlerModule($options['module']);
- }
- if (isset($options['controller'])) {
- $this->setErrorHandlerController($options['controller']);
- }
- if (isset($options['action'])) {
- $this->setErrorHandlerAction($options['action']);
- }
- return $this;
- }
-
- /**
- * Set the module name for the error handler
- *
- * @param string $module
- * @return Zend_Controller_Plugin_ErrorHandler
- */
- public function setErrorHandlerModule($module)
- {
- $this->_errorModule = (string) $module;
- return $this;
- }
-
- /**
- * Retrieve the current error handler module
- *
- * @return string
- */
- public function getErrorHandlerModule()
- {
- if (null === $this->_errorModule) {
- $this->_errorModule = Zend_Controller_Front::getInstance()->getDispatcher()->getDefaultModule();
- }
- return $this->_errorModule;
- }
-
- /**
- * Set the controller name for the error handler
- *
- * @param string $controller
- * @return Zend_Controller_Plugin_ErrorHandler
- */
- public function setErrorHandlerController($controller)
- {
- $this->_errorController = (string) $controller;
- return $this;
- }
-
- /**
- * Retrieve the current error handler controller
- *
- * @return string
- */
- public function getErrorHandlerController()
- {
- return $this->_errorController;
- }
-
- /**
- * Set the action name for the error handler
- *
- * @param string $action
- * @return Zend_Controller_Plugin_ErrorHandler
- */
- public function setErrorHandlerAction($action)
- {
- $this->_errorAction = (string) $action;
- return $this;
- }
-
- /**
- * Retrieve the current error handler action
- *
- * @return string
- */
- public function getErrorHandlerAction()
- {
- return $this->_errorAction;
- }
-
- /**
- * Route shutdown hook -- Ccheck for router exceptions
- *
- * @param Zend_Controller_Request_Abstract $request
- */
- public function routeShutdown(Zend_Controller_Request_Abstract $request)
- {
- $this->_handleError($request);
- }
-
- /**
- * Post dispatch hook -- check for exceptions and dispatch error handler if
- * necessary
- *
- * @param Zend_Controller_Request_Abstract $request
- */
- public function postDispatch(Zend_Controller_Request_Abstract $request)
- {
- $this->_handleError($request);
- }
-
- /**
- * Handle errors and exceptions
- *
- * If the 'noErrorHandler' front controller flag has been set,
- * returns early.
- *
- * @param Zend_Controller_Request_Abstract $request
- * @return void
- */
- protected function _handleError(Zend_Controller_Request_Abstract $request)
- {
- $frontController = Zend_Controller_Front::getInstance();
- if ($frontController->getParam('noErrorHandler')) {
- return;
- }
-
- $response = $this->getResponse();
-
- if ($this->_isInsideErrorHandlerLoop) {
- $exceptions = $response->getException();
- if (count($exceptions) > $this->_exceptionCountAtFirstEncounter) {
- // Exception thrown by error handler; tell the front controller to throw it
- $frontController->throwExceptions(true);
- throw array_pop($exceptions);
- }
- }
-
- // check for an exception AND allow the error handler controller the option to forward
- if (($response->isException()) && (!$this->_isInsideErrorHandlerLoop)) {
- $this->_isInsideErrorHandlerLoop = true;
-
- // Get exception information
- $error = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
- $exceptions = $response->getException();
- $exception = $exceptions[0];
- $exceptionType = get_class($exception);
- $error->exception = $exception;
- switch ($exceptionType) {
- case 'Zend_Controller_Router_Exception':
- if (404 == $exception->getCode()) {
- $error->type = self::EXCEPTION_NO_ROUTE;
- } else {
- $error->type = self::EXCEPTION_OTHER;
- }
- break;
- case 'Zend_Controller_Dispatcher_Exception':
- $error->type = self::EXCEPTION_NO_CONTROLLER;
- break;
- case 'Zend_Controller_Action_Exception':
- if (404 == $exception->getCode()) {
- $error->type = self::EXCEPTION_NO_ACTION;
- } else {
- $error->type = self::EXCEPTION_OTHER;
- }
- break;
- default:
- $error->type = self::EXCEPTION_OTHER;
- break;
- }
-
- // Keep a copy of the original request
- $error->request = clone $request;
-
- // get a count of the number of exceptions encountered
- $this->_exceptionCountAtFirstEncounter = count($exceptions);
-
- // Forward to the error handler
- $request->setParam('error_handler', $error)
- ->setModuleName($this->getErrorHandlerModule())
- ->setControllerName($this->getErrorHandlerController())
- ->setActionName($this->getErrorHandlerAction())
- ->setDispatched(false);
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Plugin/PutHandler.php zendframework-2.2.6/library/Zend/Controller/Plugin/PutHandler.php
--- zendframework-1.10.4/library/Zend/Controller/Plugin/PutHandler.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Plugin/PutHandler.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,60 +0,0 @@
-_request->isPut()) {
- $putParams = array();
- parse_str($this->_request->getRawBody(), $putParams);
- $request->setParams($putParams);
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Request/Abstract.php zendframework-2.2.6/library/Zend/Controller/Request/Abstract.php
--- zendframework-1.10.4/library/Zend/Controller/Request/Abstract.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Request/Abstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,356 +0,0 @@
-_module) {
- $this->_module = $this->getParam($this->getModuleKey());
- }
-
- return $this->_module;
- }
-
- /**
- * Set the module name to use
- *
- * @param string $value
- * @return Zend_Controller_Request_Abstract
- */
- public function setModuleName($value)
- {
- $this->_module = $value;
- return $this;
- }
-
- /**
- * Retrieve the controller name
- *
- * @return string
- */
- public function getControllerName()
- {
- if (null === $this->_controller) {
- $this->_controller = $this->getParam($this->getControllerKey());
- }
-
- return $this->_controller;
- }
-
- /**
- * Set the controller name to use
- *
- * @param string $value
- * @return Zend_Controller_Request_Abstract
- */
- public function setControllerName($value)
- {
- $this->_controller = $value;
- return $this;
- }
-
- /**
- * Retrieve the action name
- *
- * @return string
- */
- public function getActionName()
- {
- if (null === $this->_action) {
- $this->_action = $this->getParam($this->getActionKey());
- }
-
- return $this->_action;
- }
-
- /**
- * Set the action name
- *
- * @param string $value
- * @return Zend_Controller_Request_Abstract
- */
- public function setActionName($value)
- {
- $this->_action = $value;
- /**
- * @see ZF-3465
- */
- if (null === $value) {
- $this->setParam($this->getActionKey(), $value);
- }
- return $this;
- }
-
- /**
- * Retrieve the module key
- *
- * @return string
- */
- public function getModuleKey()
- {
- return $this->_moduleKey;
- }
-
- /**
- * Set the module key
- *
- * @param string $key
- * @return Zend_Controller_Request_Abstract
- */
- public function setModuleKey($key)
- {
- $this->_moduleKey = (string) $key;
- return $this;
- }
-
- /**
- * Retrieve the controller key
- *
- * @return string
- */
- public function getControllerKey()
- {
- return $this->_controllerKey;
- }
-
- /**
- * Set the controller key
- *
- * @param string $key
- * @return Zend_Controller_Request_Abstract
- */
- public function setControllerKey($key)
- {
- $this->_controllerKey = (string) $key;
- return $this;
- }
-
- /**
- * Retrieve the action key
- *
- * @return string
- */
- public function getActionKey()
- {
- return $this->_actionKey;
- }
-
- /**
- * Set the action key
- *
- * @param string $key
- * @return Zend_Controller_Request_Abstract
- */
- public function setActionKey($key)
- {
- $this->_actionKey = (string) $key;
- return $this;
- }
-
- /**
- * Get an action parameter
- *
- * @param string $key
- * @param mixed $default Default value to use if key not found
- * @return mixed
- */
- public function getParam($key, $default = null)
- {
- $key = (string) $key;
- if (isset($this->_params[$key])) {
- return $this->_params[$key];
- }
-
- return $default;
- }
-
- /**
- * Retrieve only user params (i.e, any param specific to the object and not the environment)
- *
- * @return array
- */
- public function getUserParams()
- {
- return $this->_params;
- }
-
- /**
- * Retrieve a single user param (i.e, a param specific to the object and not the environment)
- *
- * @param string $key
- * @param string $default Default value to use if key not found
- * @return mixed
- */
- public function getUserParam($key, $default = null)
- {
- if (isset($this->_params[$key])) {
- return $this->_params[$key];
- }
-
- return $default;
- }
-
- /**
- * Set an action parameter
- *
- * A $value of null will unset the $key if it exists
- *
- * @param string $key
- * @param mixed $value
- * @return Zend_Controller_Request_Abstract
- */
- public function setParam($key, $value)
- {
- $key = (string) $key;
-
- if ((null === $value) && isset($this->_params[$key])) {
- unset($this->_params[$key]);
- } elseif (null !== $value) {
- $this->_params[$key] = $value;
- }
-
- return $this;
- }
-
- /**
- * Get all action parameters
- *
- * @return array
- */
- public function getParams()
- {
- return $this->_params;
- }
-
- /**
- * Set action parameters en masse; does not overwrite
- *
- * Null values will unset the associated key.
- *
- * @param array $array
- * @return Zend_Controller_Request_Abstract
- */
- public function setParams(array $array)
- {
- $this->_params = $this->_params + (array) $array;
-
- foreach ($this->_params as $key => $value) {
- if (null === $value) {
- unset($this->_params[$key]);
- }
- }
-
- return $this;
- }
-
- /**
- * Unset all user parameters
- *
- * @return Zend_Controller_Request_Abstract
- */
- public function clearParams()
- {
- $this->_params = array();
- return $this;
- }
-
- /**
- * Set flag indicating whether or not request has been dispatched
- *
- * @param boolean $flag
- * @return Zend_Controller_Request_Abstract
- */
- public function setDispatched($flag = true)
- {
- $this->_dispatched = $flag ? true : false;
- return $this;
- }
-
- /**
- * Determine if the request has been dispatched
- *
- * @return boolean
- */
- public function isDispatched()
- {
- return $this->_dispatched;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Request/Apache404.php zendframework-2.2.6/library/Zend/Controller/Request/Apache404.php
--- zendframework-1.10.4/library/Zend/Controller/Request/Apache404.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Request/Apache404.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,82 +0,0 @@
-_requestUri = $requestUri;
- return $this;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Request/Exception.php zendframework-2.2.6/library/Zend/Controller/Request/Exception.php
--- zendframework-1.10.4/library/Zend/Controller/Request/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Request/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,37 +0,0 @@
-valid()) {
- $path = $uri->getPath();
- $query = $uri->getQuery();
- if (!empty($query)) {
- $path .= '?' . $query;
- }
-
- $this->setRequestUri($path);
- } else {
- require_once 'Zend/Controller/Request/Exception.php';
- throw new Zend_Controller_Request_Exception('Invalid URI provided to constructor');
- }
- } else {
- $this->setRequestUri();
- }
- }
-
- /**
- * Access values contained in the superglobals as public members
- * Order of precedence: 1. GET, 2. POST, 3. COOKIE, 4. SERVER, 5. ENV
- *
- * @see http://msdn.microsoft.com/en-us/library/system.web.httprequest.item.aspx
- * @param string $key
- * @return mixed
- */
- public function __get($key)
- {
- switch (true) {
- case isset($this->_params[$key]):
- return $this->_params[$key];
- case isset($_GET[$key]):
- return $_GET[$key];
- case isset($_POST[$key]):
- return $_POST[$key];
- case isset($_COOKIE[$key]):
- return $_COOKIE[$key];
- case ($key == 'REQUEST_URI'):
- return $this->getRequestUri();
- case ($key == 'PATH_INFO'):
- return $this->getPathInfo();
- case isset($_SERVER[$key]):
- return $_SERVER[$key];
- case isset($_ENV[$key]):
- return $_ENV[$key];
- default:
- return null;
- }
- }
-
- /**
- * Alias to __get
- *
- * @param string $key
- * @return mixed
- */
- public function get($key)
- {
- return $this->__get($key);
- }
-
- /**
- * Set values
- *
- * In order to follow {@link __get()}, which operates on a number of
- * superglobals, setting values through overloading is not allowed and will
- * raise an exception. Use setParam() instead.
- *
- * @param string $key
- * @param mixed $value
- * @return void
- * @throws Zend_Controller_Request_Exception
- */
- public function __set($key, $value)
- {
- require_once 'Zend/Controller/Request/Exception.php';
- throw new Zend_Controller_Request_Exception('Setting values in superglobals not allowed; please use setParam()');
- }
-
- /**
- * Alias to __set()
- *
- * @param string $key
- * @param mixed $value
- * @return void
- */
- public function set($key, $value)
- {
- return $this->__set($key, $value);
- }
-
- /**
- * Check to see if a property is set
- *
- * @param string $key
- * @return boolean
- */
- public function __isset($key)
- {
- switch (true) {
- case isset($this->_params[$key]):
- return true;
- case isset($_GET[$key]):
- return true;
- case isset($_POST[$key]):
- return true;
- case isset($_COOKIE[$key]):
- return true;
- case isset($_SERVER[$key]):
- return true;
- case isset($_ENV[$key]):
- return true;
- default:
- return false;
- }
- }
-
- /**
- * Alias to __isset()
- *
- * @param string $key
- * @return boolean
- */
- public function has($key)
- {
- return $this->__isset($key);
- }
-
- /**
- * Set GET values
- *
- * @param string|array $spec
- * @param null|mixed $value
- * @return Zend_Controller_Request_Http
- */
- public function setQuery($spec, $value = null)
- {
- if ((null === $value) && !is_array($spec)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid value passed to setQuery(); must be either array of values or key/value pair');
- }
- if ((null === $value) && is_array($spec)) {
- foreach ($spec as $key => $value) {
- $this->setQuery($key, $value);
- }
- return $this;
- }
- $_GET[(string) $spec] = $value;
- return $this;
- }
-
- /**
- * Retrieve a member of the $_GET superglobal
- *
- * If no $key is passed, returns the entire $_GET array.
- *
- * @todo How to retrieve from nested arrays
- * @param string $key
- * @param mixed $default Default value to use if key not found
- * @return mixed Returns null if key does not exist
- */
- public function getQuery($key = null, $default = null)
- {
- if (null === $key) {
- return $_GET;
- }
-
- return (isset($_GET[$key])) ? $_GET[$key] : $default;
- }
-
- /**
- * Set POST values
- *
- * @param string|array $spec
- * @param null|mixed $value
- * @return Zend_Controller_Request_Http
- */
- public function setPost($spec, $value = null)
- {
- if ((null === $value) && !is_array($spec)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid value passed to setPost(); must be either array of values or key/value pair');
- }
- if ((null === $value) && is_array($spec)) {
- foreach ($spec as $key => $value) {
- $this->setPost($key, $value);
- }
- return $this;
- }
- $_POST[(string) $spec] = $value;
- return $this;
- }
-
- /**
- * Retrieve a member of the $_POST superglobal
- *
- * If no $key is passed, returns the entire $_POST array.
- *
- * @todo How to retrieve from nested arrays
- * @param string $key
- * @param mixed $default Default value to use if key not found
- * @return mixed Returns null if key does not exist
- */
- public function getPost($key = null, $default = null)
- {
- if (null === $key) {
- return $_POST;
- }
-
- return (isset($_POST[$key])) ? $_POST[$key] : $default;
- }
-
- /**
- * Retrieve a member of the $_COOKIE superglobal
- *
- * If no $key is passed, returns the entire $_COOKIE array.
- *
- * @todo How to retrieve from nested arrays
- * @param string $key
- * @param mixed $default Default value to use if key not found
- * @return mixed Returns null if key does not exist
- */
- public function getCookie($key = null, $default = null)
- {
- if (null === $key) {
- return $_COOKIE;
- }
-
- return (isset($_COOKIE[$key])) ? $_COOKIE[$key] : $default;
- }
-
- /**
- * Retrieve a member of the $_SERVER superglobal
- *
- * If no $key is passed, returns the entire $_SERVER array.
- *
- * @param string $key
- * @param mixed $default Default value to use if key not found
- * @return mixed Returns null if key does not exist
- */
- public function getServer($key = null, $default = null)
- {
- if (null === $key) {
- return $_SERVER;
- }
-
- return (isset($_SERVER[$key])) ? $_SERVER[$key] : $default;
- }
-
- /**
- * Retrieve a member of the $_ENV superglobal
- *
- * If no $key is passed, returns the entire $_ENV array.
- *
- * @param string $key
- * @param mixed $default Default value to use if key not found
- * @return mixed Returns null if key does not exist
- */
- public function getEnv($key = null, $default = null)
- {
- if (null === $key) {
- return $_ENV;
- }
-
- return (isset($_ENV[$key])) ? $_ENV[$key] : $default;
- }
-
- /**
- * Set the REQUEST_URI on which the instance operates
- *
- * If no request URI is passed, uses the value in $_SERVER['REQUEST_URI'],
- * $_SERVER['HTTP_X_REWRITE_URL'], or $_SERVER['ORIG_PATH_INFO'] + $_SERVER['QUERY_STRING'].
- *
- * @param string $requestUri
- * @return Zend_Controller_Request_Http
- */
- public function setRequestUri($requestUri = null)
- {
- if ($requestUri === null) {
- if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch
- $requestUri = $_SERVER['HTTP_X_REWRITE_URL'];
- } elseif (
- // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem)
- isset($_SERVER['IIS_WasUrlRewritten'])
- && $_SERVER['IIS_WasUrlRewritten'] == '1'
- && isset($_SERVER['UNENCODED_URL'])
- && $_SERVER['UNENCODED_URL'] != ''
- ) {
- $requestUri = $_SERVER['UNENCODED_URL'];
- } elseif (isset($_SERVER['REQUEST_URI'])) {
- $requestUri = $_SERVER['REQUEST_URI'];
- // Http proxy reqs setup request uri with scheme and host [and port] + the url path, only use url path
- $schemeAndHttpHost = $this->getScheme() . '://' . $this->getHttpHost();
- if (strpos($requestUri, $schemeAndHttpHost) === 0) {
- $requestUri = substr($requestUri, strlen($schemeAndHttpHost));
- }
- } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI
- $requestUri = $_SERVER['ORIG_PATH_INFO'];
- if (!empty($_SERVER['QUERY_STRING'])) {
- $requestUri .= '?' . $_SERVER['QUERY_STRING'];
- }
- } else {
- return $this;
- }
- } elseif (!is_string($requestUri)) {
- return $this;
- } else {
- // Set GET items, if available
- if (false !== ($pos = strpos($requestUri, '?'))) {
- // Get key => value pairs and set $_GET
- $query = substr($requestUri, $pos + 1);
- parse_str($query, $vars);
- $this->setQuery($vars);
- }
- }
-
- $this->_requestUri = $requestUri;
- return $this;
- }
-
- /**
- * Returns the REQUEST_URI taking into account
- * platform differences between Apache and IIS
- *
- * @return string
- */
- public function getRequestUri()
- {
- if (empty($this->_requestUri)) {
- $this->setRequestUri();
- }
-
- return $this->_requestUri;
- }
-
- /**
- * Set the base URL of the request; i.e., the segment leading to the script name
- *
- * E.g.:
- * - /admin
- * - /myapp
- * - /subdir/index.php
- *
- * Do not use the full URI when providing the base. The following are
- * examples of what not to use:
- * - http://example.com/admin (should be just /admin)
- * - http://example.com/subdir/index.php (should be just /subdir/index.php)
- *
- * If no $baseUrl is provided, attempts to determine the base URL from the
- * environment, using SCRIPT_FILENAME, SCRIPT_NAME, PHP_SELF, and
- * ORIG_SCRIPT_NAME in its determination.
- *
- * @param mixed $baseUrl
- * @return Zend_Controller_Request_Http
- */
- public function setBaseUrl($baseUrl = null)
- {
- if ((null !== $baseUrl) && !is_string($baseUrl)) {
- return $this;
- }
-
- if ($baseUrl === null) {
- $filename = (isset($_SERVER['SCRIPT_FILENAME'])) ? basename($_SERVER['SCRIPT_FILENAME']) : '';
-
- if (isset($_SERVER['SCRIPT_NAME']) && basename($_SERVER['SCRIPT_NAME']) === $filename) {
- $baseUrl = $_SERVER['SCRIPT_NAME'];
- } elseif (isset($_SERVER['PHP_SELF']) && basename($_SERVER['PHP_SELF']) === $filename) {
- $baseUrl = $_SERVER['PHP_SELF'];
- } elseif (isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === $filename) {
- $baseUrl = $_SERVER['ORIG_SCRIPT_NAME']; // 1and1 shared hosting compatibility
- } else {
- // Backtrack up the script_filename to find the portion matching
- // php_self
- $path = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : '';
- $file = isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : '';
- $segs = explode('/', trim($file, '/'));
- $segs = array_reverse($segs);
- $index = 0;
- $last = count($segs);
- $baseUrl = '';
- do {
- $seg = $segs[$index];
- $baseUrl = '/' . $seg . $baseUrl;
- ++$index;
- } while (($last > $index) && (false !== ($pos = strpos($path, $baseUrl))) && (0 != $pos));
- }
-
- // Does the baseUrl have anything in common with the request_uri?
- $requestUri = $this->getRequestUri();
-
- if (0 === strpos($requestUri, $baseUrl)) {
- // full $baseUrl matches
- $this->_baseUrl = $baseUrl;
- return $this;
- }
-
- if (0 === strpos($requestUri, dirname($baseUrl))) {
- // directory portion of $baseUrl matches
- $this->_baseUrl = rtrim(dirname($baseUrl), '/');
- return $this;
- }
-
- $truncatedRequestUri = $requestUri;
- if (($pos = strpos($requestUri, '?')) !== false) {
- $truncatedRequestUri = substr($requestUri, 0, $pos);
- }
-
- $basename = basename($baseUrl);
- if (empty($basename) || !strpos($truncatedRequestUri, $basename)) {
- // no match whatsoever; set it blank
- $this->_baseUrl = '';
- return $this;
- }
-
- // If using mod_rewrite or ISAPI_Rewrite strip the script filename
- // out of baseUrl. $pos !== 0 makes sure it is not matching a value
- // from PATH_INFO or QUERY_STRING
- if ((strlen($requestUri) >= strlen($baseUrl))
- && ((false !== ($pos = strpos($requestUri, $baseUrl))) && ($pos !== 0)))
- {
- $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));
- }
- }
-
- $this->_baseUrl = rtrim($baseUrl, '/');
- return $this;
- }
-
- /**
- * Everything in REQUEST_URI before PATH_INFO
- *
- *
- * @return string
- */
- public function getBaseUrl()
- {
- if (null === $this->_baseUrl) {
- $this->setBaseUrl();
- }
-
- return $this->_baseUrl;
- }
-
- /**
- * Set the base path for the URL
- *
- * @param string|null $basePath
- * @return Zend_Controller_Request_Http
- */
- public function setBasePath($basePath = null)
- {
- if ($basePath === null) {
- $filename = (isset($_SERVER['SCRIPT_FILENAME']))
- ? basename($_SERVER['SCRIPT_FILENAME'])
- : '';
-
- $baseUrl = $this->getBaseUrl();
- if (empty($baseUrl)) {
- $this->_basePath = '';
- return $this;
- }
-
- if (basename($baseUrl) === $filename) {
- $basePath = dirname($baseUrl);
- } else {
- $basePath = $baseUrl;
- }
- }
-
- if (substr(PHP_OS, 0, 3) === 'WIN') {
- $basePath = str_replace('\\', '/', $basePath);
- }
-
- $this->_basePath = rtrim($basePath, '/');
- return $this;
- }
-
- /**
- * Everything in REQUEST_URI before PATH_INFO not including the filename
- *
- *
- * @return string
- */
- public function getBasePath()
- {
- if (null === $this->_basePath) {
- $this->setBasePath();
- }
-
- return $this->_basePath;
- }
-
- /**
- * Set the PATH_INFO string
- *
- * @param string|null $pathInfo
- * @return Zend_Controller_Request_Http
- */
- public function setPathInfo($pathInfo = null)
- {
- if ($pathInfo === null) {
- $baseUrl = $this->getBaseUrl();
-
- if (null === ($requestUri = $this->getRequestUri())) {
- return $this;
- }
-
- // Remove the query string from REQUEST_URI
- if ($pos = strpos($requestUri, '?')) {
- $requestUri = substr($requestUri, 0, $pos);
- }
-
- if (null !== $baseUrl
- && ((!empty($baseUrl) && 0 === strpos($requestUri, $baseUrl))
- || empty($baseUrl))
- && false === ($pathInfo = substr($requestUri, strlen($baseUrl)))
- ){
- // If substr() returns false then PATH_INFO is set to an empty string
- $pathInfo = '';
- } elseif (null === $baseUrl
- || (!empty($baseUrl) && false === strpos($requestUri, $baseUrl))
- ) {
- $pathInfo = $requestUri;
- }
- }
-
- $this->_pathInfo = (string) $pathInfo;
- return $this;
- }
-
- /**
- * Returns everything between the BaseUrl and QueryString.
- * This value is calculated instead of reading PATH_INFO
- * directly from $_SERVER due to cross-platform differences.
- *
- * @return string
- */
- public function getPathInfo()
- {
- if (empty($this->_pathInfo)) {
- $this->setPathInfo();
- }
-
- return $this->_pathInfo;
- }
-
- /**
- * Set allowed parameter sources
- *
- * Can be empty array, or contain one or more of '_GET' or '_POST'.
- *
- * @param array $paramSoures
- * @return Zend_Controller_Request_Http
- */
- public function setParamSources(array $paramSources = array())
- {
- $this->_paramSources = $paramSources;
- return $this;
- }
-
- /**
- * Get list of allowed parameter sources
- *
- * @return array
- */
- public function getParamSources()
- {
- return $this->_paramSources;
- }
-
- /**
- * Set a userland parameter
- *
- * Uses $key to set a userland parameter. If $key is an alias, the actual
- * key will be retrieved and used to set the parameter.
- *
- * @param mixed $key
- * @param mixed $value
- * @return Zend_Controller_Request_Http
- */
- public function setParam($key, $value)
- {
- $key = (null !== ($alias = $this->getAlias($key))) ? $alias : $key;
- parent::setParam($key, $value);
- return $this;
- }
-
- /**
- * Retrieve a parameter
- *
- * Retrieves a parameter from the instance. Priority is in the order of
- * userland parameters (see {@link setParam()}), $_GET, $_POST. If a
- * parameter matching the $key is not found, null is returned.
- *
- * If the $key is an alias, the actual key aliased will be used.
- *
- * @param mixed $key
- * @param mixed $default Default value to use if key not found
- * @return mixed
- */
- public function getParam($key, $default = null)
- {
- $keyName = (null !== ($alias = $this->getAlias($key))) ? $alias : $key;
-
- $paramSources = $this->getParamSources();
- if (isset($this->_params[$keyName])) {
- return $this->_params[$keyName];
- } elseif (in_array('_GET', $paramSources) && (isset($_GET[$keyName]))) {
- return $_GET[$keyName];
- } elseif (in_array('_POST', $paramSources) && (isset($_POST[$keyName]))) {
- return $_POST[$keyName];
- }
-
- return $default;
- }
-
- /**
- * Retrieve an array of parameters
- *
- * Retrieves a merged array of parameters, with precedence of userland
- * params (see {@link setParam()}), $_GET, $_POST (i.e., values in the
- * userland params will take precedence over all others).
- *
- * @return array
- */
- public function getParams()
- {
- $return = $this->_params;
- $paramSources = $this->getParamSources();
- if (in_array('_GET', $paramSources)
- && isset($_GET)
- && is_array($_GET)
- ) {
- $return += $_GET;
- }
- if (in_array('_POST', $paramSources)
- && isset($_POST)
- && is_array($_POST)
- ) {
- $return += $_POST;
- }
- return $return;
- }
-
- /**
- * Set parameters
- *
- * Set one or more parameters. Parameters are set as userland parameters,
- * using the keys specified in the array.
- *
- * @param array $params
- * @return Zend_Controller_Request_Http
- */
- public function setParams(array $params)
- {
- foreach ($params as $key => $value) {
- $this->setParam($key, $value);
- }
- return $this;
- }
-
- /**
- * Set a key alias
- *
- * Set an alias used for key lookups. $name specifies the alias, $target
- * specifies the actual key to use.
- *
- * @param string $name
- * @param string $target
- * @return Zend_Controller_Request_Http
- */
- public function setAlias($name, $target)
- {
- $this->_aliases[$name] = $target;
- return $this;
- }
-
- /**
- * Retrieve an alias
- *
- * Retrieve the actual key represented by the alias $name.
- *
- * @param string $name
- * @return string|null Returns null when no alias exists
- */
- public function getAlias($name)
- {
- if (isset($this->_aliases[$name])) {
- return $this->_aliases[$name];
- }
-
- return null;
- }
-
- /**
- * Retrieve the list of all aliases
- *
- * @return array
- */
- public function getAliases()
- {
- return $this->_aliases;
- }
-
- /**
- * Return the method by which the request was made
- *
- * @return string
- */
- public function getMethod()
- {
- return $this->getServer('REQUEST_METHOD');
- }
-
- /**
- * Was the request made by POST?
- *
- * @return boolean
- */
- public function isPost()
- {
- if ('POST' == $this->getMethod()) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Was the request made by GET?
- *
- * @return boolean
- */
- public function isGet()
- {
- if ('GET' == $this->getMethod()) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Was the request made by PUT?
- *
- * @return boolean
- */
- public function isPut()
- {
- if ('PUT' == $this->getMethod()) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Was the request made by DELETE?
- *
- * @return boolean
- */
- public function isDelete()
- {
- if ('DELETE' == $this->getMethod()) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Was the request made by HEAD?
- *
- * @return boolean
- */
- public function isHead()
- {
- if ('HEAD' == $this->getMethod()) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Was the request made by OPTIONS?
- *
- * @return boolean
- */
- public function isOptions()
- {
- if ('OPTIONS' == $this->getMethod()) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Is the request a Javascript XMLHttpRequest?
- *
- * Should work with Prototype/Script.aculo.us, possibly others.
- *
- * @return boolean
- */
- public function isXmlHttpRequest()
- {
- return ($this->getHeader('X_REQUESTED_WITH') == 'XMLHttpRequest');
- }
-
- /**
- * Is this a Flash request?
- *
- * @return boolean
- */
- public function isFlashRequest()
- {
- $header = strtolower($this->getHeader('USER_AGENT'));
- return (strstr($header, ' flash')) ? true : false;
- }
-
- /**
- * Is https secure request
- *
- * @return boolean
- */
- public function isSecure()
- {
- return ($this->getScheme() === self::SCHEME_HTTPS);
- }
-
- /**
- * Return the raw body of the request, if present
- *
- * @return string|false Raw body, or false if not present
- */
- public function getRawBody()
- {
- if (null === $this->_rawBody) {
- $body = file_get_contents('php://input');
-
- if (strlen(trim($body)) > 0) {
- $this->_rawBody = $body;
- } else {
- $this->_rawBody = false;
- }
- }
- return $this->_rawBody;
- }
-
- /**
- * Return the value of the given HTTP header. Pass the header name as the
- * plain, HTTP-specified header name. Ex.: Ask for 'Accept' to get the
- * Accept header, 'Accept-Encoding' to get the Accept-Encoding header.
- *
- * @param string $header HTTP header name
- * @return string|false HTTP header value, or false if not found
- * @throws Zend_Controller_Request_Exception
- */
- public function getHeader($header)
- {
- if (empty($header)) {
- require_once 'Zend/Controller/Request/Exception.php';
- throw new Zend_Controller_Request_Exception('An HTTP header name is required');
- }
-
- // Try to get it from the $_SERVER array first
- $temp = 'HTTP_' . strtoupper(str_replace('-', '_', $header));
- if (!empty($_SERVER[$temp])) {
- return $_SERVER[$temp];
- }
-
- // This seems to be the only way to get the Authorization header on
- // Apache
- if (function_exists('apache_request_headers')) {
- $headers = apache_request_headers();
- if (!empty($headers[$header])) {
- return $headers[$header];
- }
- }
-
- return false;
- }
-
- /**
- * Get the request URI scheme
- *
- * @return string
- */
- public function getScheme()
- {
- return ($this->getServer('HTTPS') == 'on') ? self::SCHEME_HTTPS : self::SCHEME_HTTP;
- }
-
- /**
- * Get the HTTP host.
- *
- * "Host" ":" host [ ":" port ] ; Section 3.2.2
- * Note the HTTP Host header is not the same as the URI host.
- * It includes the port while the URI host doesn't.
- *
- * @return string
- */
- public function getHttpHost()
- {
- $host = $this->getServer('HTTP_HOST');
- if (!empty($host)) {
- return $host;
- }
-
- $scheme = $this->getScheme();
- $name = $this->getServer('SERVER_NAME');
- $port = $this->getServer('SERVER_PORT');
-
- if (($scheme == self::SCHEME_HTTP && $port == 80) || ($scheme == self::SCHEME_HTTPS && $port == 443)) {
- return $name;
- } else {
- return $name . ':' . $port;
- }
- }
-
- /**
- * Get the client's IP addres
- *
- * @param boolean $checkProxy
- * @return string
- */
- public function getClientIp($checkProxy = true)
- {
- if ($checkProxy && $this->getServer('HTTP_CLIENT_IP') != null) {
- $ip = $this->getServer('HTTP_CLIENT_IP');
- } else if ($checkProxy && $this->getServer('HTTP_X_FORWARDED_FOR') != null) {
- $ip = $this->getServer('HTTP_X_FORWARDED_FOR');
- } else {
- $ip = $this->getServer('REMOTE_ADDR');
- }
-
- return $ip;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Request/HttpTestCase.php zendframework-2.2.6/library/Zend/Controller/Request/HttpTestCase.php
--- zendframework-1.10.4/library/Zend/Controller/Request/HttpTestCase.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Request/HttpTestCase.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,276 +0,0 @@
-_rawBody = (string) $content;
- return $this;
- }
-
- /**
- * Get RAW POST body
- *
- * @return string|null
- */
- public function getRawBody()
- {
- return $this->_rawBody;
- }
-
- /**
- * Clear raw POST body
- *
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function clearRawBody()
- {
- $this->_rawBody = null;
- return $this;
- }
-
- /**
- * Set a cookie
- *
- * @param string $key
- * @param mixed $value
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function setCookie($key, $value)
- {
- $_COOKIE[(string) $key] = $value;
- return $this;
- }
-
- /**
- * Set multiple cookies at once
- *
- * @param array $cookies
- * @return void
- */
- public function setCookies(array $cookies)
- {
- foreach ($cookies as $key => $value) {
- $_COOKIE[$key] = $value;
- }
- return $this;
- }
-
- /**
- * Clear all cookies
- *
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function clearCookies()
- {
- $_COOKIE = array();
- return $this;
- }
-
- /**
- * Set request method
- *
- * @param string $type
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function setMethod($type)
- {
- $type = strtoupper(trim((string) $type));
- if (!in_array($type, $this->_validMethodTypes)) {
- require_once 'Zend/Controller/Exception.php';
- throw new Zend_Controller_Exception('Invalid request method specified');
- }
- $this->_method = $type;
- return $this;
- }
-
- /**
- * Get request method
- *
- * @return string|null
- */
- public function getMethod()
- {
- return $this->_method;
- }
-
- /**
- * Set a request header
- *
- * @param string $key
- * @param string $value
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function setHeader($key, $value)
- {
- $key = $this->_normalizeHeaderName($key);
- $this->_headers[$key] = (string) $value;
- return $this;
- }
-
- /**
- * Set request headers
- *
- * @param array $headers
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function setHeaders(array $headers)
- {
- foreach ($headers as $key => $value) {
- $this->setHeader($key, $value);
- }
- return $this;
- }
-
- /**
- * Get request header
- *
- * @param string $header
- * @param mixed $default
- * @return string|null
- */
- public function getHeader($header, $default = null)
- {
- $header = $this->_normalizeHeaderName($header);
- if (array_key_exists($header, $this->_headers)) {
- return $this->_headers[$header];
- }
- return $default;
- }
-
- /**
- * Get all request headers
- *
- * @return array
- */
- public function getHeaders()
- {
- return $this->_headers;
- }
-
- /**
- * Clear request headers
- *
- * @return Zend_Controller_Request_HttpTestCase
- */
- public function clearHeaders()
- {
- $this->_headers = array();
- return $this;
- }
-
- /**
- * Get REQUEST_URI
- *
- * @return null|string
- */
- public function getRequestUri()
- {
- return $this->_requestUri;
- }
-
- /**
- * Normalize a header name for setting and retrieval
- *
- * @param string $name
- * @return string
- */
- protected function _normalizeHeaderName($name)
- {
- $name = strtoupper((string) $name);
- $name = str_replace('-', '_', $name);
- return $name;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Request/Simple.php zendframework-2.2.6/library/Zend/Controller/Request/Simple.php
--- zendframework-1.10.4/library/Zend/Controller/Request/Simple.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Request/Simple.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,55 +0,0 @@
-setActionName($action);
- }
-
- if ($controller) {
- $this->setControllerName($controller);
- }
-
- if ($module) {
- $this->setModuleName($module);
- }
-
- if ($params) {
- $this->setParams($params);
- }
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Response/Abstract.php zendframework-2.2.6/library/Zend/Controller/Response/Abstract.php
--- zendframework-1.10.4/library/Zend/Controller/Response/Abstract.php 2010-03-02 23:01:38.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Response/Abstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,794 +0,0 @@
-canSendHeaders(true);
- $name = $this->_normalizeHeader($name);
- $value = (string) $value;
-
- if ($replace) {
- foreach ($this->_headers as $key => $header) {
- if ($name == $header['name']) {
- unset($this->_headers[$key]);
- }
- }
- }
-
- $this->_headers[] = array(
- 'name' => $name,
- 'value' => $value,
- 'replace' => $replace
- );
-
- return $this;
- }
-
- /**
- * Set redirect URL
- *
- * Sets Location header and response code. Forces replacement of any prior
- * redirects.
- *
- * @param string $url
- * @param int $code
- * @return Zend_Controller_Response_Abstract
- */
- public function setRedirect($url, $code = 302)
- {
- $this->canSendHeaders(true);
- $this->setHeader('Location', $url, true)
- ->setHttpResponseCode($code);
-
- return $this;
- }
-
- /**
- * Is this a redirect?
- *
- * @return boolean
- */
- public function isRedirect()
- {
- return $this->_isRedirect;
- }
-
- /**
- * Return array of headers; see {@link $_headers} for format
- *
- * @return array
- */
- public function getHeaders()
- {
- return $this->_headers;
- }
-
- /**
- * Clear headers
- *
- * @return Zend_Controller_Response_Abstract
- */
- public function clearHeaders()
- {
- $this->_headers = array();
-
- return $this;
- }
-
- /**
- * Clears the specified HTTP header
- *
- * @param string $name
- * @return Zend_Controller_Response_Abstract
- */
- public function clearHeader($name)
- {
- if (! count($this->_headers)) {
- return $this;
- }
-
- foreach ($this->_headers as $index => $header) {
- if ($name == $header['name']) {
- unset($this->_headers[$index]);
- }
- }
-
- return $this;
- }
-
- /**
- * Set raw HTTP header
- *
- * Allows setting non key => value headers, such as status codes
- *
- * @param string $value
- * @return Zend_Controller_Response_Abstract
- */
- public function setRawHeader($value)
- {
- $this->canSendHeaders(true);
- if ('Location' == substr($value, 0, 8)) {
- $this->_isRedirect = true;
- }
- $this->_headersRaw[] = (string) $value;
- return $this;
- }
-
- /**
- * Retrieve all {@link setRawHeader() raw HTTP headers}
- *
- * @return array
- */
- public function getRawHeaders()
- {
- return $this->_headersRaw;
- }
-
- /**
- * Clear all {@link setRawHeader() raw HTTP headers}
- *
- * @return Zend_Controller_Response_Abstract
- */
- public function clearRawHeaders()
- {
- $this->_headersRaw = array();
- return $this;
- }
-
- /**
- * Clears the specified raw HTTP header
- *
- * @param string $headerRaw
- * @return Zend_Controller_Response_Abstract
- */
- public function clearRawHeader($headerRaw)
- {
- if (! count($this->_headersRaw)) {
- return $this;
- }
-
- $key = array_search($headerRaw, $this->_headersRaw);
- unset($this->_headersRaw[$key]);
-
- return $this;
- }
-
- /**
- * Clear all headers, normal and raw
- *
- * @return Zend_Controller_Response_Abstract
- */
- public function clearAllHeaders()
- {
- return $this->clearHeaders()
- ->clearRawHeaders();
- }
-
- /**
- * Set HTTP response code to use with headers
- *
- * @param int $code
- * @return Zend_Controller_Response_Abstract
- */
- public function setHttpResponseCode($code)
- {
- if (!is_int($code) || (100 > $code) || (599 < $code)) {
- require_once 'Zend/Controller/Response/Exception.php';
- throw new Zend_Controller_Response_Exception('Invalid HTTP response code');
- }
-
- if ((300 <= $code) && (307 >= $code)) {
- $this->_isRedirect = true;
- } else {
- $this->_isRedirect = false;
- }
-
- $this->_httpResponseCode = $code;
- return $this;
- }
-
- /**
- * Retrieve HTTP response code
- *
- * @return int
- */
- public function getHttpResponseCode()
- {
- return $this->_httpResponseCode;
- }
-
- /**
- * Can we send headers?
- *
- * @param boolean $throw Whether or not to throw an exception if headers have been sent; defaults to false
- * @return boolean
- * @throws Zend_Controller_Response_Exception
- */
- public function canSendHeaders($throw = false)
- {
- $ok = headers_sent($file, $line);
- if ($ok && $throw && $this->headersSentThrowsException) {
- require_once 'Zend/Controller/Response/Exception.php';
- throw new Zend_Controller_Response_Exception('Cannot send headers; headers already sent in ' . $file . ', line ' . $line);
- }
-
- return !$ok;
- }
-
- /**
- * Send all headers
- *
- * Sends any headers specified. If an {@link setHttpResponseCode() HTTP response code}
- * has been specified, it is sent with the first header.
- *
- * @return Zend_Controller_Response_Abstract
- */
- public function sendHeaders()
- {
- // Only check if we can send headers if we have headers to send
- if (count($this->_headersRaw) || count($this->_headers) || (200 != $this->_httpResponseCode)) {
- $this->canSendHeaders(true);
- } elseif (200 == $this->_httpResponseCode) {
- // Haven't changed the response code, and we have no headers
- return $this;
- }
-
- $httpCodeSent = false;
-
- foreach ($this->_headersRaw as $header) {
- if (!$httpCodeSent && $this->_httpResponseCode) {
- header($header, true, $this->_httpResponseCode);
- $httpCodeSent = true;
- } else {
- header($header);
- }
- }
-
- foreach ($this->_headers as $header) {
- if (!$httpCodeSent && $this->_httpResponseCode) {
- header($header['name'] . ': ' . $header['value'], $header['replace'], $this->_httpResponseCode);
- $httpCodeSent = true;
- } else {
- header($header['name'] . ': ' . $header['value'], $header['replace']);
- }
- }
-
- if (!$httpCodeSent) {
- header('HTTP/1.1 ' . $this->_httpResponseCode);
- $httpCodeSent = true;
- }
-
- return $this;
- }
-
- /**
- * Set body content
- *
- * If $name is not passed, or is not a string, resets the entire body and
- * sets the 'default' key to $content.
- *
- * If $name is a string, sets the named segment in the body array to
- * $content.
- *
- * @param string $content
- * @param null|string $name
- * @return Zend_Controller_Response_Abstract
- */
- public function setBody($content, $name = null)
- {
- if ((null === $name) || !is_string($name)) {
- $this->_body = array('default' => (string) $content);
- } else {
- $this->_body[$name] = (string) $content;
- }
-
- return $this;
- }
-
- /**
- * Append content to the body content
- *
- * @param string $content
- * @param null|string $name
- * @return Zend_Controller_Response_Abstract
- */
- public function appendBody($content, $name = null)
- {
- if ((null === $name) || !is_string($name)) {
- if (isset($this->_body['default'])) {
- $this->_body['default'] .= (string) $content;
- } else {
- return $this->append('default', $content);
- }
- } elseif (isset($this->_body[$name])) {
- $this->_body[$name] .= (string) $content;
- } else {
- return $this->append($name, $content);
- }
-
- return $this;
- }
-
- /**
- * Clear body array
- *
- * With no arguments, clears the entire body array. Given a $name, clears
- * just that named segment; if no segment matching $name exists, returns
- * false to indicate an error.
- *
- * @param string $name Named segment to clear
- * @return boolean
- */
- public function clearBody($name = null)
- {
- if (null !== $name) {
- $name = (string) $name;
- if (isset($this->_body[$name])) {
- unset($this->_body[$name]);
- return true;
- }
-
- return false;
- }
-
- $this->_body = array();
- return true;
- }
-
- /**
- * Return the body content
- *
- * If $spec is false, returns the concatenated values of the body content
- * array. If $spec is boolean true, returns the body content array. If
- * $spec is a string and matches a named segment, returns the contents of
- * that segment; otherwise, returns null.
- *
- * @param boolean $spec
- * @return string|array|null
- */
- public function getBody($spec = false)
- {
- if (false === $spec) {
- ob_start();
- $this->outputBody();
- return ob_get_clean();
- } elseif (true === $spec) {
- return $this->_body;
- } elseif (is_string($spec) && isset($this->_body[$spec])) {
- return $this->_body[$spec];
- }
-
- return null;
- }
-
- /**
- * Append a named body segment to the body content array
- *
- * If segment already exists, replaces with $content and places at end of
- * array.
- *
- * @param string $name
- * @param string $content
- * @return Zend_Controller_Response_Abstract
- */
- public function append($name, $content)
- {
- if (!is_string($name)) {
- require_once 'Zend/Controller/Response/Exception.php';
- throw new Zend_Controller_Response_Exception('Invalid body segment key ("' . gettype($name) . '")');
- }
-
- if (isset($this->_body[$name])) {
- unset($this->_body[$name]);
- }
- $this->_body[$name] = (string) $content;
- return $this;
- }
-
- /**
- * Prepend a named body segment to the body content array
- *
- * If segment already exists, replaces with $content and places at top of
- * array.
- *
- * @param string $name
- * @param string $content
- * @return void
- */
- public function prepend($name, $content)
- {
- if (!is_string($name)) {
- require_once 'Zend/Controller/Response/Exception.php';
- throw new Zend_Controller_Response_Exception('Invalid body segment key ("' . gettype($name) . '")');
- }
-
- if (isset($this->_body[$name])) {
- unset($this->_body[$name]);
- }
-
- $new = array($name => (string) $content);
- $this->_body = $new + $this->_body;
-
- return $this;
- }
-
- /**
- * Insert a named segment into the body content array
- *
- * @param string $name
- * @param string $content
- * @param string $parent
- * @param boolean $before Whether to insert the new segment before or
- * after the parent. Defaults to false (after)
- * @return Zend_Controller_Response_Abstract
- */
- public function insert($name, $content, $parent = null, $before = false)
- {
- if (!is_string($name)) {
- require_once 'Zend/Controller/Response/Exception.php';
- throw new Zend_Controller_Response_Exception('Invalid body segment key ("' . gettype($name) . '")');
- }
-
- if ((null !== $parent) && !is_string($parent)) {
- require_once 'Zend/Controller/Response/Exception.php';
- throw new Zend_Controller_Response_Exception('Invalid body segment parent key ("' . gettype($parent) . '")');
- }
-
- if (isset($this->_body[$name])) {
- unset($this->_body[$name]);
- }
-
- if ((null === $parent) || !isset($this->_body[$parent])) {
- return $this->append($name, $content);
- }
-
- $ins = array($name => (string) $content);
- $keys = array_keys($this->_body);
- $loc = array_search($parent, $keys);
- if (!$before) {
- // Increment location if not inserting before
- ++$loc;
- }
-
- if (0 === $loc) {
- // If location of key is 0, we're prepending
- $this->_body = $ins + $this->_body;
- } elseif ($loc >= (count($this->_body))) {
- // If location of key is maximal, we're appending
- $this->_body = $this->_body + $ins;
- } else {
- // Otherwise, insert at location specified
- $pre = array_slice($this->_body, 0, $loc);
- $post = array_slice($this->_body, $loc);
- $this->_body = $pre + $ins + $post;
- }
-
- return $this;
- }
-
- /**
- * Echo the body segments
- *
- * @return void
- */
- public function outputBody()
- {
- $body = implode('', $this->_body);
- echo $body;
- }
-
- /**
- * Register an exception with the response
- *
- * @param Exception $e
- * @return Zend_Controller_Response_Abstract
- */
- public function setException(Exception $e)
- {
- $this->_exceptions[] = $e;
- return $this;
- }
-
- /**
- * Retrieve the exception stack
- *
- * @return array
- */
- public function getException()
- {
- return $this->_exceptions;
- }
-
- /**
- * Has an exception been registered with the response?
- *
- * @return boolean
- */
- public function isException()
- {
- return !empty($this->_exceptions);
- }
-
- /**
- * Does the response object contain an exception of a given type?
- *
- * @param string $type
- * @return boolean
- */
- public function hasExceptionOfType($type)
- {
- foreach ($this->_exceptions as $e) {
- if ($e instanceof $type) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Does the response object contain an exception with a given message?
- *
- * @param string $message
- * @return boolean
- */
- public function hasExceptionOfMessage($message)
- {
- foreach ($this->_exceptions as $e) {
- if ($message == $e->getMessage()) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Does the response object contain an exception with a given code?
- *
- * @param int $code
- * @return boolean
- */
- public function hasExceptionOfCode($code)
- {
- $code = (int) $code;
- foreach ($this->_exceptions as $e) {
- if ($code == $e->getCode()) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Retrieve all exceptions of a given type
- *
- * @param string $type
- * @return false|array
- */
- public function getExceptionByType($type)
- {
- $exceptions = array();
- foreach ($this->_exceptions as $e) {
- if ($e instanceof $type) {
- $exceptions[] = $e;
- }
- }
-
- if (empty($exceptions)) {
- $exceptions = false;
- }
-
- return $exceptions;
- }
-
- /**
- * Retrieve all exceptions of a given message
- *
- * @param string $message
- * @return false|array
- */
- public function getExceptionByMessage($message)
- {
- $exceptions = array();
- foreach ($this->_exceptions as $e) {
- if ($message == $e->getMessage()) {
- $exceptions[] = $e;
- }
- }
-
- if (empty($exceptions)) {
- $exceptions = false;
- }
-
- return $exceptions;
- }
-
- /**
- * Retrieve all exceptions of a given code
- *
- * @param mixed $code
- * @return void
- */
- public function getExceptionByCode($code)
- {
- $code = (int) $code;
- $exceptions = array();
- foreach ($this->_exceptions as $e) {
- if ($code == $e->getCode()) {
- $exceptions[] = $e;
- }
- }
-
- if (empty($exceptions)) {
- $exceptions = false;
- }
-
- return $exceptions;
- }
-
- /**
- * Whether or not to render exceptions (off by default)
- *
- * If called with no arguments or a null argument, returns the value of the
- * flag; otherwise, sets it and returns the current value.
- *
- * @param boolean $flag Optional
- * @return boolean
- */
- public function renderExceptions($flag = null)
- {
- if (null !== $flag) {
- $this->_renderExceptions = $flag ? true : false;
- }
-
- return $this->_renderExceptions;
- }
-
- /**
- * Send the response, including all headers, rendering exceptions if so
- * requested.
- *
- * @return void
- */
- public function sendResponse()
- {
- $this->sendHeaders();
-
- if ($this->isException() && $this->renderExceptions()) {
- $exceptions = '';
- foreach ($this->getException() as $e) {
- $exceptions .= $e->__toString() . "\n";
- }
- echo $exceptions;
- return;
- }
-
- $this->outputBody();
- }
-
- /**
- * Magic __toString functionality
- *
- * Proxies to {@link sendResponse()} and returns response value as string
- * using output buffering.
- *
- * @return string
- */
- public function __toString()
- {
- ob_start();
- $this->sendResponse();
- return ob_get_clean();
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Response/Cli.php zendframework-2.2.6/library/Zend/Controller/Response/Cli.php
--- zendframework-1.10.4/library/Zend/Controller/Response/Cli.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Response/Cli.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,68 +0,0 @@
-isException() && $this->renderExceptions()) {
- $exceptions = '';
- foreach ($this->getException() as $e) {
- $exceptions .= $e->__toString() . "\n";
- }
- return $exceptions;
- }
-
- return $this->_body;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Response/Exception.php zendframework-2.2.6/library/Zend/Controller/Response/Exception.php
--- zendframework-1.10.4/library/Zend/Controller/Response/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Response/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,36 +0,0 @@
-_headersRaw as $header) {
- $headers[] = $header;
- }
- foreach ($this->_headers as $header) {
- $name = $header['name'];
- $key = strtolower($name);
- if (array_key_exists($name, $headers)) {
- if ($header['replace']) {
- $headers[$key] = $header['name'] . ': ' . $header['value'];
- }
- } else {
- $headers[$key] = $header['name'] . ': ' . $header['value'];
- }
- }
- return $headers;
- }
-
- /**
- * Can we send headers?
- *
- * @param bool $throw
- * @return void
- */
- public function canSendHeaders($throw = false)
- {
- return true;
- }
-
- /**
- * Return the concatenated body segments
- *
- * @return string
- */
- public function outputBody()
- {
- $fullContent = '';
- foreach ($this->_body as $content) {
- $fullContent .= $content;
- }
- return $fullContent;
- }
-
- /**
- * Get body and/or body segments
- *
- * @param bool|string $spec
- * @return string|array|null
- */
- public function getBody($spec = false)
- {
- if (false === $spec) {
- return $this->outputBody();
- } elseif (true === $spec) {
- return $this->_body;
- } elseif (is_string($spec) && isset($this->_body[$spec])) {
- return $this->_body[$spec];
- }
-
- return null;
- }
-
- /**
- * "send" Response
- *
- * Concats all response headers, and then final body (separated by two
- * newlines)
- *
- * @return string
- */
- public function sendResponse()
- {
- $headers = $this->sendHeaders();
- $content = implode("\n", $headers) . "\n\n";
-
- if ($this->isException() && $this->renderExceptions()) {
- $exceptions = '';
- foreach ($this->getException() as $e) {
- $exceptions .= $e->__toString() . "\n";
- }
- $content .= $exceptions;
- } else {
- $content .= $this->outputBody();
- }
-
- return $content;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Router/Abstract.php zendframework-2.2.6/library/Zend/Controller/Router/Abstract.php
--- zendframework-1.10.4/library/Zend/Controller/Router/Abstract.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Router/Abstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,170 +0,0 @@
-setParams($params);
- }
-
- /**
- * Add or modify a parameter to use when instantiating an action controller
- *
- * @param string $name
- * @param mixed $value
- * @return Zend_Controller_Router
- */
- public function setParam($name, $value)
- {
- $name = (string) $name;
- $this->_invokeParams[$name] = $value;
- return $this;
- }
-
- /**
- * Set parameters to pass to action controller constructors
- *
- * @param array $params
- * @return Zend_Controller_Router
- */
- public function setParams(array $params)
- {
- $this->_invokeParams = array_merge($this->_invokeParams, $params);
- return $this;
- }
-
- /**
- * Retrieve a single parameter from the controller parameter stack
- *
- * @param string $name
- * @return mixed
- */
- public function getParam($name)
- {
- if(isset($this->_invokeParams[$name])) {
- return $this->_invokeParams[$name];
- }
-
- return null;
- }
-
- /**
- * Retrieve action controller instantiation parameters
- *
- * @return array
- */
- public function getParams()
- {
- return $this->_invokeParams;
- }
-
- /**
- * Clear the controller parameter stack
- *
- * By default, clears all parameters. If a parameter name is given, clears
- * only that parameter; if an array of parameter names is provided, clears
- * each.
- *
- * @param null|string|array single key or array of keys for params to clear
- * @return Zend_Controller_Router
- */
- public function clearParams($name = null)
- {
- if (null === $name) {
- $this->_invokeParams = array();
- } elseif (is_string($name) && isset($this->_invokeParams[$name])) {
- unset($this->_invokeParams[$name]);
- } elseif (is_array($name)) {
- foreach ($name as $key) {
- if (is_string($key) && isset($this->_invokeParams[$key])) {
- unset($this->_invokeParams[$key]);
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Retrieve Front Controller
- *
- * @return Zend_Controller_Front
- */
- public function getFrontController()
- {
- // Used cache version if found
- if (null !== $this->_frontController) {
- return $this->_frontController;
- }
-
- require_once 'Zend/Controller/Front.php';
- $this->_frontController = Zend_Controller_Front::getInstance();
- return $this->_frontController;
- }
-
- /**
- * Set Front Controller
- *
- * @param Zend_Controller_Front $controller
- * @return Zend_Controller_Router_Interface
- */
- public function setFrontController(Zend_Controller_Front $controller)
- {
- $this->_frontController = $controller;
- return $this;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Router/Exception.php zendframework-2.2.6/library/Zend/Controller/Router/Exception.php
--- zendframework-1.10.4/library/Zend/Controller/Router/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Router/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,36 +0,0 @@
-hasRoute('default')) {
- $dispatcher = $this->getFrontController()->getDispatcher();
- $request = $this->getFrontController()->getRequest();
-
- require_once 'Zend/Controller/Router/Route/Module.php';
- $compat = new Zend_Controller_Router_Route_Module(array(), $dispatcher, $request);
-
- $this->_routes = array_merge(array('default' => $compat), $this->_routes);
- }
-
- return $this;
- }
-
- /**
- * Add route to the route chain
- *
- * If route contains method setRequest(), it is initialized with a request object
- *
- * @param string $name Name of the route
- * @param Zend_Controller_Router_Route_Interface $route Instance of the route
- * @return Zend_Controller_Router_Rewrite
- */
- public function addRoute($name, Zend_Controller_Router_Route_Interface $route)
- {
- if (method_exists($route, 'setRequest')) {
- $route->setRequest($this->getFrontController()->getRequest());
- }
-
- $this->_routes[$name] = $route;
-
- return $this;
- }
-
- /**
- * Add routes to the route chain
- *
- * @param array $routes Array of routes with names as keys and routes as values
- * @return Zend_Controller_Router_Rewrite
- */
- public function addRoutes($routes) {
- foreach ($routes as $name => $route) {
- $this->addRoute($name, $route);
- }
-
- return $this;
- }
-
- /**
- * Create routes out of Zend_Config configuration
- *
- * Example INI:
- * routes.archive.route = "archive/:year/*"
- * routes.archive.defaults.controller = archive
- * routes.archive.defaults.action = show
- * routes.archive.defaults.year = 2000
- * routes.archive.reqs.year = "\d+"
- *
- * routes.news.type = "Zend_Controller_Router_Route_Static"
- * routes.news.route = "news"
- * routes.news.defaults.controller = "news"
- * routes.news.defaults.action = "list"
- *
- * And finally after you have created a Zend_Config with above ini:
- * $router = new Zend_Controller_Router_Rewrite();
- * $router->addConfig($config, 'routes');
- *
- * @param Zend_Config $config Configuration object
- * @param string $section Name of the config section containing route's definitions
- * @throws Zend_Controller_Router_Exception
- * @return Zend_Controller_Router_Rewrite
- */
- public function addConfig(Zend_Config $config, $section = null)
- {
- if ($section !== null) {
- if ($config->{$section} === null) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception("No route configuration in section '{$section}'");
- }
-
- $config = $config->{$section};
- }
-
- foreach ($config as $name => $info) {
- $route = $this->_getRouteFromConfig($info);
-
- if ($route instanceof Zend_Controller_Router_Route_Chain) {
- if (!isset($info->chain)) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception("No chain defined");
- }
-
- if ($info->chain instanceof Zend_Config) {
- $childRouteNames = $info->chain;
- } else {
- $childRouteNames = explode(',', $info->chain);
- }
-
- foreach ($childRouteNames as $childRouteName) {
- $childRoute = $this->getRoute(trim($childRouteName));
- $route->chain($childRoute);
- }
-
- $this->addRoute($name, $route);
- } elseif (isset($info->chains) && $info->chains instanceof Zend_Config) {
- $this->_addChainRoutesFromConfig($name, $route, $info->chains);
- } else {
- $this->addRoute($name, $route);
- }
- }
-
- return $this;
- }
-
- /**
- * Get a route frm a config instance
- *
- * @param Zend_Config $info
- * @return Zend_Controller_Router_Route_Interface
- */
- protected function _getRouteFromConfig(Zend_Config $info)
- {
- $class = (isset($info->type)) ? $info->type : 'Zend_Controller_Router_Route';
- if (!class_exists($class)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($class);
- }
-
- $route = call_user_func(array($class, 'getInstance'), $info);
-
- if (isset($info->abstract) && $info->abstract && method_exists($route, 'isAbstract')) {
- $route->isAbstract(true);
- }
-
- return $route;
- }
-
- /**
- * Add chain routes from a config route
- *
- * @param string $name
- * @param Zend_Controller_Router_Route_Interface $route
- * @param Zend_Config $childRoutesInfo
- * @return void
- */
- protected function _addChainRoutesFromConfig($name,
- Zend_Controller_Router_Route_Interface $route,
- Zend_Config $childRoutesInfo)
- {
- foreach ($childRoutesInfo as $childRouteName => $childRouteInfo) {
- if (is_string($childRouteInfo)) {
- $childRouteName = $childRouteInfo;
- $childRoute = $this->getRoute($childRouteName);
- } else {
- $childRoute = $this->_getRouteFromConfig($childRouteInfo);
- }
-
- if ($route instanceof Zend_Controller_Router_Route_Chain) {
- $chainRoute = clone $route;
- $chainRoute->chain($childRoute);
- } else {
- $chainRoute = $route->chain($childRoute);
- }
-
- $chainName = $name . $this->_chainNameSeparator . $childRouteName;
-
- if (isset($childRouteInfo->chains)) {
- $this->_addChainRoutesFromConfig($chainName, $chainRoute, $childRouteInfo->chains);
- } else {
- $this->addRoute($chainName, $chainRoute);
- }
- }
- }
-
- /**
- * Remove a route from the route chain
- *
- * @param string $name Name of the route
- * @throws Zend_Controller_Router_Exception
- * @return Zend_Controller_Router_Rewrite
- */
- public function removeRoute($name)
- {
- if (!isset($this->_routes[$name])) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception("Route $name is not defined");
- }
-
- unset($this->_routes[$name]);
-
- return $this;
- }
-
- /**
- * Remove all standard default routes
- *
- * @param Zend_Controller_Router_Route_Interface Route
- * @return Zend_Controller_Router_Rewrite
- */
- public function removeDefaultRoutes()
- {
- $this->_useDefaultRoutes = false;
-
- return $this;
- }
-
- /**
- * Check if named route exists
- *
- * @param string $name Name of the route
- * @return boolean
- */
- public function hasRoute($name)
- {
- return isset($this->_routes[$name]);
- }
-
- /**
- * Retrieve a named route
- *
- * @param string $name Name of the route
- * @throws Zend_Controller_Router_Exception
- * @return Zend_Controller_Router_Route_Interface Route object
- */
- public function getRoute($name)
- {
- if (!isset($this->_routes[$name])) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception("Route $name is not defined");
- }
-
- return $this->_routes[$name];
- }
-
- /**
- * Retrieve a currently matched route
- *
- * @throws Zend_Controller_Router_Exception
- * @return Zend_Controller_Router_Route_Interface Route object
- */
- public function getCurrentRoute()
- {
- if (!isset($this->_currentRoute)) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception("Current route is not defined");
- }
- return $this->getRoute($this->_currentRoute);
- }
-
- /**
- * Retrieve a name of currently matched route
- *
- * @throws Zend_Controller_Router_Exception
- * @return Zend_Controller_Router_Route_Interface Route object
- */
- public function getCurrentRouteName()
- {
- if (!isset($this->_currentRoute)) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception("Current route is not defined");
- }
- return $this->_currentRoute;
- }
-
- /**
- * Retrieve an array of routes added to the route chain
- *
- * @return array All of the defined routes
- */
- public function getRoutes()
- {
- return $this->_routes;
- }
-
- /**
- * Find a matching route to the current PATH_INFO and inject
- * returning values to the Request object.
- *
- * @throws Zend_Controller_Router_Exception
- * @return Zend_Controller_Request_Abstract Request object
- */
- public function route(Zend_Controller_Request_Abstract $request)
- {
- if (!$request instanceof Zend_Controller_Request_Http) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception('Zend_Controller_Router_Rewrite requires a Zend_Controller_Request_Http-based request object');
- }
-
- if ($this->_useDefaultRoutes) {
- $this->addDefaultRoutes();
- }
-
- // Find the matching route
- $routeMatched = false;
-
- foreach (array_reverse($this->_routes) as $name => $route) {
- // TODO: Should be an interface method. Hack for 1.0 BC
- if (method_exists($route, 'isAbstract') && $route->isAbstract()) {
- continue;
- }
-
- // TODO: Should be an interface method. Hack for 1.0 BC
- if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) {
- $match = $request->getPathInfo();
- } else {
- $match = $request;
- }
-
- if ($params = $route->match($match)) {
- $this->_setRequestParams($request, $params);
- $this->_currentRoute = $name;
- $routeMatched = true;
- break;
- }
- }
-
- if (!$routeMatched) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception('No route matched the request', 404);
- }
-
- if($this->_useCurrentParamsAsGlobal) {
- $params = $request->getParams();
- foreach($params as $param => $value) {
- $this->setGlobalParam($param, $value);
- }
- }
-
- return $request;
-
- }
-
- protected function _setRequestParams($request, $params)
- {
- foreach ($params as $param => $value) {
-
- $request->setParam($param, $value);
-
- if ($param === $request->getModuleKey()) {
- $request->setModuleName($value);
- }
- if ($param === $request->getControllerKey()) {
- $request->setControllerName($value);
- }
- if ($param === $request->getActionKey()) {
- $request->setActionName($value);
- }
-
- }
- }
-
- /**
- * Generates a URL path that can be used in URL creation, redirection, etc.
- *
- * @param array $userParams Options passed by a user used to override parameters
- * @param mixed $name The name of a Route to use
- * @param bool $reset Whether to reset to the route defaults ignoring URL params
- * @param bool $encode Tells to encode URL parts on output
- * @throws Zend_Controller_Router_Exception
- * @return string Resulting absolute URL path
- */
- public function assemble($userParams, $name = null, $reset = false, $encode = true)
- {
- if ($name == null) {
- try {
- $name = $this->getCurrentRouteName();
- } catch (Zend_Controller_Router_Exception $e) {
- $name = 'default';
- }
- }
-
- $params = array_merge($this->_globalParams, $userParams);
-
- $route = $this->getRoute($name);
- $url = $route->assemble($params, $reset, $encode);
-
- if (!preg_match('|^[a-z]+://|', $url)) {
- $url = rtrim($this->getFrontController()->getBaseUrl(), '/') . '/' . $url;
- }
-
- return $url;
- }
-
- /**
- * Set a global parameter
- *
- * @param string $name
- * @param mixed $value
- * @return Zend_Controller_Router_Rewrite
- */
- public function setGlobalParam($name, $value)
- {
- $this->_globalParams[$name] = $value;
-
- return $this;
- }
-
- /**
- * Set the separator to use with chain names
- *
- * @param string $separator The separator to use
- * @return Zend_Controller_Router_Rewrite
- */
- public function setChainNameSeparator($separator) {
- $this->_chainNameSeparator = $separator;
-
- return $this;
- }
-
- /**
- * Get the separator to use for chain names
- *
- * @return string
- */
- public function getChainNameSeparator() {
- return $this->_chainNameSeparator;
- }
-
- /**
- * Determines/returns whether to use the request parameters as global parameters.
- *
- * @param boolean|null $use
- * Null/unset when you want to retrieve the current state.
- * True when request parameters should be global, false otherwise
- * @return boolean|Zend_Controller_Router_Rewrite
- * Returns a boolean if first param isn't set, returns an
- * instance of Zend_Controller_Router_Rewrite otherwise.
- *
- */
- public function useRequestParametersAsGlobal($use = null) {
- if($use === null) {
- return $this->_useCurrentParamsAsGlobal;
- }
-
- $this->_useCurrentParamsAsGlobal = (bool) $use;
-
- return $this;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Router/Route/Abstract.php zendframework-2.2.6/library/Zend/Controller/Router/Route/Abstract.php
--- zendframework-1.10.4/library/Zend/Controller/Router/Route/Abstract.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Router/Route/Abstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,117 +0,0 @@
-_matchedPath = $path;
- }
-
- /**
- * Get partially matched path
- *
- * @return string
- */
- public function getMatchedPath()
- {
- return $this->_matchedPath;
- }
-
- /**
- * Check or set wether this is an abstract route or not
- *
- * @param boolean $flag
- * @return boolean
- */
- public function isAbstract($flag = null)
- {
- if ($flag !== null) {
- $this->_isAbstract = $flag;
- }
-
- return $this->_isAbstract;
- }
-
- /**
- * Create a new chain
- *
- * @param Zend_Controller_Router_Route_Abstract $route
- * @param string $separator
- * @return Zend_Controller_Router_Route_Chain
- */
- public function chain(Zend_Controller_Router_Route_Abstract $route, $separator = '/')
- {
- require_once 'Zend/Controller/Router/Route/Chain.php';
-
- $chain = new Zend_Controller_Router_Route_Chain();
- $chain->chain($this)->chain($route, $separator);
-
- return $chain;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Router/Route/Chain.php zendframework-2.2.6/library/Zend/Controller/Router/Route/Chain.php
--- zendframework-1.10.4/library/Zend/Controller/Router/Route/Chain.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Router/Route/Chain.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,169 +0,0 @@
-defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
- return new self($config->route, $defs);
- }
-
- /**
- * Add a route to this chain
- *
- * @param Zend_Controller_Router_Route_Abstract $route
- * @param string $separator
- * @return Zend_Controller_Router_Route_Chain
- */
- public function chain(Zend_Controller_Router_Route_Abstract $route, $separator = '/')
- {
- $this->_routes[] = $route;
- $this->_separators[] = $separator;
-
- return $this;
-
- }
-
- /**
- * Matches a user submitted path with a previously defined route.
- * Assigns and returns an array of defaults on a successful match.
- *
- * @param Zend_Controller_Request_Http $request Request to get the path info from
- * @return array|false An array of assigned values or a false on a mismatch
- */
- public function match($request, $partial = null)
- {
- $path = trim($request->getPathInfo(), '/');
- $subPath = $path;
- $values = array();
-
- foreach ($this->_routes as $key => $route) {
- if ($key > 0 && $matchedPath !== null) {
- $separator = substr($subPath, 0, strlen($this->_separators[$key]));
-
- if ($separator !== $this->_separators[$key]) {
- return false;
- }
-
- $subPath = substr($subPath, strlen($separator));
- }
-
- // TODO: Should be an interface method. Hack for 1.0 BC
- if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) {
- $match = $subPath;
- } else {
- $request->setPathInfo($subPath);
- $match = $request;
- }
-
- $res = $route->match($match, true);
- if ($res === false) {
- return false;
- }
-
- $matchedPath = $route->getMatchedPath();
-
- if ($matchedPath !== null) {
- $subPath = substr($subPath, strlen($matchedPath));
- $separator = substr($subPath, 0, strlen($this->_separators[$key]));
- }
-
- $values = $res + $values;
- }
-
- $request->setPathInfo($path);
-
- if ($subPath !== '' && $subPath !== false) {
- return false;
- }
-
- return $values;
- }
-
- /**
- * Assembles a URL path defined by this route
- *
- * @param array $data An array of variable and value pairs used as parameters
- * @return string Route path with user submitted parameters
- */
- public function assemble($data = array(), $reset = false, $encode = false)
- {
- $value = '';
- $numRoutes = count($this->_routes);
-
- foreach ($this->_routes as $key => $route) {
- if ($key > 0) {
- $value .= $this->_separators[$key];
- }
-
- $value .= $route->assemble($data, $reset, $encode, (($numRoutes - 1) > $key));
-
- if (method_exists($route, 'getVariables')) {
- $variables = $route->getVariables();
-
- foreach ($variables as $variable) {
- $data[$variable] = null;
- }
- }
- }
-
- return $value;
- }
-
- /**
- * Set the request object for this and the child routes
- *
- * @param Zend_Controller_Request_Abstract|null $request
- * @return void
- */
- public function setRequest(Zend_Controller_Request_Abstract $request = null)
- {
- $this->_request = $request;
-
- foreach ($this->_routes as $route) {
- if (method_exists($route, 'setRequest')) {
- $route->setRequest($request);
- }
- }
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Router/Route/Hostname.php zendframework-2.2.6/library/Zend/Controller/Router/Route/Hostname.php
--- zendframework-1.10.4/library/Zend/Controller/Router/Route/Hostname.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Router/Route/Hostname.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,342 +0,0 @@
-_request = $request;
- }
-
- /**
- * Get the request object
- *
- * @return Zend_Controller_Request_Abstract $request
- */
- public function getRequest()
- {
- if ($this->_request === null) {
- require_once 'Zend/Controller/Front.php';
- $this->_request = Zend_Controller_Front::getInstance()->getRequest();
- }
-
- return $this->_request;
- }
-
- /**
- * Instantiates route based on passed Zend_Config structure
- *
- * @param Zend_Config $config Configuration object
- */
- public static function getInstance(Zend_Config $config)
- {
- $reqs = ($config->reqs instanceof Zend_Config) ? $config->reqs->toArray() : array();
- $defs = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
- $scheme = (isset($config->scheme)) ? $config->scheme : null;
- return new self($config->route, $defs, $reqs, $scheme);
- }
-
- /**
- * Prepares the route for mapping by splitting (exploding) it
- * to a corresponding atomic parts. These parts are assigned
- * a position which is later used for matching and preparing values.
- *
- * @param string $route Map used to match with later submitted hostname
- * @param array $defaults Defaults for map variables with keys as variable names
- * @param array $reqs Regular expression requirements for variables (keys as variable names)
- * @param string $scheme
- */
- public function __construct($route, $defaults = array(), $reqs = array(), $scheme = null)
- {
- $route = trim($route, '.');
- $this->_defaults = (array) $defaults;
- $this->_requirements = (array) $reqs;
- $this->_scheme = $scheme;
-
- if ($route != '') {
- foreach (explode('.', $route) as $pos => $part) {
- if (substr($part, 0, 1) == $this->_hostVariable) {
- $name = substr($part, 1);
- $this->_parts[$pos] = (isset($reqs[$name]) ? $reqs[$name] : $this->_defaultRegex);
- $this->_variables[$pos] = $name;
- } else {
- $this->_parts[$pos] = $part;
- $this->_staticCount++;
- }
- }
- }
- }
-
- /**
- * Matches a user submitted path with parts defined by a map. Assigns and
- * returns an array of variables on a successful match.
- *
- * @param Zend_Controller_Request_Http $request Request to get the host from
- * @return array|false An array of assigned values or a false on a mismatch
- */
- public function match($request)
- {
- // Check the scheme if required
- if ($this->_scheme !== null) {
- $scheme = $request->getScheme();
-
- if ($scheme !== $this->_scheme) {
- return false;
- }
- }
-
- // Get the host and remove unnecessary port information
- $host = $request->getHttpHost();
- if (preg_match('#:\d+$#', $host, $result) === 1) {
- $host = substr($host, 0, -strlen($result[0]));
- }
-
- $hostStaticCount = 0;
- $values = array();
-
- $host = trim($host, '.');
-
- if ($host != '') {
- $host = explode('.', $host);
-
- foreach ($host as $pos => $hostPart) {
- // Host is longer than a route, it's not a match
- if (!array_key_exists($pos, $this->_parts)) {
- return false;
- }
-
- $name = isset($this->_variables[$pos]) ? $this->_variables[$pos] : null;
- $hostPart = urldecode($hostPart);
-
- // If it's a static part, match directly
- if ($name === null && $this->_parts[$pos] != $hostPart) {
- return false;
- }
-
- // If it's a variable with requirement, match a regex. If not - everything matches
- if ($this->_parts[$pos] !== null && !preg_match($this->_regexDelimiter . '^' . $this->_parts[$pos] . '$' . $this->_regexDelimiter . 'iu', $hostPart)) {
- return false;
- }
-
- // If it's a variable store it's value for later
- if ($name !== null) {
- $values[$name] = $hostPart;
- } else {
- $hostStaticCount++;
- }
- }
- }
-
- // Check if all static mappings have been matched
- if ($this->_staticCount != $hostStaticCount) {
- return false;
- }
-
- $return = $values + $this->_defaults;
-
- // Check if all map variables have been initialized
- foreach ($this->_variables as $var) {
- if (!array_key_exists($var, $return)) {
- return false;
- }
- }
-
- $this->_values = $values;
-
- return $return;
-
- }
-
- /**
- * Assembles user submitted parameters forming a hostname defined by this route
- *
- * @param array $data An array of variable and value pairs used as parameters
- * @param boolean $reset Whether or not to set route defaults with those provided in $data
- * @return string Route path with user submitted parameters
- */
- public function assemble($data = array(), $reset = false, $encode = false, $partial = false)
- {
- $host = array();
- $flag = false;
-
- foreach ($this->_parts as $key => $part) {
- $name = isset($this->_variables[$key]) ? $this->_variables[$key] : null;
-
- $useDefault = false;
- if (isset($name) && array_key_exists($name, $data) && $data[$name] === null) {
- $useDefault = true;
- }
-
- if (isset($name)) {
- if (isset($data[$name]) && !$useDefault) {
- $host[$key] = $data[$name];
- unset($data[$name]);
- } elseif (!$reset && !$useDefault && isset($this->_values[$name])) {
- $host[$key] = $this->_values[$name];
- } elseif (isset($this->_defaults[$name])) {
- $host[$key] = $this->_defaults[$name];
- } else {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception($name . ' is not specified');
- }
- } else {
- $host[$key] = $part;
- }
- }
-
- $return = '';
-
- foreach (array_reverse($host, true) as $key => $value) {
- if ($flag || !isset($this->_variables[$key]) || $value !== $this->getDefault($this->_variables[$key]) || $partial) {
- if ($encode) $value = urlencode($value);
- $return = '.' . $value . $return;
- $flag = true;
- }
- }
-
- $url = trim($return, '.');
-
- if ($this->_scheme !== null) {
- $scheme = $this->_scheme;
- } else {
- $request = $this->getRequest();
- if ($request instanceof Zend_Controller_Request_Http) {
- $scheme = $request->getScheme();
- } else {
- $scheme = 'http';
- }
- }
-
- $hostname = implode('.', $host);
- $url = $scheme . '://' . $url;
-
- return $url;
- }
-
- /**
- * Return a single parameter of route's defaults
- *
- * @param string $name Array key of the parameter
- * @return string Previously set default
- */
- public function getDefault($name) {
- if (isset($this->_defaults[$name])) {
- return $this->_defaults[$name];
- }
- return null;
- }
-
- /**
- * Return an array of defaults
- *
- * @return array Route defaults
- */
- public function getDefaults() {
- return $this->_defaults;
- }
-
- /**
- * Get all variables which are used by the route
- *
- * @return array
- */
- public function getVariables()
- {
- return $this->_variables;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Router/Route/Interface.php zendframework-2.2.6/library/Zend/Controller/Router/Route/Interface.php
--- zendframework-1.10.4/library/Zend/Controller/Router/Route/Interface.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Router/Route/Interface.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,37 +0,0 @@
-defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
- $dispatcher = $frontController->getDispatcher();
- $request = $frontController->getRequest();
-
- return new self($defs, $dispatcher, $request);
- }
-
- /**
- * Constructor
- *
- * @param array $defaults Defaults for map variables with keys as variable names
- * @param Zend_Controller_Dispatcher_Interface $dispatcher Dispatcher object
- * @param Zend_Controller_Request_Abstract $request Request object
- */
- public function __construct(array $defaults = array(),
- Zend_Controller_Dispatcher_Interface $dispatcher = null,
- Zend_Controller_Request_Abstract $request = null)
- {
- $this->_defaults = $defaults;
-
- if (isset($request)) {
- $this->_request = $request;
- }
-
- if (isset($dispatcher)) {
- $this->_dispatcher = $dispatcher;
- }
- }
-
- /**
- * Set request keys based on values in request object
- *
- * @return void
- */
- protected function _setRequestKeys()
- {
- if (null !== $this->_request) {
- $this->_moduleKey = $this->_request->getModuleKey();
- $this->_controllerKey = $this->_request->getControllerKey();
- $this->_actionKey = $this->_request->getActionKey();
- }
-
- if (null !== $this->_dispatcher) {
- $this->_defaults += array(
- $this->_controllerKey => $this->_dispatcher->getDefaultControllerName(),
- $this->_actionKey => $this->_dispatcher->getDefaultAction(),
- $this->_moduleKey => $this->_dispatcher->getDefaultModule()
- );
- }
-
- $this->_keysSet = true;
- }
-
- /**
- * Matches a user submitted path. Assigns and returns an array of variables
- * on a successful match.
- *
- * If a request object is registered, it uses its setModuleName(),
- * setControllerName(), and setActionName() accessors to set those values.
- * Always returns the values as an array.
- *
- * @param string $path Path used to match against this routing map
- * @return array An array of assigned values or a false on a mismatch
- */
- public function match($path, $partial = false)
- {
- $this->_setRequestKeys();
-
- $values = array();
- $params = array();
-
- if (!$partial) {
- $path = trim($path, self::URI_DELIMITER);
- } else {
- $matchedPath = $path;
- }
-
- if ($path != '') {
- $path = explode(self::URI_DELIMITER, $path);
-
- if ($this->_dispatcher && $this->_dispatcher->isValidModule($path[0])) {
- $values[$this->_moduleKey] = array_shift($path);
- $this->_moduleValid = true;
- }
-
- if (count($path) && !empty($path[0])) {
- $values[$this->_controllerKey] = array_shift($path);
- }
-
- if (count($path) && !empty($path[0])) {
- $values[$this->_actionKey] = array_shift($path);
- }
-
- if ($numSegs = count($path)) {
- for ($i = 0; $i < $numSegs; $i = $i + 2) {
- $key = urldecode($path[$i]);
- $val = isset($path[$i + 1]) ? urldecode($path[$i + 1]) : null;
- $params[$key] = (isset($params[$key]) ? (array_merge((array) $params[$key], array($val))): $val);
- }
- }
- }
-
- if ($partial) {
- $this->setMatchedPath($matchedPath);
- }
-
- $this->_values = $values + $params;
-
- return $this->_values + $this->_defaults;
- }
-
- /**
- * Assembles user submitted parameters forming a URL path defined by this route
- *
- * @param array $data An array of variable and value pairs used as parameters
- * @param bool $reset Weither to reset the current params
- * @return string Route path with user submitted parameters
- */
- public function assemble($data = array(), $reset = false, $encode = true, $partial = false)
- {
- if (!$this->_keysSet) {
- $this->_setRequestKeys();
- }
-
- $params = (!$reset) ? $this->_values : array();
-
- foreach ($data as $key => $value) {
- if ($value !== null) {
- $params[$key] = $value;
- } elseif (isset($params[$key])) {
- unset($params[$key]);
- }
- }
-
- $params += $this->_defaults;
-
- $url = '';
-
- if ($this->_moduleValid || array_key_exists($this->_moduleKey, $data)) {
- if ($params[$this->_moduleKey] != $this->_defaults[$this->_moduleKey]) {
- $module = $params[$this->_moduleKey];
- }
- }
- unset($params[$this->_moduleKey]);
-
- $controller = $params[$this->_controllerKey];
- unset($params[$this->_controllerKey]);
-
- $action = $params[$this->_actionKey];
- unset($params[$this->_actionKey]);
-
- foreach ($params as $key => $value) {
- $key = ($encode) ? urlencode($key) : $key;
- if (is_array($value)) {
- foreach ($value as $arrayValue) {
- $arrayValue = ($encode) ? urlencode($arrayValue) : $arrayValue;
- $url .= '/' . $key;
- $url .= '/' . $arrayValue;
- }
- } else {
- if ($encode) $value = urlencode($value);
- $url .= '/' . $key;
- $url .= '/' . $value;
- }
- }
-
- if (!empty($url) || $action !== $this->_defaults[$this->_actionKey]) {
- if ($encode) $action = urlencode($action);
- $url = '/' . $action . $url;
- }
-
- if (!empty($url) || $controller !== $this->_defaults[$this->_controllerKey]) {
- if ($encode) $controller = urlencode($controller);
- $url = '/' . $controller . $url;
- }
-
- if (isset($module)) {
- if ($encode) $module = urlencode($module);
- $url = '/' . $module . $url;
- }
-
- return ltrim($url, self::URI_DELIMITER);
- }
-
- /**
- * Return a single parameter of route's defaults
- *
- * @param string $name Array key of the parameter
- * @return string Previously set default
- */
- public function getDefault($name) {
- if (isset($this->_defaults[$name])) {
- return $this->_defaults[$name];
- }
- }
-
- /**
- * Return an array of defaults
- *
- * @return array Route defaults
- */
- public function getDefaults() {
- return $this->_defaults;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Router/Route/Regex.php zendframework-2.2.6/library/Zend/Controller/Router/Route/Regex.php
--- zendframework-1.10.4/library/Zend/Controller/Router/Route/Regex.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Router/Route/Regex.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,269 +0,0 @@
-defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
- $map = ($config->map instanceof Zend_Config) ? $config->map->toArray() : array();
- $reverse = (isset($config->reverse)) ? $config->reverse : null;
- return new self($config->route, $defs, $map, $reverse);
- }
-
- public function __construct($route, $defaults = array(), $map = array(), $reverse = null)
- {
- $this->_regex = $route;
- $this->_defaults = (array) $defaults;
- $this->_map = (array) $map;
- $this->_reverse = $reverse;
- }
-
- public function getVersion() {
- return 1;
- }
-
- /**
- * Matches a user submitted path with a previously defined route.
- * Assigns and returns an array of defaults on a successful match.
- *
- * @param string $path Path used to match against this routing map
- * @return array|false An array of assigned values or a false on a mismatch
- */
- public function match($path, $partial = false)
- {
- if (!$partial) {
- $path = trim(urldecode($path), '/');
- $regex = '#^' . $this->_regex . '$#i';
- } else {
- $regex = '#^' . $this->_regex . '#i';
- }
-
- $res = preg_match($regex, $path, $values);
-
- if ($res === 0) {
- return false;
- }
-
- if ($partial) {
- $this->setMatchedPath($values[0]);
- }
-
- // array_filter_key()? Why isn't this in a standard PHP function set yet? :)
- foreach ($values as $i => $value) {
- if (!is_int($i) || $i === 0) {
- unset($values[$i]);
- }
- }
-
- $this->_values = $values;
-
- $values = $this->_getMappedValues($values);
- $defaults = $this->_getMappedValues($this->_defaults, false, true);
- $return = $values + $defaults;
-
- return $return;
- }
-
- /**
- * Maps numerically indexed array values to it's associative mapped counterpart.
- * Or vice versa. Uses user provided map array which consists of index => name
- * parameter mapping. If map is not found, it returns original array.
- *
- * Method strips destination type of keys form source array. Ie. if source array is
- * indexed numerically then every associative key will be stripped. Vice versa if reversed
- * is set to true.
- *
- * @param array $values Indexed or associative array of values to map
- * @param boolean $reversed False means translation of index to association. True means reverse.
- * @param boolean $preserve Should wrong type of keys be preserved or stripped.
- * @return array An array of mapped values
- */
- protected function _getMappedValues($values, $reversed = false, $preserve = false)
- {
- if (count($this->_map) == 0) {
- return $values;
- }
-
- $return = array();
-
- foreach ($values as $key => $value) {
- if (is_int($key) && !$reversed) {
- if (array_key_exists($key, $this->_map)) {
- $index = $this->_map[$key];
- } elseif (false === ($index = array_search($key, $this->_map))) {
- $index = $key;
- }
- $return[$index] = $values[$key];
- } elseif ($reversed) {
- $index = $key;
- if (!is_int($key)) {
- if (array_key_exists($key, $this->_map)) {
- $index = $this->_map[$key];
- } else {
- $index = array_search($key, $this->_map, true);
- }
- }
- if (false !== $index) {
- $return[$index] = $values[$key];
- }
- } elseif ($preserve) {
- $return[$key] = $value;
- }
- }
-
- return $return;
- }
-
- /**
- * Assembles a URL path defined by this route
- *
- * @param array $data An array of name (or index) and value pairs used as parameters
- * @return string Route path with user submitted parameters
- */
- public function assemble($data = array(), $reset = false, $encode = false, $partial = false)
- {
- if ($this->_reverse === null) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception('Cannot assemble. Reversed route is not specified.');
- }
-
- $defaultValuesMapped = $this->_getMappedValues($this->_defaults, true, false);
- $matchedValuesMapped = $this->_getMappedValues($this->_values, true, false);
- $dataValuesMapped = $this->_getMappedValues($data, true, false);
-
- // handle resets, if so requested (By null value) to do so
- if (($resetKeys = array_search(null, $dataValuesMapped, true)) !== false) {
- foreach ((array) $resetKeys as $resetKey) {
- if (isset($matchedValuesMapped[$resetKey])) {
- unset($matchedValuesMapped[$resetKey]);
- unset($dataValuesMapped[$resetKey]);
- }
- }
- }
-
- // merge all the data together, first defaults, then values matched, then supplied
- $mergedData = $defaultValuesMapped;
- $mergedData = $this->_arrayMergeNumericKeys($mergedData, $matchedValuesMapped);
- $mergedData = $this->_arrayMergeNumericKeys($mergedData, $dataValuesMapped);
-
- if ($encode) {
- foreach ($mergedData as $key => &$value) {
- $value = urlencode($value);
- }
- }
-
- ksort($mergedData);
-
- $return = @vsprintf($this->_reverse, $mergedData);
-
- if ($return === false) {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception('Cannot assemble. Too few arguments?');
- }
-
- return $return;
-
- }
-
- /**
- * Return a single parameter of route's defaults
- *
- * @param string $name Array key of the parameter
- * @return string Previously set default
- */
- public function getDefault($name) {
- if (isset($this->_defaults[$name])) {
- return $this->_defaults[$name];
- }
- }
-
- /**
- * Return an array of defaults
- *
- * @return array Route defaults
- */
- public function getDefaults() {
- return $this->_defaults;
- }
-
- /**
- * Get all variables which are used by the route
- *
- * @return array
- */
- public function getVariables()
- {
- $variables = array();
-
- foreach ($this->_map as $key => $value) {
- if (is_numeric($key)) {
- $variables[] = $value;
- } else {
- $variables[] = $key;
- }
- }
-
- return $variables;
- }
-
- /**
- * _arrayMergeNumericKeys() - allows for a strict key (numeric's included) array_merge.
- * php's array_merge() lacks the ability to merge with numeric keys.
- *
- * @param array $array1
- * @param array $array2
- * @return array
- */
- protected function _arrayMergeNumericKeys(Array $array1, Array $array2)
- {
- $returnArray = $array1;
- foreach ($array2 as $array2Index => $array2Value) {
- $returnArray[$array2Index] = $array2Value;
- }
- return $returnArray;
- }
-
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Router/Route/Static.php zendframework-2.2.6/library/Zend/Controller/Router/Route/Static.php
--- zendframework-1.10.4/library/Zend/Controller/Router/Route/Static.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Router/Route/Static.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,125 +0,0 @@
-defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
- return new self($config->route, $defs);
- }
-
- /**
- * Prepares the route for mapping.
- *
- * @param string $route Map used to match with later submitted URL path
- * @param array $defaults Defaults for map variables with keys as variable names
- */
- public function __construct($route, $defaults = array())
- {
- $this->_route = trim($route, '/');
- $this->_defaults = (array) $defaults;
- }
-
- /**
- * Matches a user submitted path with a previously defined route.
- * Assigns and returns an array of defaults on a successful match.
- *
- * @param string $path Path used to match against this routing map
- * @return array|false An array of assigned values or a false on a mismatch
- */
- public function match($path, $partial = false)
- {
- if ($partial) {
- if (substr($path, 0, strlen($this->_route)) === $this->_route) {
- $this->setMatchedPath($this->_route);
- return $this->_defaults;
- }
- } else {
- if (trim($path, '/') == $this->_route) {
- return $this->_defaults;
- }
- }
-
- return false;
- }
-
- /**
- * Assembles a URL path defined by this route
- *
- * @param array $data An array of variable and value pairs used as parameters
- * @return string Route path with user submitted parameters
- */
- public function assemble($data = array(), $reset = false, $encode = false, $partial = false)
- {
- return $this->_route;
- }
-
- /**
- * Return a single parameter of route's defaults
- *
- * @param string $name Array key of the parameter
- * @return string Previously set default
- */
- public function getDefault($name) {
- if (isset($this->_defaults[$name])) {
- return $this->_defaults[$name];
- }
- return null;
- }
-
- /**
- * Return an array of defaults
- *
- * @return array Route defaults
- */
- public function getDefaults() {
- return $this->_defaults;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Controller/Router/Route.php zendframework-2.2.6/library/Zend/Controller/Router/Route.php
--- zendframework-1.10.4/library/Zend/Controller/Router/Route.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Controller/Router/Route.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,559 +0,0 @@
-reqs instanceof Zend_Config) ? $config->reqs->toArray() : array();
- $defs = ($config->defaults instanceof Zend_Config) ? $config->defaults->toArray() : array();
- return new self($config->route, $defs, $reqs);
- }
-
- /**
- * Prepares the route for mapping by splitting (exploding) it
- * to a corresponding atomic parts. These parts are assigned
- * a position which is later used for matching and preparing values.
- *
- * @param string $route Map used to match with later submitted URL path
- * @param array $defaults Defaults for map variables with keys as variable names
- * @param array $reqs Regular expression requirements for variables (keys as variable names)
- * @param Zend_Translate $translator Translator to use for this instance
- */
- public function __construct($route, $defaults = array(), $reqs = array(), Zend_Translate $translator = null, $locale = null)
- {
- $route = trim($route, $this->_urlDelimiter);
- $this->_defaults = (array) $defaults;
- $this->_requirements = (array) $reqs;
- $this->_translator = $translator;
- $this->_locale = $locale;
-
- if ($route !== '') {
- foreach (explode($this->_urlDelimiter, $route) as $pos => $part) {
- if (substr($part, 0, 1) == $this->_urlVariable && substr($part, 1, 1) != $this->_urlVariable) {
- $name = substr($part, 1);
-
- if (substr($name, 0, 1) === '@' && substr($name, 1, 1) !== '@') {
- $name = substr($name, 1);
- $this->_translatable[] = $name;
- $this->_isTranslated = true;
- }
-
- $this->_parts[$pos] = (isset($reqs[$name]) ? $reqs[$name] : $this->_defaultRegex);
- $this->_variables[$pos] = $name;
- } else {
- if (substr($part, 0, 1) == $this->_urlVariable) {
- $part = substr($part, 1);
- }
-
- if (substr($part, 0, 1) === '@' && substr($part, 1, 1) !== '@') {
- $this->_isTranslated = true;
- }
-
- $this->_parts[$pos] = $part;
-
- if ($part !== '*') {
- $this->_staticCount++;
- }
- }
- }
- }
- }
-
- /**
- * Matches a user submitted path with parts defined by a map. Assigns and
- * returns an array of variables on a successful match.
- *
- * @param string $path Path used to match against this routing map
- * @return array|false An array of assigned values or a false on a mismatch
- */
- public function match($path, $partial = false)
- {
- if ($this->_isTranslated) {
- $translateMessages = $this->getTranslator()->getMessages();
- }
-
- $pathStaticCount = 0;
- $values = array();
- $matchedPath = '';
-
- if (!$partial) {
- $path = trim($path, $this->_urlDelimiter);
- }
-
- if ($path !== '') {
- $path = explode($this->_urlDelimiter, $path);
-
- foreach ($path as $pos => $pathPart) {
- // Path is longer than a route, it's not a match
- if (!array_key_exists($pos, $this->_parts)) {
- if ($partial) {
- break;
- } else {
- return false;
- }
- }
-
- $matchedPath .= $pathPart . $this->_urlDelimiter;
-
- // If it's a wildcard, get the rest of URL as wildcard data and stop matching
- if ($this->_parts[$pos] == '*') {
- $count = count($path);
- for($i = $pos; $i < $count; $i+=2) {
- $var = urldecode($path[$i]);
- if (!isset($this->_wildcardData[$var]) && !isset($this->_defaults[$var]) && !isset($values[$var])) {
- $this->_wildcardData[$var] = (isset($path[$i+1])) ? urldecode($path[$i+1]) : null;
- }
- }
-
- $matchedPath = implode($this->_urlDelimiter, $path);
- break;
- }
-
- $name = isset($this->_variables[$pos]) ? $this->_variables[$pos] : null;
- $pathPart = urldecode($pathPart);
-
- // Translate value if required
- $part = $this->_parts[$pos];
- if ($this->_isTranslated && (substr($part, 0, 1) === '@' && substr($part, 1, 1) !== '@' && $name === null) || $name !== null && in_array($name, $this->_translatable)) {
- if (substr($part, 0, 1) === '@') {
- $part = substr($part, 1);
- }
-
- if (($originalPathPart = array_search($pathPart, $translateMessages)) !== false) {
- $pathPart = $originalPathPart;
- }
- }
-
- if (substr($part, 0, 2) === '@@') {
- $part = substr($part, 1);
- }
-
- // If it's a static part, match directly
- if ($name === null && $part != $pathPart) {
- return false;
- }
-
- // If it's a variable with requirement, match a regex. If not - everything matches
- if ($part !== null && !preg_match($this->_regexDelimiter . '^' . $part . '$' . $this->_regexDelimiter . 'iu', $pathPart)) {
- return false;
- }
-
- // If it's a variable store it's value for later
- if ($name !== null) {
- $values[$name] = $pathPart;
- } else {
- $pathStaticCount++;
- }
- }
- }
-
- // Check if all static mappings have been matched
- if ($this->_staticCount != $pathStaticCount) {
- return false;
- }
-
- $return = $values + $this->_wildcardData + $this->_defaults;
-
- // Check if all map variables have been initialized
- foreach ($this->_variables as $var) {
- if (!array_key_exists($var, $return)) {
- return false;
- }
- }
-
- $this->setMatchedPath(rtrim($matchedPath, $this->_urlDelimiter));
-
- $this->_values = $values;
-
- return $return;
-
- }
-
- /**
- * Assembles user submitted parameters forming a URL path defined by this route
- *
- * @param array $data An array of variable and value pairs used as parameters
- * @param boolean $reset Whether or not to set route defaults with those provided in $data
- * @return string Route path with user submitted parameters
- */
- public function assemble($data = array(), $reset = false, $encode = false, $partial = false)
- {
- if ($this->_isTranslated) {
- $translator = $this->getTranslator();
-
- if (isset($data['@locale'])) {
- $locale = $data['@locale'];
- unset($data['@locale']);
- } else {
- $locale = $this->getLocale();
- }
- }
-
- $url = array();
- $flag = false;
-
- foreach ($this->_parts as $key => $part) {
- $name = isset($this->_variables[$key]) ? $this->_variables[$key] : null;
-
- $useDefault = false;
- if (isset($name) && array_key_exists($name, $data) && $data[$name] === null) {
- $useDefault = true;
- }
-
- if (isset($name)) {
- if (isset($data[$name]) && !$useDefault) {
- $value = $data[$name];
- unset($data[$name]);
- } elseif (!$reset && !$useDefault && isset($this->_values[$name])) {
- $value = $this->_values[$name];
- } elseif (!$reset && !$useDefault && isset($this->_wildcardData[$name])) {
- $value = $this->_wildcardData[$name];
- } elseif (isset($this->_defaults[$name])) {
- $value = $this->_defaults[$name];
- } else {
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception($name . ' is not specified');
- }
-
- if ($this->_isTranslated && in_array($name, $this->_translatable)) {
- $url[$key] = $translator->translate($value, $locale);
- } else {
- $url[$key] = $value;
- }
- } elseif ($part != '*') {
- if ($this->_isTranslated && substr($part, 0, 1) === '@') {
- if (substr($part, 1, 1) !== '@') {
- $url[$key] = $translator->translate(substr($part, 1), $locale);
- } else {
- $url[$key] = substr($part, 1);
- }
- } else {
- if (substr($part, 0, 2) === '@@') {
- $part = substr($part, 1);
- }
-
- $url[$key] = $part;
- }
- } else {
- if (!$reset) $data += $this->_wildcardData;
- $defaults = $this->getDefaults();
- foreach ($data as $var => $value) {
- if ($value !== null && (!isset($defaults[$var]) || $value != $defaults[$var])) {
- $url[$key++] = $var;
- $url[$key++] = $value;
- $flag = true;
- }
- }
- }
- }
-
- $return = '';
-
- foreach (array_reverse($url, true) as $key => $value) {
- $defaultValue = null;
-
- if (isset($this->_variables[$key])) {
- $defaultValue = $this->getDefault($this->_variables[$key]);
-
- if ($this->_isTranslated && $defaultValue !== null && isset($this->_translatable[$this->_variables[$key]])) {
- $defaultValue = $translator->translate($defaultValue, $locale);
- }
- }
-
- if ($flag || $value !== $defaultValue || $partial) {
- if ($encode) $value = urlencode($value);
- $return = $this->_urlDelimiter . $value . $return;
- $flag = true;
- }
- }
-
- return trim($return, $this->_urlDelimiter);
-
- }
-
- /**
- * Return a single parameter of route's defaults
- *
- * @param string $name Array key of the parameter
- * @return string Previously set default
- */
- public function getDefault($name) {
- if (isset($this->_defaults[$name])) {
- return $this->_defaults[$name];
- }
- return null;
- }
-
- /**
- * Return an array of defaults
- *
- * @return array Route defaults
- */
- public function getDefaults() {
- return $this->_defaults;
- }
-
- /**
- * Get all variables which are used by the route
- *
- * @return array
- */
- public function getVariables()
- {
- return $this->_variables;
- }
-
- /**
- * Set a default translator
- *
- * @param Zend_Translate $translator
- * @return void
- */
- public static function setDefaultTranslator(Zend_Translate $translator = null)
- {
- self::$_defaultTranslator = $translator;
- }
-
- /**
- * Get the default translator
- *
- * @return Zend_Translate
- */
- public static function getDefaultTranslator()
- {
- return self::$_defaultTranslator;
- }
-
- /**
- * Set a translator
- *
- * @param Zend_Translate $translator
- * @return void
- */
- public function setTranslator(Zend_Translate $translator)
- {
- $this->_translator = $translator;
- }
-
- /**
- * Get the translator
- *
- * @throws Zend_Controller_Router_Exception When no translator can be found
- * @return Zend_Translate
- */
- public function getTranslator()
- {
- if ($this->_translator !== null) {
- return $this->_translator;
- } else if (($translator = self::getDefaultTranslator()) !== null) {
- return $translator;
- } else {
- try {
- $translator = Zend_Registry::get('Zend_Translate');
- } catch (Zend_Exception $e) {
- $translator = null;
- }
-
- if ($translator instanceof Zend_Translate) {
- return $translator;
- }
- }
-
- require_once 'Zend/Controller/Router/Exception.php';
- throw new Zend_Controller_Router_Exception('Could not find a translator');
- }
-
- /**
- * Set a default locale
- *
- * @param mixed $locale
- * @return void
- */
- public static function setDefaultLocale($locale = null)
- {
- self::$_defaultLocale = $locale;
- }
-
- /**
- * Get the default locale
- *
- * @return mixed
- */
- public static function getDefaultLocale()
- {
- return self::$_defaultLocale;
- }
-
- /**
- * Set a locale
- *
- * @param mixed $locale
- * @return void
- */
- public function setLocale($locale)
- {
- $this->_locale = $locale;
- }
-
- /**
- * Get the locale
- *
- * @return mixed
- */
- public function getLocale()
- {
- if ($this->_locale !== null) {
- return $this->_locale;
- } else if (($locale = self::getDefaultLocale()) !== null) {
- return $locale;
- } else {
- try {
- $locale = Zend_Registry::get('Zend_Locale');
- } catch (Zend_Exception $e) {
- $locale = null;
- }
-
- if ($locale !== null) {
- return $locale;
- }
- }
-
- return null;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/BlockCipher.php zendframework-2.2.6/library/Zend/Crypt/BlockCipher.php
--- zendframework-1.10.4/library/Zend/Crypt/BlockCipher.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/BlockCipher.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,445 @@
+cipher = $cipher;
+ }
+
+ /**
+ * Factory.
+ *
+ * @param string $adapter
+ * @param array $options
+ * @return BlockCipher
+ */
+ public static function factory($adapter, $options = array())
+ {
+ $plugins = static::getSymmetricPluginManager();
+ $adapter = $plugins->get($adapter, (array) $options);
+
+ return new static($adapter);
+ }
+
+ /**
+ * Returns the symmetric cipher plugin manager. If it doesn't exist it's created.
+ *
+ * @return SymmetricPluginManager
+ */
+ public static function getSymmetricPluginManager()
+ {
+ if (static::$symmetricPlugins === null) {
+ static::setSymmetricPluginManager(new SymmetricPluginManager());
+ }
+
+ return static::$symmetricPlugins;
+ }
+
+ /**
+ * Set the symmetric cipher plugin manager
+ *
+ * @param string|SymmetricPluginManager $plugins
+ * @throws Exception\InvalidArgumentException
+ */
+ public static function setSymmetricPluginManager($plugins)
+ {
+ if (is_string($plugins)) {
+ if (!class_exists($plugins)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Unable to locate symmetric cipher plugins using class "%s"; class does not exist',
+ $plugins
+ ));
+ }
+ $plugins = new $plugins();
+ }
+ if (!$plugins instanceof SymmetricPluginManager) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Expected an instance or extension of %s\SymmetricPluginManager; received "%s"',
+ __NAMESPACE__,
+ (is_object($plugins) ? get_class($plugins) : gettype($plugins))
+ ));
+ }
+ static::$symmetricPlugins = $plugins;
+ }
+
+ /**
+ * Set the symmetric cipher
+ *
+ * @param SymmetricInterface $cipher
+ * @return BlockCipher
+ */
+ public function setCipher(SymmetricInterface $cipher)
+ {
+ $this->cipher = $cipher;
+ return $this;
+ }
+
+ /**
+ * Get symmetric cipher
+ *
+ * @return SymmetricInterface
+ */
+ public function getCipher()
+ {
+ return $this->cipher;
+ }
+
+ /**
+ * Set the number of iterations for Pbkdf2
+ *
+ * @param int $num
+ * @return BlockCipher
+ */
+ public function setKeyIteration($num)
+ {
+ $this->keyIteration = (int) $num;
+
+ return $this;
+ }
+
+ /**
+ * Get the number of iterations for Pbkdf2
+ *
+ * @return int
+ */
+ public function getKeyIteration()
+ {
+ return $this->keyIteration;
+ }
+
+ /**
+ * Set the salt (IV)
+ *
+ * @param string $salt
+ * @return BlockCipher
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setSalt($salt)
+ {
+ try {
+ $this->cipher->setSalt($salt);
+ } catch (Symmetric\Exception\InvalidArgumentException $e) {
+ throw new Exception\InvalidArgumentException("The salt is not valid: " . $e->getMessage());
+ }
+ $this->saltSetted = true;
+
+ return $this;
+ }
+
+ /**
+ * Get the salt (IV) according to the size requested by the algorithm
+ *
+ * @return string
+ */
+ public function getSalt()
+ {
+ return $this->cipher->getSalt();
+ }
+
+ /**
+ * Get the original salt value
+ *
+ * @return string
+ */
+ public function getOriginalSalt()
+ {
+ return $this->cipher->getOriginalSalt();
+ }
+
+ /**
+ * Enable/disable the binary output
+ *
+ * @param bool $value
+ * @return BlockCipher
+ */
+ public function setBinaryOutput($value)
+ {
+ $this->binaryOutput = (bool) $value;
+
+ return $this;
+ }
+
+ /**
+ * Get the value of binary output
+ *
+ * @return bool
+ */
+ public function getBinaryOutput()
+ {
+ return $this->binaryOutput;
+ }
+
+ /**
+ * Set the encryption/decryption key
+ *
+ * @param string $key
+ * @return BlockCipher
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setKey($key)
+ {
+ if (empty($key)) {
+ throw new Exception\InvalidArgumentException('The key cannot be empty');
+ }
+ $this->key = $key;
+
+ return $this;
+ }
+
+ /**
+ * Get the key
+ *
+ * @return string
+ */
+ public function getKey()
+ {
+ return $this->key;
+ }
+
+ /**
+ * Set algorithm of the symmetric cipher
+ *
+ * @param string $algo
+ * @return BlockCipher
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setCipherAlgorithm($algo)
+ {
+ if (empty($this->cipher)) {
+ throw new Exception\InvalidArgumentException('No symmetric cipher specified');
+ }
+ try {
+ $this->cipher->setAlgorithm($algo);
+ } catch (Symmetric\Exception\InvalidArgumentException $e) {
+ throw new Exception\InvalidArgumentException($e->getMessage());
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get the cipher algorithm
+ *
+ * @return string|bool
+ */
+ public function getCipherAlgorithm()
+ {
+ if (!empty($this->cipher)) {
+ return $this->cipher->getAlgorithm();
+ }
+
+ return false;
+ }
+
+ /**
+ * Get the supported algorithms of the symmetric cipher
+ *
+ * @return array
+ */
+ public function getCipherSupportedAlgorithms()
+ {
+ if (!empty($this->cipher)) {
+ return $this->cipher->getSupportedAlgorithms();
+ }
+
+ return array();
+ }
+
+ /**
+ * Set the hash algorithm for HMAC authentication
+ *
+ * @param string $hash
+ * @return BlockCipher
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setHashAlgorithm($hash)
+ {
+ if (!Hash::isSupported($hash)) {
+ throw new Exception\InvalidArgumentException(
+ "The specified hash algorithm '{$hash}' is not supported by Zend\Crypt\Hash"
+ );
+ }
+ $this->hash = $hash;
+
+ return $this;
+ }
+
+ /**
+ * Get the hash algorithm for HMAC authentication
+ *
+ * @return string
+ */
+ public function getHashAlgorithm()
+ {
+ return $this->hash;
+ }
+
+ /**
+ * Encrypt then authenticate using HMAC
+ *
+ * @param string $data
+ * @return string
+ * @throws Exception\InvalidArgumentException
+ */
+ public function encrypt($data)
+ {
+ // 0 (as integer), 0.0 (as float) & '0' (as string) will return false, though these should be allowed
+ if (!is_string($data) || $data === '') {
+ throw new Exception\InvalidArgumentException('The data to encrypt cannot be empty');
+ }
+ if (empty($this->cipher)) {
+ throw new Exception\InvalidArgumentException('No symmetric cipher specified');
+ }
+ if (empty($this->key)) {
+ throw new Exception\InvalidArgumentException('No key specified for the encryption');
+ }
+ $keySize = $this->cipher->getKeySize();
+ // generate a random salt (IV) if the salt has not been set
+ if (!$this->saltSetted) {
+ $this->cipher->setSalt(Rand::getBytes($this->cipher->getSaltSize(), true));
+ }
+ // generate the encryption key and the HMAC key for the authentication
+ $hash = Pbkdf2::calc(self::KEY_DERIV_HMAC,
+ $this->getKey(),
+ $this->getSalt(),
+ $this->keyIteration,
+ $keySize * 2);
+ // set the encryption key
+ $this->cipher->setKey(substr($hash, 0, $keySize));
+ // set the key for HMAC
+ $keyHmac = substr($hash, $keySize);
+ // encryption
+ $ciphertext = $this->cipher->encrypt($data);
+ // HMAC
+ $hmac = Hmac::compute($keyHmac,
+ $this->hash,
+ $this->cipher->getAlgorithm() . $ciphertext);
+ if (!$this->binaryOutput) {
+ $ciphertext = base64_encode($ciphertext);
+ }
+
+ return $hmac . $ciphertext;
+ }
+
+ /**
+ * Decrypt
+ *
+ * @param string $data
+ * @return string|bool
+ * @throws Exception\InvalidArgumentException
+ */
+ public function decrypt($data)
+ {
+ if (!is_string($data)) {
+ throw new Exception\InvalidArgumentException('The data to decrypt must be a string');
+ }
+ if ('' === $data) {
+ throw new Exception\InvalidArgumentException('The data to decrypt cannot be empty');
+ }
+ if (empty($this->key)) {
+ throw new Exception\InvalidArgumentException('No key specified for the decryption');
+ }
+ if (empty($this->cipher)) {
+ throw new Exception\InvalidArgumentException('No symmetric cipher specified');
+ }
+ $hmacSize = Hmac::getOutputSize($this->hash);
+ $hmac = substr($data, 0, $hmacSize);
+ $ciphertext = substr($data, $hmacSize);
+ if (!$this->binaryOutput) {
+ $ciphertext = base64_decode($ciphertext);
+ }
+ $iv = substr($ciphertext, 0, $this->cipher->getSaltSize());
+ $keySize = $this->cipher->getKeySize();
+ // generate the encryption key and the HMAC key for the authentication
+ $hash = Pbkdf2::calc(self::KEY_DERIV_HMAC,
+ $this->getKey(),
+ $iv,
+ $this->keyIteration,
+ $keySize * 2);
+ // set the decryption key
+ $this->cipher->setKey(substr($hash, 0, $keySize));
+ // set the key for HMAC
+ $keyHmac = substr($hash, $keySize);
+ $hmacNew = Hmac::compute($keyHmac,
+ $this->hash,
+ $this->cipher->getAlgorithm() . $ciphertext);
+ if (!Utils::compareStrings($hmacNew, $hmac)) {
+ return false;
+ }
+
+ return $this->cipher->decrypt($ciphertext);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/composer.json zendframework-2.2.6/library/Zend/Crypt/composer.json
--- zendframework-1.10.4/library/Zend/Crypt/composer.json 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/composer.json 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,27 @@
+{
+ "name": "zendframework/zend-crypt",
+ "description": " ",
+ "license": "BSD-3-Clause",
+ "keywords": [
+ "zf2",
+ "crypt"
+ ],
+ "autoload": {
+ "psr-0": {
+ "Zend\\Crypt\\": ""
+ }
+ },
+ "target-dir": "Zend/Crypt",
+ "require": {
+ "php": ">=5.3.3",
+ "zendframework/zend-math": "self.version",
+ "zendframework/zend-stdlib": "self.version",
+ "zendframework/zend-servicemanager": "self.version"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev",
+ "dev-develop": "2.3-dev"
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/DiffieHellman/Exception.php zendframework-2.2.6/library/Zend/Crypt/DiffieHellman/Exception.php
--- zendframework-1.10.4/library/Zend/Crypt/DiffieHellman/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/DiffieHellman/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,36 +0,0 @@
-setPrime($prime);
- $this->setGenerator($generator);
- if (!is_null($privateKey)) {
- $this->setPrivateKey($privateKey, $privateKeyType);
- }
- $this->setBigIntegerMath();
- }
-
- /**
- * Generate own public key. If a private number has not already been
- * set, one will be generated at this stage.
- *
- * @return Zend_Crypt_DiffieHellman
- */
- public function generateKeys()
- {
- if (function_exists('openssl_dh_compute_key') && self::$useOpenssl !== false) {
- $details = array();
- $details['p'] = $this->getPrime();
- $details['g'] = $this->getGenerator();
- if ($this->hasPrivateKey()) {
- $details['priv_key'] = $this->getPrivateKey();
- }
- $opensslKeyResource = openssl_pkey_new( array('dh' => $details) );
- $data = openssl_pkey_get_details($opensslKeyResource);
- $this->setPrivateKey($data['dh']['priv_key'], self::BINARY);
- $this->setPublicKey($data['dh']['pub_key'], self::BINARY);
- } else {
- // Private key is lazy generated in the absence of PHP 5.3's ext/openssl
- $publicKey = $this->_math->powmod($this->getGenerator(), $this->getPrivateKey(), $this->getPrime());
- $this->setPublicKey($publicKey);
- }
- return $this;
- }
-
- /**
- * Setter for the value of the public number
- *
- * @param string $number
- * @param string $type
- * @return Zend_Crypt_DiffieHellman
- */
- public function setPublicKey($number, $type = self::NUMBER)
- {
- if ($type == self::BINARY) {
- $number = $this->_math->fromBinary($number);
- }
- if (!preg_match("/^\d+$/", $number)) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number');
- }
- $this->_publicKey = (string) $number;
- return $this;
- }
-
- /**
- * Returns own public key for communication to the second party to this
- * transaction.
- *
- * @param string $type
- * @return string
- */
- public function getPublicKey($type = self::NUMBER)
- {
- if (is_null($this->_publicKey)) {
- require_once 'Zend/Crypt/DiffieHellman/Exception.php';
- throw new Zend_Crypt_DiffieHellman_Exception('A public key has not yet been generated using a prior call to generateKeys()');
- }
- if ($type == self::BINARY) {
- return $this->_math->toBinary($this->_publicKey);
- } elseif ($type == self::BTWOC) {
- return $this->_math->btwoc($this->_math->toBinary($this->_publicKey));
- }
- return $this->_publicKey;
- }
-
- /**
- * Compute the shared secret key based on the public key received from the
- * the second party to this transaction. This should agree to the secret
- * key the second party computes on our own public key.
- * Once in agreement, the key is known to only to both parties.
- * By default, the function expects the public key to be in binary form
- * which is the typical format when being transmitted.
- *
- * If you need the binary form of the shared secret key, call
- * getSharedSecretKey() with the optional parameter for Binary output.
- *
- * @param string $publicKey
- * @param string $type
- * @return mixed
- */
- public function computeSecretKey($publicKey, $type = self::NUMBER, $output = self::NUMBER)
- {
- if ($type == self::BINARY) {
- $publicKey = $this->_math->fromBinary($publicKey);
- }
- if (!preg_match("/^\d+$/", $publicKey)) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number');
- }
- if (function_exists('openssl_dh_compute_key') && self::$useOpenssl !== false) {
- $this->_secretKey = openssl_dh_compute_key($publicKey, $this->getPublicKey());
- } else {
- $this->_secretKey = $this->_math->powmod($publicKey, $this->getPrivateKey(), $this->getPrime());
- }
- return $this->getSharedSecretKey($output);
- }
-
- /**
- * Return the computed shared secret key from the DiffieHellman transaction
- *
- * @param string $type
- * @return string
- */
- public function getSharedSecretKey($type = self::NUMBER)
- {
- if (!isset($this->_secretKey)) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('A secret key has not yet been computed; call computeSecretKey()');
- }
- if ($type == self::BINARY) {
- return $this->_math->toBinary($this->_secretKey);
- } elseif ($type == self::BTWOC) {
- return $this->_math->btwoc($this->_math->toBinary($this->_secretKey));
- }
- return $this->_secretKey;
- }
-
- /**
- * Setter for the value of the prime number
- *
- * @param string $number
- * @return Zend_Crypt_DiffieHellman
- */
- public function setPrime($number)
- {
- if (!preg_match("/^\d+$/", $number) || $number < 11) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number or too small: should be a large natural number prime');
- }
- $this->_prime = (string) $number;
- return $this;
- }
-
- /**
- * Getter for the value of the prime number
- *
- * @return string
- */
- public function getPrime()
- {
- if (!isset($this->_prime)) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('No prime number has been set');
- }
- return $this->_prime;
- }
-
-
- /**
- * Setter for the value of the generator number
- *
- * @param string $number
- * @return Zend_Crypt_DiffieHellman
- */
- public function setGenerator($number)
- {
- if (!preg_match("/^\d+$/", $number) || $number < 2) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number greater than 1');
- }
- $this->_generator = (string) $number;
- return $this;
- }
-
- /**
- * Getter for the value of the generator number
- *
- * @return string
- */
- public function getGenerator()
- {
- if (!isset($this->_generator)) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('No generator number has been set');
- }
- return $this->_generator;
- }
-
- /**
- * Setter for the value of the private number
- *
- * @param string $number
- * @param string $type
- * @return Zend_Crypt_DiffieHellman
- */
- public function setPrivateKey($number, $type = self::NUMBER)
- {
- if ($type == self::BINARY) {
- $number = $this->_math->fromBinary($number);
- }
- if (!preg_match("/^\d+$/", $number)) {
- require_once('Zend/Crypt/DiffieHellman/Exception.php');
- throw new Zend_Crypt_DiffieHellman_Exception('invalid parameter; not a positive natural number');
- }
- $this->_privateKey = (string) $number;
- return $this;
- }
-
- /**
- * Getter for the value of the private number
- *
- * @param string $type
- * @return string
- */
- public function getPrivateKey($type = self::NUMBER)
- {
- if (!$this->hasPrivateKey()) {
- $this->setPrivateKey($this->_generatePrivateKey());
- }
- if ($type == self::BINARY) {
- return $this->_math->toBinary($this->_privateKey);
- } elseif ($type == self::BTWOC) {
- return $this->_math->btwoc($this->_math->toBinary($this->_privateKey));
- }
- return $this->_privateKey;
- }
-
- /**
- * Check whether a private key currently exists.
- *
- * @return boolean
- */
- public function hasPrivateKey()
- {
- return isset($this->_privateKey);
- }
-
- /**
- * Setter to pass an extension parameter which is used to create
- * a specific BigInteger instance for a specific extension type.
- * Allows manual setting of the class in case of an extension
- * problem or bug.
- *
- * @param string $extension
- * @return void
- */
- public function setBigIntegerMath($extension = null)
- {
- /**
- * @see Zend_Crypt_Math
- */
- require_once 'Zend/Crypt/Math.php';
- $this->_math = new Zend_Crypt_Math($extension);
- }
-
- /**
- * In the event a private number/key has not been set by the user,
- * or generated by ext/openssl, a best attempt will be made to
- * generate a random key. Having a random number generator installed
- * on linux/bsd is highly recommended! The alternative is not recommended
- * for production unless without any other option.
- *
- * @return string
- */
- protected function _generatePrivateKey()
- {
- $rand = $this->_math->rand($this->getGenerator(), $this->getPrime());
- return $rand;
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Crypt/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Crypt/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Exception/ExceptionInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,14 @@
+80 using internal algo)
- * @todo Check if mhash() is a required alternative (will be PECL-only soon)
- * @category Zend
- * @package Zend_Crypt
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class Zend_Crypt_Hmac extends Zend_Crypt
+class Hmac
{
+ const OUTPUT_STRING = false;
+ const OUTPUT_BINARY = true;
/**
- * The key to use for the hash
- *
- * @var string
- */
- protected static $_key = null;
-
- /**
- * pack() format to be used for current hashing method
- *
- * @var string
- */
- protected static $_packFormat = null;
-
- /**
- * Hashing algorithm; can be the md5/sha1 functions or any algorithm name
- * listed in the output of PHP 5.1.2+ hash_algos().
- *
- * @var string
- */
- protected static $_hashAlgorithm = 'md5';
-
- /**
- * List of algorithms supported my mhash()
+ * Last algorithm supported
*
- * @var array
- */
- protected static $_supportedMhashAlgorithms = array('adler32',' crc32', 'crc32b', 'gost',
- 'haval128', 'haval160', 'haval192', 'haval256', 'md4', 'md5', 'ripemd160',
- 'sha1', 'sha256', 'tiger', 'tiger128', 'tiger160');
-
- /**
- * Constants representing the output mode of the hash algorithm
+ * @var string|null
*/
- const STRING = 'string';
- const BINARY = 'binary';
+ protected static $lastAlgorithmSupported;
/**
* Performs a HMAC computation given relevant details such as Key, Hashing
* algorithm, the data to compute MAC of, and an output format of String,
- * Binary notation or BTWOC.
+ * or Binary.
*
- * @param string $key
- * @param string $hash
- * @param string $data
- * @param string $output
- * @param boolean $internal
+ * @param string $key
+ * @param string $hash
+ * @param string $data
+ * @param bool $output
+ * @throws Exception\InvalidArgumentException
* @return string
*/
- public static function compute($key, $hash, $data, $output = self::STRING)
+ public static function compute($key, $hash, $data, $output = self::OUTPUT_STRING)
{
- // set the key
- if (!isset($key) || empty($key)) {
- require_once 'Zend/Crypt/Hmac/Exception.php';
- throw new Zend_Crypt_Hmac_Exception('provided key is null or empty');
+
+ if (empty($key)) {
+ throw new Exception\InvalidArgumentException('Provided key is null or empty');
}
- self::$_key = $key;
- // set the hash
- self::_setHashAlgorithm($hash);
+ if (!$hash || ($hash !== static::$lastAlgorithmSupported && !static::isSupported($hash))) {
+ throw new Exception\InvalidArgumentException(
+ "Hash algorithm is not supported on this PHP installation; provided '{$hash}'"
+ );
+ }
- // perform hashing and return
- return self::_hash($data, $output);
+ return hash_hmac($hash, $data, $key, $output);
}
/**
- * Setter for the hash method.
+ * Get the output size according to the hash algorithm and the output format
*
- * @param string $hash
- * @return Zend_Crypt_Hmac
+ * @param string $hash
+ * @param bool $output
+ * @return int
*/
- protected static function _setHashAlgorithm($hash)
+ public static function getOutputSize($hash, $output = self::OUTPUT_STRING)
{
- if (!isset($hash) || empty($hash)) {
- require_once 'Zend/Crypt/Hmac/Exception.php';
- throw new Zend_Crypt_Hmac_Exception('provided hash string is null or empty');
- }
-
- $hash = strtolower($hash);
- $hashSupported = false;
-
- if (function_exists('hash_algos') && in_array($hash, hash_algos())) {
- $hashSupported = true;
- }
-
- if ($hashSupported === false && function_exists('mhash') && in_array($hash, self::$_supportedAlgosMhash)) {
- $hashSupported = true;
- }
+ return strlen(static::compute('key', $hash, 'data', $output));
+ }
- if ($hashSupported === false) {
- require_once 'Zend/Crypt/Hmac/Exception.php';
- throw new Zend_Crypt_Hmac_Exception('hash algorithm provided is not supported on this PHP installation; please enable the hash or mhash extensions');
- }
- self::$_hashAlgorithm = $hash;
+ /**
+ * Get the supported algorithm
+ *
+ * @return array
+ */
+ public static function getSupportedAlgorithms()
+ {
+ return hash_algos();
}
/**
- * Perform HMAC and return the keyed data
+ * Is the hash algorithm supported?
*
- * @param string $data
- * @param string $output
- * @param bool $internal Option to not use hash() functions for testing
- * @return string
+ * @param string $algorithm
+ * @return bool
*/
- protected static function _hash($data, $output = self::STRING, $internal = false)
+ public static function isSupported($algorithm)
{
- if (function_exists('hash_hmac')) {
- if ($output == self::BINARY) {
- return hash_hmac(self::$_hashAlgorithm, $data, self::$_key, 1);
- }
- return hash_hmac(self::$_hashAlgorithm, $data, self::$_key);
+ if ($algorithm === static::$lastAlgorithmSupported) {
+ return true;
}
- if (function_exists('mhash')) {
- if ($output == self::BINARY) {
- return mhash(self::_getMhashDefinition(self::$_hashAlgorithm), $data, self::$_key);
- }
- $bin = mhash(self::_getMhashDefinition(self::$_hashAlgorithm), $data, self::$_key);
- return bin2hex($bin);
+ if (in_array(strtolower($algorithm), hash_algos(), true)) {
+ static::$lastAlgorithmSupported = $algorithm;
+ return true;
}
+
+ return false;
}
/**
- * Since MHASH accepts an integer constant representing the hash algorithm
- * we need to make a small detour to get the correct integer matching our
- * algorithm's name.
- *
- * @param string $hashAlgorithm
- * @return integer
+ * Clear the cache of last algorithm supported
*/
- protected static function _getMhashDefinition($hashAlgorithm)
+ public static function clearLastAlgorithmCache()
{
- for ($i = 0; $i <= mhash_count(); $i++)
- {
- $types[mhash_get_hash_name($i)] = $i;
- }
- return $types[strtoupper($hashAlgorithm)];
+ static::$lastAlgorithmSupported = null;
}
-
-}
\ No newline at end of file
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Key/Derivation/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Crypt/Key/Derivation/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Crypt/Key/Derivation/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Key/Derivation/Exception/ExceptionInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+ MHASH_MD2,
+ 'md4' => MHASH_MD4,
+ 'md5' => MHASH_MD5,
+ 'sha1' => MHASH_SHA1,
+ 'sha224' => MHASH_SHA224,
+ 'sha256' => MHASH_SHA256,
+ 'sha384' => MHASH_SHA384,
+ 'sha512' => MHASH_SHA512,
+ 'ripemd128' => MHASH_RIPEMD128,
+ 'ripemd256' => MHASH_RIPEMD256,
+ 'ripemd320' => MHASH_RIPEMD320,
+ 'haval128,3' => MHASH_HAVAL128,
+ 'haval160,3' => MHASH_HAVAL160,
+ 'haval192,3' => MHASH_HAVAL192,
+ 'haval224,3' => MHASH_HAVAL224,
+ 'haval256,3' => MHASH_HAVAL256,
+ 'tiger128,3' => MHASH_TIGER128,
+ 'riger160,3' => MHASH_TIGER160,
+ 'whirpool' => MHASH_WHIRLPOOL,
+ 'snefru256' => MHASH_SNEFRU256,
+ 'gost' => MHASH_GOST,
+ 'crc32' => MHASH_CRC32,
+ 'crc32b' => MHASH_CRC32B
+ );
+
+ /**
+ * Generate the new key
+ *
+ * @param string $hash The hash algorithm to be used by HMAC
+ * @param string $password The source password/key
+ * @param int $bytes The output size in bytes
+ * @param string $salt The salt of the algorithm
+ * @throws Exception\InvalidArgumentException
+ * @return string
+ */
+ public static function calc($hash, $password, $salt, $bytes)
+ {
+ if (!in_array($hash, array_keys(static::$supportedMhashAlgos))) {
+ throw new Exception\InvalidArgumentException("The hash algorihtm $hash is not supported by " . __CLASS__);
+ }
+ if (strlen($salt)<8) {
+ throw new Exception\InvalidArgumentException('The salt size must be at least of 8 bytes');
+ }
+ return mhash_keygen_s2k(static::$supportedMhashAlgos[$hash], $password, $salt, $bytes);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Key/Derivation/Scrypt.php zendframework-2.2.6/library/Zend/Crypt/Key/Derivation/Scrypt.php
--- zendframework-1.10.4/library/Zend/Crypt/Key/Derivation/Scrypt.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Key/Derivation/Scrypt.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,341 @@
+ 0 and a power of 2");
+ }
+ if ($n > PHP_INT_MAX / 128 / $r) {
+ throw new Exception\InvalidArgumentException("Parameter n is too large");
+ }
+ if ($r > PHP_INT_MAX / 128 / $p) {
+ throw new Exception\InvalidArgumentException("Parameter r is too large");
+ }
+
+ if (extension_loaded('Scrypt')) {
+ if ($length < 16) {
+ throw new Exception\InvalidArgumentException("Key length is too low, must be greater or equal to 16");
+ }
+ return self::hex2bin(scrypt($password, $salt, $n, $r, $p, $length));
+ }
+
+ $b = Pbkdf2::calc('sha256', $password, $salt, 1, $p * 128 * $r);
+
+ $s = '';
+ for ($i = 0; $i < $p; $i++) {
+ $s .= self::scryptROMix(substr($b, $i * 128 * $r, 128 * $r), $n, $r);
+ }
+
+ return Pbkdf2::calc('sha256', $password, $s, 1, $length);
+ }
+
+ /**
+ * scryptROMix
+ *
+ * @param string $b
+ * @param int $n
+ * @param int $r
+ * @return string
+ * @see https://tools.ietf.org/html/draft-josefsson-scrypt-kdf-01#section-4
+ */
+ protected static function scryptROMix($b, $n, $r)
+ {
+ $x = $b;
+ $v = array();
+ for ($i = 0; $i < $n; $i++) {
+ $v[$i] = $x;
+ $x = self::scryptBlockMix($x, $r);
+ }
+ for ($i = 0; $i < $n; $i++) {
+ $j = self::integerify($x) % $n;
+ $t = $x ^ $v[$j];
+ $x = self::scryptBlockMix($t, $r);
+ }
+ return $x;
+ }
+
+ /**
+ * scryptBlockMix
+ *
+ * @param string $b
+ * @param int $r
+ * @return string
+ * @see https://tools.ietf.org/html/draft-josefsson-scrypt-kdf-01#section-3
+ */
+ protected static function scryptBlockMix($b, $r)
+ {
+ $x = substr($b, -64);
+ $even = '';
+ $odd = '';
+ $len = 2 * $r;
+
+ for ($i = 0; $i < $len; $i++) {
+ if (PHP_INT_SIZE === 4) {
+ $x = self::salsa208Core32($x ^ substr($b, 64 * $i, 64));
+ } else {
+ $x = self::salsa208Core64($x ^ substr($b, 64 * $i, 64));
+ }
+ if ($i % 2 == 0) {
+ $even .= $x;
+ } else {
+ $odd .= $x;
+ }
+ }
+ return $even . $odd;
+ }
+
+ /**
+ * Salsa 20/8 core (32 bit version)
+ *
+ * @param string $b
+ * @return string
+ * @see https://tools.ietf.org/html/draft-josefsson-scrypt-kdf-01#section-2
+ * @see http://cr.yp.to/salsa20.html
+ */
+ protected static function salsa208Core32($b)
+ {
+ $b32 = array();
+ for ($i = 0; $i < 16; $i++) {
+ list(, $b32[$i]) = unpack("V", substr($b, $i * 4, 4));
+ }
+
+ $x = $b32;
+ for ($i = 0; $i < 8; $i += 2) {
+ $a = ($x[ 0] + $x[12]);
+ $x[ 4] ^= ($a << 7) | ($a >> 25) & 0x7f;
+ $a = ($x[ 4] + $x[ 0]);
+ $x[ 8] ^= ($a << 9) | ($a >> 23) & 0x1ff;
+ $a = ($x[ 8] + $x[ 4]);
+ $x[12] ^= ($a << 13) | ($a >> 19) & 0x1fff;
+ $a = ($x[12] + $x[ 8]);
+ $x[ 0] ^= ($a << 18) | ($a >> 14) & 0x3ffff;
+ $a = ($x[ 5] + $x[ 1]);
+ $x[ 9] ^= ($a << 7) | ($a >> 25) & 0x7f;
+ $a = ($x[ 9] + $x[ 5]);
+ $x[13] ^= ($a << 9) | ($a >> 23) & 0x1ff;
+ $a = ($x[13] + $x[ 9]);
+ $x[ 1] ^= ($a << 13) | ($a >> 19) & 0x1fff;
+ $a = ($x[ 1] + $x[13]);
+ $x[ 5] ^= ($a << 18) | ($a >> 14) & 0x3ffff;
+ $a = ($x[10] + $x[ 6]);
+ $x[14] ^= ($a << 7) | ($a >> 25) & 0x7f;
+ $a = ($x[14] + $x[10]);
+ $x[ 2] ^= ($a << 9) | ($a >> 23) & 0x1ff;
+ $a = ($x[ 2] + $x[14]);
+ $x[ 6] ^= ($a << 13) | ($a >> 19) & 0x1fff;
+ $a = ($x[ 6] + $x[ 2]);
+ $x[10] ^= ($a << 18) | ($a >> 14) & 0x3ffff;
+ $a = ($x[15] + $x[11]);
+ $x[ 3] ^= ($a << 7) | ($a >> 25) & 0x7f;
+ $a = ($x[ 3] + $x[15]);
+ $x[ 7] ^= ($a << 9) | ($a >> 23) & 0x1ff;
+ $a = ($x[ 7] + $x[ 3]);
+ $x[11] ^= ($a << 13) | ($a >> 19) & 0x1fff;
+ $a = ($x[11] + $x[ 7]);
+ $x[15] ^= ($a << 18) | ($a >> 14) & 0x3ffff;
+ $a = ($x[ 0] + $x[ 3]);
+ $x[ 1] ^= ($a << 7) | ($a >> 25) & 0x7f;
+ $a = ($x[ 1] + $x[ 0]);
+ $x[ 2] ^= ($a << 9) | ($a >> 23) & 0x1ff;
+ $a = ($x[ 2] + $x[ 1]);
+ $x[ 3] ^= ($a << 13) | ($a >> 19) & 0x1fff;
+ $a = ($x[ 3] + $x[ 2]);
+ $x[ 0] ^= ($a << 18) | ($a >> 14) & 0x3ffff;
+ $a = ($x[ 5] + $x[ 4]);
+ $x[ 6] ^= ($a << 7) | ($a >> 25) & 0x7f;
+ $a = ($x[ 6] + $x[ 5]);
+ $x[ 7] ^= ($a << 9) | ($a >> 23) & 0x1ff;
+ $a = ($x[ 7] + $x[ 6]);
+ $x[ 4] ^= ($a << 13) | ($a >> 19) & 0x1fff;
+ $a = ($x[ 4] + $x[ 7]);
+ $x[ 5] ^= ($a << 18) | ($a >> 14) & 0x3ffff;
+ $a = ($x[10] + $x[ 9]);
+ $x[11] ^= ($a << 7) | ($a >> 25) & 0x7f;
+ $a = ($x[11] + $x[10]);
+ $x[ 8] ^= ($a << 9) | ($a >> 23) & 0x1ff;
+ $a = ($x[ 8] + $x[11]);
+ $x[ 9] ^= ($a << 13) | ($a >> 19) & 0x1fff;
+ $a = ($x[ 9] + $x[ 8]);
+ $x[10] ^= ($a << 18) | ($a >> 14) & 0x3ffff;
+ $a = ($x[15] + $x[14]);
+ $x[12] ^= ($a << 7) | ($a >> 25) & 0x7f;
+ $a = ($x[12] + $x[15]);
+ $x[13] ^= ($a << 9) | ($a >> 23) & 0x1ff;
+ $a = ($x[13] + $x[12]);
+ $x[14] ^= ($a << 13) | ($a >> 19) & 0x1fff;
+ $a = ($x[14] + $x[13]);
+ $x[15] ^= ($a << 18) | ($a >> 14) & 0x3ffff;
+ }
+ for ($i = 0; $i < 16; $i++) {
+ $b32[$i] = $b32[$i] + $x[$i];
+ }
+ $result = '';
+ for ($i = 0; $i < 16; $i++) {
+ $result .= pack("V", $b32[$i]);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Salsa 20/8 core (64 bit version)
+ *
+ * @param string $b
+ * @return string
+ * @see https://tools.ietf.org/html/draft-josefsson-scrypt-kdf-01#section-2
+ * @see http://cr.yp.to/salsa20.html
+ */
+ protected static function salsa208Core64($b)
+ {
+ $b32 = array();
+ for ($i = 0; $i < 16; $i++) {
+ list(, $b32[$i]) = unpack("V", substr($b, $i * 4, 4));
+ }
+
+ $x = $b32;
+ for ($i = 0; $i < 8; $i += 2) {
+ $a = ($x[ 0] + $x[12]) & 0xffffffff;
+ $x[ 4] ^= ($a << 7) | ($a >> 25);
+ $a = ($x[ 4] + $x[ 0]) & 0xffffffff;
+ $x[ 8] ^= ($a << 9) | ($a >> 23);
+ $a = ($x[ 8] + $x[ 4]) & 0xffffffff;
+ $x[12] ^= ($a << 13) | ($a >> 19);
+ $a = ($x[12] + $x[ 8]) & 0xffffffff;
+ $x[ 0] ^= ($a << 18) | ($a >> 14);
+ $a = ($x[ 5] + $x[ 1]) & 0xffffffff;
+ $x[ 9] ^= ($a << 7) | ($a >> 25);
+ $a = ($x[ 9] + $x[ 5]) & 0xffffffff;
+ $x[13] ^= ($a << 9) | ($a >> 23);
+ $a = ($x[13] + $x[ 9]) & 0xffffffff;
+ $x[ 1] ^= ($a << 13) | ($a >> 19);
+ $a = ($x[ 1] + $x[13]) & 0xffffffff;
+ $x[ 5] ^= ($a << 18) | ($a >> 14);
+ $a = ($x[10] + $x[ 6]) & 0xffffffff;
+ $x[14] ^= ($a << 7) | ($a >> 25);
+ $a = ($x[14] + $x[10]) & 0xffffffff;
+ $x[ 2] ^= ($a << 9) | ($a >> 23);
+ $a = ($x[ 2] + $x[14]) & 0xffffffff;
+ $x[ 6] ^= ($a << 13) | ($a >> 19);
+ $a = ($x[ 6] + $x[ 2]) & 0xffffffff;
+ $x[10] ^= ($a << 18) | ($a >> 14);
+ $a = ($x[15] + $x[11]) & 0xffffffff;
+ $x[ 3] ^= ($a << 7) | ($a >> 25);
+ $a = ($x[ 3] + $x[15]) & 0xffffffff;
+ $x[ 7] ^= ($a << 9) | ($a >> 23);
+ $a = ($x[ 7] + $x[ 3]) & 0xffffffff;
+ $x[11] ^= ($a << 13) | ($a >> 19);
+ $a = ($x[11] + $x[ 7]) & 0xffffffff;
+ $x[15] ^= ($a << 18) | ($a >> 14);
+ $a = ($x[ 0] + $x[ 3]) & 0xffffffff;
+ $x[ 1] ^= ($a << 7) | ($a >> 25);
+ $a = ($x[ 1] + $x[ 0]) & 0xffffffff;
+ $x[ 2] ^= ($a << 9) | ($a >> 23);
+ $a = ($x[ 2] + $x[ 1]) & 0xffffffff;
+ $x[ 3] ^= ($a << 13) | ($a >> 19);
+ $a = ($x[ 3] + $x[ 2]) & 0xffffffff;
+ $x[ 0] ^= ($a << 18) | ($a >> 14);
+ $a = ($x[ 5] + $x[ 4]) & 0xffffffff;
+ $x[ 6] ^= ($a << 7) | ($a >> 25);
+ $a = ($x[ 6] + $x[ 5]) & 0xffffffff;
+ $x[ 7] ^= ($a << 9) | ($a >> 23);
+ $a = ($x[ 7] + $x[ 6]) & 0xffffffff;
+ $x[ 4] ^= ($a << 13) | ($a >> 19);
+ $a = ($x[ 4] + $x[ 7]) & 0xffffffff;
+ $x[ 5] ^= ($a << 18) | ($a >> 14);
+ $a = ($x[10] + $x[ 9]) & 0xffffffff;
+ $x[11] ^= ($a << 7) | ($a >> 25);
+ $a = ($x[11] + $x[10]) & 0xffffffff;
+ $x[ 8] ^= ($a << 9) | ($a >> 23);
+ $a = ($x[ 8] + $x[11]) & 0xffffffff;
+ $x[ 9] ^= ($a << 13) | ($a >> 19);
+ $a = ($x[ 9] + $x[ 8]) & 0xffffffff;
+ $x[10] ^= ($a << 18) | ($a >> 14);
+ $a = ($x[15] + $x[14]) & 0xffffffff;
+ $x[12] ^= ($a << 7) | ($a >> 25);
+ $a = ($x[12] + $x[15]) & 0xffffffff;
+ $x[13] ^= ($a << 9) | ($a >> 23);
+ $a = ($x[13] + $x[12]) & 0xffffffff;
+ $x[14] ^= ($a << 13) | ($a >> 19);
+ $a = ($x[14] + $x[13]) & 0xffffffff;
+ $x[15] ^= ($a << 18) | ($a >> 14);
+ }
+ for ($i = 0; $i < 16; $i++) {
+ $b32[$i] = ($b32[$i] + $x[$i]) & 0xffffffff;
+ }
+ $result = '';
+ for ($i = 0; $i < 16; $i++) {
+ $result .= pack("V", $b32[$i]);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Integerify
+ *
+ * Integerify (B[0] ... B[2 * r - 1]) is defined as the result
+ * of interpreting B[2 * r - 1] as a little-endian integer.
+ * Each block B is a string of 64 bytes.
+ *
+ * @param string $b
+ * @return int
+ * @see https://tools.ietf.org/html/draft-josefsson-scrypt-kdf-01#section-4
+ */
+ protected static function integerify($b)
+ {
+ $v = 'v';
+ if (PHP_INT_SIZE === 8) {
+ $v = 'V';
+ }
+ list(,$n) = unpack($v, substr($b, -64));
+ return $n;
+ }
+
+ /**
+ * Convert hex string in a binary string
+ *
+ * @param string $hex
+ * @return string
+ */
+ protected static function hex2bin($hex)
+ {
+ if (version_compare(PHP_VERSION, '5.4') >= 0) {
+ return hex2bin($hex);
+ }
+ $len = strlen($hex);
+ $result = '';
+ for ($i = 0; $i < $len; $i+=2) {
+ $result .= chr(hexdec($hex[$i] . $hex[$i+1]));
+ }
+ return $result;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Math/BigInteger/Bcmath.php zendframework-2.2.6/library/Zend/Crypt/Math/BigInteger/Bcmath.php
--- zendframework-1.10.4/library/Zend/Crypt/Math/BigInteger/Bcmath.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Math/BigInteger/Bcmath.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,203 +0,0 @@
- 0) {
- $return = chr(bcmod($operand, 256)) . $return;
- $operand = bcdiv($operand, 256);
- }
- if (ord($return[0]) > 127) {
- $return = chr(0) . $return;
- }
- return $return;
- }
-
- /**public function integerToBinary($operand)
- {
- $return = '';
- while(bccomp($operand, '0')) {
- $return .= chr(bcmod($operand, '256'));
- $operand = bcdiv($operand, '256');
- }
- return $return;
- }**/ // Prior version for referenced offset
-
-
- public function hexToDecimal($operand)
- {
- $return = '0';
- while(strlen($hex)) {
- $hex = hexdec(substr($operand, 0, 4));
- $dec = bcadd(bcmul($return, 65536), $hex);
- $operand = substr($operand, 4);
- }
- return $return;
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Math/BigInteger/Exception.php zendframework-2.2.6/library/Zend/Crypt/Math/BigInteger/Exception.php
--- zendframework-1.10.4/library/Zend/Crypt/Math/BigInteger/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Math/BigInteger/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,36 +0,0 @@
- '7') {
- $bigInt = '00' . $bigInt;
- }
- $return = pack("H*", $bigInt);
- return $return;
- }
-
-
- public function hexToDecimal($operand)
- {
- $return = '0';
- while(strlen($hex)) {
- $hex = hexdec(substr($operand, 0, 4));
- $dec = gmp_add(gmp_mul($return, 65536), $hex);
- $operand = substr($operand, 4);
- }
- return $return;
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Math/BigInteger/Interface.php zendframework-2.2.6/library/Zend/Crypt/Math/BigInteger/Interface.php
--- zendframework-1.10.4/library/Zend/Crypt/Math/BigInteger/Interface.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Math/BigInteger/Interface.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,51 +0,0 @@
-_loadAdapter($extension);
- }
-
- /**
- * Redirect all public method calls to the wrapped extension object.
- *
- * @param string $methodName
- * @param array $args
- * @throws Zend_Crypt_Math_BigInteger_Exception
- */
- public function __call($methodName, $args)
- {
- if(!method_exists($this->_math, $methodName)) {
- require_once 'Zend/Crypt/Math/BigInteger/Exception.php';
- throw new Zend_Crypt_Math_BigInteger_Exception('invalid method call: ' . get_class($this->_math) . '::' . $methodName . '() does not exist');
- }
- return call_user_func_array(array($this->_math, $methodName), $args);
- }
-
- /**
- * @param string $extension
- * @throws Zend_Crypt_Math_BigInteger_Exception
- */
- protected function _loadAdapter($extension = null)
- {
- if (is_null($extension)) {
- if (extension_loaded('gmp')) {
- $extension = 'gmp';
- //} elseif (extension_loaded('big_int')) {
- // $extension = 'big_int';
- } else {
- $extension = 'bcmath';
- }
- }
- if($extension == 'gmp' && extension_loaded('gmp')) {
- require_once 'Zend/Crypt/Math/BigInteger/Gmp.php';
- $this->_math = new Zend_Crypt_Math_BigInteger_Gmp();
- //} elseif($extension == 'bigint' && extension_loaded('big_int')) {
- // require_once 'Zend/Crypt_Math/BigInteger/Bigint.php';
- // $this->_math = new Zend_Crypt_Math_BigInteger_Bigint();
- } elseif ($extension == 'bcmath') {
- require_once 'Zend/Crypt/Math/BigInteger/Bcmath.php';
- $this->_math = new Zend_Crypt_Math_BigInteger_Bcmath();
- } else {
- require_once 'Zend/Crypt/Math/BigInteger/Exception.php';
- throw new Zend_Crypt_Math_BigInteger_Exception($extension . ' big integer precision math support not detected');
- }
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Math/Exception.php zendframework-2.2.6/library/Zend/Crypt/Math/Exception.php
--- zendframework-1.10.4/library/Zend/Crypt/Math/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Math/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,36 +0,0 @@
- 127) {
- return "\x00" . $long;
- }
- return $long;
- }
-
- /**
- * Translate a binary form into a big integer string
- *
- * @param string $binary
- * @return string
- */
- public function fromBinary($binary) {
- return $this->_math->binaryToInteger($binary);
- }
-
- /**
- * Translate a big integer string into a binary form
- *
- * @param string $integer
- * @return string
- */
- public function toBinary($integer)
- {
- return $this->_math->integerToBinary($integer);
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Password/Apache.php zendframework-2.2.6/library/Zend/Crypt/Password/Apache.php
--- zendframework-1.10.4/library/Zend/Crypt/Password/Apache.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Password/Apache.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,298 @@
+ $value) {
+ switch (strtolower($key)) {
+ case 'format':
+ $this->setFormat($value);
+ break;
+ case 'authname':
+ $this->setAuthName($value);
+ break;
+ case 'username':
+ $this->setUserName($value);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Generate the hash of a password
+ *
+ * @param string $password
+ * @throws Exception\RuntimeException
+ * @return string
+ */
+ public function create($password)
+ {
+ if (empty($this->format)) {
+ throw new Exception\RuntimeException(
+ 'You must specify a password format'
+ );
+ }
+ switch ($this->format) {
+ case 'crypt' :
+ $hash = crypt($password, Rand::getString(2, self::ALPHA64));
+ break;
+ case 'sha1' :
+ $hash = '{SHA}' . base64_encode(sha1($password, true));
+ break;
+ case 'md5' :
+ $hash = $this->apr1Md5($password);
+ break;
+ case 'digest':
+ if (empty($this->userName) || empty($this->authName)) {
+ throw new Exception\RuntimeException(
+ 'You must specify UserName and AuthName (realm) to generate the digest'
+ );
+ }
+ $hash = md5($this->userName . ':' . $this->authName . ':' .$password);
+ break;
+ }
+
+ return $hash;
+ }
+
+ /**
+ * Verify if a password is correct against an hash value
+ *
+ * @param string $password
+ * @param string $hash
+ * @return bool
+ */
+ public function verify($password, $hash)
+ {
+ if (substr($hash, 0, 5) === '{SHA}') {
+ $hash2 = '{SHA}' . base64_encode(sha1($password, true));
+ return ($hash === $hash2);
+ }
+ if (substr($hash, 0, 6) === '$apr1$') {
+ $token = explode('$', $hash);
+ if (empty($token[2])) {
+ throw new Exception\InvalidArgumentException(
+ 'The APR1 password format is not valid'
+ );
+ }
+ $hash2 = $this->apr1Md5($password, $token[2]);
+ return ($hash === $hash2);
+ }
+ if (strlen($hash) > 13) { // digest
+ if (empty($this->userName) || empty($this->authName)) {
+ throw new Exception\RuntimeException(
+ 'You must specify UserName and AuthName (realm) to verify the digest'
+ );
+ }
+ $hash2 = md5($this->userName . ':' . $this->authName . ':' .$password);
+ return ($hash === $hash2);
+ }
+ return (crypt($password, $hash) === $hash);
+ }
+
+ /**
+ * Set the format of the password
+ *
+ * @param string $format
+ * @throws Exception\InvalidArgumentException
+ * @return Apache
+ */
+ public function setFormat($format)
+ {
+ $format = strtolower($format);
+ if (!in_array($format, $this->supportedFormat)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'The format %s specified is not valid. The supported formats are: %s',
+ $format, implode(',', $this->supportedFormat)
+ ));
+ }
+ $this->format = $format;
+
+ return $this;
+ }
+
+ /**
+ * Get the format of the password
+ *
+ * @return string
+ */
+ public function getFormat()
+ {
+ return $this->format;
+ }
+
+ /**
+ * Set the AuthName (for digest authentication)
+ *
+ * @param string $name
+ * @return Apache
+ */
+ public function setAuthName($name)
+ {
+ $this->authName = $name;
+
+ return $this;
+ }
+
+ /**
+ * Get the AuthName (for digest authentication)
+ *
+ * @return string
+ */
+ public function getAuthName()
+ {
+ return $this->authName;
+ }
+
+ /**
+ * Set the username
+ *
+ * @param string $name
+ * @return Apache
+ */
+ public function setUserName($name)
+ {
+ $this->userName = $name;
+
+ return $this;
+ }
+
+ /**
+ * Get the username
+ *
+ * @return string
+ */
+ public function getUserName()
+ {
+ return $this->userName;
+ }
+
+ /**
+ * Convert a binary string using the alphabet "./0-9A-Za-z"
+ *
+ * @param string $value
+ * @return string
+ */
+ protected function toAlphabet64($value)
+ {
+ return strtr(strrev(substr(base64_encode($value), 2)), self::BASE64, self::ALPHA64);
+ }
+
+ /**
+ * APR1 MD5 algorithm
+ *
+ * @param string $password
+ * @param null|string $salt
+ * @return string
+ */
+ protected function apr1Md5($password, $salt = null)
+ {
+ if (null === $salt) {
+ $salt = Rand::getString(8, self::ALPHA64);
+ } else {
+ if (strlen($salt) !== 8) {
+ throw new Exception\InvalidArgumentException(
+ 'The salt value for APR1 algorithm must be 8 characters long'
+ );
+ }
+ for ($i = 0; $i < 8; $i++) {
+ if (strpos(self::ALPHA64, $salt[$i]) === false) {
+ throw new Exception\InvalidArgumentException(
+ 'The salt value must be a string in the alphabet "./0-9A-Za-z"'
+ );
+ }
+ }
+ }
+ $len = strlen($password);
+ $text = $password . '$apr1$' . $salt;
+ $bin = pack("H32", md5($password . $salt . $password));
+ for ($i = $len; $i > 0; $i -= 16) {
+ $text .= substr($bin, 0, min(16, $i));
+ }
+ for ($i = $len; $i > 0; $i >>= 1) {
+ $text .= ($i & 1) ? chr(0) : $password[0];
+ }
+ $bin = pack("H32", md5($text));
+ for ($i = 0; $i < 1000; $i++) {
+ $new = ($i & 1) ? $password : $bin;
+ if ($i % 3) {
+ $new .= $salt;
+ }
+ if ($i % 7) {
+ $new .= $password;
+ }
+ $new .= ($i & 1) ? $bin : $password;
+ $bin = pack("H32", md5($new));
+ }
+ $tmp = '';
+ for ($i = 0; $i < 5; $i++) {
+ $k = $i + 6;
+ $j = $i + 12;
+ if ($j == 16) $j = 5;
+ $tmp = $bin[$i] . $bin[$k] . $bin[$j] . $tmp;
+ }
+ $tmp = chr(0) . chr(0) . $bin[11] . $tmp;
+
+ return '$apr1$' . $salt . '$' . $this->toAlphabet64($tmp);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Password/Bcrypt.php zendframework-2.2.6/library/Zend/Crypt/Password/Bcrypt.php
--- zendframework-1.10.4/library/Zend/Crypt/Password/Bcrypt.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Password/Bcrypt.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,219 @@
+ $value) {
+ switch (strtolower($key)) {
+ case 'salt':
+ $this->setSalt($value);
+ break;
+ case 'cost':
+ $this->setCost($value);
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Bcrypt
+ *
+ * @param string $password
+ * @throws Exception\RuntimeException
+ * @return string
+ */
+ public function create($password)
+ {
+ if (empty($this->salt)) {
+ $salt = Rand::getBytes(self::MIN_SALT_SIZE);
+ } else {
+ $salt = $this->salt;
+ }
+ $salt64 = substr(str_replace('+', '.', base64_encode($salt)), 0, 22);
+ /**
+ * Check for security flaw in the bcrypt implementation used by crypt()
+ * @see http://php.net/security/crypt_blowfish.php
+ */
+ if ((version_compare(PHP_VERSION, '5.3.7') >= 0) && !$this->backwardCompatibility) {
+ $prefix = '$2y$';
+ } else {
+ $prefix = '$2a$';
+ // check if the password contains 8-bit character
+ if (preg_match('/[\x80-\xFF]/', $password)) {
+ throw new Exception\RuntimeException(
+ 'The bcrypt implementation used by PHP can contain a security flaw ' .
+ 'using password with 8-bit character. ' .
+ 'We suggest to upgrade to PHP 5.3.7+ or use passwords with only 7-bit characters'
+ );
+ }
+ }
+ $hash = crypt($password, $prefix . $this->cost . '$' . $salt64);
+ if (strlen($hash) < 13) {
+ throw new Exception\RuntimeException('Error during the bcrypt generation');
+ }
+ return $hash;
+ }
+
+ /**
+ * Verify if a password is correct against an hash value
+ *
+ * @param string $password
+ * @param string $hash
+ * @throws Exception\RuntimeException when the hash is unable to be processed
+ * @return bool
+ */
+ public function verify($password, $hash)
+ {
+ $result = crypt($password, $hash);
+ if ($result === $hash) {
+ return true;
+ }
+ if (strlen($result) <= 13) {
+ /* This should only happen if the algorithm that generated hash is
+ * either unsupported by this version of crypt(), or is invalid.
+ *
+ * An example of when this can happen, is if you generate
+ * non-backwards-compatible hashes on 5.3.7+, and then try to verify
+ * them on < 5.3.7.
+ *
+ * This is needed, because version comparisons are not possible due
+ * to back-ported functionality by some distributions.
+ */
+ throw new Exception\RuntimeException(
+ 'The supplied password hash could not be verified. Please check ' .
+ 'backwards compatibility settings.'
+ );
+ }
+ return false;
+ }
+
+ /**
+ * Set the cost parameter
+ *
+ * @param int|string $cost
+ * @throws Exception\InvalidArgumentException
+ * @return Bcrypt
+ */
+ public function setCost($cost)
+ {
+ if (!empty($cost)) {
+ $cost = (int) $cost;
+ if ($cost < 4 || $cost > 31) {
+ throw new Exception\InvalidArgumentException(
+ 'The cost parameter of bcrypt must be in range 04-31'
+ );
+ }
+ $this->cost = sprintf('%1$02d', $cost);
+ }
+ return $this;
+ }
+
+ /**
+ * Get the cost parameter
+ *
+ * @return string
+ */
+ public function getCost()
+ {
+ return $this->cost;
+ }
+
+ /**
+ * Set the salt value
+ *
+ * @param string $salt
+ * @throws Exception\InvalidArgumentException
+ * @return Bcrypt
+ */
+ public function setSalt($salt)
+ {
+ if (strlen($salt) < self::MIN_SALT_SIZE) {
+ throw new Exception\InvalidArgumentException(
+ 'The length of the salt must be at least ' . self::MIN_SALT_SIZE . ' bytes'
+ );
+ }
+ $this->salt = $salt;
+ return $this;
+ }
+
+ /**
+ * Get the salt value
+ *
+ * @return string
+ */
+ public function getSalt()
+ {
+ return $this->salt;
+ }
+
+ /**
+ * Set the backward compatibility $2a$ instead of $2y$ for PHP 5.3.7+
+ *
+ * @param bool $value
+ * @return Bcrypt
+ */
+ public function setBackwardCompatibility($value)
+ {
+ $this->backwardCompatibility = (bool) $value;
+ return $this;
+ }
+
+ /**
+ * Get the backward compatibility
+ *
+ * @return bool
+ */
+ public function getBackwardCompatibility()
+ {
+ return $this->backwardCompatibility;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Password/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Crypt/Password/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Crypt/Password/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Password/Exception/ExceptionInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+setPrime($prime);
+ $this->setGenerator($generator);
+ if ($privateKey !== null) {
+ $this->setPrivateKey($privateKey, $privateKeyFormat);
+ }
+
+ // set up BigInteger adapter
+ $this->math = Math\BigInteger\BigInteger::factory();
+ }
+
+ /**
+ * Set whether to use openssl extension
+ *
+ * @static
+ * @param bool $flag
+ */
+ public static function useOpensslExtension($flag = true)
+ {
+ static::$useOpenssl = (bool) $flag;
+ }
+
+ /**
+ * Generate own public key. If a private number has not already been set,
+ * one will be generated at this stage.
+ *
+ * @return DiffieHellman
+ * @throws \Zend\Crypt\Exception\RuntimeException
+ */
+ public function generateKeys()
+ {
+ if (function_exists('openssl_dh_compute_key') && static::$useOpenssl !== false) {
+ $details = array(
+ 'p' => $this->convert($this->getPrime(), self::FORMAT_NUMBER, self::FORMAT_BINARY),
+ 'g' => $this->convert($this->getGenerator(), self::FORMAT_NUMBER, self::FORMAT_BINARY)
+ );
+ if ($this->hasPrivateKey()) {
+ $details['priv_key'] = $this->convert(
+ $this->privateKey, self::FORMAT_NUMBER, self::FORMAT_BINARY
+ );
+ $opensslKeyResource = openssl_pkey_new(array('dh' => $details));
+ } else {
+ $opensslKeyResource = openssl_pkey_new(array(
+ 'dh' => $details,
+ 'private_key_bits' => self::DEFAULT_KEY_SIZE,
+ 'private_key_type' => OPENSSL_KEYTYPE_DH
+ ));
+ }
+
+ if (false === $opensslKeyResource) {
+ throw new Exception\RuntimeException(
+ 'Can not generate new key; openssl ' . openssl_error_string()
+ );
+ }
+
+ $data = openssl_pkey_get_details($opensslKeyResource);
+
+ $this->setPrivateKey($data['dh']['priv_key'], self::FORMAT_BINARY);
+ $this->setPublicKey($data['dh']['pub_key'], self::FORMAT_BINARY);
+
+ $this->opensslKeyResource = $opensslKeyResource;
+ } else {
+ // Private key is lazy generated in the absence of ext/openssl
+ $publicKey = $this->math->powmod($this->getGenerator(), $this->getPrivateKey(), $this->getPrime());
+ $this->setPublicKey($publicKey);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Setter for the value of the public number
+ *
+ * @param string $number
+ * @param string $format
+ * @return DiffieHellman
+ * @throws \Zend\Crypt\Exception\InvalidArgumentException
+ */
+ public function setPublicKey($number, $format = self::FORMAT_NUMBER)
+ {
+ $number = $this->convert($number, $format, self::FORMAT_NUMBER);
+ if (!preg_match('/^\d+$/', $number)) {
+ throw new Exception\InvalidArgumentException('Invalid parameter; not a positive natural number');
+ }
+ $this->publicKey = (string) $number;
+
+ return $this;
+ }
+
+ /**
+ * Returns own public key for communication to the second party to this transaction
+ *
+ * @param string $format
+ * @return string
+ * @throws \Zend\Crypt\Exception\InvalidArgumentException
+ */
+ public function getPublicKey($format = self::FORMAT_NUMBER)
+ {
+ if ($this->publicKey === null) {
+ throw new Exception\InvalidArgumentException(
+ 'A public key has not yet been generated using a prior call to generateKeys()'
+ );
+ }
+
+ return $this->convert($this->publicKey, self::FORMAT_NUMBER, $format);
+ }
+
+ /**
+ * Compute the shared secret key based on the public key received from the
+ * the second party to this transaction. This should agree to the secret
+ * key the second party computes on our own public key.
+ * Once in agreement, the key is known to only to both parties.
+ * By default, the function expects the public key to be in binary form
+ * which is the typical format when being transmitted.
+ *
+ * If you need the binary form of the shared secret key, call
+ * getSharedSecretKey() with the optional parameter for Binary output.
+ *
+ * @param string $publicKey
+ * @param string $publicKeyFormat
+ * @param string $secretKeyFormat
+ * @return string
+ * @throws \Zend\Crypt\Exception\InvalidArgumentException
+ * @throws \Zend\Crypt\Exception\RuntimeException
+ */
+ public function computeSecretKey($publicKey, $publicKeyFormat = self::FORMAT_NUMBER,
+ $secretKeyFormat = self::FORMAT_NUMBER)
+ {
+ if (function_exists('openssl_dh_compute_key') && static::$useOpenssl !== false) {
+ $publicKey = $this->convert($publicKey, $publicKeyFormat, self::FORMAT_BINARY);
+ $secretKey = openssl_dh_compute_key($publicKey, $this->opensslKeyResource);
+ if (false === $secretKey) {
+ throw new Exception\RuntimeException(
+ 'Can not compute key; openssl ' . openssl_error_string()
+ );
+ }
+ $this->secretKey = $this->convert($secretKey, self::FORMAT_BINARY, self::FORMAT_NUMBER);
+ } else {
+ $publicKey = $this->convert($publicKey, $publicKeyFormat, self::FORMAT_NUMBER);
+ if (!preg_match('/^\d+$/', $publicKey)) {
+ throw new Exception\InvalidArgumentException(
+ 'Invalid parameter; not a positive natural number'
+ );
+ }
+ $this->secretKey = $this->math->powmod($publicKey, $this->getPrivateKey(), $this->getPrime());
+ }
+
+ return $this->getSharedSecretKey($secretKeyFormat);
+ }
+
+ /**
+ * Return the computed shared secret key from the DiffieHellman transaction
+ *
+ * @param string $format
+ * @return string
+ * @throws \Zend\Crypt\Exception\InvalidArgumentException
+ */
+ public function getSharedSecretKey($format = self::FORMAT_NUMBER)
+ {
+ if (!isset($this->secretKey)) {
+ throw new Exception\InvalidArgumentException(
+ 'A secret key has not yet been computed; call computeSecretKey() first'
+ );
+ }
+
+ return $this->convert($this->secretKey, self::FORMAT_NUMBER, $format);
+ }
+
+ /**
+ * Setter for the value of the prime number
+ *
+ * @param string $number
+ * @return DiffieHellman
+ * @throws \Zend\Crypt\Exception\InvalidArgumentException
+ */
+ public function setPrime($number)
+ {
+ if (!preg_match('/^\d+$/', $number) || $number < 11) {
+ throw new Exception\InvalidArgumentException(
+ 'Invalid parameter; not a positive natural number or too small: ' .
+ 'should be a large natural number prime'
+ );
+ }
+ $this->prime = (string) $number;
+
+ return $this;
+ }
+
+ /**
+ * Getter for the value of the prime number
+ *
+ * @param string $format
+ * @return string
+ * @throws \Zend\Crypt\Exception\InvalidArgumentException
+ */
+ public function getPrime($format = self::FORMAT_NUMBER)
+ {
+ if (!isset($this->prime)) {
+ throw new Exception\InvalidArgumentException('No prime number has been set');
+ }
+
+ return $this->convert($this->prime, self::FORMAT_NUMBER, $format);
+ }
+
+
+ /**
+ * Setter for the value of the generator number
+ *
+ * @param string $number
+ * @return DiffieHellman
+ * @throws \Zend\Crypt\Exception\InvalidArgumentException
+ */
+ public function setGenerator($number)
+ {
+ if (!preg_match('/^\d+$/', $number) || $number < 2) {
+ throw new Exception\InvalidArgumentException(
+ 'Invalid parameter; not a positive natural number greater than 1'
+ );
+ }
+ $this->generator = (string) $number;
+
+ return $this;
+ }
+
+ /**
+ * Getter for the value of the generator number
+ *
+ * @param string $format
+ * @return string
+ * @throws \Zend\Crypt\Exception\InvalidArgumentException
+ */
+ public function getGenerator($format = self::FORMAT_NUMBER)
+ {
+ if (!isset($this->generator)) {
+ throw new Exception\InvalidArgumentException('No generator number has been set');
+ }
+
+ return $this->convert($this->generator, self::FORMAT_NUMBER, $format);
+ }
+
+ /**
+ * Setter for the value of the private number
+ *
+ * @param string $number
+ * @param string $format
+ * @return DiffieHellman
+ * @throws \Zend\Crypt\Exception\InvalidArgumentException
+ */
+ public function setPrivateKey($number, $format = self::FORMAT_NUMBER)
+ {
+ $number = $this->convert($number, $format, self::FORMAT_NUMBER);
+ if (!preg_match('/^\d+$/', $number)) {
+ throw new Exception\InvalidArgumentException('Invalid parameter; not a positive natural number');
+ }
+ $this->privateKey = (string) $number;
+
+ return $this;
+ }
+
+ /**
+ * Getter for the value of the private number
+ *
+ * @param string $format
+ * @return string
+ */
+ public function getPrivateKey($format = self::FORMAT_NUMBER)
+ {
+ if (!$this->hasPrivateKey()) {
+ $this->setPrivateKey($this->generatePrivateKey(), self::FORMAT_BINARY);
+ }
+
+ return $this->convert($this->privateKey, self::FORMAT_NUMBER, $format);
+ }
+
+ /**
+ * Check whether a private key currently exists.
+ *
+ * @return bool
+ */
+ public function hasPrivateKey()
+ {
+ return isset($this->privateKey);
+ }
+
+ /**
+ * Convert number between formats
+ *
+ * @param $number
+ * @param string $inputFormat
+ * @param string $outputFormat
+ * @return string
+ */
+ protected function convert($number, $inputFormat = self::FORMAT_NUMBER,
+ $outputFormat = self::FORMAT_BINARY)
+ {
+ if ($inputFormat == $outputFormat) {
+ return $number;
+ }
+
+ // convert to number
+ switch ($inputFormat) {
+ case self::FORMAT_BINARY:
+ case self::FORMAT_BTWOC:
+ $number = $this->math->binToInt($number);
+ break;
+ case self::FORMAT_NUMBER:
+ default:
+ // do nothing
+ break;
+ }
+
+ // convert to output format
+ switch ($outputFormat) {
+ case self::FORMAT_BINARY:
+ return $this->math->intToBin($number);
+ break;
+ case self::FORMAT_BTWOC:
+ return $this->math->intToBin($number, true);
+ break;
+ case self::FORMAT_NUMBER:
+ default:
+ return $number;
+ break;
+ }
+ }
+
+ /**
+ * In the event a private number/key has not been set by the user,
+ * or generated by ext/openssl, a best attempt will be made to
+ * generate a random key. Having a random number generator installed
+ * on linux/bsd is highly recommended! The alternative is not recommended
+ * for production unless without any other option.
+ *
+ * @return string
+ */
+ protected function generatePrivateKey()
+ {
+ return Math\Rand::getBytes(strlen($this->getPrime()), true);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/PublicKey/Rsa/AbstractKey.php zendframework-2.2.6/library/Zend/Crypt/PublicKey/Rsa/AbstractKey.php
--- zendframework-1.10.4/library/Zend/Crypt/PublicKey/Rsa/AbstractKey.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/PublicKey/Rsa/AbstractKey.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,90 @@
+details['bits'];
+ }
+
+ /**
+ * Retrieve openssl key resource
+ *
+ * @return resource
+ */
+ public function getOpensslKeyResource()
+ {
+ return $this->opensslKeyResource;
+ }
+
+ /**
+ * Encrypt using this key
+ *
+ * @abstract
+ * @param string $data
+ * @return string
+ */
+ abstract public function encrypt($data);
+
+ /**
+ * Decrypt using this key
+ *
+ * @abstract
+ * @param string $data
+ * @return string
+ */
+ abstract public function decrypt($data);
+
+ /**
+ * Get string representation of this key
+ *
+ * @abstract
+ * @return string
+ */
+ abstract public function toString();
+
+ /**
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->toString();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/PublicKey/Rsa/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Crypt/PublicKey/Rsa/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Crypt/PublicKey/Rsa/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/PublicKey/Rsa/Exception/ExceptionInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+pemString = $pemString;
+ $this->opensslKeyResource = $result;
+ $this->details = openssl_pkey_get_details($this->opensslKeyResource);
+ }
+
+ /**
+ * Get the public key
+ *
+ * @return PublicKey
+ */
+ public function getPublicKey()
+ {
+ if ($this->publicKey === null) {
+ $this->publicKey = new PublicKey($this->details['key']);
+ }
+
+ return $this->publicKey;
+ }
+
+ /**
+ * Encrypt using this key
+ *
+ * @param string $data
+ * @return string
+ * @throws Exception\RuntimeException
+ * @throws Exception\InvalidArgumentException
+ */
+ public function encrypt($data)
+ {
+ if (empty($data)) {
+ throw new Exception\InvalidArgumentException('The data to encrypt cannot be empty');
+ }
+
+ $encrypted = '';
+ $result = openssl_private_encrypt($data, $encrypted, $this->getOpensslKeyResource());
+ if (false === $result) {
+ throw new Exception\RuntimeException(
+ 'Can not encrypt; openssl ' . openssl_error_string()
+ );
+ }
+
+ return $encrypted;
+ }
+
+ /**
+ * Decrypt using this key
+ *
+ * @param string $data
+ * @return string
+ * @throws Exception\RuntimeException
+ * @throws Exception\InvalidArgumentException
+ */
+ public function decrypt($data)
+ {
+ if (!is_string($data)) {
+ throw new Exception\InvalidArgumentException('The data to decrypt must be a string');
+ }
+ if ('' === $data) {
+ throw new Exception\InvalidArgumentException('The data to decrypt cannot be empty');
+ }
+
+ $decrypted = '';
+ $result = openssl_private_decrypt($data, $decrypted, $this->getOpensslKeyResource());
+ if (false === $result) {
+ throw new Exception\RuntimeException(
+ 'Can not decrypt; openssl ' . openssl_error_string()
+ );
+ }
+
+ return $decrypted;
+ }
+
+ /**
+ * @return string
+ */
+ public function toString()
+ {
+ return $this->pemString;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/PublicKey/Rsa/PublicKey.php zendframework-2.2.6/library/Zend/Crypt/PublicKey/Rsa/PublicKey.php
--- zendframework-1.10.4/library/Zend/Crypt/PublicKey/Rsa/PublicKey.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/PublicKey/Rsa/PublicKey.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,147 @@
+certificateString = $pemStringOrCertificate;
+ } else {
+ $this->pemString = $pemStringOrCertificate;
+ }
+
+ $this->opensslKeyResource = $result;
+ $this->details = openssl_pkey_get_details($this->opensslKeyResource);
+ }
+
+ /**
+ * Encrypt using this key
+ *
+ * @param string $data
+ * @throws Exception\InvalidArgumentException
+ * @throws Exception\RuntimeException
+ * @return string
+ */
+ public function encrypt($data)
+ {
+ if (empty($data)) {
+ throw new Exception\InvalidArgumentException('The data to encrypt cannot be empty');
+ }
+
+ $encrypted = '';
+ $result = openssl_public_encrypt($data, $encrypted, $this->getOpensslKeyResource());
+ if (false === $result) {
+ throw new Exception\RuntimeException(
+ 'Can not encrypt; openssl ' . openssl_error_string()
+ );
+ }
+
+ return $encrypted;
+ }
+
+
+ /**
+ * Decrypt using this key
+ *
+ * @param string $data
+ * @throws Exception\InvalidArgumentException
+ * @throws Exception\RuntimeException
+ * @return string
+ */
+ public function decrypt($data)
+ {
+ if (!is_string($data)) {
+ throw new Exception\InvalidArgumentException('The data to decrypt must be a string');
+ }
+ if ('' === $data) {
+ throw new Exception\InvalidArgumentException('The data to decrypt cannot be empty');
+ }
+
+ $decrypted = '';
+ $result = openssl_public_decrypt($data, $decrypted, $this->getOpensslKeyResource());
+ if (false === $result) {
+ throw new Exception\RuntimeException(
+ 'Can not decrypt; openssl ' . openssl_error_string()
+ );
+ }
+
+ return $decrypted;
+ }
+
+ /**
+ * Get certificate string
+ *
+ * @return string
+ */
+ public function getCertificate()
+ {
+ return $this->certificateString;
+ }
+
+ /**
+ * To string
+ *
+ * @return string
+ * @throws Exception\RuntimeException
+ */
+ public function toString()
+ {
+ if (!empty($this->certificateString)) {
+ return $this->certificateString;
+ } elseif (!empty($this->pemString)) {
+ return $this->pemString;
+ }
+ throw new Exception\RuntimeException('No public key string representation is available');
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/PublicKey/RsaOptions.php zendframework-2.2.6/library/Zend/Crypt/PublicKey/RsaOptions.php
--- zendframework-1.10.4/library/Zend/Crypt/PublicKey/RsaOptions.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/PublicKey/RsaOptions.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,221 @@
+privateKey = $key;
+ $this->publicKey = $this->privateKey->getPublicKey();
+ return $this;
+ }
+
+ /**
+ * Get private key
+ *
+ * @return null|Rsa\PrivateKey
+ */
+ public function getPrivateKey()
+ {
+ return $this->privateKey;
+ }
+
+ /**
+ * Set public key
+ *
+ * @param Rsa\PublicKey $key
+ * @return RsaOptions
+ */
+ public function setPublicKey(Rsa\PublicKey $key)
+ {
+ $this->publicKey = $key;
+ return $this;
+ }
+
+ /**
+ * Get public key
+ *
+ * @return null|Rsa\PublicKey
+ */
+ public function getPublicKey()
+ {
+ return $this->publicKey;
+ }
+
+ /**
+ * Set pass phrase
+ *
+ * @param string $phrase
+ * @return RsaOptions
+ */
+ public function setPassPhrase($phrase)
+ {
+ $this->passPhrase = (string) $phrase;
+ return $this;
+ }
+
+ /**
+ * Get pass phrase
+ *
+ * @return string
+ */
+ public function getPassPhrase()
+ {
+ return $this->passPhrase;
+ }
+
+ /**
+ * Set hash algorithm
+ *
+ * @param string $hash
+ * @return RsaOptions
+ * @throws Rsa\Exception\RuntimeException
+ * @throws Rsa\Exception\InvalidArgumentException
+ */
+ public function setHashAlgorithm($hash)
+ {
+ $hashUpper = strtoupper($hash);
+ if (!defined('OPENSSL_ALGO_' . $hashUpper)) {
+ throw new Exception\InvalidArgumentException(
+ "Hash algorithm '{$hash}' is not supported"
+ );
+ }
+
+ $this->hashAlgorithm = strtolower($hash);
+ $this->opensslSignatureAlgorithm = constant('OPENSSL_ALGO_' . $hashUpper);
+ return $this;
+ }
+
+ /**
+ * Get hash algorithm
+ *
+ * @return string
+ */
+ public function getHashAlgorithm()
+ {
+ return $this->hashAlgorithm;
+ }
+
+ public function getOpensslSignatureAlgorithm()
+ {
+ if (!isset($this->opensslSignatureAlgorithm)) {
+ $this->opensslSignatureAlgorithm = constant('OPENSSL_ALGO_' . strtoupper($this->hashAlgorithm));
+ }
+ return $this->opensslSignatureAlgorithm;
+ }
+
+ /**
+ * Enable/disable the binary output
+ *
+ * @param bool $value
+ * @return RsaOptions
+ */
+ public function setBinaryOutput($value)
+ {
+ $this->binaryOutput = (bool) $value;
+ return $this;
+ }
+
+ /**
+ * Get the value of binary output
+ *
+ * @return bool
+ */
+ public function getBinaryOutput()
+ {
+ return $this->binaryOutput;
+ }
+
+ /**
+ * Generate new private/public key pair
+ *
+ * @param array $opensslConfig
+ * @return RsaOptions
+ * @throws Rsa\Exception\RuntimeException
+ */
+ public function generateKeys(array $opensslConfig = array())
+ {
+ $opensslConfig = array_replace(array(
+ 'private_key_type' => OPENSSL_KEYTYPE_RSA,
+ 'private_key_bits' => Rsa\PrivateKey::DEFAULT_KEY_SIZE,
+ 'digest_alg' => $this->getHashAlgorithm()
+ ), $opensslConfig);
+
+ // generate
+ $resource = openssl_pkey_new($opensslConfig);
+ if (false === $resource) {
+ throw new Exception\RuntimeException(
+ 'Can not generate keys; openssl ' . openssl_error_string()
+ );
+ }
+
+ // export key
+ $passPhrase = $this->getPassPhrase();
+ $result = openssl_pkey_export($resource, $private, $passPhrase, $opensslConfig);
+ if (false === $result) {
+ throw new Exception\RuntimeException(
+ 'Can not export key; openssl ' . openssl_error_string()
+ );
+ }
+
+ $details = openssl_pkey_get_details($resource);
+ $this->privateKey = new Rsa\PrivateKey($private, $passPhrase);
+ $this->publicKey = new Rsa\PublicKey($details['key']);
+
+ return $this;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/PublicKey/Rsa.php zendframework-2.2.6/library/Zend/Crypt/PublicKey/Rsa.php
--- zendframework-1.10.4/library/Zend/Crypt/PublicKey/Rsa.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/PublicKey/Rsa.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,333 @@
+setPrivateKey($privateKey);
+ }
+ if ($publicKey instanceof Rsa\PublicKey) {
+ $options->setPublicKey($publicKey);
+ }
+
+ return new Rsa($options);
+ }
+
+ /**
+ * Class constructor
+ *
+ * @param RsaOptions $options
+ * @throws Rsa\Exception\RuntimeException
+ */
+ public function __construct(RsaOptions $options = null)
+ {
+ if (!extension_loaded('openssl')) {
+ throw new Exception\RuntimeException(
+ 'Zend\Crypt\PublicKey\Rsa requires openssl extension to be loaded'
+ );
+ }
+
+ if ($options === null) {
+ $this->options = new RsaOptions();
+ } else {
+ $this->options = $options;
+ }
+ }
+
+ /**
+ * Set options
+ *
+ * @param RsaOptions $options
+ * @return Rsa
+ */
+ public function setOptions(RsaOptions $options)
+ {
+ $this->options = $options;
+ return $this;
+ }
+
+ /**
+ * Get options
+ *
+ * @return RsaOptions
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * Return last openssl error(s)
+ *
+ * @return string
+ */
+ public function getOpensslErrorString()
+ {
+ $message = '';
+ while (false !== ($error = openssl_error_string())) {
+ $message .= $error . "\n";
+ }
+ return trim($message);
+ }
+
+ /**
+ * Sign with private key
+ *
+ * @param string $data
+ * @param Rsa\PrivateKey $privateKey
+ * @return string
+ * @throws Rsa\Exception\RuntimeException
+ */
+ public function sign($data, Rsa\PrivateKey $privateKey = null)
+ {
+ $signature = '';
+ if (null === $privateKey) {
+ $privateKey = $this->options->getPrivateKey();
+ }
+
+ $result = openssl_sign(
+ $data,
+ $signature,
+ $privateKey->getOpensslKeyResource(),
+ $this->options->getOpensslSignatureAlgorithm()
+ );
+ if (false === $result) {
+ throw new Exception\RuntimeException(
+ 'Can not generate signature; openssl ' . $this->getOpensslErrorString()
+ );
+ }
+
+ if ($this->options->getBinaryOutput()) {
+ return $signature;
+ }
+
+ return base64_encode($signature);
+ }
+
+ /**
+ * Verify signature with public key
+ *
+ * $signature can be encoded in base64 or not. $mode sets how the input must be processed:
+ * - MODE_AUTO: Check if the $signature is encoded in base64. Not recommended for performance.
+ * - MODE_BASE64: Decode $signature using base64 algorithm.
+ * - MODE_RAW: $signature is not encoded.
+ *
+ * @param string $data
+ * @param string $signature
+ * @param null|Rsa\PublicKey $publicKey
+ * @param int $mode Input encoding
+ * @return bool
+ * @throws Rsa\Exception\RuntimeException
+ * @see Rsa::MODE_AUTO
+ * @see Rsa::MODE_BASE64
+ * @see Rsa::MODE_RAW
+ */
+ public function verify(
+ $data,
+ $signature,
+ Rsa\PublicKey $publicKey = null,
+ $mode = self::MODE_AUTO
+ ) {
+ if (null === $publicKey) {
+ $publicKey = $this->options->getPublicKey();
+ }
+
+ switch ($mode) {
+ case self::MODE_AUTO:
+ // check if data is encoded in Base64
+ $output = base64_decode($signature, true);
+ if ((false !== $output) && ($signature === base64_encode($output))) {
+ $signature = $output;
+ }
+ break;
+ case self::MODE_BASE64:
+ $signature = base64_decode($signature);
+ break;
+ case self::MODE_RAW:
+ default:
+ break;
+ }
+
+ $result = openssl_verify(
+ $data,
+ $signature,
+ $publicKey->getOpensslKeyResource(),
+ $this->options->getOpensslSignatureAlgorithm()
+ );
+ if (-1 === $result) {
+ throw new Exception\RuntimeException(
+ 'Can not verify signature; openssl ' . $this->getOpensslErrorString()
+ );
+ }
+
+ return ($result === 1);
+ }
+
+ /**
+ * Encrypt with private/public key
+ *
+ * @param string $data
+ * @param Rsa\AbstractKey $key
+ * @return string
+ * @throws Rsa\Exception\InvalidArgumentException
+ */
+ public function encrypt($data, Rsa\AbstractKey $key = null)
+ {
+ if (null === $key) {
+ $key = $this->options->getPublicKey();
+ }
+
+ if (null === $key) {
+ throw new Exception\InvalidArgumentException('No key specified for the decryption');
+ }
+
+ $encrypted = $key->encrypt($data);
+
+ if ($this->options->getBinaryOutput()) {
+ return $encrypted;
+ }
+
+ return base64_encode($encrypted);
+ }
+
+ /**
+ * Decrypt with private/public key
+ *
+ * $data can be encoded in base64 or not. $mode sets how the input must be processed:
+ * - MODE_AUTO: Check if the $signature is encoded in base64. Not recommended for performance.
+ * - MODE_BASE64: Decode $data using base64 algorithm.
+ * - MODE_RAW: $data is not encoded.
+ *
+ * @param string $data
+ * @param Rsa\AbstractKey $key
+ * @param int $mode Input encoding
+ * @return string
+ * @throws Rsa\Exception\InvalidArgumentException
+ * @see Rsa::MODE_AUTO
+ * @see Rsa::MODE_BASE64
+ * @see Rsa::MODE_RAW
+ */
+ public function decrypt(
+ $data,
+ Rsa\AbstractKey $key = null,
+ $mode = self::MODE_AUTO
+ ) {
+ if (null === $key) {
+ $key = $this->options->getPrivateKey();
+ }
+
+ if (null === $key) {
+ throw new Exception\InvalidArgumentException('No key specified for the decryption');
+ }
+
+ switch ($mode) {
+ case self::MODE_AUTO:
+ // check if data is encoded in Base64
+ $output = base64_decode($data, true);
+ if ((false !== $output) && ($data === base64_encode($output))) {
+ $data = $output;
+ }
+ break;
+ case self::MODE_BASE64:
+ $data = base64_decode($data);
+ break;
+ case self::MODE_RAW:
+ default:
+ break;
+ }
+
+ return $key->decrypt($data);
+ }
+
+ /**
+ * Generate new private/public key pair
+ * @see RsaOptions::generateKeys()
+ *
+ * @param array $opensslConfig
+ * @return Rsa
+ * @throws Rsa\Exception\RuntimeException
+ */
+ public function generateKeys(array $opensslConfig = array())
+ {
+ $this->options->generateKeys($opensslConfig);
+ return $this;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/README.md zendframework-2.2.6/library/Zend/Crypt/README.md
--- zendframework-1.10.4/library/Zend/Crypt/README.md 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/README.md 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+Crypt Component from ZF2
+========================
+
+This is the Crypt component for ZF2.
+
+- File issues at https://github.com/zendframework/zf2/issues
+- Create pull requests against https://github.com/zendframework/zf2
+- Documentation is at http://framework.zend.com/docs
+
+LICENSE
+-------
+
+The files in this archive are released under the [Zend Framework
+license](http://framework.zend.com/license), which is a 3-clause BSD license.
+
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Rsa/Key/Private.php zendframework-2.2.6/library/Zend/Crypt/Rsa/Key/Private.php
--- zendframework-1.10.4/library/Zend/Crypt/Rsa/Key/Private.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Rsa/Key/Private.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,75 +0,0 @@
-_pemString = $pemString;
- $this->_parse($passPhrase);
- }
-
- /**
- * @param string $passPhrase
- * @throws Zend_Crypt_Exception
- */
- protected function _parse($passPhrase)
- {
- $result = openssl_get_privatekey($this->_pemString, $passPhrase);
- if (!$result) {
- /**
- * @see Zend_Crypt_Exception
- */
- require_once 'Zend/Crypt/Exception.php';
- throw new Zend_Crypt_Exception('Unable to load private key');
- }
- $this->_opensslKeyResource = $result;
- $this->_details = openssl_pkey_get_details($this->_opensslKeyResource);
- }
-
- public function getPublicKey()
- {
- if (is_null($this->_publicKey)) {
- /**
- * @see Zend_Crypt_Rsa_Key_Public
- */
- require_once 'Zend/Crypt/Rsa/Key/Public.php';
- $this->_publicKey = new Zend_Crypt_Rsa_Key_Public($this->_details['key']);
- }
- return $this->_publicKey;
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Rsa/Key/Public.php zendframework-2.2.6/library/Zend/Crypt/Rsa/Key/Public.php
--- zendframework-1.10.4/library/Zend/Crypt/Rsa/Key/Public.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Rsa/Key/Public.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,74 +0,0 @@
-_parse($string);
- }
-
- /**
- * @param string $string
- * @throws Zend_Crypt_Exception
- */
- protected function _parse($string)
- {
- if (preg_match("/^-----BEGIN CERTIFICATE-----/", $string)) {
- $this->_certificateString = $string;
- } else {
- $this->_pemString = $string;
- }
- $result = openssl_get_publickey($string);
- if (!$result) {
- /**
- * @see Zend_Crypt_Exception
- */
- require_once 'Zend/Crypt/Exception.php';
- throw new Zend_Crypt_Exception('Unable to load public key');
- }
- //openssl_pkey_export($result, $public);
- //$this->_pemString = $public;
- $this->_opensslKeyResource = $result;
- $this->_details = openssl_pkey_get_details($this->_opensslKeyResource);
- }
-
- public function getCertificate()
- {
- return $this->_certificateString;
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Rsa/Key.php zendframework-2.2.6/library/Zend/Crypt/Rsa/Key.php
--- zendframework-1.10.4/library/Zend/Crypt/Rsa/Key.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Rsa/Key.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,95 +0,0 @@
-_opensslKeyResource;
- }
-
- /**
- * @return string
- * @throws Zend_Crypt_Exception
- */
- public function toString()
- {
- if (!empty($this->_pemString)) {
- return $this->_pemString;
- } elseif (!empty($this->_certificateString)) {
- return $this->_certificateString;
- }
- /**
- * @see Zend_Crypt_Exception
- */
- require_once 'Zend/Crypt/Exception.php';
- throw new Zend_Crypt_Exception('No public key string representation is available');
- }
-
- /**
- * @return string
- */
- public function __toString()
- {
- return $this->toString();
- }
-
- public function count()
- {
- return $this->_details['bits'];
- }
-
- public function getType()
- {
- return $this->_details['type'];
- }
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Rsa.php zendframework-2.2.6/library/Zend/Crypt/Rsa.php
--- zendframework-1.10.4/library/Zend/Crypt/Rsa.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Rsa.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,298 +0,0 @@
-setOptions($options);
- }
- }
-
- public function setOptions(array $options)
- {
- if (isset($options['passPhrase'])) {
- $this->_passPhrase = $options['passPhrase'];
- }
- foreach ($options as $option=>$value) {
- switch ($option) {
- case 'pemString':
- $this->setPemString($value);
- break;
- case 'pemPath':
- $this->setPemPath($value);
- break;
- case 'certificateString':
- $this->setCertificateString($value);
- break;
- case 'certificatePath':
- $this->setCertificatePath($value);
- break;
- case 'hashAlgorithm':
- $this->setHashAlgorithm($value);
- break;
- }
- }
- }
-
- public function getPrivateKey()
- {
- return $this->_privateKey;
- }
-
- public function getPublicKey()
- {
- return $this->_publicKey;
- }
-
- /**
- * @param string $data
- * @param Zend_Crypt_Rsa_Key_Private $privateKey
- * @param string $format
- * @return string
- */
- public function sign($data, Zend_Crypt_Rsa_Key_Private $privateKey = null, $format = null)
- {
- $signature = '';
- if (isset($privateKey)) {
- $opensslKeyResource = $privateKey->getOpensslKeyResource();
- } else {
- $opensslKeyResource = $this->_privateKey->getOpensslKeyResource();
- }
- $result = openssl_sign(
- $data, $signature,
- $opensslKeyResource,
- $this->getHashAlgorithm()
- );
- if ($format == self::BASE64) {
- return base64_encode($signature);
- }
- return $signature;
- }
-
- /**
- * @param string $data
- * @param string $signature
- * @param string $format
- * @return string
- */
- public function verifySignature($data, $signature, $format = null)
- {
- if ($format == self::BASE64) {
- $signature = base64_decode($signature);
- }
- $result = openssl_verify($data, $signature,
- $this->getPublicKey()->getOpensslKeyResource(),
- $this->getHashAlgorithm());
- return $result;
- }
-
- /**
- * @param string $data
- * @param Zend_Crypt_Rsa_Key $key
- * @param string $format
- * @return string
- */
- public function encrypt($data, Zend_Crypt_Rsa_Key $key, $format = null)
- {
- $encrypted = '';
- $function = 'openssl_public_encrypt';
- if ($key instanceof Zend_Crypt_Rsa_Key_Private) {
- $function = 'openssl_private_encrypt';
- }
- $function($data, $encrypted, $key->getOpensslKeyResource());
- if ($format == self::BASE64) {
- return base64_encode($encrypted);
- }
- return $encrypted;
- }
-
- /**
- * @param string $data
- * @param Zend_Crypt_Rsa_Key $key
- * @param string $format
- * @return string
- */
- public function decrypt($data, Zend_Crypt_Rsa_Key $key, $format = null)
- {
- $decrypted = '';
- if ($format == self::BASE64) {
- $data = base64_decode($data);
- }
- $function = 'openssl_private_decrypt';
- if ($key instanceof Zend_Crypt_Rsa_Key_Public) {
- $function = 'openssl_public_decrypt';
- }
- $function($data, $decrypted, $key->getOpensslKeyResource());
- return $decrypted;
- }
-
- public function generateKeys(array $configargs = null)
- {
- $config = null;
- $passPhrase = null;
- if (!is_null($configargs)) {
- if (isset($configargs['passPhrase'])) {
- $passPhrase = $configargs['passPhrase'];
- unset($configargs['passPhrase']);
- }
- $config = $this->_parseConfigArgs($configargs);
- }
- $privateKey = null;
- $publicKey = null;
- $resource = openssl_pkey_new($config);
- // above fails on PHP 5.3
- openssl_pkey_export($resource, $private, $passPhrase);
- $privateKey = new Zend_Crypt_Rsa_Key_Private($private, $passPhrase);
- $details = openssl_pkey_get_details($resource);
- $publicKey = new Zend_Crypt_Rsa_Key_Public($details['key']);
- $return = new ArrayObject(array(
- 'privateKey'=>$privateKey,
- 'publicKey'=>$publicKey
- ), ArrayObject::ARRAY_AS_PROPS);
- return $return;
- }
-
- /**
- * @param string $value
- */
- public function setPemString($value)
- {
- $this->_pemString = $value;
- $this->_privateKey = new Zend_Crypt_Rsa_Key_Private($this->_pemString, $this->_passPhrase);
- $this->_publicKey = $this->_privateKey->getPublicKey();
- }
-
- public function setPemPath($value)
- {
- $this->_pemPath = $value;
- $this->setPemString(file_get_contents($this->_pemPath));
- }
-
- public function setCertificateString($value)
- {
- $this->_certificateString = $value;
- $this->_publicKey = new Zend_Crypt_Rsa_Key_Public($this->_certificateString, $this->_passPhrase);
- }
-
- public function setCertificatePath($value)
- {
- $this->_certificatePath = $value;
- $this->setCertificateString(file_get_contents($this->_certificatePath));
- }
-
- public function setHashAlgorithm($name)
- {
- switch ($name) {
- case 'md2':
- $this->_hashAlgorithm = OPENSSL_ALGO_MD2;
- break;
- case 'md4':
- $this->_hashAlgorithm = OPENSSL_ALGO_MD4;
- break;
- case 'md5':
- $this->_hashAlgorithm = OPENSSL_ALGO_MD5;
- break;
- }
- }
-
- /**
- * @return string
- */
- public function getPemString()
- {
- return $this->_pemString;
- }
-
- public function getPemPath()
- {
- return $this->_pemPath;
- }
-
- public function getCertificateString()
- {
- return $this->_certificateString;
- }
-
- public function getCertificatePath()
- {
- return $this->_certificatePath;
- }
-
- public function getHashAlgorithm()
- {
- return $this->_hashAlgorithm;
- }
-
- protected function _parseConfigArgs(array $config = null)
- {
- $configs = array();
- if (isset($config['privateKeyBits'])) {
- $configs['private_key_bits'] = $config['privateKeyBits'];
- }
- if (!empty($configs)) {
- return $configs;
- }
- return null;
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Symmetric/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Crypt/Symmetric/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Crypt/Symmetric/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Symmetric/Exception/ExceptionInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+ 'rijndael-128',
+ 'blowfish' => 'blowfish',
+ 'des' => 'des',
+ '3des' => 'tripledes',
+ 'tripledes' => 'tripledes',
+ 'cast-128' => 'cast-128',
+ 'cast-256' => 'cast-256',
+ 'rijndael-128' => 'rijndael-128',
+ 'rijndael-192' => 'rijndael-192',
+ 'rijndael-256' => 'rijndael-256',
+ 'saferplus' => 'saferplus',
+ 'serpent' => 'serpent',
+ 'twofish' => 'twofish'
+ );
+
+ /**
+ * Supported encryption modes
+ *
+ * @var array
+ */
+ protected $supportedModes = array(
+ 'cbc' => 'cbc',
+ 'cfb' => 'cfb',
+ 'ctr' => 'ctr',
+ 'ofb' => 'ofb',
+ 'nofb' => 'nofb',
+ 'ncfb' => 'ncfb'
+ );
+
+ /**
+ * Constructor
+ *
+ * @param array|Traversable $options
+ * @throws Exception\RuntimeException
+ * @throws Exception\InvalidArgumentException
+ */
+ public function __construct($options = array())
+ {
+ if (!extension_loaded('mcrypt')) {
+ throw new Exception\RuntimeException(
+ 'You cannot use ' . __CLASS__ . ' without the Mcrypt extension'
+ );
+ }
+ if (!empty($options)) {
+ if ($options instanceof Traversable) {
+ $options = ArrayUtils::iteratorToArray($options);
+ } elseif (!is_array($options)) {
+ throw new Exception\InvalidArgumentException(
+ 'The options parameter must be an array, a Zend\Config\Config object or a Traversable'
+ );
+ }
+ foreach ($options as $key => $value) {
+ switch (strtolower($key)) {
+ case 'algo':
+ case 'algorithm':
+ $this->setAlgorithm($value);
+ break;
+ case 'mode':
+ $this->setMode($value);
+ break;
+ case 'key':
+ $this->setKey($value);
+ break;
+ case 'iv':
+ case 'salt':
+ $this->setSalt($value);
+ break;
+ case 'padding':
+ $plugins = static::getPaddingPluginManager();
+ $padding = $plugins->get($value);
+ $this->padding = $padding;
+ break;
+ }
+ }
+ }
+ $this->setDefaultOptions($options);
+ }
+
+ /**
+ * Set default options
+ *
+ * @param array $options
+ * @return void
+ */
+ protected function setDefaultOptions($options = array())
+ {
+ if (!isset($options['padding'])) {
+ $plugins = static::getPaddingPluginManager();
+ $padding = $plugins->get(self::DEFAULT_PADDING);
+ $this->padding = $padding;
+ }
+ }
+
+ /**
+ * Returns the padding plugin manager. If it doesn't exist it's created.
+ *
+ * @return PaddingPluginManager
+ */
+ public static function getPaddingPluginManager()
+ {
+ if (static::$paddingPlugins === null) {
+ self::setPaddingPluginManager(new PaddingPluginManager());
+ }
+
+ return static::$paddingPlugins;
+ }
+
+ /**
+ * Set the padding plugin manager
+ *
+ * @param string|PaddingPluginManager $plugins
+ * @throws Exception\InvalidArgumentException
+ * @return void
+ */
+ public static function setPaddingPluginManager($plugins)
+ {
+ if (is_string($plugins)) {
+ if (!class_exists($plugins)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Unable to locate padding plugin manager via class "%s"; class does not exist',
+ $plugins
+ ));
+ }
+ $plugins = new $plugins();
+ }
+ if (!$plugins instanceof PaddingPluginManager) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Padding plugins must extend %s\PaddingPluginManager; received "%s"',
+ __NAMESPACE__,
+ (is_object($plugins) ? get_class($plugins) : gettype($plugins))
+ ));
+ }
+ static::$paddingPlugins = $plugins;
+ }
+
+ /**
+ * Get the maximum key size for the selected cipher and mode of operation
+ *
+ * @return int
+ */
+ public function getKeySize()
+ {
+ return mcrypt_get_key_size($this->supportedAlgos[$this->algo],
+ $this->supportedModes[$this->mode]);
+ }
+
+ /**
+ * Set the encryption key
+ * If the key is longer than maximum supported, it will be truncated by getKey().
+ *
+ * @param string $key
+ * @throws Exception\InvalidArgumentException
+ * @return Mcrypt
+ */
+ public function setKey($key)
+ {
+ $keyLen = strlen($key);
+
+ if (!$keyLen) {
+ throw new Exception\InvalidArgumentException('The key cannot be empty');
+ }
+ $keySizes = mcrypt_module_get_supported_key_sizes($this->supportedAlgos[$this->algo]);
+ $maxKey = $this->getKeySize();
+
+ /*
+ * blowfish has $keySizes empty, meaning it can have arbitrary key length.
+ * the others are more picky.
+ */
+ if (!empty($keySizes) && $keyLen < $maxKey) {
+
+ if (!in_array($keyLen, $keySizes)) {
+ throw new Exception\InvalidArgumentException(
+ "The size of the key must be one of "
+ . implode(", ", $keySizes) . " bytes or longer");
+ }
+ }
+ $this->key = $key;
+
+ return $this;
+ }
+
+ /**
+ * Get the encryption key
+ *
+ * @return string
+ */
+ public function getKey()
+ {
+ if (empty($this->key)) {
+ return null;
+ }
+ return substr($this->key, 0, $this->getKeySize());
+ }
+
+ /**
+ * Set the encryption algorithm (cipher)
+ *
+ * @param string $algo
+ * @throws Exception\InvalidArgumentException
+ * @return Mcrypt
+ */
+ public function setAlgorithm($algo)
+ {
+ if (!array_key_exists($algo, $this->supportedAlgos)) {
+ throw new Exception\InvalidArgumentException(
+ "The algorithm $algo is not supported by " . __CLASS__
+ );
+ }
+ $this->algo = $algo;
+
+ return $this;
+ }
+
+ /**
+ * Get the encryption algorithm
+ *
+ * @return string
+ */
+ public function getAlgorithm()
+ {
+ return $this->algo;
+ }
+
+ /**
+ * Set the padding object
+ *
+ * @param Padding\PaddingInterface $padding
+ * @return Mcrypt
+ */
+ public function setPadding(Padding\PaddingInterface $padding)
+ {
+ $this->padding = $padding;
+
+ return $this;
+ }
+
+ /**
+ * Get the padding object
+ *
+ * @return Padding\PaddingInterface
+ */
+ public function getPadding()
+ {
+ return $this->padding;
+ }
+
+ /**
+ * Encrypt
+ *
+ * @param string $data
+ * @throws Exception\InvalidArgumentException
+ * @return string
+ */
+ public function encrypt($data)
+ {
+ if (empty($data)) {
+ throw new Exception\InvalidArgumentException('The data to encrypt cannot be empty');
+ }
+ if (null === $this->getKey()) {
+ throw new Exception\InvalidArgumentException('No key specified for the encryption');
+ }
+ if (null === $this->getSalt()) {
+ throw new Exception\InvalidArgumentException('The salt (IV) cannot be empty');
+ }
+ if (null === $this->getPadding()) {
+ throw new Exception\InvalidArgumentException('You have to specify a padding method');
+ }
+ // padding
+ $data = $this->padding->pad($data, $this->getBlockSize());
+ $iv = $this->getSalt();
+ // encryption
+ $result = mcrypt_encrypt(
+ $this->supportedAlgos[$this->algo],
+ $this->getKey(),
+ $data,
+ $this->supportedModes[$this->mode],
+ $iv
+ );
+
+ return $iv . $result;
+ }
+
+ /**
+ * Decrypt
+ *
+ * @param string $data
+ * @throws Exception\InvalidArgumentException
+ * @return string
+ */
+ public function decrypt($data)
+ {
+ if (empty($data)) {
+ throw new Exception\InvalidArgumentException('The data to decrypt cannot be empty');
+ }
+ if (null === $this->getKey()) {
+ throw new Exception\InvalidArgumentException('No key specified for the decryption');
+ }
+ if (null === $this->getPadding()) {
+ throw new Exception\InvalidArgumentException('You have to specify a padding method');
+ }
+ $iv = substr($data, 0, $this->getSaltSize());
+ $ciphertext = substr($data, $this->getSaltSize());
+ $result = mcrypt_decrypt(
+ $this->supportedAlgos[$this->algo],
+ $this->getKey(),
+ $ciphertext,
+ $this->supportedModes[$this->mode],
+ $iv
+ );
+ // unpadding
+ return $this->padding->strip($result);
+ }
+
+ /**
+ * Get the salt (IV) size
+ *
+ * @return int
+ */
+ public function getSaltSize()
+ {
+ return mcrypt_get_iv_size($this->supportedAlgos[$this->algo],
+ $this->supportedModes[$this->mode]);
+ }
+
+ /**
+ * Get the supported algorithms
+ *
+ * @return array
+ */
+ public function getSupportedAlgorithms()
+ {
+ return array_keys($this->supportedAlgos);
+ }
+
+ /**
+ * Set the salt (IV)
+ *
+ * @param string $salt
+ * @throws Exception\InvalidArgumentException
+ * @return Mcrypt
+ */
+ public function setSalt($salt)
+ {
+ if (empty($salt)) {
+ throw new Exception\InvalidArgumentException('The salt (IV) cannot be empty');
+ }
+ if (strlen($salt) < $this->getSaltSize()) {
+ throw new Exception\InvalidArgumentException(
+ 'The size of the salt (IV) must be at least ' . $this->getSaltSize() . ' bytes'
+ );
+ }
+ $this->iv = $salt;
+
+ return $this;
+ }
+
+ /**
+ * Get the salt (IV) according to the size requested by the algorithm
+ *
+ * @return string
+ */
+ public function getSalt()
+ {
+ if (empty($this->iv)) {
+ return null;
+ }
+ if (strlen($this->iv) < $this->getSaltSize()) {
+ throw new Exception\RuntimeException(
+ 'The size of the salt (IV) must be at least ' . $this->getSaltSize() . ' bytes'
+ );
+ }
+
+ return substr($this->iv, 0, $this->getSaltSize());
+ }
+
+ /**
+ * Get the original salt value
+ *
+ * @return string
+ */
+ public function getOriginalSalt()
+ {
+ return $this->iv;
+ }
+
+ /**
+ * Set the cipher mode
+ *
+ * @param string $mode
+ * @throws Exception\InvalidArgumentException
+ * @return Mcrypt
+ */
+ public function setMode($mode)
+ {
+ if (!empty($mode)) {
+ $mode = strtolower($mode);
+ if (!array_key_exists($mode, $this->supportedModes)) {
+ throw new Exception\InvalidArgumentException(
+ "The mode $mode is not supported by " . __CLASS__
+ );
+ }
+ $this->mode = $mode;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get the cipher mode
+ *
+ * @return string
+ */
+ public function getMode()
+ {
+ return $this->mode;
+ }
+
+ /**
+ * Get all supported encryption modes
+ *
+ * @return array
+ */
+ public function getSupportedModes()
+ {
+ return array_keys($this->supportedModes);
+ }
+
+ /**
+ * Get the block size
+ *
+ * @return int
+ */
+ public function getBlockSize()
+ {
+ return mcrypt_get_block_size($this->supportedAlgos[$this->algo],
+ $this->supportedModes[$this->mode]);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Symmetric/Padding/PaddingInterface.php zendframework-2.2.6/library/Zend/Crypt/Symmetric/Padding/PaddingInterface.php
--- zendframework-1.10.4/library/Zend/Crypt/Symmetric/Padding/PaddingInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Symmetric/Padding/PaddingInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,30 @@
+ 'Zend\Crypt\Symmetric\Padding\Pkcs7'
+ );
+
+ /**
+ * Do not share by default
+ *
+ * @var bool
+ */
+ protected $shareByDefault = false;
+
+ /**
+ * Validate the plugin
+ *
+ * Checks that the padding adapter loaded is an instance of Padding\PaddingInterface.
+ *
+ * @param mixed $plugin
+ * @return void
+ * @throws Exception\InvalidArgumentException if invalid
+ */
+ public function validatePlugin($plugin)
+ {
+ if ($plugin instanceof Padding\PaddingInterface) {
+ // we're okay
+ return;
+ }
+
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Plugin of type %s is invalid; must implement %s\Padding\PaddingInterface',
+ (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
+ __NAMESPACE__
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Symmetric/SymmetricInterface.php zendframework-2.2.6/library/Zend/Crypt/Symmetric/SymmetricInterface.php
--- zendframework-1.10.4/library/Zend/Crypt/Symmetric/SymmetricInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Symmetric/SymmetricInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,43 @@
+ 'Zend\Crypt\Symmetric\Mcrypt',
+ );
+
+ /**
+ * Do not share by default
+ *
+ * @var bool
+ */
+ protected $shareByDefault = false;
+
+ /**
+ * Validate the plugin
+ *
+ * Checks that the adapter loaded is an instance
+ * of Symmetric\SymmetricInterface.
+ *
+ * @param mixed $plugin
+ * @return void
+ * @throws Exception\InvalidArgumentException if invalid
+ */
+ public function validatePlugin($plugin)
+ {
+ if ($plugin instanceof Symmetric\SymmetricInterface) {
+ // we're okay
+ return;
+ }
+
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Plugin of type %s is invalid; must implement %s\Symmetric\SymmetricInterface',
+ (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
+ __NAMESPACE__
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Crypt/Utils.php zendframework-2.2.6/library/Zend/Crypt/Utils.php
--- zendframework-1.10.4/library/Zend/Crypt/Utils.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Crypt/Utils.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,45 @@
+ Position for the currency sign
- * 'script' => Script for the output
- * 'format' => Locale for numeric output
- * 'display' => Currency detail to show
- * 'precision' => Precision for the currency
- * 'name' => Name for this currency
- * 'currency' => 3 lettered international abbreviation
- * 'symbol' => Currency symbol
- * 'locale' => Locale for this currency
- * 'value' => Money value
- * 'service' => Exchange service to use
- *
- * @var array
- * @see Zend_Locale
- */
- protected $_options = array(
- 'position' => self::STANDARD,
- 'script' => null,
- 'format' => null,
- 'display' => self::NO_SYMBOL,
- 'precision' => 2,
- 'name' => null,
- 'currency' => null,
- 'symbol' => null,
- 'locale' => null,
- 'value' => 0,
- 'service' => null
- );
-
- /**
- * Creates a currency instance. Every supressed parameter is used from the actual or the given locale.
- *
- * @param string|array $options OPTIONAL Options array or currency short name
- * when string is given
- * @param string|Zend_Locale $locale OPTIONAL locale name
- * @throws Zend_Currency_Exception When currency is invalid
- */
- public function __construct($options = null, $locale = null)
- {
- if (is_array($options)) {
- $this->setLocale($locale);
- $this->setFormat($options);
- } else if (Zend_Locale::isLocale($options, false, false)) {
- $this->setLocale($options);
- $options = $locale;
- } else {
- $this->setLocale($locale);
- }
-
- // Get currency details
- if (!isset($this->_options['currency']) || !is_array($options)) {
- $this->_options['currency'] = self::getShortName($options, $this->_options['locale']);
- }
-
- if (!isset($this->_options['name']) || !is_array($options)) {
- $this->_options['name'] = self::getName($options, $this->_options['locale']);
- }
-
- if (!isset($this->_options['symbol']) || !is_array($options)) {
- $this->_options['symbol'] = self::getSymbol($options, $this->_options['locale']);
- }
-
- if (($this->_options['currency'] === null) and ($this->_options['name'] === null)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("Currency '$options' not found");
- }
-
- // Get the format
- if (!empty($this->_options['symbol'])) {
- $this->_options['display'] = self::USE_SYMBOL;
- } else if (!empty($this->_options['currency'])) {
- $this->_options['display'] = self::USE_SHORTNAME;
- }
- }
-
- /**
- * Returns a localized currency string
- *
- * @param integer|float $value OPTIONAL Currency value
- * @param array $options OPTIONAL options to set temporary
- * @throws Zend_Currency_Exception When the value is not a number
- * @return string
- */
- public function toCurrency($value = null, array $options = array())
- {
- if ($value === null) {
- if (is_array($value) && isset($options['value'])) {
- $value = $options['value'];
- } else {
- $value = $this->_options['value'];
- }
- }
-
- if (is_array($value)) {
- $options += $value;
- if (isset($options['value'])) {
- $value = $options['value'];
- }
- }
-
- // Validate the passed number
- if (!(isset($value)) or (is_numeric($value) === false)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("Value '$value' has to be numeric");
- }
-
- if (isset($options['currency'])) {
- if (!isset($options['locale'])) {
- $options['locale'] = $this->_options['locale'];
- }
-
- $options['currency'] = self::getShortName($options['currency'], $options['locale']);
- $options['name'] = self::getName($options['currency'], $options['locale']);
- $options['symbol'] = self::getSymbol($options['currency'], $options['locale']);
- }
-
- $options = $this->_checkOptions($options) + $this->_options;
-
- // Format the number
- $format = $options['format'];
- $locale = $options['locale'];
- if (empty($format)) {
- $format = Zend_Locale_Data::getContent($locale, 'currencynumber');
- } else if (Zend_Locale::isLocale($format, true, false)) {
- $locale = $format;
- $format = Zend_Locale_Data::getContent($format, 'currencynumber');
- }
-
- $original = $value;
- $value = Zend_Locale_Format::toNumber($value, array('locale' => $locale,
- 'number_format' => $format,
- 'precision' => $options['precision']));
-
- if ($options['position'] !== self::STANDARD) {
- $value = str_replace('¤', '', $value);
- $space = '';
- if (iconv_strpos($value, ' ') !== false) {
- $value = str_replace(' ', '', $value);
- $space = ' ';
- }
-
- if ($options['position'] == self::LEFT) {
- $value = '¤' . $space . $value;
- } else {
- $value = $value . $space . '¤';
- }
- }
-
- // Localize the number digits
- if (empty($options['script']) === false) {
- $value = Zend_Locale_Format::convertNumerals($value, 'Latn', $options['script']);
- }
-
- // Get the sign to be placed next to the number
- if (is_numeric($options['display']) === false) {
- $sign = $options['display'];
- } else {
- switch($options['display']) {
- case self::USE_SYMBOL:
- $sign = $this->_extractPattern($options['symbol'], $original);
- break;
-
- case self::USE_SHORTNAME:
- $sign = $options['currency'];
- break;
-
- case self::USE_NAME:
- $sign = $options['name'];
- break;
-
- default:
- $sign = '';
- $value = str_replace(' ', '', $value);
- break;
- }
- }
-
- $value = str_replace('¤', $sign, $value);
- return $value;
- }
-
- /**
- * Internal method to extract the currency pattern
- * when a choice is given based on the given value
- *
- * @param string $pattern
- * @param float|integer $value
- * @return string
- */
- private function _extractPattern($pattern, $value)
- {
- if (strpos($pattern, '|') === false) {
- return $pattern;
- }
-
- $patterns = explode('|', $pattern);
- $token = $pattern;
- $value = trim(str_replace('¤', '', $value));
- krsort($patterns);
- foreach($patterns as $content) {
- if (strpos($content, '<') !== false) {
- $check = iconv_substr($content, 0, iconv_strpos($content, '<'));
- $token = iconv_substr($content, iconv_strpos($content, '<') + 1);
- if ($check < $value) {
- return $token;
- }
- } else {
- $check = iconv_substr($content, 0, iconv_strpos($content, '≤'));
- $token = iconv_substr($content, iconv_strpos($content, '≤') + 1);
- if ($check <= $value) {
- return $token;
- }
- }
-
- }
-
- return $token;
- }
-
- /**
- * Sets the formating options of the localized currency string
- * If no parameter is passed, the standard setting of the
- * actual set locale will be used
- *
- * @param array $options (Optional) Options to set
- * @return Zend_Currency
- */
- public function setFormat(array $options = array())
- {
- $this->_options = $this->_checkOptions($options) + $this->_options;
- return $this;
- }
-
- /**
- * Internal function for checking static given locale parameter
- *
- * @param string $currency (Optional) Currency name
- * @param string|Zend_Locale $locale (Optional) Locale to display informations
- * @throws Zend_Currency_Exception When locale contains no region
- * @return string The extracted locale representation as string
- */
- private function _checkParams($currency = null, $locale = null)
- {
- // Manage the params
- if ((empty($locale)) and (!empty($currency)) and
- (Zend_Locale::isLocale($currency, true, false))) {
- $locale = $currency;
- $currency = null;
- }
-
- // Validate the locale and get the country short name
- $country = null;
- if ((Zend_Locale::isLocale($locale, true, false)) and (strlen($locale) > 4)) {
- $country = substr($locale, (strpos($locale, '_') + 1));
- } else {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("No region found within the locale '" . (string) $locale . "'");
- }
-
- // Get the available currencies for this country
- $data = Zend_Locale_Data::getContent($locale, 'currencytoregion', $country);
- if ((empty($currency) === false) and (empty($data) === false)) {
- $abbreviation = $currency;
- } else {
- $abbreviation = $data;
- }
-
- return array('locale' => $locale, 'currency' => $currency, 'name' => $abbreviation, 'country' => $country);
- }
-
- /**
- * Returns the actual or details of other currency symbols,
- * when no symbol is available it returns the currency shortname (f.e. FIM for Finnian Mark)
- *
- * @param string $currency (Optional) Currency name
- * @param string|Zend_Locale $locale (Optional) Locale to display informations
- * @return string
- */
- public function getSymbol($currency = null, $locale = null)
- {
- if (($currency === null) and ($locale === null)) {
- return $this->_options['symbol'];
- }
-
- $params = self::_checkParams($currency, $locale);
-
- // Get the symbol
- $symbol = Zend_Locale_Data::getContent($params['locale'], 'currencysymbol', $params['currency']);
- if (empty($symbol) === true) {
- $symbol = Zend_Locale_Data::getContent($params['locale'], 'currencysymbol', $params['name']);
- }
-
- if (empty($symbol) === true) {
- return null;
- }
-
- return $symbol;
- }
-
- /**
- * Returns the actual or details of other currency shortnames
- *
- * @param string $currency OPTIONAL Currency's name
- * @param string|Zend_Locale $locale OPTIONAL The locale
- * @return string
- */
- public function getShortName($currency = null, $locale = null)
- {
- if (($currency === null) and ($locale === null)) {
- return $this->_options['currency'];
- }
-
- $params = self::_checkParams($currency, $locale);
-
- // Get the shortname
- if (empty($params['currency']) === true) {
- return $params['name'];
- }
-
- $list = Zend_Locale_Data::getContent($params['locale'], 'currencytoname', $params['currency']);
- if (empty($list) === true) {
- $list = Zend_Locale_Data::getContent($params['locale'], 'nametocurrency', $params['currency']);
- if (empty($list) === false) {
- $list = $params['currency'];
- }
- }
-
- if (empty($list) === true) {
- return null;
- }
-
- return $list;
- }
-
- /**
- * Returns the actual or details of other currency names
- *
- * @param string $currency (Optional) Currency's short name
- * @param string|Zend_Locale $locale (Optional) The locale
- * @return string
- */
- public function getName($currency = null, $locale = null)
- {
- if (($currency === null) and ($locale === null)) {
- return $this->_options['name'];
- }
-
- $params = self::_checkParams($currency, $locale);
-
- // Get the name
- $name = Zend_Locale_Data::getContent($params['locale'], 'nametocurrency', $params['currency']);
- if (empty($name) === true) {
- $name = Zend_Locale_Data::getContent($params['locale'], 'nametocurrency', $params['name']);
- }
-
- if (empty($name) === true) {
- return null;
- }
-
- return $name;
- }
-
- /**
- * Returns a list of regions where this currency is or was known
- *
- * @param string $currency OPTIONAL Currency's short name
- * @throws Zend_Currency_Exception When no currency was defined
- * @return array List of regions
- */
- public function getRegionList($currency = null)
- {
- if ($currency === null) {
- $currency = $this->_options['currency'];
- }
-
- if (empty($currency) === true) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception('No currency defined');
- }
-
- $data = Zend_Locale_Data::getContent('', 'regiontocurrency', $currency);
-
- $result = explode(' ', $data);
- return $result;
- }
-
- /**
- * Returns a list of currencies which are used in this region
- * a region name should be 2 charachters only (f.e. EG, DE, US)
- * If no region is given, the actual region is used
- *
- * @param string $region OPTIONAL Region to return the currencies for
- * @return array List of currencies
- */
- public function getCurrencyList($region = null)
- {
- if (empty($region) === true) {
- if (strlen($this->_options['locale']) > 4) {
- $region = substr($this->_options['locale'], (strpos($this->_options['locale'], '_') + 1));
- }
- }
-
- return Zend_Locale_Data::getList('', 'regiontocurrency', $region);
- }
-
- /**
- * Returns the actual currency name
- *
- * @return string
- */
- public function toString()
- {
- return $this->toCurrency();
- }
-
- /**
- * Returns the currency name
- *
- * @return string
- */
- public function __toString()
- {
- return $this->toString();
- }
-
- /**
- * Returns the set cache
- *
- * @return Zend_Cache_Core The set cache
- */
- public static function getCache()
- {
- $cache = Zend_Locale_Data::getCache();
- return $cache;
- }
-
- /**
- * Sets a cache for Zend_Currency
- *
- * @param Zend_Cache_Core $cache Cache to set
- * @return void
- */
- public static function setCache(Zend_Cache_Core $cache)
- {
- Zend_Locale_Data::setCache($cache);
- }
-
- /**
- * Returns true when a cache is set
- *
- * @return boolean
- */
- public static function hasCache()
- {
- return Zend_Locale_Data::hasCache();
- }
-
- /**
- * Removes any set cache
- *
- * @return void
- */
- public static function removeCache()
- {
- Zend_Locale_Data::removeCache();
- }
-
- /**
- * Clears all set cache data
- *
- * @return void
- */
- public static function clearCache()
- {
- Zend_Locale_Data::clearCache();
- }
-
- /**
- * Sets a new locale for data retreivement
- * Example: 'de_XX' will be set to 'de' because 'de_XX' does not exist
- * 'xx_YY' will be set to 'root' because 'xx' does not exist
- *
- * @param string|Zend_Locale $locale (Optional) Locale for parsing input
- * @throws Zend_Currency_Exception When the given locale does not exist
- * @return Zend_Currency Provides fluent interface
- */
- public function setLocale($locale = null)
- {
- require_once 'Zend/Locale.php';
- try {
- $locale = Zend_Locale::findLocale($locale);
- if (strlen($locale) > 4) {
- $this->_options['locale'] = $locale;
- } else {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("No region found within the locale '" . (string) $locale . "'");
- }
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception($e->getMessage());
- }
-
- // Get currency details
- $this->_options['currency'] = $this->getShortName(null, $this->_options['locale']);
- $this->_options['name'] = $this->getName(null, $this->_options['locale']);
- $this->_options['symbol'] = $this->getSymbol(null, $this->_options['locale']);
-
- return $this;
- }
-
- /**
- * Returns the actual set locale
- *
- * @return string
- */
- public function getLocale()
- {
- return $this->_options['locale'];
- }
-
- /**
- * Returns the value
- *
- * @return float
- */
- public function getValue()
- {
- return $this->_options['value'];
- }
-
- /**
- * Adds a currency
- *
- * @param float|integer|Zend_Currency $value Add this value to currency
- * @param string|Zend_Currency $currency The currency to add
- * @return Zend_Currency
- */
- public function setValue($value, $currency = null)
- {
- $this->_options['value'] = $this->_exchangeCurrency($value, $currency);
- return $this;
- }
-
- /**
- * Adds a currency
- *
- * @param float|integer|Zend_Currency $value Add this value to currency
- * @param string|Zend_Currency $currency The currency to add
- * @return Zend_Currency
- */
- public function add($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- $this->_options['value'] += (float) $value;
- return $this;
- }
-
- /**
- * Substracts a currency
- *
- * @param float|integer|Zend_Currency $value Substracts this value from currency
- * @param string|Zend_Currency $currency The currency to substract
- * @return Zend_Currency
- */
- public function sub($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- $this->_options['value'] -= (float) $value;
- return $this;
- }
-
- /**
- * Divides a currency
- *
- * @param float|integer|Zend_Currency $value Divides this value from currency
- * @param string|Zend_Currency $currency The currency to divide
- * @return Zend_Currency
- */
- public function div($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- $this->_options['value'] /= (float) $value;
- return $this;
- }
-
- /**
- * Multiplies a currency
- *
- * @param float|integer|Zend_Currency $value Multiplies this value from currency
- * @param string|Zend_Currency $currency The currency to multiply
- * @return Zend_Currency
- */
- public function mul($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- $this->_options['value'] *= (float) $value;
- return $this;
- }
-
- /**
- * Calculates the modulo from a currency
- *
- * @param float|integer|Zend_Currency $value Calculate modulo from this value
- * @param string|Zend_Currency $currency The currency to calculate the modulo
- * @return Zend_Currency
- */
- public function mod($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- $this->_options['value'] %= (float) $value;
- return $this;
- }
-
- /**
- * Compares two currencies
- *
- * @param float|integer|Zend_Currency $value Compares the currency with this value
- * @param string|Zend_Currency $currency The currency to compare this value from
- * @return Zend_Currency
- */
- public function compare($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- $value = $this->_options['value'] - $value;
- if ($value < 0) {
- return -1;
- } else if ($value > 0) {
- return 1;
- }
-
- return 0;
- }
-
- /**
- * Returns true when the two currencies are equal
- *
- * @param float|integer|Zend_Currency $value Compares the currency with this value
- * @param string|Zend_Currency $currency The currency to compare this value from
- * @return boolean
- */
- public function equals($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- if ($this->_options['value'] == $value) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns true when the currency is more than the given value
- *
- * @param float|integer|Zend_Currency $value Compares the currency with this value
- * @param string|Zend_Currency $currency The currency to compare this value from
- * @return boolean
- */
- public function isMore($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- if ($this->_options['value'] > $value) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns true when the currency is less than the given value
- *
- * @param float|integer|Zend_Currency $value Compares the currency with this value
- * @param string|Zend_Currency $currency The currency to compare this value from
- * @return boolean
- */
- public function isLess($value, $currency = null)
- {
- $value = $this->_exchangeCurrency($value, $currency);
- if ($this->_options['value'] < $value) {
- return true;
- }
-
- return false;
-
- }
-
- /**
- * Internal method which calculates the exchanges currency
- *
- * @param float|integer|Zend_Currency $value Compares the currency with this value
- * @param string|Zend_Currency $currency The currency to compare this value from
- * @return unknown
- */
- protected function _exchangeCurrency($value, $currency)
- {
- if ($value instanceof Zend_Currency) {
- $currency = $value->getShortName();
- $value = $value->getValue();
- } else {
- $currency = $this->getShortName($currency, $this->getLocale());
- }
-
- $rate = 1;
- if ($currency !== $this->getShortName()) {
- $service = $this->getService();
- if (!($service instanceof Zend_Currency_CurrencyInterface)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception('No exchange service applied');
- }
-
- $rate = $service->getRate($currency, $this->getShortName());
- }
-
- $value *= $rate;
- return $value;
- }
-
- /**
- * Returns the set service class
- *
- * @return Zend_Service
- */
- public function getService()
- {
- return $this->_options['service'];
- }
-
- /**
- * Sets a new exchange service
- *
- * @param string|Zend_Currency_CurrencyInterface $service Service class
- * @return Zend_Currency
- */
- public function setService($service)
- {
- if (is_string($service)) {
- require_once 'Zend/Loader.php';
- if (!class_exists($service)) {
- $file = str_replace('_', DIRECTORY_SEPARATOR, $service) . '.php';
- if (Zend_Loader::isReadable($file)) {
- Zend_Loader::loadClass($class);
- }
- }
-
- $service = new $service;
- }
-
- if (!($service instanceof Zend_Currency_CurrencyInterface)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception('A currency service must implement Zend_Currency_CurrencyInterface');
- }
-
- $this->_options['service'] = $service;
- return $this;
- }
-
- /**
- * Internal method for checking the options array
- *
- * @param array $options Options to check
- * @throws Zend_Currency_Exception On unknown position
- * @throws Zend_Currency_Exception On unknown locale
- * @throws Zend_Currency_Exception On unknown display
- * @throws Zend_Currency_Exception On precision not between -1 and 30
- * @throws Zend_Currency_Exception On problem with script conversion
- * @throws Zend_Currency_Exception On unknown options
- * @return array
- */
- protected function _checkOptions(array $options = array())
- {
- if (count($options) === 0) {
- return $this->_options;
- }
-
- foreach ($options as $name => $value) {
- $name = strtolower($name);
- if ($name !== 'format') {
- if (gettype($value) === 'string') {
- $value = strtolower($value);
- }
- }
-
- switch($name) {
- case 'position':
- if (($value !== self::STANDARD) and ($value !== self::RIGHT) and ($value !== self::LEFT)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("Unknown position '" . $value . "'");
- }
-
- break;
-
- case 'format':
- if ((empty($value) === false) and (Zend_Locale::isLocale($value, null, false) === false)) {
- if (!is_string($value) || (strpos($value, '0') === false)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("'" .
- ((gettype($value) === 'object') ? get_class($value) : $value)
- . "' is no format token");
- }
- }
- break;
-
- case 'display':
- if (is_numeric($value) and ($value !== self::NO_SYMBOL) and ($value !== self::USE_SYMBOL) and
- ($value !== self::USE_SHORTNAME) and ($value !== self::USE_NAME)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("Unknown display '$value'");
- }
- break;
-
- case 'precision':
- if ($value === null) {
- $value = -1;
- }
-
- if (($value < -1) or ($value > 30)) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception("'$value' precision has to be between -1 and 30.");
- }
- break;
-
- case 'script':
- try {
- Zend_Locale_Format::convertNumerals(0, $options['script']);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Currency/Exception.php';
- throw new Zend_Currency_Exception($e->getMessage());
- }
- break;
-
- default:
- break;
- }
- }
-
- return $options;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Date/Cities.php zendframework-2.2.6/library/Zend/Date/Cities.php
--- zendframework-1.10.4/library/Zend/Date/Cities.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Date/Cities.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,322 +0,0 @@
- array('latitude' => 5.3411111, 'longitude' => -4.0280556),
- 'Abu Dhabi' => array('latitude' => 24.4666667, 'longitude' => 54.3666667),
- 'Abuja' => array('latitude' => 9.1758333, 'longitude' => 7.1808333),
- 'Accra' => array('latitude' => 5.55, 'longitude' => -0.2166667),
- 'Adamstown' => array('latitude' => -25.0666667, 'longitude' => -130.0833333),
- 'Addis Ababa' => array('latitude' => 9.0333333, 'longitude' => 38.7),
- 'Adelaide' => array('latitude' => -34.9333333, 'longitude' => 138.6),
- 'Algiers' => array('latitude' => 36.7630556, 'longitude' => 3.0505556),
- 'Alofi' => array('latitude' => -19.0166667, 'longitude' => -169.9166667),
- 'Amman' => array('latitude' => 31.95, 'longitude' => 35.9333333),
- 'Amsterdam' => array('latitude' => 52.35, 'longitude' => 4.9166667),
- 'Andorra la Vella' => array('latitude' => 42.5, 'longitude' => 1.5166667),
- 'Ankara' => array('latitude' => 39.9272222, 'longitude' => 32.8644444),
- 'Antananarivo' => array('latitude' => -18.9166667, 'longitude' => 47.5166667),
- 'Apia' => array('latitude' => -13.8333333, 'longitude' => -171.7333333),
- 'Ashgabat' => array('latitude' => 37.95, 'longitude' => 58.3833333),
- 'Asmara' => array('latitude' => 15.3333333, 'longitude' => 38.9333333),
- 'Astana' => array('latitude' => 51.1811111, 'longitude' => 71.4277778),
- 'Asunción' => array('latitude' => -25.2666667, 'longitude' => -57.6666667),
- 'Athens' => array('latitude' => 37.9833333, 'longitude' => 23.7333333),
- 'Auckland' => array('latitude' => -36.8666667, 'longitude' => 174.7666667),
- 'Avarua' => array('latitude' => -21.2, 'longitude' => -159.7666667),
- 'Baghdad' => array('latitude' => 33.3386111, 'longitude' => 44.3938889),
- 'Baku' => array('latitude' => 40.3952778, 'longitude' => 49.8822222),
- 'Bamako' => array('latitude' => 12.65, 'longitude' => -8),
- 'Bandar Seri Begawan' => array('latitude' => 4.8833333, 'longitude' => 114.9333333),
- 'Bankok' => array('latitude' => 13.5833333, 'longitude' => 100.2166667),
- 'Bangui' => array('latitude' => 4.3666667, 'longitude' => 18.5833333),
- 'Banjul' => array('latitude' => 13.4530556, 'longitude' => -16.5775),
- 'Basel' => array('latitude' => 47.5666667, 'longitude' => 7.6),
- 'Basseterre' => array('latitude' => 17.3, 'longitude' => -62.7166667),
- 'Beijing' => array('latitude' => 39.9288889, 'longitude' => 116.3883333),
- 'Beirut' => array('latitude' => 33.8719444, 'longitude' => 35.5097222),
- 'Belgrade' => array('latitude' => 44.8186111, 'longitude' => 20.4680556),
- 'Belmopan' => array('latitude' => 17.25, 'longitude' => -88.7666667),
- 'Berlin' => array('latitude' => 52.5166667, 'longitude' => 13.4),
- 'Bern' => array('latitude' => 46.9166667, 'longitude' => 7.4666667),
- 'Bishkek' => array('latitude' => 42.8730556, 'longitude' => 74.6002778),
- 'Bissau' => array('latitude' => 11.85, 'longitude' => -15.5833333),
- 'Bloemfontein' => array('latitude' => -29.1333333, 'longitude' => 26.2),
- 'Bogotá' => array('latitude' => 4.6, 'longitude' => -74.0833333),
- 'Brasilia' => array('latitude' => -15.7833333, 'longitude' => -47.9166667),
- 'Bratislava' => array('latitude' => 48.15, 'longitude' => 17.1166667),
- 'Brazzaville' => array('latitude' => -4.2591667, 'longitude' => 15.2847222),
- 'Bridgetown' => array('latitude' => 13.1, 'longitude' => -59.6166667),
- 'Brisbane' => array('latitude' => -27.5, 'longitude' => 153.0166667),
- 'Brussels' => array('latitude' => 50.8333333, 'longitude' => 4.3333333),
- 'Bucharest' => array('latitude' => 44.4333333, 'longitude' => 26.1),
- 'Budapest' => array('latitude' => 47.5, 'longitude' => 19.0833333),
- 'Buenos Aires' => array('latitude' => -34.5875, 'longitude' => -58.6725),
- 'Bujumbura' => array('latitude' => -3.3761111, 'longitude' => 29.36),
- 'Cairo' => array('latitude' => 30.05, 'longitude' => 31.25),
- 'Calgary' => array('latitude' => 51.0833333, 'longitude' => -114.0833333),
- 'Canberra' => array('latitude' => -35.2833333, 'longitude' => 149.2166667),
- 'Cape Town' => array('latitude' => -33.9166667, 'longitude' => 18.4166667),
- 'Caracas' => array('latitude' => 10.5, 'longitude' => -66.9166667),
- 'Castries' => array('latitude' => 14, 'longitude' => -61),
- 'Charlotte Amalie' => array('latitude' => 18.34389, 'longitude' => -64.93111),
- 'Chicago' => array('latitude' => 41.85, 'longitude' => -87.65),
- 'Chisinau' => array('latitude' => 47.055556, 'longitude' => 28.8575),
- 'Cockburn Town' => array('latitude' => 21.4666667, 'longitude' => -71.1333333),
- 'Colombo' => array('latitude' => 6.9319444, 'longitude' => 79.8477778),
- 'Conakry' => array('latitude' => 9.5091667, 'longitude' => -13.7122222),
- 'Copenhagen' => array('latitude' => 55.6666667, 'longitude' => 12.5833333),
- 'Cotonou' => array('latitude' => 6.35, 'longitude' => 2.4333333),
- 'Dakar' => array('latitude' => 14.6708333, 'longitude' => -17.4380556),
- 'Damascus' => array('latitude' => 33.5, 'longitude' => 36.3),
- 'Dar es Salaam' => array('latitude' => -6.8, 'longitude' => 39.2833333),
- 'Dhaka' => array('latitude' => 23.7230556, 'longitude' => 90.4086111),
- 'Dili' => array('latitude' => -8.5586111, 'longitude' => 125.5736111),
- 'Djibouti' => array('latitude' => 11.595, 'longitude' => 43.1480556),
- 'Dodoma' => array('latitude' => -6.1833333, 'longitude' => 35.75),
- 'Doha' => array('latitude' => 25.2866667, 'longitude' => 51.5333333),
- 'Dubai' => array('latitude' => 25.2522222, 'longitude' => 55.28),
- 'Dublin' => array('latitude' => 53.3330556, 'longitude' => -6.2488889),
- 'Dushanbe' => array('latitude' => 38.56, 'longitude' => 68.7738889 ),
- 'Fagatogo' => array('latitude' => -14.2825, 'longitude' => -170.69),
- 'Fongafale' => array('latitude' => -8.5166667, 'longitude' => 179.2166667),
- 'Freetown' => array('latitude' => 8.49, 'longitude' => -13.2341667),
- 'Gaborone' => array('latitude' => -24.6463889, 'longitude' => 25.9119444),
- 'Geneva' => array('latitude' => 46.2, 'longitude' => 6.1666667),
- 'George Town' => array('latitude' => 19.3, 'longitude' => -81.3833333),
- 'Georgetown' => array('latitude' => 6.8, 'longitude' => -58.1666667),
- 'Gibraltar' => array('latitude' => 36.1333333, 'longitude' => -5.35),
- 'Glasgow' => array('latitude' => 55.8333333, 'longitude' => -4.25),
- 'Guatemala la Nueva' => array('latitude' => 14.6211111, 'longitude' => -90.5269444),
- 'Hagatna' => array('latitude' => 13.47417, 'longitude' => 144.74778),
- 'The Hague' => array('latitude' => 52.0833333, 'longitude' => 4.3),
- 'Hamilton' => array('latitude' => 32.2941667, 'longitude' => -64.7838889),
- 'Hanoi' => array('latitude' => 21.0333333, 'longitude' => 105.85),
- 'Harare' => array('latitude' => -17.8177778, 'longitude' => 31.0447222),
- 'Havana' => array('latitude' => 23.1319444, 'longitude' => -82.3641667),
- 'Helsinki' => array('latitude' => 60.1755556, 'longitude' => 24.9341667),
- 'Honiara' => array('latitude' => -9.4333333, 'longitude' => 159.95),
- 'Islamabad' => array('latitude' => 30.8486111, 'longitude' => 72.4944444),
- 'Istanbul' => array('latitude' => 41.0186111, 'longitude' => 28.9647222),
- 'Jakarta' => array('latitude' => -6.1744444, 'longitude' => 106.8294444),
- 'Jamestown' => array('latitude' => -15.9333333, 'longitude' => -5.7166667),
- 'Jerusalem' => array('latitude' => 31.7666667, 'longitude' => 35.2333333),
- 'Johannesburg' => array('latitude' => -26.2, 'longitude' => 28.0833333),
- 'Kabul' => array('latitude' => 34.5166667, 'longitude' => 69.1833333),
- 'Kampala' => array('latitude' => 0.3155556, 'longitude' => 32.5655556),
- 'Kathmandu' => array('latitude' => 27.7166667, 'longitude' => 85.3166667),
- 'Khartoum' => array('latitude' => 15.5880556, 'longitude' => 32.5341667),
- 'Kigali' => array('latitude' => -1.9536111, 'longitude' => 30.0605556),
- 'Kingston' => array('latitude' => -29.05, 'longitude' => 167.95),
- 'Kingstown' => array('latitude' => 13.1333333, 'longitude' => -61.2166667),
- 'Kinshasa' => array('latitude' => -4.3, 'longitude' => 15.3),
- 'Kolkata' => array('latitude' => 22.5697222, 'longitude' => 88.3697222),
- 'Kuala Lumpur' => array('latitude' => 3.1666667, 'longitude' => 101.7),
- 'Kuwait City' => array('latitude' => 29.3697222, 'longitude' => 47.9783333),
- 'Kiev' => array('latitude' => 50.4333333, 'longitude' => 30.5166667),
- 'La Paz' => array('latitude' => -16.5, 'longitude' => -68.15),
- 'Libreville' => array('latitude' => 0.3833333, 'longitude' => 9.45),
- 'Lilongwe' => array('latitude' => -13.9833333, 'longitude' => 33.7833333),
- 'Lima' => array('latitude' => -12.05, 'longitude' => -77.05),
- 'Lisbon' => array('latitude' => 38.7166667, 'longitude' => -9.1333333),
- 'Ljubljana' => array('latitude' => 46.0552778, 'longitude' => 14.5144444),
- 'Lobamba' => array('latitude' => -26.4666667, 'longitude' => 31.2),
- 'Lomé' => array('latitude' => 9.7166667, 'longitude' => 38.3),
- 'London' => array('latitude' => 51.5, 'longitude' => -0.1166667),
- 'Los Angeles' => array('latitude' => 34.05222, 'longitude' => -118.24278),
- 'Luanda' => array('latitude' => -8.8383333, 'longitude' => 13.2344444),
- 'Lusaka' => array('latitude' => -15.4166667, 'longitude' => 28.2833333),
- 'Luxembourg' => array('latitude' => 49.6116667, 'longitude' => 6.13),
- 'Madrid' => array('latitude' => 40.4, 'longitude' => -3.6833333),
- 'Majuro' => array('latitude' => 7.1, 'longitude' => 171.3833333),
- 'Malabo' => array('latitude' => 3.75, 'longitude' => 8.7833333),
- 'Managua' => array('latitude' => 12.1508333, 'longitude' => -86.2683333),
- 'Manama' => array('latitude' => 26.2361111, 'longitude' => 50.5830556),
- 'Manila' => array('latitude' => 14.6041667, 'longitude' => 120.9822222),
- 'Maputo' => array('latitude' => -25.9652778, 'longitude' => 32.5891667),
- 'Maseru' => array('latitude' => -29.3166667, 'longitude' => 27.4833333),
- 'Mbabane' => array('latitude' => -26.3166667, 'longitude' => 31.1333333),
- 'Melbourne' => array('latitude' => -37.8166667, 'longitude' => 144.9666667),
- 'Melekeok' => array('latitude' => 7.4933333, 'longitude' => 134.6341667),
- 'Mexiko City' => array('latitude' => 19.4341667, 'longitude' => -99.1386111),
- 'Minsk' => array('latitude' => 53.9, 'longitude' => 27.5666667),
- 'Mogadishu' => array('latitude' => 2.0666667, 'longitude' => 45.3666667),
- 'Monaco' => array('latitude' => 43.7333333, 'longitude' => 7.4166667),
- 'Monrovia' => array('latitude' => 6.3105556, 'longitude' => -10.8047222),
- 'Montevideo' => array('latitude' => -34.8580556, 'longitude' => -56.1708333),
- 'Montreal' => array('latitude' => 45.5, 'longitude' => -73.5833333),
- 'Moroni' => array('latitude' => -11.7041667, 'longitude' => 43.2402778),
- 'Moscow' => array('latitude' => 55.7522222, 'longitude' => 37.6155556),
- 'Muscat' => array('latitude' => 23.6133333, 'longitude' => 58.5933333),
- 'Nairobi' => array('latitude' => -1.3166667, 'longitude' => 36.8333333),
- 'Nassau' => array('latitude' => 25.0833333, 'longitude' => -77.35),
- 'N´Djamena' => array('latitude' => 12.1130556, 'longitude' => 15.0491667),
- 'New Dehli' => array('latitude' => 28.6, 'longitude' => 77.2),
- 'New York' => array('latitude' => 40.71417, 'longitude' => -74.00639),
- 'Newcastle' => array('latitude' => -32.9166667, 'longitude' => 151.75),
- 'Niamey' => array('latitude' => 13.6666667, 'longitude' => 1.7833333),
- 'Nicosia' => array('latitude' => 35.1666667, 'longitude' => 33.3666667),
- 'Nouakchott' => array('latitude' => 18.0863889, 'longitude' => -15.9752778),
- 'Noumea' => array('latitude' => -22.2666667, 'longitude' => 166.45),
- 'Nuku´alofa' => array('latitude' => -21.1333333, 'longitude' => -175.2),
- 'Nuuk' => array('latitude' => 64.1833333, 'longitude' => -51.75),
- 'Oranjestad' => array('latitude' => 12.5166667, 'longitude' => -70.0333333),
- 'Oslo' => array('latitude' => 59.9166667, 'longitude' => 10.75),
- 'Ouagadougou' => array('latitude' => 12.3702778, 'longitude' => -1.5247222),
- 'Palikir' => array('latitude' => 6.9166667, 'longitude' => 158.15),
- 'Panama City' => array('latitude' => 8.9666667, 'longitude' => -79.5333333),
- 'Papeete' => array('latitude' => -17.5333333, 'longitude' => -149.5666667),
- 'Paramaribo' => array('latitude' => 5.8333333, 'longitude' => -55.1666667),
- 'Paris' => array('latitude' => 48.8666667, 'longitude' => 2.3333333),
- 'Perth' => array('latitude' => -31.9333333, 'longitude' => 115.8333333),
- 'Phnom Penh' => array('latitude' => 11.55, 'longitude' => 104.9166667),
- 'Podgorica' => array('latitude' => 43.7752778, 'longitude' => 19.6827778),
- 'Port Louis' => array('latitude' => -20.1666667, 'longitude' => 57.5),
- 'Port Moresby' => array('latitude' => -9.4647222, 'longitude' => 147.1925),
- 'Port-au-Prince' => array('latitude' => 18.5391667, 'longitude' => -72.335),
- 'Port of Spain' => array('latitude' => 10.6666667, 'longitude' => -61.5),
- 'Porto-Novo' => array('latitude' => 6.4833333, 'longitude' => 2.6166667),
- 'Prague' => array('latitude' => 50.0833333, 'longitude' => 14.4666667),
- 'Praia' => array('latitude' => 14.9166667, 'longitude' => -23.5166667),
- 'Pretoria' => array('latitude' => -25.7069444, 'longitude' => 28.2294444),
- 'Pyongyang' => array('latitude' => 39.0194444, 'longitude' => 125.7547222),
- 'Quito' => array('latitude' => -0.2166667, 'longitude' => -78.5),
- 'Rabat' => array('latitude' => 34.0252778, 'longitude' => -6.8361111),
- 'Reykjavik' => array('latitude' => 64.15, 'longitude' => -21.95),
- 'Riga' => array('latitude' => 56.95, 'longitude' => 24.1),
- 'Rio de Janero' => array('latitude' => -22.9, 'longitude' => -43.2333333),
- 'Road Town' => array('latitude' => 18.4166667, 'longitude' => -64.6166667),
- 'Rome' => array('latitude' => 41.9, 'longitude' => 12.4833333),
- 'Roseau' => array('latitude' => 15.3, 'longitude' => -61.4),
- 'Rotterdam' => array('latitude' => 51.9166667, 'longitude' => 4.5),
- 'Salvador' => array('latitude' => -12.9833333, 'longitude' => -38.5166667),
- 'San José' => array('latitude' => 9.9333333, 'longitude' => -84.0833333),
- 'San Juan' => array('latitude' => 18.46833, 'longitude' => -66.10611),
- 'San Marino' => array('latitude' => 43.5333333, 'longitude' => 12.9666667),
- 'San Salvador' => array('latitude' => 13.7086111, 'longitude' => -89.2030556),
- 'Sanaá' => array('latitude' => 15.3547222, 'longitude' => 44.2066667),
- 'Santa Cruz' => array('latitude' => -17.8, 'longitude' => -63.1666667),
- 'Santiago' => array('latitude' => -33.45, 'longitude' => -70.6666667),
- 'Santo Domingo' => array('latitude' => 18.4666667, 'longitude' => -69.9),
- 'Sao Paulo' => array('latitude' => -23.5333333, 'longitude' => -46.6166667),
- 'Sarajevo' => array('latitude' => 43.85, 'longitude' => 18.3833333),
- 'Seoul' => array('latitude' => 37.5663889, 'longitude' => 126.9997222),
- 'Shanghai' => array('latitude' => 31.2222222, 'longitude' => 121.4580556),
- 'Sydney' => array('latitude' => -33.8833333, 'longitude' => 151.2166667),
- 'Singapore' => array('latitude' => 1.2930556, 'longitude' => 103.8558333),
- 'Skopje' => array('latitude' => 42, 'longitude' => 21.4333333),
- 'Sofia' => array('latitude' => 42.6833333, 'longitude' => 23.3166667),
- 'St. George´s' => array('latitude' => 12.05, 'longitude' => -61.75),
- 'St. John´s' => array('latitude' => 17.1166667, 'longitude' => -61.85),
- 'Stanley' => array('latitude' => -51.7, 'longitude' => -57.85),
- 'Stockholm' => array('latitude' => 59.3333333, 'longitude' => 18.05),
- 'Suva' => array('latitude' => -18.1333333, 'longitude' => 178.4166667),
- 'Taipei' => array('latitude' => 25.0166667, 'longitude' => 121.45),
- 'Tallinn' => array('latitude' => 59.4338889, 'longitude' => 24.7280556),
- 'Tashkent' => array('latitude' => 41.3166667, 'longitude' => 69.25),
- 'Tbilisi' => array('latitude' => 41.725, 'longitude' => 44.7908333),
- 'Tegucigalpa' => array('latitude' => 14.1, 'longitude' => -87.2166667),
- 'Tehran' => array('latitude' => 35.6719444, 'longitude' => 51.4244444),
- 'The Hague' => array('latitude' => 52.0833333, 'longitude' => 4.3),
- 'Thimphu' => array('latitude' => 27.4833333, 'longitude' => 89.6),
- 'Tirana' => array('latitude' => 41.3275, 'longitude' => 19.8188889),
- 'Tiraspol' => array('latitude' => 46.8402778, 'longitude' => 29.6433333),
- 'Tokyo' => array('latitude' => 35.685, 'longitude' => 139.7513889),
- 'Toronto' => array('latitude' => 43.6666667, 'longitude' => -79.4166667),
- 'Tórshavn' => array('latitude' => 62.0166667, 'longitude' => -6.7666667),
- 'Tripoli' => array('latitude' => 32.8925, 'longitude' => 13.18),
- 'Tunis' => array('latitude' => 36.8027778, 'longitude' => 10.1797222),
- 'Ulaanbaatar' => array('latitude' => 47.9166667, 'longitude' => 106.9166667),
- 'Vaduz' => array('latitude' => 47.1333333, 'longitude' => 9.5166667),
- 'Valletta' => array('latitude' => 35.8997222, 'longitude' => 14.5147222),
- 'Valparaiso' => array('latitude' => -33.0477778, 'longitude' => -71.6011111),
- 'Vancouver' => array('latitude' => 49.25, 'longitude' => -123.1333333),
- 'Vatican City' => array('latitude' => 41.9, 'longitude' => 12.4833333),
- 'Victoria' => array('latitude' => -4.6166667, 'longitude' => 55.45),
- 'Vienna' => array('latitude' => 48.2, 'longitude' => 16.3666667),
- 'Vientaine' => array('latitude' => 17.9666667, 'longitude' => 102.6),
- 'Vilnius' => array('latitude' => 54.6833333, 'longitude' => 25.3166667),
- 'Warsaw' => array('latitude' => 52.25, 'longitude' => 21),
- 'Washington dc' => array('latitude' => 38.895, 'longitude' => -77.03667),
- 'Wellington' => array('latitude' => -41.3, 'longitude' => 174.7833333),
- 'Willemstad' => array('latitude' => 12.1, 'longitude' => -68.9166667),
- 'Windhoek' => array('latitude' => -22.57, 'longitude' => 17.0836111),
- 'Yamoussoukro' => array('latitude' => 6.8166667, 'longitude' => -5.2833333),
- 'Yaoundé' => array('latitude' => 3.8666667, 'longitude' => 11.5166667),
- 'Yerevan' => array('latitude' => 40.1811111, 'longitude' => 44.5136111),
- 'Zürich' => array('latitude' => 47.3666667, 'longitude' => 8.55),
- 'Zagreb' => array('latitude' => 45.8, 'longitude' => 16)
- );
-
- /**
- * Returns the location from the selected city
- *
- * @param string $city City to get location for
- * @param string $horizon Horizon to use :
- * default: effective
- * others are civil, nautic, astronomic
- * @return array
- * @throws Zend_Date_Exception When city is unknown
- */
- public static function City($city, $horizon = false)
- {
- foreach (self::$cities as $key => $value) {
- if (strtolower($key) === strtolower($city)) {
- $return = $value;
- $return['horizon'] = $horizon;
- return $return;
- }
- }
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('unknown city');
- }
-
- /**
- * Return a list with all known cities
- *
- * @return array
- */
- public static function getCityList()
- {
- return array_keys(self::$cities);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Date/DateObject.php zendframework-2.2.6/library/Zend/Date/DateObject.php
--- zendframework-1.10.4/library/Zend/Date/DateObject.php 2010-04-03 19:24:46.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Date/DateObject.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,1060 +0,0 @@
- 0, 1960 => -315619200, 1950 => -631152000,
- 1940 => -946771200, 1930 => -1262304000, 1920 => -1577923200,
- 1910 => -1893456000, 1900 => -2208988800, 1890 => -2524521600,
- 1880 => -2840140800, 1870 => -3155673600, 1860 => -3471292800,
- 1850 => -3786825600, 1840 => -4102444800, 1830 => -4417977600,
- 1820 => -4733596800, 1810 => -5049129600, 1800 => -5364662400,
- 1790 => -5680195200, 1780 => -5995814400, 1770 => -6311347200,
- 1760 => -6626966400, 1750 => -6942499200, 1740 => -7258118400,
- 1730 => -7573651200, 1720 => -7889270400, 1710 => -8204803200,
- 1700 => -8520336000, 1690 => -8835868800, 1680 => -9151488000,
- 1670 => -9467020800, 1660 => -9782640000, 1650 => -10098172800,
- 1640 => -10413792000, 1630 => -10729324800, 1620 => -11044944000,
- 1610 => -11360476800, 1600 => -11676096000);
-
- /**
- * Set this object to have a new UNIX timestamp.
- *
- * @param string|integer $timestamp OPTIONAL timestamp; defaults to local time using time()
- * @return string|integer old timestamp
- * @throws Zend_Date_Exception
- */
- protected function setUnixTimestamp($timestamp = null)
- {
- $old = $this->_unixTimestamp;
-
- if (is_numeric($timestamp)) {
- $this->_unixTimestamp = $timestamp;
- } else if ($timestamp === null) {
- $this->_unixTimestamp = time();
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('\'' . $timestamp . '\' is not a valid UNIX timestamp', 0, null, $timestamp);
- }
-
- return $old;
- }
-
- /**
- * Returns this object's UNIX timestamp
- * A timestamp greater then the integer range will be returned as string
- * This function does not return the timestamp as object. Use copy() instead.
- *
- * @return integer|string timestamp
- */
- protected function getUnixTimestamp()
- {
- if ($this->_unixTimestamp === intval($this->_unixTimestamp)) {
- return (int) $this->_unixTimestamp;
- } else {
- return (string) $this->_unixTimestamp;
- }
- }
-
- /**
- * Internal function.
- * Returns time(). This method exists to allow unit tests to work-around methods that might otherwise
- * be hard-coded to use time(). For example, this makes it possible to test isYesterday() in Date.php.
- *
- * @param integer $sync OPTIONAL time syncronisation value
- * @return integer timestamp
- */
- protected function _getTime($sync = null)
- {
- if ($sync !== null) {
- $this->_syncronised = round($sync);
- }
- return (time() + $this->_syncronised);
- }
-
- /**
- * Internal mktime function used by Zend_Date.
- * The timestamp returned by mktime() can exceed the precision of traditional UNIX timestamps,
- * by allowing PHP to auto-convert to using a float value.
- *
- * Returns a timestamp relative to 1970/01/01 00:00:00 GMT/UTC.
- * DST (Summer/Winter) is depriciated since php 5.1.0.
- * Year has to be 4 digits otherwise it would be recognised as
- * year 70 AD instead of 1970 AD as expected !!
- *
- * @param integer $hour
- * @param integer $minute
- * @param integer $second
- * @param integer $month
- * @param integer $day
- * @param integer $year
- * @param boolean $gmt OPTIONAL true = other arguments are for UTC time, false = arguments are for local time/date
- * @return integer|float timestamp (number of seconds elapsed relative to 1970/01/01 00:00:00 GMT/UTC)
- */
- protected function mktime($hour, $minute, $second, $month, $day, $year, $gmt = false)
- {
-
- // complete date but in 32bit timestamp - use PHP internal
- if ((1901 < $year) and ($year < 2038)) {
-
- $oldzone = @date_default_timezone_get();
- // Timezone also includes DST settings, therefor substracting the GMT offset is not enough
- // We have to set the correct timezone to get the right value
- if (($this->_timezone != $oldzone) and ($gmt === false)) {
- date_default_timezone_set($this->_timezone);
- }
- $result = ($gmt) ? @gmmktime($hour, $minute, $second, $month, $day, $year)
- : @mktime($hour, $minute, $second, $month, $day, $year);
- date_default_timezone_set($oldzone);
-
- return $result;
- }
-
- if ($gmt !== true) {
- $second += $this->_offset;
- }
-
- if (isset(self::$_cache)) {
- $id = strtr('Zend_DateObject_mkTime_' . $this->_offset . '_' . $year.$month.$day.'_'.$hour.$minute.$second . '_'.(int)$gmt, '-','_');
- if ($result = self::$_cache->load($id)) {
- return unserialize($result);
- }
- }
-
- // date to integer
- $day = intval($day);
- $month = intval($month);
- $year = intval($year);
-
- // correct months > 12 and months < 1
- if ($month > 12) {
- $overlap = floor($month / 12);
- $year += $overlap;
- $month -= $overlap * 12;
- } else {
- $overlap = ceil((1 - $month) / 12);
- $year -= $overlap;
- $month += $overlap * 12;
- }
-
- $date = 0;
- if ($year >= 1970) {
-
- // Date is after UNIX epoch
- // go through leapyears
- // add months from latest given year
- for ($count = 1970; $count <= $year; $count++) {
-
- $leapyear = self::isYearLeapYear($count);
- if ($count < $year) {
-
- $date += 365;
- if ($leapyear === true) {
- $date++;
- }
-
- } else {
-
- for ($mcount = 0; $mcount < ($month - 1); $mcount++) {
- $date += self::$_monthTable[$mcount];
- if (($leapyear === true) and ($mcount == 1)) {
- $date++;
- }
-
- }
- }
- }
-
- $date += $day - 1;
- $date = (($date * 86400) + ($hour * 3600) + ($minute * 60) + $second);
- } else {
-
- // Date is before UNIX epoch
- // go through leapyears
- // add months from latest given year
- for ($count = 1969; $count >= $year; $count--) {
-
- $leapyear = self::isYearLeapYear($count);
- if ($count > $year)
- {
- $date += 365;
- if ($leapyear === true)
- $date++;
- } else {
-
- for ($mcount = 11; $mcount > ($month - 1); $mcount--) {
- $date += self::$_monthTable[$mcount];
- if (($leapyear === true) and ($mcount == 2)) {
- $date++;
- }
-
- }
- }
- }
-
- $date += (self::$_monthTable[$month - 1] - $day);
- $date = -(($date * 86400) + (86400 - (($hour * 3600) + ($minute * 60) + $second)));
-
- // gregorian correction for 5.Oct.1582
- if ($date < -12220185600) {
- $date += 864000;
- } else if ($date < -12219321600) {
- $date = -12219321600;
- }
- }
-
- if (isset(self::$_cache)) {
- self::$_cache->save( serialize($date), $id);
- }
-
- return $date;
- }
-
- /**
- * Returns true, if given $year is a leap year.
- *
- * @param integer $year
- * @return boolean true, if year is leap year
- */
- protected static function isYearLeapYear($year)
- {
- // all leapyears can be divided through 4
- if (($year % 4) != 0) {
- return false;
- }
-
- // all leapyears can be divided through 400
- if ($year % 400 == 0) {
- return true;
- } else if (($year > 1582) and ($year % 100 == 0)) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Internal mktime function used by Zend_Date for handling 64bit timestamps.
- *
- * Returns a formatted date for a given timestamp.
- *
- * @param string $format format for output
- * @param mixed $timestamp
- * @param boolean $gmt OPTIONAL true = other arguments are for UTC time, false = arguments are for local time/date
- * @return string
- */
- protected function date($format, $timestamp = null, $gmt = false)
- {
- $oldzone = @date_default_timezone_get();
- if ($this->_timezone != $oldzone) {
- date_default_timezone_set($this->_timezone);
- }
-
- if ($timestamp === null) {
- $result = ($gmt) ? @gmdate($format) : @date($format);
- date_default_timezone_set($oldzone);
- return $result;
- }
-
- if (abs($timestamp) <= 0x7FFFFFFF) {
- $result = ($gmt) ? @gmdate($format, $timestamp) : @date($format, $timestamp);
- date_default_timezone_set($oldzone);
- return $result;
- }
-
- $jump = false;
- $origstamp = $timestamp;
- if (isset(self::$_cache)) {
- $idstamp = strtr('Zend_DateObject_date_' . $this->_offset . '_'. $timestamp . '_'.(int)$gmt, '-','_');
- if ($result2 = self::$_cache->load($idstamp)) {
- $timestamp = unserialize($result2);
- $jump = true;
- }
- }
-
- // check on false or null alone failes
- if (empty($gmt) and empty($jump)) {
- $tempstamp = $timestamp;
- if ($tempstamp > 0) {
- while (abs($tempstamp) > 0x7FFFFFFF) {
- $tempstamp -= (86400 * 23376);
- }
-
- $dst = date("I", $tempstamp);
- if ($dst === 1) {
- $timestamp += 3600;
- }
-
- $temp = date('Z', $tempstamp);
- $timestamp += $temp;
- }
-
- if (isset(self::$_cache)) {
- self::$_cache->save( serialize($timestamp), $idstamp);
- }
- }
-
-
- if (($timestamp < 0) and ($gmt !== true)) {
- $timestamp -= $this->_offset;
- }
-
- date_default_timezone_set($oldzone);
- $date = $this->getDateParts($timestamp, true);
- $length = strlen($format);
- $output = '';
-
- for ($i = 0; $i < $length; $i++) {
- switch($format[$i]) {
- // day formats
- case 'd': // day of month, 2 digits, with leading zero, 01 - 31
- $output .= (($date['mday'] < 10) ? '0' . $date['mday'] : $date['mday']);
- break;
-
- case 'D': // day of week, 3 letters, Mon - Sun
- $output .= date('D', 86400 * (3 + self::dayOfWeek($date['year'], $date['mon'], $date['mday'])));
- break;
-
- case 'j': // day of month, without leading zero, 1 - 31
- $output .= $date['mday'];
- break;
-
- case 'l': // day of week, full string name, Sunday - Saturday
- $output .= date('l', 86400 * (3 + self::dayOfWeek($date['year'], $date['mon'], $date['mday'])));
- break;
-
- case 'N': // ISO 8601 numeric day of week, 1 - 7
- $day = self::dayOfWeek($date['year'], $date['mon'], $date['mday']);
- if ($day == 0) {
- $day = 7;
- }
- $output .= $day;
- break;
-
- case 'S': // english suffix for day of month, st nd rd th
- if (($date['mday'] % 10) == 1) {
- $output .= 'st';
- } else if ((($date['mday'] % 10) == 2) and ($date['mday'] != 12)) {
- $output .= 'nd';
- } else if (($date['mday'] % 10) == 3) {
- $output .= 'rd';
- } else {
- $output .= 'th';
- }
- break;
-
- case 'w': // numeric day of week, 0 - 6
- $output .= self::dayOfWeek($date['year'], $date['mon'], $date['mday']);
- break;
-
- case 'z': // day of year, 0 - 365
- $output .= $date['yday'];
- break;
-
-
- // week formats
- case 'W': // ISO 8601, week number of year
- $output .= $this->weekNumber($date['year'], $date['mon'], $date['mday']);
- break;
-
-
- // month formats
- case 'F': // string month name, january - december
- $output .= date('F', mktime(0, 0, 0, $date['mon'], 2, 1971));
- break;
-
- case 'm': // number of month, with leading zeros, 01 - 12
- $output .= (($date['mon'] < 10) ? '0' . $date['mon'] : $date['mon']);
- break;
-
- case 'M': // 3 letter month name, Jan - Dec
- $output .= date('M',mktime(0, 0, 0, $date['mon'], 2, 1971));
- break;
-
- case 'n': // number of month, without leading zeros, 1 - 12
- $output .= $date['mon'];
- break;
-
- case 't': // number of day in month
- $output .= self::$_monthTable[$date['mon'] - 1];
- break;
-
-
- // year formats
- case 'L': // is leap year ?
- $output .= (self::isYearLeapYear($date['year'])) ? '1' : '0';
- break;
-
- case 'o': // ISO 8601 year number
- $week = $this->weekNumber($date['year'], $date['mon'], $date['mday']);
- if (($week > 50) and ($date['mon'] == 1)) {
- $output .= ($date['year'] - 1);
- } else {
- $output .= $date['year'];
- }
- break;
-
- case 'Y': // year number, 4 digits
- $output .= $date['year'];
- break;
-
- case 'y': // year number, 2 digits
- $output .= substr($date['year'], strlen($date['year']) - 2, 2);
- break;
-
-
- // time formats
- case 'a': // lower case am/pm
- $output .= (($date['hours'] >= 12) ? 'pm' : 'am');
- break;
-
- case 'A': // upper case am/pm
- $output .= (($date['hours'] >= 12) ? 'PM' : 'AM');
- break;
-
- case 'B': // swatch internet time
- $dayseconds = ($date['hours'] * 3600) + ($date['minutes'] * 60) + $date['seconds'];
- if ($gmt === true) {
- $dayseconds += 3600;
- }
- $output .= (int) (($dayseconds % 86400) / 86.4);
- break;
-
- case 'g': // hours without leading zeros, 12h format
- if ($date['hours'] > 12) {
- $hour = $date['hours'] - 12;
- } else {
- if ($date['hours'] == 0) {
- $hour = '12';
- } else {
- $hour = $date['hours'];
- }
- }
- $output .= $hour;
- break;
-
- case 'G': // hours without leading zeros, 24h format
- $output .= $date['hours'];
- break;
-
- case 'h': // hours with leading zeros, 12h format
- if ($date['hours'] > 12) {
- $hour = $date['hours'] - 12;
- } else {
- if ($date['hours'] == 0) {
- $hour = '12';
- } else {
- $hour = $date['hours'];
- }
- }
- $output .= (($hour < 10) ? '0'.$hour : $hour);
- break;
-
- case 'H': // hours with leading zeros, 24h format
- $output .= (($date['hours'] < 10) ? '0' . $date['hours'] : $date['hours']);
- break;
-
- case 'i': // minutes with leading zeros
- $output .= (($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes']);
- break;
-
- case 's': // seconds with leading zeros
- $output .= (($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds']);
- break;
-
-
- // timezone formats
- case 'e': // timezone identifier
- if ($gmt === true) {
- $output .= gmdate('e', mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], 2000));
- } else {
- $output .= date('e', mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], 2000));
- }
- break;
-
- case 'I': // daylight saving time or not
- if ($gmt === true) {
- $output .= gmdate('I', mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], 2000));
- } else {
- $output .= date('I', mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], 2000));
- }
- break;
-
- case 'O': // difference to GMT in hours
- $gmtstr = ($gmt === true) ? 0 : $this->getGmtOffset();
- $output .= sprintf('%s%04d', ($gmtstr <= 0) ? '+' : '-', abs($gmtstr) / 36);
- break;
-
- case 'P': // difference to GMT with colon
- $gmtstr = ($gmt === true) ? 0 : $this->getGmtOffset();
- $gmtstr = sprintf('%s%04d', ($gmtstr <= 0) ? '+' : '-', abs($gmtstr) / 36);
- $output = $output . substr($gmtstr, 0, 3) . ':' . substr($gmtstr, 3);
- break;
-
- case 'T': // timezone settings
- if ($gmt === true) {
- $output .= gmdate('T', mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], 2000));
- } else {
- $output .= date('T', mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], 2000));
- }
- break;
-
- case 'Z': // timezone offset in seconds
- $output .= ($gmt === true) ? 0 : -$this->getGmtOffset();
- break;
-
-
- // complete time formats
- case 'c': // ISO 8601 date format
- $difference = $this->getGmtOffset();
- $difference = sprintf('%s%04d', ($difference <= 0) ? '+' : '-', abs($difference) / 36);
- $difference = substr($difference, 0, 3) . ':' . substr($difference, 3);
- $output .= $date['year'] . '-'
- . (($date['mon'] < 10) ? '0' . $date['mon'] : $date['mon']) . '-'
- . (($date['mday'] < 10) ? '0' . $date['mday'] : $date['mday']) . 'T'
- . (($date['hours'] < 10) ? '0' . $date['hours'] : $date['hours']) . ':'
- . (($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes']) . ':'
- . (($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds'])
- . $difference;
- break;
-
- case 'r': // RFC 2822 date format
- $difference = $this->getGmtOffset();
- $difference = sprintf('%s%04d', ($difference <= 0) ? '+' : '-', abs($difference) / 36);
- $output .= gmdate('D', 86400 * (3 + self::dayOfWeek($date['year'], $date['mon'], $date['mday']))) . ', '
- . (($date['mday'] < 10) ? '0' . $date['mday'] : $date['mday']) . ' '
- . date('M', mktime(0, 0, 0, $date['mon'], 2, 1971)) . ' '
- . $date['year'] . ' '
- . (($date['hours'] < 10) ? '0' . $date['hours'] : $date['hours']) . ':'
- . (($date['minutes'] < 10) ? '0' . $date['minutes'] : $date['minutes']) . ':'
- . (($date['seconds'] < 10) ? '0' . $date['seconds'] : $date['seconds']) . ' '
- . $difference;
- break;
-
- case 'U': // Unix timestamp
- $output .= $origstamp;
- break;
-
-
- // special formats
- case "\\": // next letter to print with no format
- $i++;
- if ($i < $length) {
- $output .= $format[$i];
- }
- break;
-
- default: // letter is no format so add it direct
- $output .= $format[$i];
- break;
- }
- }
-
- return (string) $output;
- }
-
- /**
- * Returns the day of week for a Gregorian calendar date.
- * 0 = sunday, 6 = saturday
- *
- * @param integer $year
- * @param integer $month
- * @param integer $day
- * @return integer dayOfWeek
- */
- protected static function dayOfWeek($year, $month, $day)
- {
- if ((1901 < $year) and ($year < 2038)) {
- return (int) date('w', mktime(0, 0, 0, $month, $day, $year));
- }
-
- // gregorian correction
- $correction = 0;
- if (($year < 1582) or (($year == 1582) and (($month < 10) or (($month == 10) && ($day < 15))))) {
- $correction = 3;
- }
-
- if ($month > 2) {
- $month -= 2;
- } else {
- $month += 10;
- $year--;
- }
-
- $day = floor((13 * $month - 1) / 5) + $day + ($year % 100) + floor(($year % 100) / 4);
- $day += floor(($year / 100) / 4) - 2 * floor($year / 100) + 77 + $correction;
-
- return (int) ($day - 7 * floor($day / 7));
- }
-
- /**
- * Internal getDateParts function for handling 64bit timestamps, similar to:
- * http://www.php.net/getdate
- *
- * Returns an array of date parts for $timestamp, relative to 1970/01/01 00:00:00 GMT/UTC.
- *
- * $fast specifies ALL date parts should be returned (slower)
- * Default is false, and excludes $dayofweek, weekday, month and timestamp from parts returned.
- *
- * @param mixed $timestamp
- * @param boolean $fast OPTIONAL defaults to fast (false), resulting in fewer date parts
- * @return array
- */
- protected function getDateParts($timestamp = null, $fast = null)
- {
-
- // actual timestamp
- if (!is_numeric($timestamp)) {
- return getdate();
- }
-
- // 32bit timestamp
- if (abs($timestamp) <= 0x7FFFFFFF) {
- return @getdate((int) $timestamp);
- }
-
- if (isset(self::$_cache)) {
- $id = strtr('Zend_DateObject_getDateParts_' . $timestamp.'_'.(int)$fast, '-','_');
- if ($result = self::$_cache->load($id)) {
- return unserialize($result);
- }
- }
-
- $otimestamp = $timestamp;
- $numday = 0;
- $month = 0;
- // gregorian correction
- if ($timestamp < -12219321600) {
- $timestamp -= 864000;
- }
-
- // timestamp lower 0
- if ($timestamp < 0) {
- $sec = 0;
- $act = 1970;
-
- // iterate through 10 years table, increasing speed
- foreach(self::$_yearTable as $year => $seconds) {
- if ($timestamp >= $seconds) {
- $i = $act;
- break;
- }
- $sec = $seconds;
- $act = $year;
- }
-
- $timestamp -= $sec;
- if (!isset($i)) {
- $i = $act;
- }
-
- // iterate the max last 10 years
- do {
- --$i;
- $day = $timestamp;
-
- $timestamp += 31536000;
- $leapyear = self::isYearLeapYear($i);
- if ($leapyear === true) {
- $timestamp += 86400;
- }
-
- if ($timestamp >= 0) {
- $year = $i;
- break;
- }
- } while ($timestamp < 0);
-
- $secondsPerYear = 86400 * ($leapyear ? 366 : 365) + $day;
-
- $timestamp = $day;
- // iterate through months
- for ($i = 12; --$i >= 0;) {
- $day = $timestamp;
-
- $timestamp += self::$_monthTable[$i] * 86400;
- if (($leapyear === true) and ($i == 1)) {
- $timestamp += 86400;
- }
-
- if ($timestamp >= 0) {
- $month = $i;
- $numday = self::$_monthTable[$i];
- if (($leapyear === true) and ($i == 1)) {
- ++$numday;
- }
- break;
- }
- }
-
- $timestamp = $day;
- $numberdays = $numday + ceil(($timestamp + 1) / 86400);
-
- $timestamp += ($numday - $numberdays + 1) * 86400;
- $hours = floor($timestamp / 3600);
- } else {
-
- // iterate through years
- for ($i = 1970;;$i++) {
- $day = $timestamp;
-
- $timestamp -= 31536000;
- $leapyear = self::isYearLeapYear($i);
- if ($leapyear === true) {
- $timestamp -= 86400;
- }
-
- if ($timestamp < 0) {
- $year = $i;
- break;
- }
- }
-
- $secondsPerYear = $day;
-
- $timestamp = $day;
- // iterate through months
- for ($i = 0; $i <= 11; $i++) {
- $day = $timestamp;
- $timestamp -= self::$_monthTable[$i] * 86400;
-
- if (($leapyear === true) and ($i == 1)) {
- $timestamp -= 86400;
- }
-
- if ($timestamp < 0) {
- $month = $i;
- $numday = self::$_monthTable[$i];
- if (($leapyear === true) and ($i == 1)) {
- ++$numday;
- }
- break;
- }
- }
-
- $timestamp = $day;
- $numberdays = ceil(($timestamp + 1) / 86400);
- $timestamp = $timestamp - ($numberdays - 1) * 86400;
- $hours = floor($timestamp / 3600);
- }
-
- $timestamp -= $hours * 3600;
-
- $month += 1;
- $minutes = floor($timestamp / 60);
- $seconds = $timestamp - $minutes * 60;
-
- if ($fast === true) {
- $array = array(
- 'seconds' => $seconds,
- 'minutes' => $minutes,
- 'hours' => $hours,
- 'mday' => $numberdays,
- 'mon' => $month,
- 'year' => $year,
- 'yday' => floor($secondsPerYear / 86400),
- );
- } else {
-
- $dayofweek = self::dayOfWeek($year, $month, $numberdays);
- $array = array(
- 'seconds' => $seconds,
- 'minutes' => $minutes,
- 'hours' => $hours,
- 'mday' => $numberdays,
- 'wday' => $dayofweek,
- 'mon' => $month,
- 'year' => $year,
- 'yday' => floor($secondsPerYear / 86400),
- 'weekday' => gmdate('l', 86400 * (3 + $dayofweek)),
- 'month' => gmdate('F', mktime(0, 0, 0, $month, 1, 1971)),
- 0 => $otimestamp
- );
- }
-
- if (isset(self::$_cache)) {
- self::$_cache->save( serialize($array), $id);
- }
-
- return $array;
- }
-
- /**
- * Internal getWeekNumber function for handling 64bit timestamps
- *
- * Returns the ISO 8601 week number of a given date
- *
- * @param integer $year
- * @param integer $month
- * @param integer $day
- * @return integer
- */
- protected function weekNumber($year, $month, $day)
- {
- if ((1901 < $year) and ($year < 2038)) {
- return (int) date('W', mktime(0, 0, 0, $month, $day, $year));
- }
-
- $dayofweek = self::dayOfWeek($year, $month, $day);
- $firstday = self::dayOfWeek($year, 1, 1);
- if (($month == 1) and (($firstday < 1) or ($firstday > 4)) and ($day < 4)) {
- $firstday = self::dayOfWeek($year - 1, 1, 1);
- $month = 12;
- $day = 31;
-
- } else if (($month == 12) and ((self::dayOfWeek($year + 1, 1, 1) < 5) and
- (self::dayOfWeek($year + 1, 1, 1) > 0))) {
- return 1;
- }
-
- return intval (((self::dayOfWeek($year, 1, 1) < 5) and (self::dayOfWeek($year, 1, 1) > 0)) +
- 4 * ($month - 1) + (2 * ($month - 1) + ($day - 1) + $firstday - $dayofweek + 6) * 36 / 256);
- }
-
- /**
- * Internal _range function
- * Sets the value $a to be in the range of [0, $b]
- *
- * @param float $a - value to correct
- * @param float $b - maximum range to set
- */
- private function _range($a, $b) {
- while ($a < 0) {
- $a += $b;
- }
- while ($a >= $b) {
- $a -= $b;
- }
- return $a;
- }
-
- /**
- * Calculates the sunrise or sunset based on a location
- *
- * @param array $location Location for calculation MUST include 'latitude', 'longitude', 'horizon'
- * @param bool $horizon true: sunrise; false: sunset
- * @return mixed - false: midnight sun, integer:
- */
- protected function calcSun($location, $horizon, $rise = false)
- {
- // timestamp within 32bit
- if (abs($this->_unixTimestamp) <= 0x7FFFFFFF) {
- if ($rise === false) {
- return date_sunset($this->_unixTimestamp, SUNFUNCS_RET_TIMESTAMP, $location['latitude'],
- $location['longitude'], 90 + $horizon, $this->getGmtOffset() / 3600);
- }
- return date_sunrise($this->_unixTimestamp, SUNFUNCS_RET_TIMESTAMP, $location['latitude'],
- $location['longitude'], 90 + $horizon, $this->getGmtOffset() / 3600);
- }
-
- // self calculation - timestamp bigger than 32bit
- // fix circle values
- $quarterCircle = 0.5 * M_PI;
- $halfCircle = M_PI;
- $threeQuarterCircle = 1.5 * M_PI;
- $fullCircle = 2 * M_PI;
-
- // radiant conversion for coordinates
- $radLatitude = $location['latitude'] * $halfCircle / 180;
- $radLongitude = $location['longitude'] * $halfCircle / 180;
-
- // get solar coordinates
- $tmpRise = $rise ? $quarterCircle : $threeQuarterCircle;
- $radDay = $this->date('z',$this->_unixTimestamp) + ($tmpRise - $radLongitude) / $fullCircle;
-
- // solar anomoly and longitude
- $solAnomoly = $radDay * 0.017202 - 0.0574039;
- $solLongitude = $solAnomoly + 0.0334405 * sin($solAnomoly);
- $solLongitude += 4.93289 + 3.49066E-4 * sin(2 * $solAnomoly);
-
- // get quadrant
- $solLongitude = $this->_range($solLongitude, $fullCircle);
-
- if (($solLongitude / $quarterCircle) - intval($solLongitude / $quarterCircle) == 0) {
- $solLongitude += 4.84814E-6;
- }
-
- // solar ascension
- $solAscension = sin($solLongitude) / cos($solLongitude);
- $solAscension = atan2(0.91746 * $solAscension, 1);
-
- // adjust quadrant
- if ($solLongitude > $threeQuarterCircle) {
- $solAscension += $fullCircle;
- } else if ($solLongitude > $quarterCircle) {
- $solAscension += $halfCircle;
- }
-
- // solar declination
- $solDeclination = 0.39782 * sin($solLongitude);
- $solDeclination /= sqrt(-$solDeclination * $solDeclination + 1);
- $solDeclination = atan2($solDeclination, 1);
-
- $solHorizon = $horizon - sin($solDeclination) * sin($radLatitude);
- $solHorizon /= cos($solDeclination) * cos($radLatitude);
-
- // midnight sun, always night
- if (abs($solHorizon) > 1) {
- return false;
- }
-
- $solHorizon /= sqrt(-$solHorizon * $solHorizon + 1);
- $solHorizon = $quarterCircle - atan2($solHorizon, 1);
-
- if ($rise) {
- $solHorizon = $fullCircle - $solHorizon;
- }
-
- // time calculation
- $localTime = $solHorizon + $solAscension - 0.0172028 * $radDay - 1.73364;
- $universalTime = $localTime - $radLongitude;
-
- // determinate quadrant
- $universalTime = $this->_range($universalTime, $fullCircle);
-
- // radiant to hours
- $universalTime *= 24 / $fullCircle;
-
- // convert to time
- $hour = intval($universalTime);
- $universalTime = ($universalTime - $hour) * 60;
- $min = intval($universalTime);
- $universalTime = ($universalTime - $min) * 60;
- $sec = intval($universalTime);
-
- return $this->mktime($hour, $min, $sec, $this->date('m', $this->_unixTimestamp),
- $this->date('j', $this->_unixTimestamp), $this->date('Y', $this->_unixTimestamp),
- -1, true);
- }
-
- /**
- * Sets a new timezone for calculation of $this object's gmt offset.
- * For a list of supported timezones look here: http://php.net/timezones
- * If no timezone can be detected or the given timezone is wrong UTC will be set.
- *
- * @param string $zone OPTIONAL timezone for date calculation; defaults to date_default_timezone_get()
- * @return Zend_Date_DateObject Provides fluent interface
- * @throws Zend_Date_Exception
- */
- public function setTimezone($zone = null)
- {
- $oldzone = @date_default_timezone_get();
- if ($zone === null) {
- $zone = $oldzone;
- }
-
- // throw an error on false input, but only if the new date extension is available
- if (function_exists('timezone_open')) {
- if (!@timezone_open($zone)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("timezone ($zone) is not a known timezone", 0, null, $zone);
- }
- }
- // this can generate an error if the date extension is not available and a false timezone is given
- $result = @date_default_timezone_set($zone);
- if ($result === true) {
- $this->_offset = mktime(0, 0, 0, 1, 2, 1970) - gmmktime(0, 0, 0, 1, 2, 1970);
- $this->_timezone = $zone;
- }
- date_default_timezone_set($oldzone);
-
- if (($zone == 'UTC') or ($zone == 'GMT')) {
- $this->_dst = false;
- } else {
- $this->_dst = true;
- }
-
- return $this;
- }
-
- /**
- * Return the timezone of $this object.
- * The timezone is initially set when the object is instantiated.
- *
- * @return string actual set timezone string
- */
- public function getTimezone()
- {
- return $this->_timezone;
- }
-
- /**
- * Return the offset to GMT of $this object's timezone.
- * The offset to GMT is initially set when the object is instantiated using the currently,
- * in effect, default timezone for PHP functions.
- *
- * @return integer seconds difference between GMT timezone and timezone when object was instantiated
- */
- public function getGmtOffset()
- {
- $date = $this->getDateParts($this->getUnixTimestamp(), true);
- $zone = @date_default_timezone_get();
- $result = @date_default_timezone_set($this->_timezone);
- if ($result === true) {
- $offset = $this->mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], $date['year'], false)
- - $this->mktime($date['hours'], $date['minutes'], $date['seconds'],
- $date['mon'], $date['mday'], $date['year'], true);
- }
- date_default_timezone_set($zone);
-
- return $offset;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Date/Exception.php zendframework-2.2.6/library/Zend/Date/Exception.php
--- zendframework-1.10.4/library/Zend/Date/Exception.php 2010-01-14 15:21:47.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Date/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,49 +0,0 @@
-operand = $op;
- parent::__construct($message, $code, $e);
- }
-
- public function getOperand()
- {
- return $this->operand;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Date.php zendframework-2.2.6/library/Zend/Date.php
--- zendframework-1.10.4/library/Zend/Date.php 2010-04-03 19:24:46.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Date.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,4952 +0,0 @@
- 'iso', // format for date strings 'iso' or 'php'
- 'fix_dst' => true, // fix dst on summer/winter time change
- 'extend_month' => false, // false - addMonth like SQL, true like excel
- 'cache' => null, // cache to set
- 'timesync' => null // timesync server to set
- );
-
- // Class wide Date Constants
- const DAY = 'dd';
- const DAY_SHORT = 'd';
- const DAY_SUFFIX = 'SS';
- const DAY_OF_YEAR = 'D';
- const WEEKDAY = 'EEEE';
- const WEEKDAY_SHORT = 'EEE';
- const WEEKDAY_NARROW = 'E';
- const WEEKDAY_NAME = 'EE';
- const WEEKDAY_8601 = 'eee';
- const WEEKDAY_DIGIT = 'e';
- const WEEK = 'ww';
- const MONTH = 'MM';
- const MONTH_SHORT = 'M';
- const MONTH_DAYS = 'ddd';
- const MONTH_NAME = 'MMMM';
- const MONTH_NAME_SHORT = 'MMM';
- const MONTH_NAME_NARROW = 'MMMMM';
- const YEAR = 'y';
- const YEAR_SHORT = 'yy';
- const YEAR_8601 = 'Y';
- const YEAR_SHORT_8601 = 'YY';
- const LEAPYEAR = 'l';
- const MERIDIEM = 'a';
- const SWATCH = 'B';
- const HOUR = 'HH';
- const HOUR_SHORT = 'H';
- const HOUR_AM = 'hh';
- const HOUR_SHORT_AM = 'h';
- const MINUTE = 'mm';
- const MINUTE_SHORT = 'm';
- const SECOND = 'ss';
- const SECOND_SHORT = 's';
- const MILLISECOND = 'S';
- const TIMEZONE_NAME = 'zzzz';
- const DAYLIGHT = 'I';
- const GMT_DIFF = 'Z';
- const GMT_DIFF_SEP = 'ZZZZ';
- const TIMEZONE = 'z';
- const TIMEZONE_SECS = 'X';
- const ISO_8601 = 'c';
- const RFC_2822 = 'r';
- const TIMESTAMP = 'U';
- const ERA = 'G';
- const ERA_NAME = 'GGGG';
- const ERA_NARROW = 'GGGGG';
- const DATES = 'F';
- const DATE_FULL = 'FFFFF';
- const DATE_LONG = 'FFFF';
- const DATE_MEDIUM = 'FFF';
- const DATE_SHORT = 'FF';
- const TIMES = 'WW';
- const TIME_FULL = 'TTTTT';
- const TIME_LONG = 'TTTT';
- const TIME_MEDIUM = 'TTT';
- const TIME_SHORT = 'TT';
- const DATETIME = 'K';
- const DATETIME_FULL = 'KKKKK';
- const DATETIME_LONG = 'KKKK';
- const DATETIME_MEDIUM = 'KKK';
- const DATETIME_SHORT = 'KK';
- const ATOM = 'OOO';
- const COOKIE = 'CCC';
- const RFC_822 = 'R';
- const RFC_850 = 'RR';
- const RFC_1036 = 'RRR';
- const RFC_1123 = 'RRRR';
- const RFC_3339 = 'RRRRR';
- const RSS = 'SSS';
- const W3C = 'WWW';
-
- /**
- * Generates the standard date object, could be a unix timestamp, localized date,
- * string, integer, array and so on. Also parts of dates or time are supported
- * Always set the default timezone: http://php.net/date_default_timezone_set
- * For example, in your bootstrap: date_default_timezone_set('America/Los_Angeles');
- * For detailed instructions please look in the docu.
- *
- * @param string|integer|Zend_Date|array $date OPTIONAL Date value or value of date part to set
- * ,depending on $part. If null the actual time is set
- * @param string $part OPTIONAL Defines the input format of $date
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- * @throws Zend_Date_Exception
- */
- public function __construct($date = null, $part = null, $locale = null)
- {
- if (is_object($date) and !($date instanceof Zend_TimeSync_Protocol) and
- !($date instanceof Zend_Date)) {
- if ($locale instanceof Zend_Locale) {
- $locale = $date;
- $date = null;
- $part = null;
- } else {
- $date = (string) $date;
- }
- }
-
- if (($date !== null) and !is_array($date) and !($date instanceof Zend_TimeSync_Protocol) and
- !($date instanceof Zend_Date) and !defined($date) and Zend_Locale::isLocale($date, true, false)) {
- $locale = $date;
- $date = null;
- $part = null;
- } else if (($part !== null) and !defined($part) and Zend_Locale::isLocale($part, true, false)) {
- $locale = $part;
- $part = null;
- }
-
- $this->setLocale($locale);
- if (is_string($date) && ($part === null) && (strlen($date) <= 5)) {
- $part = $date;
- $date = null;
- }
-
- if ($date === null) {
- if ($part === null) {
- $date = time();
- } else if ($part !== self::TIMESTAMP) {
- $date = self::now($locale);
- $date = $date->get($part);
- }
- }
-
- if ($date instanceof Zend_TimeSync_Protocol) {
- $date = $date->getInfo();
- $date = $this->_getTime($date['offset']);
- $part = null;
- } else if (parent::$_defaultOffset != 0) {
- $date = $this->_getTime(parent::$_defaultOffset);
- }
-
- // set the timezone and offset for $this
- $zone = @date_default_timezone_get();
- $this->setTimezone($zone);
-
- // try to get timezone from date-string
- if (!is_int($date)) {
- $zone = $this->getTimezoneFromString($date);
- $this->setTimezone($zone);
- }
-
- // set datepart
- if (($part !== null && $part !== self::TIMESTAMP) or (!is_numeric($date))) {
- // switch off dst handling for value setting
- $this->setUnixTimestamp($this->getGmtOffset());
- $this->set($date, $part, $this->_locale);
-
- // DST fix
- if (is_array($date) === true) {
- if (!isset($date['hour'])) {
- $date['hour'] = 0;
- }
-
- $hour = $this->toString('H', 'iso', true);
- $hour = $date['hour'] - $hour;
- switch ($hour) {
- case 1 :
- case -23 :
- $this->addTimestamp(3600);
- break;
- case -1 :
- case 23 :
- $this->subTimestamp(3600);
- break;
- case 2 :
- case -22 :
- $this->addTimestamp(7200);
- break;
- case -2 :
- case 22 :
- $this->subTimestamp(7200);
- break;
- }
- }
- } else {
- $this->setUnixTimestamp($date);
- }
- }
-
- /**
- * Sets class wide options, if no option was given, the actual set options will be returned
- *
- * @param array $options Options to set
- * @throws Zend_Date_Exception
- * @return Options array if no option was given
- */
- public static function setOptions(array $options = array())
- {
- if (empty($options)) {
- return self::$_options;
- }
-
- foreach ($options as $name => $value) {
- $name = strtolower($name);
-
- if (array_key_exists($name, self::$_options)) {
- switch($name) {
- case 'format_type' :
- if ((strtolower($value) != 'php') && (strtolower($value) != 'iso')) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("Unknown format type ($value) for dates, only 'iso' and 'php' supported", 0, null, $value);
- }
- break;
- case 'fix_dst' :
- if (!is_bool($value)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("'fix_dst' has to be boolean", 0, null, $value);
- }
- break;
- case 'extend_month' :
- if (!is_bool($value)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("'extend_month' has to be boolean", 0, null, $value);
- }
- break;
- case 'cache' :
- if ($value === null) {
- parent::$_cache = null;
- } else {
- if (!$value instanceof Zend_Cache_Core) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("Instance of Zend_Cache expected");
- }
-
- parent::$_cache = $value;
- Zend_Locale_Data::setCache($value);
- }
- break;
- case 'timesync' :
- if ($value === null) {
- parent::$_defaultOffset = 0;
- } else {
- if (!$value instanceof Zend_TimeSync_Protocol) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("Instance of Zend_TimeSync expected");
- }
-
- $date = $value->getInfo();
- parent::$_defaultOffset = $date['offset'];
- }
- break;
- }
- self::$_options[$name] = $value;
- }
- else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("Unknown option: $name = $value");
- }
- }
- }
-
- /**
- * Returns this object's internal UNIX timestamp (equivalent to Zend_Date::TIMESTAMP).
- * If the timestamp is too large for integers, then the return value will be a string.
- * This function does not return the timestamp as an object.
- * Use clone() or copyPart() instead.
- *
- * @return integer|string UNIX timestamp
- */
- public function getTimestamp()
- {
- return $this->getUnixTimestamp();
- }
-
- /**
- * Returns the calculated timestamp
- * HINT: timestamps are always GMT
- *
- * @param string $calc Type of calculation to make
- * @param string|integer|array|Zend_Date $stamp Timestamp to calculate, when null the actual timestamp is calculated
- * @return Zend_Date|integer
- * @throws Zend_Date_Exception
- */
- private function _timestamp($calc, $stamp)
- {
- if ($stamp instanceof Zend_Date) {
- // extract timestamp from object
- $stamp = $stamp->getTimestamp();
- }
-
- if (is_array($stamp)) {
- if (isset($stamp['timestamp']) === true) {
- $stamp = $stamp['timestamp'];
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('no timestamp given in array');
- }
- }
-
- if ($calc === 'set') {
- $return = $this->setUnixTimestamp($stamp);
- } else {
- $return = $this->_calcdetail($calc, $stamp, self::TIMESTAMP, null);
- }
- if ($calc != 'cmp') {
- return $this;
- }
- return $return;
- }
-
- /**
- * Sets a new timestamp
- *
- * @param integer|string|array|Zend_Date $timestamp Timestamp to set
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setTimestamp($timestamp)
- {
- return $this->_timestamp('set', $timestamp);
- }
-
- /**
- * Adds a timestamp
- *
- * @param integer|string|array|Zend_Date $timestamp Timestamp to add
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addTimestamp($timestamp)
- {
- return $this->_timestamp('add', $timestamp);
- }
-
- /**
- * Subtracts a timestamp
- *
- * @param integer|string|array|Zend_Date $timestamp Timestamp to sub
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function subTimestamp($timestamp)
- {
- return $this->_timestamp('sub', $timestamp);
- }
-
- /**
- * Compares two timestamps, returning the difference as integer
- *
- * @param integer|string|array|Zend_Date $timestamp Timestamp to compare
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareTimestamp($timestamp)
- {
- return $this->_timestamp('cmp', $timestamp);
- }
-
- /**
- * Returns a string representation of the object
- * Supported format tokens are:
- * G - era, y - year, Y - ISO year, M - month, w - week of year, D - day of year, d - day of month
- * E - day of week, e - number of weekday (1-7), h - hour 1-12, H - hour 0-23, m - minute, s - second
- * A - milliseconds of day, z - timezone, Z - timezone offset, S - fractional second, a - period of day
- *
- * Additionally format tokens but non ISO conform are:
- * SS - day suffix, eee - php number of weekday(0-6), ddd - number of days per month
- * l - Leap year, B - swatch internet time, I - daylight saving time, X - timezone offset in seconds
- * r - RFC2822 format, U - unix timestamp
- *
- * Not supported ISO tokens are
- * u - extended year, Q - quarter, q - quarter, L - stand alone month, W - week of month
- * F - day of week of month, g - modified julian, c - stand alone weekday, k - hour 0-11, K - hour 1-24
- * v - wall zone
- *
- * @param string $format OPTIONAL Rule for formatting output. If null the default date format is used
- * @param string $type OPTIONAL Type for the format string which overrides the standard setting
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return string
- */
- public function toString($format = null, $type = null, $locale = null)
- {
- if (is_object($format)) {
- if ($format instanceof Zend_Locale) {
- $locale = $format;
- $format = null;
- } else {
- $format = (string) $format;
- }
- }
-
- if (is_object($type)) {
- if ($type instanceof Zend_Locale) {
- $locale = $type;
- $type = null;
- } else {
- $type = (string) $type;
- }
- }
-
- if (($format !== null) && !defined($format)
- && ($format != 'ee') && ($format != 'ss') && ($format != 'GG') && ($format != 'MM') && ($format != 'EE') && ($format != 'TT')
- && Zend_Locale::isLocale($format, null, false)) {
- $locale = $format;
- $format = null;
- }
-
- if (($type !== null) and ($type != 'php') and ($type != 'iso') and
- Zend_Locale::isLocale($type, null, false)) {
- $locale = $type;
- $type = null;
- }
-
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- if ($format === null) {
- $format = Zend_Locale_Format::getDateFormat($locale) . ' ' . Zend_Locale_Format::getTimeFormat($locale);
- } else if (((self::$_options['format_type'] == 'php') && ($type === null)) or ($type == 'php')) {
- $format = Zend_Locale_Format::convertPhpToIsoFormat($format);
- }
-
- return $this->date($this->_toToken($format, $locale), $this->getUnixTimestamp(), false);
- }
-
- /**
- * Returns a string representation of the date which is equal with the timestamp
- *
- * @return string
- */
- public function __toString()
- {
- return $this->toString(null, $this->_locale);
- }
-
- /**
- * Returns a integer representation of the object
- * But returns false when the given part is no value f.e. Month-Name
- *
- * @param string|integer|Zend_Date $part OPTIONAL Defines the date or datepart to return as integer
- * @return integer|false
- */
- public function toValue($part = null)
- {
- $result = $this->get($part);
- if (is_numeric($result)) {
- return intval("$result");
- } else {
- return false;
- }
- }
-
- /**
- * Returns an array representation of the object
- *
- * @return array
- */
- public function toArray()
- {
- return array('day' => $this->toString(self::DAY_SHORT, 'iso'),
- 'month' => $this->toString(self::MONTH_SHORT, 'iso'),
- 'year' => $this->toString(self::YEAR, 'iso'),
- 'hour' => $this->toString(self::HOUR_SHORT, 'iso'),
- 'minute' => $this->toString(self::MINUTE_SHORT, 'iso'),
- 'second' => $this->toString(self::SECOND_SHORT, 'iso'),
- 'timezone' => $this->toString(self::TIMEZONE, 'iso'),
- 'timestamp' => $this->toString(self::TIMESTAMP, 'iso'),
- 'weekday' => $this->toString(self::WEEKDAY_8601, 'iso'),
- 'dayofyear' => $this->toString(self::DAY_OF_YEAR, 'iso'),
- 'week' => $this->toString(self::WEEK, 'iso'),
- 'gmtsecs' => $this->toString(self::TIMEZONE_SECS, 'iso'));
- }
-
- /**
- * Returns a representation of a date or datepart
- * This could be for example a localized monthname, the time without date,
- * the era or only the fractional seconds. There are about 50 different supported date parts.
- * For a complete list of supported datepart values look into the docu
- *
- * @param string $part OPTIONAL Part of the date to return, if null the timestamp is returned
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return string date or datepart
- */
- public function get($part = null, $locale = null)
- {
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- if (($part !== null) && !defined($part)
- && ($part != 'ee') && ($part != 'ss') && ($part != 'GG') && ($part != 'MM') && ($part != 'EE') && ($part != 'TT')
- && Zend_Locale::isLocale($part, null, false)) {
- $locale = $part;
- $part = null;
- }
-
- if ($part === null) {
- $part = self::TIMESTAMP;
- } else if (self::$_options['format_type'] == 'php') {
- $part = Zend_Locale_Format::convertPhpToIsoFormat($part);
- }
-
- return $this->date($this->_toToken($part, $locale), $this->getUnixTimestamp(), false);
- }
-
- /**
- * Internal method to apply tokens
- *
- * @param string $part
- * @param string $locale
- * @return string
- */
- private function _toToken($part, $locale) {
- // get format tokens
- $comment = false;
- $format = '';
- $orig = '';
- for ($i = 0; $i < strlen($part); ++$i) {
- if ($part[$i] == "'") {
- $comment = $comment ? false : true;
- if (isset($part[$i+1]) && ($part[$i+1] == "'")) {
- $comment = $comment ? false : true;
- $format .= "\\'";
- ++$i;
- }
-
- $orig = '';
- continue;
- }
-
- if ($comment) {
- $format .= '\\' . $part[$i];
- $orig = '';
- } else {
- $orig .= $part[$i];
- if (!isset($part[$i+1]) || (isset($orig[0]) && ($orig[0] != $part[$i+1]))) {
- $format .= $this->_parseIsoToDate($orig, $locale);
- $orig = '';
- }
- }
- }
-
- return $format;
- }
-
- /**
- * Internal parsing method
- *
- * @param string $token
- * @param string $locale
- * @return string
- */
- private function _parseIsoToDate($token, $locale) {
- switch($token) {
- case self::DAY :
- return 'd';
- break;
-
- case self::WEEKDAY_SHORT :
- $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false));
- $day = Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'wide', $weekday));
- return $this->_toComment(iconv_substr($day, 0, 3, 'UTF-8'));
- break;
-
- case self::DAY_SHORT :
- return 'j';
- break;
-
- case self::WEEKDAY :
- $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false));
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'wide', $weekday)));
- break;
-
- case self::WEEKDAY_8601 :
- return 'N';
- break;
-
- case 'ee' :
- return $this->_toComment(str_pad($this->date('N', $this->getUnixTimestamp(), false), 2, '0', STR_PAD_LEFT));
- break;
-
- case self::DAY_SUFFIX :
- return 'S';
- break;
-
- case self::WEEKDAY_DIGIT :
- return 'w';
- break;
-
- case self::DAY_OF_YEAR :
- return 'z';
- break;
-
- case 'DDD' :
- return $this->_toComment(str_pad($this->date('z', $this->getUnixTimestamp(), false), 3, '0', STR_PAD_LEFT));
- break;
-
- case 'DD' :
- return $this->_toComment(str_pad($this->date('z', $this->getUnixTimestamp(), false), 2, '0', STR_PAD_LEFT));
- break;
-
- case self::WEEKDAY_NARROW :
- case 'EEEEE' :
- $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false));
- $day = Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'abbreviated', $weekday));
- return $this->_toComment(iconv_substr($day, 0, 1, 'UTF-8'));
- break;
-
- case self::WEEKDAY_NAME :
- $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false));
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'abbreviated', $weekday)));
- break;
-
- case 'w' :
- $week = $this->date('W', $this->getUnixTimestamp(), false);
- return $this->_toComment(($week[0] == '0') ? $week[1] : $week);
- break;
-
- case self::WEEK :
- return 'W';
- break;
-
- case self::MONTH_NAME :
- $month = $this->date('n', $this->getUnixTimestamp(), false);
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'month', array('gregorian', 'format', 'wide', $month)));
- break;
-
- case self::MONTH :
- return 'm';
- break;
-
- case self::MONTH_NAME_SHORT :
- $month = $this->date('n', $this->getUnixTimestamp(), false);
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'month', array('gregorian', 'format', 'abbreviated', $month)));
- break;
-
- case self::MONTH_SHORT :
- return 'n';
- break;
-
- case self::MONTH_DAYS :
- return 't';
- break;
-
- case self::MONTH_NAME_NARROW :
- $month = $this->date('n', $this->getUnixTimestamp(), false);
- $mon = Zend_Locale_Data::getContent($locale, 'month', array('gregorian', 'format', 'abbreviated', $month));
- return $this->_toComment(iconv_substr($mon, 0, 1, 'UTF-8'));
- break;
-
- case self::LEAPYEAR :
- return 'L';
- break;
-
- case self::YEAR_8601 :
- return 'o';
- break;
-
- case self::YEAR :
- return 'Y';
- break;
-
- case self::YEAR_SHORT :
- return 'y';
- break;
-
- case self::YEAR_SHORT_8601 :
- return $this->_toComment(substr($this->date('o', $this->getUnixTimestamp(), false), -2, 2));
- break;
-
- case self::MERIDIEM :
- $am = $this->date('a', $this->getUnixTimestamp(), false);
- if ($am == 'am') {
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'am'));
- }
-
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'pm'));
- break;
-
- case self::SWATCH :
- return 'B';
- break;
-
- case self::HOUR_SHORT_AM :
- return 'g';
- break;
-
- case self::HOUR_SHORT :
- return 'G';
- break;
-
- case self::HOUR_AM :
- return 'h';
- break;
-
- case self::HOUR :
- return 'H';
- break;
-
- case self::MINUTE :
- return $this->_toComment(str_pad($this->date('i', $this->getUnixTimestamp(), false), 2, '0', STR_PAD_LEFT));
- break;
-
- case self::SECOND :
- return $this->_toComment(str_pad($this->date('s', $this->getUnixTimestamp(), false), 2, '0', STR_PAD_LEFT));
- break;
-
- case self::MINUTE_SHORT :
- return 'i';
- break;
-
- case self::SECOND_SHORT :
- return 's';
- break;
-
- case self::MILLISECOND :
- return $this->_toComment($this->getMilliSecond());
- break;
-
- case self::TIMEZONE_NAME :
- case 'vvvv' :
- return 'e';
- break;
-
- case self::DAYLIGHT :
- return 'I';
- break;
-
- case self::GMT_DIFF :
- case 'ZZ' :
- case 'ZZZ' :
- return 'O';
- break;
-
- case self::GMT_DIFF_SEP :
- return 'P';
- break;
-
- case self::TIMEZONE :
- case 'v' :
- case 'zz' :
- case 'zzz' :
- return 'T';
- break;
-
- case self::TIMEZONE_SECS :
- return 'Z';
- break;
-
- case self::ISO_8601 :
- return 'c';
- break;
-
- case self::RFC_2822 :
- return 'r';
- break;
-
- case self::TIMESTAMP :
- return 'U';
- break;
-
- case self::ERA :
- case 'GG' :
- case 'GGG' :
- $year = $this->date('Y', $this->getUnixTimestamp(), false);
- if ($year < 0) {
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'era', array('gregorian', 'Abbr', '0')));
- }
-
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'era', array('gregorian', 'Abbr', '1')));
- break;
-
- case self::ERA_NARROW :
- $year = $this->date('Y', $this->getUnixTimestamp(), false);
- if ($year < 0) {
- return $this->_toComment(iconv_substr(Zend_Locale_Data::getContent($locale, 'era', array('gregorian', 'Abbr', '0')), 0, 1, 'UTF-8')) . '.';
- }
-
- return $this->_toComment(iconv_substr(Zend_Locale_Data::getContent($locale, 'era', array('gregorian', 'Abbr', '1')), 0, 1, 'UTF-8')) . '.';
- break;
-
- case self::ERA_NAME :
- $year = $this->date('Y', $this->getUnixTimestamp(), false);
- if ($year < 0) {
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'era', array('gregorian', 'Names', '0')));
- }
-
- return $this->_toComment(Zend_Locale_Data::getContent($locale, 'era', array('gregorian', 'Names', '1')));
- break;
-
- case self::DATES :
- return $this->_toToken(Zend_Locale_Format::getDateFormat($locale), $locale);
- break;
-
- case self::DATE_FULL :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'full')), $locale);
- break;
-
- case self::DATE_LONG :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'long')), $locale);
- break;
-
- case self::DATE_MEDIUM :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'medium')), $locale);
- break;
-
- case self::DATE_SHORT :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'short')), $locale);
- break;
-
- case self::TIMES :
- return $this->_toToken(Zend_Locale_Format::getTimeFormat($locale), $locale);
- break;
-
- case self::TIME_FULL :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'time', 'full'), $locale);
- break;
-
- case self::TIME_LONG :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'time', 'long'), $locale);
- break;
-
- case self::TIME_MEDIUM :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'time', 'medium'), $locale);
- break;
-
- case self::TIME_SHORT :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'time', 'short'), $locale);
- break;
-
- case self::DATETIME :
- return $this->_toToken(Zend_Locale_Format::getDateTimeFormat($locale), $locale);
- break;
-
- case self::DATETIME_FULL :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'full')), $locale);
- break;
-
- case self::DATETIME_LONG :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'long')), $locale);
- break;
-
- case self::DATETIME_MEDIUM :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'medium')), $locale);
- break;
-
- case self::DATETIME_SHORT :
- return $this->_toToken(Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'short')), $locale);
- break;
-
- case self::ATOM :
- return 'Y\-m\-d\TH\:i\:sP';
- break;
-
- case self::COOKIE :
- return 'l\, d\-M\-y H\:i\:s e';
- break;
-
- case self::RFC_822 :
- return 'D\, d M y H\:i\:s O';
- break;
-
- case self::RFC_850 :
- return 'l\, d\-M\-y H\:i\:s e';
- break;
-
- case self::RFC_1036 :
- return 'D\, d M y H\:i\:s O';
- break;
-
- case self::RFC_1123 :
- return 'D\, d M Y H\:i\:s O';
- break;
-
- case self::RFC_3339 :
- return 'Y\-m\-d\TH\:i\:sP';
- break;
-
- case self::RSS :
- return 'D\, d M Y H\:i\:s O';
- break;
-
- case self::W3C :
- return 'Y\-m\-d\TH\:i\:sP';
- break;
- }
-
- if ($token == '') {
- return '';
- }
-
- switch ($token[0]) {
- case 'y' :
- if ((strlen($token) == 4) && (abs($this->getUnixTimestamp()) <= 0x7FFFFFFF)) {
- return 'Y';
- }
-
- $length = iconv_strlen($token, 'UTF-8');
- return $this->_toComment(str_pad($this->date('Y', $this->getUnixTimestamp(), false), $length, '0', STR_PAD_LEFT));
- break;
-
- case 'Y' :
- if ((strlen($token) == 4) && (abs($this->getUnixTimestamp()) <= 0x7FFFFFFF)) {
- return 'o';
- }
-
- $length = iconv_strlen($token, 'UTF-8');
- return $this->_toComment(str_pad($this->date('o', $this->getUnixTimestamp(), false), $length, '0', STR_PAD_LEFT));
- break;
-
- case 'A' :
- $length = iconv_strlen($token, 'UTF-8');
- $result = substr($this->getMilliSecond(), 0, 3);
- $result += $this->date('s', $this->getUnixTimestamp(), false) * 1000;
- $result += $this->date('i', $this->getUnixTimestamp(), false) * 60000;
- $result += $this->date('H', $this->getUnixTimestamp(), false) * 3600000;
-
- return $this->_toComment(str_pad($result, $length, '0', STR_PAD_LEFT));
- break;
- }
-
- return $this->_toComment($token);
- }
-
- /**
- * Private function to make a comment of a token
- *
- * @param string $token
- * @return string
- */
- private function _toComment($token)
- {
- $token = str_split($token);
- $result = '';
- foreach ($token as $tok) {
- $result .= '\\' . $tok;
- }
-
- return $result;
- }
-
- /**
- * Return digit from standard names (english)
- * Faster implementation than locale aware searching
- *
- * @param string $name
- * @return integer Number of this month
- * @throws Zend_Date_Exception
- */
- private function _getDigitFromName($name)
- {
- switch($name) {
- case "Jan":
- return 1;
-
- case "Feb":
- return 2;
-
- case "Mar":
- return 3;
-
- case "Apr":
- return 4;
-
- case "May":
- return 5;
-
- case "Jun":
- return 6;
-
- case "Jul":
- return 7;
-
- case "Aug":
- return 8;
-
- case "Sep":
- return 9;
-
- case "Oct":
- return 10;
-
- case "Nov":
- return 11;
-
- case "Dec":
- return 12;
-
- default:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('Month ($name) is not a known month');
- }
- }
-
- /**
- * Counts the exact year number
- * < 70 - 2000 added, >70 < 100 - 1900, others just returned
- *
- * @param integer $value year number
- * @return integer Number of year
- */
- public static function getFullYear($value)
- {
- if ($value >= 0) {
- if ($value < 70) {
- $value += 2000;
- } else if ($value < 100) {
- $value += 1900;
- }
- }
- return $value;
- }
-
- /**
- * Sets the given date as new date or a given datepart as new datepart returning the new datepart
- * This could be for example a localized dayname, the date without time,
- * the month or only the seconds. There are about 50 different supported date parts.
- * For a complete list of supported datepart values look into the docu
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to set
- * @param string $part OPTIONAL Part of the date to set, if null the timestamp is set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function set($date, $part = null, $locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $part = Zend_Locale_Format::convertPhpToIsoFormat($part);
- }
-
- $zone = $this->getTimezoneFromString($date);
- $this->setTimezone($zone);
-
- $this->_calculate('set', $date, $part, $locale);
- return $this;
- }
-
- /**
- * Adds a date or datepart to the existing date, by extracting $part from $date,
- * and modifying this object by adding that part. The $part is then extracted from
- * this object and returned as an integer or numeric string (for large values, or $part's
- * corresponding to pre-defined formatted date strings).
- * This could be for example a ISO 8601 date, the hour the monthname or only the minute.
- * There are about 50 different supported date parts.
- * For a complete list of supported datepart values look into the docu.
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to add
- * @param string $part OPTIONAL Part of the date to add, if null the timestamp is added
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function add($date, $part = self::TIMESTAMP, $locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $part = Zend_Locale_Format::convertPhpToIsoFormat($part);
- }
-
- $this->_calculate('add', $date, $part, $locale);
- return $this;
- }
-
- /**
- * Subtracts a date from another date.
- * This could be for example a RFC2822 date, the time,
- * the year or only the timestamp. There are about 50 different supported date parts.
- * For a complete list of supported datepart values look into the docu
- * Be aware: Adding -2 Months is not equal to Subtracting 2 Months !!!
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to subtract
- * @param string $part OPTIONAL Part of the date to sub, if null the timestamp is subtracted
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function sub($date, $part = self::TIMESTAMP, $locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $part = Zend_Locale_Format::convertPhpToIsoFormat($part);
- }
-
- $this->_calculate('sub', $date, $part, $locale);
- return $this;
- }
-
- /**
- * Compares a date or datepart with the existing one.
- * Returns -1 if earlier, 0 if equal and 1 if later.
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to compare with the date object
- * @param string $part OPTIONAL Part of the date to compare, if null the timestamp is subtracted
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compare($date, $part = null, $locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $part = Zend_Locale_Format::convertPhpToIsoFormat($part);
- }
-
- $compare = $this->_calculate('cmp', $date, $part, $locale);
-
- if ($compare > 0) {
- return 1;
- } else if ($compare < 0) {
- return -1;
- }
- return 0;
- }
-
- /**
- * Returns a new instance of Zend_Date with the selected part copied.
- * To make an exact copy, use PHP's clone keyword.
- * For a complete list of supported date part values look into the docu.
- * If a date part is copied, all other date parts are set to standard values.
- * For example: If only YEAR is copied, the returned date object is equal to
- * 01-01-YEAR 00:00:00 (01-01-1970 00:00:00 is equal to timestamp 0)
- * If only HOUR is copied, the returned date object is equal to
- * 01-01-1970 HOUR:00:00 (so $this contains a timestamp equal to a timestamp of 0 plus HOUR).
- *
- * @param string $part Part of the date to compare, if null the timestamp is subtracted
- * @param string|Zend_Locale $locale OPTIONAL New object's locale. No adjustments to timezone are made.
- * @return Zend_Date New clone with requested part
- */
- public function copyPart($part, $locale = null)
- {
- $clone = clone $this; // copy all instance variables
- $clone->setUnixTimestamp(0); // except the timestamp
- if ($locale != null) {
- $clone->setLocale($locale); // set an other locale if selected
- }
- $clone->set($this, $part);
- return $clone;
- }
-
- /**
- * Internal function, returns the offset of a given timezone
- *
- * @param string $zone
- * @return integer
- */
- public function getTimezoneFromString($zone)
- {
- if (is_array($zone)) {
- return $this->getTimezone();
- }
-
- if ($zone instanceof Zend_Date) {
- return $zone->getTimezone();
- }
-
- $match = array();
- preg_match('/\dZ$/', $zone, $match);
- if (!empty($match)) {
- return "Etc/UTC";
- }
-
- preg_match('/([+-]\d{2}):{0,1}\d{2}/', $zone, $match);
- if (!empty($match) and ($match[count($match) - 1] <= 12) and ($match[count($match) - 1] >= -12)) {
- $zone = "Etc/GMT";
- $zone .= ($match[count($match) - 1] < 0) ? "+" : "-";
- $zone .= (int) abs($match[count($match) - 1]);
- return $zone;
- }
-
- preg_match('/([[:alpha:]\/]{3,30})(?!.*([[:alpha:]\/]{3,30}))/', $zone, $match);
- try {
- if (!empty($match) and (!is_int($match[count($match) - 1]))) {
- $oldzone = $this->getTimezone();
- $this->setTimezone($match[count($match) - 1]);
- $result = $this->getTimezone();
- $this->setTimezone($oldzone);
- if ($result !== $oldzone) {
- return $match[count($match) - 1];
- }
- }
- } catch (Exception $e) {
- // fall through
- }
-
- return $this->getTimezone();
- }
-
- /**
- * Calculates the date or object
- *
- * @param string $calc Calculation to make
- * @param string|integer $date Date for calculation
- * @param string|integer $comp Second date for calculation
- * @param boolean|integer $dst Use dst correction if option is set
- * @return integer|string|Zend_Date new timestamp or Zend_Date depending on calculation
- */
- private function _assign($calc, $date, $comp = 0, $dst = false)
- {
- switch ($calc) {
- case 'set' :
- if (!empty($comp)) {
- $this->setUnixTimestamp(call_user_func(Zend_Locale_Math::$sub, $this->getUnixTimestamp(), $comp));
- }
- $this->setUnixTimestamp(call_user_func(Zend_Locale_Math::$add, $this->getUnixTimestamp(), $date));
- $value = $this->getUnixTimestamp();
- break;
- case 'add' :
- $this->setUnixTimestamp(call_user_func(Zend_Locale_Math::$add, $this->getUnixTimestamp(), $date));
- $value = $this->getUnixTimestamp();
- break;
- case 'sub' :
- $this->setUnixTimestamp(call_user_func(Zend_Locale_Math::$sub, $this->getUnixTimestamp(), $date));
- $value = $this->getUnixTimestamp();
- break;
- default :
- // cmp - compare
- return call_user_func(Zend_Locale_Math::$comp, $comp, $date);
- break;
- }
-
- // dst-correction if 'fix_dst' = true and dst !== false but only for non UTC and non GMT
- if ((self::$_options['fix_dst'] === true) and ($dst !== false) and ($this->_dst === true)) {
- $hour = $this->toString(self::HOUR, 'iso');
- if ($hour != $dst) {
- if (($dst == ($hour + 1)) or ($dst == ($hour - 23))) {
- $value += 3600;
- } else if (($dst == ($hour - 1)) or ($dst == ($hour + 23))) {
- $value -= 3600;
- }
- $this->setUnixTimestamp($value);
- }
- }
- return $this->getUnixTimestamp();
- }
-
-
- /**
- * Calculates the date or object
- *
- * @param string $calc Calculation to make, one of: 'add'|'sub'|'cmp'|'copy'|'set'
- * @param string|integer|array|Zend_Date $date Date or datepart to calculate with
- * @param string $part Part of the date to calculate, if null the timestamp is used
- * @param string|Zend_Locale $locale Locale for parsing input
- * @return integer|string|Zend_Date new timestamp
- * @throws Zend_Date_Exception
- */
- private function _calculate($calc, $date, $part, $locale)
- {
- if ($date === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('parameter $date must be set, null is not allowed');
- }
-
- if (($part !== null) && (strlen($part) !== 2) && (Zend_Locale::isLocale($part, null, false))) {
- $locale = $part;
- $part = null;
- }
-
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- $locale = (string) $locale;
-
- // Create date parts
- $year = $this->toString(self::YEAR, 'iso');
- $month = $this->toString(self::MONTH_SHORT, 'iso');
- $day = $this->toString(self::DAY_SHORT, 'iso');
- $hour = $this->toString(self::HOUR_SHORT, 'iso');
- $minute = $this->toString(self::MINUTE_SHORT, 'iso');
- $second = $this->toString(self::SECOND_SHORT, 'iso');
- // If object extract value
- if ($date instanceof Zend_Date) {
- $date = $date->toString($part, 'iso', $locale);
- }
-
- if (is_array($date) === true) {
- if (empty($part) === false) {
- switch($part) {
- // Fall through
- case self::DAY:
- case self::DAY_SHORT:
- if (isset($date['day']) === true) {
- $date = $date['day'];
- }
- break;
- // Fall through
- case self::WEEKDAY_SHORT:
- case self::WEEKDAY:
- case self::WEEKDAY_8601:
- case self::WEEKDAY_DIGIT:
- case self::WEEKDAY_NARROW:
- case self::WEEKDAY_NAME:
- if (isset($date['weekday']) === true) {
- $date = $date['weekday'];
- $part = self::WEEKDAY_DIGIT;
- }
- break;
- case self::DAY_OF_YEAR:
- if (isset($date['day_of_year']) === true) {
- $date = $date['day_of_year'];
- }
- break;
- // Fall through
- case self::MONTH:
- case self::MONTH_SHORT:
- case self::MONTH_NAME:
- case self::MONTH_NAME_SHORT:
- case self::MONTH_NAME_NARROW:
- if (isset($date['month']) === true) {
- $date = $date['month'];
- }
- break;
- // Fall through
- case self::YEAR:
- case self::YEAR_SHORT:
- case self::YEAR_8601:
- case self::YEAR_SHORT_8601:
- if (isset($date['year']) === true) {
- $date = $date['year'];
- }
- break;
- // Fall through
- case self::HOUR:
- case self::HOUR_AM:
- case self::HOUR_SHORT:
- case self::HOUR_SHORT_AM:
- if (isset($date['hour']) === true) {
- $date = $date['hour'];
- }
- break;
- // Fall through
- case self::MINUTE:
- case self::MINUTE_SHORT:
- if (isset($date['minute']) === true) {
- $date = $date['minute'];
- }
- break;
- // Fall through
- case self::SECOND:
- case self::SECOND_SHORT:
- if (isset($date['second']) === true) {
- $date = $date['second'];
- }
- break;
- // Fall through
- case self::TIMEZONE:
- case self::TIMEZONE_NAME:
- if (isset($date['timezone']) === true) {
- $date = $date['timezone'];
- }
- break;
- case self::TIMESTAMP:
- if (isset($date['timestamp']) === true) {
- $date = $date['timestamp'];
- }
- break;
- case self::WEEK:
- if (isset($date['week']) === true) {
- $date = $date['week'];
- }
- break;
- case self::TIMEZONE_SECS:
- if (isset($date['gmtsecs']) === true) {
- $date = $date['gmtsecs'];
- }
- break;
- default:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("datepart for part ($part) not found in array");
- break;
- }
- } else {
- $hours = 0;
- if (isset($date['hour']) === true) {
- $hours = $date['hour'];
- }
- $minutes = 0;
- if (isset($date['minute']) === true) {
- $minutes = $date['minute'];
- }
- $seconds = 0;
- if (isset($date['second']) === true) {
- $seconds = $date['second'];
- }
- $months = 0;
- if (isset($date['month']) === true) {
- $months = $date['month'];
- }
- $days = 0;
- if (isset($date['day']) === true) {
- $days = $date['day'];
- }
- $years = 0;
- if (isset($date['year']) === true) {
- $years = $date['year'];
- }
- return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, $months, $days, $years, true),
- $this->mktime($hour, $minute, $second, $month, $day, $year, true), $hour);
- }
- }
-
- // $date as object, part of foreign date as own date
- switch($part) {
-
- // day formats
- case self::DAY:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + intval($day), 1970, true), $hour);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, day expected", 0, null, $date);
- break;
-
- case self::WEEKDAY_SHORT:
- $daylist = Zend_Locale_Data::getList($locale, 'day');
- $weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
- $cnt = 0;
-
- foreach ($daylist as $key => $value) {
- if (strtoupper(iconv_substr($value, 0, 3, 'UTF-8')) == strtoupper($date)) {
- $found = $cnt;
- break;
- }
- ++$cnt;
- }
-
- // Weekday found
- if ($cnt < 7) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
- }
-
- // Weekday not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", 0, null, $date);
- break;
-
- case self::DAY_SHORT:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + intval($day), 1970, true), $hour);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, day expected", 0, null, $date);
- break;
-
- case self::WEEKDAY:
- $daylist = Zend_Locale_Data::getList($locale, 'day');
- $weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
- $cnt = 0;
-
- foreach ($daylist as $key => $value) {
- if (strtoupper($value) == strtoupper($date)) {
- $found = $cnt;
- break;
- }
- ++$cnt;
- }
-
- // Weekday found
- if ($cnt < 7) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
- }
-
- // Weekday not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", 0, null, $date);
- break;
-
- case self::WEEKDAY_8601:
- $weekday = (int) $this->toString(self::WEEKDAY_8601, 'iso', $locale);
- if ((intval($date) > 0) and (intval($date) < 8)) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + intval($date), 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
- }
-
- // Weekday not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", 0, null, $date);
- break;
-
- case self::DAY_SUFFIX:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('day suffix not supported', 0, null, $date);
- break;
-
- case self::WEEKDAY_DIGIT:
- $weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
- if (is_numeric($date) and (intval($date) >= 0) and (intval($date) < 7)) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $date, 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
- }
-
- // Weekday not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", 0, null, $date);
- break;
-
- case self::DAY_OF_YEAR:
- if (is_numeric($date)) {
- if (($calc == 'add') || ($calc == 'sub')) {
- $year = 1970;
- ++$date;
- ++$day;
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, $date, $year, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), $hour);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, day expected", 0, null, $date);
- break;
-
- case self::WEEKDAY_NARROW:
- $daylist = Zend_Locale_Data::getList($locale, 'day', array('gregorian', 'format', 'abbreviated'));
- $weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
- $cnt = 0;
- foreach ($daylist as $key => $value) {
- if (strtoupper(iconv_substr($value, 0, 1, 'UTF-8')) == strtoupper($date)) {
- $found = $cnt;
- break;
- }
- ++$cnt;
- }
-
- // Weekday found
- if ($cnt < 7) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
- }
-
- // Weekday not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", 0, null, $date);
- break;
-
- case self::WEEKDAY_NAME:
- $daylist = Zend_Locale_Data::getList($locale, 'day', array('gregorian', 'format', 'abbreviated'));
- $weekday = (int) $this->toString(self::WEEKDAY_DIGIT, 'iso', $locale);
- $cnt = 0;
- foreach ($daylist as $key => $value) {
- if (strtoupper($value) == strtoupper($date)) {
- $found = $cnt;
- break;
- }
- ++$cnt;
- }
-
- // Weekday found
- if ($cnt < 7) {
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1, 1 + $found, 1970, true),
- $this->mktime(0, 0, 0, 1, 1 + $weekday, 1970, true), $hour);
- }
-
- // Weekday not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, weekday expected", 0, null, $date);
- break;
-
- // week formats
- case self::WEEK:
- if (is_numeric($date)) {
- $week = (int) $this->toString(self::WEEK, 'iso', $locale);
- return $this->_assign($calc, parent::mktime(0, 0, 0, 1, 1 + ($date * 7), 1970, true),
- parent::mktime(0, 0, 0, 1, 1 + ($week * 7), 1970, true), $hour);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, week expected", 0, null, $date);
- break;
-
- // month formats
- case self::MONTH_NAME:
- $monthlist = Zend_Locale_Data::getList($locale, 'month');
- $cnt = 0;
- foreach ($monthlist as $key => $value) {
- if (strtoupper($value) == strtoupper($date)) {
- $found = $key;
- break;
- }
- ++$cnt;
- }
- $date = array_search($date, $monthlist);
-
- // Monthname found
- if ($cnt < 12) {
- $fixday = 0;
- if ($calc == 'add') {
- $date += $found;
- $calc = 'set';
- if (self::$_options['extend_month'] == false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- } else if ($calc == 'sub') {
- $date = $month - $found;
- $calc = 'set';
- if (self::$_options['extend_month'] == false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, $date, $day + $fixday, $year, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), $hour);
- }
-
- // Monthname not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, month expected", 0, null, $date);
- break;
-
- case self::MONTH:
- if (is_numeric($date)) {
- $fixday = 0;
- if ($calc == 'add') {
- $date += $month;
- $calc = 'set';
- if (self::$_options['extend_month'] == false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- } else if ($calc == 'sub') {
- $date = $month - $date;
- $calc = 'set';
- if (self::$_options['extend_month'] == false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, $date, $day + $fixday, $year, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), $hour);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, month expected", 0, null, $date);
- break;
-
- case self::MONTH_NAME_SHORT:
- $monthlist = Zend_Locale_Data::getList($locale, 'month', array('gregorian', 'format', 'abbreviated'));
- $cnt = 0;
- foreach ($monthlist as $key => $value) {
- if (strtoupper($value) == strtoupper($date)) {
- $found = $key;
- break;
- }
- ++$cnt;
- }
- $date = array_search($date, $monthlist);
-
- // Monthname found
- if ($cnt < 12) {
- $fixday = 0;
- if ($calc == 'add') {
- $date += $found;
- $calc = 'set';
- if (self::$_options['extend_month'] === false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- } else if ($calc == 'sub') {
- $date = $month - $found;
- $calc = 'set';
- if (self::$_options['extend_month'] === false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, $date, $day + $fixday, $year, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), $hour);
- }
-
- // Monthname not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, month expected", 0, null, $date);
- break;
-
- case self::MONTH_SHORT:
- if (is_numeric($date) === true) {
- $fixday = 0;
- if ($calc === 'add') {
- $date += $month;
- $calc = 'set';
- if (self::$_options['extend_month'] === false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- } else if ($calc === 'sub') {
- $date = $month - $date;
- $calc = 'set';
- if (self::$_options['extend_month'] === false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, $date, $day + $fixday, $year, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), $hour);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, month expected", 0, null, $date);
- break;
-
- case self::MONTH_DAYS:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('month days not supported', 0, null, $date);
- break;
-
- case self::MONTH_NAME_NARROW:
- $monthlist = Zend_Locale_Data::getList($locale, 'month', array('gregorian', 'stand-alone', 'narrow'));
- $cnt = 0;
- foreach ($monthlist as $key => $value) {
- if (strtoupper($value) === strtoupper($date)) {
- $found = $key;
- break;
- }
- ++$cnt;
- }
- $date = array_search($date, $monthlist);
-
- // Monthname found
- if ($cnt < 12) {
- $fixday = 0;
- if ($calc === 'add') {
- $date += $found;
- $calc = 'set';
- if (self::$_options['extend_month'] === false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- } else if ($calc === 'sub') {
- $date = $month - $found;
- $calc = 'set';
- if (self::$_options['extend_month'] === false) {
- $parts = $this->getDateParts($this->mktime($hour, $minute, $second, $date, $day, $year, false));
- if ($parts['mday'] != $day) {
- $fixday = ($parts['mday'] < $day) ? -$parts['mday'] : ($parts['mday'] - $day);
- }
- }
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, $date, $day + $fixday, $year, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), $hour);
- }
-
- // Monthname not found
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, month expected", 0, null, $date);
- break;
-
- // year formats
- case self::LEAPYEAR:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('leap year not supported', 0, null, $date);
- break;
-
- case self::YEAR_8601:
- if (is_numeric($date)) {
- if ($calc === 'add') {
- $date += $year;
- $calc = 'set';
- } else if ($calc === 'sub') {
- $date = $year - $date;
- $calc = 'set';
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, intval($date), true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, year expected", 0, null, $date);
- break;
-
- case self::YEAR:
- if (is_numeric($date)) {
- if ($calc === 'add') {
- $date += $year;
- $calc = 'set';
- } else if ($calc === 'sub') {
- $date = $year - $date;
- $calc = 'set';
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, intval($date), true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, year expected", 0, null, $date);
- break;
-
- case self::YEAR_SHORT:
- if (is_numeric($date)) {
- $date = intval($date);
- if (($calc == 'set') || ($calc == 'cmp')) {
- $date = self::getFullYear($date);
- }
- if ($calc === 'add') {
- $date += $year;
- $calc = 'set';
- } else if ($calc === 'sub') {
- $date = $year - $date;
- $calc = 'set';
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, $date, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, year expected", 0, null, $date);
- break;
-
- case self::YEAR_SHORT_8601:
- if (is_numeric($date)) {
- $date = intval($date);
- if (($calc === 'set') || ($calc === 'cmp')) {
- $date = self::getFullYear($date);
- }
- if ($calc === 'add') {
- $date += $year;
- $calc = 'set';
- } else if ($calc === 'sub') {
- $date = $year - $date;
- $calc = 'set';
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, $month, $day, $date, true),
- $this->mktime(0, 0, 0, $month, $day, $year, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, year expected", 0, null, $date);
- break;
-
- // time formats
- case self::MERIDIEM:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('meridiem not supported', 0, null, $date);
- break;
-
- case self::SWATCH:
- if (is_numeric($date)) {
- $rest = intval($date);
- $hours = floor($rest * 24 / 1000);
- $rest = $rest - ($hours * 1000 / 24);
- $minutes = floor($rest * 1440 / 1000);
- $rest = $rest - ($minutes * 1000 / 1440);
- $seconds = floor($rest * 86400 / 1000);
- return $this->_assign($calc, $this->mktime($hours, $minutes, $seconds, 1, 1, 1970, true),
- $this->mktime($hour, $minute, $second, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, swatchstamp expected", 0, null, $date);
- break;
-
- case self::HOUR_SHORT_AM:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),
- $this->mktime($hour, 0, 0, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, hour expected", 0, null, $date);
- break;
-
- case self::HOUR_SHORT:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),
- $this->mktime($hour, 0, 0, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, hour expected", 0, null, $date);
- break;
-
- case self::HOUR_AM:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),
- $this->mktime($hour, 0, 0, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, hour expected", 0, null, $date);
- break;
-
- case self::HOUR:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(intval($date), 0, 0, 1, 1, 1970, true),
- $this->mktime($hour, 0, 0, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, hour expected", 0, null, $date);
- break;
-
- case self::MINUTE:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, intval($date), 0, 1, 1, 1970, true),
- $this->mktime(0, $minute, 0, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, minute expected", 0, null, $date);
- break;
-
- case self::SECOND:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, 0, intval($date), 1, 1, 1970, true),
- $this->mktime(0, 0, $second, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, second expected", 0, null, $date);
- break;
-
- case self::MILLISECOND:
- if (is_numeric($date)) {
- switch($calc) {
- case 'set' :
- return $this->setMillisecond($date);
- break;
- case 'add' :
- return $this->addMillisecond($date);
- break;
- case 'sub' :
- return $this->subMillisecond($date);
- break;
- }
-
- return $this->compareMillisecond($date);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, milliseconds expected", 0, null, $date);
- break;
-
- case self::MINUTE_SHORT:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, intval($date), 0, 1, 1, 1970, true),
- $this->mktime(0, $minute, 0, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, minute expected", 0, null, $date);
- break;
-
- case self::SECOND_SHORT:
- if (is_numeric($date)) {
- return $this->_assign($calc, $this->mktime(0, 0, intval($date), 1, 1, 1970, true),
- $this->mktime(0, 0, $second, 1, 1, 1970, true), false);
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, second expected", 0, null, $date);
- break;
-
- // timezone formats
- // break intentionally omitted
- case self::TIMEZONE_NAME:
- case self::TIMEZONE:
- case self::TIMEZONE_SECS:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('timezone not supported', 0, null, $date);
- break;
-
- case self::DAYLIGHT:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('daylight not supported', 0, null, $date);
- break;
-
- case self::GMT_DIFF:
- case self::GMT_DIFF_SEP:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('gmtdiff not supported', 0, null, $date);
- break;
-
- // date strings
- case self::ISO_8601:
- // (-)YYYY-MM-dd
- preg_match('/^(-{0,1}\d{4})-(\d{2})-(\d{2})/', $date, $datematch);
- // (-)YY-MM-dd
- if (empty($datematch)) {
- preg_match('/^(-{0,1}\d{2})-(\d{2})-(\d{2})/', $date, $datematch);
- }
- // (-)YYYYMMdd
- if (empty($datematch)) {
- preg_match('/^(-{0,1}\d{4})(\d{2})(\d{2})/', $date, $datematch);
- }
- // (-)YYMMdd
- if (empty($datematch)) {
- preg_match('/^(-{0,1}\d{2})(\d{2})(\d{2})/', $date, $datematch);
- }
- $tmpdate = $date;
- if (!empty($datematch)) {
- $dateMatchCharCount = iconv_strlen($datematch[0], 'UTF-8');
- $tmpdate = iconv_substr($date,
- $dateMatchCharCount,
- iconv_strlen($date, 'UTF-8') - $dateMatchCharCount,
- 'UTF-8');
- }
- // (T)hh:mm:ss
- preg_match('/[T,\s]{0,1}(\d{2}):(\d{2}):(\d{2})/', $tmpdate, $timematch);
- if (empty($timematch)) {
- preg_match('/[T,\s]{0,1}(\d{2})(\d{2})(\d{2})/', $tmpdate, $timematch);
- }
- if (empty($datematch) and empty($timematch)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("unsupported ISO8601 format ($date)", 0, null, $date);
- }
- if (!empty($timematch)) {
- $timeMatchCharCount = iconv_strlen($timematch[0], 'UTF-8');
- $tmpdate = iconv_substr($tmpdate,
- $timeMatchCharCount,
- iconv_strlen($tmpdate, 'UTF-8') - $timeMatchCharCount,
- 'UTF-8');
- }
- if (empty($datematch)) {
- $datematch[1] = 1970;
- $datematch[2] = 1;
- $datematch[3] = 1;
- } else if (iconv_strlen($datematch[1], 'UTF-8') == 2) {
- $datematch[1] = self::getFullYear($datematch[1]);
- }
- if (empty($timematch)) {
- $timematch[1] = 0;
- $timematch[2] = 0;
- $timematch[3] = 0;
- }
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$datematch[2];
- --$month;
- --$datematch[3];
- --$day;
- $datematch[1] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($timematch[1], $timematch[2], $timematch[3], 1 + $datematch[2], 1 + $datematch[3], 1970 + $datematch[1], false),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, false), false);
- break;
-
- case self::RFC_2822:
- $result = preg_match('/^\w{3},\s(\d{1,2})\s(\w{3})\s(\d{4})\s(\d{2}):(\d{2}):{0,1}(\d{0,2})\s([+-]{1}\d{4})$/', $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no RFC 2822 format ($date)", 0, null, $date);
- }
-
- $months = $this->_getDigitFromName($match[2]);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$months;
- --$month;
- --$match[1];
- --$day;
- $match[3] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], false),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, false), false);
- break;
-
- case self::TIMESTAMP:
- if (is_numeric($date)) {
- return $this->_assign($calc, $date, $this->getUnixTimestamp());
- }
-
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, timestamp expected", 0, null, $date);
- break;
-
- // additional formats
- // break intentionally omitted
- case self::ERA:
- case self::ERA_NAME:
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('era not supported', 0, null, $date);
- break;
-
- case self::DATES:
- try {
- $parsed = Zend_Locale_Format::getDate($date, array('locale' => $locale, 'format_type' => 'iso', 'fix_date' => true));
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
-
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATE_FULL:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'full'));
- $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATE_LONG:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'long'));
- $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- if (($calc == 'set') || ($calc == 'cmp')){
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATE_MEDIUM:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'medium'));
- $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATE_SHORT:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'short'));
- $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- $parsed['year'] = self::getFullYear($parsed['year']);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime(0, 0, 0, 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime(0, 0, 0, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::TIMES:
- try {
- if ($calc != 'set') {
- $month = 1;
- $day = 1;
- $year = 1970;
- }
- $parsed = Zend_Locale_Format::getTime($date, array('locale' => $locale, 'format_type' => 'iso', 'fix_date' => true));
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $month, $day, $year, true),
- $this->mktime($hour, $minute, $second, $month, $day, $year, true), false);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::TIME_FULL:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'time', array('gregorian', 'full'));
- $parsed = Zend_Locale_Format::getTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
- if ($calc != 'set') {
- $month = 1;
- $day = 1;
- $year = 1970;
- }
-
- if (!isset($parsed['second'])) {
- $parsed['second'] = 0;
- }
-
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $month, $day, $year, true),
- $this->mktime($hour, $minute, $second, $month, $day, $year, true), false);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::TIME_LONG:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'time', array('gregorian', 'long'));
- $parsed = Zend_Locale_Format::getTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
- if ($calc != 'set') {
- $month = 1;
- $day = 1;
- $year = 1970;
- }
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $month, $day, $year, true),
- $this->mktime($hour, $minute, $second, $month, $day, $year, true), false);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::TIME_MEDIUM:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'time', array('gregorian', 'medium'));
- $parsed = Zend_Locale_Format::getTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
- if ($calc != 'set') {
- $month = 1;
- $day = 1;
- $year = 1970;
- }
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $month, $day, $year, true),
- $this->mktime($hour, $minute, $second, $month, $day, $year, true), false);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::TIME_SHORT:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'time', array('gregorian', 'short'));
- $parsed = Zend_Locale_Format::getTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
- if ($calc != 'set') {
- $month = 1;
- $day = 1;
- $year = 1970;
- }
-
- if (!isset($parsed['second'])) {
- $parsed['second'] = 0;
- }
-
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $month, $day, $year, true),
- $this->mktime($hour, $minute, $second, $month, $day, $year, true), false);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATETIME:
- try {
- $parsed = Zend_Locale_Format::getDateTime($date, array('locale' => $locale, 'format_type' => 'iso', 'fix_date' => true));
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATETIME_FULL:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'full'));
- $parsed = Zend_Locale_Format::getDateTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
-
- if (!isset($parsed['second'])) {
- $parsed['second'] = 0;
- }
-
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATETIME_LONG:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'long'));
- $parsed = Zend_Locale_Format::getDateTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- if (($calc == 'set') || ($calc == 'cmp')){
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATETIME_MEDIUM:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'medium'));
- $parsed = Zend_Locale_Format::getDateTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- case self::DATETIME_SHORT:
- try {
- $format = Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'short'));
- $parsed = Zend_Locale_Format::getDateTime($date, array('date_format' => $format, 'format_type' => 'iso', 'locale' => $locale));
-
- $parsed['year'] = self::getFullYear($parsed['year']);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$parsed['month'];
- --$month;
- --$parsed['day'];
- --$day;
- $parsed['year'] -= 1970;
- $year -= 1970;
- }
-
- if (!isset($parsed['second'])) {
- $parsed['second'] = 0;
- }
-
- return $this->_assign($calc, $this->mktime($parsed['hour'], $parsed['minute'], $parsed['second'], 1 + $parsed['month'], 1 + $parsed['day'], 1970 + $parsed['year'], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), $hour);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- break;
-
- // ATOM and RFC_3339 are identical
- case self::ATOM:
- case self::RFC_3339:
- $result = preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\d{0,4}([+-]{1}\d{2}:\d{2}|Z)$/', $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, ATOM format expected", 0, null, $date);
- }
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$match[2];
- --$month;
- --$match[3];
- --$day;
- $match[1] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $match[2], 1 + $match[3], 1970 + $match[1], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
- break;
-
- case self::COOKIE:
- $result = preg_match("/^\w{6,9},\s(\d{2})-(\w{3})-(\d{2})\s(\d{2}):(\d{2}):(\d{2})\s.{3,20}$/", $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, COOKIE format expected", 0, null, $date);
- }
- $matchStartPos = iconv_strpos($match[0], ' ', 0, 'UTF-8') + 1;
- $match[0] = iconv_substr($match[0],
- $matchStartPos,
- iconv_strlen($match[0], 'UTF-8') - $matchStartPos,
- 'UTF-8');
-
- $months = $this->_getDigitFromName($match[2]);
- $match[3] = self::getFullYear($match[3]);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$months;
- --$month;
- --$match[1];
- --$day;
- $match[3] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
- break;
-
- case self::RFC_822:
- case self::RFC_1036:
- // new RFC 822 format, identical to RFC 1036 standard
- $result = preg_match('/^\w{0,3},{0,1}\s{0,1}(\d{1,2})\s(\w{3})\s(\d{2})\s(\d{2}):(\d{2}):{0,1}(\d{0,2})\s([+-]{1}\d{4}|\w{1,20})$/', $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, RFC 822 date format expected", 0, null, $date);
- }
-
- $months = $this->_getDigitFromName($match[2]);
- $match[3] = self::getFullYear($match[3]);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$months;
- --$month;
- --$match[1];
- --$day;
- $match[3] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], false),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, false), false);
- break;
-
- case self::RFC_850:
- $result = preg_match('/^\w{6,9},\s(\d{2})-(\w{3})-(\d{2})\s(\d{2}):(\d{2}):(\d{2})\s.{3,21}$/', $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, RFC 850 date format expected", 0, null, $date);
- }
-
- $months = $this->_getDigitFromName($match[2]);
- $match[3] = self::getFullYear($match[3]);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$months;
- --$month;
- --$match[1];
- --$day;
- $match[3] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
- break;
-
- case self::RFC_1123:
- $result = preg_match('/^\w{0,3},{0,1}\s{0,1}(\d{1,2})\s(\w{3})\s(\d{2,4})\s(\d{2}):(\d{2}):{0,1}(\d{0,2})\s([+-]{1}\d{4}|\w{1,20})$/', $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, RFC 1123 date format expected", 0, null, $date);
- }
-
- $months = $this->_getDigitFromName($match[2]);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$months;
- --$month;
- --$match[1];
- --$day;
- $match[3] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
- break;
-
- case self::RSS:
- $result = preg_match('/^\w{3},\s(\d{2})\s(\w{3})\s(\d{2,4})\s(\d{1,2}):(\d{2}):(\d{2})\s.{1,21}$/', $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, RSS date format expected", 0, null, $date);
- }
-
- $months = $this->_getDigitFromName($match[2]);
- $match[3] = self::getFullYear($match[3]);
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$months;
- --$month;
- --$match[1];
- --$day;
- $match[3] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $months, 1 + $match[1], 1970 + $match[3], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
- break;
-
- case self::W3C:
- $result = preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})[+-]{1}\d{2}:\d{2}$/', $date, $match);
- if (!$result) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid date ($date) operand, W3C date format expected", 0, null, $date);
- }
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- --$match[2];
- --$month;
- --$match[3];
- --$day;
- $match[1] -= 1970;
- $year -= 1970;
- }
- return $this->_assign($calc, $this->mktime($match[4], $match[5], $match[6], 1 + $match[2], 1 + $match[3], 1970 + $match[1], true),
- $this->mktime($hour, $minute, $second, 1 + $month, 1 + $day, 1970 + $year, true), false);
- break;
-
- default:
- if (!is_numeric($date) || !empty($part)) {
- try {
- if (empty($part)) {
- $part = Zend_Locale_Format::getDateFormat($locale) . " ";
- $part .= Zend_Locale_Format::getTimeFormat($locale);
- }
-
- $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $part, 'locale' => $locale, 'fix_date' => true, 'format_type' => 'iso'));
- if ((strpos(strtoupper($part), 'YY') !== false) and (strpos(strtoupper($part), 'YYYY') === false)) {
- $parsed['year'] = self::getFullYear($parsed['year']);
- }
-
- if (($calc == 'set') || ($calc == 'cmp')) {
- if (isset($parsed['month'])) {
- --$parsed['month'];
- } else {
- $parsed['month'] = 0;
- }
-
- if (isset($parsed['day'])) {
- --$parsed['day'];
- } else {
- $parsed['day'] = 0;
- }
-
- if (isset($parsed['year'])) {
- $parsed['year'] -= 1970;
- } else {
- $parsed['year'] = 0;
- }
- }
-
- return $this->_assign($calc, $this->mktime(
- isset($parsed['hour']) ? $parsed['hour'] : 0,
- isset($parsed['minute']) ? $parsed['minute'] : 0,
- isset($parsed['second']) ? $parsed['second'] : 0,
- isset($parsed['month']) ? (1 + $parsed['month']) : 1,
- isset($parsed['day']) ? (1 + $parsed['day']) : 1,
- isset($parsed['year']) ? (1970 + $parsed['year']) : 1970,
- false), $this->getUnixTimestamp(), false);
- } catch (Zend_Locale_Exception $e) {
- if (!is_numeric($date)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e, $date);
- }
- }
- }
-
- return $this->_assign($calc, $date, $this->getUnixTimestamp(), false);
- break;
- }
- }
-
- /**
- * Returns true when both date objects or date parts are equal.
- * For example:
- * 15.May.2000 <-> 15.June.2000 Equals only for Day or Year... all other will return false
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to equal with
- * @param string $part OPTIONAL Part of the date to compare, if null the timestamp is used
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return boolean
- * @throws Zend_Date_Exception
- */
- public function equals($date, $part = null, $locale = null)
- {
- $result = $this->compare($date, $part, $locale);
-
- if ($result == 0) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns if the given date or datepart is earlier
- * For example:
- * 15.May.2000 <-> 13.June.1999 will return true for day, year and date, but not for month
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to compare with
- * @param string $part OPTIONAL Part of the date to compare, if null the timestamp is used
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return boolean
- * @throws Zend_Date_Exception
- */
- public function isEarlier($date, $part = null, $locale = null)
- {
- $result = $this->compare($date, $part, $locale);
-
- if ($result == -1) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns if the given date or datepart is later
- * For example:
- * 15.May.2000 <-> 13.June.1999 will return true for month but false for day, year and date
- * Returns if the given date is later
- *
- * @param string|integer|array|Zend_Date $date Date or datepart to compare with
- * @param string $part OPTIONAL Part of the date to compare, if null the timestamp is used
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return boolean
- * @throws Zend_Date_Exception
- */
- public function isLater($date, $part = null, $locale = null)
- {
- $result = $this->compare($date, $part, $locale);
-
- if ($result == 1) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns only the time of the date as new Zend_Date object
- * For example:
- * 15.May.2000 10:11:23 will return a dateobject equal to 01.Jan.1970 10:11:23
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getTime($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'H:i:s';
- } else {
- $format = self::TIME_MEDIUM;
- }
-
- return $this->copyPart($format, $locale);
- }
-
- /**
- * Returns the calculated time
- *
- * @param string $calc Calculation to make
- * @param string|integer|array|Zend_Date $time Time to calculate with, if null the actual time is taken
- * @param string $format Timeformat for parsing input
- * @param string|Zend_Locale $locale Locale for parsing input
- * @return integer|Zend_Date new time
- * @throws Zend_Date_Exception
- */
- private function _time($calc, $time, $format, $locale)
- {
- if ($time === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('parameter $time must be set, null is not allowed');
- }
-
- if ($time instanceof Zend_Date) {
- // extract time from object
- $time = $time->toString('HH:mm:ss', 'iso');
- } else {
- if (is_array($time)) {
- if ((isset($time['hour']) === true) or (isset($time['minute']) === true) or
- (isset($time['second']) === true)) {
- $parsed = $time;
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no hour, minute or second given in array");
- }
- } else {
- if (self::$_options['format_type'] == 'php') {
- $format = Zend_Locale_Format::convertPhpToIsoFormat($format);
- }
- try {
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- $parsed = Zend_Locale_Format::getTime($time, array('date_format' => $format, 'locale' => $locale, 'format_type' => 'iso'));
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e);
- }
- }
-
- if (!array_key_exists('hour', $parsed)) {
- $parsed['hour'] = 0;
- }
-
- if (!array_key_exists('minute', $parsed)) {
- $parsed['minute'] = 0;
- }
-
- if (!array_key_exists('second', $parsed)) {
- $parsed['second'] = 0;
- }
-
- $time = str_pad($parsed['hour'], 2, '0', STR_PAD_LEFT) . ":";
- $time .= str_pad($parsed['minute'], 2, '0', STR_PAD_LEFT) . ":";
- $time .= str_pad($parsed['second'], 2, '0', STR_PAD_LEFT);
- }
-
- $return = $this->_calcdetail($calc, $time, self::TIMES, 'de');
- if ($calc != 'cmp') {
- return $this;
- }
-
- return $return;
- }
-
-
- /**
- * Sets a new time for the date object. Format defines how to parse the time string.
- * Also a complete date can be given, but only the time is used for setting.
- * For example: dd.MMMM.yyTHH:mm' and 'ss sec'-> 10.May.07T25:11 and 44 sec => 1h11min44sec + 1 day
- * Returned is the new date object and the existing date is left as it was before
- *
- * @param string|integer|array|Zend_Date $time Time to set
- * @param string $format OPTIONAL Timeformat for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setTime($time, $format = null, $locale = null)
- {
- return $this->_time('set', $time, $format, $locale);
- }
-
-
- /**
- * Adds a time to the existing date. Format defines how to parse the time string.
- * If only parts are given the other parts are set to 0.
- * If no format is given, the standardformat of this locale is used.
- * For example: HH:mm:ss -> 10 -> +10 hours
- *
- * @param string|integer|array|Zend_Date $time Time to add
- * @param string $format OPTIONAL Timeformat for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addTime($time, $format = null, $locale = null)
- {
- return $this->_time('add', $time, $format, $locale);
- }
-
-
- /**
- * Subtracts a time from the existing date. Format defines how to parse the time string.
- * If only parts are given the other parts are set to 0.
- * If no format is given, the standardformat of this locale is used.
- * For example: HH:mm:ss -> 10 -> -10 hours
- *
- * @param string|integer|array|Zend_Date $time Time to sub
- * @param string $format OPTIONAL Timeformat for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid inteface
- * @throws Zend_Date_Exception
- */
- public function subTime($time, $format = null, $locale = null)
- {
- return $this->_time('sub', $time, $format, $locale);
- }
-
-
- /**
- * Compares the time from the existing date. Format defines how to parse the time string.
- * If only parts are given the other parts are set to default.
- * If no format us given, the standardformat of this locale is used.
- * For example: HH:mm:ss -> 10 -> 10 hours
- *
- * @param string|integer|array|Zend_Date $time Time to compare
- * @param string $format OPTIONAL Timeformat for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareTime($time, $format = null, $locale = null)
- {
- return $this->_time('cmp', $time, $format, $locale);
- }
-
- /**
- * Returns a clone of $this, with the time part set to 00:00:00.
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getDate($locale = null)
- {
- $orig = self::$_options['format_type'];
- if (self::$_options['format_type'] == 'php') {
- self::$_options['format_type'] = 'iso';
- }
-
- $date = $this->copyPart(self::DATE_MEDIUM, $locale);
- $date->addTimestamp($this->getGmtOffset());
- self::$_options['format_type'] = $orig;
-
- return $date;
- }
-
- /**
- * Returns the calculated date
- *
- * @param string $calc Calculation to make
- * @param string|integer|array|Zend_Date $date Date to calculate with, if null the actual date is taken
- * @param string $format Date format for parsing
- * @param string|Zend_Locale $locale Locale for parsing input
- * @return integer|Zend_Date new date
- * @throws Zend_Date_Exception
- */
- private function _date($calc, $date, $format, $locale)
- {
- if ($date === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('parameter $date must be set, null is not allowed');
- }
-
- if ($date instanceof Zend_Date) {
- // extract date from object
- $date = $date->toString('d.M.y', 'iso');
- } else {
- if (is_array($date)) {
- if ((isset($date['year']) === true) or (isset($date['month']) === true) or
- (isset($date['day']) === true)) {
- $parsed = $date;
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no day,month or year given in array");
- }
- } else {
- if ((self::$_options['format_type'] == 'php') && !defined($format)) {
- $format = Zend_Locale_Format::convertPhpToIsoFormat($format);
- }
- try {
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- $parsed = Zend_Locale_Format::getDate($date, array('date_format' => $format, 'locale' => $locale, 'format_type' => 'iso'));
- if ((strpos(strtoupper($format), 'YY') !== false) and (strpos(strtoupper($format), 'YYYY') === false)) {
- $parsed['year'] = self::getFullYear($parsed['year']);
- }
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e);
- }
- }
-
- if (!array_key_exists('day', $parsed)) {
- $parsed['day'] = 1;
- }
-
- if (!array_key_exists('month', $parsed)) {
- $parsed['month'] = 1;
- }
-
- if (!array_key_exists('year', $parsed)) {
- $parsed['year'] = 0;
- }
-
- $date = $parsed['day'] . "." . $parsed['month'] . "." . $parsed['year'];
- }
-
- $return = $this->_calcdetail($calc, $date, self::DATE_MEDIUM, 'de');
- if ($calc != 'cmp') {
- return $this;
- }
- return $return;
- }
-
-
- /**
- * Sets a new date for the date object. Format defines how to parse the date string.
- * Also a complete date with time can be given, but only the date is used for setting.
- * For example: MMMM.yy HH:mm-> May.07 22:11 => 01.May.07 00:00
- * Returned is the new date object and the existing time is left as it was before
- *
- * @param string|integer|array|Zend_Date $date Date to set
- * @param string $format OPTIONAL Date format for parsing
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setDate($date, $format = null, $locale = null)
- {
- return $this->_date('set', $date, $format, $locale);
- }
-
-
- /**
- * Adds a date to the existing date object. Format defines how to parse the date string.
- * If only parts are given the other parts are set to 0.
- * If no format is given, the standardformat of this locale is used.
- * For example: MM.dd.YYYY -> 10 -> +10 months
- *
- * @param string|integer|array|Zend_Date $date Date to add
- * @param string $format OPTIONAL Date format for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addDate($date, $format = null, $locale = null)
- {
- return $this->_date('add', $date, $format, $locale);
- }
-
-
- /**
- * Subtracts a date from the existing date object. Format defines how to parse the date string.
- * If only parts are given the other parts are set to 0.
- * If no format is given, the standardformat of this locale is used.
- * For example: MM.dd.YYYY -> 10 -> -10 months
- * Be aware: Subtracting 2 months is not equal to Adding -2 months !!!
- *
- * @param string|integer|array|Zend_Date $date Date to sub
- * @param string $format OPTIONAL Date format for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function subDate($date, $format = null, $locale = null)
- {
- return $this->_date('sub', $date, $format, $locale);
- }
-
-
- /**
- * Compares the date from the existing date object, ignoring the time.
- * Format defines how to parse the date string.
- * If only parts are given the other parts are set to 0.
- * If no format is given, the standardformat of this locale is used.
- * For example: 10.01.2000 => 10.02.1999 -> false
- *
- * @param string|integer|array|Zend_Date $date Date to compare
- * @param string $format OPTIONAL Date format for parsing input
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareDate($date, $format = null, $locale = null)
- {
- return $this->_date('cmp', $date, $format, $locale);
- }
-
-
- /**
- * Returns the full ISO 8601 date from the date object.
- * Always the complete ISO 8601 specifiction is used. If an other ISO date is needed
- * (ISO 8601 defines several formats) use toString() instead.
- * This function does not return the ISO date as object. Use copy() instead.
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return string
- */
- public function getIso($locale = null)
- {
- return $this->toString(self::ISO_8601, 'iso', $locale);
- }
-
-
- /**
- * Sets a new date for the date object. Not given parts are set to default.
- * Only supported ISO 8601 formats are accepted.
- * For example: 050901 -> 01.Sept.2005 00:00:00, 20050201T10:00:30 -> 01.Feb.2005 10h00m30s
- * Returned is the new date object
- *
- * @param string|integer|Zend_Date $date ISO Date to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setIso($date, $locale = null)
- {
- return $this->_calcvalue('set', $date, 'iso', self::ISO_8601, $locale);
- }
-
-
- /**
- * Adds a ISO date to the date object. Not given parts are set to default.
- * Only supported ISO 8601 formats are accepted.
- * For example: 050901 -> + 01.Sept.2005 00:00:00, 10:00:00 -> +10h
- * Returned is the new date object
- *
- * @param string|integer|Zend_Date $date ISO Date to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addIso($date, $locale = null)
- {
- return $this->_calcvalue('add', $date, 'iso', self::ISO_8601, $locale);
- }
-
-
- /**
- * Subtracts a ISO date from the date object. Not given parts are set to default.
- * Only supported ISO 8601 formats are accepted.
- * For example: 050901 -> - 01.Sept.2005 00:00:00, 10:00:00 -> -10h
- * Returned is the new date object
- *
- * @param string|integer|Zend_Date $date ISO Date to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function subIso($date, $locale = null)
- {
- return $this->_calcvalue('sub', $date, 'iso', self::ISO_8601, $locale);
- }
-
-
- /**
- * Compares a ISO date with the date object. Not given parts are set to default.
- * Only supported ISO 8601 formats are accepted.
- * For example: 050901 -> - 01.Sept.2005 00:00:00, 10:00:00 -> -10h
- * Returns if equal, earlier or later
- *
- * @param string|integer|Zend_Date $date ISO Date to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareIso($date, $locale = null)
- {
- return $this->_calcvalue('cmp', $date, 'iso', self::ISO_8601, $locale);
- }
-
-
- /**
- * Returns a RFC 822 compilant datestring from the date object.
- * This function does not return the RFC date as object. Use copy() instead.
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return string
- */
- public function getArpa($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'D\, d M y H\:i\:s O';
- } else {
- $format = self::RFC_822;
- }
-
- return $this->toString($format, 'iso', $locale);
- }
-
-
- /**
- * Sets a RFC 822 date as new date for the date object.
- * Only RFC 822 compilant date strings are accepted.
- * For example: Sat, 14 Feb 09 00:31:30 +0100
- * Returned is the new date object
- *
- * @param string|integer|Zend_Date $date RFC 822 to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setArpa($date, $locale = null)
- {
- return $this->_calcvalue('set', $date, 'arpa', self::RFC_822, $locale);
- }
-
-
- /**
- * Adds a RFC 822 date to the date object.
- * ARPA messages are used in emails or HTTP Headers.
- * Only RFC 822 compilant date strings are accepted.
- * For example: Sat, 14 Feb 09 00:31:30 +0100
- * Returned is the new date object
- *
- * @param string|integer|Zend_Date $date RFC 822 Date to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addArpa($date, $locale = null)
- {
- return $this->_calcvalue('add', $date, 'arpa', self::RFC_822, $locale);
- }
-
-
- /**
- * Subtracts a RFC 822 date from the date object.
- * ARPA messages are used in emails or HTTP Headers.
- * Only RFC 822 compilant date strings are accepted.
- * For example: Sat, 14 Feb 09 00:31:30 +0100
- * Returned is the new date object
- *
- * @param string|integer|Zend_Date $date RFC 822 Date to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function subArpa($date, $locale = null)
- {
- return $this->_calcvalue('sub', $date, 'arpa', self::RFC_822, $locale);
- }
-
-
- /**
- * Compares a RFC 822 compilant date with the date object.
- * ARPA messages are used in emails or HTTP Headers.
- * Only RFC 822 compilant date strings are accepted.
- * For example: Sat, 14 Feb 09 00:31:30 +0100
- * Returns if equal, earlier or later
- *
- * @param string|integer|Zend_Date $date RFC 822 Date to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareArpa($date, $locale = null)
- {
- return $this->_calcvalue('cmp', $date, 'arpa', self::RFC_822, $locale);
- }
-
-
- /**
- * Check if location is supported
- *
- * @param $location array - locations array
- * @return $horizon float
- */
- private function _checkLocation($location)
- {
- if (!isset($location['longitude']) or !isset($location['latitude'])) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('Location must include \'longitude\' and \'latitude\'', 0, null, $location);
- }
- if (($location['longitude'] > 180) or ($location['longitude'] < -180)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('Longitude must be between -180 and 180', 0, null, $location);
- }
- if (($location['latitude'] > 90) or ($location['latitude'] < -90)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('Latitude must be between -90 and 90', 0, null, $location);
- }
-
- if (!isset($location['horizon'])){
- $location['horizon'] = 'effective';
- }
-
- switch ($location['horizon']) {
- case 'civil' :
- return -0.104528;
- break;
- case 'nautic' :
- return -0.207912;
- break;
- case 'astronomic' :
- return -0.309017;
- break;
- default :
- return -0.0145439;
- break;
- }
- }
-
-
- /**
- * Returns the time of sunrise for this date and a given location as new date object
- * For a list of cities and correct locations use the class Zend_Date_Cities
- *
- * @param $location array - location of sunrise
- * ['horizon'] -> civil, nautic, astronomical, effective (default)
- * ['longitude'] -> longitude of location
- * ['latitude'] -> latitude of location
- * @return Zend_Date
- * @throws Zend_Date_Exception
- */
- public function getSunrise($location)
- {
- $horizon = $this->_checkLocation($location);
- $result = clone $this;
- $result->set($this->calcSun($location, $horizon, true), self::TIMESTAMP);
- return $result;
- }
-
-
- /**
- * Returns the time of sunset for this date and a given location as new date object
- * For a list of cities and correct locations use the class Zend_Date_Cities
- *
- * @param $location array - location of sunset
- * ['horizon'] -> civil, nautic, astronomical, effective (default)
- * ['longitude'] -> longitude of location
- * ['latitude'] -> latitude of location
- * @return Zend_Date
- * @throws Zend_Date_Exception
- */
- public function getSunset($location)
- {
- $horizon = $this->_checkLocation($location);
- $result = clone $this;
- $result->set($this->calcSun($location, $horizon, false), self::TIMESTAMP);
- return $result;
- }
-
-
- /**
- * Returns an array with the sunset and sunrise dates for all horizon types
- * For a list of cities and correct locations use the class Zend_Date_Cities
- *
- * @param $location array - location of suninfo
- * ['horizon'] -> civil, nautic, astronomical, effective (default)
- * ['longitude'] -> longitude of location
- * ['latitude'] -> latitude of location
- * @return array - [sunset|sunrise][effective|civil|nautic|astronomic]
- * @throws Zend_Date_Exception
- */
- public function getSunInfo($location)
- {
- $suninfo = array();
- for ($i = 0; $i < 4; ++$i) {
- switch ($i) {
- case 0 :
- $location['horizon'] = 'effective';
- break;
- case 1 :
- $location['horizon'] = 'civil';
- break;
- case 2 :
- $location['horizon'] = 'nautic';
- break;
- case 3 :
- $location['horizon'] = 'astronomic';
- break;
- }
- $horizon = $this->_checkLocation($location);
- $result = clone $this;
- $result->set($this->calcSun($location, $horizon, true), self::TIMESTAMP);
- $suninfo['sunrise'][$location['horizon']] = $result;
- $result = clone $this;
- $result->set($this->calcSun($location, $horizon, false), self::TIMESTAMP);
- $suninfo['sunset'][$location['horizon']] = $result;
- }
- return $suninfo;
- }
-
-
- /**
- * Check a given year for leap year.
- *
- * @param integer|array|Zend_Date $year Year to check
- * @return boolean
- */
- public static function checkLeapYear($year)
- {
- if ($year instanceof Zend_Date) {
- $year = (int) $year->toString(self::YEAR, 'iso');
- }
-
- if (is_array($year)) {
- if (isset($year['year']) === true) {
- $year = $year['year'];
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no year given in array");
- }
- }
-
- if (!is_numeric($year)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("year ($year) has to be integer for checkLeapYear()", 0, null, $year);
- }
-
- return (bool) parent::isYearLeapYear($year);
- }
-
-
- /**
- * Returns true, if the year is a leap year.
- *
- * @return boolean
- */
- public function isLeapYear()
- {
- return self::checkLeapYear($this);
- }
-
-
- /**
- * Returns if the set date is todays date
- *
- * @return boolean
- */
- public function isToday()
- {
- $today = $this->date('Ymd', $this->_getTime());
- $day = $this->date('Ymd', $this->getUnixTimestamp());
- return ($today == $day);
- }
-
-
- /**
- * Returns if the set date is yesterdays date
- *
- * @return boolean
- */
- public function isYesterday()
- {
- list($year, $month, $day) = explode('-', $this->date('Y-m-d', $this->_getTime()));
- // adjusts for leap days and DST changes that are timezone specific
- $yesterday = $this->date('Ymd', $this->mktime(0, 0, 0, $month, $day -1, $year));
- $day = $this->date('Ymd', $this->getUnixTimestamp());
- return $day == $yesterday;
- }
-
-
- /**
- * Returns if the set date is tomorrows date
- *
- * @return boolean
- */
- public function isTomorrow()
- {
- list($year, $month, $day) = explode('-', $this->date('Y-m-d', $this->_getTime()));
- // adjusts for leap days and DST changes that are timezone specific
- $tomorrow = $this->date('Ymd', $this->mktime(0, 0, 0, $month, $day +1, $year));
- $day = $this->date('Ymd', $this->getUnixTimestamp());
- return $day == $tomorrow;
- }
-
- /**
- * Returns the actual date as new date object
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public static function now($locale = null)
- {
- return new Zend_Date(time(), self::TIMESTAMP, $locale);
- }
-
- /**
- * Calculate date details
- *
- * @param string $calc Calculation to make
- * @param string|integer|array|Zend_Date $date Date or Part to calculate
- * @param string $part Datepart for Calculation
- * @param string|Zend_Locale $locale Locale for parsing input
- * @return integer|string new date
- * @throws Zend_Date_Exception
- */
- private function _calcdetail($calc, $date, $type, $locale)
- {
- $old = false;
- if (self::$_options['format_type'] == 'php') {
- self::$_options['format_type'] = 'iso';
- $old = true;
- }
-
- switch($calc) {
- case 'set' :
- $return = $this->set($date, $type, $locale);
- break;
- case 'add' :
- $return = $this->add($date, $type, $locale);
- break;
- case 'sub' :
- $return = $this->sub($date, $type, $locale);
- break;
- default :
- $return = $this->compare($date, $type, $locale);
- break;
- }
-
- if ($old) {
- self::$_options['format_type'] = 'php';
- }
-
- return $return;
- }
-
- /**
- * Internal calculation, returns the requested date type
- *
- * @param string $calc Calculation to make
- * @param string|integer|Zend_Date $value Datevalue to calculate with, if null the actual value is taken
- * @param string|Zend_Locale $locale Locale for parsing input
- * @return integer|Zend_Date new date
- * @throws Zend_Date_Exception
- */
- private function _calcvalue($calc, $value, $type, $parameter, $locale)
- {
- if ($value === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("parameter $type must be set, null is not allowed");
- }
-
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- if ($value instanceof Zend_Date) {
- // extract value from object
- $value = $value->toString($parameter, 'iso', $locale);
- } else if (!is_array($value) && !is_numeric($value) && ($type != 'iso') && ($type != 'arpa')) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid $type ($value) operand", 0, null, $value);
- }
-
- $return = $this->_calcdetail($calc, $value, $parameter, $locale);
- if ($calc != 'cmp') {
- return $this;
- }
- return $return;
- }
-
-
- /**
- * Returns only the year from the date object as new object.
- * For example: 10.May.2000 10:30:00 -> 01.Jan.2000 00:00:00
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getYear($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'Y';
- } else {
- $format = self::YEAR;
- }
-
- return $this->copyPart($format, $locale);
- }
-
-
- /**
- * Sets a new year
- * If the year is between 0 and 69, 2000 will be set (2000-2069)
- * If the year if between 70 and 99, 1999 will be set (1970-1999)
- * 3 or 4 digit years are set as expected. If you need to set year 0-99
- * use set() instead.
- * Returned is the new date object
- *
- * @param string|integer|array|Zend_Date $date Year to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setYear($year, $locale = null)
- {
- return $this->_calcvalue('set', $year, 'year', self::YEAR, $locale);
- }
-
-
- /**
- * Adds the year to the existing date object
- * If the year is between 0 and 69, 2000 will be added (2000-2069)
- * If the year if between 70 and 99, 1999 will be added (1970-1999)
- * 3 or 4 digit years are added as expected. If you need to add years from 0-99
- * use add() instead.
- * Returned is the new date object
- *
- * @param string|integer|array|Zend_Date $date Year to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addYear($year, $locale = null)
- {
- return $this->_calcvalue('add', $year, 'year', self::YEAR, $locale);
- }
-
-
- /**
- * Subs the year from the existing date object
- * If the year is between 0 and 69, 2000 will be subtracted (2000-2069)
- * If the year if between 70 and 99, 1999 will be subtracted (1970-1999)
- * 3 or 4 digit years are subtracted as expected. If you need to subtract years from 0-99
- * use sub() instead.
- * Returned is the new date object
- *
- * @param string|integer|array|Zend_Date $date Year to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function subYear($year, $locale = null)
- {
- return $this->_calcvalue('sub', $year, 'year', self::YEAR, $locale);
- }
-
-
- /**
- * Compares the year with the existing date object, ignoring other date parts.
- * For example: 10.03.2000 -> 15.02.2000 -> true
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $year Year to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareYear($year, $locale = null)
- {
- return $this->_calcvalue('cmp', $year, 'year', self::YEAR, $locale);
- }
-
-
- /**
- * Returns only the month from the date object as new object.
- * For example: 10.May.2000 10:30:00 -> 01.May.1970 00:00:00
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getMonth($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'm';
- } else {
- $format = self::MONTH;
- }
-
- return $this->copyPart($format, $locale);
- }
-
-
- /**
- * Returns the calculated month
- *
- * @param string $calc Calculation to make
- * @param string|integer|array|Zend_Date $month Month to calculate with, if null the actual month is taken
- * @param string|Zend_Locale $locale Locale for parsing input
- * @return integer|Zend_Date new time
- * @throws Zend_Date_Exception
- */
- private function _month($calc, $month, $locale)
- {
- if ($month === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('parameter $month must be set, null is not allowed');
- }
-
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- if ($month instanceof Zend_Date) {
- // extract month from object
- $found = $month->toString(self::MONTH_SHORT, 'iso', $locale);
- } else {
- if (is_numeric($month)) {
- $found = $month;
- } else if (is_array($month)) {
- if (isset($month['month']) === true) {
- $month = $month['month'];
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no month given in array");
- }
- } else {
- $monthlist = Zend_Locale_Data::getList($locale, 'month');
- $monthlist2 = Zend_Locale_Data::getList($locale, 'month', array('gregorian', 'format', 'abbreviated'));
-
- $monthlist = array_merge($monthlist, $monthlist2);
- $found = 0;
- $cnt = 0;
- foreach ($monthlist as $key => $value) {
- if (strtoupper($value) == strtoupper($month)) {
- $found = ($key % 12) + 1;
- break;
- }
- ++$cnt;
- }
- if ($found == 0) {
- foreach ($monthlist2 as $key => $value) {
- if (strtoupper(iconv_substr($value, 0, 1, 'UTF-8')) == strtoupper($month)) {
- $found = $key + 1;
- break;
- }
- ++$cnt;
- }
- }
- if ($found == 0) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("unknown month name ($month)", 0, null, $month);
- }
- }
- }
- $return = $this->_calcdetail($calc, $found, self::MONTH_SHORT, $locale);
- if ($calc != 'cmp') {
- return $this;
- }
- return $return;
- }
-
-
- /**
- * Sets a new month
- * The month can be a number or a string. Setting months lower then 0 and greater then 12
- * will result in adding or subtracting the relevant year. (12 months equal one year)
- * If a localized monthname is given it will be parsed with the default locale or the optional
- * set locale.
- * Returned is the new date object
- *
- * @param string|integer|array|Zend_Date $month Month to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setMonth($month, $locale = null)
- {
- return $this->_month('set', $month, $locale);
- }
-
-
- /**
- * Adds months to the existing date object.
- * The month can be a number or a string. Adding months lower then 0 and greater then 12
- * will result in adding or subtracting the relevant year. (12 months equal one year)
- * If a localized monthname is given it will be parsed with the default locale or the optional
- * set locale.
- * Returned is the new date object
- *
- * @param string|integer|array|Zend_Date $month Month to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addMonth($month, $locale = null)
- {
- return $this->_month('add', $month, $locale);
- }
-
-
- /**
- * Subtracts months from the existing date object.
- * The month can be a number or a string. Subtracting months lower then 0 and greater then 12
- * will result in adding or subtracting the relevant year. (12 months equal one year)
- * If a localized monthname is given it will be parsed with the default locale or the optional
- * set locale.
- * Returned is the new date object
- *
- * @param string|integer|array|Zend_Date $month Month to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function subMonth($month, $locale = null)
- {
- return $this->_month('sub', $month, $locale);
- }
-
-
- /**
- * Compares the month with the existing date object, ignoring other date parts.
- * For example: 10.03.2000 -> 15.03.1950 -> true
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $month Month to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareMonth($month, $locale = null)
- {
- return $this->_month('cmp', $month, $locale);
- }
-
-
- /**
- * Returns the day as new date object
- * Example: 20.May.1986 -> 20.Jan.1970 00:00:00
- *
- * @param $locale string|Zend_Locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getDay($locale = null)
- {
- return $this->copyPart(self::DAY_SHORT, $locale);
- }
-
-
- /**
- * Returns the calculated day
- *
- * @param $calc string Type of calculation to make
- * @param $day string|integer|Zend_Date Day to calculate, when null the actual day is calculated
- * @param $locale string|Zend_Locale Locale for parsing input
- * @return Zend_Date|integer
- */
- private function _day($calc, $day, $locale)
- {
- if ($day === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('parameter $day must be set, null is not allowed');
- }
-
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- if ($day instanceof Zend_Date) {
- $day = $day->toString(self::DAY_SHORT, 'iso', $locale);
- }
-
- if (is_numeric($day)) {
- $type = self::DAY_SHORT;
- } else if (is_array($day)) {
- if (isset($day['day']) === true) {
- $day = $day['day'];
- $type = self::WEEKDAY;
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no day given in array");
- }
- } else {
- switch (iconv_strlen($day, 'UTF-8')) {
- case 1 :
- $type = self::WEEKDAY_NARROW;
- break;
- case 2:
- $type = self::WEEKDAY_NAME;
- break;
- case 3:
- $type = self::WEEKDAY_SHORT;
- break;
- default:
- $type = self::WEEKDAY;
- break;
- }
- }
- $return = $this->_calcdetail($calc, $day, $type, $locale);
- if ($calc != 'cmp') {
- return $this;
- }
- return $return;
- }
-
-
- /**
- * Sets a new day
- * The day can be a number or a string. Setting days lower then 0 or greater than the number of this months days
- * will result in adding or subtracting the relevant month.
- * If a localized dayname is given it will be parsed with the default locale or the optional
- * set locale.
- * Returned is the new date object
- * Example: setDay('Montag', 'de_AT'); will set the monday of this week as day.
- *
- * @param string|integer|array|Zend_Date $month Day to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setDay($day, $locale = null)
- {
- return $this->_day('set', $day, $locale);
- }
-
-
- /**
- * Adds days to the existing date object.
- * The day can be a number or a string. Adding days lower then 0 or greater than the number of this months days
- * will result in adding or subtracting the relevant month.
- * If a localized dayname is given it will be parsed with the default locale or the optional
- * set locale.
- *
- * @param string|integer|array|Zend_Date $month Day to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addDay($day, $locale = null)
- {
- return $this->_day('add', $day, $locale);
- }
-
-
- /**
- * Subtracts days from the existing date object.
- * The day can be a number or a string. Subtracting days lower then 0 or greater than the number of this months days
- * will result in adding or subtracting the relevant month.
- * If a localized dayname is given it will be parsed with the default locale or the optional
- * set locale.
- *
- * @param string|integer|array|Zend_Date $month Day to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function subDay($day, $locale = null)
- {
- return $this->_day('sub', $day, $locale);
- }
-
-
- /**
- * Compares the day with the existing date object, ignoring other date parts.
- * For example: 'Monday', 'en' -> 08.Jan.2007 -> 0
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $day Day to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareDay($day, $locale = null)
- {
- return $this->_day('cmp', $day, $locale);
- }
-
-
- /**
- * Returns the weekday as new date object
- * Weekday is always from 1-7
- * Example: 09-Jan-2007 -> 2 = Tuesday -> 02-Jan-1970 (when 02.01.1970 is also Tuesday)
- *
- * @param $locale string|Zend_Locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getWeekday($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'l';
- } else {
- $format = self::WEEKDAY;
- }
-
- return $this->copyPart($format, $locale);
- }
-
-
- /**
- * Returns the calculated weekday
- *
- * @param $calc string Type of calculation to make
- * @param $weekday string|integer|array|Zend_Date Weekday to calculate, when null the actual weekday is calculated
- * @param $locale string|Zend_Locale Locale for parsing input
- * @return Zend_Date|integer
- * @throws Zend_Date_Exception
- */
- private function _weekday($calc, $weekday, $locale)
- {
- if ($weekday === null) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('parameter $weekday must be set, null is not allowed');
- }
-
- if ($locale === null) {
- $locale = $this->getLocale();
- }
-
- if ($weekday instanceof Zend_Date) {
- $weekday = $weekday->toString(self::WEEKDAY_8601, 'iso', $locale);
- }
-
- if (is_numeric($weekday)) {
- $type = self::WEEKDAY_8601;
- } else if (is_array($weekday)) {
- if (isset($weekday['weekday']) === true) {
- $weekday = $weekday['weekday'];
- $type = self::WEEKDAY;
- } else {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("no weekday given in array");
- }
- } else {
- switch(iconv_strlen($weekday, 'UTF-8')) {
- case 1:
- $type = self::WEEKDAY_NARROW;
- break;
- case 2:
- $type = self::WEEKDAY_NAME;
- break;
- case 3:
- $type = self::WEEKDAY_SHORT;
- break;
- default:
- $type = self::WEEKDAY;
- break;
- }
- }
- $return = $this->_calcdetail($calc, $weekday, $type, $locale);
- if ($calc != 'cmp') {
- return $this;
- }
- return $return;
- }
-
-
- /**
- * Sets a new weekday
- * The weekday can be a number or a string. If a localized weekday name is given,
- * then it will be parsed as a date in $locale (defaults to the same locale as $this).
- * Returned is the new date object.
- * Example: setWeekday(3); will set the wednesday of this week as day.
- *
- * @param string|integer|array|Zend_Date $month Weekday to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setWeekday($weekday, $locale = null)
- {
- return $this->_weekday('set', $weekday, $locale);
- }
-
-
- /**
- * Adds weekdays to the existing date object.
- * The weekday can be a number or a string.
- * If a localized dayname is given it will be parsed with the default locale or the optional
- * set locale.
- * Returned is the new date object
- * Example: addWeekday(3); will add the difference of days from the begining of the month until
- * wednesday.
- *
- * @param string|integer|array|Zend_Date $month Weekday to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addWeekday($weekday, $locale = null)
- {
- return $this->_weekday('add', $weekday, $locale);
- }
-
-
- /**
- * Subtracts weekdays from the existing date object.
- * The weekday can be a number or a string.
- * If a localized dayname is given it will be parsed with the default locale or the optional
- * set locale.
- * Returned is the new date object
- * Example: subWeekday(3); will subtract the difference of days from the begining of the month until
- * wednesday.
- *
- * @param string|integer|array|Zend_Date $month Weekday to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function subWeekday($weekday, $locale = null)
- {
- return $this->_weekday('sub', $weekday, $locale);
- }
-
-
- /**
- * Compares the weekday with the existing date object, ignoring other date parts.
- * For example: 'Monday', 'en' -> 08.Jan.2007 -> 0
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $weekday Weekday to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareWeekday($weekday, $locale = null)
- {
- return $this->_weekday('cmp', $weekday, $locale);
- }
-
-
- /**
- * Returns the day of year as new date object
- * Example: 02.Feb.1986 10:00:00 -> 02.Feb.1970 00:00:00
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getDayOfYear($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'D';
- } else {
- $format = self::DAY_OF_YEAR;
- }
-
- return $this->copyPart($format, $locale);
- }
-
-
- /**
- * Sets a new day of year
- * The day of year is always a number.
- * Returned is the new date object
- * Example: 04.May.2004 -> setDayOfYear(10) -> 10.Jan.2004
- *
- * @param string|integer|array|Zend_Date $day Day of Year to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setDayOfYear($day, $locale = null)
- {
- return $this->_calcvalue('set', $day, 'day of year', self::DAY_OF_YEAR, $locale);
- }
-
-
- /**
- * Adds a day of year to the existing date object.
- * The day of year is always a number.
- * Returned is the new date object
- * Example: addDayOfYear(10); will add 10 days to the existing date object.
- *
- * @param string|integer|array|Zend_Date $day Day of Year to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addDayOfYear($day, $locale = null)
- {
- return $this->_calcvalue('add', $day, 'day of year', self::DAY_OF_YEAR, $locale);
- }
-
-
- /**
- * Subtracts a day of year from the existing date object.
- * The day of year is always a number.
- * Returned is the new date object
- * Example: subDayOfYear(10); will subtract 10 days from the existing date object.
- *
- * @param string|integer|array|Zend_Date $day Day of Year to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function subDayOfYear($day, $locale = null)
- {
- return $this->_calcvalue('sub', $day, 'day of year', self::DAY_OF_YEAR, $locale);
- }
-
-
- /**
- * Compares the day of year with the existing date object.
- * For example: compareDayOfYear(33) -> 02.Feb.2007 -> 0
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $day Day of Year to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareDayOfYear($day, $locale = null)
- {
- return $this->_calcvalue('cmp', $day, 'day of year', self::DAY_OF_YEAR, $locale);
- }
-
-
- /**
- * Returns the hour as new date object
- * Example: 02.Feb.1986 10:30:25 -> 01.Jan.1970 10:00:00
- *
- * @param $locale string|Zend_Locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getHour($locale = null)
- {
- return $this->copyPart(self::HOUR, $locale);
- }
-
-
- /**
- * Sets a new hour
- * The hour is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> setHour(7); -> 04.May.1993 07:07:25
- *
- * @param string|integer|array|Zend_Date $hour Hour to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setHour($hour, $locale = null)
- {
- return $this->_calcvalue('set', $hour, 'hour', self::HOUR_SHORT, $locale);
- }
-
-
- /**
- * Adds hours to the existing date object.
- * The hour is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> addHour(12); -> 05.May.1993 01:07:25
- *
- * @param string|integer|array|Zend_Date $hour Hour to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addHour($hour, $locale = null)
- {
- return $this->_calcvalue('add', $hour, 'hour', self::HOUR_SHORT, $locale);
- }
-
-
- /**
- * Subtracts hours from the existing date object.
- * The hour is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> subHour(6); -> 05.May.1993 07:07:25
- *
- * @param string|integer|array|Zend_Date $hour Hour to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function subHour($hour, $locale = null)
- {
- return $this->_calcvalue('sub', $hour, 'hour', self::HOUR_SHORT, $locale);
- }
-
-
- /**
- * Compares the hour with the existing date object.
- * For example: 10:30:25 -> compareHour(10) -> 0
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $hour Hour to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareHour($hour, $locale = null)
- {
- return $this->_calcvalue('cmp', $hour, 'hour', self::HOUR_SHORT, $locale);
- }
-
-
- /**
- * Returns the minute as new date object
- * Example: 02.Feb.1986 10:30:25 -> 01.Jan.1970 00:30:00
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getMinute($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'i';
- } else {
- $format = self::MINUTE;
- }
-
- return $this->copyPart($format, $locale);
- }
-
-
- /**
- * Sets a new minute
- * The minute is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> setMinute(29); -> 04.May.1993 13:29:25
- *
- * @param string|integer|array|Zend_Date $minute Minute to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setMinute($minute, $locale = null)
- {
- return $this->_calcvalue('set', $minute, 'minute', self::MINUTE_SHORT, $locale);
- }
-
-
- /**
- * Adds minutes to the existing date object.
- * The minute is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> addMinute(65); -> 04.May.1993 13:12:25
- *
- * @param string|integer|array|Zend_Date $minute Minute to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addMinute($minute, $locale = null)
- {
- return $this->_calcvalue('add', $minute, 'minute', self::MINUTE_SHORT, $locale);
- }
-
-
- /**
- * Subtracts minutes from the existing date object.
- * The minute is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> subMinute(9); -> 04.May.1993 12:58:25
- *
- * @param string|integer|array|Zend_Date $minute Minute to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function subMinute($minute, $locale = null)
- {
- return $this->_calcvalue('sub', $minute, 'minute', self::MINUTE_SHORT, $locale);
- }
-
-
- /**
- * Compares the minute with the existing date object.
- * For example: 10:30:25 -> compareMinute(30) -> 0
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $minute Hour to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareMinute($minute, $locale = null)
- {
- return $this->_calcvalue('cmp', $minute, 'minute', self::MINUTE_SHORT, $locale);
- }
-
-
- /**
- * Returns the second as new date object
- * Example: 02.Feb.1986 10:30:25 -> 01.Jan.1970 00:00:25
- *
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getSecond($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 's';
- } else {
- $format = self::SECOND;
- }
-
- return $this->copyPart($format, $locale);
- }
-
-
- /**
- * Sets new seconds to the existing date object.
- * The second is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> setSecond(100); -> 04.May.1993 13:08:40
- *
- * @param string|integer|array|Zend_Date $second Second to set
- * @param string|Zend_Locale $locale (Optional) Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setSecond($second, $locale = null)
- {
- return $this->_calcvalue('set', $second, 'second', self::SECOND_SHORT, $locale);
- }
-
-
- /**
- * Adds seconds to the existing date object.
- * The second is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> addSecond(65); -> 04.May.1993 13:08:30
- *
- * @param string|integer|array|Zend_Date $second Second to add
- * @param string|Zend_Locale $locale (Optional) Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addSecond($second, $locale = null)
- {
- return $this->_calcvalue('add', $second, 'second', self::SECOND_SHORT, $locale);
- }
-
-
- /**
- * Subtracts seconds from the existing date object.
- * The second is always a number.
- * Returned is the new date object
- * Example: 04.May.1993 13:07:25 -> subSecond(10); -> 04.May.1993 13:07:15
- *
- * @param string|integer|array|Zend_Date $second Second to sub
- * @param string|Zend_Locale $locale (Optional) Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function subSecond($second, $locale = null)
- {
- return $this->_calcvalue('sub', $second, 'second', self::SECOND_SHORT, $locale);
- }
-
-
- /**
- * Compares the second with the existing date object.
- * For example: 10:30:25 -> compareSecond(25) -> 0
- * Returns if equal, earlier or later
- *
- * @param string|integer|array|Zend_Date $second Second to compare
- * @param string|Zend_Locale $locale (Optional) Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- * @throws Zend_Date_Exception
- */
- public function compareSecond($second, $locale = null)
- {
- return $this->_calcvalue('cmp', $second, 'second', self::SECOND_SHORT, $locale);
- }
-
-
- /**
- * Returns the precision for fractional seconds
- *
- * @return integer
- */
- public function getFractionalPrecision()
- {
- return $this->_precision;
- }
-
-
- /**
- * Sets a new precision for fractional seconds
- *
- * @param integer $precision Precision for the fractional datepart 3 = milliseconds
- * @throws Zend_Date_Exception
- * @return Zend_Date Provides fluid interface
- */
- public function setFractionalPrecision($precision)
- {
- if (!intval($precision) or ($precision < 0) or ($precision > 9)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("precision ($precision) must be a positive integer less than 10", 0, null, $precision);
- }
-
- $this->_precision = (int) $precision;
- if ($this->_precision < strlen($this->_fractional)) {
- $this->_fractional = substr($this->_fractional, 0, $this->_precision);
- } else {
- $this->_fractional = str_pad($this->_fractional, $this->_precision, '0', STR_PAD_RIGHT);
- }
-
- return $this;
- }
-
-
- /**
- * Returns the milliseconds of the date object
- *
- * @return string
- */
- public function getMilliSecond()
- {
- return $this->_fractional;
- }
-
-
- /**
- * Sets new milliseconds for the date object
- * Example: setMilliSecond(550, 2) -> equals +5 Sec +50 MilliSec
- *
- * @param integer|Zend_Date $milli (Optional) Millisecond to set, when null the actual millisecond is set
- * @param integer $precision (Optional) Fraction precision of the given milliseconds
- * @return Zend_Date Provides fluid interface
- */
- public function setMilliSecond($milli = null, $precision = null)
- {
- if ($milli === null) {
- list($milli, $time) = explode(" ", microtime());
- $milli = intval($milli);
- $precision = 6;
- } else if (!is_numeric($milli)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid milli second ($milli) operand", 0, null, $milli);
- }
-
- if ($precision === null) {
- $precision = $this->_precision;
- }
-
- if (!is_int($precision) || $precision < 1 || $precision > 9) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("precision ($precision) must be a positive integer less than 10", 0, null, $precision);
- }
-
- $this->_fractional = 0;
- $this->addMilliSecond($milli, $precision);
- return $this;
- }
-
-
- /**
- * Adds milliseconds to the date object
- *
- * @param integer|Zend_Date $milli (Optional) Millisecond to add, when null the actual millisecond is added
- * @param integer $precision (Optional) Fractional precision for the given milliseconds
- * @return Zend_Date Provides fluid interface
- */
- public function addMilliSecond($milli = null, $precision = null)
- {
- if ($milli === null) {
- list($milli, $time) = explode(" ", microtime());
- $milli = intval($milli);
- } else if (!is_numeric($milli)) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid milli second ($milli) operand", 0, null, $milli);
- }
-
- if ($precision === null) {
- $precision = strlen($milli);
- if ($milli < 0) {
- --$precision;
- }
- }
-
- if (!is_int($precision) || $precision < 1 || $precision > 9) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("precision ($precision) must be a positive integer less than 10", 0, null, $precision);
- }
-
- $this->_fractional += $milli;
-
- // Add/sub milliseconds + add/sub seconds
- $max = pow(10, $this->_precision);
- // Milli includes seconds
- if ($this->_fractional >= $max) {
- while ($this->_fractional >= $max) {
- $this->addSecond(1);
- $this->_fractional -= $max;
- }
- }
-
- if ($this->_fractional < 0) {
- while ($this->_fractional < 0) {
- $this->subSecond(1);
- $this->_fractional += $max;
- }
- }
-
- if ($this->_precision > strlen($this->_fractional)) {
- $this->_fractional = str_pad($this->_fractional, $this->_precision, '0', STR_PAD_LEFT);
- }
-
- return $this;
- }
-
-
- /**
- * Subtracts a millisecond
- *
- * @param integer|Zend_Date $milli (Optional) Millisecond to sub, when null the actual millisecond is subtracted
- * @param integer $precision (Optional) Fractional precision for the given milliseconds
- * @return Zend_Date Provides fluid interface
- */
- public function subMilliSecond($milli = null, $precision = null)
- {
- $this->addMilliSecond(0 - $milli, $precision);
- return $this;
- }
-
- /**
- * Compares only the millisecond part, returning the difference
- *
- * @param integer|Zend_Date $milli OPTIONAL Millisecond to compare, when null the actual millisecond is compared
- * @param integer $precision OPTIONAL Fractional precision for the given milliseconds
- * @throws Zend_Date_Exception On invalid input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- */
- public function compareMilliSecond($milli = null, $precision = null)
- {
- if ($milli === null) {
- list($milli, $time) = explode(" ", microtime());
- $milli = intval($milli);
- } else if (is_numeric($milli) === false) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("invalid milli second ($milli) operand", 0, null, $milli);
- }
-
- if ($precision === null) {
- $precision = strlen($milli);
- } else if (!is_int($precision) || $precision < 1 || $precision > 9) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception("precision ($precision) must be a positive integer less than 10", 0, null, $precision);
- }
-
- if ($precision === 0) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception('precision is 0');
- }
-
- if ($precision != $this->_precision) {
- if ($precision > $this->_precision) {
- $diff = $precision - $this->_precision;
- $milli = (int) ($milli / (10 * $diff));
- } else {
- $diff = $this->_precision - $precision;
- $milli = (int) ($milli * (10 * $diff));
- }
- }
-
- $comp = $this->_fractional - $milli;
- if ($comp < 0) {
- return -1;
- } else if ($comp > 0) {
- return 1;
- }
- return 0;
- }
-
- /**
- * Returns the week as new date object using monday as begining of the week
- * Example: 12.Jan.2007 -> 08.Jan.1970 00:00:00
- *
- * @param $locale string|Zend_Locale OPTIONAL Locale for parsing input
- * @return Zend_Date
- */
- public function getWeek($locale = null)
- {
- if (self::$_options['format_type'] == 'php') {
- $format = 'W';
- } else {
- $format = self::WEEK;
- }
-
- return $this->copyPart($format, $locale);
- }
-
- /**
- * Sets a new week. The week is always a number. The day of week is not changed.
- * Returned is the new date object
- * Example: 09.Jan.2007 13:07:25 -> setWeek(1); -> 02.Jan.2007 13:07:25
- *
- * @param string|integer|array|Zend_Date $week Week to set
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function setWeek($week, $locale = null)
- {
- return $this->_calcvalue('set', $week, 'week', self::WEEK, $locale);
- }
-
- /**
- * Adds a week. The week is always a number. The day of week is not changed.
- * Returned is the new date object
- * Example: 09.Jan.2007 13:07:25 -> addWeek(1); -> 16.Jan.2007 13:07:25
- *
- * @param string|integer|array|Zend_Date $week Week to add
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function addWeek($week, $locale = null)
- {
- return $this->_calcvalue('add', $week, 'week', self::WEEK, $locale);
- }
-
- /**
- * Subtracts a week. The week is always a number. The day of week is not changed.
- * Returned is the new date object
- * Example: 09.Jan.2007 13:07:25 -> subWeek(1); -> 02.Jan.2007 13:07:25
- *
- * @param string|integer|array|Zend_Date $week Week to sub
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return Zend_Date Provides fluid interface
- * @throws Zend_Date_Exception
- */
- public function subWeek($week, $locale = null)
- {
- return $this->_calcvalue('sub', $week, 'week', self::WEEK, $locale);
- }
-
- /**
- * Compares only the week part, returning the difference
- * Returned is the new date object
- * Returns if equal, earlier or later
- * Example: 09.Jan.2007 13:07:25 -> compareWeek(2); -> 0
- *
- * @param string|integer|array|Zend_Date $week Week to compare
- * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
- * @return integer 0 = equal, 1 = later, -1 = earlier
- */
- public function compareWeek($week, $locale = null)
- {
- return $this->_calcvalue('cmp', $week, 'week', self::WEEK, $locale);
- }
-
- /**
- * Sets a new standard locale for the date object.
- * This locale will be used for all functions
- * Returned is the really set locale.
- * Example: 'de_XX' will be set to 'de' because 'de_XX' does not exist
- * 'xx_YY' will be set to 'root' because 'xx' does not exist
- *
- * @param string|Zend_Locale $locale (Optional) Locale for parsing input
- * @throws Zend_Date_Exception When the given locale does not exist
- * @return Zend_Date Provides fluent interface
- */
- public function setLocale($locale = null)
- {
- try {
- $this->_locale = Zend_Locale::findLocale($locale);
- } catch (Zend_Locale_Exception $e) {
- require_once 'Zend/Date/Exception.php';
- throw new Zend_Date_Exception($e->getMessage(), 0, $e);
- }
-
- return $this;
- }
-
- /**
- * Returns the actual set locale
- *
- * @return string
- */
- public function getLocale()
- {
- return $this->_locale;
- }
-
- /**
- * Checks if the given date is a real date or datepart.
- * Returns false if a expected datepart is missing or a datepart exceeds its possible border.
- * But the check will only be done for the expected dateparts which are given by format.
- * If no format is given the standard dateformat for the actual locale is used.
- * f.e. 30.February.2007 will return false if format is 'dd.MMMM.YYYY'
- *
- * @param string|array|Zend_Date $date Date to parse for correctness
- * @param string $format (Optional) Format for parsing the date string
- * @param string|Zend_Locale $locale (Optional) Locale for parsing date parts
- * @return boolean True when all date parts are correct
- */
- public static function isDate($date, $format = null, $locale = null)
- {
- if (!is_string($date) && !is_numeric($date) && !($date instanceof Zend_Date) &&
- !is_array($date)) {
- return false;
- }
-
- if (($format !== null) and (Zend_Locale::isLocale($format, null, false))) {
- $locale = $format;
- $format = null;
- }
-
- $locale = Zend_Locale::findLocale($locale);
-
- if ($format === null) {
- $format = Zend_Locale_Format::getDateFormat($locale);
- } else if ((self::$_options['format_type'] == 'php') && !defined($format)) {
- $format = Zend_Locale_Format::convertPhpToIsoFormat($format);
- }
-
- $format = self::_getLocalizedToken($format, $locale);
- if (!is_array($date)) {
- try {
- $parsed = Zend_Locale_Format::getDate($date, array('locale' => $locale,
- 'date_format' => $format, 'format_type' => 'iso',
- 'fix_date' => false));
- } catch (Zend_Locale_Exception $e) {
- // Date can not be parsed
- return false;
- }
- } else {
- $parsed = $date;
- }
-
- if (((strpos($format, 'Y') !== false) or (strpos($format, 'y') !== false)) and
- (!isset($parsed['year']))) {
- // Year expected but not found
- return false;
- }
-
- if ((strpos($format, 'M') !== false) and (!isset($parsed['month']))) {
- // Month expected but not found
- return false;
- }
-
- if ((strpos($format, 'd') !== false) and (!isset($parsed['day']))) {
- // Day expected but not found
- return false;
- }
-
- if (((strpos($format, 'H') !== false) or (strpos($format, 'h') !== false)) and
- (!isset($parsed['hour']))) {
- // Hour expected but not found
- return false;
- }
-
- if ((strpos($format, 'm') !== false) and (!isset($parsed['minute']))) {
- // Minute expected but not found
- return false;
- }
-
- if ((strpos($format, 's') !== false) and (!isset($parsed['second']))) {
- // Second expected but not found
- return false;
- }
-
- // Set not given dateparts
- if (isset($parsed['hour']) === false) {
- $parsed['hour'] = 12;
- }
-
- if (isset($parsed['minute']) === false) {
- $parsed['minute'] = 0;
- }
-
- if (isset($parsed['second']) === false) {
- $parsed['second'] = 0;
- }
-
- if (isset($parsed['month']) === false) {
- $parsed['month'] = 1;
- }
-
- if (isset($parsed['day']) === false) {
- $parsed['day'] = 1;
- }
-
- if (isset($parsed['year']) === false) {
- $parsed['year'] = 1970;
- }
-
- if (self::isYearLeapYear($parsed['year'])) {
- $parsed['year'] = 1972;
- } else {
- $parsed['year'] = 1971;
- }
-
- $date = new self($parsed, null, $locale);
- $timestamp = $date->mktime($parsed['hour'], $parsed['minute'], $parsed['second'],
- $parsed['month'], $parsed['day'], $parsed['year']);
-
- if ($parsed['year'] != $date->date('Y', $timestamp)) {
- // Given year differs from parsed year
- return false;
- }
-
- if ($parsed['month'] != $date->date('n', $timestamp)) {
- // Given month differs from parsed month
- return false;
- }
-
- if ($parsed['day'] != $date->date('j', $timestamp)) {
- // Given day differs from parsed day
- return false;
- }
-
- if ($parsed['hour'] != $date->date('G', $timestamp)) {
- // Given hour differs from parsed hour
- return false;
- }
-
- if ($parsed['minute'] != $date->date('i', $timestamp)) {
- // Given minute differs from parsed minute
- return false;
- }
-
- if ($parsed['second'] != $date->date('s', $timestamp)) {
- // Given second differs from parsed second
- return false;
- }
-
- return true;
- }
-
- /**
- * Returns the ISO Token for all localized constants
- *
- * @param string $token Token to normalize
- * @param string $locale Locale to search
- * @return string
- */
- protected static function _getLocalizedToken($token, $locale)
- {
- switch($token) {
- case self::ISO_8601 :
- return "yyyy-MM-ddThh:mm:ss";
- break;
- case self::RFC_2822 :
- return "EEE, dd MMM yyyy HH:mm:ss";
- break;
- case self::DATES :
- return Zend_Locale_Data::getContent($locale, 'date');
- break;
- case self::DATE_FULL :
- return Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'full'));
- break;
- case self::DATE_LONG :
- return Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'long'));
- break;
- case self::DATE_MEDIUM :
- return Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'medium'));
- break;
- case self::DATE_SHORT :
- return Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'short'));
- break;
- case self::TIMES :
- return Zend_Locale_Data::getContent($locale, 'date');
- break;
- case self::TIME_FULL :
- return Zend_Locale_Data::getContent($locale, 'time', array('gregorian', 'full'));
- break;
- case self::TIME_LONG :
- return Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'long'));
- break;
- case self::TIME_MEDIUM :
- return Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'medium'));
- break;
- case self::TIME_SHORT :
- return Zend_Locale_Data::getContent($locale, 'date', array('gregorian', 'short'));
- break;
- case self::DATETIME :
- return Zend_Locale_Data::getContent($locale, 'datetime');
- break;
- case self::DATETIME_FULL :
- return Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'full'));
- break;
- case self::DATETIME_LONG :
- return Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'long'));
- break;
- case self::DATETIME_MEDIUM :
- return Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'medium'));
- break;
- case self::DATETIME_SHORT :
- return Zend_Locale_Data::getContent($locale, 'datetime', array('gregorian', 'short'));
- break;
- case self::ATOM :
- case self::RFC_3339 :
- case self::W3C :
- return "yyyy-MM-DD HH:mm:ss";
- break;
- case self::COOKIE :
- case self::RFC_850 :
- return "EEEE, dd-MM-yyyy HH:mm:ss";
- break;
- case self::RFC_822 :
- case self::RFC_1036 :
- case self::RFC_1123 :
- case self::RSS :
- return "EEE, dd MM yyyy HH:mm:ss";
- break;
- }
-
- return $token;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Abstract.php zendframework-2.2.6/library/Zend/Db/Adapter/Abstract.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Abstract.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Abstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,1252 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE
- );
-
- /** Weither or not that object can get serialized
- *
- * @var bool
- */
- protected $_allowSerialization = true;
-
- /**
- * Weither or not the database should be reconnected
- * to that adapter when waking up
- *
- * @var bool
- */
- protected $_autoReconnectOnUnserialize = false;
-
- /**
- * Constructor.
- *
- * $config is an array of key/value pairs or an instance of Zend_Config
- * containing configuration options. These options are common to most adapters:
- *
- * dbname => (string) The name of the database to user
- * username => (string) Connect to the database as this username.
- * password => (string) Password associated with the username.
- * host => (string) What host to connect to, defaults to localhost
- *
- * Some options are used on a case-by-case basis by adapters:
- *
- * port => (string) The port of the database
- * persistent => (boolean) Whether to use a persistent connection or not, defaults to false
- * protocol => (string) The network protocol, defaults to TCPIP
- * caseFolding => (int) style of case-alteration used for identifiers
- *
- * @param array|Zend_Config $config An array or instance of Zend_Config having configuration data
- * @throws Zend_Db_Adapter_Exception
- */
- public function __construct($config)
- {
- /*
- * Verify that adapter parameters are in an array.
- */
- if (!is_array($config)) {
- /*
- * Convert Zend_Config argument to a plain array.
- */
- if ($config instanceof Zend_Config) {
- $config = $config->toArray();
- } else {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception('Adapter parameters must be in an array or a Zend_Config object');
- }
- }
-
- $this->_checkRequiredOptions($config);
-
- $options = array(
- Zend_Db::CASE_FOLDING => $this->_caseFolding,
- Zend_Db::AUTO_QUOTE_IDENTIFIERS => $this->_autoQuoteIdentifiers
- );
- $driverOptions = array();
-
- /*
- * normalize the config and merge it with the defaults
- */
- if (array_key_exists('options', $config)) {
- // can't use array_merge() because keys might be integers
- foreach ((array) $config['options'] as $key => $value) {
- $options[$key] = $value;
- }
- }
- if (array_key_exists('driver_options', $config)) {
- if (!empty($config['driver_options'])) {
- // can't use array_merge() because keys might be integers
- foreach ((array) $config['driver_options'] as $key => $value) {
- $driverOptions[$key] = $value;
- }
- }
- }
-
- if (!isset($config['charset'])) {
- $config['charset'] = null;
- }
-
- if (!isset($config['persistent'])) {
- $config['persistent'] = false;
- }
-
- $this->_config = array_merge($this->_config, $config);
- $this->_config['options'] = $options;
- $this->_config['driver_options'] = $driverOptions;
-
-
- // obtain the case setting, if there is one
- if (array_key_exists(Zend_Db::CASE_FOLDING, $options)) {
- $case = (int) $options[Zend_Db::CASE_FOLDING];
- switch ($case) {
- case Zend_Db::CASE_LOWER:
- case Zend_Db::CASE_UPPER:
- case Zend_Db::CASE_NATURAL:
- $this->_caseFolding = $case;
- break;
- default:
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception('Case must be one of the following constants: '
- . 'Zend_Db::CASE_NATURAL, Zend_Db::CASE_LOWER, Zend_Db::CASE_UPPER');
- }
- }
-
- // obtain quoting property if there is one
- if (array_key_exists(Zend_Db::AUTO_QUOTE_IDENTIFIERS, $options)) {
- $this->_autoQuoteIdentifiers = (bool) $options[Zend_Db::AUTO_QUOTE_IDENTIFIERS];
- }
-
- // obtain allow serialization property if there is one
- if (array_key_exists(Zend_Db::ALLOW_SERIALIZATION, $options)) {
- $this->_allowSerialization = (bool) $options[Zend_Db::ALLOW_SERIALIZATION];
- }
-
- // obtain auto reconnect on unserialize property if there is one
- if (array_key_exists(Zend_Db::AUTO_RECONNECT_ON_UNSERIALIZE, $options)) {
- $this->_autoReconnectOnUnserialize = (bool) $options[Zend_Db::AUTO_RECONNECT_ON_UNSERIALIZE];
- }
-
- // create a profiler object
- $profiler = false;
- if (array_key_exists(Zend_Db::PROFILER, $this->_config)) {
- $profiler = $this->_config[Zend_Db::PROFILER];
- unset($this->_config[Zend_Db::PROFILER]);
- }
- $this->setProfiler($profiler);
- }
-
- /**
- * Check for config options that are mandatory.
- * Throw exceptions if any are missing.
- *
- * @param array $config
- * @throws Zend_Db_Adapter_Exception
- */
- protected function _checkRequiredOptions(array $config)
- {
- // we need at least a dbname
- if (! array_key_exists('dbname', $config)) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance");
- }
-
- if (! array_key_exists('password', $config)) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'password' for login credentials");
- }
-
- if (! array_key_exists('username', $config)) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'username' for login credentials");
- }
- }
-
- /**
- * Returns the underlying database connection object or resource.
- * If not presently connected, this initiates the connection.
- *
- * @return object|resource|null
- */
- public function getConnection()
- {
- $this->_connect();
- return $this->_connection;
- }
-
- /**
- * Returns the configuration variables in this adapter.
- *
- * @return array
- */
- public function getConfig()
- {
- return $this->_config;
- }
-
- /**
- * Set the adapter's profiler object.
- *
- * The argument may be a boolean, an associative array, an instance of
- * Zend_Db_Profiler, or an instance of Zend_Config.
- *
- * A boolean argument sets the profiler to enabled if true, or disabled if
- * false. The profiler class is the adapter's default profiler class,
- * Zend_Db_Profiler.
- *
- * An instance of Zend_Db_Profiler sets the adapter's instance to that
- * object. The profiler is enabled and disabled separately.
- *
- * An associative array argument may contain any of the keys 'enabled',
- * 'class', and 'instance'. The 'enabled' and 'instance' keys correspond to the
- * boolean and object types documented above. The 'class' key is used to name a
- * class to use for a custom profiler. The class must be Zend_Db_Profiler or a
- * subclass. The class is instantiated with no constructor arguments. The 'class'
- * option is ignored when the 'instance' option is supplied.
- *
- * An object of type Zend_Config may contain the properties 'enabled', 'class', and
- * 'instance', just as if an associative array had been passed instead.
- *
- * @param Zend_Db_Profiler|Zend_Config|array|boolean $profiler
- * @return Zend_Db_Adapter_Abstract Provides a fluent interface
- * @throws Zend_Db_Profiler_Exception if the object instance or class specified
- * is not Zend_Db_Profiler or an extension of that class.
- */
- public function setProfiler($profiler)
- {
- $enabled = null;
- $profilerClass = $this->_defaultProfilerClass;
- $profilerInstance = null;
-
- if ($profilerIsObject = is_object($profiler)) {
- if ($profiler instanceof Zend_Db_Profiler) {
- $profilerInstance = $profiler;
- } else if ($profiler instanceof Zend_Config) {
- $profiler = $profiler->toArray();
- } else {
- /**
- * @see Zend_Db_Profiler_Exception
- */
- require_once 'Zend/Db/Profiler/Exception.php';
- throw new Zend_Db_Profiler_Exception('Profiler argument must be an instance of either Zend_Db_Profiler'
- . ' or Zend_Config when provided as an object');
- }
- }
-
- if (is_array($profiler)) {
- if (isset($profiler['enabled'])) {
- $enabled = (bool) $profiler['enabled'];
- }
- if (isset($profiler['class'])) {
- $profilerClass = $profiler['class'];
- }
- if (isset($profiler['instance'])) {
- $profilerInstance = $profiler['instance'];
- }
- } else if (!$profilerIsObject) {
- $enabled = (bool) $profiler;
- }
-
- if ($profilerInstance === null) {
- if (!class_exists($profilerClass)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($profilerClass);
- }
- $profilerInstance = new $profilerClass();
- }
-
- if (!$profilerInstance instanceof Zend_Db_Profiler) {
- /** @see Zend_Db_Profiler_Exception */
- require_once 'Zend/Db/Profiler/Exception.php';
- throw new Zend_Db_Profiler_Exception('Class ' . get_class($profilerInstance) . ' does not extend '
- . 'Zend_Db_Profiler');
- }
-
- if (null !== $enabled) {
- $profilerInstance->setEnabled($enabled);
- }
-
- $this->_profiler = $profilerInstance;
-
- return $this;
- }
-
-
- /**
- * Returns the profiler for this adapter.
- *
- * @return Zend_Db_Profiler
- */
- public function getProfiler()
- {
- return $this->_profiler;
- }
-
- /**
- * Get the default statement class.
- *
- * @return string
- */
- public function getStatementClass()
- {
- return $this->_defaultStmtClass;
- }
-
- /**
- * Set the default statement class.
- *
- * @return Zend_Db_Adapter_Abstract Fluent interface
- */
- public function setStatementClass($class)
- {
- $this->_defaultStmtClass = $class;
- return $this;
- }
-
- /**
- * Prepares and executes an SQL statement with bound data.
- *
- * @param mixed $sql The SQL statement with placeholders.
- * May be a string or Zend_Db_Select.
- * @param mixed $bind An array of data to bind to the placeholders.
- * @return Zend_Db_Statement_Interface
- */
- public function query($sql, $bind = array())
- {
- // connect to the database if needed
- $this->_connect();
-
- // is the $sql a Zend_Db_Select object?
- if ($sql instanceof Zend_Db_Select) {
- if (empty($bind)) {
- $bind = $sql->getBind();
- }
-
- $sql = $sql->assemble();
- }
-
- // make sure $bind to an array;
- // don't use (array) typecasting because
- // because $bind may be a Zend_Db_Expr object
- if (!is_array($bind)) {
- $bind = array($bind);
- }
-
- // prepare and execute the statement with profiling
- $stmt = $this->prepare($sql);
- $stmt->execute($bind);
-
- // return the results embedded in the prepared statement object
- $stmt->setFetchMode($this->_fetchMode);
- return $stmt;
- }
-
- /**
- * Leave autocommit mode and begin a transaction.
- *
- * @return Zend_Db_Adapter_Abstract
- */
- public function beginTransaction()
- {
- $this->_connect();
- $q = $this->_profiler->queryStart('begin', Zend_Db_Profiler::TRANSACTION);
- $this->_beginTransaction();
- $this->_profiler->queryEnd($q);
- return $this;
- }
-
- /**
- * Commit a transaction and return to autocommit mode.
- *
- * @return Zend_Db_Adapter_Abstract
- */
- public function commit()
- {
- $this->_connect();
- $q = $this->_profiler->queryStart('commit', Zend_Db_Profiler::TRANSACTION);
- $this->_commit();
- $this->_profiler->queryEnd($q);
- return $this;
- }
-
- /**
- * Roll back a transaction and return to autocommit mode.
- *
- * @return Zend_Db_Adapter_Abstract
- */
- public function rollBack()
- {
- $this->_connect();
- $q = $this->_profiler->queryStart('rollback', Zend_Db_Profiler::TRANSACTION);
- $this->_rollBack();
- $this->_profiler->queryEnd($q);
- return $this;
- }
-
- /**
- * Inserts a table row with specified data.
- *
- * @param mixed $table The table to insert data into.
- * @param array $bind Column-value pairs.
- * @return int The number of affected rows.
- */
- public function insert($table, array $bind)
- {
- // extract and quote col names from the array keys
- $cols = array();
- $vals = array();
- foreach ($bind as $col => $val) {
- $cols[] = $this->quoteIdentifier($col, true);
- if ($val instanceof Zend_Db_Expr) {
- $vals[] = $val->__toString();
- unset($bind[$col]);
- } else {
- $vals[] = '?';
- }
- }
-
- // build the statement
- $sql = "INSERT INTO "
- . $this->quoteIdentifier($table, true)
- . ' (' . implode(', ', $cols) . ') '
- . 'VALUES (' . implode(', ', $vals) . ')';
-
- // execute the statement and return the number of affected rows
- $stmt = $this->query($sql, array_values($bind));
- $result = $stmt->rowCount();
- return $result;
- }
-
- /**
- * Updates table rows with specified data based on a WHERE clause.
- *
- * @param mixed $table The table to update.
- * @param array $bind Column-value pairs.
- * @param mixed $where UPDATE WHERE clause(s).
- * @return int The number of affected rows.
- */
- public function update($table, array $bind, $where = '')
- {
- /**
- * Build "col = ?" pairs for the statement,
- * except for Zend_Db_Expr which is treated literally.
- */
- $set = array();
- $i = 0;
- foreach ($bind as $col => $val) {
- if ($val instanceof Zend_Db_Expr) {
- $val = $val->__toString();
- unset($bind[$col]);
- } else {
- if ($this->supportsParameters('positional')) {
- $val = '?';
- } else {
- if ($this->supportsParameters('named')) {
- unset($bind[$col]);
- $bind[':'.$col.$i] = $val;
- $val = ':'.$col.$i;
- $i++;
- } else {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception(get_class($this) ." doesn't support positional or named binding");
- }
- }
- }
- $set[] = $this->quoteIdentifier($col, true) . ' = ' . $val;
- }
-
- $where = $this->_whereExpr($where);
-
- /**
- * Build the UPDATE statement
- */
- $sql = "UPDATE "
- . $this->quoteIdentifier($table, true)
- . ' SET ' . implode(', ', $set)
- . (($where) ? " WHERE $where" : '');
-
- /**
- * Execute the statement and return the number of affected rows
- */
- if ($this->supportsParameters('positional')) {
- $stmt = $this->query($sql, array_values($bind));
- } else {
- $stmt = $this->query($sql, $bind);
- }
- $result = $stmt->rowCount();
- return $result;
- }
-
- /**
- * Deletes table rows based on a WHERE clause.
- *
- * @param mixed $table The table to update.
- * @param mixed $where DELETE WHERE clause(s).
- * @return int The number of affected rows.
- */
- public function delete($table, $where = '')
- {
- $where = $this->_whereExpr($where);
-
- /**
- * Build the DELETE statement
- */
- $sql = "DELETE FROM "
- . $this->quoteIdentifier($table, true)
- . (($where) ? " WHERE $where" : '');
-
- /**
- * Execute the statement and return the number of affected rows
- */
- $stmt = $this->query($sql);
- $result = $stmt->rowCount();
- return $result;
- }
-
- /**
- * Convert an array, string, or Zend_Db_Expr object
- * into a string to put in a WHERE clause.
- *
- * @param mixed $where
- * @return string
- */
- protected function _whereExpr($where)
- {
- if (empty($where)) {
- return $where;
- }
- if (!is_array($where)) {
- $where = array($where);
- }
- foreach ($where as $cond => &$term) {
- // is $cond an int? (i.e. Not a condition)
- if (is_int($cond)) {
- // $term is the full condition
- if ($term instanceof Zend_Db_Expr) {
- $term = $term->__toString();
- }
- } else {
- // $cond is the condition with placeholder,
- // and $term is quoted into the condition
- $term = $this->quoteInto($cond, $term);
- }
- $term = '(' . $term . ')';
- }
-
- $where = implode(' AND ', $where);
- return $where;
- }
-
- /**
- * Creates and returns a new Zend_Db_Select object for this adapter.
- *
- * @return Zend_Db_Select
- */
- public function select()
- {
- return new Zend_Db_Select($this);
- }
-
- /**
- * Get the fetch mode.
- *
- * @return int
- */
- public function getFetchMode()
- {
- return $this->_fetchMode;
- }
-
- /**
- * Fetches all SQL result rows as a sequential array.
- * Uses the current fetchMode for the adapter.
- *
- * @param string|Zend_Db_Select $sql An SQL SELECT statement.
- * @param mixed $bind Data to bind into SELECT placeholders.
- * @param mixed $fetchMode Override current fetch mode.
- * @return array
- */
- public function fetchAll($sql, $bind = array(), $fetchMode = null)
- {
- if ($fetchMode === null) {
- $fetchMode = $this->_fetchMode;
- }
- $stmt = $this->query($sql, $bind);
- $result = $stmt->fetchAll($fetchMode);
- return $result;
- }
-
- /**
- * Fetches the first row of the SQL result.
- * Uses the current fetchMode for the adapter.
- *
- * @param string|Zend_Db_Select $sql An SQL SELECT statement.
- * @param mixed $bind Data to bind into SELECT placeholders.
- * @param mixed $fetchMode Override current fetch mode.
- * @return array
- */
- public function fetchRow($sql, $bind = array(), $fetchMode = null)
- {
- if ($fetchMode === null) {
- $fetchMode = $this->_fetchMode;
- }
- $stmt = $this->query($sql, $bind);
- $result = $stmt->fetch($fetchMode);
- return $result;
- }
-
- /**
- * Fetches all SQL result rows as an associative array.
- *
- * The first column is the key, the entire row array is the
- * value. You should construct the query to be sure that
- * the first column contains unique values, or else
- * rows with duplicate values in the first column will
- * overwrite previous data.
- *
- * @param string|Zend_Db_Select $sql An SQL SELECT statement.
- * @param mixed $bind Data to bind into SELECT placeholders.
- * @return array
- */
- public function fetchAssoc($sql, $bind = array())
- {
- $stmt = $this->query($sql, $bind);
- $data = array();
- while ($row = $stmt->fetch(Zend_Db::FETCH_ASSOC)) {
- $tmp = array_values(array_slice($row, 0, 1));
- $data[$tmp[0]] = $row;
- }
- return $data;
- }
-
- /**
- * Fetches the first column of all SQL result rows as an array.
- *
- * The first column in each row is used as the array key.
- *
- * @param string|Zend_Db_Select $sql An SQL SELECT statement.
- * @param mixed $bind Data to bind into SELECT placeholders.
- * @return array
- */
- public function fetchCol($sql, $bind = array())
- {
- $stmt = $this->query($sql, $bind);
- $result = $stmt->fetchAll(Zend_Db::FETCH_COLUMN, 0);
- return $result;
- }
-
- /**
- * Fetches all SQL result rows as an array of key-value pairs.
- *
- * The first column is the key, the second column is the
- * value.
- *
- * @param string|Zend_Db_Select $sql An SQL SELECT statement.
- * @param mixed $bind Data to bind into SELECT placeholders.
- * @return array
- */
- public function fetchPairs($sql, $bind = array())
- {
- $stmt = $this->query($sql, $bind);
- $data = array();
- while ($row = $stmt->fetch(Zend_Db::FETCH_NUM)) {
- $data[$row[0]] = $row[1];
- }
- return $data;
- }
-
- /**
- * Fetches the first column of the first row of the SQL result.
- *
- * @param string|Zend_Db_Select $sql An SQL SELECT statement.
- * @param mixed $bind Data to bind into SELECT placeholders.
- * @return string
- */
- public function fetchOne($sql, $bind = array())
- {
- $stmt = $this->query($sql, $bind);
- $result = $stmt->fetchColumn(0);
- return $result;
- }
-
- /**
- * Quote a raw string.
- *
- * @param string $value Raw string
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (is_int($value)) {
- return $value;
- } elseif (is_float($value)) {
- return sprintf('%F', $value);
- }
- return "'" . addcslashes($value, "\000\n\r\\'\"\032") . "'";
- }
-
- /**
- * Safely quotes a value for an SQL statement.
- *
- * If an array is passed as the value, the array values are quoted
- * and then returned as a comma-separated string.
- *
- * @param mixed $value The value to quote.
- * @param mixed $type OPTIONAL the SQL datatype name, or constant, or null.
- * @return mixed An SQL-safe quoted value (or string of separated values).
- */
- public function quote($value, $type = null)
- {
- $this->_connect();
-
- if ($value instanceof Zend_Db_Select) {
- return '(' . $value->assemble() . ')';
- }
-
- if ($value instanceof Zend_Db_Expr) {
- return $value->__toString();
- }
-
- if (is_array($value)) {
- foreach ($value as &$val) {
- $val = $this->quote($val, $type);
- }
- return implode(', ', $value);
- }
-
- if ($type !== null && array_key_exists($type = strtoupper($type), $this->_numericDataTypes)) {
- $quotedValue = '0';
- switch ($this->_numericDataTypes[$type]) {
- case Zend_Db::INT_TYPE: // 32-bit integer
- $quotedValue = (string) intval($value);
- break;
- case Zend_Db::BIGINT_TYPE: // 64-bit integer
- // ANSI SQL-style hex literals (e.g. x'[\dA-F]+')
- // are not supported here, because these are string
- // literals, not numeric literals.
- if (preg_match('/^(
- [+-]? # optional sign
- (?:
- 0[Xx][\da-fA-F]+ # ODBC-style hexadecimal
- |\d+ # decimal or octal, or MySQL ZEROFILL decimal
- (?:[eE][+-]?\d+)? # optional exponent on decimals or octals
- )
- )/x',
- (string) $value, $matches)) {
- $quotedValue = $matches[1];
- }
- break;
- case Zend_Db::FLOAT_TYPE: // float or decimal
- $quotedValue = sprintf('%F', $value);
- }
- return $quotedValue;
- }
-
- return $this->_quote($value);
- }
-
- /**
- * Quotes a value and places into a piece of text at a placeholder.
- *
- * The placeholder is a question-mark; all placeholders will be replaced
- * with the quoted value. For example:
- *
- *
- * $text = "WHERE date < ?";
- * $date = "2005-01-02";
- * $safe = $sql->quoteInto($text, $date);
- * // $safe = "WHERE date < '2005-01-02'"
- *
- *
- * @param string $text The text with a placeholder.
- * @param mixed $value The value to quote.
- * @param string $type OPTIONAL SQL datatype
- * @param integer $count OPTIONAL count of placeholders to replace
- * @return string An SQL-safe quoted value placed into the original text.
- */
- public function quoteInto($text, $value, $type = null, $count = null)
- {
- if ($count === null) {
- return str_replace('?', $this->quote($value, $type), $text);
- } else {
- while ($count > 0) {
- if (strpos($text, '?') !== false) {
- $text = substr_replace($text, $this->quote($value, $type), strpos($text, '?'), 1);
- }
- --$count;
- }
- return $text;
- }
- }
-
- /**
- * Quotes an identifier.
- *
- * Accepts a string representing a qualified indentifier. For Example:
- *
- * $adapter->quoteIdentifier('myschema.mytable')
- *
- * Returns: "myschema"."mytable"
- *
- * Or, an array of one or more identifiers that may form a qualified identifier:
- *
- * $adapter->quoteIdentifier(array('myschema','my.table'))
- *
- * Returns: "myschema"."my.table"
- *
- * The actual quote character surrounding the identifiers may vary depending on
- * the adapter.
- *
- * @param string|array|Zend_Db_Expr $ident The identifier.
- * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
- * @return string The quoted identifier.
- */
- public function quoteIdentifier($ident, $auto=false)
- {
- return $this->_quoteIdentifierAs($ident, null, $auto);
- }
-
- /**
- * Quote a column identifier and alias.
- *
- * @param string|array|Zend_Db_Expr $ident The identifier or expression.
- * @param string $alias An alias for the column.
- * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
- * @return string The quoted identifier and alias.
- */
- public function quoteColumnAs($ident, $alias, $auto=false)
- {
- return $this->_quoteIdentifierAs($ident, $alias, $auto);
- }
-
- /**
- * Quote a table identifier and alias.
- *
- * @param string|array|Zend_Db_Expr $ident The identifier or expression.
- * @param string $alias An alias for the table.
- * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
- * @return string The quoted identifier and alias.
- */
- public function quoteTableAs($ident, $alias = null, $auto = false)
- {
- return $this->_quoteIdentifierAs($ident, $alias, $auto);
- }
-
- /**
- * Quote an identifier and an optional alias.
- *
- * @param string|array|Zend_Db_Expr $ident The identifier or expression.
- * @param string $alias An optional alias.
- * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
- * @param string $as The string to add between the identifier/expression and the alias.
- * @return string The quoted identifier and alias.
- */
- protected function _quoteIdentifierAs($ident, $alias = null, $auto = false, $as = ' AS ')
- {
- if ($ident instanceof Zend_Db_Expr) {
- $quoted = $ident->__toString();
- } elseif ($ident instanceof Zend_Db_Select) {
- $quoted = '(' . $ident->assemble() . ')';
- } else {
- if (is_string($ident)) {
- $ident = explode('.', $ident);
- }
- if (is_array($ident)) {
- $segments = array();
- foreach ($ident as $segment) {
- if ($segment instanceof Zend_Db_Expr) {
- $segments[] = $segment->__toString();
- } else {
- $segments[] = $this->_quoteIdentifier($segment, $auto);
- }
- }
- if ($alias !== null && end($ident) == $alias) {
- $alias = null;
- }
- $quoted = implode('.', $segments);
- } else {
- $quoted = $this->_quoteIdentifier($ident, $auto);
- }
- }
- if ($alias !== null) {
- $quoted .= $as . $this->_quoteIdentifier($alias, $auto);
- }
- return $quoted;
- }
-
- /**
- * Quote an identifier.
- *
- * @param string $value The identifier or expression.
- * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
- * @return string The quoted identifier and alias.
- */
- protected function _quoteIdentifier($value, $auto=false)
- {
- if ($auto === false || $this->_autoQuoteIdentifiers === true) {
- $q = $this->getQuoteIdentifierSymbol();
- return ($q . str_replace("$q", "$q$q", $value) . $q);
- }
- return $value;
- }
-
- /**
- * Returns the symbol the adapter uses for delimited identifiers.
- *
- * @return string
- */
- public function getQuoteIdentifierSymbol()
- {
- return '"';
- }
-
- /**
- * Return the most recent value from the specified sequence in the database.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function lastSequenceId($sequenceName)
- {
- return null;
- }
-
- /**
- * Generate a new value from the specified sequence in the database, and return it.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function nextSequenceId($sequenceName)
- {
- return null;
- }
-
- /**
- * Helper method to change the case of the strings used
- * when returning result sets in FETCH_ASSOC and FETCH_BOTH
- * modes.
- *
- * This is not intended to be used by application code,
- * but the method must be public so the Statement class
- * can invoke it.
- *
- * @param string $key
- * @return string
- */
- public function foldCase($key)
- {
- switch ($this->_caseFolding) {
- case Zend_Db::CASE_LOWER:
- $value = strtolower((string) $key);
- break;
- case Zend_Db::CASE_UPPER:
- $value = strtoupper((string) $key);
- break;
- case Zend_Db::CASE_NATURAL:
- default:
- $value = (string) $key;
- }
- return $value;
- }
-
- /**
- * called when object is getting serialized
- * This disconnects the DB object that cant be serialized
- *
- * @throws Zend_Db_Adapter_Exception
- * @return array
- */
- public function __sleep()
- {
- if ($this->_allowSerialization == false) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception(get_class($this) ." is not allowed to be serialized");
- }
- $this->_connection = false;
- return array_keys(array_diff_key(get_object_vars($this), array('_connection'=>false)));
- }
-
- /**
- * called when object is getting unserialized
- *
- * @return void
- */
- public function __wakeup()
- {
- if ($this->_autoReconnectOnUnserialize == true) {
- $this->getConnection();
- }
- }
-
- /**
- * Abstract Methods
- */
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- abstract public function listTables();
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- abstract public function describeTable($tableName, $schemaName = null);
-
- /**
- * Creates a connection to the database.
- *
- * @return void
- */
- abstract protected function _connect();
-
- /**
- * Test if a connection is active
- *
- * @return boolean
- */
- abstract public function isConnected();
-
- /**
- * Force the connection to close.
- *
- * @return void
- */
- abstract public function closeConnection();
-
- /**
- * Prepare a statement and return a PDOStatement-like object.
- *
- * @param string|Zend_Db_Select $sql SQL query
- * @return Zend_Db_Statement|PDOStatement
- */
- abstract public function prepare($sql);
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- */
- abstract public function lastInsertId($tableName = null, $primaryKey = null);
-
- /**
- * Begin a transaction.
- */
- abstract protected function _beginTransaction();
-
- /**
- * Commit a transaction.
- */
- abstract protected function _commit();
-
- /**
- * Roll-back a transaction.
- */
- abstract protected function _rollBack();
-
- /**
- * Set the fetch mode.
- *
- * @param integer $mode
- * @return void
- * @throws Zend_Db_Adapter_Exception
- */
- abstract public function setFetchMode($mode);
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param mixed $sql
- * @param integer $count
- * @param integer $offset
- * @return string
- */
- abstract public function limit($sql, $count, $offset = 0);
-
- /**
- * Check if the adapter supports real SQL parameters.
- *
- * @param string $type 'positional' or 'named'
- * @return bool
- */
- abstract public function supportsParameters($type);
-
- /**
- * Retrieve server version in PHP style
- *
- * @return string
- */
- abstract public function getServerVersion();
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/AdapterAbstractServiceFactory.php zendframework-2.2.6/library/Zend/Db/Adapter/AdapterAbstractServiceFactory.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/AdapterAbstractServiceFactory.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/AdapterAbstractServiceFactory.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,99 @@
+getConfig($services);
+ if (empty($config)) {
+ return false;
+ }
+
+ return (
+ isset($config[$requestedName])
+ && is_array($config[$requestedName])
+ && !empty($config[$requestedName])
+ );
+ }
+
+ /**
+ * Create a DB adapter
+ *
+ * @param ServiceLocatorInterface $services
+ * @param string $name
+ * @param string $requestedName
+ * @return Adapter
+ */
+ public function createServiceWithName(ServiceLocatorInterface $services, $name, $requestedName)
+ {
+ $config = $this->getConfig($services);
+ return new Adapter($config[$requestedName]);
+ }
+
+ /**
+ * Get db configuration, if any
+ *
+ * @param ServiceLocatorInterface $services
+ * @return array
+ */
+ protected function getConfig(ServiceLocatorInterface $services)
+ {
+ if ($this->config !== null) {
+ return $this->config;
+ }
+
+ if (!$services->has('Config')) {
+ $this->config = array();
+ return $this->config;
+ }
+
+ $config = $services->get('Config');
+ if (!isset($config['db'])
+ || !is_array($config['db'])
+ ) {
+ $this->config = array();
+ return $this->config;
+ }
+
+ $config = $config['db'];
+ if (!isset($config['adapters'])
+ || !is_array($config['adapters'])
+ ) {
+ $this->config = array();
+ return $this->config;
+ }
+
+ $this->config = $config['adapters'];
+ return $this->config;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/AdapterAwareInterface.php zendframework-2.2.6/library/Zend/Db/Adapter/AdapterAwareInterface.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/AdapterAwareInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/AdapterAwareInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,21 @@
+adapter = $adapter;
+
+ return $this;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/AdapterInterface.php zendframework-2.2.6/library/Zend/Db/Adapter/AdapterInterface.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/AdapterInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/AdapterInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,29 @@
+createProfiler($parameters);
+ }
+ $driver = $this->createDriver($parameters);
+ } elseif (!$driver instanceof Driver\DriverInterface) {
+ throw new Exception\InvalidArgumentException(
+ 'The supplied or instantiated driver object does not implement Zend\Db\Adapter\Driver\DriverInterface'
+ );
+ }
+
+ $driver->checkEnvironment();
+ $this->driver = $driver;
+
+ if ($platform == null) {
+ $platform = $this->createPlatform($parameters);
+ }
+
+ $this->platform = $platform;
+ $this->queryResultSetPrototype = ($queryResultPrototype) ?: new ResultSet\ResultSet();
+
+ if ($profiler) {
+ $this->setProfiler($profiler);
+ }
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Adapter
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ if ($this->driver instanceof Profiler\ProfilerAwareInterface) {
+ $this->driver->setProfiler($profiler);
+ }
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * getDriver()
+ *
+ * @throws Exception\RuntimeException
+ * @return Driver\DriverInterface
+ */
+ public function getDriver()
+ {
+ if ($this->driver == null) {
+ throw new Exception\RuntimeException('Driver has not been set or configured for this adapter.');
+ }
+ return $this->driver;
+ }
+
+ /**
+ * @return Platform\PlatformInterface
+ */
+ public function getPlatform()
+ {
+ return $this->platform;
+ }
+
+ /**
+ * @return ResultSet\ResultSetInterface
+ */
+ public function getQueryResultSetPrototype()
+ {
+ return $this->queryResultSetPrototype;
+ }
+
+ public function getCurrentSchema()
+ {
+ return $this->driver->getConnection()->getCurrentSchema();
+ }
+
+ /**
+ * query() is a convenience function
+ *
+ * @param string $sql
+ * @param string|array|ParameterContainer $parametersOrQueryMode
+ * @throws Exception\InvalidArgumentException
+ * @return Driver\StatementInterface|ResultSet\ResultSet
+ */
+ public function query($sql, $parametersOrQueryMode = self::QUERY_MODE_PREPARE)
+ {
+ if (is_string($parametersOrQueryMode) && in_array($parametersOrQueryMode, array(self::QUERY_MODE_PREPARE, self::QUERY_MODE_EXECUTE))) {
+ $mode = $parametersOrQueryMode;
+ $parameters = null;
+ } elseif (is_array($parametersOrQueryMode) || $parametersOrQueryMode instanceof ParameterContainer) {
+ $mode = self::QUERY_MODE_PREPARE;
+ $parameters = $parametersOrQueryMode;
+ } else {
+ throw new Exception\InvalidArgumentException('Parameter 2 to this method must be a flag, an array, or ParameterContainer');
+ }
+
+ if ($mode == self::QUERY_MODE_PREPARE) {
+ $this->lastPreparedStatement = null;
+ $this->lastPreparedStatement = $this->driver->createStatement($sql);
+ $this->lastPreparedStatement->prepare();
+ if (is_array($parameters) || $parameters instanceof ParameterContainer) {
+ $this->lastPreparedStatement->setParameterContainer((is_array($parameters)) ? new ParameterContainer($parameters) : $parameters);
+ $result = $this->lastPreparedStatement->execute();
+ } else {
+ return $this->lastPreparedStatement;
+ }
+ } else {
+ $result = $this->driver->getConnection()->execute($sql);
+ }
+
+ if ($result instanceof Driver\ResultInterface && $result->isQueryResult()) {
+ $resultSet = clone $this->queryResultSetPrototype;
+ $resultSet->initialize($result);
+ return $resultSet;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Create statement
+ *
+ * @param string $initialSql
+ * @param ParameterContainer $initialParameters
+ * @return Driver\StatementInterface
+ */
+ public function createStatement($initialSql = null, $initialParameters = null)
+ {
+ $statement = $this->driver->createStatement($initialSql);
+ if ($initialParameters == null || !$initialParameters instanceof ParameterContainer && is_array($initialParameters)) {
+ $initialParameters = new ParameterContainer((is_array($initialParameters) ? $initialParameters : array()));
+ }
+ $statement->setParameterContainer($initialParameters);
+ return $statement;
+ }
+
+ public function getHelpers(/* $functions */)
+ {
+ $functions = array();
+ $platform = $this->platform;
+ foreach (func_get_args() as $arg) {
+ switch ($arg) {
+ case self::FUNCTION_QUOTE_IDENTIFIER:
+ $functions[] = function ($value) use ($platform) { return $platform->quoteIdentifier($value); };
+ break;
+ case self::FUNCTION_QUOTE_VALUE:
+ $functions[] = function ($value) use ($platform) { return $platform->quoteValue($value); };
+ break;
+
+ }
+ }
+ }
+
+ /**
+ * @param $name
+ * @throws Exception\InvalidArgumentException
+ * @return Driver\DriverInterface|Platform\PlatformInterface
+ */
+ public function __get($name)
+ {
+ switch (strtolower($name)) {
+ case 'driver':
+ return $this->driver;
+ case 'platform':
+ return $this->platform;
+ default:
+ throw new Exception\InvalidArgumentException('Invalid magic property on adapter');
+ }
+
+ }
+
+ /**
+ * @param array $parameters
+ * @return Driver\DriverInterface
+ * @throws \InvalidArgumentException
+ * @throws Exception\InvalidArgumentException
+ */
+ protected function createDriver($parameters)
+ {
+ if (!isset($parameters['driver'])) {
+ throw new Exception\InvalidArgumentException(__FUNCTION__ . ' expects a "driver" key to be present inside the parameters');
+ }
+
+ if ($parameters['driver'] instanceof Driver\DriverInterface) {
+ return $parameters['driver'];
+ }
+
+ if (!is_string($parameters['driver'])) {
+ throw new Exception\InvalidArgumentException(__FUNCTION__ . ' expects a "driver" to be a string or instance of DriverInterface');
+ }
+
+ $options = array();
+ if (isset($parameters['options'])) {
+ $options = (array) $parameters['options'];
+ unset($parameters['options']);
+ }
+
+ $driverName = strtolower($parameters['driver']);
+ switch ($driverName) {
+ case 'mysqli':
+ $driver = new Driver\Mysqli\Mysqli($parameters, null, null, $options);
+ break;
+ case 'sqlsrv':
+ $driver = new Driver\Sqlsrv\Sqlsrv($parameters);
+ break;
+ case 'oci8':
+ $driver = new Driver\Oci8\Oci8($parameters);
+ break;
+ case 'pgsql':
+ $driver = new Driver\Pgsql\Pgsql($parameters);
+ break;
+ case 'ibmdb2':
+ $driver = new Driver\IbmDb2\IbmDb2($parameters);
+ break;
+ case 'pdo':
+ default:
+ if ($driverName == 'pdo' || strpos($driverName, 'pdo') === 0) {
+ $driver = new Driver\Pdo\Pdo($parameters);
+ }
+ }
+
+ if (!isset($driver) || !$driver instanceof Driver\DriverInterface) {
+ throw new Exception\InvalidArgumentException('DriverInterface expected', null, null);
+ }
+
+ return $driver;
+ }
+
+ /**
+ * @param Driver\DriverInterface $driver
+ * @return Platform\PlatformInterface
+ */
+ protected function createPlatform($parameters)
+ {
+ if (isset($parameters['platform'])) {
+ $platformName = $parameters['platform'];
+ } elseif ($this->driver instanceof Driver\DriverInterface) {
+ $platformName = $this->driver->getDatabasePlatformName(Driver\DriverInterface::NAME_FORMAT_CAMELCASE);
+ } else {
+ throw new Exception\InvalidArgumentException('A platform could not be determined from the provided configuration');
+ }
+
+ // currently only supported by the IbmDb2 & Oracle concrete implementations
+ $options = (isset($parameters['platform_options'])) ? $parameters['platform_options'] : array();
+
+ switch ($platformName) {
+ case 'Mysql':
+ // mysqli or pdo_mysql driver
+ $driver = ($this->driver instanceof Driver\Mysqli\Mysqli || $this->driver instanceof Driver\Pdo\Pdo) ? $this->driver : null;
+ return new Platform\Mysql($driver);
+ case 'SqlServer':
+ // PDO is only supported driver for quoting values in this platform
+ return new Platform\SqlServer(($this->driver instanceof Driver\Pdo\Pdo) ? $this->driver : null);
+ case 'Oracle':
+ // oracle does not accept a driver as an option, no driver specific quoting available
+ return new Platform\Oracle($options);
+ case 'Sqlite':
+ // PDO is only supported driver for quoting values in this platform
+ return new Platform\Sqlite(($this->driver instanceof Driver\Pdo\Pdo) ? $this->driver : null);
+ case 'Postgresql':
+ // pgsql or pdo postgres driver
+ $driver = ($this->driver instanceof Driver\Pgsql\Pgsql || $this->driver instanceof Driver\Pdo\Pdo) ? $this->driver : null;
+ return new Platform\Postgresql($driver);
+ case 'IbmDb2':
+ // ibm_db2 driver escaping does not need an action connection
+ return new Platform\IbmDb2($options);
+ default:
+ return new Platform\Sql92();
+ }
+ }
+
+ protected function createProfiler($parameters)
+ {
+ if ($parameters['profiler'] instanceof Profiler\ProfilerInterface) {
+ $profiler = $parameters['profiler'];
+ } elseif (is_bool($parameters['profiler'])) {
+ $profiler = ($parameters['profiler'] == true) ? new Profiler\Profiler : null;
+ } else {
+ throw new Exception\InvalidArgumentException(
+ '"profiler" parameter must be an instance of ProfilerInterface or a boolean'
+ );
+ }
+ return $profiler;
+ }
+
+ /**
+ * @param array $parameters
+ * @return Driver\DriverInterface
+ * @throws \InvalidArgumentException
+ * @throws Exception\InvalidArgumentException
+ * @deprecated
+ */
+ protected function createDriverFromParameters(array $parameters)
+ {
+ return $this->createDriver($parameters);
+ }
+
+ /**
+ * @param Driver\DriverInterface $driver
+ * @return Platform\PlatformInterface
+ * @deprecated
+ */
+ protected function createPlatformFromDriver(Driver\DriverInterface $driver)
+ {
+ return $this->createPlatform($driver);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/AdapterServiceFactory.php zendframework-2.2.6/library/Zend/Db/Adapter/AdapterServiceFactory.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/AdapterServiceFactory.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/AdapterServiceFactory.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,28 @@
+get('Config');
+ return new Adapter($config['db']);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Db2/Exception.php zendframework-2.2.6/library/Zend/Db/Adapter/Db2/Exception.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Db2/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Db2/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,45 +0,0 @@
- (string) Connect to the database as this username.
- * password => (string) Password associated with the username.
- * host => (string) What host to connect to (default 127.0.0.1)
- * dbname => (string) The name of the database to user
- * protocol => (string) Protocol to use, defaults to "TCPIP"
- * port => (integer) Port number to use for TCP/IP if protocol is "TCPIP"
- * persistent => (boolean) Set TRUE to use a persistent connection (db2_pconnect)
- * os => (string) This should be set to 'i5' if the db is on an os400/i5
- * schema => (string) The default schema the connection should use
- *
- * @var array
- */
- protected $_config = array(
- 'dbname' => null,
- 'username' => null,
- 'password' => null,
- 'host' => 'localhost',
- 'port' => '50000',
- 'protocol' => 'TCPIP',
- 'persistent' => false,
- 'os' => null,
- 'schema' => null
- );
-
- /**
- * Execution mode
- *
- * @var int execution flag (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF)
- */
- protected $_execute_mode = DB2_AUTOCOMMIT_ON;
-
- /**
- * Default class name for a DB statement.
- *
- * @var string
- */
- protected $_defaultStmtClass = 'Zend_Db_Statement_Db2';
- protected $_isI5 = false;
-
- /**
- * Keys are UPPERCASE SQL datatypes or the constants
- * Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE.
- *
- * Values are:
- * 0 = 32-bit integer
- * 1 = 64-bit integer
- * 2 = float or decimal
- *
- * @var array Associative array of datatypes to values 0, 1, or 2.
- */
- protected $_numericDataTypes = array(
- Zend_Db::INT_TYPE => Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INTEGER' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Creates a connection resource.
- *
- * @return void
- */
- protected function _connect()
- {
- if (is_resource($this->_connection)) {
- // connection already exists
- return;
- }
-
- if (!extension_loaded('ibm_db2')) {
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- require_once 'Zend/Db/Adapter/Db2/Exception.php';
- throw new Zend_Db_Adapter_Db2_Exception('The IBM DB2 extension is required for this adapter but the extension is not loaded');
- }
-
- $this->_determineI5();
- if ($this->_config['persistent']) {
- // use persistent connection
- $conn_func_name = 'db2_pconnect';
- } else {
- // use "normal" connection
- $conn_func_name = 'db2_connect';
- }
-
- if (!isset($this->_config['driver_options']['autocommit'])) {
- // set execution mode
- $this->_config['driver_options']['autocommit'] = &$this->_execute_mode;
- }
-
- if (isset($this->_config['options'][Zend_Db::CASE_FOLDING])) {
- $caseAttrMap = array(
- Zend_Db::CASE_NATURAL => DB2_CASE_NATURAL,
- Zend_Db::CASE_UPPER => DB2_CASE_UPPER,
- Zend_Db::CASE_LOWER => DB2_CASE_LOWER
- );
- $this->_config['driver_options']['DB2_ATTR_CASE'] = $caseAttrMap[$this->_config['options'][Zend_Db::CASE_FOLDING]];
- }
-
- if ($this->_config['host'] !== 'localhost' && !$this->_isI5) {
- // if the host isn't localhost, use extended connection params
- $dbname = 'DRIVER={IBM DB2 ODBC DRIVER}' .
- ';DATABASE=' . $this->_config['dbname'] .
- ';HOSTNAME=' . $this->_config['host'] .
- ';PORT=' . $this->_config['port'] .
- ';PROTOCOL=' . $this->_config['protocol'] .
- ';UID=' . $this->_config['username'] .
- ';PWD=' . $this->_config['password'] .';';
- $this->_connection = $conn_func_name(
- $dbname,
- null,
- null,
- $this->_config['driver_options']
- );
- } else {
- // host is localhost, so use standard connection params
- $this->_connection = $conn_func_name(
- $this->_config['dbname'],
- $this->_config['username'],
- $this->_config['password'],
- $this->_config['driver_options']
- );
- }
-
- // check the connection
- if (!$this->_connection) {
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- require_once 'Zend/Db/Adapter/Db2/Exception.php';
- throw new Zend_Db_Adapter_Db2_Exception(db2_conn_errormsg(), db2_conn_error());
- }
- }
-
- /**
- * Test if a connection is active
- *
- * @return boolean
- */
- public function isConnected()
- {
- return ((bool) (is_resource($this->_connection)
- && get_resource_type($this->_connection) == 'DB2 Connection'));
- }
-
- /**
- * Force the connection to close.
- *
- * @return void
- */
- public function closeConnection()
- {
- if ($this->isConnected()) {
- db2_close($this->_connection);
- }
- $this->_connection = null;
- }
-
- /**
- * Returns an SQL statement for preparation.
- *
- * @param string $sql The SQL statement with placeholders.
- * @return Zend_Db_Statement_Db2
- */
- public function prepare($sql)
- {
- $this->_connect();
- $stmtClass = $this->_defaultStmtClass;
- if (!class_exists($stmtClass)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($stmtClass);
- }
- $stmt = new $stmtClass($this, $sql);
- $stmt->setFetchMode($this->_fetchMode);
- return $stmt;
- }
-
- /**
- * Gets the execution mode
- *
- * @return int the execution mode (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF)
- */
- public function _getExecuteMode()
- {
- return $this->_execute_mode;
- }
-
- /**
- * @param integer $mode
- * @return void
- */
- public function _setExecuteMode($mode)
- {
- switch ($mode) {
- case DB2_AUTOCOMMIT_OFF:
- case DB2_AUTOCOMMIT_ON:
- $this->_execute_mode = $mode;
- db2_autocommit($this->_connection, $mode);
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- require_once 'Zend/Db/Adapter/Db2/Exception.php';
- throw new Zend_Db_Adapter_Db2_Exception("execution mode not supported");
- break;
- }
- }
-
- /**
- * Quote a raw string.
- *
- * @param string $value Raw string
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (is_int($value) || is_float($value)) {
- return $value;
- }
- /**
- * Use db2_escape_string() if it is present in the IBM DB2 extension.
- * But some supported versions of PHP do not include this function,
- * so fall back to default quoting in the parent class.
- */
- if (function_exists('db2_escape_string')) {
- return "'" . db2_escape_string($value) . "'";
- }
- return parent::_quote($value);
- }
-
- /**
- * @return string
- */
- public function getQuoteIdentifierSymbol()
- {
- $this->_connect();
- $info = db2_server_info($this->_connection);
- if ($info) {
- $identQuote = $info->IDENTIFIER_QUOTE_CHAR;
- } else {
- // db2_server_info() does not return result on some i5 OS version
- if ($this->_isI5) {
- $identQuote ="'";
- }
- }
- return $identQuote;
- }
-
- /**
- * Returns a list of the tables in the database.
- * @param string $schema OPTIONAL
- * @return array
- */
- public function listTables($schema = null)
- {
- $this->_connect();
-
- if ($schema === null && $this->_config['schema'] != null) {
- $schema = $this->_config['schema'];
- }
-
- $tables = array();
-
- if (!$this->_isI5) {
- if ($schema) {
- $stmt = db2_tables($this->_connection, null, $schema);
- } else {
- $stmt = db2_tables($this->_connection);
- }
- while ($row = db2_fetch_assoc($stmt)) {
- $tables[] = $row['TABLE_NAME'];
- }
- } else {
- $tables = $this->_i5listTables($schema);
- }
-
- return $tables;
- }
-
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * DB2 not supports UNSIGNED integer.
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- // Ensure the connection is made so that _isI5 is set
- $this->_connect();
-
- if ($schemaName === null && $this->_config['schema'] != null) {
- $schemaName = $this->_config['schema'];
- }
-
- if (!$this->_isI5) {
-
- $sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
- c.typename, c.default, c.nulls, c.length, c.scale,
- c.identity, tc.type AS tabconsttype, k.colseq
- FROM syscat.columns c
- LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
- ON (k.tabschema = tc.tabschema
- AND k.tabname = tc.tabname
- AND tc.type = 'P'))
- ON (c.tabschema = k.tabschema
- AND c.tabname = k.tabname
- AND c.colname = k.colname)
- WHERE "
- . $this->quoteInto('UPPER(c.tabname) = UPPER(?)', $tableName);
-
- if ($schemaName) {
- $sql .= $this->quoteInto(' AND UPPER(c.tabschema) = UPPER(?)', $schemaName);
- }
-
- $sql .= " ORDER BY c.colno";
-
- } else {
-
- // DB2 On I5 specific query
- $sql = "SELECT DISTINCT C.TABLE_SCHEMA, C.TABLE_NAME, C.COLUMN_NAME, C.ORDINAL_POSITION,
- C.DATA_TYPE, C.COLUMN_DEFAULT, C.NULLS ,C.LENGTH, C.SCALE, LEFT(C.IDENTITY,1),
- LEFT(tc.TYPE, 1) AS tabconsttype, k.COLSEQ
- FROM QSYS2.SYSCOLUMNS C
- LEFT JOIN (QSYS2.syskeycst k JOIN QSYS2.SYSCST tc
- ON (k.TABLE_SCHEMA = tc.TABLE_SCHEMA
- AND k.TABLE_NAME = tc.TABLE_NAME
- AND LEFT(tc.type,1) = 'P'))
- ON (C.TABLE_SCHEMA = k.TABLE_SCHEMA
- AND C.TABLE_NAME = k.TABLE_NAME
- AND C.COLUMN_NAME = k.COLUMN_NAME)
- WHERE "
- . $this->quoteInto('UPPER(C.TABLE_NAME) = UPPER(?)', $tableName);
-
- if ($schemaName) {
- $sql .= $this->quoteInto(' AND UPPER(C.TABLE_SCHEMA) = UPPER(?)', $schemaName);
- }
-
- $sql .= " ORDER BY C.ORDINAL_POSITION FOR FETCH ONLY";
- }
-
- $desc = array();
- $stmt = $this->query($sql);
-
- /**
- * To avoid case issues, fetch using FETCH_NUM
- */
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- /**
- * The ordering of columns is defined by the query so we can map
- * to variables to improve readability
- */
- $tabschema = 0;
- $tabname = 1;
- $colname = 2;
- $colno = 3;
- $typename = 4;
- $default = 5;
- $nulls = 6;
- $length = 7;
- $scale = 8;
- $identityCol = 9;
- $tabconstType = 10;
- $colseq = 11;
-
- foreach ($result as $key => $row) {
- list ($primary, $primaryPosition, $identity) = array(false, null, false);
- if ($row[$tabconstType] == 'P') {
- $primary = true;
- $primaryPosition = $row[$colseq];
- }
- /**
- * In IBM DB2, an column can be IDENTITY
- * even if it is not part of the PRIMARY KEY.
- */
- if ($row[$identityCol] == 'Y') {
- $identity = true;
- }
-
- // only colname needs to be case adjusted
- $desc[$this->foldCase($row[$colname])] = array(
- 'SCHEMA_NAME' => $this->foldCase($row[$tabschema]),
- 'TABLE_NAME' => $this->foldCase($row[$tabname]),
- 'COLUMN_NAME' => $this->foldCase($row[$colname]),
- 'COLUMN_POSITION' => (!$this->_isI5) ? $row[$colno]+1 : $row[$colno],
- 'DATA_TYPE' => $row[$typename],
- 'DEFAULT' => $row[$default],
- 'NULLABLE' => (bool) ($row[$nulls] == 'Y'),
- 'LENGTH' => $row[$length],
- 'SCALE' => $row[$scale],
- 'PRECISION' => ($row[$typename] == 'DECIMAL' ? $row[$length] : 0),
- 'UNSIGNED' => false,
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
-
- return $desc;
- }
-
- /**
- * Return the most recent value from the specified sequence in the database.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function lastSequenceId($sequenceName)
- {
- $this->_connect();
-
- if (!$this->_isI5) {
- $quotedSequenceName = $this->quoteIdentifier($sequenceName, true);
- $sql = 'SELECT PREVVAL FOR ' . $quotedSequenceName . ' AS VAL FROM SYSIBM.SYSDUMMY1';
- } else {
- $quotedSequenceName = $sequenceName;
- $sql = 'SELECT PREVVAL FOR ' . $this->quoteIdentifier($sequenceName, true) . ' AS VAL FROM QSYS2.QSQPTABL';
- }
-
- $value = $this->fetchOne($sql);
- return (string) $value;
- }
-
- /**
- * Generate a new value from the specified sequence in the database, and return it.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function nextSequenceId($sequenceName)
- {
- $this->_connect();
- $sql = 'SELECT NEXTVAL FOR '.$this->quoteIdentifier($sequenceName, true).' AS VAL FROM SYSIBM.SYSDUMMY1';
- $value = $this->fetchOne($sql);
- return (string) $value;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * The IDENTITY_VAL_LOCAL() function gives the last generated identity value
- * in the current process, even if it was for a GENERATED column.
- *
- * @param string $tableName OPTIONAL
- * @param string $primaryKey OPTIONAL
- * @param string $idType OPTIONAL used for i5 platform to define sequence/idenity unique value
- * @return string
- */
-
- public function lastInsertId($tableName = null, $primaryKey = null, $idType = null)
- {
- $this->_connect();
-
- if ($this->_isI5) {
- return (string) $this->_i5LastInsertId($tableName, $idType);
- }
-
- if ($tableName !== null) {
- $sequenceName = $tableName;
- if ($primaryKey) {
- $sequenceName .= "_$primaryKey";
- }
- $sequenceName .= '_seq';
- return $this->lastSequenceId($sequenceName);
- }
-
- $sql = 'SELECT IDENTITY_VAL_LOCAL() AS VAL FROM SYSIBM.SYSDUMMY1';
- $value = $this->fetchOne($sql);
- return (string) $value;
- }
-
- /**
- * Begin a transaction.
- *
- * @return void
- */
- protected function _beginTransaction()
- {
- $this->_setExecuteMode(DB2_AUTOCOMMIT_OFF);
- }
-
- /**
- * Commit a transaction.
- *
- * @return void
- */
- protected function _commit()
- {
- if (!db2_commit($this->_connection)) {
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- require_once 'Zend/Db/Adapter/Db2/Exception.php';
- throw new Zend_Db_Adapter_Db2_Exception(
- db2_conn_errormsg($this->_connection),
- db2_conn_error($this->_connection));
- }
-
- $this->_setExecuteMode(DB2_AUTOCOMMIT_ON);
- }
-
- /**
- * Rollback a transaction.
- *
- * @return void
- */
- protected function _rollBack()
- {
- if (!db2_rollback($this->_connection)) {
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- require_once 'Zend/Db/Adapter/Db2/Exception.php';
- throw new Zend_Db_Adapter_Db2_Exception(
- db2_conn_errormsg($this->_connection),
- db2_conn_error($this->_connection));
- }
- $this->_setExecuteMode(DB2_AUTOCOMMIT_ON);
- }
-
- /**
- * Set the fetch mode.
- *
- * @param integer $mode
- * @return void
- * @throws Zend_Db_Adapter_Db2_Exception
- */
- public function setFetchMode($mode)
- {
- switch ($mode) {
- case Zend_Db::FETCH_NUM: // seq array
- case Zend_Db::FETCH_ASSOC: // assoc array
- case Zend_Db::FETCH_BOTH: // seq+assoc array
- case Zend_Db::FETCH_OBJ: // object
- $this->_fetchMode = $mode;
- break;
- case Zend_Db::FETCH_BOUND: // bound to PHP variable
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- require_once 'Zend/Db/Adapter/Db2/Exception.php';
- throw new Zend_Db_Adapter_Db2_Exception('FETCH_BOUND is not supported yet');
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- require_once 'Zend/Db/Adapter/Db2/Exception.php';
- throw new Zend_Db_Adapter_Db2_Exception("Invalid fetch mode '$mode' specified");
- break;
- }
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- require_once 'Zend/Db/Adapter/Db2/Exception.php';
- throw new Zend_Db_Adapter_Db2_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /**
- * @see Zend_Db_Adapter_Db2_Exception
- */
- require_once 'Zend/Db/Adapter/Db2/Exception.php';
- throw new Zend_Db_Adapter_Db2_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- if ($offset == 0) {
- $limit_sql = $sql . " FETCH FIRST $count ROWS ONLY";
- return $limit_sql;
- }
-
- /**
- * DB2 does not implement the LIMIT clause as some RDBMS do.
- * We have to simulate it with subqueries and ROWNUM.
- * Unfortunately because we use the column wildcard "*",
- * this puts an extra column into the query result set.
- */
- $limit_sql = "SELECT z2.*
- FROM (
- SELECT ROW_NUMBER() OVER() AS \"ZEND_DB_ROWNUM\", z1.*
- FROM (
- " . $sql . "
- ) z1
- ) z2
- WHERE z2.zend_db_rownum BETWEEN " . ($offset+1) . " AND " . ($offset+$count);
- return $limit_sql;
- }
-
- /**
- * Check if the adapter supports real SQL parameters.
- *
- * @param string $type 'positional' or 'named'
- * @return bool
- */
- public function supportsParameters($type)
- {
- if ($type == 'positional') {
- return true;
- }
-
- // if its 'named' or anything else
- return false;
- }
-
- /**
- * Retrieve server version in PHP style
- *
- * @return string
- */
- public function getServerVersion()
- {
- $this->_connect();
- $server_info = db2_server_info($this->_connection);
- if ($server_info !== false) {
- $version = $server_info->DBMS_VER;
- if ($this->_isI5) {
- $version = (int) substr($version, 0, 2) . '.' . (int) substr($version, 2, 2) . '.' . (int) substr($version, 4);
- }
- return $version;
- } else {
- return null;
- }
- }
-
- /**
- * Return whether or not this is running on i5
- *
- * @return bool
- */
- public function isI5()
- {
- if ($this->_isI5 === null) {
- $this->_determineI5();
- }
-
- return (bool) $this->_isI5;
- }
-
- /**
- * Check the connection parameters according to verify
- * type of used OS
- *
- * @return void
- */
- protected function _determineI5()
- {
- // first us the compiled flag.
- $this->_isI5 = (php_uname('s') == 'OS400') ? true : false;
-
- // if this is set, then us it
- if (isset($this->_config['os'])){
- if (strtolower($this->_config['os']) === 'i5') {
- $this->_isI5 = true;
- } else {
- // any other value passed in, its null
- $this->_isI5 = false;
- }
- }
-
- }
-
- /**
- * Db2 On I5 specific method
- *
- * Returns a list of the tables in the database .
- * Used only for DB2/400.
- *
- * @return array
- */
- protected function _i5listTables($schema = null)
- {
- //list of i5 libraries.
- $tables = array();
- if ($schema) {
- $tablesStatement = db2_tables($this->_connection, null, $schema);
- while ($rowTables = db2_fetch_assoc($tablesStatement) ) {
- if ($rowTables['TABLE_NAME'] !== null) {
- $tables[] = $rowTables['TABLE_NAME'];
- }
- }
- } else {
- $schemaStatement = db2_tables($this->_connection);
- while ($schema = db2_fetch_assoc($schemaStatement)) {
- if ($schema['TABLE_SCHEM'] !== null) {
- // list of the tables which belongs to the selected library
- $tablesStatement = db2_tables($this->_connection, NULL, $schema['TABLE_SCHEM']);
- if (is_resource($tablesStatement)) {
- while ($rowTables = db2_fetch_assoc($tablesStatement) ) {
- if ($rowTables['TABLE_NAME'] !== null) {
- $tables[] = $rowTables['TABLE_NAME'];
- }
- }
- }
- }
- }
- }
-
- return $tables;
- }
-
- protected function _i5LastInsertId($objectName = null, $idType = null)
- {
-
- if ($objectName === null) {
- $sql = 'SELECT IDENTITY_VAL_LOCAL() AS VAL FROM QSYS2.QSQPTABL';
- $value = $this->fetchOne($sql);
- return $value;
- }
-
- if (strtoupper($idType) === 'S'){
- //check i5_lib option
- $sequenceName = $objectName;
- return $this->lastSequenceId($sequenceName);
- }
-
- //returns last identity value for the specified table
- //if (strtoupper($idType) === 'I') {
- $tableName = $objectName;
- return $this->fetchOne('SELECT IDENTITY_VAL_LOCAL() from ' . $this->quoteIdentifier($tableName));
- }
-
-}
-
-
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/ConnectionInterface.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/ConnectionInterface.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/ConnectionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/ConnectionInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,85 @@
+driver = $driver;
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ abstract public function getName();
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Feature/DriverFeatureInterface.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Feature/DriverFeatureInterface.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Feature/DriverFeatureInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Feature/DriverFeatureInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,37 @@
+setConnectionParameters($connectionParameters);
+ } elseif (is_resource($connectionParameters)) {
+ $this->setResource($connectionParameters);
+ } elseif (null !== $connectionParameters) {
+ throw new Exception\InvalidArgumentException(
+ '$connection must be an array of parameters, a db2 connection resource or null'
+ );
+ }
+ }
+
+ /**
+ * Set driver
+ *
+ * @param IbmDb2 $driver
+ * @return Connection
+ */
+ public function setDriver(IbmDb2 $driver)
+ {
+ $this->driver = $driver;
+ return $this;
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Connection
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * @param array $connectionParameters
+ * @return Connection
+ */
+ public function setConnectionParameters(array $connectionParameters)
+ {
+ $this->connectionParameters = $connectionParameters;
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getConnectionParameters()
+ {
+ return $this->connectionParameters;
+ }
+
+ /**
+ * @param resource $resource DB2 resource
+ * @return Connection
+ */
+ public function setResource($resource)
+ {
+ if (!is_resource($resource) || get_resource_type($resource) !== 'DB2 Connection') {
+ throw new Exception\InvalidArgumentException('The resource provided must be of type "DB2 Connection"');
+ }
+ $this->resource = $resource;
+ return $this;
+ }
+
+ /**
+ * Get current schema
+ *
+ * @return string
+ */
+ public function getCurrentSchema()
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ $info = db2_server_info($this->resource);
+ return (isset($info->DB_NAME) ? $info->DB_NAME : '');
+ }
+
+ /**
+ * Get resource
+ *
+ * @return mixed
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * Connect
+ *
+ * @return ConnectionInterface
+ */
+ public function connect()
+ {
+ if (is_resource($this->resource)) {
+ return $this;
+ }
+
+ // localize
+ $p = $this->connectionParameters;
+
+ // given a list of key names, test for existence in $p
+ $findParameterValue = function (array $names) use ($p) {
+ foreach ($names as $name) {
+ if (isset($p[$name])) {
+ return $p[$name];
+ }
+ }
+ return null;
+ };
+
+ $database = $findParameterValue(array('database', 'db'));
+ $username = $findParameterValue(array('username', 'uid', 'UID'));
+ $password = $findParameterValue(array('password', 'pwd', 'PWD'));
+ $isPersistent = $findParameterValue(array('persistent', 'PERSISTENT', 'Persistent'));
+ $options = (isset($p['driver_options']) ? $p['driver_options'] : array());
+
+ if ($isPersistent) {
+ $this->resource = db2_pconnect($database, $username, $password, $options);
+ } else {
+ $this->resource = db2_connect($database, $username, $password, $options);
+ }
+
+ if ($this->resource === false) {
+ throw new Exception\RuntimeException(sprintf(
+ '%s: Unable to connect to database',
+ __METHOD__
+ ));
+ }
+ return $this;
+ }
+
+ /**
+ * Is connected
+ *
+ * @return bool
+ */
+ public function isConnected()
+ {
+ return ($this->resource !== null);
+ }
+
+ /**
+ * Disconnect
+ *
+ * @return ConnectionInterface
+ */
+ public function disconnect()
+ {
+ if ($this->resource) {
+ db2_close($this->resource);
+ $this->resource = null;
+ }
+ return $this;
+ }
+
+ /**
+ * Begin transaction
+ *
+ * @return ConnectionInterface
+ */
+ public function beginTransaction()
+ {
+ // TODO: Implement beginTransaction() method.
+ }
+
+ /**
+ * Commit
+ *
+ * @return ConnectionInterface
+ */
+ public function commit()
+ {
+ // TODO: Implement commit() method.
+ }
+
+ /**
+ * Rollback
+ *
+ * @return ConnectionInterface
+ */
+ public function rollback()
+ {
+ // TODO: Implement rollback() method.
+ }
+
+ /**
+ * Execute
+ *
+ * @param string $sql
+ * @return Result
+ */
+ public function execute($sql)
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ if ($this->profiler) {
+ $this->profiler->profilerStart($sql);
+ }
+
+ set_error_handler(function () {}, E_WARNING); // suppress warnings
+ $resultResource = db2_exec($this->resource, $sql);
+ restore_error_handler();
+
+ if ($this->profiler) {
+ $this->profiler->profilerFinish($sql);
+ }
+
+ // if the returnValue is something other than a pg result resource, bypass wrapping it
+ if ($resultResource === false) {
+ throw new Exception\InvalidQueryException(db2_stmt_errormsg());
+ }
+
+ $resultPrototype = $this->driver->createResult(($resultResource === true) ? $this->resource : $resultResource);
+ return $resultPrototype;
+ }
+
+ /**
+ * Get last generated id
+ *
+ * @param null $name Ignored
+ * @return int
+ */
+ public function getLastGeneratedValue($name = null)
+ {
+ return db2_last_insert_id($this->resource);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/IbmDb2/IbmDb2.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/IbmDb2/IbmDb2.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/IbmDb2/IbmDb2.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/IbmDb2/IbmDb2.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,214 @@
+registerConnection($connection);
+ $this->registerStatementPrototype(($statementPrototype) ?: new Statement());
+ $this->registerResultPrototype(($resultPrototype) ?: new Result());
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return IbmDb2
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ if ($this->connection instanceof Profiler\ProfilerAwareInterface) {
+ $this->connection->setProfiler($profiler);
+ }
+ if ($this->statementPrototype instanceof Profiler\ProfilerAwareInterface) {
+ $this->statementPrototype->setProfiler($profiler);
+ }
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * @param Connection $connection
+ * @return IbmDb2
+ */
+ public function registerConnection(Connection $connection)
+ {
+ $this->connection = $connection;
+ $this->connection->setDriver($this);
+ return $this;
+ }
+
+ /**
+ * @param Statement $statementPrototype
+ * @return IbmDb2
+ */
+ public function registerStatementPrototype(Statement $statementPrototype)
+ {
+ $this->statementPrototype = $statementPrototype;
+ $this->statementPrototype->setDriver($this);
+ return $this;
+ }
+
+ /**
+ * @param Result $resultPrototype
+ * @return IbmDb2
+ */
+ public function registerResultPrototype(Result $resultPrototype)
+ {
+ $this->resultPrototype = $resultPrototype;
+ return $this;
+ }
+
+ /**
+ * Get database platform name
+ *
+ * @param string $nameFormat
+ * @return string
+ */
+ public function getDatabasePlatformName($nameFormat = self::NAME_FORMAT_CAMELCASE)
+ {
+ if ($nameFormat == self::NAME_FORMAT_CAMELCASE) {
+ return 'IbmDb2';
+ } else {
+ return 'IBM DB2';
+ }
+ }
+
+ /**
+ * Check environment
+ *
+ * @return bool
+ */
+ public function checkEnvironment()
+ {
+ if (!extension_loaded('ibm_db2')) {
+ throw new Exception\RuntimeException('The ibm_db2 extension is required by this driver.');
+ }
+ }
+
+ /**
+ * Get connection
+ *
+ * @return Connection
+ */
+ public function getConnection()
+ {
+ return $this->connection;
+ }
+
+ /**
+ * Create statement
+ *
+ * @param string|resource $sqlOrResource
+ * @return Statement
+ */
+ public function createStatement($sqlOrResource = null)
+ {
+ $statement = clone $this->statementPrototype;
+ if (is_resource($sqlOrResource) && get_resource_type($sqlOrResource) == 'DB2 Statement') {
+ $statement->setResource($sqlOrResource);
+ } else {
+ if (is_string($sqlOrResource)) {
+ $statement->setSql($sqlOrResource);
+ } elseif ($sqlOrResource !== null) {
+ throw new Exception\InvalidArgumentException(
+ __FUNCTION__ . ' only accepts an SQL string or a ibm_db2 resource'
+ );
+ }
+ if (!$this->connection->isConnected()) {
+ $this->connection->connect();
+ }
+ $statement->initialize($this->connection->getResource());
+ }
+ return $statement;
+ }
+
+ /**
+ * Create result
+ *
+ * @param resource $resource
+ * @return Result
+ */
+ public function createResult($resource)
+ {
+ $result = clone $this->resultPrototype;
+ $result->initialize($resource, $this->connection->getLastGeneratedValue());
+ return $result;
+ }
+
+ /**
+ * Get prepare type
+ *
+ * @return array
+ */
+ public function getPrepareType()
+ {
+ return self::PARAMETERIZATION_POSITIONAL;
+ }
+
+ /**
+ * Format parameter name
+ *
+ * @param string $name
+ * @param mixed $type
+ * @return string
+ */
+ public function formatParameterName($name, $type = null)
+ {
+ return '?';
+ }
+
+ /**
+ * Get last generated value
+ *
+ * @return mixed
+ */
+ public function getLastGeneratedValue()
+ {
+ return $this->connection->getLastGeneratedValue();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/IbmDb2/Result.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/IbmDb2/Result.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/IbmDb2/Result.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/IbmDb2/Result.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,192 @@
+resource = $resource;
+ $this->generatedValue = $generatedValue;
+ return $this;
+ }
+
+ /**
+ * (PHP 5 >= 5.0.0)
+ * Return the current element
+ * @link http://php.net/manual/en/iterator.current.php
+ * @return mixed Can return any type.
+ */
+ public function current()
+ {
+ if ($this->currentComplete) {
+ return $this->currentData;
+ }
+
+ $this->currentData = db2_fetch_assoc($this->resource);
+ return $this->currentData;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function next()
+ {
+ $this->currentData = db2_fetch_assoc($this->resource);
+ $this->currentComplete = true;
+ $this->position++;
+ return $this->currentData;
+ }
+
+ /**
+ * @return int|string
+ */
+ public function key()
+ {
+ return $this->position;
+ }
+
+ /**
+ * @return bool
+ */
+ public function valid()
+ {
+ return ($this->currentData !== false);
+ }
+
+ /**
+ * (PHP 5 >= 5.0.0)
+ * Rewind the Iterator to the first element
+ * @link http://php.net/manual/en/iterator.rewind.php
+ * @return void Any returned value is ignored.
+ */
+ public function rewind()
+ {
+ if ($this->position > 0) {
+ throw new Exception\RuntimeException(
+ 'This result is a forward only result set, calling rewind() after moving forward is not supported'
+ );
+ }
+ $this->currentData = db2_fetch_assoc($this->resource);
+ $this->currentComplete = true;
+ $this->position = 1;
+ }
+
+ /**
+ * Force buffering
+ *
+ * @return void
+ */
+ public function buffer()
+ {
+ return null;
+ }
+
+ /**
+ * Check if is buffered
+ *
+ * @return bool|null
+ */
+ public function isBuffered()
+ {
+ return false;
+ }
+
+ /**
+ * Is query result?
+ *
+ * @return bool
+ */
+ public function isQueryResult()
+ {
+ return (db2_num_fields($this->resource) > 0);
+ }
+
+ /**
+ * Get affected rows
+ *
+ * @return int
+ */
+ public function getAffectedRows()
+ {
+ return db2_num_rows($this->resource);
+ }
+
+ /**
+ * Get generated value
+ *
+ * @return mixed|null
+ */
+ public function getGeneratedValue()
+ {
+ return $this->generatedValue;
+ }
+
+ /**
+ * Get the resource
+ *
+ * @return mixed
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * Get field count
+ *
+ * @return int
+ */
+ public function getFieldCount()
+ {
+ return db2_num_fields($this->resource);
+ }
+
+ /**
+ * @return null|int
+ */
+ public function count()
+ {
+ return null;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/IbmDb2/Statement.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/IbmDb2/Statement.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/IbmDb2/Statement.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/IbmDb2/Statement.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,240 @@
+db2 = $resource;
+ return $this;
+ }
+
+ /**
+ * @param IbmDb2 $driver
+ * @return Statement
+ */
+ public function setDriver(IbmDb2 $driver)
+ {
+ $this->driver = $driver;
+ return $this;
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Statement
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Set sql
+ *
+ * @param $sql
+ * @return mixed
+ */
+ public function setSql($sql)
+ {
+ $this->sql = $sql;
+ return $this;
+ }
+
+ /**
+ * Get sql
+ *
+ * @return mixed
+ */
+ public function getSql()
+ {
+ return $this->sql;
+ }
+
+ /**
+ * Set parameter container
+ *
+ * @param ParameterContainer $parameterContainer
+ * @return mixed
+ */
+ public function setParameterContainer(ParameterContainer $parameterContainer)
+ {
+ $this->parameterContainer = $parameterContainer;
+ return $this;
+ }
+
+ /**
+ * Get parameter container
+ *
+ * @return mixed
+ */
+ public function getParameterContainer()
+ {
+ return $this->parameterContainer;
+ }
+
+ /**
+ * @param $resource
+ * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException
+ */
+ public function setResource($resource)
+ {
+ if (get_resource_type($resource) !== 'DB2 Statement') {
+ throw new Exception\InvalidArgumentException('Resource must be of type DB2 Statement');
+ }
+ $this->resource = $resource;
+ }
+
+ /**
+ * Get resource
+ *
+ * @return resource
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * Prepare sql
+ *
+ * @param string|null $sql
+ * @return Statement
+ */
+ public function prepare($sql = null)
+ {
+ if ($this->isPrepared) {
+ throw new Exception\RuntimeException('This statement has been prepared already');
+ }
+
+ if ($sql == null) {
+ $sql = $this->sql;
+ }
+
+ $this->resource = db2_prepare($this->db2, $sql);
+
+ if ($this->resource === false) {
+ throw new Exception\RuntimeException(db2_stmt_errormsg(), db2_stmt_error());
+ }
+
+ $this->isPrepared = true;
+ return $this;
+ }
+
+ /**
+ * Check if is prepared
+ *
+ * @return bool
+ */
+ public function isPrepared()
+ {
+ return $this->isPrepared;
+ }
+
+ /**
+ * Execute
+ *
+ * @param null $parameters
+ * @return Result
+ */
+ public function execute($parameters = null)
+ {
+ if (!$this->isPrepared) {
+ $this->prepare();
+ }
+
+ /** START Standard ParameterContainer Merging Block */
+ if (!$this->parameterContainer instanceof ParameterContainer) {
+ if ($parameters instanceof ParameterContainer) {
+ $this->parameterContainer = $parameters;
+ $parameters = null;
+ } else {
+ $this->parameterContainer = new ParameterContainer();
+ }
+ }
+
+ if (is_array($parameters)) {
+ $this->parameterContainer->setFromArray($parameters);
+ }
+ /** END Standard ParameterContainer Merging Block */
+
+ if ($this->profiler) {
+ $this->profiler->profilerStart($this);
+ }
+
+ set_error_handler(function () {}, E_WARNING); // suppress warnings
+ $response = db2_execute($this->resource, $this->parameterContainer->getPositionalArray());
+ restore_error_handler();
+
+ if ($this->profiler) {
+ $this->profiler->profilerFinish();
+ }
+
+ if ($response === false) {
+ throw new Exception\RuntimeException(db2_stmt_errormsg($this->resource));
+ }
+
+ $result = $this->driver->createResult($this->resource);
+ return $result;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Mysqli/Connection.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Mysqli/Connection.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Mysqli/Connection.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Mysqli/Connection.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,337 @@
+setConnectionParameters($connectionInfo);
+ } elseif ($connectionInfo instanceof \mysqli) {
+ $this->setResource($connectionInfo);
+ } elseif (null !== $connectionInfo) {
+ throw new Exception\InvalidArgumentException('$connection must be an array of parameters, a mysqli object or null');
+ }
+ }
+
+ /**
+ * @param Mysqli $driver
+ * @return Connection
+ */
+ public function setDriver(Mysqli $driver)
+ {
+ $this->driver = $driver;
+ return $this;
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Connection
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Set connection parameters
+ *
+ * @param array $connectionParameters
+ * @return Connection
+ */
+ public function setConnectionParameters(array $connectionParameters)
+ {
+ $this->connectionParameters = $connectionParameters;
+ return $this;
+ }
+
+ /**
+ * Get connection parameters
+ *
+ * @return array
+ */
+ public function getConnectionParameters()
+ {
+ return $this->connectionParameters;
+ }
+
+ /**
+ * Get current schema
+ *
+ * @return string
+ */
+ public function getCurrentSchema()
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ /** @var $result \mysqli_result */
+ $result = $this->resource->query('SELECT DATABASE()');
+ $r = $result->fetch_row();
+ return $r[0];
+ }
+
+ /**
+ * Set resource
+ *
+ * @param \mysqli $resource
+ * @return Connection
+ */
+ public function setResource(\mysqli $resource)
+ {
+ $this->resource = $resource;
+ return $this;
+ }
+
+ /**
+ * Get resource
+ *
+ * @return \mysqli
+ */
+ public function getResource()
+ {
+ $this->connect();
+ return $this->resource;
+ }
+
+ /**
+ * Connect
+ *
+ * @throws Exception\RuntimeException
+ * @return Connection
+ */
+ public function connect()
+ {
+ if ($this->resource instanceof \mysqli) {
+ return $this;
+ }
+
+ // localize
+ $p = $this->connectionParameters;
+
+ // given a list of key names, test for existence in $p
+ $findParameterValue = function (array $names) use ($p) {
+ foreach ($names as $name) {
+ if (isset($p[$name])) {
+ return $p[$name];
+ }
+ }
+ return;
+ };
+
+ $hostname = $findParameterValue(array('hostname', 'host'));
+ $username = $findParameterValue(array('username', 'user'));
+ $password = $findParameterValue(array('password', 'passwd', 'pw'));
+ $database = $findParameterValue(array('database', 'dbname', 'db', 'schema'));
+ $port = (isset($p['port'])) ? (int) $p['port'] : null;
+ $socket = (isset($p['socket'])) ? $p['socket'] : null;
+
+ $this->resource = new \mysqli();
+ $this->resource->init();
+
+ if (!empty($p['driver_options'])) {
+ foreach ($p['driver_options'] as $option => $value) {
+ if (is_string($option)) {
+ $option = strtoupper($option);
+ if (!defined($option)) {
+ continue;
+ }
+ $option = constant($option);
+ }
+ $this->resource->options($option, $value);
+ }
+ }
+
+ $this->resource->real_connect($hostname, $username, $password, $database, $port, $socket);
+
+ if ($this->resource->connect_error) {
+ throw new Exception\RuntimeException(
+ 'Connection error',
+ null,
+ new Exception\ErrorException($this->resource->connect_error, $this->resource->connect_errno)
+ );
+ }
+
+ if (!empty($p['charset'])) {
+ $this->resource->set_charset($p['charset']);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Is connected
+ *
+ * @return bool
+ */
+ public function isConnected()
+ {
+ return ($this->resource instanceof \mysqli);
+ }
+
+ /**
+ * Disconnect
+ *
+ * @return void
+ */
+ public function disconnect()
+ {
+ if ($this->resource instanceof \mysqli) {
+ $this->resource->close();
+ }
+ unset($this->resource);
+ }
+
+ /**
+ * Begin transaction
+ *
+ * @return void
+ */
+ public function beginTransaction()
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ $this->resource->autocommit(false);
+ $this->inTransaction = true;
+ }
+
+ /**
+ * Commit
+ *
+ * @return void
+ */
+ public function commit()
+ {
+ if (!$this->resource) {
+ $this->connect();
+ }
+
+ $this->resource->commit();
+ $this->inTransaction = false;
+ $this->resource->autocommit(true);
+ }
+
+ /**
+ * Rollback
+ *
+ * @throws Exception\RuntimeException
+ * @return Connection
+ */
+ public function rollback()
+ {
+ if (!$this->resource) {
+ throw new Exception\RuntimeException('Must be connected before you can rollback.');
+ }
+
+ if (!$this->inTransaction) {
+ throw new Exception\RuntimeException('Must call commit() before you can rollback.');
+ }
+
+ $this->resource->rollback();
+ $this->resource->autocommit(true);
+ return $this;
+ }
+
+ /**
+ * Execute
+ *
+ * @param string $sql
+ * @throws Exception\InvalidQueryException
+ * @return Result
+ */
+ public function execute($sql)
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ if ($this->profiler) {
+ $this->profiler->profilerStart($sql);
+ }
+
+ $resultResource = $this->resource->query($sql);
+
+ if ($this->profiler) {
+ $this->profiler->profilerFinish($sql);
+ }
+
+ // if the returnValue is something other than a mysqli_result, bypass wrapping it
+ if ($resultResource === false) {
+ throw new Exception\InvalidQueryException($this->resource->error);
+ }
+
+ $resultPrototype = $this->driver->createResult(($resultResource === true) ? $this->resource : $resultResource);
+ return $resultPrototype;
+ }
+
+ /**
+ * Get last generated id
+ *
+ * @param null $name Ignored
+ * @return int
+ */
+ public function getLastGeneratedValue($name = null)
+ {
+ return $this->resource->insert_id;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Mysqli/Mysqli.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Mysqli/Mysqli.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Mysqli/Mysqli.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Mysqli/Mysqli.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,257 @@
+ false
+ );
+
+ /**
+ * Constructor
+ *
+ * @param array|Connection|\mysqli $connection
+ * @param null|Statement $statementPrototype
+ * @param null|Result $resultPrototype
+ * @param array $options
+ */
+ public function __construct($connection, Statement $statementPrototype = null, Result $resultPrototype = null, array $options = array())
+ {
+ if (!$connection instanceof Connection) {
+ $connection = new Connection($connection);
+ }
+
+ $options = array_intersect_key(array_merge($this->options, $options), $this->options);
+
+ $this->registerConnection($connection);
+ $this->registerStatementPrototype(($statementPrototype) ?: new Statement($options['buffer_results']));
+ $this->registerResultPrototype(($resultPrototype) ?: new Result());
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Mysqli
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ if ($this->connection instanceof Profiler\ProfilerAwareInterface) {
+ $this->connection->setProfiler($profiler);
+ }
+ if ($this->statementPrototype instanceof Profiler\ProfilerAwareInterface) {
+ $this->statementPrototype->setProfiler($profiler);
+ }
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Register connection
+ *
+ * @param Connection $connection
+ * @return Mysqli
+ */
+ public function registerConnection(Connection $connection)
+ {
+ $this->connection = $connection;
+ $this->connection->setDriver($this); // needs access to driver to createStatement()
+ return $this;
+ }
+
+ /**
+ * Register statement prototype
+ *
+ * @param Statement $statementPrototype
+ */
+ public function registerStatementPrototype(Statement $statementPrototype)
+ {
+ $this->statementPrototype = $statementPrototype;
+ $this->statementPrototype->setDriver($this); // needs access to driver to createResult()
+ }
+
+ /**
+ * Get statement prototype
+ *
+ * @return null|Statement
+ */
+ public function getStatementPrototype()
+ {
+ return $this->statementPrototype;
+ }
+
+ /**
+ * Register result prototype
+ *
+ * @param Result $resultPrototype
+ */
+ public function registerResultPrototype(Result $resultPrototype)
+ {
+ $this->resultPrototype = $resultPrototype;
+ }
+
+ /**
+ * @return null|Result
+ */
+ public function getResultPrototype()
+ {
+ return $this->resultPrototype;
+ }
+
+ /**
+ * Get database platform name
+ *
+ * @param string $nameFormat
+ * @return string
+ */
+ public function getDatabasePlatformName($nameFormat = self::NAME_FORMAT_CAMELCASE)
+ {
+ if ($nameFormat == self::NAME_FORMAT_CAMELCASE) {
+ return 'Mysql';
+ }
+
+ return 'MySQL';
+ }
+
+ /**
+ * Check environment
+ *
+ * @throws Exception\RuntimeException
+ * @return void
+ */
+ public function checkEnvironment()
+ {
+ if (!extension_loaded('mysqli')) {
+ throw new Exception\RuntimeException('The Mysqli extension is required for this adapter but the extension is not loaded');
+ }
+ }
+
+ /**
+ * Get connection
+ *
+ * @return Connection
+ */
+ public function getConnection()
+ {
+ return $this->connection;
+ }
+
+ /**
+ * Create statement
+ *
+ * @param string $sqlOrResource
+ * @return Statement
+ */
+ public function createStatement($sqlOrResource = null)
+ {
+ /**
+ * @todo Resource tracking
+ if (is_resource($sqlOrResource) && !in_array($sqlOrResource, $this->resources, true)) {
+ $this->resources[] = $sqlOrResource;
+ }
+ */
+
+ $statement = clone $this->statementPrototype;
+ if ($sqlOrResource instanceof mysqli_stmt) {
+ $statement->setResource($sqlOrResource);
+ } else {
+ if (is_string($sqlOrResource)) {
+ $statement->setSql($sqlOrResource);
+ }
+ if (!$this->connection->isConnected()) {
+ $this->connection->connect();
+ }
+ $statement->initialize($this->connection->getResource());
+ }
+ return $statement;
+ }
+
+ /**
+ * Create result
+ *
+ * @param resource $resource
+ * @param null|bool $isBuffered
+ * @return Result
+ */
+ public function createResult($resource, $isBuffered = null)
+ {
+ $result = clone $this->resultPrototype;
+ $result->initialize($resource, $this->connection->getLastGeneratedValue(), $isBuffered);
+ return $result;
+ }
+
+ /**
+ * Get prepare type
+ *
+ * @return array
+ */
+ public function getPrepareType()
+ {
+ return self::PARAMETERIZATION_POSITIONAL;
+ }
+
+ /**
+ * Format parameter name
+ *
+ * @param string $name
+ * @param mixed $type
+ * @return string
+ */
+ public function formatParameterName($name, $type = null)
+ {
+ return '?';
+ }
+
+ /**
+ * Get last generated value
+ *
+ * @return mixed
+ */
+ public function getLastGeneratedValue()
+ {
+ return $this->getConnection()->getLastGeneratedValue();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Mysqli/Result.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Mysqli/Result.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Mysqli/Result.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Mysqli/Result.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,342 @@
+ null, 'values' => array());
+
+ /**
+ * @var mixed
+ */
+ protected $generatedValue = null;
+
+ /**
+ * Initialize
+ *
+ * @param mixed $resource
+ * @param mixed $generatedValue
+ * @param bool|null $isBuffered
+ * @throws Exception\InvalidArgumentException
+ * @return Result
+ */
+ public function initialize($resource, $generatedValue, $isBuffered = null)
+ {
+ if (!$resource instanceof \mysqli && !$resource instanceof \mysqli_result && !$resource instanceof \mysqli_stmt) {
+ throw new Exception\InvalidArgumentException('Invalid resource provided.');
+ }
+
+ if ($isBuffered !== null) {
+ $this->isBuffered = $isBuffered;
+ } else {
+ if ($resource instanceof \mysqli || $resource instanceof \mysqli_result
+ || $resource instanceof \mysqli_stmt && $resource->num_rows != 0) {
+ $this->isBuffered = true;
+ }
+ }
+
+ $this->resource = $resource;
+ $this->generatedValue = $generatedValue;
+ return $this;
+ }
+
+ /**
+ * Force buffering
+ *
+ * @throws Exception\RuntimeException
+ */
+ public function buffer()
+ {
+ if ($this->resource instanceof \mysqli_stmt && $this->isBuffered !== true) {
+ if ($this->position > 0) {
+ throw new Exception\RuntimeException('Cannot buffer a result set that has started iteration.');
+ }
+ $this->resource->store_result();
+ $this->isBuffered = true;
+ }
+ }
+
+ /**
+ * Check if is buffered
+ *
+ * @return bool|null
+ */
+ public function isBuffered()
+ {
+ return $this->isBuffered;
+ }
+
+ /**
+ * Return the resource
+ *
+ * @return mixed
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * Is query result?
+ *
+ * @return bool
+ */
+ public function isQueryResult()
+ {
+ return ($this->resource->field_count > 0);
+ }
+
+ /**
+ * Get affected rows
+ *
+ * @return int
+ */
+ public function getAffectedRows()
+ {
+ if ($this->resource instanceof \mysqli || $this->resource instanceof \mysqli_stmt) {
+ return $this->resource->affected_rows;
+ }
+
+ return $this->resource->num_rows;
+ }
+
+ /**
+ * Current
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ if ($this->currentComplete) {
+ return $this->currentData;
+ }
+
+ if ($this->resource instanceof \mysqli_stmt) {
+ $this->loadDataFromMysqliStatement();
+ return $this->currentData;
+ } else {
+ $this->loadFromMysqliResult();
+ return $this->currentData;
+ }
+ }
+
+ /**
+ * Mysqli's binding and returning of statement values
+ *
+ * Mysqli requires you to bind variables to the extension in order to
+ * get data out. These values have to be references:
+ * @see http://php.net/manual/en/mysqli-stmt.bind-result.php
+ *
+ * @throws Exception\RuntimeException
+ * @return bool
+ */
+ protected function loadDataFromMysqliStatement()
+ {
+ $data = null;
+ // build the default reference based bind structure, if it does not already exist
+ if ($this->statementBindValues['keys'] === null) {
+ $this->statementBindValues['keys'] = array();
+ $resultResource = $this->resource->result_metadata();
+ foreach ($resultResource->fetch_fields() as $col) {
+ $this->statementBindValues['keys'][] = $col->name;
+ }
+ $this->statementBindValues['values'] = array_fill(0, count($this->statementBindValues['keys']), null);
+ $refs = array();
+ foreach ($this->statementBindValues['values'] as $i => &$f) {
+ $refs[$i] = &$f;
+ }
+ call_user_func_array(array($this->resource, 'bind_result'), $this->statementBindValues['values']);
+ }
+
+ if (($r = $this->resource->fetch()) === null) {
+ if (!$this->isBuffered) {
+ $this->resource->close();
+ }
+ return false;
+ } elseif ($r === false) {
+ throw new Exception\RuntimeException($this->resource->error);
+ }
+
+ // dereference
+ for ($i = 0, $count = count($this->statementBindValues['keys']); $i < $count; $i++) {
+ $this->currentData[$this->statementBindValues['keys'][$i]] = $this->statementBindValues['values'][$i];
+ }
+ $this->currentComplete = true;
+ $this->nextComplete = true;
+ $this->position++;
+ return true;
+ }
+
+ /**
+ * Load from mysqli result
+ *
+ * @return bool
+ */
+ protected function loadFromMysqliResult()
+ {
+ $this->currentData = null;
+
+ if (($data = $this->resource->fetch_assoc()) === null) {
+ return false;
+ }
+
+ $this->position++;
+ $this->currentData = $data;
+ $this->currentComplete = true;
+ $this->nextComplete = true;
+ $this->position++;
+ return true;
+ }
+
+ /**
+ * Next
+ *
+ * @return void
+ */
+ public function next()
+ {
+ $this->currentComplete = false;
+
+ if ($this->nextComplete == false) {
+ $this->position++;
+ }
+
+ $this->nextComplete = false;
+ }
+
+ /**
+ * Key
+ *
+ * @return mixed
+ */
+ public function key()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Rewind
+ *
+ * @throws Exception\RuntimeException
+ * @return void
+ */
+ public function rewind()
+ {
+ if ($this->position !== 0) {
+ if ($this->isBuffered === false) {
+ throw new Exception\RuntimeException('Unbuffered results cannot be rewound for multiple iterations');
+ }
+ }
+ $this->resource->data_seek(0); // works for both mysqli_result & mysqli_stmt
+ $this->currentComplete = false;
+ $this->position = 0;
+ }
+
+ /**
+ * Valid
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ if ($this->currentComplete) {
+ return true;
+ }
+
+ if ($this->resource instanceof \mysqli_stmt) {
+ return $this->loadDataFromMysqliStatement();
+ }
+
+ return $this->loadFromMysqliResult();
+ }
+
+ /**
+ * Count
+ *
+ * @throws Exception\RuntimeException
+ * @return int
+ */
+ public function count()
+ {
+ if ($this->isBuffered === false) {
+ throw new Exception\RuntimeException('Row count is not available in unbuffered result sets.');
+ }
+ return $this->resource->num_rows;
+ }
+
+ /**
+ * Get field count
+ *
+ * @return int
+ */
+ public function getFieldCount()
+ {
+ return $this->resource->field_count;
+ }
+
+ /**
+ * Get generated value
+ *
+ * @return mixed|null
+ */
+ public function getGeneratedValue()
+ {
+ return $this->generatedValue;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Mysqli/Statement.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Mysqli/Statement.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Mysqli/Statement.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Mysqli/Statement.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,316 @@
+bufferResults = (bool) $bufferResults;
+ }
+
+ /**
+ * Set driver
+ *
+ * @param Mysqli $driver
+ * @return Statement
+ */
+ public function setDriver(Mysqli $driver)
+ {
+ $this->driver = $driver;
+ return $this;
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Statement
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Initialize
+ *
+ * @param \mysqli $mysqli
+ * @return Statement
+ */
+ public function initialize(\mysqli $mysqli)
+ {
+ $this->mysqli = $mysqli;
+ return $this;
+ }
+
+ /**
+ * Set sql
+ *
+ * @param string $sql
+ * @return Statement
+ */
+ public function setSql($sql)
+ {
+ $this->sql = $sql;
+ return $this;
+ }
+
+ /**
+ * Set Parameter container
+ *
+ * @param ParameterContainer $parameterContainer
+ * @return Statement
+ */
+ public function setParameterContainer(ParameterContainer $parameterContainer)
+ {
+ $this->parameterContainer = $parameterContainer;
+ return $this;
+ }
+
+ /**
+ * Get resource
+ *
+ * @return mixed
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * Set resource
+ *
+ * @param \mysqli_stmt $mysqliStatement
+ * @return Statement
+ */
+ public function setResource(\mysqli_stmt $mysqliStatement)
+ {
+ $this->resource = $mysqliStatement;
+ $this->isPrepared = true;
+ return $this;
+ }
+
+ /**
+ * Get sql
+ *
+ * @return string
+ */
+ public function getSql()
+ {
+ return $this->sql;
+ }
+
+ /**
+ * Get parameter count
+ *
+ * @return ParameterContainer
+ */
+ public function getParameterContainer()
+ {
+ return $this->parameterContainer;
+ }
+
+ /**
+ * Is prepared
+ *
+ * @return bool
+ */
+ public function isPrepared()
+ {
+ return $this->isPrepared;
+ }
+
+ /**
+ * Prepare
+ *
+ * @param string $sql
+ * @throws Exception\InvalidQueryException
+ * @throws Exception\RuntimeException
+ * @return Statement
+ */
+ public function prepare($sql = null)
+ {
+ if ($this->isPrepared) {
+ throw new Exception\RuntimeException('This statement has already been prepared');
+ }
+
+ $sql = ($sql) ?: $this->sql;
+
+ $this->resource = $this->mysqli->prepare($sql);
+ if (!$this->resource instanceof \mysqli_stmt) {
+ throw new Exception\InvalidQueryException(
+ 'Statement couldn\'t be produced with sql: ' . $sql,
+ null,
+ new Exception\ErrorException($this->mysqli->error, $this->mysqli->errno)
+ );
+ }
+
+ $this->isPrepared = true;
+ return $this;
+ }
+
+ /**
+ * Execute
+ *
+ * @param ParameterContainer|array $parameters
+ * @throws Exception\RuntimeException
+ * @return mixed
+ */
+ public function execute($parameters = null)
+ {
+ if (!$this->isPrepared) {
+ $this->prepare();
+ }
+
+ /** START Standard ParameterContainer Merging Block */
+ if (!$this->parameterContainer instanceof ParameterContainer) {
+ if ($parameters instanceof ParameterContainer) {
+ $this->parameterContainer = $parameters;
+ $parameters = null;
+ } else {
+ $this->parameterContainer = new ParameterContainer();
+ }
+ }
+
+ if (is_array($parameters)) {
+ $this->parameterContainer->setFromArray($parameters);
+ }
+
+ if ($this->parameterContainer->count() > 0) {
+ $this->bindParametersFromContainer();
+ }
+ /** END Standard ParameterContainer Merging Block */
+
+ if ($this->profiler) {
+ $this->profiler->profilerStart($this);
+ }
+
+ $return = $this->resource->execute();
+
+ if ($this->profiler) {
+ $this->profiler->profilerFinish();
+ }
+
+ if ($return === false) {
+ throw new Exception\RuntimeException($this->resource->error);
+ }
+
+ if ($this->bufferResults === true) {
+ $this->resource->store_result();
+ $this->isPrepared = false;
+ $buffered = true;
+ } else {
+ $buffered = false;
+ }
+
+ $result = $this->driver->createResult($this->resource, $buffered);
+ return $result;
+ }
+
+ /**
+ * Bind parameters from container
+ *
+ * @return void
+ */
+ protected function bindParametersFromContainer()
+ {
+ $parameters = $this->parameterContainer->getNamedArray();
+ $type = '';
+ $args = array();
+
+ foreach ($parameters as $name => &$value) {
+ if ($this->parameterContainer->offsetHasErrata($name)) {
+ switch ($this->parameterContainer->offsetGetErrata($name)) {
+ case ParameterContainer::TYPE_DOUBLE:
+ $type .= 'd';
+ break;
+ case ParameterContainer::TYPE_NULL:
+ $value = null; // as per @see http://www.php.net/manual/en/mysqli-stmt.bind-param.php#96148
+ case ParameterContainer::TYPE_INTEGER:
+ $type .= 'i';
+ break;
+ case ParameterContainer::TYPE_STRING:
+ default:
+ $type .= 's';
+ break;
+ }
+ } else {
+ $type .= 's';
+ }
+ $args[] = &$value;
+ }
+
+ if ($args) {
+ array_unshift($args, $type);
+ call_user_func_array(array($this->resource, 'bind_param'), $args);
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Oci8/Connection.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Oci8/Connection.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Oci8/Connection.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Oci8/Connection.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,346 @@
+setConnectionParameters($connectionInfo);
+ } elseif ($connectionInfo instanceof \oci8) {
+ $this->setResource($connectionInfo);
+ } elseif (null !== $connectionInfo) {
+ throw new Exception\InvalidArgumentException('$connection must be an array of parameters, a oci8 resource or null');
+ }
+ }
+
+ /**
+ * @param Oci8 $driver
+ * @return Connection
+ */
+ public function setDriver(Oci8 $driver)
+ {
+ $this->driver = $driver;
+ return $this;
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Connection
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Set connection parameters
+ *
+ * @param array $connectionParameters
+ * @return Connection
+ */
+ public function setConnectionParameters(array $connectionParameters)
+ {
+ $this->connectionParameters = $connectionParameters;
+ return $this;
+ }
+
+ /**
+ * Get connection parameters
+ *
+ * @return array
+ */
+ public function getConnectionParameters()
+ {
+ return $this->connectionParameters;
+ }
+
+ /**
+ * Get current schema
+ *
+ * @return string
+ */
+ public function getCurrentSchema()
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ $query = "SELECT sys_context('USERENV', 'CURRENT_SCHEMA') as \"current_schema\" FROM DUAL";
+ $stmt = oci_parse($this->resource, $query);
+ oci_execute($stmt);
+ $dbNameArray = oci_fetch_array($stmt, OCI_ASSOC);
+ return $dbNameArray['current_schema'];
+ }
+
+ /**
+ * Set resource
+ *
+ * @param resource $resource
+ * @return Connection
+ */
+ public function setResource($resource)
+ {
+ if (!is_resource($resource) || get_resource_type($resource) !== 'oci8 connection') {
+ throw new Exception\InvalidArgumentException('A resource of type "oci8 connection" was expected');
+ }
+ $this->resource = $resource;
+ return $this;
+ }
+
+ /**
+ * Get resource
+ *
+ * @return \oci8
+ */
+ public function getResource()
+ {
+ $this->connect();
+ return $this->resource;
+ }
+
+ /**
+ * Connect
+ *
+ * @return Connection
+ */
+ public function connect()
+ {
+ if (is_resource($this->resource)) {
+ return $this;
+ }
+
+ // localize
+ $p = $this->connectionParameters;
+
+ // given a list of key names, test for existence in $p
+ $findParameterValue = function (array $names) use ($p) {
+ foreach ($names as $name) {
+ if (isset($p[$name])) {
+ return $p[$name];
+ }
+ }
+ return null;
+ };
+
+ // http://www.php.net/manual/en/function.oci-connect.php
+ $username = $findParameterValue(array('username'));
+ $password = $findParameterValue(array('password'));
+ $connectionString = $findParameterValue(array('connection_string', 'connectionstring', 'connection', 'hostname', 'instance'));
+ $characterSet = $findParameterValue(array('character_set', 'charset', 'encoding'));
+ $sessionMode = $findParameterValue(array('session_mode'));
+
+ // connection modifiers
+ $isUnique = $findParameterValue(array('unique'));
+ $isPersistent = $findParameterValue(array('persistent'));
+
+ if ($isUnique == true) {
+ $this->resource = oci_new_connect($username, $password, $connectionString, $characterSet, $sessionMode);
+ } elseif ($isPersistent == true) {
+ $this->resource = oci_pconnect($username, $password, $connectionString, $characterSet, $sessionMode);
+ } else {
+ $this->resource = oci_connect($username, $password, $connectionString, $characterSet, $sessionMode);
+ }
+
+ if (!$this->resource) {
+ $e = oci_error();
+ throw new Exception\RuntimeException(
+ 'Connection error',
+ null,
+ new Exception\ErrorException($e['message'], $e['code'])
+ );
+ }
+
+ return $this;
+ }
+
+ /**
+ * Is connected
+ *
+ * @return bool
+ */
+ public function isConnected()
+ {
+ return (is_resource($this->resource));
+ }
+
+ /**
+ * Disconnect
+ */
+ public function disconnect()
+ {
+ if (is_resource($this->resource)) {
+ oci_close($this->resource);
+ }
+ }
+
+ /**
+ * Begin transaction
+ */
+ public function beginTransaction()
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ // A transaction begins when the first SQL statement that changes data is executed with oci_execute() using the OCI_NO_AUTO_COMMIT flag.
+ $this->inTransaction = true;
+ }
+
+ /**
+ * In transaction
+ *
+ * @return bool
+ */
+ public function inTransaction()
+ {
+ return $this->inTransaction;
+ }
+
+ /**
+ * Commit
+ */
+ public function commit()
+ {
+ if (!$this->resource) {
+ $this->connect();
+ }
+
+ if ($this->inTransaction) {
+ $valid = oci_commit($this->resource);
+ if ($valid === false) {
+ $e = oci_error($this->resource);
+ throw new Exception\InvalidQueryException($e['message'], $e['code']);
+ }
+ }
+ }
+
+ /**
+ * Rollback
+ *
+ * @return Connection
+ */
+ public function rollback()
+ {
+ if (!$this->resource) {
+ throw new Exception\RuntimeException('Must be connected before you can rollback.');
+ }
+
+ if (!$this->inTransaction) {
+ throw new Exception\RuntimeException('Must call commit() before you can rollback.');
+ }
+
+ $valid = oci_rollback($this->resource);
+ if ($valid === false) {
+ $e = oci_error($this->resource);
+ throw new Exception\InvalidQueryException($e['message'], $e['code']);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Execute
+ *
+ * @param string $sql
+ * @return Result
+ */
+ public function execute($sql)
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ if ($this->profiler) {
+ $this->profiler->profilerStart($sql);
+ }
+
+ $ociStmt = oci_parse($this->resource, $sql);
+
+ if ($this->inTransaction) {
+ $valid = @oci_execute($ociStmt, OCI_NO_AUTO_COMMIT);
+ } else {
+ $valid = @oci_execute($ociStmt, OCI_COMMIT_ON_SUCCESS);
+ }
+
+ if ($this->profiler) {
+ $this->profiler->profilerFinish($sql);
+ }
+
+ if ($valid === false) {
+ $e = oci_error($ociStmt);
+ throw new Exception\InvalidQueryException($e['message'], $e['code']);
+ }
+
+ $resultPrototype = $this->driver->createResult($ociStmt);
+ return $resultPrototype;
+ }
+
+ /**
+ * Get last generated id
+ *
+ * @param null $name Ignored
+ * @return int
+ */
+ public function getLastGeneratedValue($name = null)
+ {
+ // @todo Get Last Generated Value in Connection (this might not apply)
+ return null;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Oci8/Oci8.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Oci8/Oci8.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Oci8/Oci8.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Oci8/Oci8.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,235 @@
+options, $options), $this->options);
+
+ $this->registerConnection($connection);
+ $this->registerStatementPrototype(($statementPrototype) ?: new Statement());
+ $this->registerResultPrototype(($resultPrototype) ?: new Result());
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Oci8
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ if ($this->connection instanceof Profiler\ProfilerAwareInterface) {
+ $this->connection->setProfiler($profiler);
+ }
+ if ($this->statementPrototype instanceof Profiler\ProfilerAwareInterface) {
+ $this->statementPrototype->setProfiler($profiler);
+ }
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Register connection
+ *
+ * @param Connection $connection
+ * @return Oci8
+ */
+ public function registerConnection(Connection $connection)
+ {
+ $this->connection = $connection;
+ $this->connection->setDriver($this); // needs access to driver to createStatement()
+ return $this;
+ }
+
+ /**
+ * Register statement prototype
+ *
+ * @param Statement $statementPrototype
+ * @return Oci8
+ */
+ public function registerStatementPrototype(Statement $statementPrototype)
+ {
+ $this->statementPrototype = $statementPrototype;
+ $this->statementPrototype->setDriver($this); // needs access to driver to createResult()
+ return $this;
+ }
+
+ /**
+ * @return null|Statement
+ */
+ public function getStatementPrototype()
+ {
+ return $this->statementPrototype;
+ }
+
+ /**
+ * Register result prototype
+ *
+ * @param Result $resultPrototype
+ * @return Oci8
+ */
+ public function registerResultPrototype(Result $resultPrototype)
+ {
+ $this->resultPrototype = $resultPrototype;
+ return $this;
+ }
+
+ /**
+ * @return null|Result
+ */
+ public function getResultPrototype()
+ {
+ return $this->resultPrototype;
+ }
+
+ /**
+ * Get database platform name
+ *
+ * @param string $nameFormat
+ * @return string
+ */
+ public function getDatabasePlatformName($nameFormat = self::NAME_FORMAT_CAMELCASE)
+ {
+ return 'Oracle';
+ }
+
+ /**
+ * Check environment
+ */
+ public function checkEnvironment()
+ {
+ if (!extension_loaded('oci8')) {
+ throw new Exception\RuntimeException('The Oci8 extension is required for this adapter but the extension is not loaded');
+ }
+ }
+
+ /**
+ * @return Connection
+ */
+ public function getConnection()
+ {
+ return $this->connection;
+ }
+
+ /**
+ * @param string $sqlOrResource
+ * @return Statement
+ */
+ public function createStatement($sqlOrResource = null)
+ {
+ $statement = clone $this->statementPrototype;
+ if (is_resource($sqlOrResource) && get_resource_type($sqlOrResource) == 'oci8 statement') {
+ $statement->setResource($sqlOrResource);
+ } else {
+ if (is_string($sqlOrResource)) {
+ $statement->setSql($sqlOrResource);
+ } elseif ($sqlOrResource !== null) {
+ throw new Exception\InvalidArgumentException(
+ 'Oci8 only accepts an SQL string or a oci8 resource in ' . __FUNCTION__
+ );
+ }
+ if (!$this->connection->isConnected()) {
+ $this->connection->connect();
+ }
+ $statement->initialize($this->connection->getResource());
+ }
+ return $statement;
+ }
+
+ /**
+ * @param resource $resource
+ * @param null $isBuffered
+ * @return Result
+ */
+ public function createResult($resource, $isBuffered = null)
+ {
+ $result = clone $this->resultPrototype;
+ $result->initialize($resource, $this->connection->getLastGeneratedValue(), $isBuffered);
+ return $result;
+ }
+
+ /**
+ * @return array
+ */
+ public function getPrepareType()
+ {
+ return self::PARAMETERIZATION_NAMED;
+ }
+
+ /**
+ * @param string $name
+ * @param mixed $type
+ * @return string
+ */
+ public function formatParameterName($name, $type = null)
+ {
+ return ':' . $name;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getLastGeneratedValue()
+ {
+ return $this->getConnection()->getLastGeneratedValue();
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Oci8/Result.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Oci8/Result.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Oci8/Result.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Oci8/Result.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,226 @@
+ null, 'values' => array());
+
+ /**
+ * @var mixed
+ */
+ protected $generatedValue = null;
+
+ /**
+ * Initialize
+ * @param resource $resource
+ * @return Result
+ */
+ public function initialize($resource /*, $generatedValue, $isBuffered = null*/)
+ {
+ if (!is_resource($resource) && get_resource_type($resource) !== 'oci8 statement') {
+ throw new Exception\InvalidArgumentException('Invalid resource provided.');
+ }
+ $this->resource = $resource;
+ return $this;
+ }
+
+ /**
+ * Force buffering at driver level
+ *
+ * Oracle does not support this, to my knowledge (@ralphschindler)
+ *
+ * @throws Exception\RuntimeException
+ */
+ public function buffer()
+ {
+ return null;
+ }
+
+ /**
+ * Is the result buffered?
+ *
+ * @return bool
+ */
+ public function isBuffered()
+ {
+ return false;
+ }
+
+ /**
+ * Return the resource
+ * @return mixed
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * Is query result?
+ *
+ * @return bool
+ */
+ public function isQueryResult()
+ {
+ return (oci_num_fields($this->resource) > 0);
+ }
+
+ /**
+ * Get affected rows
+ * @return int
+ */
+ public function getAffectedRows()
+ {
+ return oci_num_rows($this->resource);
+ }
+
+ /**
+ * Current
+ * @return mixed
+ */
+ public function current()
+ {
+ if ($this->currentComplete == false) {
+ if ($this->loadData() === false) {
+ return false;
+ }
+ }
+
+ return $this->currentData;
+ }
+
+ /**
+ * Load from oci8 result
+ *
+ * @return bool
+ */
+ protected function loadData()
+ {
+ $this->currentComplete = true;
+ $this->currentData = oci_fetch_assoc($this->resource);
+
+ if ($this->currentData !== false) {
+ $this->position++;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Next
+ */
+ public function next()
+ {
+ return $this->loadData();
+ }
+
+ /**
+ * Key
+ * @return mixed
+ */
+ public function key()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Rewind
+ */
+ public function rewind()
+ {
+ if ($this->position > 0) {
+ throw new Exception\RuntimeException('Oci8 results cannot be rewound for multiple iterations');
+ }
+ }
+
+ /**
+ * Valid
+ * @return bool
+ */
+ public function valid()
+ {
+ if ($this->currentComplete) {
+ return ($this->currentData !== false);
+ }
+
+ return $this->loadData();
+ }
+
+ /**
+ * Count
+ * @return int
+ */
+ public function count()
+ {
+ // @todo OCI8 row count in Driver Result
+ return null;
+ }
+
+ /**
+ * @return int
+ */
+ public function getFieldCount()
+ {
+ return oci_num_fields($this->resource);
+ }
+
+ /**
+ * @return mixed|null
+ */
+ public function getGeneratedValue()
+ {
+ // @todo OCI8 generated value in Driver Result
+ return null;
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Oci8/Statement.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Oci8/Statement.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Oci8/Statement.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Oci8/Statement.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,307 @@
+driver = $driver;
+ return $this;
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Statement
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Initialize
+ *
+ * @param resource $oci8
+ * @return Statement
+ */
+ public function initialize($oci8)
+ {
+ $this->oci8 = $oci8;
+ return $this;
+ }
+
+ /**
+ * Set sql
+ *
+ * @param string $sql
+ * @return Statement
+ */
+ public function setSql($sql)
+ {
+ $this->sql = $sql;
+ return $this;
+ }
+
+ /**
+ * Set Parameter container
+ *
+ * @param ParameterContainer $parameterContainer
+ * @return Statement
+ */
+ public function setParameterContainer(ParameterContainer $parameterContainer)
+ {
+ $this->parameterContainer = $parameterContainer;
+ return $this;
+ }
+
+ /**
+ * Get resource
+ *
+ * @return mixed
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * Set resource
+ *
+ * @param resource $oci8Statement
+ * @return Statement
+ */
+ public function setResource($oci8Statement)
+ {
+ $type = oci_statement_type($oci8Statement);
+ if (false === $type || 'UNKNOWN' == $type) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Invalid statement provided to %s',
+ __METHOD__
+ ));
+ }
+ $this->resource = $oci8Statement;
+ $this->isPrepared = true;
+ return $this;
+ }
+
+ /**
+ * Get sql
+ *
+ * @return string
+ */
+ public function getSql()
+ {
+ return $this->sql;
+ }
+
+ /**
+ * @return ParameterContainer
+ */
+ public function getParameterContainer()
+ {
+ return $this->parameterContainer;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isPrepared()
+ {
+ return $this->isPrepared;
+ }
+
+ /**
+ * @param string $sql
+ * @return Statement
+ */
+ public function prepare($sql = null)
+ {
+ if ($this->isPrepared) {
+ throw new Exception\RuntimeException('This statement has already been prepared');
+ }
+
+ $sql = ($sql) ?: $this->sql;
+
+ // get oci8 statement resource
+ $this->resource = oci_parse($this->oci8, $sql);
+
+ if (!$this->resource) {
+ $e = oci_error($this->oci8);
+ throw new Exception\InvalidQueryException(
+ 'Statement couldn\'t be produced with sql: ' . $sql,
+ null,
+ new Exception\ErrorException($e['message'], $e['code'])
+ );
+ }
+
+ $this->isPrepared = true;
+ return $this;
+ }
+
+ /**
+ * Execute
+ *
+ * @param ParameterContainer $parameters
+ * @return mixed
+ */
+ public function execute($parameters = null)
+ {
+ if (!$this->isPrepared) {
+ $this->prepare();
+ }
+
+ /** START Standard ParameterContainer Merging Block */
+ if (!$this->parameterContainer instanceof ParameterContainer) {
+ if ($parameters instanceof ParameterContainer) {
+ $this->parameterContainer = $parameters;
+ $parameters = null;
+ } else {
+ $this->parameterContainer = new ParameterContainer();
+ }
+ }
+
+ if (is_array($parameters)) {
+ $this->parameterContainer->setFromArray($parameters);
+ }
+
+ if ($this->parameterContainer->count() > 0) {
+ $this->bindParametersFromContainer();
+ }
+ /** END Standard ParameterContainer Merging Block */
+
+ if ($this->profiler) {
+ $this->profiler->profilerStart($this);
+ }
+
+ if ($this->driver->getConnection()->inTransaction()) {
+ $ret = @oci_execute($this->resource, OCI_NO_AUTO_COMMIT);
+ } else {
+ $ret = @oci_execute($this->resource, OCI_COMMIT_ON_SUCCESS);
+ }
+
+ if ($this->profiler) {
+ $this->profiler->profilerFinish();
+ }
+
+ if ($ret === false) {
+ $e = oci_error($this->resource);
+ throw new Exception\RuntimeException($e['message'], $e['code']);
+ }
+
+ $result = $this->driver->createResult($this->resource);
+ return $result;
+ }
+
+ /**
+ * Bind parameters from container
+ *
+ * @param ParameterContainer $pContainer
+ */
+ protected function bindParametersFromContainer()
+ {
+ $parameters = $this->parameterContainer->getNamedArray();
+
+ foreach ($parameters as $name => &$value) {
+ if ($this->parameterContainer->offsetHasErrata($name)) {
+ switch ($this->parameterContainer->offsetGetErrata($name)) {
+ case ParameterContainer::TYPE_NULL:
+ $type = null;
+ $value = null;
+ break;
+ case ParameterContainer::TYPE_DOUBLE:
+ case ParameterContainer::TYPE_INTEGER:
+ $type = SQLT_INT;
+ if (is_string($value)) {
+ $value = (int) $value;
+ }
+ break;
+ case ParameterContainer::TYPE_BINARY:
+ $type = SQLT_BIN;
+ break;
+ case ParameterContainer::TYPE_STRING:
+ default:
+ $type = SQLT_CHR;
+ break;
+ }
+ } else {
+ $type = SQLT_CHR;
+ }
+
+ oci_bind_by_name($this->resource, $name, $value, -1, $type);
+ }
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pdo/Connection.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pdo/Connection.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pdo/Connection.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pdo/Connection.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,437 @@
+setConnectionParameters($connectionParameters);
+ } elseif ($connectionParameters instanceof \PDO) {
+ $this->setResource($connectionParameters);
+ } elseif (null !== $connectionParameters) {
+ throw new Exception\InvalidArgumentException('$connection must be an array of parameters, a PDO object or null');
+ }
+ }
+
+ /**
+ * Set driver
+ *
+ * @param Pdo $driver
+ * @return Connection
+ */
+ public function setDriver(Pdo $driver)
+ {
+ $this->driver = $driver;
+ return $this;
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Connection
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Get driver name
+ *
+ * @return null|string
+ */
+ public function getDriverName()
+ {
+ return $this->driverName;
+ }
+
+ /**
+ * Set connection parameters
+ *
+ * @param array $connectionParameters
+ * @return void
+ */
+ public function setConnectionParameters(array $connectionParameters)
+ {
+ $this->connectionParameters = $connectionParameters;
+ if (isset($connectionParameters['dsn'])) {
+ $this->driverName = substr($connectionParameters['dsn'], 0,
+ strpos($connectionParameters['dsn'], ':')
+ );
+ } elseif (isset($connectionParameters['pdodriver'])) {
+ $this->driverName = strtolower($connectionParameters['pdodriver']);
+ } elseif (isset($connectionParameters['driver'])) {
+ $this->driverName = strtolower(substr(
+ str_replace(array('-', '_', ' '), '', $connectionParameters['driver']),
+ 3
+ ));
+ }
+ }
+
+ /**
+ * Get connection parameters
+ *
+ * @return array
+ */
+ public function getConnectionParameters()
+ {
+ return $this->connectionParameters;
+ }
+
+ /**
+ * Get current schema
+ *
+ * @return string
+ */
+ public function getCurrentSchema()
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ switch ($this->driverName) {
+ case 'mysql':
+ $sql = 'SELECT DATABASE()';
+ break;
+ case 'sqlite':
+ return 'main';
+ case 'pgsql':
+ default:
+ $sql = 'SELECT CURRENT_SCHEMA';
+ break;
+ }
+
+ /** @var $result \PDOStatement */
+ $result = $this->resource->query($sql);
+ if ($result instanceof \PDOStatement) {
+ return $result->fetchColumn();
+ }
+ return false;
+ }
+
+ /**
+ * Set resource
+ *
+ * @param \PDO $resource
+ * @return Connection
+ */
+ public function setResource(\PDO $resource)
+ {
+ $this->resource = $resource;
+ $this->driverName = strtolower($this->resource->getAttribute(\PDO::ATTR_DRIVER_NAME));
+ return $this;
+ }
+
+ /**
+ * Get resource
+ *
+ * @return \PDO
+ */
+ public function getResource()
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+ return $this->resource;
+ }
+
+ /**
+ * Connect
+ *
+ * @return Connection
+ * @throws Exception\InvalidConnectionParametersException
+ * @throws Exception\RuntimeException
+ */
+ public function connect()
+ {
+ if ($this->resource) {
+ return $this;
+ }
+
+ $dsn = $username = $password = $hostname = $database = null;
+ $options = array();
+ foreach ($this->connectionParameters as $key => $value) {
+ switch (strtolower($key)) {
+ case 'dsn':
+ $dsn = $value;
+ break;
+ case 'driver':
+ $value = strtolower($value);
+ if (strpos($value, 'pdo') === 0) {
+ $pdoDriver = strtolower(substr(str_replace(array('-', '_', ' '), '', $value), 3));
+ }
+ break;
+ case 'pdodriver':
+ $pdoDriver = (string) $value;
+ break;
+ case 'user':
+ case 'username':
+ $username = (string) $value;
+ break;
+ case 'pass':
+ case 'password':
+ $password = (string) $value;
+ break;
+ case 'host':
+ case 'hostname':
+ $hostname = (string) $value;
+ break;
+ case 'port':
+ $port = (int) $value;
+ break;
+ case 'database':
+ case 'dbname':
+ $database = (string) $value;
+ break;
+ case 'driver_options':
+ case 'options':
+ $value = (array) $value;
+ $options = array_diff_key($options, $value) + $value;
+ break;
+ default:
+ $options[$key] = $value;
+ break;
+ }
+ }
+
+ if (!isset($dsn) && isset($pdoDriver)) {
+ $dsn = array();
+ switch ($pdoDriver) {
+ case 'sqlite':
+ $dsn[] = $database;
+ break;
+ default:
+ if (isset($database)) {
+ $dsn[] = "dbname={$database}";
+ }
+ if (isset($hostname)) {
+ $dsn[] = "host={$hostname}";
+ }
+ if (isset($port)) {
+ $dsn[] = "port={$port}";
+ }
+ break;
+ }
+ $dsn = $pdoDriver . ':' . implode(';', $dsn);
+ } elseif (!isset($dsn)) {
+ throw new Exception\InvalidConnectionParametersException(
+ 'A dsn was not provided or could not be constructed from your parameters',
+ $this->connectionParameters
+ );
+ }
+
+ try {
+ $this->resource = new \PDO($dsn, $username, $password, $options);
+ $this->resource->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
+ $this->driverName = strtolower($this->resource->getAttribute(\PDO::ATTR_DRIVER_NAME));
+ } catch (\PDOException $e) {
+ $code = $e->getCode();
+ if (!is_long($code)) {
+ $code = null;
+ }
+ throw new Exception\RuntimeException('Connect Error: ' . $e->getMessage(), $code, $e);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Is connected
+ *
+ * @return bool
+ */
+ public function isConnected()
+ {
+ return ($this->resource instanceof \PDO);
+ }
+
+ /**
+ * Disconnect
+ *
+ * @return Connection
+ */
+ public function disconnect()
+ {
+ if ($this->isConnected()) {
+ $this->resource = null;
+ }
+ return $this;
+ }
+
+ /**
+ * Begin transaction
+ *
+ * @return Connection
+ */
+ public function beginTransaction()
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+ $this->resource->beginTransaction();
+ $this->inTransaction = true;
+ return $this;
+ }
+
+ /**
+ * Commit
+ *
+ * @return Connection
+ */
+ public function commit()
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ $this->resource->commit();
+ $this->inTransaction = false;
+ return $this;
+ }
+
+ /**
+ * Rollback
+ *
+ * @return Connection
+ * @throws Exception\RuntimeException
+ */
+ public function rollback()
+ {
+ if (!$this->isConnected()) {
+ throw new Exception\RuntimeException('Must be connected before you can rollback');
+ }
+
+ if (!$this->inTransaction) {
+ throw new Exception\RuntimeException('Must call beginTransaction() before you can rollback');
+ }
+
+ $this->resource->rollBack();
+ return $this;
+ }
+
+ /**
+ * Execute
+ *
+ * @param $sql
+ * @return Result
+ * @throws Exception\InvalidQueryException
+ */
+ public function execute($sql)
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ if ($this->profiler) {
+ $this->profiler->profilerStart($sql);
+ }
+
+ $resultResource = $this->resource->query($sql);
+
+ if ($this->profiler) {
+ $this->profiler->profilerFinish($sql);
+ }
+
+ if ($resultResource === false) {
+ $errorInfo = $this->resource->errorInfo();
+ throw new Exception\InvalidQueryException($errorInfo[2]);
+ }
+
+ $result = $this->driver->createResult($resultResource, $sql);
+ return $result;
+
+ }
+
+ /**
+ * Prepare
+ *
+ * @param string $sql
+ * @return Statement
+ */
+ public function prepare($sql)
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ $statement = $this->driver->createStatement($sql);
+ return $statement;
+ }
+
+ /**
+ * Get last generated id
+ *
+ * @param string $name
+ * @return string|null|false
+ */
+ public function getLastGeneratedValue($name = null)
+ {
+ if ($name === null && $this->driverName == 'pgsql') {
+ return null;
+ }
+
+ try {
+ return $this->resource->lastInsertId($name);
+ } catch (\Exception $e) {
+ // do nothing
+ }
+ return false;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pdo/Feature/OracleRowCounter.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pdo/Feature/OracleRowCounter.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pdo/Feature/OracleRowCounter.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pdo/Feature/OracleRowCounter.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,80 @@
+getSql();
+ if ($sql == '' || stripos($sql, 'select') === false) {
+ return null;
+ }
+ $countSql = 'SELECT COUNT(*) as "count" FROM (' . $sql . ')';
+ $countStmt->prepare($countSql);
+ $result = $countStmt->execute();
+ $countRow = $result->getResource()->fetch(\PDO::FETCH_ASSOC);
+ unset($statement, $result);
+ return $countRow['count'];
+ }
+
+ /**
+ * @param $sql
+ * @return null|int
+ */
+ public function getCountForSql($sql)
+ {
+ if (!stripos($sql, 'select')) {
+ return null;
+ }
+ $countSql = 'SELECT COUNT(*) as count FROM (' . $sql . ')';
+ /** @var $pdo \PDO */
+ $pdo = $this->pdoDriver->getConnection()->getResource();
+ $result = $pdo->query($countSql);
+ $countRow = $result->fetch(\PDO::FETCH_ASSOC);
+ return $countRow['count'];
+ }
+
+ /**
+ * @param $context
+ * @return closure
+ */
+ public function getRowCountClosure($context)
+ {
+ $oracleRowCounter = $this;
+ return function () use ($oracleRowCounter, $context) {
+ /** @var $oracleRowCounter OracleRowCounter */
+ return ($context instanceof Pdo\Statement)
+ ? $oracleRowCounter->getCountForStatement($context)
+ : $oracleRowCounter->getCountForSql($context);
+ };
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pdo/Feature/SqliteRowCounter.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pdo/Feature/SqliteRowCounter.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pdo/Feature/SqliteRowCounter.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pdo/Feature/SqliteRowCounter.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,79 @@
+getSql();
+ if ($sql == '' || stripos($sql, 'select') === false) {
+ return null;
+ }
+ $countSql = 'SELECT COUNT(*) as "count" FROM (' . $sql . ')';
+ $countStmt->prepare($countSql);
+ $result = $countStmt->execute();
+ $countRow = $result->getResource()->fetch(\PDO::FETCH_ASSOC);
+ unset($statement, $result);
+ return $countRow['count'];
+ }
+
+ /**
+ * @param $sql
+ * @return null|int
+ */
+ public function getCountForSql($sql)
+ {
+ if (!stripos($sql, 'select')) {
+ return null;
+ }
+ $countSql = 'SELECT COUNT(*) as count FROM (' . $sql . ')';
+ /** @var $pdo \PDO */
+ $pdo = $this->pdoDriver->getConnection()->getResource();
+ $result = $pdo->query($countSql);
+ $countRow = $result->fetch(\PDO::FETCH_ASSOC);
+ return $countRow['count'];
+ }
+
+ /**
+ * @param $context
+ * @return closure
+ */
+ public function getRowCountClosure($context)
+ {
+ $sqliteRowCounter = $this;
+ return function () use ($sqliteRowCounter, $context) {
+ /** @var $sqliteRowCounter SqliteRowCounter */
+ return ($context instanceof Pdo\Statement)
+ ? $sqliteRowCounter->getCountForStatement($context)
+ : $sqliteRowCounter->getCountForSql($context);
+ };
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pdo/Pdo.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pdo/Pdo.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pdo/Pdo.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pdo/Pdo.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,309 @@
+registerConnection($connection);
+ $this->registerStatementPrototype(($statementPrototype) ?: new Statement());
+ $this->registerResultPrototype(($resultPrototype) ?: new Result());
+ if (is_array($features)) {
+ foreach ($features as $name => $feature) {
+ $this->addFeature($name, $feature);
+ }
+ } elseif ($features instanceof AbstractFeature) {
+ $this->addFeature($features->getName(), $features);
+ } elseif ($features === self::FEATURES_DEFAULT) {
+ $this->setupDefaultFeatures();
+ }
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Pdo
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ if ($this->connection instanceof Profiler\ProfilerAwareInterface) {
+ $this->connection->setProfiler($profiler);
+ }
+ if ($this->statementPrototype instanceof Profiler\ProfilerAwareInterface) {
+ $this->statementPrototype->setProfiler($profiler);
+ }
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Register connection
+ *
+ * @param Connection $connection
+ * @return Pdo
+ */
+ public function registerConnection(Connection $connection)
+ {
+ $this->connection = $connection;
+ $this->connection->setDriver($this);
+ return $this;
+ }
+
+ /**
+ * Register statement prototype
+ *
+ * @param Statement $statementPrototype
+ */
+ public function registerStatementPrototype(Statement $statementPrototype)
+ {
+ $this->statementPrototype = $statementPrototype;
+ $this->statementPrototype->setDriver($this);
+ }
+
+ /**
+ * Register result prototype
+ *
+ * @param Result $resultPrototype
+ */
+ public function registerResultPrototype(Result $resultPrototype)
+ {
+ $this->resultPrototype = $resultPrototype;
+ }
+
+ /**
+ * Add feature
+ *
+ * @param string $name
+ * @param AbstractFeature $feature
+ * @return Pdo
+ */
+ public function addFeature($name, $feature)
+ {
+ if ($feature instanceof AbstractFeature) {
+ $name = $feature->getName(); // overwrite the name, just in case
+ $feature->setDriver($this);
+ }
+ $this->features[$name] = $feature;
+ return $this;
+ }
+
+ /**
+ * Setup the default features for Pdo
+ *
+ * @return Pdo
+ */
+ public function setupDefaultFeatures()
+ {
+ $driverName = $this->connection->getDriverName();
+ if ($driverName == 'sqlite') {
+ $this->addFeature(null, new Feature\SqliteRowCounter);
+ } elseif ($driverName == 'oci') {
+ $this->addFeature(null, new Feature\OracleRowCounter);
+ }
+ return $this;
+ }
+
+ /**
+ * Get feature
+ *
+ * @param $name
+ * @return AbstractFeature|false
+ */
+ public function getFeature($name)
+ {
+ if (isset($this->features[$name])) {
+ return $this->features[$name];
+ }
+ return false;
+ }
+
+ /**
+ * Get database platform name
+ *
+ * @param string $nameFormat
+ * @return string
+ */
+ public function getDatabasePlatformName($nameFormat = self::NAME_FORMAT_CAMELCASE)
+ {
+ $name = $this->getConnection()->getDriverName();
+ if ($nameFormat == self::NAME_FORMAT_CAMELCASE) {
+ switch ($name) {
+ case 'pgsql':
+ return 'Postgresql';
+ case 'oci':
+ return 'Oracle';
+
+ default:
+ return ucfirst($name);
+ }
+ } else {
+ switch ($name) {
+ case 'sqlite':
+ return 'SQLite';
+ case 'mysql':
+ return 'MySQL';
+ case 'pgsql':
+ return 'PostgreSQL';
+ case 'oci':
+ return 'Oracle';
+ default:
+ return ucfirst($name);
+ }
+ }
+ }
+
+ /**
+ * Check environment
+ */
+ public function checkEnvironment()
+ {
+ if (!extension_loaded('PDO')) {
+ throw new Exception\RuntimeException('The PDO extension is required for this adapter but the extension is not loaded');
+ }
+ }
+
+ /**
+ * @return Connection
+ */
+ public function getConnection()
+ {
+ return $this->connection;
+ }
+
+ /**
+ * @param string|PDOStatement $sqlOrResource
+ * @return Statement
+ */
+ public function createStatement($sqlOrResource = null)
+ {
+ $statement = clone $this->statementPrototype;
+ if ($sqlOrResource instanceof PDOStatement) {
+ $statement->setResource($sqlOrResource);
+ } else {
+ if (is_string($sqlOrResource)) {
+ $statement->setSql($sqlOrResource);
+ }
+ if (!$this->connection->isConnected()) {
+ $this->connection->connect();
+ }
+ $statement->initialize($this->connection->getResource());
+ }
+ return $statement;
+ }
+
+ /**
+ * @param resource $resource
+ * @param mixed $context
+ * @return Result
+ */
+ public function createResult($resource, $context = null)
+ {
+ $result = clone $this->resultPrototype;
+ $rowCount = null;
+
+ // special feature, sqlite PDO counter
+ if ($this->connection->getDriverName() == 'sqlite'
+ && ($sqliteRowCounter = $this->getFeature('SqliteRowCounter'))
+ && $resource->columnCount() > 0) {
+ $rowCount = $sqliteRowCounter->getRowCountClosure($context);
+ }
+
+ // special feature, oracle PDO counter
+ if ($this->connection->getDriverName() == 'oci'
+ && ($oracleRowCounter = $this->getFeature('OracleRowCounter'))
+ && $resource->columnCount() > 0) {
+ $rowCount = $oracleRowCounter->getRowCountClosure($context);
+ }
+
+
+ $result->initialize($resource, $this->connection->getLastGeneratedValue(), $rowCount);
+ return $result;
+ }
+
+ /**
+ * @return array
+ */
+ public function getPrepareType()
+ {
+ return self::PARAMETERIZATION_NAMED;
+ }
+
+ /**
+ * @param string $name
+ * @param string|null $type
+ * @return string
+ */
+ public function formatParameterName($name, $type = null)
+ {
+ if ($type == null && !is_numeric($name) || $type == self::PARAMETERIZATION_NAMED) {
+ return ':' . $name;
+ }
+
+ return '?';
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getLastGeneratedValue($name = null)
+ {
+ return $this->connection->getLastGeneratedValue($name);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pdo/Result.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pdo/Result.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pdo/Result.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pdo/Result.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,227 @@
+resource = $resource;
+ $this->generatedValue = $generatedValue;
+ $this->rowCount = $rowCount;
+
+ return $this;
+ }
+
+ /**
+ * @return null
+ */
+ public function buffer()
+ {
+ return null;
+ }
+
+ /**
+ * @return bool|null
+ */
+ public function isBuffered()
+ {
+ return false;
+ }
+
+ /**
+ * Get resource
+ *
+ * @return mixed
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * Get the data
+ * @return array
+ */
+ public function current()
+ {
+ if ($this->currentComplete) {
+ return $this->currentData;
+ }
+
+ $this->currentData = $this->resource->fetch(\PDO::FETCH_ASSOC);
+ $this->currentComplete = true;
+ return $this->currentData;
+ }
+
+ /**
+ * Next
+ *
+ * @return mixed
+ */
+ public function next()
+ {
+ $this->currentData = $this->resource->fetch(\PDO::FETCH_ASSOC);
+ $this->currentComplete = true;
+ $this->position++;
+ return $this->currentData;
+ }
+
+ /**
+ * Key
+ *
+ * @return mixed
+ */
+ public function key()
+ {
+ return $this->position;
+ }
+
+ /**
+ * @throws Exception\RuntimeException
+ * @return void
+ */
+ public function rewind()
+ {
+ if ($this->statementMode == self::STATEMENT_MODE_FORWARD && $this->position > 0) {
+ throw new Exception\RuntimeException(
+ 'This result is a forward only result set, calling rewind() after moving forward is not supported'
+ );
+ }
+ $this->currentData = $this->resource->fetch(\PDO::FETCH_ASSOC);
+ $this->currentComplete = true;
+ $this->position = 0;
+ }
+
+ /**
+ * Valid
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return ($this->currentData !== false);
+ }
+
+ /**
+ * Count
+ *
+ * @return int
+ */
+ public function count()
+ {
+ if (is_int($this->rowCount)) {
+ return $this->rowCount;
+ }
+ if ($this->rowCount instanceof \Closure) {
+ $this->rowCount = (int) call_user_func($this->rowCount);
+ } else {
+ $this->rowCount = (int) $this->resource->rowCount();
+ }
+ return $this->rowCount;
+ }
+
+ /**
+ * @return int
+ */
+ public function getFieldCount()
+ {
+ return $this->resource->columnCount();
+ }
+
+ /**
+ * Is query result
+ *
+ * @return bool
+ */
+ public function isQueryResult()
+ {
+ return ($this->resource->columnCount() > 0);
+ }
+
+ /**
+ * Get affected rows
+ *
+ * @return int
+ */
+ public function getAffectedRows()
+ {
+ return $this->resource->rowCount();
+ }
+
+ /**
+ * @return mixed|null
+ */
+ public function getGeneratedValue()
+ {
+ return $this->generatedValue;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pdo/Statement.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pdo/Statement.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pdo/Statement.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pdo/Statement.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,311 @@
+driver = $driver;
+ return $this;
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Statement
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Initialize
+ *
+ * @param \PDO $connectionResource
+ * @return Statement
+ */
+ public function initialize(\PDO $connectionResource)
+ {
+ $this->pdo = $connectionResource;
+ return $this;
+ }
+
+ /**
+ * Set resource
+ *
+ * @param \PDOStatement $pdoStatement
+ * @return Statement
+ */
+ public function setResource(\PDOStatement $pdoStatement)
+ {
+ $this->resource = $pdoStatement;
+ return $this;
+ }
+
+ /**
+ * Get resource
+ *
+ * @return mixed
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * Set sql
+ *
+ * @param string $sql
+ * @return Statement
+ */
+ public function setSql($sql)
+ {
+ $this->sql = $sql;
+ return $this;
+ }
+
+ /**
+ * Get sql
+ *
+ * @return string
+ */
+ public function getSql()
+ {
+ return $this->sql;
+ }
+
+ /**
+ * @param ParameterContainer $parameterContainer
+ * @return Statement
+ */
+ public function setParameterContainer(ParameterContainer $parameterContainer)
+ {
+ $this->parameterContainer = $parameterContainer;
+ return $this;
+ }
+
+ /**
+ * @return ParameterContainer
+ */
+ public function getParameterContainer()
+ {
+ return $this->parameterContainer;
+ }
+
+ /**
+ * @param string $sql
+ * @throws Exception\RuntimeException
+ */
+ public function prepare($sql = null)
+ {
+ if ($this->isPrepared) {
+ throw new Exception\RuntimeException('This statement has been prepared already');
+ }
+
+ if ($sql == null) {
+ $sql = $this->sql;
+ }
+
+ $this->resource = $this->pdo->prepare($sql);
+
+ if ($this->resource === false) {
+ $error = $this->pdo->errorInfo();
+ throw new Exception\RuntimeException($error[2]);
+ }
+
+ $this->isPrepared = true;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isPrepared()
+ {
+ return $this->isPrepared;
+ }
+
+ /**
+ * @param mixed $parameters
+ * @throws Exception\InvalidQueryException
+ * @return Result
+ */
+ public function execute($parameters = null)
+ {
+ if (!$this->isPrepared) {
+ $this->prepare();
+ }
+
+ /** START Standard ParameterContainer Merging Block */
+ if (!$this->parameterContainer instanceof ParameterContainer) {
+ if ($parameters instanceof ParameterContainer) {
+ $this->parameterContainer = $parameters;
+ $parameters = null;
+ } else {
+ $this->parameterContainer = new ParameterContainer();
+ }
+ }
+
+ if (is_array($parameters)) {
+ $this->parameterContainer->setFromArray($parameters);
+ }
+
+ if ($this->parameterContainer->count() > 0) {
+ $this->bindParametersFromContainer();
+ }
+ /** END Standard ParameterContainer Merging Block */
+
+ if ($this->profiler) {
+ $this->profiler->profilerStart($this);
+ }
+
+ try {
+ $this->resource->execute();
+ } catch (\PDOException $e) {
+ if ($this->profiler) {
+ $this->profiler->profilerFinish();
+ }
+ throw new Exception\InvalidQueryException(
+ 'Statement could not be executed (' . implode(' - ', $this->resource->errorInfo()) . ')',
+ null,
+ $e
+ );
+ }
+
+ if ($this->profiler) {
+ $this->profiler->profilerFinish();
+ }
+
+ $result = $this->driver->createResult($this->resource, $this);
+ return $result;
+ }
+
+ /**
+ * Bind parameters from container
+ */
+ protected function bindParametersFromContainer()
+ {
+ if ($this->parametersBound) {
+ return;
+ }
+
+ $parameters = $this->parameterContainer->getNamedArray();
+ foreach ($parameters as $name => &$value) {
+ if (is_bool($value)) {
+ $type = \PDO::PARAM_BOOL;
+ } else {
+ $type = \PDO::PARAM_STR;
+ }
+ if ($this->parameterContainer->offsetHasErrata($name)) {
+ switch ($this->parameterContainer->offsetGetErrata($name)) {
+ case ParameterContainer::TYPE_INTEGER:
+ $type = \PDO::PARAM_INT;
+ break;
+ case ParameterContainer::TYPE_NULL:
+ $type = \PDO::PARAM_NULL;
+ break;
+ case ParameterContainer::TYPE_LOB:
+ $type = \PDO::PARAM_LOB;
+ break;
+ }
+ }
+
+ // parameter is named or positional, value is reference
+ $parameter = is_int($name) ? ($name + 1) : $name;
+ $this->resource->bindParam($parameter, $value, $type);
+ }
+
+ }
+
+ /**
+ * Perform a deep clone
+ * @return Statement A cloned statement
+ */
+ public function __clone()
+ {
+ $this->isPrepared = false;
+ $this->parametersBound = false;
+ $this->resource = null;
+ if ($this->parameterContainer) {
+ $this->parameterContainer = clone $this->parameterContainer;
+ }
+
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pgsql/Connection.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pgsql/Connection.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pgsql/Connection.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pgsql/Connection.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,301 @@
+setConnectionParameters($connectionInfo);
+ } elseif (is_resource($connectionInfo)) {
+ $this->setResource($connectionInfo);
+ }
+ }
+
+ /**
+ * Set connection parameters
+ *
+ * @param array $connectionParameters
+ * @return Connection
+ */
+ public function setConnectionParameters(array $connectionParameters)
+ {
+ $this->connectionParameters = $connectionParameters;
+ return $this;
+ }
+
+ /**
+ * Set driver
+ *
+ * @param Pgsql $driver
+ * @return Connection
+ */
+ public function setDriver(Pgsql $driver)
+ {
+ $this->driver = $driver;
+ return $this;
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Connection
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Set resource
+ *
+ * @param resource $resource
+ * @return Connection
+ */
+ public function setResource($resource)
+ {
+ $this->resource = $resource;
+ return;
+ }
+
+ /**
+ * Get current schema
+ *
+ * @return null|string
+ */
+ public function getCurrentSchema()
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ $result = pg_query($this->resource, 'SELECT CURRENT_SCHEMA AS "currentschema"');
+ if ($result == false) {
+ return null;
+ }
+ return pg_fetch_result($result, 0, 'currentschema');
+ }
+
+ /**
+ * Get resource
+ *
+ * @return resource
+ */
+ public function getResource()
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+ return $this->resource;
+ }
+
+ /**
+ * Connect to the database
+ *
+ * @return Connection
+ * @throws Exception\RuntimeException on failure
+ */
+ public function connect()
+ {
+ if (is_resource($this->resource)) {
+ return $this;
+ }
+
+ // localize
+ $p = $this->connectionParameters;
+
+ // given a list of key names, test for existence in $p
+ $findParameterValue = function (array $names) use ($p) {
+ foreach ($names as $name) {
+ if (isset($p[$name])) {
+ return $p[$name];
+ }
+ }
+ return null;
+ };
+
+ $connection = array();
+ $connection['host'] = $findParameterValue(array('hostname', 'host'));
+ $connection['user'] = $findParameterValue(array('username', 'user'));
+ $connection['password'] = $findParameterValue(array('password', 'passwd', 'pw'));
+ $connection['dbname'] = $findParameterValue(array('database', 'dbname', 'db', 'schema'));
+ $connection['port'] = (isset($p['port'])) ? (int) $p['port'] : null;
+ $connection['socket'] = (isset($p['socket'])) ? $p['socket'] : null;
+
+ $connection = array_filter($connection); // remove nulls
+ $connection = http_build_query($connection, null, ' '); // @link http://php.net/pg_connect
+
+ set_error_handler(function ($number, $string) {
+ throw new Exception\RuntimeException(
+ __METHOD__ . ': Unable to connect to database', null, new Exception\ErrorException($string, $number)
+ );
+ });
+ $this->resource = pg_connect($connection);
+ restore_error_handler();
+
+ if ($this->resource === false) {
+ throw new Exception\RuntimeException(sprintf(
+ '%s: Unable to connect to database',
+ __METHOD__
+ ));
+ }
+
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isConnected()
+ {
+ return (is_resource($this->resource));
+ }
+
+ /**
+ * @return void
+ */
+ public function disconnect()
+ {
+ pg_close($this->resource);
+ }
+
+ /**
+ * @return void
+ */
+ public function beginTransaction()
+ {
+ if ($this->inTransaction) {
+ throw new Exception\RuntimeException('Nested transactions are not supported');
+ }
+
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ pg_query($this->resource, 'BEGIN');
+ $this->inTransaction = true;
+ }
+
+ /**
+ * @return void
+ */
+ public function commit()
+ {
+ if (!$this->inTransaction) {
+ return; // We ignore attempts to commit non-existing transaction
+ }
+
+ pg_query($this->resource, 'COMMIT');
+ $this->inTransaction = false;
+ }
+
+ /**
+ * @return void
+ */
+ public function rollback()
+ {
+ if (!$this->inTransaction) {
+ return;
+ }
+
+ pg_query($this->resource, 'ROLLBACK');
+ $this->inTransaction = false;
+ }
+
+ /**
+ * @param string $sql
+ * @throws Exception\InvalidQueryException
+ * @return resource|\Zend\Db\ResultSet\ResultSetInterface
+ */
+ public function execute($sql)
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ if ($this->profiler) {
+ $this->profiler->profilerStart($sql);
+ }
+
+ $resultResource = pg_query($this->resource, $sql);
+
+ if ($this->profiler) {
+ $this->profiler->profilerFinish($sql);
+ }
+
+ // if the returnValue is something other than a pg result resource, bypass wrapping it
+ if ($resultResource === false) {
+ throw new Exception\InvalidQueryException(pg_errormessage());
+ }
+
+ $resultPrototype = $this->driver->createResult(($resultResource === true) ? $this->resource : $resultResource);
+ return $resultPrototype;
+ }
+
+ /**
+ * @param null $name Ignored
+ * @return string
+ */
+ public function getLastGeneratedValue($name = null)
+ {
+ if ($name == null) {
+ return null;
+ }
+ $result = pg_query($this->resource, 'SELECT CURRVAL(\'' . str_replace('\'', '\\\'', $name) . '\') as "currval"');
+ return pg_fetch_result($result, 0, 'currval');
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pgsql/Pgsql.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pgsql/Pgsql.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pgsql/Pgsql.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pgsql/Pgsql.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,227 @@
+ false
+ );
+
+ /**
+ * Constructor
+ *
+ * @param array|Connection|resource $connection
+ * @param null|Statement $statementPrototype
+ * @param null|Result $resultPrototype
+ * @param array $options
+ */
+ public function __construct($connection, Statement $statementPrototype = null, Result $resultPrototype = null, $options = null)
+ {
+ if (!$connection instanceof Connection) {
+ $connection = new Connection($connection);
+ }
+
+ $this->registerConnection($connection);
+ $this->registerStatementPrototype(($statementPrototype) ?: new Statement());
+ $this->registerResultPrototype(($resultPrototype) ?: new Result());
+ }
+
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ if ($this->connection instanceof Profiler\ProfilerAwareInterface) {
+ $this->connection->setProfiler($profiler);
+ }
+ if ($this->statementPrototype instanceof Profiler\ProfilerAwareInterface) {
+ $this->statementPrototype->setProfiler($profiler);
+ }
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Register connection
+ *
+ * @param Connection $connection
+ * @return Pgsql
+ */
+ public function registerConnection(Connection $connection)
+ {
+ $this->connection = $connection;
+ $this->connection->setDriver($this);
+ return $this;
+ }
+
+ /**
+ * Register statement prototype
+ *
+ * @param Statement $statement
+ * @return Pgsql
+ */
+ public function registerStatementPrototype(Statement $statement)
+ {
+ $this->statementPrototype = $statement;
+ $this->statementPrototype->setDriver($this); // needs access to driver to createResult()
+ return $this;
+ }
+
+ /**
+ * Register result prototype
+ *
+ * @param Result $result
+ * @return Pgsql
+ */
+ public function registerResultPrototype(Result $result)
+ {
+ $this->resultPrototype = $result;
+ return $this;
+ }
+
+ /**
+ * Get database platform name
+ *
+ * @param string $nameFormat
+ * @return string
+ */
+ public function getDatabasePlatformName($nameFormat = self::NAME_FORMAT_CAMELCASE)
+ {
+ if ($nameFormat == self::NAME_FORMAT_CAMELCASE) {
+ return 'Postgresql';
+ }
+
+ return 'PostgreSQL';
+ }
+
+ /**
+ * Check environment
+ *
+ * @throws Exception\RuntimeException
+ * @return bool
+ */
+ public function checkEnvironment()
+ {
+ if (!extension_loaded('pgsql')) {
+ throw new Exception\RuntimeException('The PostgreSQL (pgsql) extension is required for this adapter but the extension is not loaded');
+ }
+ }
+
+ /**
+ * Get connection
+ *
+ * @return Connection
+ */
+ public function getConnection()
+ {
+ return $this->connection;
+ }
+
+ /**
+ * Create statement
+ *
+ * @param string|null $sqlOrResource
+ * @return Statement
+ */
+ public function createStatement($sqlOrResource = null)
+ {
+ $statement = clone $this->statementPrototype;
+
+ if (is_string($sqlOrResource)) {
+ $statement->setSql($sqlOrResource);
+ }
+
+ if (!$this->connection->isConnected()) {
+ $this->connection->connect();
+ }
+
+ $statement->initialize($this->connection->getResource());
+ return $statement;
+ }
+
+ /**
+ * Create result
+ *
+ * @param resource $resource
+ * @return Result
+ */
+ public function createResult($resource)
+ {
+ $result = clone $this->resultPrototype;
+ $result->initialize($resource, $this->connection->getLastGeneratedValue());
+ return $result;
+ }
+
+ /**
+ * Get prepare Type
+ *
+ * @return array
+ */
+ public function getPrepareType()
+ {
+ return self::PARAMETERIZATION_POSITIONAL;
+ }
+
+ /**
+ * Format parameter name
+ *
+ * @param string $name
+ * @param mixed $type
+ * @return string
+ */
+ public function formatParameterName($name, $type = null)
+ {
+ return '$#';
+ }
+
+ /**
+ * Get last generated value
+ *
+ * @param string $name
+ * @return mixed
+ */
+ public function getLastGeneratedValue($name = null)
+ {
+ return $this->connection->getLastGeneratedValue($name);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pgsql/Result.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pgsql/Result.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pgsql/Result.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pgsql/Result.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,193 @@
+resource = $resource;
+ $this->count = pg_num_rows($this->resource);
+ $this->generatedValue = $generatedValue;
+ }
+
+ /**
+ * Current
+ *
+ * @return array|bool|mixed
+ */
+ public function current()
+ {
+ if ($this->count === 0) {
+ return false;
+ }
+ return pg_fetch_assoc($this->resource, $this->position);
+ }
+
+ /**
+ * Next
+ *
+ * @return void
+ */
+ public function next()
+ {
+ $this->position++;
+ }
+
+ /**
+ * Key
+ *
+ * @return int|mixed
+ */
+ public function key()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Valid
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return ($this->position < $this->count);
+ }
+
+ /**
+ * Rewind
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ $this->position = 0;
+ }
+
+ /**
+ * Buffer
+ *
+ * @return null
+ */
+ public function buffer()
+ {
+ return null;
+ }
+
+ /**
+ * Is buffered
+ *
+ * @return false
+ */
+ public function isBuffered()
+ {
+ return false;
+ }
+
+ /**
+ * Is query result
+ *
+ * @return bool
+ */
+ public function isQueryResult()
+ {
+ return (pg_num_fields($this->resource) > 0);
+ }
+
+ /**
+ * Get affected rows
+ *
+ * @return int
+ */
+ public function getAffectedRows()
+ {
+ return pg_affected_rows($this->resource);
+ }
+
+ /**
+ * Get generated value
+ *
+ * @return mixed|null
+ */
+ public function getGeneratedValue()
+ {
+ return $this->generatedValue;
+ }
+
+ /**
+ * Get resource
+ */
+ public function getResource()
+ {
+ // TODO: Implement getResource() method.
+ }
+
+ /**
+ * Count
+ *
+ * (PHP 5 >= 5.1.0)
+ * Count elements of an object
+ * @link http://php.net/manual/en/countable.count.php
+ * @return int The custom count as an integer.
+ *
+ *
+ * The return value is cast to an integer.
+ */
+ public function count()
+ {
+ return $this->count;
+ }
+
+ /**
+ * Get field count
+ *
+ * @return int
+ */
+ public function getFieldCount()
+ {
+ return pg_num_fields($this->resource);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pgsql/Statement.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pgsql/Statement.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Pgsql/Statement.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Pgsql/Statement.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,241 @@
+driver = $driver;
+ return $this;
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Statement
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Initialize
+ *
+ * @param resource $pgsql
+ * @return void
+ * @throws Exception\RuntimeException for invalid or missing postgresql connection
+ */
+ public function initialize($pgsql)
+ {
+ if (!is_resource($pgsql) || get_resource_type($pgsql) !== 'pgsql link') {
+ throw new Exception\RuntimeException(sprintf(
+ '%s: Invalid or missing postgresql connection; received "%s"',
+ __METHOD__,
+ get_resource_type($pgsql)
+ ));
+ }
+ $this->pgsql = $pgsql;
+ }
+
+ /**
+ * Get resource
+ *
+ * @return resource
+ */
+ public function getResource()
+ {
+ // TODO: Implement getResource() method.
+ }
+
+ /**
+ * Set sql
+ *
+ * @param string $sql
+ * @return Statement
+ */
+ public function setSql($sql)
+ {
+ $this->sql = $sql;
+ return $this;
+ }
+
+ /**
+ * Get sql
+ *
+ * @return string
+ */
+ public function getSql()
+ {
+ return $this->sql;
+ }
+
+ /**
+ * Set parameter container
+ *
+ * @param ParameterContainer $parameterContainer
+ * @return Statement
+ */
+ public function setParameterContainer(ParameterContainer $parameterContainer)
+ {
+ $this->parameterContainer = $parameterContainer;
+ return $this;
+ }
+
+ /**
+ * Get parameter container
+ *
+ * @return ParameterContainer
+ */
+ public function getParameterContainer()
+ {
+ return $this->parameterContainer;
+ }
+
+ /**
+ * Prepare
+ *
+ * @param string $sql
+ */
+ public function prepare($sql = null)
+ {
+ $sql = ($sql) ?: $this->sql;
+
+ $pCount = 1;
+ $sql = preg_replace_callback(
+ '#\$\##', function ($foo) use (&$pCount) {
+ return '$' . $pCount++;
+ },
+ $sql
+ );
+
+ $this->sql = $sql;
+ $this->statementName = 'statement' . ++static::$statementIndex;
+ $this->resource = pg_prepare($this->pgsql, $this->statementName, $sql);
+ }
+
+ /**
+ * Is prepared
+ *
+ * @return bool
+ */
+ public function isPrepared()
+ {
+ return isset($this->resource);
+ }
+
+ /**
+ * Execute
+ *
+ * @param ParameterContainer|null $parameters
+ * @throws Exception\InvalidQueryException
+ * @return Result
+ */
+ public function execute($parameters = null)
+ {
+ if (!$this->isPrepared()) {
+ $this->prepare();
+ }
+
+ /** START Standard ParameterContainer Merging Block */
+ if (!$this->parameterContainer instanceof ParameterContainer) {
+ if ($parameters instanceof ParameterContainer) {
+ $this->parameterContainer = $parameters;
+ $parameters = null;
+ } else {
+ $this->parameterContainer = new ParameterContainer();
+ }
+ }
+
+ if (is_array($parameters)) {
+ $this->parameterContainer->setFromArray($parameters);
+ }
+
+ if ($this->parameterContainer->count() > 0) {
+ $parameters = $this->parameterContainer->getPositionalArray();
+ }
+ /** END Standard ParameterContainer Merging Block */
+
+ if ($this->profiler) {
+ $this->profiler->profilerStart($this);
+ }
+
+ $resultResource = pg_execute($this->pgsql, $this->statementName, (array) $parameters);
+
+ if ($this->profiler) {
+ $this->profiler->profilerFinish();
+ }
+
+ if ($resultResource === false) {
+ throw new Exception\InvalidQueryException(pg_last_error());
+ }
+
+ $result = $this->driver->createResult($resultResource);
+ return $result;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/ResultInterface.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/ResultInterface.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/ResultInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/ResultInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,67 @@
+setConnectionParameters($connectionInfo);
+ } elseif (is_resource($connectionInfo)) {
+ $this->setResource($connectionInfo);
+ } else {
+ throw new Exception\InvalidArgumentException('$connection must be an array of parameters or a resource');
+ }
+ }
+
+ /**
+ * Set driver
+ *
+ * @param Sqlsrv $driver
+ * @return Connection
+ */
+ public function setDriver(Sqlsrv $driver)
+ {
+ $this->driver = $driver;
+ return $this;
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Connection
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Set connection parameters
+ *
+ * @param array $connectionParameters
+ * @return Connection
+ */
+ public function setConnectionParameters(array $connectionParameters)
+ {
+ $this->connectionParameters = $connectionParameters;
+ return $this;
+ }
+
+ /**
+ * Get connection parameters
+ *
+ * @return array
+ */
+ public function getConnectionParameters()
+ {
+ return $this->connectionParameters;
+ }
+
+ /**
+ * Get current schema
+ *
+ * @return string
+ */
+ public function getCurrentSchema()
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ $result = sqlsrv_query($this->resource, 'SELECT SCHEMA_NAME()');
+ $r = sqlsrv_fetch_array($result);
+ return $r[0];
+ }
+
+ /**
+ * Set resource
+ *
+ * @param resource $resource
+ * @throws Exception\InvalidArgumentException
+ * @return Connection
+ */
+ public function setResource($resource)
+ {
+ if (get_resource_type($resource) !== 'SQL Server Connection') {
+ throw new Exception\InvalidArgumentException('Resource provided was not of type SQL Server Connection');
+ }
+ $this->resource = $resource;
+ return $this;
+ }
+
+ /**
+ * @return resource
+ */
+ public function getResource()
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+ return $this->resource;
+ }
+
+ /**
+ * Connect
+ *
+ * @throws Exception\RuntimeException
+ * @return Connection
+ */
+ public function connect()
+ {
+ if ($this->resource) {
+ return $this;
+ }
+
+ $serverName = '.';
+ $params = array(
+ 'ReturnDatesAsStrings' => true
+ );
+ foreach ($this->connectionParameters as $key => $value) {
+ switch (strtolower($key)) {
+ case 'hostname':
+ case 'servername':
+ $serverName = (string) $value;
+ break;
+ case 'username':
+ case 'uid':
+ $params['UID'] = (string) $value;
+ break;
+ case 'password':
+ case 'pwd':
+ $params['PWD'] = (string) $value;
+ break;
+ case 'database':
+ case 'dbname':
+ $params['Database'] = (string) $value;
+ break;
+ case 'driver_options':
+ case 'options':
+ $params = array_merge($params, (array) $value);
+ break;
+
+ }
+ }
+
+ $this->resource = sqlsrv_connect($serverName, $params);
+
+ if (!$this->resource) {
+ throw new Exception\RuntimeException(
+ 'Connect Error',
+ null,
+ new ErrorException(sqlsrv_errors())
+ );
+ }
+
+ return $this;
+ }
+
+ /**
+ * Is connected
+ * @return bool
+ */
+ public function isConnected()
+ {
+ return (is_resource($this->resource));
+ }
+
+ /**
+ * Disconnect
+ */
+ public function disconnect()
+ {
+ sqlsrv_close($this->resource);
+ $this->resource = null;
+ }
+
+ /**
+ * Begin transaction
+ */
+ public function beginTransaction()
+ {
+ // http://msdn.microsoft.com/en-us/library/cc296151.aspx
+ /*
+ $this->resource->autocommit(false);
+ $this->inTransaction = true;
+ */
+ }
+
+ /**
+ * Commit
+ */
+ public function commit()
+ {
+ // http://msdn.microsoft.com/en-us/library/cc296194.aspx
+ /*
+ if (!$this->resource) {
+ $this->connect();
+ }
+
+ $this->resource->commit();
+
+ $this->inTransaction = false;
+ */
+ }
+
+ /**
+ * Rollback
+ */
+ public function rollback()
+ {
+ // http://msdn.microsoft.com/en-us/library/cc296176.aspx
+ /*
+ if (!$this->resource) {
+ throw new \Exception('Must be connected before you can rollback.');
+ }
+
+ if (!$this->_inCommit) {
+ throw new \Exception('Must call commit() before you can rollback.');
+ }
+
+ $this->resource->rollback();
+ return $this;
+ */
+ }
+
+ /**
+ * Execute
+ *
+ * @param string $sql
+ * @throws Exception\RuntimeException
+ * @return mixed
+ */
+ public function execute($sql)
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ if (!$this->driver instanceof Sqlsrv) {
+ throw new Exception\RuntimeException('Connection is missing an instance of Sqlsrv');
+ }
+
+ if ($this->profiler) {
+ $this->profiler->profilerStart($sql);
+ }
+
+ $returnValue = sqlsrv_query($this->resource, $sql);
+
+ if ($this->profiler) {
+ $this->profiler->profilerFinish($sql);
+ }
+
+ // if the returnValue is something other than a Sqlsrv_result, bypass wrapping it
+ if ($returnValue === false) {
+ $errors = sqlsrv_errors();
+ // ignore general warnings
+ if ($errors[0]['SQLSTATE'] != '01000') {
+ throw new Exception\RuntimeException(
+ 'An exception occurred while trying to execute the provided $sql',
+ null,
+ new ErrorException($errors)
+ );
+ }
+ }
+
+ $result = $this->driver->createResult($returnValue);
+ return $result;
+ }
+
+ /**
+ * Prepare
+ *
+ * @param string $sql
+ * @return string
+ */
+ public function prepare($sql)
+ {
+ if (!$this->isConnected()) {
+ $this->connect();
+ }
+
+ $statement = $this->driver->createStatement($sql);
+ return $statement;
+ }
+
+ /**
+ * Get last generated id
+ *
+ * @param string $name
+ * @return mixed
+ */
+ public function getLastGeneratedValue($name = null)
+ {
+ if (!$this->resource) {
+ $this->connect();
+ }
+ $sql = 'SELECT @@IDENTITY as Current_Identity';
+ $result = sqlsrv_query($this->resource, $sql);
+ $row = sqlsrv_fetch_array($result);
+ return $row['Current_Identity'];
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ErrorException.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ErrorException.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ErrorException.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ErrorException.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,33 @@
+errors = ($errors === false) ? sqlsrv_errors() : $errors;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Sqlsrv/Exception/ExceptionInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,16 @@
+resource = $resource;
+ $this->generatedValue = $generatedValue;
+ return $this;
+ }
+
+ /**
+ * @return null
+ */
+ public function buffer()
+ {
+ return null;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isBuffered()
+ {
+ return false;
+ }
+
+ /**
+ * Get resource
+ *
+ * @return resource
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * Current
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ if ($this->currentComplete) {
+ return $this->currentData;
+ }
+
+ $this->load();
+ return $this->currentData;
+ }
+
+ /**
+ * Next
+ *
+ * @return bool
+ */
+ public function next()
+ {
+ $this->load();
+ return true;
+ }
+
+ /**
+ * Load
+ *
+ * @param int $row
+ * @return mixed
+ */
+ protected function load($row = SQLSRV_SCROLL_NEXT)
+ {
+ $this->currentData = sqlsrv_fetch_array($this->resource, SQLSRV_FETCH_ASSOC, $row);
+ $this->currentComplete = true;
+ $this->position++;
+ return $this->currentData;
+ }
+
+ /**
+ * Key
+ *
+ * @return mixed
+ */
+ public function key()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Rewind
+ *
+ * @return bool
+ */
+ public function rewind()
+ {
+ $this->position = 0;
+ $this->load(SQLSRV_SCROLL_FIRST);
+ return true;
+ }
+
+ /**
+ * Valid
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ if ($this->currentComplete && $this->currentData) {
+ return true;
+ }
+
+ return $this->load();
+ }
+
+ /**
+ * Count
+ *
+ * @return int
+ */
+ public function count()
+ {
+ return sqlsrv_num_rows($this->resource);
+ }
+
+ /**
+ * @return bool|int
+ */
+ public function getFieldCount()
+ {
+ return sqlsrv_num_fields($this->resource);
+ }
+
+ /**
+ * Is query result
+ *
+ * @return bool
+ */
+ public function isQueryResult()
+ {
+ if (is_bool($this->resource)) {
+ return false;
+ }
+ return (sqlsrv_num_fields($this->resource) > 0);
+ }
+
+ /**
+ * Get affected rows
+ *
+ * @return int
+ */
+ public function getAffectedRows()
+ {
+ return sqlsrv_rows_affected($this->resource);
+ }
+
+ /**
+ * @return mixed|null
+ */
+ public function getGeneratedValue()
+ {
+ return $this->generatedValue;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Sqlsrv/Sqlsrv.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Sqlsrv/Sqlsrv.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Sqlsrv/Sqlsrv.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Sqlsrv/Sqlsrv.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,212 @@
+registerConnection($connection);
+ $this->registerStatementPrototype(($statementPrototype) ?: new Statement());
+ $this->registerResultPrototype(($resultPrototype) ?: new Result());
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Sqlsrv
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ if ($this->connection instanceof Profiler\ProfilerAwareInterface) {
+ $this->connection->setProfiler($profiler);
+ }
+ if ($this->statementPrototype instanceof Profiler\ProfilerAwareInterface) {
+ $this->statementPrototype->setProfiler($profiler);
+ }
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ * Register connection
+ *
+ * @param Connection $connection
+ * @return Sqlsrv
+ */
+ public function registerConnection(Connection $connection)
+ {
+ $this->connection = $connection;
+ $this->connection->setDriver($this);
+ return $this;
+ }
+
+ /**
+ * Register statement prototype
+ *
+ * @param Statement $statementPrototype
+ * @return Sqlsrv
+ */
+ public function registerStatementPrototype(Statement $statementPrototype)
+ {
+ $this->statementPrototype = $statementPrototype;
+ $this->statementPrototype->setDriver($this);
+ return $this;
+ }
+
+ /**
+ * Register result prototype
+ *
+ * @param Result $resultPrototype
+ * @return Sqlsrv
+ */
+ public function registerResultPrototype(Result $resultPrototype)
+ {
+ $this->resultPrototype = $resultPrototype;
+ return $this;
+ }
+
+ /**
+ * Get database paltform name
+ *
+ * @param string $nameFormat
+ * @return string
+ */
+ public function getDatabasePlatformName($nameFormat = self::NAME_FORMAT_CAMELCASE)
+ {
+ if ($nameFormat == self::NAME_FORMAT_CAMELCASE) {
+ return 'SqlServer';
+ }
+
+ return 'SQLServer';
+ }
+
+ /**
+ * Check environment
+ *
+ * @throws Exception\RuntimeException
+ * @return void
+ */
+ public function checkEnvironment()
+ {
+ if (!extension_loaded('sqlsrv')) {
+ throw new Exception\RuntimeException('The Sqlsrv extension is required for this adapter but the extension is not loaded');
+ }
+ }
+
+ /**
+ * @return Connection
+ */
+ public function getConnection()
+ {
+ return $this->connection;
+ }
+
+ /**
+ * @param string|resource $sqlOrResource
+ * @return Statement
+ */
+ public function createStatement($sqlOrResource = null)
+ {
+ $statement = clone $this->statementPrototype;
+ if (is_resource($sqlOrResource)) {
+ $statement->initialize($sqlOrResource);
+ } else {
+ if (!$this->connection->isConnected()) {
+ $this->connection->connect();
+ }
+ $statement->initialize($this->connection->getResource());
+ if (is_string($sqlOrResource)) {
+ $statement->setSql($sqlOrResource);
+ } elseif ($sqlOrResource != null) {
+ throw new Exception\InvalidArgumentException('createStatement() only accepts an SQL string or a Sqlsrv resource');
+ }
+ }
+ return $statement;
+ }
+
+ /**
+ * @param resource $resource
+ * @return Result
+ */
+ public function createResult($resource)
+ {
+ $result = clone $this->resultPrototype;
+ $result->initialize($resource, $this->connection->getLastGeneratedValue());
+ return $result;
+ }
+
+ /**
+ * @return array
+ */
+ public function getPrepareType()
+ {
+ return self::PARAMETERIZATION_POSITIONAL;
+ }
+
+ /**
+ * @param string $name
+ * @param mixed $type
+ * @return string
+ */
+ public function formatParameterName($name, $type = null)
+ {
+ return '?';
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getLastGeneratedValue()
+ {
+ return $this->getConnection()->getLastGeneratedValue();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Sqlsrv/Statement.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Sqlsrv/Statement.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/Sqlsrv/Statement.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/Sqlsrv/Statement.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,289 @@
+driver = $driver;
+ return $this;
+ }
+
+ /**
+ * @param Profiler\ProfilerInterface $profiler
+ * @return Statement
+ */
+ public function setProfiler(Profiler\ProfilerInterface $profiler)
+ {
+ $this->profiler = $profiler;
+ return $this;
+ }
+
+ /**
+ * @return null|Profiler\ProfilerInterface
+ */
+ public function getProfiler()
+ {
+ return $this->profiler;
+ }
+
+ /**
+ *
+ * One of two resource types will be provided here:
+ * a) "SQL Server Connection" when a prepared statement needs to still be produced
+ * b) "SQL Server Statement" when a prepared statement has been already produced
+ * (there will need to already be a bound param set if it applies to this query)
+ *
+ * @param resource $resource
+ * @throws Exception\InvalidArgumentException
+ * @return Statement
+ */
+ public function initialize($resource)
+ {
+ $resourceType = get_resource_type($resource);
+
+ if ($resourceType == 'SQL Server Connection') {
+ $this->sqlsrv = $resource;
+ } elseif ($resourceType == 'SQL Server Statement') {
+ $this->resource = $resource;
+ $this->isPrepared = true;
+ } else {
+ throw new Exception\InvalidArgumentException('Invalid resource provided to ' . __CLASS__);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set parameter container
+ *
+ * @param ParameterContainer $parameterContainer
+ * @return Statement
+ */
+ public function setParameterContainer(ParameterContainer $parameterContainer)
+ {
+ $this->parameterContainer = $parameterContainer;
+ return $this;
+ }
+
+ /**
+ * @return ParameterContainer
+ */
+ public function getParameterContainer()
+ {
+ return $this->parameterContainer;
+ }
+
+ /**
+ * @param $resource
+ * @return Statement
+ */
+ public function setResource($resource)
+ {
+ $this->resource = $resource;
+ return $this;
+ }
+
+ /**
+ * Get resource
+ *
+ * @return resource
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * @param string $sql
+ * @return Statement
+ */
+ public function setSql($sql)
+ {
+ $this->sql = $sql;
+ return $this;
+ }
+
+ /**
+ * Get sql
+ *
+ * @return string
+ */
+ public function getSql()
+ {
+ return $this->sql;
+ }
+
+ /**
+ * @param string $sql
+ * @throws Exception\RuntimeException
+ * @return Statement
+ */
+ public function prepare($sql = null)
+ {
+ if ($this->isPrepared) {
+ throw new Exception\RuntimeException('Already prepared');
+ }
+ $sql = ($sql) ?: $this->sql;
+
+ $pRef = &$this->parameterReferences;
+ for ($position = 0, $count = substr_count($sql, '?'); $position < $count; $position++) {
+ $pRef[$position] = array('', SQLSRV_PARAM_IN, null, null);
+ }
+
+ $this->resource = sqlsrv_prepare($this->sqlsrv, $sql, $pRef);
+
+ $this->isPrepared = true;
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isPrepared()
+ {
+ return $this->isPrepared;
+ }
+
+ /**
+ * Execute
+ *
+ * @param array|ParameterContainer $parameters
+ * @throws Exception\RuntimeException
+ * @return Result
+ */
+ public function execute($parameters = null)
+ {
+ if (!$this->isPrepared) {
+ $this->prepare();
+ }
+
+ /** START Standard ParameterContainer Merging Block */
+ if (!$this->parameterContainer instanceof ParameterContainer) {
+ if ($parameters instanceof ParameterContainer) {
+ $this->parameterContainer = $parameters;
+ $parameters = null;
+ } else {
+ $this->parameterContainer = new ParameterContainer();
+ }
+ }
+
+ if (is_array($parameters)) {
+ $this->parameterContainer->setFromArray($parameters);
+ }
+
+ if ($this->parameterContainer->count() > 0) {
+ $this->bindParametersFromContainer();
+ }
+ /** END Standard ParameterContainer Merging Block */
+
+ if ($this->profiler) {
+ $this->profiler->profilerStart($this);
+ }
+
+ $resultValue = sqlsrv_execute($this->resource);
+
+ if ($this->profiler) {
+ $this->profiler->profilerFinish();
+ }
+
+ if ($resultValue === false) {
+ $errors = sqlsrv_errors();
+ // ignore general warnings
+ if ($errors[0]['SQLSTATE'] != '01000') {
+ throw new Exception\RuntimeException($errors[0]['message']);
+ }
+ }
+
+ $result = $this->driver->createResult($this->resource);
+ return $result;
+ }
+
+ /**
+ * Bind parameters from container
+ *
+ */
+ protected function bindParametersFromContainer()
+ {
+ $values = $this->parameterContainer->getPositionalArray();
+ $position = 0;
+ foreach ($values as $value) {
+ $this->parameterReferences[$position++][0] = $value;
+ }
+
+ // @todo bind errata
+ //foreach ($this->parameterContainer as $name => &$value) {
+ // $p[$position][0] = $value;
+ // $position++;
+ // if ($this->parameterContainer->offsetHasErrata($name)) {
+ // $p[$position][3] = $this->parameterContainer->offsetGetErrata($name);
+ // }
+ //}
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Driver/StatementInterface.php zendframework-2.2.6/library/Zend/Db/Adapter/Driver/StatementInterface.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Driver/StatementInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Driver/StatementInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,46 @@
+parameters = $parameters;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Exception/InvalidQueryException.php zendframework-2.2.6/library/Zend/Db/Adapter/Exception/InvalidQueryException.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Exception/InvalidQueryException.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Exception/InvalidQueryException.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,14 @@
+getCode();
- }
- parent::__construct($message, $code, $e);
- }
-
- public function hasChainedException()
- {
- return ($this->_previous !== null);
- }
-
- public function getChainedException()
- {
- return $this->getPrevious();
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Mysqli/Exception.php zendframework-2.2.6/library/Zend/Db/Adapter/Mysqli/Exception.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Mysqli/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Mysqli/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,40 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INT' => Zend_Db::INT_TYPE,
- 'INTEGER' => Zend_Db::INT_TYPE,
- 'MEDIUMINT' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'TINYINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'SERIAL' => Zend_Db::BIGINT_TYPE,
- 'DEC' => Zend_Db::FLOAT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE,
- 'FIXED' => Zend_Db::FLOAT_TYPE,
- 'FLOAT' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * @var Zend_Db_Statement_Mysqli
- */
- protected $_stmt = null;
-
- /**
- * Default class name for a DB statement.
- *
- * @var string
- */
- protected $_defaultStmtClass = 'Zend_Db_Statement_Mysqli';
-
- /**
- * Quote a raw string.
- *
- * @param mixed $value Raw string
- *
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (is_int($value) || is_float($value)) {
- return $value;
- }
- $this->_connect();
- return "'" . $this->_connection->real_escape_string($value) . "'";
- }
-
- /**
- * Returns the symbol the adapter uses for delimiting identifiers.
- *
- * @return string
- */
- public function getQuoteIdentifierSymbol()
- {
- return "`";
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $result = array();
- // Use mysqli extension API, because SHOW doesn't work
- // well as a prepared statement on MySQL 4.1.
- $sql = 'SHOW TABLES';
- if ($queryResult = $this->getConnection()->query($sql)) {
- while ($row = $queryResult->fetch_row()) {
- $result[] = $row[0];
- }
- $queryResult->close();
- } else {
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
- throw new Zend_Db_Adapter_Mysqli_Exception($this->getConnection()->error);
- }
- return $result;
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- /**
- * @todo use INFORMATION_SCHEMA someday when
- * MySQL's implementation isn't too slow.
- */
-
- if ($schemaName) {
- $sql = 'DESCRIBE ' . $this->quoteIdentifier("$schemaName.$tableName", true);
- } else {
- $sql = 'DESCRIBE ' . $this->quoteIdentifier($tableName, true);
- }
-
- /**
- * Use mysqli extension API, because DESCRIBE doesn't work
- * well as a prepared statement on MySQL 4.1.
- */
- if ($queryResult = $this->getConnection()->query($sql)) {
- while ($row = $queryResult->fetch_assoc()) {
- $result[] = $row;
- }
- $queryResult->close();
- } else {
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
- throw new Zend_Db_Adapter_Mysqli_Exception($this->getConnection()->error);
- }
-
- $desc = array();
-
- $row_defaults = array(
- 'Length' => null,
- 'Scale' => null,
- 'Precision' => null,
- 'Unsigned' => null,
- 'Primary' => false,
- 'PrimaryPosition' => null,
- 'Identity' => false
- );
- $i = 1;
- $p = 1;
- foreach ($result as $key => $row) {
- $row = array_merge($row_defaults, $row);
- if (preg_match('/unsigned/', $row['Type'])) {
- $row['Unsigned'] = true;
- }
- if (preg_match('/^((?:var)?char)\((\d+)\)/', $row['Type'], $matches)) {
- $row['Type'] = $matches[1];
- $row['Length'] = $matches[2];
- } else if (preg_match('/^decimal\((\d+),(\d+)\)/', $row['Type'], $matches)) {
- $row['Type'] = 'decimal';
- $row['Precision'] = $matches[1];
- $row['Scale'] = $matches[2];
- } else if (preg_match('/^float\((\d+),(\d+)\)/', $row['Type'], $matches)) {
- $row['Type'] = 'float';
- $row['Precision'] = $matches[1];
- $row['Scale'] = $matches[2];
- } else if (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)/', $row['Type'], $matches)) {
- $row['Type'] = $matches[1];
- /**
- * The optional argument of a MySQL int type is not precision
- * or length; it is only a hint for display width.
- */
- }
- if (strtoupper($row['Key']) == 'PRI') {
- $row['Primary'] = true;
- $row['PrimaryPosition'] = $p;
- if ($row['Extra'] == 'auto_increment') {
- $row['Identity'] = true;
- } else {
- $row['Identity'] = false;
- }
- ++$p;
- }
- $desc[$this->foldCase($row['Field'])] = array(
- 'SCHEMA_NAME' => null, // @todo
- 'TABLE_NAME' => $this->foldCase($tableName),
- 'COLUMN_NAME' => $this->foldCase($row['Field']),
- 'COLUMN_POSITION' => $i,
- 'DATA_TYPE' => $row['Type'],
- 'DEFAULT' => $row['Default'],
- 'NULLABLE' => (bool) ($row['Null'] == 'YES'),
- 'LENGTH' => $row['Length'],
- 'SCALE' => $row['Scale'],
- 'PRECISION' => $row['Precision'],
- 'UNSIGNED' => $row['Unsigned'],
- 'PRIMARY' => $row['Primary'],
- 'PRIMARY_POSITION' => $row['PrimaryPosition'],
- 'IDENTITY' => $row['Identity']
- );
- ++$i;
- }
- return $desc;
- }
-
- /**
- * Creates a connection to the database.
- *
- * @return void
- * @throws Zend_Db_Adapter_Mysqli_Exception
- */
- protected function _connect()
- {
- if ($this->_connection) {
- return;
- }
-
- if (!extension_loaded('mysqli')) {
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
- throw new Zend_Db_Adapter_Mysqli_Exception('The Mysqli extension is required for this adapter but the extension is not loaded');
- }
-
- if (isset($this->_config['port'])) {
- $port = (integer) $this->_config['port'];
- } else {
- $port = null;
- }
-
- $this->_connection = mysqli_init();
-
- if(!empty($this->_config['driver_options'])) {
- foreach($this->_config['driver_options'] as $option=>$value) {
- if(is_string($option)) {
- // Suppress warnings here
- // Ignore it if it's not a valid constant
- $option = @constant(strtoupper($option));
- if($option === null)
- continue;
- }
- mysqli_options($this->_connection, $option, $value);
- }
- }
-
- // Suppress connection warnings here.
- // Throw an exception instead.
- $_isConnected = @mysqli_real_connect(
- $this->_connection,
- $this->_config['host'],
- $this->_config['username'],
- $this->_config['password'],
- $this->_config['dbname'],
- $port
- );
-
- if ($_isConnected === false || mysqli_connect_errno()) {
-
- $this->closeConnection();
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
- throw new Zend_Db_Adapter_Mysqli_Exception(mysqli_connect_error());
- }
-
- if (!empty($this->_config['charset'])) {
- mysqli_set_charset($this->_connection, $this->_config['charset']);
- }
- }
-
- /**
- * Test if a connection is active
- *
- * @return boolean
- */
- public function isConnected()
- {
- return ((bool) ($this->_connection instanceof mysqli));
- }
-
- /**
- * Force the connection to close.
- *
- * @return void
- */
- public function closeConnection()
- {
- if ($this->isConnected()) {
- $this->_connection->close();
- }
- $this->_connection = null;
- }
-
- /**
- * Prepare a statement and return a PDOStatement-like object.
- *
- * @param string $sql SQL query
- * @return Zend_Db_Statement_Mysqli
- */
- public function prepare($sql)
- {
- $this->_connect();
- if ($this->_stmt) {
- $this->_stmt->close();
- }
- $stmtClass = $this->_defaultStmtClass;
- if (!class_exists($stmtClass)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($stmtClass);
- }
- $stmt = new $stmtClass($this, $sql);
- if ($stmt === false) {
- return false;
- }
- $stmt->setFetchMode($this->_fetchMode);
- $this->_stmt = $stmt;
- return $stmt;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * MySQL does not support sequences, so $tableName and $primaryKey are ignored.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- * @todo Return value should be int?
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- $mysqli = $this->_connection;
- return (string) $mysqli->insert_id;
- }
-
- /**
- * Begin a transaction.
- *
- * @return void
- */
- protected function _beginTransaction()
- {
- $this->_connect();
- $this->_connection->autocommit(false);
- }
-
- /**
- * Commit a transaction.
- *
- * @return void
- */
- protected function _commit()
- {
- $this->_connect();
- $this->_connection->commit();
- $this->_connection->autocommit(true);
- }
-
- /**
- * Roll-back a transaction.
- *
- * @return void
- */
- protected function _rollBack()
- {
- $this->_connect();
- $this->_connection->rollback();
- $this->_connection->autocommit(true);
- }
-
- /**
- * Set the fetch mode.
- *
- * @param int $mode
- * @return void
- * @throws Zend_Db_Adapter_Mysqli_Exception
- */
- public function setFetchMode($mode)
- {
- switch ($mode) {
- case Zend_Db::FETCH_LAZY:
- case Zend_Db::FETCH_ASSOC:
- case Zend_Db::FETCH_NUM:
- case Zend_Db::FETCH_BOTH:
- case Zend_Db::FETCH_NAMED:
- case Zend_Db::FETCH_OBJ:
- $this->_fetchMode = $mode;
- break;
- case Zend_Db::FETCH_BOUND: // bound to PHP variable
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
- throw new Zend_Db_Adapter_Mysqli_Exception('FETCH_BOUND is not supported yet');
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
- throw new Zend_Db_Adapter_Mysqli_Exception("Invalid fetch mode '$mode' specified");
- }
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param int $count
- * @param int $offset OPTIONAL
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
- throw new Zend_Db_Adapter_Mysqli_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /**
- * @see Zend_Db_Adapter_Mysqli_Exception
- */
- require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
- throw new Zend_Db_Adapter_Mysqli_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- $sql .= " LIMIT $count";
- if ($offset > 0) {
- $sql .= " OFFSET $offset";
- }
-
- return $sql;
- }
-
- /**
- * Check if the adapter supports real SQL parameters.
- *
- * @param string $type 'positional' or 'named'
- * @return bool
- */
- public function supportsParameters($type)
- {
- switch ($type) {
- case 'positional':
- return true;
- case 'named':
- default:
- return false;
- }
- }
-
- /**
- * Retrieve server version in PHP style
- *
- *@return string
- */
- public function getServerVersion()
- {
- $this->_connect();
- $version = $this->_connection->server_version;
- $major = (int) ($version / 10000);
- $minor = (int) ($version % 10000 / 100);
- $revision = (int) ($version % 100);
- return $major . '.' . $minor . '.' . $revision;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Oracle/Exception.php zendframework-2.2.6/library/Zend/Db/Adapter/Oracle/Exception.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Oracle/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Oracle/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,60 +0,0 @@
-message = $error['code'] .' '. $error['message'];
- } else {
- $this->message = $error['code'] .' '. $error['message']." "
- . substr($error['sqltext'], 0, $error['offset'])
- . "*"
- . substr($error['sqltext'], $error['offset']);
- }
- $this->code = $error['code'];
- } else if (is_string($error)) {
- $this->message = $error;
- }
- if (!$this->code && $code) {
- $this->code = $code;
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Oracle.php zendframework-2.2.6/library/Zend/Db/Adapter/Oracle.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Oracle.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Oracle.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,682 +0,0 @@
- (string) Connect to the database as this username.
- * password => (string) Password associated with the username.
- * dbname => Either the name of the local Oracle instance, or the
- * name of the entry in tnsnames.ora to which you want to connect.
- * persistent => (boolean) Set TRUE to use a persistent connection
- * @var array
- */
- protected $_config = array(
- 'dbname' => null,
- 'username' => null,
- 'password' => null,
- 'persistent' => false
- );
-
- /**
- * Keys are UPPERCASE SQL datatypes or the constants
- * Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE.
- *
- * Values are:
- * 0 = 32-bit integer
- * 1 = 64-bit integer
- * 2 = float or decimal
- *
- * @var array Associative array of datatypes to values 0, 1, or 2.
- */
- protected $_numericDataTypes = array(
- Zend_Db::INT_TYPE => Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'BINARY_DOUBLE' => Zend_Db::FLOAT_TYPE,
- 'BINARY_FLOAT' => Zend_Db::FLOAT_TYPE,
- 'NUMBER' => Zend_Db::FLOAT_TYPE,
- );
-
- /**
- * @var integer
- */
- protected $_execute_mode = null;
-
- /**
- * Default class name for a DB statement.
- *
- * @var string
- */
- protected $_defaultStmtClass = 'Zend_Db_Statement_Oracle';
-
- /**
- * Check if LOB field are returned as string
- * instead of OCI-Lob object
- *
- * @var boolean
- */
- protected $_lobAsString = null;
-
- /**
- * Creates a connection resource.
- *
- * @return void
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- protected function _connect()
- {
- if (is_resource($this->_connection)) {
- // connection already exists
- return;
- }
-
- if (!extension_loaded('oci8')) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Adapter/Oracle/Exception.php';
- throw new Zend_Db_Adapter_Oracle_Exception('The OCI8 extension is required for this adapter but the extension is not loaded');
- }
-
- $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS);
-
- $connectionFuncName = ($this->_config['persistent'] == true) ? 'oci_pconnect' : 'oci_connect';
-
- $this->_connection = @$connectionFuncName(
- $this->_config['username'],
- $this->_config['password'],
- $this->_config['dbname'],
- $this->_config['charset']);
-
- // check the connection
- if (!$this->_connection) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Adapter/Oracle/Exception.php';
- throw new Zend_Db_Adapter_Oracle_Exception(oci_error());
- }
- }
-
- /**
- * Test if a connection is active
- *
- * @return boolean
- */
- public function isConnected()
- {
- return ((bool) (is_resource($this->_connection)
- && get_resource_type($this->_connection) == 'oci8 connection'));
- }
-
- /**
- * Force the connection to close.
- *
- * @return void
- */
- public function closeConnection()
- {
- if ($this->isConnected()) {
- oci_close($this->_connection);
- }
- $this->_connection = null;
- }
-
- /**
- * Activate/deactivate return of LOB as string
- *
- * @param string $lob_as_string
- * @return Zend_Db_Adapter_Oracle
- */
- public function setLobAsString($lobAsString)
- {
- $this->_lobAsString = (bool) $lobAsString;
- return $this;
- }
-
- /**
- * Return whether or not LOB are returned as string
- *
- * @return boolean
- */
- public function getLobAsString()
- {
- if ($this->_lobAsString === null) {
- // if never set by user, we use driver option if it exists otherwise false
- if (isset($this->_config['driver_options']) &&
- isset($this->_config['driver_options']['lob_as_string'])) {
- $this->_lobAsString = (bool) $this->_config['driver_options']['lob_as_string'];
- } else {
- $this->_lobAsString = false;
- }
- }
- return $this->_lobAsString;
- }
-
- /**
- * Returns an SQL statement for preparation.
- *
- * @param string $sql The SQL statement with placeholders.
- * @return Zend_Db_Statement_Oracle
- */
- public function prepare($sql)
- {
- $this->_connect();
- $stmtClass = $this->_defaultStmtClass;
- if (!class_exists($stmtClass)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($stmtClass);
- }
- $stmt = new $stmtClass($this, $sql);
- if ($stmt instanceof Zend_Db_Statement_Oracle) {
- $stmt->setLobAsString($this->getLobAsString());
- }
- $stmt->setFetchMode($this->_fetchMode);
- return $stmt;
- }
-
- /**
- * Quote a raw string.
- *
- * @param string $value Raw string
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (is_int($value) || is_float($value)) {
- return $value;
- }
- $value = str_replace("'", "''", $value);
- return "'" . addcslashes($value, "\000\n\r\\\032") . "'";
- }
-
- /**
- * Quote a table identifier and alias.
- *
- * @param string|array|Zend_Db_Expr $ident The identifier or expression.
- * @param string $alias An alias for the table.
- * @param boolean $auto If true, heed the AUTO_QUOTE_IDENTIFIERS config option.
- * @return string The quoted identifier and alias.
- */
- public function quoteTableAs($ident, $alias = null, $auto = false)
- {
- // Oracle doesn't allow the 'AS' keyword between the table identifier/expression and alias.
- return $this->_quoteIdentifierAs($ident, $alias, $auto, ' ');
- }
-
- /**
- * Return the most recent value from the specified sequence in the database.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function lastSequenceId($sequenceName)
- {
- $this->_connect();
- $sql = 'SELECT '.$this->quoteIdentifier($sequenceName, true).'.CURRVAL FROM dual';
- $value = $this->fetchOne($sql);
- return $value;
- }
-
- /**
- * Generate a new value from the specified sequence in the database, and return it.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function nextSequenceId($sequenceName)
- {
- $this->_connect();
- $sql = 'SELECT '.$this->quoteIdentifier($sequenceName, true).'.NEXTVAL FROM dual';
- $value = $this->fetchOne($sql);
- return $value;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * Oracle does not support IDENTITY columns, so if the sequence is not
- * specified, this method returns null.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- if ($tableName !== null) {
- $sequenceName = $tableName;
- if ($primaryKey) {
- $sequenceName .= "_$primaryKey";
- }
- $sequenceName .= '_seq';
- return $this->lastSequenceId($sequenceName);
- }
-
- // No support for IDENTITY columns; return null
- return null;
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $this->_connect();
- $data = $this->fetchCol('SELECT table_name FROM all_tables');
- return $data;
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @todo Discover integer unsigned property.
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- $version = $this->getServerVersion();
- if (($version === null) || version_compare($version, '9.0.0', '>=')) {
- $sql = "SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
- TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
- TC.DATA_SCALE, TC.DATA_PRECISION, C.CONSTRAINT_TYPE, CC.POSITION
- FROM ALL_TAB_COLUMNS TC
- LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C
- ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P'))
- ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME
- WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)";
- $bind[':TBNAME'] = $tableName;
- if ($schemaName) {
- $sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
- $bind[':SCNAME'] = $schemaName;
- }
- $sql .= ' ORDER BY TC.COLUMN_ID';
- } else {
- $subSql="SELECT AC.OWNER, AC.TABLE_NAME, ACC.COLUMN_NAME, AC.CONSTRAINT_TYPE, ACC.POSITION
- from ALL_CONSTRAINTS AC, ALL_CONS_COLUMNS ACC
- WHERE ACC.CONSTRAINT_NAME = AC.CONSTRAINT_NAME
- AND ACC.TABLE_NAME = AC.TABLE_NAME
- AND ACC.OWNER = AC.OWNER
- AND AC.CONSTRAINT_TYPE = 'P'
- AND UPPER(AC.TABLE_NAME) = UPPER(:TBNAME)";
- $bind[':TBNAME'] = $tableName;
- if ($schemaName) {
- $subSql .= ' AND UPPER(ACC.OWNER) = UPPER(:SCNAME)';
- $bind[':SCNAME'] = $schemaName;
- }
- $sql="SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
- TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
- TC.DATA_SCALE, TC.DATA_PRECISION, CC.CONSTRAINT_TYPE, CC.POSITION
- FROM ALL_TAB_COLUMNS TC, ($subSql) CC
- WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)
- AND TC.OWNER = CC.OWNER(+) AND TC.TABLE_NAME = CC.TABLE_NAME(+) AND TC.COLUMN_NAME = CC.COLUMN_NAME(+)";
- if ($schemaName) {
- $sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
- }
- $sql .= ' ORDER BY TC.COLUMN_ID';
- }
-
- $stmt = $this->query($sql, $bind);
-
- /**
- * Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
- */
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- $table_name = 0;
- $owner = 1;
- $column_name = 2;
- $data_type = 3;
- $data_default = 4;
- $nullable = 5;
- $column_id = 6;
- $data_length = 7;
- $data_scale = 8;
- $data_precision = 9;
- $constraint_type = 10;
- $position = 11;
-
- $desc = array();
- foreach ($result as $key => $row) {
- list ($primary, $primaryPosition, $identity) = array(false, null, false);
- if ($row[$constraint_type] == 'P') {
- $primary = true;
- $primaryPosition = $row[$position];
- /**
- * Oracle does not support auto-increment keys.
- */
- $identity = false;
- }
- $desc[$this->foldCase($row[$column_name])] = array(
- 'SCHEMA_NAME' => $this->foldCase($row[$owner]),
- 'TABLE_NAME' => $this->foldCase($row[$table_name]),
- 'COLUMN_NAME' => $this->foldCase($row[$column_name]),
- 'COLUMN_POSITION' => $row[$column_id],
- 'DATA_TYPE' => $row[$data_type],
- 'DEFAULT' => $row[$data_default],
- 'NULLABLE' => (bool) ($row[$nullable] == 'Y'),
- 'LENGTH' => $row[$data_length],
- 'SCALE' => $row[$data_scale],
- 'PRECISION' => $row[$data_precision],
- 'UNSIGNED' => null, // @todo
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
- return $desc;
- }
-
- /**
- * Leave autocommit mode and begin a transaction.
- *
- * @return void
- */
- protected function _beginTransaction()
- {
- $this->_setExecuteMode(OCI_DEFAULT);
- }
-
- /**
- * Commit a transaction and return to autocommit mode.
- *
- * @return void
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- protected function _commit()
- {
- if (!oci_commit($this->_connection)) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Adapter/Oracle/Exception.php';
- throw new Zend_Db_Adapter_Oracle_Exception(oci_error($this->_connection));
- }
- $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS);
- }
-
- /**
- * Roll back a transaction and return to autocommit mode.
- *
- * @return void
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- protected function _rollBack()
- {
- if (!oci_rollback($this->_connection)) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Adapter/Oracle/Exception.php';
- throw new Zend_Db_Adapter_Oracle_Exception(oci_error($this->_connection));
- }
- $this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS);
- }
-
- /**
- * Set the fetch mode.
- *
- * @todo Support FETCH_CLASS and FETCH_INTO.
- *
- * @param integer $mode A fetch mode.
- * @return void
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- public function setFetchMode($mode)
- {
- switch ($mode) {
- case Zend_Db::FETCH_NUM: // seq array
- case Zend_Db::FETCH_ASSOC: // assoc array
- case Zend_Db::FETCH_BOTH: // seq+assoc array
- case Zend_Db::FETCH_OBJ: // object
- $this->_fetchMode = $mode;
- break;
- case Zend_Db::FETCH_BOUND: // bound to PHP variable
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Adapter/Oracle/Exception.php';
- throw new Zend_Db_Adapter_Oracle_Exception('FETCH_BOUND is not supported yet');
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Adapter/Oracle/Exception.php';
- throw new Zend_Db_Adapter_Oracle_Exception("Invalid fetch mode '$mode' specified");
- break;
- }
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @return string
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Adapter/Oracle/Exception.php';
- throw new Zend_Db_Adapter_Oracle_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Adapter/Oracle/Exception.php';
- throw new Zend_Db_Adapter_Oracle_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- /**
- * Oracle does not implement the LIMIT clause as some RDBMS do.
- * We have to simulate it with subqueries and ROWNUM.
- * Unfortunately because we use the column wildcard "*",
- * this puts an extra column into the query result set.
- */
- $limit_sql = "SELECT z2.*
- FROM (
- SELECT z1.*, ROWNUM AS \"zend_db_rownum\"
- FROM (
- " . $sql . "
- ) z1
- ) z2
- WHERE z2.\"zend_db_rownum\" BETWEEN " . ($offset+1) . " AND " . ($offset+$count);
- return $limit_sql;
- }
-
- /**
- * @param integer $mode
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- private function _setExecuteMode($mode)
- {
- switch($mode) {
- case OCI_COMMIT_ON_SUCCESS:
- case OCI_DEFAULT:
- case OCI_DESCRIBE_ONLY:
- $this->_execute_mode = $mode;
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Adapter/Oracle/Exception.php';
- throw new Zend_Db_Adapter_Oracle_Exception("Invalid execution mode '$mode' specified");
- break;
- }
- }
-
- /**
- * @return int
- */
- public function _getExecuteMode()
- {
- return $this->_execute_mode;
- }
-
- /**
- * Inserts a table row with specified data.
- *
- * Oracle does not support anonymous ('?') binds.
- *
- * @param mixed $table The table to insert data into.
- * @param array $bind Column-value pairs.
- * @return int The number of affected rows.
- */
- public function insert($table, array $bind)
- {
- $i = 0;
- // extract and quote col names from the array keys
- $cols = array();
- $vals = array();
- foreach ($bind as $col => $val) {
- $cols[] = $this->quoteIdentifier($col, true);
- if ($val instanceof Zend_Db_Expr) {
- $vals[] = $val->__toString();
- unset($bind[$col]);
- } else {
- $vals[] = ':'.$col.$i;
- unset($bind[$col]);
- $bind[':'.$col.$i] = $val;
- }
- $i++;
- }
-
- // build the statement
- $sql = "INSERT INTO "
- . $this->quoteIdentifier($table, true)
- . ' (' . implode(', ', $cols) . ') '
- . 'VALUES (' . implode(', ', $vals) . ')';
-
- // execute the statement and return the number of affected rows
- $stmt = $this->query($sql, $bind);
- $result = $stmt->rowCount();
- return $result;
- }
-
- /**
- * Check if the adapter supports real SQL parameters.
- *
- * @param string $type 'positional' or 'named'
- * @return bool
- */
- public function supportsParameters($type)
- {
- switch ($type) {
- case 'named':
- return true;
- case 'positional':
- default:
- return false;
- }
- }
-
- /**
- * Retrieve server version in PHP style
- *
- * @return string
- */
- public function getServerVersion()
- {
- $this->_connect();
- $version = oci_server_version($this->_connection);
- if ($version !== false) {
- $matches = null;
- if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $version, $matches)) {
- return $matches[1];
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/ParameterContainer.php zendframework-2.2.6/library/Zend/Db/Adapter/ParameterContainer.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/ParameterContainer.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/ParameterContainer.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,336 @@
+setFromArray($data);
+ }
+ }
+
+ /**
+ * Offset exists
+ *
+ * @param string $name
+ * @return bool
+ */
+ public function offsetExists($name)
+ {
+ return (isset($this->data[$name]));
+ }
+
+ /**
+ * Offset get
+ *
+ * @param string $name
+ * @return mixed
+ */
+ public function offsetGet($name)
+ {
+ return (isset($this->data[$name])) ? $this->data[$name] : null;
+ }
+
+ /**
+ * @param $name
+ * @param $from
+ */
+ public function offsetSetReference($name, $from)
+ {
+ $this->data[$name] =& $this->data[$from];
+ }
+
+ /**
+ * Offset set
+ *
+ * @param string|int $name
+ * @param mixed $value
+ * @param mixed $errata
+ */
+ public function offsetSet($name, $value, $errata = null)
+ {
+ $position = false;
+
+ // if integer, get name for this position
+ if (is_int($name)) {
+ if (isset($this->positions[$name])) {
+ $position = $name;
+ $name = $this->positions[$name];
+ } else {
+ $name = (string) $name;
+ }
+ } elseif (is_string($name)) {
+ // is a string:
+ $currentNames = array_keys($this->data);
+ $position = array_search($name, $currentNames, true);
+ } elseif ($name === null) {
+ $name = (string) count($this->data);
+ } else {
+ throw new Exception\InvalidArgumentException('Keys must be string, integer or null');
+ }
+
+ if ($position === false) {
+ $this->positions[] = $name;
+ }
+
+ $this->data[$name] = $value;
+
+ if ($errata) {
+ $this->offsetSetErrata($name, $errata);
+ }
+ }
+
+ /**
+ * Offset unset
+ *
+ * @param string $name
+ * @return ParameterContainer
+ */
+ public function offsetUnset($name)
+ {
+ if (is_int($name) && isset($this->positions[$name])) {
+ $name = $this->positions[$name];
+ }
+ unset($this->data[$name]);
+ return $this;
+ }
+
+ /**
+ * Set from array
+ *
+ * @param array $data
+ * @return ParameterContainer
+ */
+ public function setFromArray(Array $data)
+ {
+ foreach ($data as $n => $v) {
+ $this->offsetSet($n, $v);
+ }
+ return $this;
+ }
+
+ /**
+ * Offset set errata
+ *
+ * @param string|int $name
+ * @param mixed $errata
+ */
+ public function offsetSetErrata($name, $errata)
+ {
+ if (is_int($name)) {
+ $name = $this->positions[$name];
+ }
+ $this->errata[$name] = $errata;
+ }
+
+ /**
+ * Offset get errata
+ *
+ * @param string|int $name
+ * @throws Exception\InvalidArgumentException
+ * @return mixed
+ */
+ public function offsetGetErrata($name)
+ {
+ if (is_int($name)) {
+ $name = $this->positions[$name];
+ }
+ if (!array_key_exists($name, $this->data)) {
+ throw new Exception\InvalidArgumentException('Data does not exist for this name/position');
+ }
+ return $this->errata[$name];
+ }
+
+ /**
+ * Offset has errata
+ *
+ * @param string|int $name
+ * @return bool
+ */
+ public function offsetHasErrata($name)
+ {
+ if (is_int($name)) {
+ $name = $this->positions[$name];
+ }
+ return (isset($this->errata[$name]));
+ }
+
+ /**
+ * Offset unset errata
+ *
+ * @param string|int $name
+ * @throws Exception\InvalidArgumentException
+ */
+ public function offsetUnsetErrata($name)
+ {
+ if (is_int($name)) {
+ $name = $this->positions[$name];
+ }
+ if (!array_key_exists($name, $this->errata)) {
+ throw new Exception\InvalidArgumentException('Data does not exist for this name/position');
+ }
+ $this->errata[$name] = null;
+ }
+
+ /**
+ * Get errata iterator
+ *
+ * @return \ArrayIterator
+ */
+ public function getErrataIterator()
+ {
+ return new \ArrayIterator($this->errata);
+ }
+
+ /**
+ * getNamedArray
+ *
+ * @return array
+ */
+ public function getNamedArray()
+ {
+ return $this->data;
+ }
+
+ /**
+ * getNamedArray
+ *
+ * @return array
+ */
+ public function getPositionalArray()
+ {
+ return array_values($this->data);
+ }
+
+ /**
+ * count
+ *
+ * @return int
+ */
+ public function count()
+ {
+ return count($this->data);
+ }
+
+ /**
+ * Current
+ *
+ * @return mixed
+ */
+ public function current()
+ {
+ return current($this->data);
+ }
+
+ /**
+ * Next
+ *
+ * @return mixed
+ */
+ public function next()
+ {
+ return next($this->data);
+ }
+
+ /**
+ * Key
+ *
+ * @return mixed
+ */
+ public function key()
+ {
+ return key($this->data);
+ }
+
+ /**
+ * Valid
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return (current($this->data) !== false);
+ }
+
+ /**
+ * Rewind
+ */
+ public function rewind()
+ {
+ reset($this->data);
+ }
+
+ /**
+ * @param array|ParameterContainer $parameters
+ * @throws Exception\InvalidArgumentException
+ * @return ParameterContainer
+ */
+ public function merge($parameters)
+ {
+ if (!is_array($parameters) && !$parameters instanceof ParameterContainer) {
+ throw new Exception\InvalidArgumentException('$parameters must be an array or an instance of ParameterContainer');
+ }
+
+ if (count($parameters) == 0) {
+ return $this;
+ }
+
+ if ($parameters instanceof ParameterContainer) {
+ $parameters = $parameters->getNamedArray();
+ }
+
+ foreach ($parameters as $key => $value) {
+ if (is_int($key)) {
+ $key = null;
+ }
+ $this->offsetSet($key, $value);
+ }
+ return $this;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Abstract.php zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Abstract.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Abstract.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Abstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,401 +0,0 @@
-_config settings.
- *
- * @return string
- */
- protected function _dsn()
- {
- // baseline of DSN parts
- $dsn = $this->_config;
-
- // don't pass the username, password, charset, persistent and driver_options in the DSN
- unset($dsn['username']);
- unset($dsn['password']);
- unset($dsn['options']);
- unset($dsn['charset']);
- unset($dsn['persistent']);
- unset($dsn['driver_options']);
-
- // use all remaining parts in the DSN
- foreach ($dsn as $key => $val) {
- $dsn[$key] = "$key=$val";
- }
-
- return $this->_pdoType . ':' . implode(';', $dsn);
- }
-
- /**
- * Creates a PDO object and connects to the database.
- *
- * @return void
- * @throws Zend_Db_Adapter_Exception
- */
- protected function _connect()
- {
- // if we already have a PDO object, no need to re-connect.
- if ($this->_connection) {
- return;
- }
-
- // get the dsn first, because some adapters alter the $_pdoType
- $dsn = $this->_dsn();
-
- // check for PDO extension
- if (!extension_loaded('pdo')) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception('The PDO extension is required for this adapter but the extension is not loaded');
- }
-
- // check the PDO driver is available
- if (!in_array($this->_pdoType, PDO::getAvailableDrivers())) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception('The ' . $this->_pdoType . ' driver is not currently installed');
- }
-
- // create PDO connection
- $q = $this->_profiler->queryStart('connect', Zend_Db_Profiler::CONNECT);
-
- // add the persistence flag if we find it in our config array
- if (isset($this->_config['persistent']) && ($this->_config['persistent'] == true)) {
- $this->_config['driver_options'][PDO::ATTR_PERSISTENT] = true;
- }
-
- try {
- $this->_connection = new PDO(
- $dsn,
- $this->_config['username'],
- $this->_config['password'],
- $this->_config['driver_options']
- );
-
- $this->_profiler->queryEnd($q);
-
- // set the PDO connection to perform case-folding on array keys, or not
- $this->_connection->setAttribute(PDO::ATTR_CASE, $this->_caseFolding);
-
- // always use exceptions.
- $this->_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-
- } catch (PDOException $e) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
- }
-
- }
-
- /**
- * Test if a connection is active
- *
- * @return boolean
- */
- public function isConnected()
- {
- return ((bool) ($this->_connection instanceof PDO));
- }
-
- /**
- * Force the connection to close.
- *
- * @return void
- */
- public function closeConnection()
- {
- $this->_connection = null;
- }
-
- /**
- * Prepares an SQL statement.
- *
- * @param string $sql The SQL statement with placeholders.
- * @param array $bind An array of data to bind to the placeholders.
- * @return PDOStatement
- */
- public function prepare($sql)
- {
- $this->_connect();
- $stmtClass = $this->_defaultStmtClass;
- if (!class_exists($stmtClass)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($stmtClass);
- }
- $stmt = new $stmtClass($this, $sql);
- $stmt->setFetchMode($this->_fetchMode);
- return $stmt;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * On RDBMS brands that don't support sequences, $tableName and $primaryKey
- * are ignored.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- $this->_connect();
- return $this->_connection->lastInsertId();
- }
-
- /**
- * Special handling for PDO query().
- * All bind parameter names must begin with ':'
- *
- * @param string|Zend_Db_Select $sql The SQL statement with placeholders.
- * @param array $bind An array of data to bind to the placeholders.
- * @return Zend_Db_Statement_Pdo
- * @throws Zend_Db_Adapter_Exception To re-throw PDOException.
- */
- public function query($sql, $bind = array())
- {
- if (empty($bind) && $sql instanceof Zend_Db_Select) {
- $bind = $sql->getBind();
- }
-
- if (is_array($bind)) {
- foreach ($bind as $name => $value) {
- if (!is_int($name) && !preg_match('/^:/', $name)) {
- $newName = ":$name";
- unset($bind[$name]);
- $bind[$newName] = $value;
- }
- }
- }
-
- try {
- return parent::query($sql, $bind);
- } catch (PDOException $e) {
- /**
- * @see Zend_Db_Statement_Exception
- */
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Executes an SQL statement and return the number of affected rows
- *
- * @param mixed $sql The SQL statement with placeholders.
- * May be a string or Zend_Db_Select.
- * @return integer Number of rows that were modified
- * or deleted by the SQL statement
- */
- public function exec($sql)
- {
- if ($sql instanceof Zend_Db_Select) {
- $sql = $sql->assemble();
- }
-
- try {
- $affected = $this->getConnection()->exec($sql);
-
- if ($affected === false) {
- $errorInfo = $this->getConnection()->errorInfo();
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception($errorInfo[2]);
- }
-
- return $affected;
- } catch (PDOException $e) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Quote a raw string.
- *
- * @param string $value Raw string
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (is_int($value) || is_float($value)) {
- return $value;
- }
- $this->_connect();
- return $this->_connection->quote($value);
- }
-
- /**
- * Begin a transaction.
- */
- protected function _beginTransaction()
- {
- $this->_connect();
- $this->_connection->beginTransaction();
- }
-
- /**
- * Commit a transaction.
- */
- protected function _commit()
- {
- $this->_connect();
- $this->_connection->commit();
- }
-
- /**
- * Roll-back a transaction.
- */
- protected function _rollBack() {
- $this->_connect();
- $this->_connection->rollBack();
- }
-
- /**
- * Set the PDO fetch mode.
- *
- * @todo Support FETCH_CLASS and FETCH_INTO.
- *
- * @param int $mode A PDO fetch mode.
- * @return void
- * @throws Zend_Db_Adapter_Exception
- */
- public function setFetchMode($mode)
- {
- //check for PDO extension
- if (!extension_loaded('pdo')) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception('The PDO extension is required for this adapter but the extension is not loaded');
- }
- switch ($mode) {
- case PDO::FETCH_LAZY:
- case PDO::FETCH_ASSOC:
- case PDO::FETCH_NUM:
- case PDO::FETCH_BOTH:
- case PDO::FETCH_NAMED:
- case PDO::FETCH_OBJ:
- $this->_fetchMode = $mode;
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("Invalid fetch mode '$mode' specified");
- break;
- }
- }
-
- /**
- * Check if the adapter supports real SQL parameters.
- *
- * @param string $type 'positional' or 'named'
- * @return bool
- */
- public function supportsParameters($type)
- {
- switch ($type) {
- case 'positional':
- case 'named':
- default:
- return true;
- }
- }
-
- /**
- * Retrieve server version in PHP style
- *
- * @return string
- */
- public function getServerVersion()
- {
- $this->_connect();
- try {
- $version = $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION);
- } catch (PDOException $e) {
- // In case of the driver doesn't support getting attributes
- return null;
- }
- $matches = null;
- if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $version, $matches)) {
- return $matches[1];
- } else {
- return null;
- }
- }
-}
-
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Ibm/Db2.php zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Ibm/Db2.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Ibm/Db2.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Ibm/Db2.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,228 +0,0 @@
-_adapter = $adapter;
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $sql = "SELECT tabname "
- . "FROM SYSCAT.TABLES ";
- return $this->_adapter->fetchCol($sql);
- }
-
- /**
- * DB2 catalog lookup for describe table
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- $sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
- c.typename, c.default, c.nulls, c.length, c.scale,
- c.identity, tc.type AS tabconsttype, k.colseq
- FROM syscat.columns c
- LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
- ON (k.tabschema = tc.tabschema
- AND k.tabname = tc.tabname
- AND tc.type = 'P'))
- ON (c.tabschema = k.tabschema
- AND c.tabname = k.tabname
- AND c.colname = k.colname)
- WHERE "
- . $this->_adapter->quoteInto('UPPER(c.tabname) = UPPER(?)', $tableName);
- if ($schemaName) {
- $sql .= $this->_adapter->quoteInto(' AND UPPER(c.tabschema) = UPPER(?)', $schemaName);
- }
- $sql .= " ORDER BY c.colno";
-
- $desc = array();
- $stmt = $this->_adapter->query($sql);
-
- /**
- * To avoid case issues, fetch using FETCH_NUM
- */
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- /**
- * The ordering of columns is defined by the query so we can map
- * to variables to improve readability
- */
- $tabschema = 0;
- $tabname = 1;
- $colname = 2;
- $colno = 3;
- $typename = 4;
- $default = 5;
- $nulls = 6;
- $length = 7;
- $scale = 8;
- $identityCol = 9;
- $tabconstype = 10;
- $colseq = 11;
-
- foreach ($result as $key => $row) {
- list ($primary, $primaryPosition, $identity) = array(false, null, false);
- if ($row[$tabconstype] == 'P') {
- $primary = true;
- $primaryPosition = $row[$colseq];
- }
- /**
- * In IBM DB2, an column can be IDENTITY
- * even if it is not part of the PRIMARY KEY.
- */
- if ($row[$identityCol] == 'Y') {
- $identity = true;
- }
-
- $desc[$this->_adapter->foldCase($row[$colname])] = array(
- 'SCHEMA_NAME' => $this->_adapter->foldCase($row[$tabschema]),
- 'TABLE_NAME' => $this->_adapter->foldCase($row[$tabname]),
- 'COLUMN_NAME' => $this->_adapter->foldCase($row[$colname]),
- 'COLUMN_POSITION' => $row[$colno]+1,
- 'DATA_TYPE' => $row[$typename],
- 'DEFAULT' => $row[$default],
- 'NULLABLE' => (bool) ($row[$nulls] == 'Y'),
- 'LENGTH' => $row[$length],
- 'SCALE' => $row[$scale],
- 'PRECISION' => ($row[$typename] == 'DECIMAL' ? $row[$length] : 0),
- 'UNSIGNED' => false,
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
-
- return $desc;
- }
-
- /**
- * Adds a DB2-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @throws Zend_Db_Adapter_Exception
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count < 0) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- } else {
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- if ($offset == 0 && $count > 0) {
- $limit_sql = $sql . " FETCH FIRST $count ROWS ONLY";
- return $limit_sql;
- }
- /**
- * DB2 does not implement the LIMIT clause as some RDBMS do.
- * We have to simulate it with subqueries and ROWNUM.
- * Unfortunately because we use the column wildcard "*",
- * this puts an extra column into the query result set.
- */
- $limit_sql = "SELECT z2.*
- FROM (
- SELECT ROW_NUMBER() OVER() AS \"ZEND_DB_ROWNUM\", z1.*
- FROM (
- " . $sql . "
- ) z1
- ) z2
- WHERE z2.zend_db_rownum BETWEEN " . ($offset+1) . " AND " . ($offset+$count);
- }
- return $limit_sql;
- }
-
- /**
- * DB2-specific last sequence id
- *
- * @param string $sequenceName
- * @return integer
- */
- public function lastSequenceId($sequenceName)
- {
- $sql = 'SELECT PREVVAL FOR '.$this->_adapter->quoteIdentifier($sequenceName).' AS VAL FROM SYSIBM.SYSDUMMY1';
- $value = $this->_adapter->fetchOne($sql);
- return $value;
- }
-
- /**
- * DB2-specific sequence id value
- *
- * @param string $sequenceName
- * @return integer
- */
- public function nextSequenceId($sequenceName)
- {
- $sql = 'SELECT NEXTVAL FOR '.$this->_adapter->quoteIdentifier($sequenceName).' AS VAL FROM SYSIBM.SYSDUMMY1';
- $value = $this->_adapter->fetchOne($sql);
- return $value;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Ibm/Ids.php zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Ibm/Ids.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Ibm/Ids.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Ibm/Ids.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,301 +0,0 @@
-_adapter = $adapter;
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $sql = "SELECT tabname "
- . "FROM systables ";
-
- return $this->_adapter->fetchCol($sql);
- }
-
- /**
- * IDS catalog lookup for describe table
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- // this is still a work in progress
-
- $sql= "SELECT DISTINCT t.owner, t.tabname, c.colname, c.colno, c.coltype,
- d.default, c.collength, t.tabid
- FROM syscolumns c
- JOIN systables t ON c.tabid = t.tabid
- LEFT JOIN sysdefaults d ON c.tabid = d.tabid AND c.colno = d.colno
- WHERE "
- . $this->_adapter->quoteInto('UPPER(t.tabname) = UPPER(?)', $tableName);
- if ($schemaName) {
- $sql .= $this->_adapter->quoteInto(' AND UPPER(t.owner) = UPPER(?)', $schemaName);
- }
- $sql .= " ORDER BY c.colno";
-
- $desc = array();
- $stmt = $this->_adapter->query($sql);
-
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- /**
- * The ordering of columns is defined by the query so we can map
- * to variables to improve readability
- */
- $tabschema = 0;
- $tabname = 1;
- $colname = 2;
- $colno = 3;
- $typename = 4;
- $default = 5;
- $length = 6;
- $tabid = 7;
-
- $primaryCols = null;
-
- foreach ($result as $key => $row) {
- $primary = false;
- $primaryPosition = null;
-
- if (!$primaryCols) {
- $primaryCols = $this->_getPrimaryInfo($row[$tabid]);
- }
-
- if (array_key_exists($row[$colno], $primaryCols)) {
- $primary = true;
- $primaryPosition = $primaryCols[$row[$colno]];
- }
-
- $identity = false;
- if ($row[$typename] == 6 + 256 ||
- $row[$typename] == 18 + 256) {
- $identity = true;
- }
-
- $desc[$this->_adapter->foldCase($row[$colname])] = array (
- 'SCHEMA_NAME' => $this->_adapter->foldCase($row[$tabschema]),
- 'TABLE_NAME' => $this->_adapter->foldCase($row[$tabname]),
- 'COLUMN_NAME' => $this->_adapter->foldCase($row[$colname]),
- 'COLUMN_POSITION' => $row[$colno],
- 'DATA_TYPE' => $this->_getDataType($row[$typename]),
- 'DEFAULT' => $row[$default],
- 'NULLABLE' => (bool) !($row[$typename] - 256 >= 0),
- 'LENGTH' => $row[$length],
- 'SCALE' => ($row[$typename] == 5 ? $row[$length]&255 : 0),
- 'PRECISION' => ($row[$typename] == 5 ? (int)($row[$length]/256) : 0),
- 'UNSIGNED' => false,
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
-
- return $desc;
- }
-
- /**
- * Map number representation of a data type
- * to a string
- *
- * @param int $typeNo
- * @return string
- */
- protected function _getDataType($typeNo)
- {
- $typemap = array(
- 0 => "CHAR",
- 1 => "SMALLINT",
- 2 => "INTEGER",
- 3 => "FLOAT",
- 4 => "SMALLFLOAT",
- 5 => "DECIMAL",
- 6 => "SERIAL",
- 7 => "DATE",
- 8 => "MONEY",
- 9 => "NULL",
- 10 => "DATETIME",
- 11 => "BYTE",
- 12 => "TEXT",
- 13 => "VARCHAR",
- 14 => "INTERVAL",
- 15 => "NCHAR",
- 16 => "NVARCHAR",
- 17 => "INT8",
- 18 => "SERIAL8",
- 19 => "SET",
- 20 => "MULTISET",
- 21 => "LIST",
- 22 => "Unnamed ROW",
- 40 => "Variable-length opaque type",
- 4118 => "Named ROW"
- );
-
- if ($typeNo - 256 >= 0) {
- $typeNo = $typeNo - 256;
- }
-
- return $typemap[$typeNo];
- }
-
- /**
- * Helper method to retrieve primary key column
- * and column location
- *
- * @param int $tabid
- * @return array
- */
- protected function _getPrimaryInfo($tabid)
- {
- $sql = "SELECT i.part1, i.part2, i.part3, i.part4, i.part5, i.part6,
- i.part7, i.part8, i.part9, i.part10, i.part11, i.part12,
- i.part13, i.part14, i.part15, i.part16
- FROM sysindexes i
- JOIN sysconstraints c ON c.idxname = i.idxname
- WHERE i.tabid = " . $tabid . " AND c.constrtype = 'P'";
-
- $stmt = $this->_adapter->query($sql);
- $results = $stmt->fetchAll();
-
- $cols = array();
-
- // this should return only 1 row
- // unless there is no primary key,
- // in which case, the empty array is returned
- if ($results) {
- $row = $results[0];
- } else {
- return $cols;
- }
-
- $position = 0;
- foreach ($row as $key => $colno) {
- $position++;
- if ($colno == 0) {
- return $cols;
- } else {
- $cols[$colno] = $position;
- }
- }
- }
-
- /**
- * Adds an IDS-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @throws Zend_Db_Adapter_Exception
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count < 0) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- } else if ($count == 0) {
- $limit_sql = str_ireplace("SELECT", "SELECT * FROM (SELECT", $sql);
- $limit_sql .= ") WHERE 0 = 1";
- } else {
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
- if ($offset == 0) {
- $limit_sql = str_ireplace("SELECT", "SELECT FIRST $count", $sql);
- } else {
- $limit_sql = str_ireplace("SELECT", "SELECT SKIP $offset LIMIT $count", $sql);
- }
- }
- return $limit_sql;
- }
-
- /**
- * IDS-specific last sequence id
- *
- * @param string $sequenceName
- * @return integer
- */
- public function lastSequenceId($sequenceName)
- {
- $sql = 'SELECT '.$this->_adapter->quoteIdentifier($sequenceName).'.CURRVAL FROM '
- .'systables WHERE tabid = 1';
- $value = $this->_adapter->fetchOne($sql);
- return $value;
- }
-
- /**
- * IDS-specific sequence id value
- *
- * @param string $sequenceName
- * @return integer
- */
- public function nextSequenceId($sequenceName)
- {
- $sql = 'SELECT '.$this->_adapter->quoteIdentifier($sequenceName).'.NEXTVAL FROM '
- .'systables WHERE tabid = 1';
- $value = $this->_adapter->fetchOne($sql);
- return $value;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Ibm.php zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Ibm.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Ibm.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Ibm.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,360 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INTEGER' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'DEC' => Zend_Db::FLOAT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE,
- 'FLOAT' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Creates a PDO object and connects to the database.
- *
- * The IBM data server is set.
- * Current options are DB2 or IDS
- * @todo also differentiate between z/OS and i/5
- *
- * @return void
- * @throws Zend_Db_Adapter_Exception
- */
- public function _connect()
- {
- if ($this->_connection) {
- return;
- }
- parent::_connect();
-
- $this->getConnection()->setAttribute(Zend_Db::ATTR_STRINGIFY_FETCHES, true);
-
- try {
- if ($this->_serverType === null) {
- $server = substr($this->getConnection()->getAttribute(PDO::ATTR_SERVER_INFO), 0, 3);
-
- switch ($server) {
- case 'DB2':
- $this->_serverType = new Zend_Db_Adapter_Pdo_Ibm_Db2($this);
-
- // Add DB2-specific numeric types
- $this->_numericDataTypes['DECFLOAT'] = Zend_Db::FLOAT_TYPE;
- $this->_numericDataTypes['DOUBLE'] = Zend_Db::FLOAT_TYPE;
- $this->_numericDataTypes['NUM'] = Zend_Db::FLOAT_TYPE;
-
- break;
- case 'IDS':
- $this->_serverType = new Zend_Db_Adapter_Pdo_Ibm_Ids($this);
-
- // Add IDS-specific numeric types
- $this->_numericDataTypes['SERIAL'] = Zend_Db::INT_TYPE;
- $this->_numericDataTypes['SERIAL8'] = Zend_Db::BIGINT_TYPE;
- $this->_numericDataTypes['INT8'] = Zend_Db::BIGINT_TYPE;
- $this->_numericDataTypes['SMALLFLOAT'] = Zend_Db::FLOAT_TYPE;
- $this->_numericDataTypes['MONEY'] = Zend_Db::FLOAT_TYPE;
-
- break;
- }
- }
- } catch (PDOException $e) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- $error = strpos($e->getMessage(), 'driver does not support that attribute');
- if ($error) {
- throw new Zend_Db_Adapter_Exception("PDO_IBM driver extension is downlevel. Please use driver release version 1.2.1 or later", 0, $e);
- } else {
- throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
- }
-
- /**
- * Creates a PDO DSN for the adapter from $this->_config settings.
- *
- * @return string
- */
- protected function _dsn()
- {
- $this->_checkRequiredOptions($this->_config);
-
- // check if using full connection string
- if (array_key_exists('host', $this->_config)) {
- $dsn = ';DATABASE=' . $this->_config['dbname']
- . ';HOSTNAME=' . $this->_config['host']
- . ';PORT=' . $this->_config['port']
- // PDO_IBM supports only DB2 TCPIP protocol
- . ';PROTOCOL=' . 'TCPIP;';
- } else {
- // catalogued connection
- $dsn = $this->_config['dbname'];
- }
- return $this->_pdoType . ': ' . $dsn;
- }
-
- /**
- * Checks required options
- *
- * @param array $config
- * @throws Zend_Db_Adapter_Exception
- * @return void
- */
- protected function _checkRequiredOptions(array $config)
- {
- parent::_checkRequiredOptions($config);
-
- if (array_key_exists('host', $this->_config) &&
- !array_key_exists('port', $config)) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("Configuration must have a key for 'port' when 'host' is specified");
- }
- }
-
- /**
- * Prepares an SQL statement.
- *
- * @param string $sql The SQL statement with placeholders.
- * @param array $bind An array of data to bind to the placeholders.
- * @return PDOStatement
- */
- public function prepare($sql)
- {
- $this->_connect();
- $stmtClass = $this->_defaultStmtClass;
- $stmt = new $stmtClass($this, $sql);
- $stmt->setFetchMode($this->_fetchMode);
- return $stmt;
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $this->_connect();
- return $this->_serverType->listTables();
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- *
- * @todo Discover integer unsigned property.
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- $this->_connect();
- return $this->_serverType->describeTable($tableName, $schemaName);
- }
-
- /**
- * Inserts a table row with specified data.
- * Special handling for PDO_IBM
- * remove empty slots
- *
- * @param mixed $table The table to insert data into.
- * @param array $bind Column-value pairs.
- * @return int The number of affected rows.
- */
- public function insert($table, array $bind)
- {
- $this->_connect();
- $newbind = array();
- if (is_array($bind)) {
- foreach ($bind as $name => $value) {
- if($value !== null) {
- $newbind[$name] = $value;
- }
- }
- }
-
- return parent::insert($table, $newbind);
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $this->_connect();
- return $this->_serverType->limit($sql, $count, $offset);
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT
- * column.
- *
- * @param string $tableName OPTIONAL
- * @param string $primaryKey OPTIONAL
- * @return integer
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- $this->_connect();
-
- if ($tableName !== null) {
- $sequenceName = $tableName;
- if ($primaryKey) {
- $sequenceName .= "_$primaryKey";
- }
- $sequenceName .= '_seq';
- return $this->lastSequenceId($sequenceName);
- }
-
- $id = $this->getConnection()->lastInsertId();
-
- return $id;
- }
-
- /**
- * Return the most recent value from the specified sequence in the database.
- *
- * @param string $sequenceName
- * @return integer
- */
- public function lastSequenceId($sequenceName)
- {
- $this->_connect();
- return $this->_serverType->lastSequenceId($sequenceName);
- }
-
- /**
- * Generate a new value from the specified sequence in the database,
- * and return it.
- *
- * @param string $sequenceName
- * @return integer
- */
- public function nextSequenceId($sequenceName)
- {
- $this->_connect();
- return $this->_serverType->nextSequenceId($sequenceName);
- }
-
- /**
- * Retrieve server version in PHP style
- * Pdo_Idm doesn't support getAttribute(PDO::ATTR_SERVER_VERSION)
- * @return string
- */
- public function getServerVersion()
- {
- try {
- $stmt = $this->query('SELECT service_level, fixpack_num FROM TABLE (sysproc.env_get_inst_info()) as INSTANCEINFO');
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
- if (count($result)) {
- $matches = null;
- if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $result[0][0], $matches)) {
- return $matches[1];
- } else {
- return null;
- }
- }
- return null;
- } catch (PDOException $e) {
- return null;
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Mssql.php zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Mssql.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Mssql.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Mssql.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,423 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INT' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'TINYINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'FLOAT' => Zend_Db::FLOAT_TYPE,
- 'MONEY' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE,
- 'SMALLMONEY' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Creates a PDO DSN for the adapter from $this->_config settings.
- *
- * @return string
- */
- protected function _dsn()
- {
- // baseline of DSN parts
- $dsn = $this->_config;
-
- // don't pass the username and password in the DSN
- unset($dsn['username']);
- unset($dsn['password']);
- unset($dsn['options']);
- unset($dsn['persistent']);
- unset($dsn['driver_options']);
-
- if (isset($dsn['port'])) {
- $seperator = ':';
- if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
- $seperator = ',';
- }
- $dsn['host'] .= $seperator . $dsn['port'];
- unset($dsn['port']);
- }
-
- // this driver supports multiple DSN prefixes
- // @see http://www.php.net/manual/en/ref.pdo-dblib.connection.php
- if (isset($dsn['pdoType'])) {
- switch (strtolower($dsn['pdoType'])) {
- case 'freetds':
- case 'sybase':
- $this->_pdoType = 'sybase';
- break;
- case 'mssql':
- $this->_pdoType = 'mssql';
- break;
- case 'dblib':
- default:
- $this->_pdoType = 'dblib';
- break;
- }
- unset($dsn['pdoType']);
- }
-
- // use all remaining parts in the DSN
- foreach ($dsn as $key => $val) {
- $dsn[$key] = "$key=$val";
- }
-
- $dsn = $this->_pdoType . ':' . implode(';', $dsn);
- return $dsn;
- }
-
- /**
- * @return void
- */
- protected function _connect()
- {
- if ($this->_connection) {
- return;
- }
- parent::_connect();
- $this->_connection->exec('SET QUOTED_IDENTIFIER ON');
- }
-
- /**
- * Begin a transaction.
- *
- * It is necessary to override the abstract PDO transaction functions here, as
- * the PDO driver for MSSQL does not support transactions.
- */
- protected function _beginTransaction()
- {
- $this->_connect();
- $this->_connection->exec('BEGIN TRANSACTION');
- return true;
- }
-
- /**
- * Commit a transaction.
- *
- * It is necessary to override the abstract PDO transaction functions here, as
- * the PDO driver for MSSQL does not support transactions.
- */
- protected function _commit()
- {
- $this->_connect();
- $this->_connection->exec('COMMIT TRANSACTION');
- return true;
- }
-
- /**
- * Roll-back a transaction.
- *
- * It is necessary to override the abstract PDO transaction functions here, as
- * the PDO driver for MSSQL does not support transactions.
- */
- protected function _rollBack() {
- $this->_connect();
- $this->_connection->exec('ROLLBACK TRANSACTION');
- return true;
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
- return $this->fetchCol($sql);
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * PRIMARY_AUTO => integer; position of auto-generated column in primary key
- *
- * @todo Discover column primary key position.
- * @todo Discover integer unsigned property.
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- if ($schemaName != null) {
- if (strpos($schemaName, '.') !== false) {
- $result = explode('.', $schemaName);
- $schemaName = $result[1];
- }
- }
- /**
- * Discover metadata information about this table.
- */
- $sql = "exec sp_columns @table_name = " . $this->quoteIdentifier($tableName, true);
- if ($schemaName != null) {
- $sql .= ", @table_owner = " . $this->quoteIdentifier($schemaName, true);
- }
-
- $stmt = $this->query($sql);
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- $table_name = 2;
- $column_name = 3;
- $type_name = 5;
- $precision = 6;
- $length = 7;
- $scale = 8;
- $nullable = 10;
- $column_def = 12;
- $column_position = 16;
-
- /**
- * Discover primary key column(s) for this table.
- */
- $sql = "exec sp_pkeys @table_name = " . $this->quoteIdentifier($tableName, true);
- if ($schemaName != null) {
- $sql .= ", @table_owner = " . $this->quoteIdentifier($schemaName, true);
- }
-
- $stmt = $this->query($sql);
- $primaryKeysResult = $stmt->fetchAll(Zend_Db::FETCH_NUM);
- $primaryKeyColumn = array();
- $pkey_column_name = 3;
- $pkey_key_seq = 4;
- foreach ($primaryKeysResult as $pkeysRow) {
- $primaryKeyColumn[$pkeysRow[$pkey_column_name]] = $pkeysRow[$pkey_key_seq];
- }
-
- $desc = array();
- $p = 1;
- foreach ($result as $key => $row) {
- $identity = false;
- $words = explode(' ', $row[$type_name], 2);
- if (isset($words[0])) {
- $type = $words[0];
- if (isset($words[1])) {
- $identity = (bool) preg_match('/identity/', $words[1]);
- }
- }
-
- $isPrimary = array_key_exists($row[$column_name], $primaryKeyColumn);
- if ($isPrimary) {
- $primaryPosition = $primaryKeyColumn[$row[$column_name]];
- } else {
- $primaryPosition = null;
- }
-
- $desc[$this->foldCase($row[$column_name])] = array(
- 'SCHEMA_NAME' => null, // @todo
- 'TABLE_NAME' => $this->foldCase($row[$table_name]),
- 'COLUMN_NAME' => $this->foldCase($row[$column_name]),
- 'COLUMN_POSITION' => (int) $row[$column_position],
- 'DATA_TYPE' => $type,
- 'DEFAULT' => $row[$column_def],
- 'NULLABLE' => (bool) $row[$nullable],
- 'LENGTH' => $row[$length],
- 'SCALE' => $row[$scale],
- 'PRECISION' => $row[$precision],
- 'UNSIGNED' => null, // @todo
- 'PRIMARY' => $isPrimary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
- return $desc;
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @throws Zend_Db_Adapter_Exception
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- $sql = preg_replace(
- '/^SELECT\s+(DISTINCT\s)?/i',
- 'SELECT $1TOP ' . ($count+$offset) . ' ',
- $sql
- );
-
- if ($offset > 0) {
- $orderby = stristr($sql, 'ORDER BY');
-
- if ($orderby !== false) {
- $orderParts = explode(',', substr($orderby, 8));
- $pregReplaceCount = null;
- $orderbyInverseParts = array();
- foreach ($orderParts as $orderPart) {
- $orderPart = rtrim($orderPart);
- $inv = preg_replace('/\s+desc$/i', ' ASC', $orderPart, 1, $pregReplaceCount);
- if ($pregReplaceCount) {
- $orderbyInverseParts[] = $inv;
- continue;
- }
- $inv = preg_replace('/\s+asc$/i', ' DESC', $orderPart, 1, $pregReplaceCount);
- if ($pregReplaceCount) {
- $orderbyInverseParts[] = $inv;
- continue;
- } else {
- $orderbyInverseParts[] = $orderPart . ' DESC';
- }
- }
-
- $orderbyInverse = 'ORDER BY ' . implode(', ', $orderbyInverseParts);
- }
-
-
-
-
- $sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl';
- if ($orderby !== false) {
- $sql .= ' ' . $orderbyInverse . ' ';
- }
- $sql .= ') AS outer_tbl';
- if ($orderby !== false) {
- $sql .= ' ' . $orderby;
- }
- }
-
- return $sql;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * Microsoft SQL Server does not support sequences, so the arguments to
- * this method are ignored.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- * @throws Zend_Db_Adapter_Exception
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- $sql = 'SELECT SCOPE_IDENTITY()';
- return (int)$this->fetchOne($sql);
- }
-
- /**
- * Retrieve server version in PHP style
- * Pdo_Mssql doesn't support getAttribute(PDO::ATTR_SERVER_VERSION)
- * @return string
- */
- public function getServerVersion()
- {
- try {
- $stmt = $this->query("SELECT SERVERPROPERTY('productversion')");
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
- if (count($result)) {
- return $result[0][0];
- }
- return null;
- } catch (PDOException $e) {
- return null;
- }
- }
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Mysql.php zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Mysql.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Mysql.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Mysql.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,257 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INT' => Zend_Db::INT_TYPE,
- 'INTEGER' => Zend_Db::INT_TYPE,
- 'MEDIUMINT' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'TINYINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'SERIAL' => Zend_Db::BIGINT_TYPE,
- 'DEC' => Zend_Db::FLOAT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE,
- 'FIXED' => Zend_Db::FLOAT_TYPE,
- 'FLOAT' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Creates a PDO object and connects to the database.
- *
- * @return void
- * @throws Zend_Db_Adapter_Exception
- */
- protected function _connect()
- {
- if ($this->_connection) {
- return;
- }
-
- if (!empty($this->_config['charset'])) {
- $initCommand = "SET NAMES '" . $this->_config['charset'] . "'";
- $this->_config['driver_options'][1002] = $initCommand; // 1002 = PDO::MYSQL_ATTR_INIT_COMMAND
- }
-
- parent::_connect();
- }
-
- /**
- * @return string
- */
- public function getQuoteIdentifierSymbol()
- {
- return "`";
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- return $this->fetchCol('SHOW TABLES');
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- // @todo use INFORMATION_SCHEMA someday when MySQL's
- // implementation has reasonably good performance and
- // the version with this improvement is in wide use.
-
- if ($schemaName) {
- $sql = 'DESCRIBE ' . $this->quoteIdentifier("$schemaName.$tableName", true);
- } else {
- $sql = 'DESCRIBE ' . $this->quoteIdentifier($tableName, true);
- }
- $stmt = $this->query($sql);
-
- // Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- $field = 0;
- $type = 1;
- $null = 2;
- $key = 3;
- $default = 4;
- $extra = 5;
-
- $desc = array();
- $i = 1;
- $p = 1;
- foreach ($result as $row) {
- list($length, $scale, $precision, $unsigned, $primary, $primaryPosition, $identity)
- = array(null, null, null, null, false, null, false);
- if (preg_match('/unsigned/', $row[$type])) {
- $unsigned = true;
- }
- if (preg_match('/^((?:var)?char)\((\d+)\)/', $row[$type], $matches)) {
- $row[$type] = $matches[1];
- $length = $matches[2];
- } else if (preg_match('/^decimal\((\d+),(\d+)\)/', $row[$type], $matches)) {
- $row[$type] = 'decimal';
- $precision = $matches[1];
- $scale = $matches[2];
- } else if (preg_match('/^float\((\d+),(\d+)\)/', $row[$type], $matches)) {
- $row[$type] = 'float';
- $precision = $matches[1];
- $scale = $matches[2];
- } else if (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)/', $row[$type], $matches)) {
- $row[$type] = $matches[1];
- // The optional argument of a MySQL int type is not precision
- // or length; it is only a hint for display width.
- }
- if (strtoupper($row[$key]) == 'PRI') {
- $primary = true;
- $primaryPosition = $p;
- if ($row[$extra] == 'auto_increment') {
- $identity = true;
- } else {
- $identity = false;
- }
- ++$p;
- }
- $desc[$this->foldCase($row[$field])] = array(
- 'SCHEMA_NAME' => null, // @todo
- 'TABLE_NAME' => $this->foldCase($tableName),
- 'COLUMN_NAME' => $this->foldCase($row[$field]),
- 'COLUMN_POSITION' => $i,
- 'DATA_TYPE' => $row[$type],
- 'DEFAULT' => $row[$default],
- 'NULLABLE' => (bool) ($row[$null] == 'YES'),
- 'LENGTH' => $length,
- 'SCALE' => $scale,
- 'PRECISION' => $precision,
- 'UNSIGNED' => $unsigned,
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- ++$i;
- }
- return $desc;
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @throws Zend_Db_Adapter_Exception
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- $sql .= " LIMIT $count";
- if ($offset > 0) {
- $sql .= " OFFSET $offset";
- }
-
- return $sql;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Oci.php zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Oci.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Oci.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Oci.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,378 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'BINARY_DOUBLE' => Zend_Db::FLOAT_TYPE,
- 'BINARY_FLOAT' => Zend_Db::FLOAT_TYPE,
- 'NUMBER' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Creates a PDO DSN for the adapter from $this->_config settings.
- *
- * @return string
- */
- protected function _dsn()
- {
- // baseline of DSN parts
- $dsn = $this->_config;
-
- if (isset($dsn['host'])) {
- $tns = 'dbname=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)' .
- '(HOST=' . $dsn['host'] . ')';
-
- if (isset($dsn['port'])) {
- $tns .= '(PORT=' . $dsn['port'] . ')';
- } else {
- $tns .= '(PORT=1521)';
- }
-
- $tns .= '))(CONNECT_DATA=(SID=' . $dsn['dbname'] . ')))';
- } else {
- $tns = 'dbname=' . $dsn['dbname'];
- }
-
- if (isset($dsn['charset'])) {
- $tns .= ';charset=' . $dsn['charset'];
- }
-
- return $this->_pdoType . ':' . $tns;
- }
-
- /**
- * Quote a raw string.
- * Most PDO drivers have an implementation for the quote() method,
- * but the Oracle OCI driver must use the same implementation as the
- * Zend_Db_Adapter_Abstract class.
- *
- * @param string $value Raw string
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (is_int($value) || is_float($value)) {
- return $value;
- }
- $value = str_replace("'", "''", $value);
- return "'" . addcslashes($value, "\000\n\r\\\032") . "'";
- }
-
- /**
- * Quote a table identifier and alias.
- *
- * @param string|array|Zend_Db_Expr $ident The identifier or expression.
- * @param string $alias An alias for the table.
- * @return string The quoted identifier and alias.
- */
- public function quoteTableAs($ident, $alias = null, $auto = false)
- {
- // Oracle doesn't allow the 'AS' keyword between the table identifier/expression and alias.
- return $this->_quoteIdentifierAs($ident, $alias, $auto, ' ');
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $data = $this->fetchCol('SELECT table_name FROM all_tables');
- return $data;
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @todo Discover integer unsigned property.
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- $version = $this->getServerVersion();
- if (($version === null) || version_compare($version, '9.0.0', '>=')) {
- $sql = "SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
- TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
- TC.DATA_SCALE, TC.DATA_PRECISION, C.CONSTRAINT_TYPE, CC.POSITION
- FROM ALL_TAB_COLUMNS TC
- LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C
- ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P'))
- ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME
- WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)";
- $bind[':TBNAME'] = $tableName;
- if ($schemaName) {
- $sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
- $bind[':SCNAME'] = $schemaName;
- }
- $sql .= ' ORDER BY TC.COLUMN_ID';
- } else {
- $subSql="SELECT AC.OWNER, AC.TABLE_NAME, ACC.COLUMN_NAME, AC.CONSTRAINT_TYPE, ACC.POSITION
- from ALL_CONSTRAINTS AC, ALL_CONS_COLUMNS ACC
- WHERE ACC.CONSTRAINT_NAME = AC.CONSTRAINT_NAME
- AND ACC.TABLE_NAME = AC.TABLE_NAME
- AND ACC.OWNER = AC.OWNER
- AND AC.CONSTRAINT_TYPE = 'P'
- AND UPPER(AC.TABLE_NAME) = UPPER(:TBNAME)";
- $bind[':TBNAME'] = $tableName;
- if ($schemaName) {
- $subSql .= ' AND UPPER(ACC.OWNER) = UPPER(:SCNAME)';
- $bind[':SCNAME'] = $schemaName;
- }
- $sql="SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
- TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
- TC.DATA_SCALE, TC.DATA_PRECISION, CC.CONSTRAINT_TYPE, CC.POSITION
- FROM ALL_TAB_COLUMNS TC, ($subSql) CC
- WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)
- AND TC.OWNER = CC.OWNER(+) AND TC.TABLE_NAME = CC.TABLE_NAME(+) AND TC.COLUMN_NAME = CC.COLUMN_NAME(+)";
- if ($schemaName) {
- $sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
- }
- $sql .= ' ORDER BY TC.COLUMN_ID';
- }
-
- $stmt = $this->query($sql, $bind);
-
- /**
- * Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
- */
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- $table_name = 0;
- $owner = 1;
- $column_name = 2;
- $data_type = 3;
- $data_default = 4;
- $nullable = 5;
- $column_id = 6;
- $data_length = 7;
- $data_scale = 8;
- $data_precision = 9;
- $constraint_type = 10;
- $position = 11;
-
- $desc = array();
- foreach ($result as $key => $row) {
- list ($primary, $primaryPosition, $identity) = array(false, null, false);
- if ($row[$constraint_type] == 'P') {
- $primary = true;
- $primaryPosition = $row[$position];
- /**
- * Oracle does not support auto-increment keys.
- */
- $identity = false;
- }
- $desc[$this->foldCase($row[$column_name])] = array(
- 'SCHEMA_NAME' => $this->foldCase($row[$owner]),
- 'TABLE_NAME' => $this->foldCase($row[$table_name]),
- 'COLUMN_NAME' => $this->foldCase($row[$column_name]),
- 'COLUMN_POSITION' => $row[$column_id],
- 'DATA_TYPE' => $row[$data_type],
- 'DEFAULT' => $row[$data_default],
- 'NULLABLE' => (bool) ($row[$nullable] == 'Y'),
- 'LENGTH' => $row[$data_length],
- 'SCALE' => $row[$data_scale],
- 'PRECISION' => $row[$data_precision],
- 'UNSIGNED' => null, // @todo
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
- return $desc;
- }
-
- /**
- * Return the most recent value from the specified sequence in the database.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return integer
- */
- public function lastSequenceId($sequenceName)
- {
- $this->_connect();
- $value = $this->fetchOne('SELECT '.$this->quoteIdentifier($sequenceName, true).'.CURRVAL FROM dual');
- return $value;
- }
-
- /**
- * Generate a new value from the specified sequence in the database, and return it.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return integer
- */
- public function nextSequenceId($sequenceName)
- {
- $this->_connect();
- $value = $this->fetchOne('SELECT '.$this->quoteIdentifier($sequenceName, true).'.NEXTVAL FROM dual');
- return $value;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * Oracle does not support IDENTITY columns, so if the sequence is not
- * specified, this method returns null.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- * @throws Zend_Db_Adapter_Oracle_Exception
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- if ($tableName !== null) {
- $sequenceName = $tableName;
- if ($primaryKey) {
- $sequenceName .= $this->foldCase("_$primaryKey");
- }
- $sequenceName .= $this->foldCase('_seq');
- return $this->lastSequenceId($sequenceName);
- }
- // No support for IDENTITY columns; return null
- return null;
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset
- * @throws Zend_Db_Adapter_Exception
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- /**
- * Oracle does not implement the LIMIT clause as some RDBMS do.
- * We have to simulate it with subqueries and ROWNUM.
- * Unfortunately because we use the column wildcard "*",
- * this puts an extra column into the query result set.
- */
- $limit_sql = "SELECT z2.*
- FROM (
- SELECT z1.*, ROWNUM AS \"zend_db_rownum\"
- FROM (
- " . $sql . "
- ) z1
- ) z2
- WHERE z2.\"zend_db_rownum\" BETWEEN " . ($offset+1) . " AND " . ($offset+$count);
- return $limit_sql;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Pgsql.php zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Pgsql.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Pgsql.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Pgsql.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,330 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INTEGER' => Zend_Db::INT_TYPE,
- 'SERIAL' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'BIGSERIAL' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Creates a PDO object and connects to the database.
- *
- * @return void
- * @throws Zend_Db_Adapter_Exception
- */
- protected function _connect()
- {
- if ($this->_connection) {
- return;
- }
-
- parent::_connect();
-
- if (!empty($this->_config['charset'])) {
- $sql = "SET NAMES '" . $this->_config['charset'] . "'";
- $this->_connection->exec($sql);
- }
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- // @todo use a better query with joins instead of subqueries
- $sql = "SELECT c.relname AS table_name "
- . "FROM pg_class c, pg_user u "
- . "WHERE c.relowner = u.usesysid AND c.relkind = 'r' "
- . "AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) "
- . "AND c.relname !~ '^(pg_|sql_)' "
- . "UNION "
- . "SELECT c.relname AS table_name "
- . "FROM pg_class c "
- . "WHERE c.relkind = 'r' "
- . "AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) "
- . "AND NOT EXISTS (SELECT 1 FROM pg_user WHERE usesysid = c.relowner) "
- . "AND c.relname !~ '^pg_'";
-
- return $this->fetchCol($sql);
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @todo Discover integer unsigned property.
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- $sql = "SELECT
- a.attnum,
- n.nspname,
- c.relname,
- a.attname AS colname,
- t.typname AS type,
- a.atttypmod,
- FORMAT_TYPE(a.atttypid, a.atttypmod) AS complete_type,
- d.adsrc AS default_value,
- a.attnotnull AS notnull,
- a.attlen AS length,
- co.contype,
- ARRAY_TO_STRING(co.conkey, ',') AS conkey
- FROM pg_attribute AS a
- JOIN pg_class AS c ON a.attrelid = c.oid
- JOIN pg_namespace AS n ON c.relnamespace = n.oid
- JOIN pg_type AS t ON a.atttypid = t.oid
- LEFT OUTER JOIN pg_constraint AS co ON (co.conrelid = c.oid
- AND a.attnum = ANY(co.conkey) AND co.contype = 'p')
- LEFT OUTER JOIN pg_attrdef AS d ON d.adrelid = c.oid AND d.adnum = a.attnum
- WHERE a.attnum > 0 AND c.relname = ".$this->quote($tableName);
- if ($schemaName) {
- $sql .= " AND n.nspname = ".$this->quote($schemaName);
- }
- $sql .= ' ORDER BY a.attnum';
-
- $stmt = $this->query($sql);
-
- // Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- $attnum = 0;
- $nspname = 1;
- $relname = 2;
- $colname = 3;
- $type = 4;
- $atttypemod = 5;
- $complete_type = 6;
- $default_value = 7;
- $notnull = 8;
- $length = 9;
- $contype = 10;
- $conkey = 11;
-
- $desc = array();
- foreach ($result as $key => $row) {
- $defaultValue = $row[$default_value];
- if ($row[$type] == 'varchar' || $row[$type] == 'bpchar' ) {
- if (preg_match('/character(?: varying)?(?:\((\d+)\))?/', $row[$complete_type], $matches)) {
- if (isset($matches[1])) {
- $row[$length] = $matches[1];
- } else {
- $row[$length] = null; // unlimited
- }
- }
- if (preg_match("/^'(.*?)'::(?:character varying|bpchar)$/", $defaultValue, $matches)) {
- $defaultValue = $matches[1];
- }
- }
- list($primary, $primaryPosition, $identity) = array(false, null, false);
- if ($row[$contype] == 'p') {
- $primary = true;
- $primaryPosition = array_search($row[$attnum], explode(',', $row[$conkey])) + 1;
- $identity = (bool) (preg_match('/^nextval/', $row[$default_value]));
- }
- $desc[$this->foldCase($row[$colname])] = array(
- 'SCHEMA_NAME' => $this->foldCase($row[$nspname]),
- 'TABLE_NAME' => $this->foldCase($row[$relname]),
- 'COLUMN_NAME' => $this->foldCase($row[$colname]),
- 'COLUMN_POSITION' => $row[$attnum],
- 'DATA_TYPE' => $row[$type],
- 'DEFAULT' => $defaultValue,
- 'NULLABLE' => (bool) ($row[$notnull] != 't'),
- 'LENGTH' => $row[$length],
- 'SCALE' => null, // @todo
- 'PRECISION' => null, // @todo
- 'UNSIGNED' => null, // @todo
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
- return $desc;
- }
-
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- $sql .= " LIMIT $count";
- if ($offset > 0) {
- $sql .= " OFFSET $offset";
- }
-
- return $sql;
- }
-
- /**
- * Return the most recent value from the specified sequence in the database.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function lastSequenceId($sequenceName)
- {
- $this->_connect();
- $value = $this->fetchOne("SELECT CURRVAL(".$this->quote($sequenceName).")");
- return $value;
- }
-
- /**
- * Generate a new value from the specified sequence in the database, and return it.
- * This is supported only on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
- *
- * @param string $sequenceName
- * @return string
- */
- public function nextSequenceId($sequenceName)
- {
- $this->_connect();
- $value = $this->fetchOne("SELECT NEXTVAL(".$this->quote($sequenceName).")");
- return $value;
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- if ($tableName !== null) {
- $sequenceName = $tableName;
- if ($primaryKey) {
- $sequenceName .= "_$primaryKey";
- }
- $sequenceName .= '_seq';
- return $this->lastSequenceId($sequenceName);
- }
- return $this->_connection->lastInsertId($tableName);
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Sqlite.php zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Sqlite.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Pdo/Sqlite.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Pdo/Sqlite.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,297 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INTEGER' => Zend_Db::BIGINT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Constructor.
- *
- * $config is an array of key/value pairs containing configuration
- * options. Note that the SQLite options are different than most of
- * the other PDO adapters in that no username or password are needed.
- * Also, an extra config key "sqlite2" specifies compatibility mode.
- *
- * dbname => (string) The name of the database to user (required,
- * use :memory: for memory-based database)
- *
- * sqlite2 => (boolean) PDO_SQLITE defaults to SQLite 3. For compatibility
- * with an older SQLite 2 database, set this to TRUE.
- *
- * @param array $config An array of configuration keys.
- */
- public function __construct(array $config = array())
- {
- if (isset($config['sqlite2']) && $config['sqlite2']) {
- $this->_pdoType = 'sqlite2';
- }
-
- // SQLite uses no username/password. Stub to satisfy parent::_connect()
- $this->_config['username'] = null;
- $this->_config['password'] = null;
-
- return parent::__construct($config);
- }
-
- /**
- * Check for config options that are mandatory.
- * Throw exceptions if any are missing.
- *
- * @param array $config
- * @throws Zend_Db_Adapter_Exception
- */
- protected function _checkRequiredOptions(array $config)
- {
- // we need at least a dbname
- if (! array_key_exists('dbname', $config)) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance");
- }
- }
-
- /**
- * DSN builder
- */
- protected function _dsn()
- {
- return $this->_pdoType .':'. $this->_config['dbname'];
- }
-
- /**
- * Special configuration for SQLite behavior: make sure that result sets
- * contain keys like 'column' instead of 'table.column'.
- *
- * @throws Zend_Db_Adapter_Exception
- */
- protected function _connect()
- {
- /**
- * if we already have a PDO object, no need to re-connect.
- */
- if ($this->_connection) {
- return;
- }
-
- parent::_connect();
-
- $retval = $this->_connection->exec('PRAGMA full_column_names=0');
- if ($retval === false) {
- $error = $this->_connection->errorInfo();
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception($error[2]);
- }
-
- $retval = $this->_connection->exec('PRAGMA short_column_names=1');
- if ($retval === false) {
- $error = $this->_connection->errorInfo();
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception($error[2]);
- }
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $sql = "SELECT name FROM sqlite_master WHERE type='table' "
- . "UNION ALL SELECT name FROM sqlite_temp_master "
- . "WHERE type='table' ORDER BY name";
-
- return $this->fetchCol($sql);
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of database or schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- $sql = 'PRAGMA ';
-
- if ($schemaName) {
- $sql .= $this->quoteIdentifier($schemaName) . '.';
- }
-
- $sql .= 'table_info('.$this->quoteIdentifier($tableName).')';
-
- $stmt = $this->query($sql);
-
- /**
- * Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
- */
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- $cid = 0;
- $name = 1;
- $type = 2;
- $notnull = 3;
- $dflt_value = 4;
- $pk = 5;
-
- $desc = array();
-
- $p = 1;
- foreach ($result as $key => $row) {
- list($length, $scale, $precision, $primary, $primaryPosition, $identity) =
- array(null, null, null, false, null, false);
- if (preg_match('/^((?:var)?char)\((\d+)\)/i', $row[$type], $matches)) {
- $row[$type] = $matches[1];
- $length = $matches[2];
- } else if (preg_match('/^decimal\((\d+),(\d+)\)/i', $row[$type], $matches)) {
- $row[$type] = 'DECIMAL';
- $precision = $matches[1];
- $scale = $matches[2];
- }
- if ((bool) $row[$pk]) {
- $primary = true;
- $primaryPosition = $p;
- /**
- * SQLite INTEGER primary key is always auto-increment.
- */
- $identity = (bool) ($row[$type] == 'INTEGER');
- ++$p;
- }
- $desc[$this->foldCase($row[$name])] = array(
- 'SCHEMA_NAME' => $this->foldCase($schemaName),
- 'TABLE_NAME' => $this->foldCase($tableName),
- 'COLUMN_NAME' => $this->foldCase($row[$name]),
- 'COLUMN_POSITION' => $row[$cid]+1,
- 'DATA_TYPE' => $row[$type],
- 'DEFAULT' => $row[$dflt_value],
- 'NULLABLE' => ! (bool) $row[$notnull],
- 'LENGTH' => $length,
- 'SCALE' => $scale,
- 'PRECISION' => $precision,
- 'UNSIGNED' => null, // Sqlite3 does not support unsigned data
- 'PRIMARY' => $primary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity
- );
- }
- return $desc;
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @return string
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- $sql .= " LIMIT $count";
- if ($offset > 0) {
- $sql .= " OFFSET $offset";
- }
-
- return $sql;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Platform/IbmDb2.php zendframework-2.2.6/library/Zend/Db/Adapter/Platform/IbmDb2.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Platform/IbmDb2.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Platform/IbmDb2.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,209 @@
+quoteIdentifiers = false;
+ }
+
+ if (isset($options['identifier_separator'])) {
+ $this->identifierSeparator = $options['identifier_separator'];
+ }
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return 'IBM DB2';
+ }
+
+ /**
+ * Get quote indentifier symbol
+ *
+ * @return string
+ */
+ public function getQuoteIdentifierSymbol()
+ {
+ return '"';
+ }
+
+ /**
+ * Quote identifier
+ *
+ * @param string $identifier
+ * @return string
+ */
+ public function quoteIdentifier($identifier)
+ {
+ if ($this->quoteIdentifiers === false) {
+ return $identifier;
+ }
+ return '"' . str_replace('"', '\\' . '"', $identifier) . '"';
+ }
+
+ /**
+ * Quote identifier chain
+ *
+ * @param string|string[] $identifierChain
+ * @return string
+ */
+ public function quoteIdentifierChain($identifierChain)
+ {
+ if ($this->quoteIdentifiers === false) {
+ return (is_array($identifierChain)) ? implode($this->identifierSeparator, $identifierChain) : $identifierChain;
+ }
+ $identifierChain = str_replace('"', '\\"', $identifierChain);
+ if (is_array($identifierChain)) {
+ $identifierChain = implode('"' . $this->identifierSeparator . '"', $identifierChain);
+ }
+ return '"' . $identifierChain . '"';
+ }
+
+ /**
+ * Get quote value symbol
+ *
+ * @return string
+ */
+ public function getQuoteValueSymbol()
+ {
+ return '\'';
+ }
+
+ /**
+ * Quote value
+ *
+ * @param string $value
+ * @return string
+ */
+ public function quoteValue($value)
+ {
+ if (function_exists('db2_escape_string')) {
+ return '\'' . db2_escape_string($value) . '\'';
+ }
+ trigger_error(
+ 'Attempting to quote a value in ' . __CLASS__ . ' without extension/driver support '
+ . 'can introduce security vulnerabilities in a production environment.'
+ );
+ return '\'' . str_replace("'", "''", $value) . '\'';
+ }
+
+ /**
+ * Quote Trusted Value
+ *
+ * The ability to quote values without notices
+ *
+ * @param $value
+ * @return mixed
+ */
+ public function quoteTrustedValue($value)
+ {
+ if (function_exists('db2_escape_string')) {
+ return '\'' . db2_escape_string($value) . '\'';
+ }
+ return '\'' . str_replace("'", "''", $value) . '\'';
+ }
+
+ /**
+ * Quote value list
+ *
+ * @param string|string[] $valueList
+ * @return string
+ */
+ public function quoteValueList($valueList)
+ {
+ if (!is_array($valueList)) {
+ return $this->quoteValue($valueList);
+ }
+
+ $value = reset($valueList);
+ do {
+ $valueList[key($valueList)] = $this->quoteValue($value);
+ } while ($value = next($valueList));
+ return implode(', ', $valueList);
+ }
+
+ /**
+ * Get identifier separator
+ *
+ * @return string
+ */
+ public function getIdentifierSeparator()
+ {
+ return $this->identifierSeparator;
+ }
+
+ /**
+ * Quote identifier in fragment
+ *
+ * @param string $identifier
+ * @param array $safeWords
+ * @return string
+ */
+ public function quoteIdentifierInFragment($identifier, array $safeWords = array())
+ {
+ if ($this->quoteIdentifiers === false) {
+ return $identifier;
+ }
+ $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+
+ if ($safeWords) {
+ $safeWords = array_flip($safeWords);
+ $safeWords = array_change_key_case($safeWords, CASE_LOWER);
+ }
+ foreach ($parts as $i => $part) {
+ if ($safeWords && isset($safeWords[strtolower($part)])) {
+ continue;
+ }
+
+ switch ($part) {
+ case ' ':
+ case '.':
+ case '*':
+ case 'AS':
+ case 'As':
+ case 'aS':
+ case 'as':
+ break;
+ default:
+ $parts[$i] = '"' . str_replace('"', '\\' . '"', $part) . '"';
+ }
+ }
+
+ return implode('', $parts);
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Platform/Mysql.php zendframework-2.2.6/library/Zend/Db/Adapter/Platform/Mysql.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Platform/Mysql.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Platform/Mysql.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,214 @@
+setDriver($driver);
+ }
+ }
+
+ /**
+ * @param \Zend\Db\Adapter\Driver\Mysqli\Mysqli|\Zend\Db\Adapter\Driver\Pdo\Pdo||\mysqli|\PDO $driver
+ * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException
+ * @return $this
+ */
+ public function setDriver($driver)
+ {
+ // handle Zend\Db drivers
+ if ($driver instanceof Mysqli\Mysqli
+ || ($driver instanceof Pdo\Pdo && $driver->getDatabasePlatformName() == 'Mysql')
+ || ($driver instanceof \mysqli)
+ || ($driver instanceof \PDO && $driver->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'mysql')
+ ) {
+ $this->resource = $driver;
+ return $this;
+ }
+
+ throw new Exception\InvalidArgumentException('$driver must be a Mysqli or Mysql PDO Zend\Db\Adapter\Driver, Mysqli instance or MySQL PDO instance');
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return 'MySQL';
+ }
+
+ /**
+ * Get quote identifier symbol
+ *
+ * @return string
+ */
+ public function getQuoteIdentifierSymbol()
+ {
+ return '`';
+ }
+
+ /**
+ * Quote identifier
+ *
+ * @param string $identifier
+ * @return string
+ */
+ public function quoteIdentifier($identifier)
+ {
+ return '`' . str_replace('`', '``', $identifier) . '`';
+ }
+
+ /**
+ * Quote identifier chain
+ *
+ * @param string|string[] $identifierChain
+ * @return string
+ */
+ public function quoteIdentifierChain($identifierChain)
+ {
+ $identifierChain = str_replace('`', '``', $identifierChain);
+ if (is_array($identifierChain)) {
+ $identifierChain = implode('`.`', $identifierChain);
+ }
+ return '`' . $identifierChain . '`';
+ }
+
+ /**
+ * Get quote value symbol
+ *
+ * @return string
+ */
+ public function getQuoteValueSymbol()
+ {
+ return '\'';
+ }
+
+ /**
+ * Quote value
+ *
+ * @param string $value
+ * @return string
+ */
+ public function quoteValue($value)
+ {
+ if ($this->resource instanceof DriverInterface) {
+ $this->resource = $this->resource->getConnection()->getResource();
+ }
+ if ($this->resource instanceof \mysqli) {
+ return '\'' . $this->resource->real_escape_string($value) . '\'';
+ }
+ if ($this->resource instanceof \PDO) {
+ return $this->resource->quote($value);
+ }
+ trigger_error(
+ 'Attempting to quote a value in ' . __CLASS__ . ' without extension/driver support '
+ . 'can introduce security vulnerabilities in a production environment.'
+ );
+ return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
+ }
+
+ /**
+ * Quote Trusted Value
+ *
+ * The ability to quote values without notices
+ *
+ * @param $value
+ * @return mixed
+ */
+ public function quoteTrustedValue($value)
+ {
+ if ($this->resource instanceof DriverInterface) {
+ $this->resource = $this->resource->getConnection()->getResource();
+ }
+ if ($this->resource instanceof \mysqli) {
+ return '\'' . $this->resource->real_escape_string($value) . '\'';
+ }
+ if ($this->resource instanceof \PDO) {
+ return $this->resource->quote($value);
+ }
+ return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
+ }
+
+ /**
+ * Quote value list
+ *
+ * @param string|string[] $valueList
+ * @return string
+ */
+ public function quoteValueList($valueList)
+ {
+ if (!is_array($valueList)) {
+ return $this->quoteValue($valueList);
+ }
+
+ $value = reset($valueList);
+ do {
+ $valueList[key($valueList)] = $this->quoteValue($value);
+ } while ($value = next($valueList));
+ return implode(', ', $valueList);
+ }
+
+ /**
+ * Get identifier separator
+ *
+ * @return string
+ */
+ public function getIdentifierSeparator()
+ {
+ return '.';
+ }
+
+ /**
+ * Quote identifier in fragment
+ *
+ * @param string $identifier
+ * @param array $safeWords
+ * @return string
+ */
+ public function quoteIdentifierInFragment($identifier, array $safeWords = array())
+ {
+ // regex taken from @link http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
+ $parts = preg_split('#([^0-9,a-z,A-Z$_])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+ if ($safeWords) {
+ $safeWords = array_flip($safeWords);
+ $safeWords = array_change_key_case($safeWords, CASE_LOWER);
+ }
+ foreach ($parts as $i => $part) {
+ if ($safeWords && isset($safeWords[strtolower($part)])) {
+ continue;
+ }
+ switch ($part) {
+ case ' ':
+ case '.':
+ case '*':
+ case 'AS':
+ case 'As':
+ case 'aS':
+ case 'as':
+ break;
+ default:
+ $parts[$i] = '`' . str_replace('`', '``', $part) . '`';
+ }
+ }
+ return implode('', $parts);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Platform/Oracle.php zendframework-2.2.6/library/Zend/Db/Adapter/Platform/Oracle.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Platform/Oracle.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Platform/Oracle.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,189 @@
+quoteIdentifiers = false;
+ }
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return 'Oracle';
+ }
+
+ /**
+ * Get quote identifier symbol
+ *
+ * @return string
+ */
+ public function getQuoteIdentifierSymbol()
+ {
+ return '"';
+ }
+
+ /**
+ * Quote identifier
+ *
+ * @param string $identifier
+ * @return string
+ */
+ public function quoteIdentifier($identifier)
+ {
+ if ($this->quoteIdentifiers === false) {
+ return $identifier;
+ }
+ return '"' . str_replace('"', '\\' . '"', $identifier) . '"';
+ }
+
+ /**
+ * Quote identifier chain
+ *
+ * @param string|string[] $identifierChain
+ * @return string
+ */
+ public function quoteIdentifierChain($identifierChain)
+ {
+ if ($this->quoteIdentifiers === false) {
+ return (is_array($identifierChain)) ? implode('.', $identifierChain) : $identifierChain;
+ }
+ $identifierChain = str_replace('"', '\\"', $identifierChain);
+ if (is_array($identifierChain)) {
+ $identifierChain = implode('"."', $identifierChain);
+ }
+ return '"' . $identifierChain . '"';
+ }
+
+ /**
+ * Get quote value symbol
+ *
+ * @return string
+ */
+ public function getQuoteValueSymbol()
+ {
+ return '\'';
+ }
+
+ /**
+ * Quote value
+ *
+ * @param string $value
+ * @return string
+ */
+ public function quoteValue($value)
+ {
+ trigger_error(
+ 'Attempting to quote a value in ' . __CLASS__ . ' without extension/driver support '
+ . 'can introduce security vulnerabilities in a production environment.'
+ );
+ return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
+ }
+
+ /**
+ * Quote Trusted Value
+ *
+ * The ability to quote values without notices
+ *
+ * @param $value
+ * @return mixed
+ */
+ public function quoteTrustedValue($value)
+ {
+ return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
+ }
+
+ /**
+ * Quote value list
+ *
+ * @param string|string[] $valueList
+ * @return string
+ */
+ public function quoteValueList($valueList)
+ {
+ if (!is_array($valueList)) {
+ return $this->quoteValue($valueList);
+ }
+
+ $value = reset($valueList);
+ do {
+ $valueList[key($valueList)] = $this->quoteValue($value);
+ } while ($value = next($valueList));
+ return implode(', ', $valueList);
+ }
+
+ /**
+ * Get identifier separator
+ *
+ * @return string
+ */
+ public function getIdentifierSeparator()
+ {
+ return '.';
+ }
+
+ /**
+ * Quote identifier in fragment
+ *
+ * @param string $identifier
+ * @param array $safeWords
+ * @return string
+ */
+ public function quoteIdentifierInFragment($identifier, array $safeWords = array())
+ {
+ if ($this->quoteIdentifiers === false) {
+ return $identifier;
+ }
+ $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+ if ($safeWords) {
+ $safeWords = array_flip($safeWords);
+ $safeWords = array_change_key_case($safeWords, CASE_LOWER);
+ }
+ foreach ($parts as $i => $part) {
+ if ($safeWords && isset($safeWords[strtolower($part)])) {
+ continue;
+ }
+ switch ($part) {
+ case ' ':
+ case '.':
+ case '*':
+ case 'AS':
+ case 'As':
+ case 'aS':
+ case 'as':
+ break;
+ default:
+ $parts[$i] = '"' . str_replace('"', '\\' . '"', $part) . '"';
+ }
+ }
+ return implode('', $parts);
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Platform/PlatformInterface.php zendframework-2.2.6/library/Zend/Db/Adapter/Platform/PlatformInterface.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Platform/PlatformInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Platform/PlatformInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,94 @@
+setDriver($driver);
+ }
+ }
+
+ /**
+ * @param \Zend\Db\Adapter\Driver\Pgsql\Pgsql|\Zend\Db\Adapter\Driver\Pdo\Pdo|resource|\PDO $driver
+ * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException
+ * @return $this
+ */
+ public function setDriver($driver)
+ {
+ if ($driver instanceof Pgsql\Pgsql
+ || ($driver instanceof Pdo\Pdo && $driver->getDatabasePlatformName() == 'Postgresql')
+ || (is_resource($driver) && (in_array(get_resource_type($driver), array('pgsql link', 'pgsql link persistent'))))
+ || ($driver instanceof \PDO && $driver->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'pgsql')
+ ) {
+ $this->resource = $driver;
+ return $this;
+ }
+
+ throw new Exception\InvalidArgumentException('$driver must be a Pgsql or Postgresql PDO Zend\Db\Adapter\Driver, pgsql link resource or Postgresql PDO instance');
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return 'PostgreSQL';
+ }
+
+ /**
+ * Get quote indentifier symbol
+ *
+ * @return string
+ */
+ public function getQuoteIdentifierSymbol()
+ {
+ return '"';
+ }
+
+ /**
+ * Quote identifier
+ *
+ * @param string $identifier
+ * @return string
+ */
+ public function quoteIdentifier($identifier)
+ {
+ return '"' . str_replace('"', '\\' . '"', $identifier) . '"';
+ }
+
+ /**
+ * Quote identifier chain
+ *
+ * @param string|string[] $identifierChain
+ * @return string
+ */
+ public function quoteIdentifierChain($identifierChain)
+ {
+ $identifierChain = str_replace('"', '\\"', $identifierChain);
+ if (is_array($identifierChain)) {
+ $identifierChain = implode('"."', $identifierChain);
+ }
+ return '"' . $identifierChain . '"';
+ }
+
+ /**
+ * Get quote value symbol
+ *
+ * @return string
+ */
+ public function getQuoteValueSymbol()
+ {
+ return '\'';
+ }
+
+ /**
+ * Quote value
+ *
+ * @param string $value
+ * @return string
+ */
+ public function quoteValue($value)
+ {
+ if ($this->resource instanceof DriverInterface) {
+ $this->resource = $this->resource->getConnection()->getResource();
+ }
+ if (is_resource($this->resource)) {
+ return '\'' . pg_escape_string($this->resource, $value) . '\'';
+ }
+ if ($this->resource instanceof \PDO) {
+ return $this->resource->quote($value);
+ }
+ trigger_error(
+ 'Attempting to quote a value in ' . __CLASS__ . ' without extension/driver support '
+ . 'can introduce security vulnerabilities in a production environment.'
+ );
+ return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
+ }
+
+ /**
+ * Quote Trusted Value
+ *
+ * The ability to quote values without notices
+ *
+ * @param $value
+ * @return mixed
+ */
+ public function quoteTrustedValue($value)
+ {
+ if ($this->resource instanceof DriverInterface) {
+ $this->resource = $this->resource->getConnection()->getResource();
+ }
+ if (is_resource($this->resource)) {
+ return '\'' . pg_escape_string($this->resource, $value) . '\'';
+ }
+ if ($this->resource instanceof \PDO) {
+ return $this->resource->quote($value);
+ }
+ return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
+ }
+
+ /**
+ * Quote value list
+ *
+ * @param string|string[] $valueList
+ * @return string
+ */
+ public function quoteValueList($valueList)
+ {
+ if (!is_array($valueList)) {
+ return $this->quoteValue($valueList);
+ }
+
+ $value = reset($valueList);
+ do {
+ $valueList[key($valueList)] = $this->quoteValue($value);
+ } while ($value = next($valueList));
+ return implode(', ', $valueList);
+ }
+
+ /**
+ * Get identifier separator
+ *
+ * @return string
+ */
+ public function getIdentifierSeparator()
+ {
+ return '.';
+ }
+
+ /**
+ * Quote identifier in fragment
+ *
+ * @param string $identifier
+ * @param array $safeWords
+ * @return string
+ */
+ public function quoteIdentifierInFragment($identifier, array $safeWords = array())
+ {
+ $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+ if ($safeWords) {
+ $safeWords = array_flip($safeWords);
+ $safeWords = array_change_key_case($safeWords, CASE_LOWER);
+ }
+ foreach ($parts as $i => $part) {
+ if ($safeWords && isset($safeWords[strtolower($part)])) {
+ continue;
+ }
+ switch ($part) {
+ case ' ':
+ case '.':
+ case '*':
+ case 'AS':
+ case 'As':
+ case 'aS':
+ case 'as':
+ break;
+ default:
+ $parts[$i] = '"' . str_replace('"', '\\' . '"', $part) . '"';
+ }
+ }
+ return implode('', $parts);
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Platform/Sql92.php zendframework-2.2.6/library/Zend/Db/Adapter/Platform/Sql92.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Platform/Sql92.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Platform/Sql92.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,162 @@
+quoteValue($valueList);
+ }
+
+ $value = reset($valueList);
+ do {
+ $valueList[key($valueList)] = $this->quoteValue($value);
+ } while ($value = next($valueList));
+ return implode(', ', $valueList);
+ }
+
+ /**
+ * Get identifier separator
+ *
+ * @return string
+ */
+ public function getIdentifierSeparator()
+ {
+ return '.';
+ }
+
+ /**
+ * Quote identifier in fragment
+ *
+ * @param string $identifier
+ * @param array $safeWords
+ * @return string
+ */
+ public function quoteIdentifierInFragment($identifier, array $safeWords = array())
+ {
+ $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+ if ($safeWords) {
+ $safeWords = array_flip($safeWords);
+ $safeWords = array_change_key_case($safeWords, CASE_LOWER);
+ }
+ foreach ($parts as $i => $part) {
+ if ($safeWords && isset($safeWords[strtolower($part)])) {
+ continue;
+ }
+
+ switch ($part) {
+ case ' ':
+ case '.':
+ case '*':
+ case 'AS':
+ case 'As':
+ case 'aS':
+ case 'as':
+ break;
+ default:
+ $parts[$i] = '"' . str_replace('"', '\\' . '"', $part) . '"';
+ }
+ }
+
+ return implode('', $parts);
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Platform/Sqlite.php zendframework-2.2.6/library/Zend/Db/Adapter/Platform/Sqlite.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Platform/Sqlite.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Platform/Sqlite.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,212 @@
+setDriver($driver);
+ }
+ }
+
+ /**
+ * @param \Zend\Db\Adapter\Driver\Pdo\Pdo||\PDO $driver
+ * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException
+ * @return $this
+ */
+ public function setDriver($driver)
+ {
+ if (($driver instanceof \PDO && $driver->getAttribute(\PDO::ATTR_DRIVER_NAME) == 'sqlite')
+ || ($driver instanceof Pdo\Pdo && $driver->getDatabasePlatformName() == 'Sqlite')
+ ) {
+ $this->resource = $driver;
+ return $this;
+ }
+
+ throw new Exception\InvalidArgumentException('$driver must be a Sqlite PDO Zend\Db\Adapter\Driver, Sqlite PDO instance');
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return 'SQLite';
+ }
+
+ /**
+ * Get quote identifier symbol
+ *
+ * @return string
+ */
+ public function getQuoteIdentifierSymbol()
+ {
+ return '"';
+ }
+
+ /**
+ * Quote identifier
+ *
+ * @param string $identifier
+ * @return string
+ */
+ public function quoteIdentifier($identifier)
+ {
+ return '"' . str_replace('"', '\\' . '"', $identifier) . '"';
+ }
+
+ /**
+ * Quote identifier chain
+ *
+ * @param string|string[] $identifierChain
+ * @return string
+ */
+ public function quoteIdentifierChain($identifierChain)
+ {
+ $identifierChain = str_replace('"', '\\"', $identifierChain);
+ if (is_array($identifierChain)) {
+ $identifierChain = implode('"."', $identifierChain);
+ }
+ return '"' . $identifierChain . '"';
+ }
+
+ /**
+ * Get quote value symbol
+ *
+ * @return string
+ */
+ public function getQuoteValueSymbol()
+ {
+ return '\'';
+ }
+
+ /**
+ * Quote value
+ *
+ * @param string $value
+ * @return string
+ */
+ public function quoteValue($value)
+ {
+ $resource = $this->resource;
+
+ if ($resource instanceof DriverInterface) {
+ $resource = $resource->getConnection()->getResource();
+ }
+
+ if ($resource instanceof \PDO) {
+ return $resource->quote($value);
+ }
+
+ trigger_error(
+ 'Attempting to quote a value in ' . __CLASS__ . ' without extension/driver support '
+ . 'can introduce security vulnerabilities in a production environment.'
+ );
+ return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
+ }
+
+ /**
+ * Quote Trusted Value
+ *
+ * The ability to quote values without notices
+ *
+ * @param $value
+ * @return mixed
+ */
+ public function quoteTrustedValue($value)
+ {
+ $resource = $this->resource;
+
+ if ($resource instanceof DriverInterface) {
+ $resource = $resource->getConnection()->getResource();
+ }
+
+ if ($resource instanceof \PDO) {
+ return $resource->quote($value);
+ }
+
+ return '\'' . addcslashes($value, "\x00\n\r\\'\"\x1a") . '\'';
+ }
+
+ /**
+ * Quote value list
+ *
+ * @param string|string[] $valueList
+ * @return string
+ */
+ public function quoteValueList($valueList)
+ {
+ if (!is_array($valueList)) {
+ return $this->quoteValue($valueList);
+ }
+ $value = reset($valueList);
+ do {
+ $valueList[key($valueList)] = $this->quoteValue($value);
+ } while ($value = next($valueList));
+ return implode(', ', $valueList);
+ }
+
+ /**
+ * Get identifier separator
+ *
+ * @return string
+ */
+ public function getIdentifierSeparator()
+ {
+ return '.';
+ }
+
+ /**
+ * Quote identifier in fragment
+ *
+ * @param string $identifier
+ * @param array $safeWords
+ * @return string
+ */
+ public function quoteIdentifierInFragment($identifier, array $safeWords = array())
+ {
+ $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+ if ($safeWords) {
+ $safeWords = array_flip($safeWords);
+ $safeWords = array_change_key_case($safeWords, CASE_LOWER);
+ }
+ foreach ($parts as $i => $part) {
+ if ($safeWords && isset($safeWords[strtolower($part)])) {
+ continue;
+ }
+ switch ($part) {
+ case ' ':
+ case '.':
+ case '*':
+ case 'AS':
+ case 'As':
+ case 'aS':
+ case 'as':
+ break;
+ default:
+ $parts[$i] = '"' . str_replace('"', '\\' . '"', $part) . '"';
+ }
+ }
+ return implode('', $parts);
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Platform/SqlServer.php zendframework-2.2.6/library/Zend/Db/Adapter/Platform/SqlServer.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Platform/SqlServer.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Platform/SqlServer.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,204 @@
+setDriver($driver);
+ }
+ }
+
+ /**
+ * @param \Zend\Db\Adapter\Driver\Sqlsrv\Sqlsrv|\Zend\Db\Adapter\Driver\Pdo\Pdo||resource|\PDO $driver
+ * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException
+ * @return $this
+ */
+ public function setDriver($driver)
+ {
+ // handle Zend_Db drivers
+ if (($driver instanceof Pdo\Pdo && in_array($driver->getDatabasePlatformName(), array('Sqlsrv', 'Dblib')))
+ || (($driver instanceof \PDO && in_array($driver->getAttribute(\PDO::ATTR_DRIVER_NAME), array('sqlsrv', 'dblib'))))
+ ) {
+ $this->resource = $driver;
+ return $this;
+ }
+
+ throw new Exception\InvalidArgumentException('$driver must be a Sqlsrv PDO Zend\Db\Adapter\Driver or Sqlsrv PDO instance');
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return 'SQLServer';
+ }
+
+ /**
+ * Get quote identifier symbol
+ *
+ * @return string
+ */
+ public function getQuoteIdentifierSymbol()
+ {
+ return array('[', ']');
+ }
+
+ /**
+ * Quote identifier
+ *
+ * @param string $identifier
+ * @return string
+ */
+ public function quoteIdentifier($identifier)
+ {
+ return '[' . $identifier . ']';
+ }
+
+ /**
+ * Quote identifier chain
+ *
+ * @param string|string[] $identifierChain
+ * @return string
+ */
+ public function quoteIdentifierChain($identifierChain)
+ {
+ if (is_array($identifierChain)) {
+ $identifierChain = implode('].[', $identifierChain);
+ }
+ return '[' . $identifierChain . ']';
+ }
+
+ /**
+ * Get quote value symbol
+ *
+ * @return string
+ */
+ public function getQuoteValueSymbol()
+ {
+ return '\'';
+ }
+
+ /**
+ * Quote value
+ *
+ * @param string $value
+ * @return string
+ */
+ public function quoteValue($value)
+ {
+ if ($this->resource instanceof DriverInterface) {
+ $this->resource = $this->resource->getConnection()->getResource();
+ }
+ if ($this->resource instanceof \PDO) {
+ return $this->resource->quote($value);
+ }
+ trigger_error(
+ 'Attempting to quote a value in ' . __CLASS__ . ' without extension/driver support '
+ . 'can introduce security vulnerabilities in a production environment.'
+ );
+ return '\'' . str_replace('\'', '\'\'', $value) . '\'';
+ }
+
+ /**
+ * Quote Trusted Value
+ *
+ * The ability to quote values without notices
+ *
+ * @param $value
+ * @return mixed
+ */
+ public function quoteTrustedValue($value)
+ {
+ if ($this->resource instanceof DriverInterface) {
+ $this->resource = $this->resource->getConnection()->getResource();
+ }
+ if ($this->resource instanceof \PDO) {
+ return $this->resource->quote($value);
+ }
+ return '\'' . str_replace('\'', '\'\'', $value) . '\'';
+ }
+
+ /**
+ * Quote value list
+ *
+ * @param string|string[] $valueList
+ * @return string
+ */
+ public function quoteValueList($valueList)
+ {
+ if (!is_array($valueList)) {
+ return $this->quoteValue($valueList);
+ }
+ $value = reset($valueList);
+ do {
+ $valueList[key($valueList)] = $this->quoteValue($value);
+ } while ($value = next($valueList));
+ return implode(', ', $valueList);
+ }
+
+ /**
+ * Get identifier separator
+ *
+ * @return string
+ */
+ public function getIdentifierSeparator()
+ {
+ return '.';
+ }
+
+ /**
+ * Quote identifier in fragment
+ *
+ * @param string $identifier
+ * @param array $safeWords
+ * @return string
+ */
+ public function quoteIdentifierInFragment($identifier, array $safeWords = array())
+ {
+ $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+ if ($safeWords) {
+ $safeWords = array_flip($safeWords);
+ $safeWords = array_change_key_case($safeWords, CASE_LOWER);
+ }
+ foreach ($parts as $i => $part) {
+ if ($safeWords && isset($safeWords[strtolower($part)])) {
+ continue;
+ }
+ switch ($part) {
+ case ' ':
+ case '.':
+ case '*':
+ case 'AS':
+ case 'As':
+ case 'aS':
+ case 'as':
+ break;
+ default:
+ $parts[$i] = '[' . $part . ']';
+ }
+ }
+ return implode('', $parts);
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Profiler/ProfilerAwareInterface.php zendframework-2.2.6/library/Zend/Db/Adapter/Profiler/ProfilerAwareInterface.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Profiler/ProfilerAwareInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Profiler/ProfilerAwareInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+ '',
+ 'parameters' => null,
+ 'start' => microtime(true),
+ 'end' => null,
+ 'elapse' => null
+ );
+ if ($target instanceof StatementContainerInterface) {
+ $profileInformation['sql'] = $target->getSql();
+ $profileInformation['parameters'] = clone $target->getParameterContainer();
+ } elseif (is_string($target)) {
+ $profileInformation['sql'] = $target;
+ } else {
+ throw new Exception\InvalidArgumentException(__FUNCTION__ . ' takes either a StatementContainer or a string');
+ }
+
+ $this->profiles[$this->currentIndex] = $profileInformation;
+
+ return $this;
+ }
+
+ /**
+ * @return Profiler
+ */
+ public function profilerFinish()
+ {
+ if (!isset($this->profiles[$this->currentIndex])) {
+ throw new Exception\RuntimeException('A profile must be started before ' . __FUNCTION__ . ' can be called.');
+ }
+ $current = &$this->profiles[$this->currentIndex];
+ $current['end'] = microtime(true);
+ $current['elapse'] = $current['end'] - $current['start'];
+ $this->currentIndex++;
+ return $this;
+ }
+
+ /**
+ * @return array|null
+ */
+ public function getLastProfile()
+ {
+ return end($this->profiles);
+ }
+
+ /**
+ * @return array
+ */
+ public function getProfiles()
+ {
+ return $this->profiles;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/Sqlsrv/Exception.php zendframework-2.2.6/library/Zend/Db/Adapter/Sqlsrv/Exception.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/Sqlsrv/Exception.php 2010-01-25 21:17:23.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/Sqlsrv/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,63 +0,0 @@
- (string) Connect to the database as this username.
- * password => (string) Password associated with the username.
- * dbname => The name of the local SQL Server instance
- *
- * @var array
- */
- protected $_config = array(
- 'dbname' => null,
- 'username' => null,
- 'password' => null,
- );
-
- /**
- * Last insert id from INSERT query
- *
- * @var int
- */
- protected $_lastInsertId;
-
- /**
- * Query used to fetch last insert id
- *
- * @var string
- */
- protected $_lastInsertSQL = 'SELECT SCOPE_IDENTITY() as Current_Identity';
-
- /**
- * Keys are UPPERCASE SQL datatypes or the constants
- * Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE.
- *
- * Values are:
- * 0 = 32-bit integer
- * 1 = 64-bit integer
- * 2 = float or decimal
- *
- * @var array Associative array of datatypes to values 0, 1, or 2.
- */
- protected $_numericDataTypes = array(
- Zend_Db::INT_TYPE => Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INT' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'TINYINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'FLOAT' => Zend_Db::FLOAT_TYPE,
- 'MONEY' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE,
- 'SMALLMONEY' => Zend_Db::FLOAT_TYPE,
- );
-
- /**
- * Default class name for a DB statement.
- *
- * @var string
- */
- protected $_defaultStmtClass = 'Zend_Db_Statement_Sqlsrv';
-
- /**
- * Creates a connection resource.
- *
- * @return void
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- protected function _connect()
- {
- if (is_resource($this->_connection)) {
- // connection already exists
- return;
- }
-
- if (!extension_loaded('sqlsrv')) {
- /**
- * @see Zend_Db_Adapter_Sqlsrv_Exception
- */
- require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
- throw new Zend_Db_Adapter_Sqlsrv_Exception('The Sqlsrv extension is required for this adapter but the extension is not loaded');
- }
-
- $serverName = $this->_config['host'];
- if (isset($this->_config['port'])) {
- $port = (integer) $this->_config['port'];
- $serverName .= ', ' . $port;
- }
-
- $connectionInfo = array(
- 'Database' => $this->_config['dbname'],
- );
-
- if (isset($this->_config['username']) && isset($this->_config['password']))
- {
- $connectionInfo += array(
- 'UID' => $this->_config['username'],
- 'PWD' => $this->_config['password'],
- );
- }
- // else - windows authentication
-
- if (!empty($this->_config['driver_options'])) {
- foreach ($this->_config['driver_options'] as $option => $value) {
- // A value may be a constant.
- if (is_string($value)) {
- $constantName = strtoupper($value);
- if (defined($constantName)) {
- $connectionInfo[$option] = constant($constantName);
- } else {
- $connectionInfo[$option] = $value;
- }
- }
- }
- }
-
- $this->_connection = sqlsrv_connect($serverName, $connectionInfo);
-
- if (!$this->_connection) {
- /**
- * @see Zend_Db_Adapter_Sqlsrv_Exception
- */
- require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
- throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors());
- }
- }
-
- /**
- * Check for config options that are mandatory.
- * Throw exceptions if any are missing.
- *
- * @param array $config
- * @throws Zend_Db_Adapter_Exception
- */
- protected function _checkRequiredOptions(array $config)
- {
- // we need at least a dbname
- if (! array_key_exists('dbname', $config)) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance");
- }
-
- if (! array_key_exists('password', $config) && array_key_exists('username', $config)) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'password' for login credentials.
- If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config.");
- }
-
- if (array_key_exists('password', $config) && !array_key_exists('username', $config)) {
- /**
- * @see Zend_Db_Adapter_Exception
- */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'username' for login credentials.
- If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config.");
- }
- }
-
- /**
- * Set the transaction isoltion level.
- *
- * @param integer|null $level A fetch mode from SQLSRV_TXN_*.
- * @return true
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- public function setTransactionIsolationLevel($level = null)
- {
- $this->_connect();
- $sql = null;
-
- // Default transaction level in sql server
- if ($level === null)
- {
- $level = SQLSRV_TXN_READ_COMMITTED;
- }
-
- switch ($level) {
- case SQLSRV_TXN_READ_UNCOMMITTED:
- $sql = "READ UNCOMMITTED";
- break;
- case SQLSRV_TXN_READ_COMMITTED:
- $sql = "READ COMMITTED";
- break;
- case SQLSRV_TXN_REPEATABLE_READ:
- $sql = "REPEATABLE READ";
- break;
- case SQLSRV_TXN_SNAPSHOT:
- $sql = "SNAPSHOT";
- break;
- case SQLSRV_TXN_SERIALIZABLE:
- $sql = "SERIALIZABLE";
- break;
- default:
- require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
- throw new Zend_Db_Adapter_Sqlsrv_Exception("Invalid transaction isolation level mode '$level' specified");
- }
-
- if (!sqlsrv_query($this->_connection, "SET TRANSACTION ISOLATION LEVEL $sql;")) {
- require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
- throw new Zend_Db_Adapter_Sqlsrv_Exception("Transaction cannot be changed to '$level'");
- }
-
- return true;
- }
-
- /**
- * Test if a connection is active
- *
- * @return boolean
- */
- public function isConnected()
- {
- return (is_resource($this->_connection)
- && (get_resource_type($this->_connection) == 'SQL Server Connection')
- );
- }
-
- /**
- * Force the connection to close.
- *
- * @return void
- */
- public function closeConnection()
- {
- if ($this->isConnected()) {
- sqlsrv_close($this->_connection);
- }
- $this->_connection = null;
- }
-
- /**
- * Returns an SQL statement for preparation.
- *
- * @param string $sql The SQL statement with placeholders.
- * @return Zend_Db_Statement_Sqlsrv
- */
- public function prepare($sql)
- {
- $this->_connect();
- $stmtClass = $this->_defaultStmtClass;
-
- if (!class_exists($stmtClass)) {
- /**
- * @see Zend_Loader
- */
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($stmtClass);
- }
-
- $stmt = new $stmtClass($this, $sql);
- $stmt->setFetchMode($this->_fetchMode);
- return $stmt;
- }
-
- /**
- * Quote a raw string.
- *
- * @param string $value Raw string
- * @return string Quoted string
- */
- protected function _quote($value)
- {
- if (is_int($value)) {
- return $value;
- } elseif (is_float($value)) {
- return sprintf('%F', $value);
- }
-
- return "'" . str_replace("'", "''", $value) . "'";
- }
-
- /**
- * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
- *
- * As a convention, on RDBMS brands that support sequences
- * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
- * from the arguments and returns the last id generated by that sequence.
- * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
- * returns the last value generated for such a column, and the table name
- * argument is disregarded.
- *
- * @param string $tableName OPTIONAL Name of table.
- * @param string $primaryKey OPTIONAL Name of primary key column.
- * @return string
- */
- public function lastInsertId($tableName = null, $primaryKey = null)
- {
- if ($tableName) {
- $tableName = $this->quote($tableName);
- $sql = 'SELECT IDENT_CURRENT (' . $tableName . ') as Current_Identity';
- return (string) $this->fetchOne($sql);
- }
-
- if ($this->_lastInsertId > 0) {
- return (string) $this->_lastInsertId;
- }
-
- $sql = $this->_lastInsertSQL;
- return (string) $this->fetchOne($sql);
- }
-
- /**
- * Inserts a table row with specified data.
- *
- * @param mixed $table The table to insert data into.
- * @param array $bind Column-value pairs.
- * @return int The number of affected rows.
- */
- public function insert($table, array $bind)
- {
- // extract and quote col names from the array keys
- $cols = array();
- $vals = array();
- foreach ($bind as $col => $val) {
- $cols[] = $this->quoteIdentifier($col, true);
- if ($val instanceof Zend_Db_Expr) {
- $vals[] = $val->__toString();
- unset($bind[$col]);
- } else {
- $vals[] = '?';
- }
- }
-
- // build the statement
- $sql = "INSERT INTO "
- . $this->quoteIdentifier($table, true)
- . ' (' . implode(', ', $cols) . ') '
- . 'VALUES (' . implode(', ', $vals) . ')'
- . ' ' . $this->_lastInsertSQL;
-
- // execute the statement and return the number of affected rows
- $stmt = $this->query($sql, array_values($bind));
- $result = $stmt->rowCount();
-
- $stmt->nextRowset();
-
- $this->_lastInsertId = $stmt->fetchColumn();
-
- return $result;
- }
-
- /**
- * Returns a list of the tables in the database.
- *
- * @return array
- */
- public function listTables()
- {
- $this->_connect();
- $sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
- return $this->fetchCol($sql);
- }
-
- /**
- * Returns the column descriptions for a table.
- *
- * The return value is an associative array keyed by the column name,
- * as returned by the RDBMS.
- *
- * The value of each array element is an associative array
- * with the following keys:
- *
- * SCHEMA_NAME => string; name of schema
- * TABLE_NAME => string;
- * COLUMN_NAME => string; column name
- * COLUMN_POSITION => number; ordinal position of column in table
- * DATA_TYPE => string; SQL datatype name of column
- * DEFAULT => string; default expression of column, null if none
- * NULLABLE => boolean; true if column can have nulls
- * LENGTH => number; length of CHAR/VARCHAR
- * SCALE => number; scale of NUMERIC/DECIMAL
- * PRECISION => number; precision of NUMERIC/DECIMAL
- * UNSIGNED => boolean; unsigned property of an integer type
- * PRIMARY => boolean; true if column is part of the primary key
- * PRIMARY_POSITION => integer; position of column in primary key
- * IDENTITY => integer; true if column is auto-generated with unique values
- *
- * @todo Discover integer unsigned property.
- *
- * @param string $tableName
- * @param string $schemaName OPTIONAL
- * @return array
- */
- public function describeTable($tableName, $schemaName = null)
- {
- /**
- * Discover metadata information about this table.
- */
- $sql = "exec sp_columns @table_name = " . $this->quoteIdentifier($tableName, true);
- $stmt = $this->query($sql);
- $result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
-
- $owner = 1;
- $table_name = 2;
- $column_name = 3;
- $type_name = 5;
- $precision = 6;
- $length = 7;
- $scale = 8;
- $nullable = 10;
- $column_def = 12;
- $column_position = 16;
-
- /**
- * Discover primary key column(s) for this table.
- */
- $tableOwner = $result[0][$owner];
- $sql = "exec sp_pkeys @table_owner = " . $tableOwner
- . ", @table_name = " . $this->quoteIdentifier($tableName, true);
- $stmt = $this->query($sql);
-
- $primaryKeysResult = $stmt->fetchAll(Zend_Db::FETCH_NUM);
- $primaryKeyColumn = array();
-
- // Per http://msdn.microsoft.com/en-us/library/ms189813.aspx,
- // results from sp_keys stored procedure are:
- // 0=TABLE_QUALIFIER 1=TABLE_OWNER 2=TABLE_NAME 3=COLUMN_NAME 4=KEY_SEQ 5=PK_NAME
-
- $pkey_column_name = 3;
- $pkey_key_seq = 4;
- foreach ($primaryKeysResult as $pkeysRow) {
- $primaryKeyColumn[$pkeysRow[$pkey_column_name]] = $pkeysRow[$pkey_key_seq];
- }
-
- $desc = array();
- $p = 1;
- foreach ($result as $key => $row) {
- $identity = false;
- $words = explode(' ', $row[$type_name], 2);
- if (isset($words[0])) {
- $type = $words[0];
- if (isset($words[1])) {
- $identity = (bool) preg_match('/identity/', $words[1]);
- }
- }
-
- $isPrimary = array_key_exists($row[$column_name], $primaryKeyColumn);
- if ($isPrimary) {
- $primaryPosition = $primaryKeyColumn[$row[$column_name]];
- } else {
- $primaryPosition = null;
- }
-
- $desc[$this->foldCase($row[$column_name])] = array(
- 'SCHEMA_NAME' => null, // @todo
- 'TABLE_NAME' => $this->foldCase($row[$table_name]),
- 'COLUMN_NAME' => $this->foldCase($row[$column_name]),
- 'COLUMN_POSITION' => (int) $row[$column_position],
- 'DATA_TYPE' => $type,
- 'DEFAULT' => $row[$column_def],
- 'NULLABLE' => (bool) $row[$nullable],
- 'LENGTH' => $row[$length],
- 'SCALE' => $row[$scale],
- 'PRECISION' => $row[$precision],
- 'UNSIGNED' => null, // @todo
- 'PRIMARY' => $isPrimary,
- 'PRIMARY_POSITION' => $primaryPosition,
- 'IDENTITY' => $identity,
- );
- }
-
- return $desc;
- }
-
- /**
- * Leave autocommit mode and begin a transaction.
- *
- * @return void
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- protected function _beginTransaction()
- {
- if (!sqlsrv_begin_transaction($this->_connection)) {
- require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
- throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors());
- }
- }
-
- /**
- * Commit a transaction and return to autocommit mode.
- *
- * @return void
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- protected function _commit()
- {
- if (!sqlsrv_commit($this->_connection)) {
- require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
- throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors());
- }
- }
-
- /**
- * Roll back a transaction and return to autocommit mode.
- *
- * @return void
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- protected function _rollBack()
- {
- if (!sqlsrv_rollback($this->_connection)) {
- require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
- throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors());
- }
- }
-
- /**
- * Set the fetch mode.
- *
- * @todo Support FETCH_CLASS and FETCH_INTO.
- *
- * @param integer $mode A fetch mode.
- * @return void
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- public function setFetchMode($mode)
- {
- switch ($mode) {
- case Zend_Db::FETCH_NUM: // seq array
- case Zend_Db::FETCH_ASSOC: // assoc array
- case Zend_Db::FETCH_BOTH: // seq+assoc array
- case Zend_Db::FETCH_OBJ: // object
- $this->_fetchMode = $mode;
- break;
- case Zend_Db::FETCH_BOUND: // bound to PHP variable
- require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
- throw new Zend_Db_Adapter_Sqlsrv_Exception('FETCH_BOUND is not supported yet');
- break;
- default:
- require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
- throw new Zend_Db_Adapter_Sqlsrv_Exception("Invalid fetch mode '$mode' specified");
- break;
- }
- }
-
- /**
- * Adds an adapter-specific LIMIT clause to the SELECT statement.
- *
- * @param string $sql
- * @param integer $count
- * @param integer $offset OPTIONAL
- * @return string
- * @throws Zend_Db_Adapter_Sqlsrv_Exception
- */
- public function limit($sql, $count, $offset = 0)
- {
- $count = intval($count);
- if ($count <= 0) {
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
- }
-
- $offset = intval($offset);
- if ($offset < 0) {
- /** @see Zend_Db_Adapter_Exception */
- require_once 'Zend/Db/Adapter/Exception.php';
- throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
- }
-
- if ($offset == 0) {
- $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . $count . ' ', $sql);
- } else {
- $orderby = stristr($sql, 'ORDER BY');
- if ($orderby !== false) {
- $sort = (stripos($orderby, ' desc') !== false) ? 'desc' : 'asc';
- $order = str_ireplace('ORDER BY', '', $orderby);
- $order = trim(preg_replace('/\bASC\b|\bDESC\b/i', '', $order));
- }
-
- $sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . ($count+$offset) . ' ', $sql);
-
- $sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl';
- if ($orderby !== false) {
- $innerOrder = preg_replace('/\".*\".\"(.*)\"/i', '"inner_tbl"."$1"', $order);
- $sql .= ' ORDER BY ' . $innerOrder . ' ';
- $sql .= (stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC';
- }
- $sql .= ') AS outer_tbl';
- if ($orderby !== false) {
- $outerOrder = preg_replace('/\".*\".\"(.*)\"/i', '"outer_tbl"."$1"', $order);
- $sql .= ' ORDER BY ' . $outerOrder . ' ' . $sort;
- }
- }
-
- return $sql;
- }
-
- /**
- * Check if the adapter supports real SQL parameters.
- *
- * @param string $type 'positional' or 'named'
- * @return bool
- */
- public function supportsParameters($type)
- {
- if ($type == 'positional') {
- return true;
- }
-
- // if its 'named' or anything else
- return false;
- }
-
- /**
- * Retrieve server version in PHP style
- *
- * @return string
- */
- public function getServerVersion()
- {
- $this->_connect();
- $version = sqlsrv_client_info($this->_connection);
-
- if ($version !== false) {
- return $version['DriverVer'];
- }
-
- return null;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Adapter/StatementContainerInterface.php zendframework-2.2.6/library/Zend/Db/Adapter/StatementContainerInterface.php
--- zendframework-1.10.4/library/Zend/Db/Adapter/StatementContainerInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Adapter/StatementContainerInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,43 @@
+setSql($sql);
+ }
+ $this->parameterContainer = ($parameterContainer) ?: new ParameterContainer;
+ }
+
+ /**
+ * @param $sql
+ * @return StatementContainer
+ */
+ public function setSql($sql)
+ {
+ $this->sql = $sql;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getSql()
+ {
+ return $this->sql;
+ }
+
+ /**
+ * @param ParameterContainer $parameterContainer
+ * @return StatementContainer
+ */
+ public function setParameterContainer(ParameterContainer $parameterContainer)
+ {
+ $this->parameterContainer = $parameterContainer;
+ return $this;
+ }
+
+ /**
+ * @return null|ParameterContainer
+ */
+ public function getParameterContainer()
+ {
+ return $this->parameterContainer;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/composer.json zendframework-2.2.6/library/Zend/Db/composer.json
--- zendframework-1.10.4/library/Zend/Db/composer.json 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/composer.json 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,27 @@
+{
+ "name": "zendframework/zend-db",
+ "description": " ",
+ "license": "BSD-3-Clause",
+ "keywords": [
+ "zf2",
+ "db"
+ ],
+ "autoload": {
+ "psr-0": {
+ "Zend\\Db\\": ""
+ }
+ },
+ "target-dir": "Zend/Db",
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "suggest": {
+ "zendframework/zend-stdlib": "self.version"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev",
+ "dev-develop": "2.3-dev"
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Exception/ErrorException.php zendframework-2.2.6/library/Zend/Db/Exception/ErrorException.php
--- zendframework-1.10.4/library/Zend/Db/Exception/ErrorException.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Exception/ErrorException.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,14 @@
+_expression = (string) $expression;
- }
-
- /**
- * @return string The string of the SQL expression stored in this object.
- */
- public function __toString()
- {
- return $this->_expression;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Metadata/MetadataInterface.php zendframework-2.2.6/library/Zend/Db/Metadata/MetadataInterface.php
--- zendframework-1.10.4/library/Zend/Db/Metadata/MetadataInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Metadata/MetadataInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,36 @@
+adapter = $adapter;
+ $this->source = $this->createSourceFromAdapter($adapter);
+ }
+
+ /**
+ * Create source from adapter
+ *
+ * @param Adapter $adapter
+ * @return Source\AbstractSource
+ */
+ protected function createSourceFromAdapter(Adapter $adapter)
+ {
+ switch ($adapter->getPlatform()->getName()) {
+ case 'MySQL':
+ return new Source\MysqlMetadata($adapter);
+ case 'SQLServer':
+ return new Source\SqlServerMetadata($adapter);
+ case 'SQLite':
+ return new Source\SqliteMetadata($adapter);
+ case 'PostgreSQL':
+ return new Source\PostgresqlMetadata($adapter);
+ }
+
+ throw new \Exception('cannot create source from adapter');
+ }
+
+ // @todo methods
+
+ /**
+ * Get base tables and views
+ *
+ * @param string $schema
+ * @param bool $includeViews
+ * @return Object\TableObject[]
+ */
+ public function getTables($schema = null, $includeViews = false)
+ {
+ return $this->source->getTables($schema, $includeViews);
+ }
+
+ /**
+ * Get base tables and views
+ *
+ * @param string $schema
+ * @return Object\TableObject[]
+ */
+ public function getViews($schema = null)
+ {
+ return $this->source->getViews($schema);
+ }
+
+ /**
+ * Get triggers
+ *
+ * @param string $schema
+ * @return array
+ */
+ public function getTriggers($schema = null)
+ {
+ return $this->source->getTriggers($schema);
+ }
+
+ /**
+ * Get constraints
+ *
+ * @param string $table
+ * @param string $schema
+ * @return array
+ */
+ public function getConstraints($table, $schema = null)
+ {
+ return $this->source->getConstraints($table, $schema);
+ }
+
+ /**
+ * Get columns
+ *
+ * @param string $table
+ * @param string $schema
+ * @return array
+ */
+ public function getColumns($table, $schema = null)
+ {
+ return $this->source->getColumns($table, $schema);
+ }
+
+ /**
+ * Get constraint keys
+ *
+ * @param string $constraint
+ * @param string $table
+ * @param string $schema
+ * @return array
+ */
+ public function getConstraintKeys($constraint, $table, $schema = null)
+ {
+ return $this->source->getConstraintKeys($constraint, $table, $schema);
+ }
+
+ /**
+ * Get constraints
+ *
+ * @param string $constraintName
+ * @param string $table
+ * @param string $schema
+ * @return Object\ConstraintObject
+ */
+ public function getConstraint($constraintName, $table, $schema = null)
+ {
+ return $this->source->getConstraint($constraintName, $table, $schema);
+ }
+
+ /**
+ * Get schemas
+ */
+ public function getSchemas()
+ {
+ return $this->source->getSchemas();
+ }
+
+ /**
+ * Get table names
+ *
+ * @param string $schema
+ * @param bool $includeViews
+ * @return array
+ */
+ public function getTableNames($schema = null, $includeViews = false)
+ {
+ return $this->source->getTableNames($schema, $includeViews);
+ }
+
+ /**
+ * Get table
+ *
+ * @param string $tableName
+ * @param string $schema
+ * @return Object\TableObject
+ */
+ public function getTable($tableName, $schema = null)
+ {
+ return $this->source->getTable($tableName, $schema);
+ }
+
+ /**
+ * Get views names
+ *
+ * @param string $schema
+ * @return \Zend\Db\Metadata\Object\TableObject
+ */
+ public function getViewNames($schema = null)
+ {
+ return $this->source->getTable($schema);
+ }
+
+ /**
+ * Get view
+ *
+ * @param string $viewName
+ * @param string $schema
+ * @return \Zend\Db\Metadata\Object\TableObject
+ */
+ public function getView($viewName, $schema = null)
+ {
+ return $this->source->getView($viewName, $schema);
+ }
+
+ /**
+ * Get trigger names
+ *
+ * @param string $schema
+ * @return array
+ */
+ public function getTriggerNames($schema = null)
+ {
+ return $this->source->getTriggerNames($schema);
+ }
+
+ /**
+ * Get trigger
+ *
+ * @param string $triggerName
+ * @param string $schema
+ * @return \Zend\Db\Metadata\Object\TriggerObject
+ */
+ public function getTrigger($triggerName, $schema = null)
+ {
+ return $this->source->getTrigger($triggerName, $schema);
+ }
+
+ /**
+ * Get column names
+ *
+ * @param string $table
+ * @param string $schema
+ * @return array
+ */
+ public function getColumnNames($table, $schema = null)
+ {
+ return $this->source->getColumnNames($table, $schema);
+ }
+
+ /**
+ * Get column
+ *
+ * @param string $columnName
+ * @param string $table
+ * @param string $schema
+ * @return \Zend\Db\Metadata\Object\ColumnObject
+ */
+ public function getColumn($columnName, $table, $schema = null)
+ {
+ return $this->source->getColumn($columnName, $table, $schema);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Metadata/Object/AbstractTableObject.php zendframework-2.2.6/library/Zend/Db/Metadata/Object/AbstractTableObject.php
--- zendframework-1.10.4/library/Zend/Db/Metadata/Object/AbstractTableObject.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Metadata/Object/AbstractTableObject.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,115 @@
+setName($name);
+ }
+ }
+
+ /**
+ * Set columns
+ *
+ * @param array $columns
+ */
+ public function setColumns(array $columns)
+ {
+ $this->columns = $columns;
+ }
+
+ /**
+ * Get columns
+ *
+ * @return array
+ */
+ public function getColumns()
+ {
+ return $this->columns;
+ }
+
+ /**
+ * Set constraints
+ *
+ * @param array $constraints
+ */
+ public function setConstraints($constraints)
+ {
+ $this->constraints = $constraints;
+ }
+
+ /**
+ * Get constraints
+ *
+ * @return array
+ */
+ public function getConstraints()
+ {
+ return $this->constraints;
+ }
+
+ /**
+ * Set name
+ *
+ * @param string $name
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Metadata/Object/ColumnObject.php zendframework-2.2.6/library/Zend/Db/Metadata/Object/ColumnObject.php
--- zendframework-1.10.4/library/Zend/Db/Metadata/Object/ColumnObject.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Metadata/Object/ColumnObject.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,389 @@
+setName($name);
+ $this->setTableName($tableName);
+ $this->setSchemaName($schemaName);
+ }
+
+ /**
+ * Set name
+ *
+ * @param string $name
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Get table name
+ *
+ * @return string
+ */
+ public function getTableName()
+ {
+ return $this->tableName;
+ }
+
+ /**
+ * Set table name
+ *
+ * @param string $tableName
+ * @return ColumnObject
+ */
+ public function setTableName($tableName)
+ {
+ $this->tableName = $tableName;
+ return $this;
+ }
+
+ /**
+ * Set schema name
+ *
+ * @param string $schemaName
+ */
+ public function setSchemaName($schemaName)
+ {
+ $this->schemaName = $schemaName;
+ }
+
+ /**
+ * Get schema name
+ *
+ * @return string
+ */
+ public function getSchemaName()
+ {
+ return $this->schemaName;
+ }
+
+ /**
+ * @return int $ordinalPosition
+ */
+ public function getOrdinalPosition()
+ {
+ return $this->ordinalPosition;
+ }
+
+ /**
+ * @param int $ordinalPosition to set
+ * @return ColumnObject
+ */
+ public function setOrdinalPosition($ordinalPosition)
+ {
+ $this->ordinalPosition = $ordinalPosition;
+ return $this;
+ }
+
+ /**
+ * @return null|string the $columnDefault
+ */
+ public function getColumnDefault()
+ {
+ return $this->columnDefault;
+ }
+
+ /**
+ * @param mixed $columnDefault to set
+ * @return ColumnObject
+ */
+ public function setColumnDefault($columnDefault)
+ {
+ $this->columnDefault = $columnDefault;
+ return $this;
+ }
+
+ /**
+ * @return bool $isNullable
+ */
+ public function getIsNullable()
+ {
+ return $this->isNullable;
+ }
+
+ /**
+ * @param bool $isNullable to set
+ * @return ColumnObject
+ */
+ public function setIsNullable($isNullable)
+ {
+ $this->isNullable = $isNullable;
+ return $this;
+ }
+
+ /**
+ * @return bool $isNullable
+ */
+ public function isNullable()
+ {
+ return $this->isNullable;
+ }
+
+ /**
+ * @return null|string the $dataType
+ */
+ public function getDataType()
+ {
+ return $this->dataType;
+ }
+
+ /**
+ * @param string $dataType the $dataType to set
+ * @return ColumnObject
+ */
+ public function setDataType($dataType)
+ {
+ $this->dataType = $dataType;
+ return $this;
+ }
+
+ /**
+ * @return int|null the $characterMaximumLength
+ */
+ public function getCharacterMaximumLength()
+ {
+ return $this->characterMaximumLength;
+ }
+
+ /**
+ * @param int $characterMaximumLength the $characterMaximumLength to set
+ * @return ColumnObject
+ */
+ public function setCharacterMaximumLength($characterMaximumLength)
+ {
+ $this->characterMaximumLength = $characterMaximumLength;
+ return $this;
+ }
+
+ /**
+ * @return int|null the $characterOctetLength
+ */
+ public function getCharacterOctetLength()
+ {
+ return $this->characterOctetLength;
+ }
+
+ /**
+ * @param int $characterOctetLength the $characterOctetLength to set
+ * @return ColumnObject
+ */
+ public function setCharacterOctetLength($characterOctetLength)
+ {
+ $this->characterOctetLength = $characterOctetLength;
+ return $this;
+ }
+
+ /**
+ * @return int the $numericPrecision
+ */
+ public function getNumericPrecision()
+ {
+ return $this->numericPrecision;
+ }
+
+ /**
+ * @param int $numericPrecision the $numericPrevision to set
+ * @return ColumnObject
+ */
+ public function setNumericPrecision($numericPrecision)
+ {
+ $this->numericPrecision = $numericPrecision;
+ return $this;
+ }
+
+ /**
+ * @return int the $numericScale
+ */
+ public function getNumericScale()
+ {
+ return $this->numericScale;
+ }
+
+ /**
+ * @param int $numericScale the $numericScale to set
+ * @return ColumnObject
+ */
+ public function setNumericScale($numericScale)
+ {
+ $this->numericScale = $numericScale;
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function getNumericUnsigned()
+ {
+ return $this->numericUnsigned;
+ }
+
+ /**
+ * @param bool $numericUnsigned
+ * @return ColumnObject
+ */
+ public function setNumericUnsigned($numericUnsigned)
+ {
+ $this->numericUnsigned = $numericUnsigned;
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isNumericUnsigned()
+ {
+ return $this->numericUnsigned;
+ }
+
+ /**
+ * @return array the $errata
+ */
+ public function getErratas()
+ {
+ return $this->errata;
+ }
+
+ /**
+ * @param array $erratas
+ * @return ColumnObject
+ */
+ public function setErratas(array $erratas)
+ {
+ foreach ($erratas as $name => $value) {
+ $this->setErrata($name, $value);
+ }
+ return $this;
+ }
+
+ /**
+ * @param string $errataName
+ * @return mixed
+ */
+ public function getErrata($errataName)
+ {
+ if (array_key_exists($errataName, $this->errata)) {
+ return $this->errata[$errataName];
+ }
+ return null;
+ }
+
+ /**
+ * @param string $errataName
+ * @param mixed $errataValue
+ * @return ColumnObject
+ */
+ public function setErrata($errataName, $errataValue)
+ {
+ $this->errata[$errataName] = $errataValue;
+ return $this;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Metadata/Object/ConstraintKeyObject.php zendframework-2.2.6/library/Zend/Db/Metadata/Object/ConstraintKeyObject.php
--- zendframework-1.10.4/library/Zend/Db/Metadata/Object/ConstraintKeyObject.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Metadata/Object/ConstraintKeyObject.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,250 @@
+setColumnName($column);
+ }
+
+ /**
+ * Get column name
+ *
+ * @return string
+ */
+ public function getColumnName()
+ {
+ return $this->columnName;
+ }
+
+ /**
+ * Set column name
+ *
+ * @param string $columnName
+ * @return ConstraintKeyObject
+ */
+ public function setColumnName($columnName)
+ {
+ $this->columnName = $columnName;
+ return $this;
+ }
+
+ /**
+ * Get ordinal position
+ *
+ * @return int
+ */
+ public function getOrdinalPosition()
+ {
+ return $this->ordinalPosition;
+ }
+
+ /**
+ * Set ordinal position
+ *
+ * @param int $ordinalPosition
+ * @return ConstraintKeyObject
+ */
+ public function setOrdinalPosition($ordinalPosition)
+ {
+ $this->ordinalPosition = $ordinalPosition;
+ return $this;
+ }
+
+ /**
+ * Get position in unique constraint
+ *
+ * @return bool
+ */
+ public function getPositionInUniqueConstraint()
+ {
+ return $this->positionInUniqueConstraint;
+ }
+
+ /**
+ * Set position in unique constraint
+ *
+ * @param bool $positionInUniqueConstraint
+ * @return ConstraintKeyObject
+ */
+ public function setPositionInUniqueConstraint($positionInUniqueConstraint)
+ {
+ $this->positionInUniqueConstraint = $positionInUniqueConstraint;
+ return $this;
+ }
+
+ /**
+ * Get referencred table schema
+ *
+ * @return string
+ */
+ public function getReferencedTableSchema()
+ {
+ return $this->referencedTableSchema;
+ }
+
+ /**
+ * Set referenced table schema
+ *
+ * @param string $referencedTableSchema
+ * @return ConstraintKeyObject
+ */
+ public function setReferencedTableSchema($referencedTableSchema)
+ {
+ $this->referencedTableSchema = $referencedTableSchema;
+ return $this;
+ }
+
+ /**
+ * Get referenced table name
+ *
+ * @return string
+ */
+ public function getReferencedTableName()
+ {
+ return $this->referencedTableName;
+ }
+
+ /**
+ * Set Referenced table name
+ *
+ * @param string $referencedTableName
+ * @return ConstraintKeyObject
+ */
+ public function setReferencedTableName($referencedTableName)
+ {
+ $this->referencedTableName = $referencedTableName;
+ return $this;
+ }
+
+ /**
+ * Get referenced column name
+ *
+ * @return string
+ */
+ public function getReferencedColumnName()
+ {
+ return $this->referencedColumnName;
+ }
+
+ /**
+ * Set referenced column name
+ *
+ * @param string $referencedColumnName
+ * @return ConstraintKeyObject
+ */
+ public function setReferencedColumnName($referencedColumnName)
+ {
+ $this->referencedColumnName = $referencedColumnName;
+ return $this;
+ }
+
+ /**
+ * set foreign key update rule
+ *
+ * @param string $foreignKeyUpdateRule
+ */
+ public function setForeignKeyUpdateRule($foreignKeyUpdateRule)
+ {
+ $this->foreignKeyUpdateRule = $foreignKeyUpdateRule;
+ }
+
+ /**
+ * Get foreign key update rule
+ *
+ * @return string
+ */
+ public function getForeignKeyUpdateRule()
+ {
+ return $this->foreignKeyUpdateRule;
+ }
+
+ /**
+ * Set foreign key delete rule
+ *
+ * @param string $foreignKeyDeleteRule
+ */
+ public function setForeignKeyDeleteRule($foreignKeyDeleteRule)
+ {
+ $this->foreignKeyDeleteRule = $foreignKeyDeleteRule;
+ }
+
+ /**
+ * get foreign key delete rule
+ *
+ * @return string
+ */
+ public function getForeignKeyDeleteRule()
+ {
+ return $this->foreignKeyDeleteRule;
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Metadata/Object/ConstraintObject.php zendframework-2.2.6/library/Zend/Db/Metadata/Object/ConstraintObject.php
--- zendframework-1.10.4/library/Zend/Db/Metadata/Object/ConstraintObject.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Metadata/Object/ConstraintObject.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,411 @@
+setName($name);
+ $this->setTableName($tableName);
+ $this->setSchemaName($schemaName);
+ }
+
+ /**
+ * Set name
+ *
+ * @param string $name
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Set schema name
+ *
+ * @param string $schemaName
+ */
+ public function setSchemaName($schemaName)
+ {
+ $this->schemaName = $schemaName;
+ }
+
+ /**
+ * Get schema name
+ *
+ * @return string
+ */
+ public function getSchemaName()
+ {
+ return $this->schemaName;
+ }
+
+ /**
+ * Get table name
+ *
+ * @return string
+ */
+ public function getTableName()
+ {
+ return $this->tableName;
+ }
+
+ /**
+ * Set table name
+ *
+ * @param string $tableName
+ * @return ConstraintObject
+ */
+ public function setTableName($tableName)
+ {
+ $this->tableName = $tableName;
+ return $this;
+ }
+
+ /**
+ * Set type
+ *
+ * @param string $type
+ */
+ public function setType($type)
+ {
+ $this->type = $type;
+ }
+
+ /**
+ * Get type
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ public function hasColumns()
+ {
+ return (!empty($this->columns));
+ }
+
+ /**
+ * Get Columns.
+ *
+ * @return string[]
+ */
+ public function getColumns()
+ {
+ return $this->columns;
+ }
+
+ /**
+ * Set Columns.
+ *
+ * @param string[] $columns
+ * @return ConstraintObject
+ */
+ public function setColumns(array $columns)
+ {
+ $this->columns = $columns;
+ return $this;
+ }
+
+ /**
+ * Get Referenced Table Schema.
+ *
+ * @return string
+ */
+ public function getReferencedTableSchema()
+ {
+ return $this->referencedTableSchema;
+ }
+
+ /**
+ * Set Referenced Table Schema.
+ *
+ * @param string $referencedTableSchema
+ * @return ConstraintObject
+ */
+ public function setReferencedTableSchema($referencedTableSchema)
+ {
+ $this->referencedTableSchema = $referencedTableSchema;
+ return $this;
+ }
+
+ /**
+ * Get Referenced Table Name.
+ *
+ * @return string
+ */
+ public function getReferencedTableName()
+ {
+ return $this->referencedTableName;
+ }
+
+ /**
+ * Set Referenced Table Name.
+ *
+ * @param string $referencedTableName
+ * @return ConstraintObject
+ */
+ public function setReferencedTableName($referencedTableName)
+ {
+ $this->referencedTableName = $referencedTableName;
+ return $this;
+ }
+
+ /**
+ * Get Referenced Columns.
+ *
+ * @return string[]
+ */
+ public function getReferencedColumns()
+ {
+ return $this->referencedColumns;
+ }
+
+ /**
+ * Set Referenced Columns.
+ *
+ * @param string[] $referencedColumns
+ * @return ConstraintObject
+ */
+ public function setReferencedColumns(array $referencedColumns)
+ {
+ $this->referencedColumns = $referencedColumns;
+ return $this;
+ }
+
+ /**
+ * Get Match Option.
+ *
+ * @return string
+ */
+ public function getMatchOption()
+ {
+ return $this->matchOption;
+ }
+
+ /**
+ * Set Match Option.
+ *
+ * @param string $matchOption
+ * @return ConstraintObject
+ */
+ public function setMatchOption($matchOption)
+ {
+ $this->matchOption = $matchOption;
+ return $this;
+ }
+
+ /**
+ * Get Update Rule.
+ *
+ * @return string
+ */
+ public function getUpdateRule()
+ {
+ return $this->updateRule;
+ }
+
+ /**
+ * Set Update Rule.
+ *
+ * @param string $updateRule
+ * @return ConstraintObject
+ */
+ public function setUpdateRule($updateRule)
+ {
+ $this->updateRule = $updateRule;
+ return $this;
+ }
+
+ /**
+ * Get Delete Rule.
+ *
+ * @return string
+ */
+ public function getDeleteRule()
+ {
+ return $this->deleteRule;
+ }
+
+ /**
+ * Set Delete Rule.
+ *
+ * @param string $deleteRule
+ * @return ConstraintObject
+ */
+ public function setDeleteRule($deleteRule)
+ {
+ $this->deleteRule = $deleteRule;
+ return $this;
+ }
+
+ /**
+ * Get Check Clause.
+ *
+ * @return string
+ */
+ public function getCheckClause()
+ {
+ return $this->checkClause;
+ }
+
+ /**
+ * Set Check Clause.
+ *
+ * @param string $checkClause
+ * @return ConstraintObject
+ */
+ public function setCheckClause($checkClause)
+ {
+ $this->checkClause = $checkClause;
+ return $this;
+ }
+
+ /**
+ * Is primary key
+ *
+ * @return bool
+ */
+ public function isPrimaryKey()
+ {
+ return ('PRIMARY KEY' == $this->type);
+ }
+
+ /**
+ * Is unique key
+ *
+ * @return bool
+ */
+ public function isUnique()
+ {
+ return ('UNIQUE' == $this->type);
+ }
+
+ /**
+ * Is foreign key
+ *
+ * @return bool
+ */
+ public function isForeignKey()
+ {
+ return ('FOREIGN KEY' == $this->type);
+ }
+
+ /**
+ * Is foreign key
+ *
+ * @return bool
+ */
+ public function isCheck()
+ {
+ return ('CHECK' == $this->type);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Metadata/Object/TableObject.php zendframework-2.2.6/library/Zend/Db/Metadata/Object/TableObject.php
--- zendframework-1.10.4/library/Zend/Db/Metadata/Object/TableObject.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Metadata/Object/TableObject.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,14 @@
+name;
+ }
+
+ /**
+ * Set Name.
+ *
+ * @param string $name
+ * @return TriggerObject
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * Get Event Manipulation.
+ *
+ * @return string
+ */
+ public function getEventManipulation()
+ {
+ return $this->eventManipulation;
+ }
+
+ /**
+ * Set Event Manipulation.
+ *
+ * @param string $eventManipulation
+ * @return TriggerObject
+ */
+ public function setEventManipulation($eventManipulation)
+ {
+ $this->eventManipulation = $eventManipulation;
+ return $this;
+ }
+
+ /**
+ * Get Event Object Catalog.
+ *
+ * @return string
+ */
+ public function getEventObjectCatalog()
+ {
+ return $this->eventObjectCatalog;
+ }
+
+ /**
+ * Set Event Object Catalog.
+ *
+ * @param string $eventObjectCatalog
+ * @return TriggerObject
+ */
+ public function setEventObjectCatalog($eventObjectCatalog)
+ {
+ $this->eventObjectCatalog = $eventObjectCatalog;
+ return $this;
+ }
+
+ /**
+ * Get Event Object Schema.
+ *
+ * @return string
+ */
+ public function getEventObjectSchema()
+ {
+ return $this->eventObjectSchema;
+ }
+
+ /**
+ * Set Event Object Schema.
+ *
+ * @param string $eventObjectSchema
+ * @return TriggerObject
+ */
+ public function setEventObjectSchema($eventObjectSchema)
+ {
+ $this->eventObjectSchema = $eventObjectSchema;
+ return $this;
+ }
+
+ /**
+ * Get Event Object Table.
+ *
+ * @return string
+ */
+ public function getEventObjectTable()
+ {
+ return $this->eventObjectTable;
+ }
+
+ /**
+ * Set Event Object Table.
+ *
+ * @param string $eventObjectTable
+ * @return TriggerObject
+ */
+ public function setEventObjectTable($eventObjectTable)
+ {
+ $this->eventObjectTable = $eventObjectTable;
+ return $this;
+ }
+
+ /**
+ * Get Action Order.
+ *
+ * @return string
+ */
+ public function getActionOrder()
+ {
+ return $this->actionOrder;
+ }
+
+ /**
+ * Set Action Order.
+ *
+ * @param string $actionOrder
+ * @return TriggerObject
+ */
+ public function setActionOrder($actionOrder)
+ {
+ $this->actionOrder = $actionOrder;
+ return $this;
+ }
+
+ /**
+ * Get Action Condition.
+ *
+ * @return string
+ */
+ public function getActionCondition()
+ {
+ return $this->actionCondition;
+ }
+
+ /**
+ * Set Action Condition.
+ *
+ * @param string $actionCondition
+ * @return TriggerObject
+ */
+ public function setActionCondition($actionCondition)
+ {
+ $this->actionCondition = $actionCondition;
+ return $this;
+ }
+
+ /**
+ * Get Action Statement.
+ *
+ * @return string
+ */
+ public function getActionStatement()
+ {
+ return $this->actionStatement;
+ }
+
+ /**
+ * Set Action Statement.
+ *
+ * @param string $actionStatement
+ * @return TriggerObject
+ */
+ public function setActionStatement($actionStatement)
+ {
+ $this->actionStatement = $actionStatement;
+ return $this;
+ }
+
+ /**
+ * Get Action Orientation.
+ *
+ * @return string
+ */
+ public function getActionOrientation()
+ {
+ return $this->actionOrientation;
+ }
+
+ /**
+ * Set Action Orientation.
+ *
+ * @param string $actionOrientation
+ * @return TriggerObject
+ */
+ public function setActionOrientation($actionOrientation)
+ {
+ $this->actionOrientation = $actionOrientation;
+ return $this;
+ }
+
+ /**
+ * Get Action Timing.
+ *
+ * @return string
+ */
+ public function getActionTiming()
+ {
+ return $this->actionTiming;
+ }
+
+ /**
+ * Set Action Timing.
+ *
+ * @param string $actionTiming
+ * @return TriggerObject
+ */
+ public function setActionTiming($actionTiming)
+ {
+ $this->actionTiming = $actionTiming;
+ return $this;
+ }
+
+ /**
+ * Get Action Reference Old Table.
+ *
+ * @return string
+ */
+ public function getActionReferenceOldTable()
+ {
+ return $this->actionReferenceOldTable;
+ }
+
+ /**
+ * Set Action Reference Old Table.
+ *
+ * @param string $actionReferenceOldTable
+ * @return TriggerObject
+ */
+ public function setActionReferenceOldTable($actionReferenceOldTable)
+ {
+ $this->actionReferenceOldTable = $actionReferenceOldTable;
+ return $this;
+ }
+
+ /**
+ * Get Action Reference New Table.
+ *
+ * @return string
+ */
+ public function getActionReferenceNewTable()
+ {
+ return $this->actionReferenceNewTable;
+ }
+
+ /**
+ * Set Action Reference New Table.
+ *
+ * @param string $actionReferenceNewTable
+ * @return TriggerObject
+ */
+ public function setActionReferenceNewTable($actionReferenceNewTable)
+ {
+ $this->actionReferenceNewTable = $actionReferenceNewTable;
+ return $this;
+ }
+
+ /**
+ * Get Action Reference Old Row.
+ *
+ * @return string
+ */
+ public function getActionReferenceOldRow()
+ {
+ return $this->actionReferenceOldRow;
+ }
+
+ /**
+ * Set Action Reference Old Row.
+ *
+ * @param string $actionReferenceOldRow
+ * @return TriggerObject
+ */
+ public function setActionReferenceOldRow($actionReferenceOldRow)
+ {
+ $this->actionReferenceOldRow = $actionReferenceOldRow;
+ return $this;
+ }
+
+ /**
+ * Get Action Reference New Row.
+ *
+ * @return string
+ */
+ public function getActionReferenceNewRow()
+ {
+ return $this->actionReferenceNewRow;
+ }
+
+ /**
+ * Set Action Reference New Row.
+ *
+ * @param string $actionReferenceNewRow
+ * @return TriggerObject
+ */
+ public function setActionReferenceNewRow($actionReferenceNewRow)
+ {
+ $this->actionReferenceNewRow = $actionReferenceNewRow;
+ return $this;
+ }
+
+ /**
+ * Get Created.
+ *
+ * @return \DateTime
+ */
+ public function getCreated()
+ {
+ return $this->created;
+ }
+
+ /**
+ * Set Created.
+ *
+ * @param \DateTime $created
+ * @return TriggerObject
+ */
+ public function setCreated($created)
+ {
+ $this->created = $created;
+ return $this;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Metadata/Object/ViewObject.php zendframework-2.2.6/library/Zend/Db/Metadata/Object/ViewObject.php
--- zendframework-1.10.4/library/Zend/Db/Metadata/Object/ViewObject.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Metadata/Object/ViewObject.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,76 @@
+viewDefinition;
+ }
+
+ /**
+ * @param string $viewDefinition to set
+ * @return ViewObject
+ */
+ public function setViewDefinition($viewDefinition)
+ {
+ $this->viewDefinition = $viewDefinition;
+ return $this;
+ }
+
+ /**
+ * @return string $checkOption
+ */
+ public function getCheckOption()
+ {
+ return $this->checkOption;
+ }
+
+ /**
+ * @param string $checkOption to set
+ * @return ViewObject
+ */
+ public function setCheckOption($checkOption)
+ {
+ $this->checkOption = $checkOption;
+ return $this;
+ }
+
+ /**
+ * @return bool $isUpdatable
+ */
+ public function getIsUpdatable()
+ {
+ return $this->isUpdatable;
+ }
+
+ /**
+ * @param bool $isUpdatable to set
+ * @return ViewObject
+ */
+ public function setIsUpdatable($isUpdatable)
+ {
+ $this->isUpdatable = $isUpdatable;
+ return $this;
+ }
+
+ public function isUpdatable()
+ {
+ return $this->isUpdatable;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Metadata/Source/AbstractSource.php zendframework-2.2.6/library/Zend/Db/Metadata/Source/AbstractSource.php
--- zendframework-1.10.4/library/Zend/Db/Metadata/Source/AbstractSource.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Metadata/Source/AbstractSource.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,602 @@
+adapter = $adapter;
+ $this->defaultSchema = ($adapter->getCurrentSchema()) ?: self::DEFAULT_SCHEMA;
+ }
+
+ /**
+ * Get schemas
+ *
+ */
+ public function getSchemas()
+ {
+ $this->loadSchemaData();
+
+ return $this->data['schemas'];
+ }
+
+ /**
+ * Get table names
+ *
+ * @param string $schema
+ * @param bool $includeViews
+ * @return string[]
+ */
+ public function getTableNames($schema = null, $includeViews = false)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $this->loadTableNameData($schema);
+
+ if ($includeViews) {
+ return array_keys($this->data['table_names'][$schema]);
+ }
+
+ $tableNames = array();
+ foreach ($this->data['table_names'][$schema] as $tableName => $data) {
+ if ('BASE TABLE' == $data['table_type']) {
+ $tableNames[] = $tableName;
+ }
+ }
+ return $tableNames;
+
+ }
+
+ /**
+ * Get tables
+ *
+ * @param string $schema
+ * @param bool $includeViews
+ * @return Object\TableObject[]
+ */
+ public function getTables($schema = null, $includeViews = false)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $tables = array();
+ foreach ($this->getTableNames($schema, $includeViews) as $tableName) {
+ $tables[] = $this->getTable($tableName, $schema);
+ }
+ return $tables;
+ }
+
+ /**
+ * Get table
+ *
+ * @param string $tableName
+ * @param string $schema
+ * @return Object\TableObject
+ */
+ public function getTable($tableName, $schema = null)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $this->loadTableNameData($schema);
+
+ if (!isset($this->data['table_names'][$schema][$tableName])) {
+ throw new \Exception('Table "' . $tableName . '" does not exist');
+ }
+
+ $data = $this->data['table_names'][$schema][$tableName];
+ switch ($data['table_type']) {
+ case 'BASE TABLE':
+ $table = new Object\TableObject($tableName);
+ break;
+ case 'VIEW':
+ $table = new Object\ViewObject($tableName);
+ $table->setViewDefinition($data['view_definition']);
+ $table->setCheckOption($data['check_option']);
+ $table->setIsUpdatable($data['is_updatable']);
+ break;
+ default:
+ throw new \Exception('Table "' . $tableName . '" is of an unsupported type "' . $data['table_type'] . '"');
+ }
+ $table->setColumns($this->getColumns($tableName, $schema));
+ $table->setConstraints($this->getConstraints($tableName, $schema));
+ return $table;
+ }
+
+ /**
+ * Get view names
+ *
+ * @param string $schema
+ * @return array
+ */
+ public function getViewNames($schema = null)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $this->loadTableNameData($schema);
+
+ $viewNames = array();
+ foreach ($this->data['table_names'][$schema] as $tableName => $data) {
+ if ('VIEW' == $data['table_type']) {
+ $viewNames[] = $tableName;
+ }
+ }
+ return $viewNames;
+ }
+
+ /**
+ * Get views
+ *
+ * @param string $schema
+ * @return array
+ */
+ public function getViews($schema = null)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $views = array();
+ foreach ($this->getViewNames($schema) as $tableName) {
+ $views[] = $this->getTable($tableName, $schema);
+ }
+ return $views;
+ }
+
+ /**
+ * Get view
+ *
+ * @param string $viewName
+ * @param string $schema
+ * @return \Zend\Db\Metadata\Object\TableObject
+ */
+ public function getView($viewName, $schema = null)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $this->loadTableNameData($schema);
+
+ $tableNames = $this->data['table_names'][$schema];
+ if (isset($tableNames[$viewName]) && 'VIEW' == $tableNames[$viewName]['table_type']) {
+ return $this->getTable($viewName, $schema);
+ }
+ throw new \Exception('View "' . $viewName . '" does not exist');
+ }
+
+ /**
+ * Gt column names
+ *
+ * @param string $table
+ * @param string $schema
+ * @return array
+ */
+ public function getColumnNames($table, $schema = null)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $this->loadColumnData($table, $schema);
+
+ if (!isset($this->data['columns'][$schema][$table])) {
+ throw new \Exception('"' . $table . '" does not exist');
+ }
+
+ return array_keys($this->data['columns'][$schema][$table]);
+ }
+
+ /**
+ * Get columns
+ *
+ * @param string $table
+ * @param string $schema
+ * @return array
+ */
+ public function getColumns($table, $schema = null)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $this->loadColumnData($table, $schema);
+
+ $columns = array();
+ foreach ($this->getColumnNames($table, $schema) as $columnName) {
+ $columns[] = $this->getColumn($columnName, $table, $schema);
+ }
+ return $columns;
+ }
+
+ /**
+ * Get column
+ *
+ * @param string $columnName
+ * @param string $table
+ * @param string $schema
+ * @return Object\ColumnObject
+ */
+ public function getColumn($columnName, $table, $schema = null)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $this->loadColumnData($table, $schema);
+
+ if (!isset($this->data['columns'][$schema][$table][$columnName])) {
+ throw new \Exception('A column by that name was not found.');
+ }
+
+ $info = $this->data['columns'][$schema][$table][$columnName];
+
+ $column = new Object\ColumnObject($columnName, $table, $schema);
+ $props = array(
+ 'ordinal_position', 'column_default', 'is_nullable',
+ 'data_type', 'character_maximum_length', 'character_octet_length',
+ 'numeric_precision', 'numeric_scale', 'numeric_unsigned',
+ 'erratas'
+ );
+ foreach ($props as $prop) {
+ if (isset($info[$prop])) {
+ $column->{'set' . str_replace('_', '', $prop)}($info[$prop]);
+ }
+ }
+
+ $column->setOrdinalPosition($info['ordinal_position']);
+ $column->setColumnDefault($info['column_default']);
+ $column->setIsNullable($info['is_nullable']);
+ $column->setDataType($info['data_type']);
+ $column->setCharacterMaximumLength($info['character_maximum_length']);
+ $column->setCharacterOctetLength($info['character_octet_length']);
+ $column->setNumericPrecision($info['numeric_precision']);
+ $column->setNumericScale($info['numeric_scale']);
+ $column->setNumericUnsigned($info['numeric_unsigned']);
+ $column->setErratas($info['erratas']);
+
+ return $column;
+ }
+
+ /**
+ * Get constraints
+ *
+ * @param string $table
+ * @param string $schema
+ * @return array
+ */
+ public function getConstraints($table, $schema = null)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $this->loadConstraintData($table, $schema);
+
+ $constraints = array();
+ foreach (array_keys($this->data['constraints'][$schema][$table]) as $constraintName) {
+ $constraints[] = $this->getConstraint($constraintName, $table, $schema);
+ }
+
+ return $constraints;
+ }
+
+ /**
+ * Get constraint
+ *
+ * @param string $constraintName
+ * @param string $table
+ * @param string $schema
+ * @return Object\ConstraintObject
+ */
+ public function getConstraint($constraintName, $table, $schema = null)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $this->loadConstraintData($table, $schema);
+
+ if (!isset($this->data['constraints'][$schema][$table][$constraintName])) {
+ throw new \Exception('Cannot find a constraint by that name in this table');
+ }
+
+ $info = $this->data['constraints'][$schema][$table][$constraintName];
+ $constraint = new Object\ConstraintObject($constraintName, $table, $schema);
+
+ foreach (array(
+ 'constraint_type' => 'setType',
+ 'match_option' => 'setMatchOption',
+ 'update_rule' => 'setUpdateRule',
+ 'delete_rule' => 'setDeleteRule',
+ 'columns' => 'setColumns',
+ 'referenced_table_schema' => 'setReferencedTableSchema',
+ 'referenced_table_name' => 'setReferencedTableName',
+ 'referenced_columns' => 'setReferencedColumns',
+ 'check_clause' => 'setCheckClause',
+ ) as $key => $setMethod) {
+ if (isset($info[$key])) {
+ $constraint->{$setMethod}($info[$key]);
+ }
+ }
+
+ return $constraint;
+ }
+
+ /**
+ * Get constraint keys
+ *
+ * @param string $constraint
+ * @param string $table
+ * @param string $schema
+ * @return array
+ */
+ public function getConstraintKeys($constraint, $table, $schema = null)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $this->loadConstraintReferences($table, $schema);
+
+ // organize references first
+ $references = array();
+ foreach ($this->data['constraint_references'][$schema] as $refKeyInfo) {
+ if ($refKeyInfo['constraint_name'] == $constraint) {
+ $references[$refKeyInfo['constraint_name']] = $refKeyInfo;
+ }
+ }
+
+ $this->loadConstraintDataKeys($schema);
+
+ $keys = array();
+ foreach ($this->data['constraint_keys'][$schema] as $constraintKeyInfo) {
+ if ($constraintKeyInfo['table_name'] == $table && $constraintKeyInfo['constraint_name'] === $constraint) {
+ $keys[] = $key = new Object\ConstraintKeyObject($constraintKeyInfo['column_name']);
+ $key->setOrdinalPosition($constraintKeyInfo['ordinal_position']);
+ if (isset($references[$constraint])) {
+ //$key->setReferencedTableSchema($constraintKeyInfo['referenced_table_schema']);
+ $key->setForeignKeyUpdateRule($references[$constraint]['update_rule']);
+ $key->setForeignKeyDeleteRule($references[$constraint]['delete_rule']);
+ //$key->setReferencedTableSchema($references[$constraint]['referenced_table_schema']);
+ $key->setReferencedTableName($references[$constraint]['referenced_table_name']);
+ $key->setReferencedColumnName($references[$constraint]['referenced_column_name']);
+ }
+ }
+ }
+
+ return $keys;
+ }
+
+ /**
+ * Get trigger names
+ *
+ * @param string $schema
+ * @return array
+ */
+ public function getTriggerNames($schema = null)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $this->loadTriggerData($schema);
+
+ return array_keys($this->data['triggers'][$schema]);
+ }
+
+ /**
+ * Get triggers
+ *
+ * @param string $schema
+ * @return array
+ */
+ public function getTriggers($schema = null)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $triggers = array();
+ foreach ($this->getTriggerNames($schema) as $triggerName) {
+ $triggers[] = $this->getTrigger($triggerName, $schema);
+ }
+ return $triggers;
+ }
+
+ /**
+ * Get trigger
+ *
+ * @param string $triggerName
+ * @param string $schema
+ * @return Object\TriggerObject
+ */
+ public function getTrigger($triggerName, $schema = null)
+ {
+ if ($schema === null) {
+ $schema = $this->defaultSchema;
+ }
+
+ $this->loadTriggerData($schema);
+
+ if (!isset($this->data['triggers'][$schema][$triggerName])) {
+ throw new \Exception('Trigger "' . $triggerName . '" does not exist');
+ }
+
+ $info = $this->data['triggers'][$schema][$triggerName];
+
+ $trigger = new Object\TriggerObject();
+
+ $trigger->setName($triggerName);
+ $trigger->setEventManipulation($info['event_manipulation']);
+ $trigger->setEventObjectCatalog($info['event_object_catalog']);
+ $trigger->setEventObjectSchema($info['event_object_schema']);
+ $trigger->setEventObjectTable($info['event_object_table']);
+ $trigger->setActionOrder($info['action_order']);
+ $trigger->setActionCondition($info['action_condition']);
+ $trigger->setActionStatement($info['action_statement']);
+ $trigger->setActionOrientation($info['action_orientation']);
+ $trigger->setActionTiming($info['action_timing']);
+ $trigger->setActionReferenceOldTable($info['action_reference_old_table']);
+ $trigger->setActionReferenceNewTable($info['action_reference_new_table']);
+ $trigger->setActionReferenceOldRow($info['action_reference_old_row']);
+ $trigger->setActionReferenceNewRow($info['action_reference_new_row']);
+ $trigger->setCreated($info['created']);
+
+ return $trigger;
+ }
+
+ /**
+ * Prepare data hierarchy
+ *
+ * @param string $type
+ * @param string $key ...
+ */
+ protected function prepareDataHierarchy($type)
+ {
+ $data = &$this->data;
+ foreach (func_get_args() as $key) {
+ if (!isset($data[$key])) {
+ $data[$key] = array();
+ }
+ $data = &$data[$key];
+ }
+ }
+
+ /**
+ * Load schema data
+ */
+ protected function loadSchemaData()
+ {
+ }
+
+ /**
+ * Load table name data
+ *
+ * @param string $schema
+ */
+ protected function loadTableNameData($schema)
+ {
+ if (isset($this->data['table_names'][$schema])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('table_names', $schema);
+ }
+
+ /**
+ * Load column data
+ *
+ * @param string $table
+ * @param string $schema
+ */
+ protected function loadColumnData($table, $schema)
+ {
+ if (isset($this->data['columns'][$schema][$table])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('columns', $schema, $table);
+ }
+
+ /**
+ * Load constraint data
+ *
+ * @param string $table
+ * @param string $schema
+ */
+ protected function loadConstraintData($table, $schema)
+ {
+ if (isset($this->data['constraints'][$schema])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('constraints', $schema);
+ }
+
+ /**
+ * Load constraint data keys
+ *
+ * @param string $schema
+ */
+ protected function loadConstraintDataKeys($schema)
+ {
+ if (isset($this->data['constraint_keys'][$schema])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('constraint_keys', $schema);
+ }
+
+ /**
+ * Load constraint references
+ *
+ * @param string $table
+ * @param string $schema
+ */
+ protected function loadConstraintReferences($table, $schema)
+ {
+ if (isset($this->data['constraint_references'][$schema])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('constraint_references', $schema);
+ }
+
+ /**
+ * Load trigger data
+ *
+ * @param string $schema
+ */
+ protected function loadTriggerData($schema)
+ {
+ if (isset($this->data['triggers'][$schema])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('triggers', $schema);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Metadata/Source/MysqlMetadata.php zendframework-2.2.6/library/Zend/Db/Metadata/Source/MysqlMetadata.php
--- zendframework-1.10.4/library/Zend/Db/Metadata/Source/MysqlMetadata.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Metadata/Source/MysqlMetadata.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,493 @@
+data['schemas'])) {
+ return;
+ }
+ $this->prepareDataHierarchy('schemas');
+
+ $p = $this->adapter->getPlatform();
+
+ $sql = 'SELECT ' . $p->quoteIdentifier('SCHEMA_NAME')
+ . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'SCHEMATA'))
+ . ' WHERE ' . $p->quoteIdentifier('SCHEMA_NAME')
+ . ' != \'INFORMATION_SCHEMA\'';
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $schemas = array();
+ foreach ($results->toArray() as $row) {
+ $schemas[] = $row['SCHEMA_NAME'];
+ }
+
+ $this->data['schemas'] = $schemas;
+ }
+
+ protected function loadTableNameData($schema)
+ {
+ if (isset($this->data['table_names'][$schema])) {
+ return;
+ }
+ $this->prepareDataHierarchy('table_names', $schema);
+
+ $p = $this->adapter->getPlatform();
+
+ $isColumns = array(
+ array('T', 'TABLE_NAME'),
+ array('T', 'TABLE_TYPE'),
+ array('V', 'VIEW_DEFINITION'),
+ array('V', 'CHECK_OPTION'),
+ array('V', 'IS_UPDATABLE'),
+ );
+
+ array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifierChain($c); });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T'
+
+ . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'VIEWS')) . ' V'
+ . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('V', 'TABLE_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('V', 'TABLE_NAME'))
+
+ . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE'))
+ . ' IN (\'BASE TABLE\', \'VIEW\')';
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' != \'INFORMATION_SCHEMA\'';
+ }
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $tables = array();
+ foreach ($results->toArray() as $row) {
+ $tables[$row['TABLE_NAME']] = array(
+ 'table_type' => $row['TABLE_TYPE'],
+ 'view_definition' => $row['VIEW_DEFINITION'],
+ 'check_option' => $row['CHECK_OPTION'],
+ 'is_updatable' => ('YES' == $row['IS_UPDATABLE']),
+ );
+ }
+
+ $this->data['table_names'][$schema] = $tables;
+ }
+
+ protected function loadColumnData($table, $schema)
+ {
+ if (isset($this->data['columns'][$schema][$table])) {
+ return;
+ }
+ $this->prepareDataHierarchy('columns', $schema, $table);
+ $p = $this->adapter->getPlatform();
+
+ $isColumns = array(
+ array('C', 'ORDINAL_POSITION'),
+ array('C', 'COLUMN_DEFAULT'),
+ array('C', 'IS_NULLABLE'),
+ array('C', 'DATA_TYPE'),
+ array('C', 'CHARACTER_MAXIMUM_LENGTH'),
+ array('C', 'CHARACTER_OCTET_LENGTH'),
+ array('C', 'NUMERIC_PRECISION'),
+ array('C', 'NUMERIC_SCALE'),
+ array('C', 'COLUMN_NAME'),
+ array('C', 'COLUMN_TYPE'),
+ );
+
+ array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifierChain($c); });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T'
+ . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'COLUMNS')) . 'C'
+ . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('C', 'TABLE_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('C', 'TABLE_NAME'))
+ . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE'))
+ . ' IN (\'BASE TABLE\', \'VIEW\')'
+ . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME'))
+ . ' = ' . $p->quoteTrustedValue($table);
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' != \'INFORMATION_SCHEMA\'';
+ }
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+ $columns = array();
+ foreach ($results->toArray() as $row) {
+ $erratas = array();
+ $matches = array();
+ if (preg_match('/^(?:enum|set)\((.+)\)$/i', $row['COLUMN_TYPE'], $matches)) {
+ $permittedValues = $matches[1];
+ if (preg_match_all("/\\s*'((?:[^']++|'')*+)'\\s*(?:,|\$)/", $permittedValues, $matches, PREG_PATTERN_ORDER)) {
+ $permittedValues = str_replace("''", "'", $matches[1]);
+ } else {
+ $permittedValues = array($permittedValues);
+ }
+ $erratas['permitted_values'] = $permittedValues;
+ }
+ $columns[$row['COLUMN_NAME']] = array(
+ 'ordinal_position' => $row['ORDINAL_POSITION'],
+ 'column_default' => $row['COLUMN_DEFAULT'],
+ 'is_nullable' => ('YES' == $row['IS_NULLABLE']),
+ 'data_type' => $row['DATA_TYPE'],
+ 'character_maximum_length' => $row['CHARACTER_MAXIMUM_LENGTH'],
+ 'character_octet_length' => $row['CHARACTER_OCTET_LENGTH'],
+ 'numeric_precision' => $row['NUMERIC_PRECISION'],
+ 'numeric_scale' => $row['NUMERIC_SCALE'],
+ 'numeric_unsigned' => (false !== strpos($row['COLUMN_TYPE'], 'unsigned')),
+ 'erratas' => $erratas,
+ );
+ }
+
+ $this->data['columns'][$schema][$table] = $columns;
+ }
+
+ protected function loadConstraintData($table, $schema)
+ {
+ if (isset($this->data['constraints'][$schema][$table])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('constraints', $schema, $table);
+
+ $isColumns = array(
+ array('T', 'TABLE_NAME'),
+ array('TC', 'CONSTRAINT_NAME'),
+ array('TC', 'CONSTRAINT_TYPE'),
+ array('KCU', 'COLUMN_NAME'),
+ array('RC', 'MATCH_OPTION'),
+ array('RC', 'UPDATE_RULE'),
+ array('RC', 'DELETE_RULE'),
+ array('KCU', 'REFERENCED_TABLE_SCHEMA'),
+ array('KCU', 'REFERENCED_TABLE_NAME'),
+ array('KCU', 'REFERENCED_COLUMN_NAME'),
+ );
+
+ $p = $this->adapter->getPlatform();
+
+ array_walk($isColumns, function (&$c) use ($p) {
+ $c = $p->quoteIdentifierChain($c);
+ });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . ' T'
+
+ . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLE_CONSTRAINTS')) . ' TC'
+ . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('TC', 'TABLE_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('TC', 'TABLE_NAME'))
+
+ . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE')) . ' KCU'
+ . ' ON ' . $p->quoteIdentifierChain(array('TC', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('TC', 'TABLE_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_NAME'))
+ . ' AND ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU', 'CONSTRAINT_NAME'))
+
+ . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'REFERENTIAL_CONSTRAINTS')) . ' RC'
+ . ' ON ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_NAME'))
+
+ . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME'))
+ . ' = ' . $p->quoteTrustedValue($table)
+ . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE'))
+ . ' IN (\'BASE TABLE\', \'VIEW\')';
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' != \'INFORMATION_SCHEMA\'';
+ }
+
+ $sql .= ' ORDER BY CASE ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_TYPE'))
+ . " WHEN 'PRIMARY KEY' THEN 1"
+ . " WHEN 'UNIQUE' THEN 2"
+ . " WHEN 'FOREIGN KEY' THEN 3"
+ . " ELSE 4 END"
+
+ . ', ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME'))
+ . ', ' . $p->quoteIdentifierChain(array('KCU', 'ORDINAL_POSITION'));
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $realName = null;
+ $constraints = array();
+ foreach ($results->toArray() as $row) {
+ if ($row['CONSTRAINT_NAME'] !== $realName) {
+ $realName = $row['CONSTRAINT_NAME'];
+ $isFK = ('FOREIGN KEY' == $row['CONSTRAINT_TYPE']);
+ if ($isFK) {
+ $name = $realName;
+ } else {
+ $name = '_zf_' . $row['TABLE_NAME'] . '_' . $realName;
+ }
+ $constraints[$name] = array(
+ 'constraint_name' => $name,
+ 'constraint_type' => $row['CONSTRAINT_TYPE'],
+ 'table_name' => $row['TABLE_NAME'],
+ 'columns' => array(),
+ );
+ if ($isFK) {
+ $constraints[$name]['referenced_table_schema'] = $row['REFERENCED_TABLE_SCHEMA'];
+ $constraints[$name]['referenced_table_name'] = $row['REFERENCED_TABLE_NAME'];
+ $constraints[$name]['referenced_columns'] = array();
+ $constraints[$name]['match_option'] = $row['MATCH_OPTION'];
+ $constraints[$name]['update_rule'] = $row['UPDATE_RULE'];
+ $constraints[$name]['delete_rule'] = $row['DELETE_RULE'];
+ }
+ }
+ $constraints[$name]['columns'][] = $row['COLUMN_NAME'];
+ if ($isFK) {
+ $constraints[$name]['referenced_columns'][] = $row['REFERENCED_COLUMN_NAME'];
+ }
+ }
+
+ $this->data['constraints'][$schema][$table] = $constraints;
+ }
+
+ protected function loadConstraintDataNames($schema)
+ {
+ if (isset($this->data['constraint_names'][$schema])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('constraint_names', $schema);
+
+ $p = $this->adapter->getPlatform();
+
+ $isColumns = array(
+ array('TC', 'TABLE_NAME'),
+ array('TC', 'CONSTRAINT_NAME'),
+ array('TC', 'CONSTRAINT_TYPE'),
+ );
+
+ array_walk($isColumns, function (&$c) use ($p) {
+ $c = $p->quoteIdentifierChain($c);
+ });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T'
+ . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLE_CONSTRAINTS')) . 'TC'
+ . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('TC', 'TABLE_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('TC', 'TABLE_NAME'))
+ . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE'))
+ . ' IN (\'BASE TABLE\', \'VIEW\')';
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' != \'INFORMATION_SCHEMA\'';
+ }
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $data = array();
+ foreach ($results->toArray() as $row) {
+ $data[] = array_change_key_case($row, CASE_LOWER);
+ }
+
+ $this->data['constraint_names'][$schema] = $data;
+ }
+
+ protected function loadConstraintDataKeys($schema)
+ {
+ if (isset($this->data['constraint_keys'][$schema])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('constraint_keys', $schema);
+
+ $p = $this->adapter->getPlatform();
+
+ $isColumns = array(
+ array('T', 'TABLE_NAME'),
+ array('KCU', 'CONSTRAINT_NAME'),
+ array('KCU', 'COLUMN_NAME'),
+ array('KCU', 'ORDINAL_POSITION'),
+ );
+
+ array_walk($isColumns, function (&$c) use ($p) {
+ $c = $p->quoteIdentifierChain($c);
+ });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T'
+
+ . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE')) . 'KCU'
+ . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_NAME'))
+
+ . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE'))
+ . ' IN (\'BASE TABLE\', \'VIEW\')';
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' != \'INFORMATION_SCHEMA\'';
+ }
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $data = array();
+ foreach ($results->toArray() as $row) {
+ $data[] = array_change_key_case($row, CASE_LOWER);
+ }
+
+ $this->data['constraint_keys'][$schema] = $data;
+ }
+
+ protected function loadConstraintReferences($table, $schema)
+ {
+ parent::loadConstraintReferences($table, $schema);
+
+ $p = $this->adapter->getPlatform();
+
+ $isColumns = array(
+ array('RC', 'TABLE_NAME'),
+ array('RC', 'CONSTRAINT_NAME'),
+ array('RC', 'UPDATE_RULE'),
+ array('RC', 'DELETE_RULE'),
+ array('KCU', 'REFERENCED_TABLE_SCHEMA'),
+ array('KCU', 'REFERENCED_TABLE_NAME'),
+ array('KCU', 'REFERENCED_COLUMN_NAME'),
+ );
+
+ array_walk($isColumns, function (&$c) use ($p) {
+ $c = $p->quoteIdentifierChain($c);
+ });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . 'FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T'
+
+ . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'REFERENTIAL_CONSTRAINTS')) . 'RC'
+ . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('RC', 'TABLE_NAME'))
+
+ . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE')) . 'KCU'
+ . ' ON ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('RC', 'TABLE_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_NAME'))
+ . ' AND ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU', 'CONSTRAINT_NAME'))
+
+ . 'WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE'))
+ . ' IN (\'BASE TABLE\', \'VIEW\')';
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' != \'INFORMATION_SCHEMA\'';
+ }
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $data = array();
+ foreach ($results->toArray() as $row) {
+ $data[] = array_change_key_case($row, CASE_LOWER);
+ }
+
+ $this->data['constraint_references'][$schema] = $data;
+ }
+
+ protected function loadTriggerData($schema)
+ {
+ if (isset($this->data['triggers'][$schema])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('triggers', $schema);
+
+ $p = $this->adapter->getPlatform();
+
+ $isColumns = array(
+// 'TRIGGER_CATALOG',
+// 'TRIGGER_SCHEMA',
+ 'TRIGGER_NAME',
+ 'EVENT_MANIPULATION',
+ 'EVENT_OBJECT_CATALOG',
+ 'EVENT_OBJECT_SCHEMA',
+ 'EVENT_OBJECT_TABLE',
+ 'ACTION_ORDER',
+ 'ACTION_CONDITION',
+ 'ACTION_STATEMENT',
+ 'ACTION_ORIENTATION',
+ 'ACTION_TIMING',
+ 'ACTION_REFERENCE_OLD_TABLE',
+ 'ACTION_REFERENCE_NEW_TABLE',
+ 'ACTION_REFERENCE_OLD_ROW',
+ 'ACTION_REFERENCE_NEW_ROW',
+ 'CREATED',
+ );
+
+ array_walk($isColumns, function (&$c) use ($p) {
+ $c = $p->quoteIdentifier($c);
+ });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TRIGGERS'))
+ . ' WHERE ';
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= $p->quoteIdentifier('TRIGGER_SCHEMA')
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= $p->quoteIdentifier('TRIGGER_SCHEMA')
+ . ' != \'INFORMATION_SCHEMA\'';
+ }
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $data = array();
+ foreach ($results->toArray() as $row) {
+ $row = array_change_key_case($row, CASE_LOWER);
+ if (null !== $row['created']) {
+ $row['created'] = new \DateTime($row['created']);
+ }
+ $data[$row['trigger_name']] = $row;
+ }
+
+ $this->data['triggers'][$schema] = $data;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Metadata/Source/PostgresqlMetadata.php zendframework-2.2.6/library/Zend/Db/Metadata/Source/PostgresqlMetadata.php
--- zendframework-1.10.4/library/Zend/Db/Metadata/Source/PostgresqlMetadata.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Metadata/Source/PostgresqlMetadata.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,348 @@
+data['schemas'])) {
+ return;
+ }
+ $this->prepareDataHierarchy('schemas');
+
+ $p = $this->adapter->getPlatform();
+
+ $sql = 'SELECT ' . $p->quoteIdentifier('schema_name')
+ . ' FROM ' . $p->quoteIdentifierChain(array('information_schema', 'schemata'))
+ . ' WHERE ' . $p->quoteIdentifier('schema_name')
+ . ' != \'information_schema\''
+ . ' AND ' . $p->quoteIdentifier('schema_name') . " NOT LIKE 'pg_%'";
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $schemas = array();
+ foreach ($results->toArray() as $row) {
+ $schemas[] = $row['schema_name'];
+ }
+
+ $this->data['schemas'] = $schemas;
+ }
+
+ protected function loadTableNameData($schema)
+ {
+ if (isset($this->data['table_names'][$schema])) {
+ return;
+ }
+ $this->prepareDataHierarchy('table_names', $schema);
+
+ $p = $this->adapter->getPlatform();
+
+ $isColumns = array(
+ array('t', 'table_name'),
+ array('t', 'table_type'),
+ array('v', 'view_definition'),
+ array('v', 'check_option'),
+ array('v', 'is_updatable'),
+ );
+
+ array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifierChain($c); });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $p->quoteIdentifierChain(array('information_schema', 'tables')) . ' t'
+
+ . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('information_schema', 'views')) . ' v'
+ . ' ON ' . $p->quoteIdentifierChain(array('t', 'table_schema'))
+ . ' = ' . $p->quoteIdentifierChain(array('v', 'table_schema'))
+ . ' AND ' . $p->quoteIdentifierChain(array('t', 'table_name'))
+ . ' = ' . $p->quoteIdentifierChain(array('v', 'table_name'))
+
+ . ' WHERE ' . $p->quoteIdentifierChain(array('t', 'table_type'))
+ . ' IN (\'BASE TABLE\', \'VIEW\')';
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('t', 'table_schema'))
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('t', 'table_schema'))
+ . ' != \'information_schema\'';
+ }
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $tables = array();
+ foreach ($results->toArray() as $row) {
+ $tables[$row['table_name']] = array(
+ 'table_type' => $row['table_type'],
+ 'view_definition' => $row['view_definition'],
+ 'check_option' => $row['check_option'],
+ 'is_updatable' => ('YES' == $row['is_updatable']),
+ );
+ }
+
+ $this->data['table_names'][$schema] = $tables;
+ }
+
+ protected function loadColumnData($table, $schema)
+ {
+ if (isset($this->data['columns'][$schema][$table])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('columns', $schema, $table);
+
+ $platform = $this->adapter->getPlatform();
+
+ $isColumns = array(
+ 'table_name',
+ 'column_name',
+ 'ordinal_position',
+ 'column_default',
+ 'is_nullable',
+ 'data_type',
+ 'character_maximum_length',
+ 'character_octet_length',
+ 'numeric_precision',
+ 'numeric_scale',
+ );
+
+ array_walk($isColumns, function (&$c) use ($platform) { $c = $platform->quoteIdentifier($c); });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $platform->quoteIdentifier('information_schema')
+ . $platform->getIdentifierSeparator() . $platform->quoteIdentifier('columns')
+ . ' WHERE ' . $platform->quoteIdentifier('table_schema')
+ . ' != \'information\''
+ . ' AND ' . $platform->quoteIdentifier('table_name')
+ . ' = ' . $platform->quoteTrustedValue($table);
+
+ if ($schema != '__DEFAULT_SCHEMA__') {
+ $sql .= ' AND ' . $platform->quoteIdentifier('table_schema')
+ . ' = ' . $platform->quoteTrustedValue($schema);
+ }
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+ $columns = array();
+ foreach ($results->toArray() as $row) {
+ $columns[$row['column_name']] = array(
+ 'ordinal_position' => $row['ordinal_position'],
+ 'column_default' => $row['column_default'],
+ 'is_nullable' => ('YES' == $row['is_nullable']),
+ 'data_type' => $row['data_type'],
+ 'character_maximum_length' => $row['character_maximum_length'],
+ 'character_octet_length' => $row['character_octet_length'],
+ 'numeric_precision' => $row['numeric_precision'],
+ 'numeric_scale' => $row['numeric_scale'],
+ 'numeric_unsigned' => null,
+ 'erratas' => array(),
+ );
+ }
+
+ $this->data['columns'][$schema][$table] = $columns;
+ }
+
+ protected function loadConstraintData($table, $schema)
+ {
+ if (isset($this->data['constraints'][$schema][$table])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('constraints', $schema, $table);
+
+ $isColumns = array(
+ array('t', 'table_name'),
+ array('tc', 'constraint_name'),
+ array('tc', 'constraint_type'),
+ array('kcu', 'column_name'),
+ array('cc', 'check_clause'),
+ array('rc', 'match_option'),
+ array('rc', 'update_rule'),
+ array('rc', 'delete_rule'),
+ array('referenced_table_schema' => 'kcu2', 'table_schema'),
+ array('referenced_table_name' => 'kcu2', 'table_name'),
+ array('referenced_column_name' => 'kcu2', 'column_name'),
+ );
+
+ $p = $this->adapter->getPlatform();
+
+ array_walk($isColumns, function (&$c) use ($p) {
+ $alias = key($c);
+ $c = $p->quoteIdentifierChain($c);
+ if (is_string($alias)) {
+ $c .= ' ' . $p->quoteIdentifier($alias);
+ }
+ });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $p->quoteIdentifierChain(array('information_schema', 'tables')) . ' t'
+
+ . ' INNER JOIN ' . $p->quoteIdentifierChain(array('information_schema', 'table_constraints')) . ' tc'
+ . ' ON ' . $p->quoteIdentifierChain(array('t', 'table_schema'))
+ . ' = ' . $p->quoteIdentifierChain(array('tc', 'table_schema'))
+ . ' AND ' . $p->quoteIdentifierChain(array('t', 'table_name'))
+ . ' = ' . $p->quoteIdentifierChain(array('tc', 'table_name'))
+
+ . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('information_schema', 'key_column_usage')) . ' kcu'
+ . ' ON ' . $p->quoteIdentifierChain(array('tc', 'table_schema'))
+ . ' = ' . $p->quoteIdentifierChain(array('kcu', 'table_schema'))
+ . ' AND ' . $p->quoteIdentifierChain(array('tc', 'table_name'))
+ . ' = ' . $p->quoteIdentifierChain(array('kcu', 'table_name'))
+ . ' AND ' . $p->quoteIdentifierChain(array('tc', 'constraint_name'))
+ . ' = ' . $p->quoteIdentifierChain(array('kcu', 'constraint_name'))
+
+ . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('information_schema', 'check_constraints')) . ' cc'
+ . ' ON ' . $p->quoteIdentifierChain(array('tc', 'constraint_schema'))
+ . ' = ' . $p->quoteIdentifierChain(array('cc', 'constraint_schema'))
+ . ' AND ' . $p->quoteIdentifierChain(array('tc', 'constraint_name'))
+ . ' = ' . $p->quoteIdentifierChain(array('cc', 'constraint_name'))
+
+ . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('information_schema', 'referential_constraints')) . ' rc'
+ . ' ON ' . $p->quoteIdentifierChain(array('tc', 'constraint_schema'))
+ . ' = ' . $p->quoteIdentifierChain(array('rc', 'constraint_schema'))
+ . ' AND ' . $p->quoteIdentifierChain(array('tc', 'constraint_name'))
+ . ' = ' . $p->quoteIdentifierChain(array('rc', 'constraint_name'))
+
+ . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('information_schema', 'key_column_usage')) . ' kcu2'
+ . ' ON ' . $p->quoteIdentifierChain(array('rc', 'unique_constraint_schema'))
+ . ' = ' . $p->quoteIdentifierChain(array('kcu2', 'constraint_schema'))
+ . ' AND ' . $p->quoteIdentifierChain(array('rc', 'unique_constraint_name'))
+ . ' = ' . $p->quoteIdentifierChain(array('kcu2', 'constraint_name'))
+ . ' AND ' . $p->quoteIdentifierChain(array('kcu', 'position_in_unique_constraint'))
+ . ' = ' . $p->quoteIdentifierChain(array('kcu2', 'ordinal_position'))
+
+ . ' WHERE ' . $p->quoteIdentifierChain(array('t', 'table_name'))
+ . ' = ' . $p->quoteTrustedValue($table)
+ . ' AND ' . $p->quoteIdentifierChain(array('t', 'table_type'))
+ . ' IN (\'BASE TABLE\', \'VIEW\')';
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('t', 'table_schema'))
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('t', 'table_schema'))
+ . ' != \'information_schema\'';
+ }
+
+ $sql .= ' ORDER BY CASE ' . $p->quoteIdentifierChain(array('tc', 'constraint_type'))
+ . " WHEN 'PRIMARY KEY' THEN 1"
+ . " WHEN 'UNIQUE' THEN 2"
+ . " WHEN 'FOREIGN KEY' THEN 3"
+ . " WHEN 'CHECK' THEN 4"
+ . " ELSE 5 END"
+ . ', ' . $p->quoteIdentifierChain(array('tc', 'constraint_name'))
+ . ', ' . $p->quoteIdentifierChain(array('kcu', 'ordinal_position'));
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $name = null;
+ $constraints = array();
+ foreach ($results->toArray() as $row) {
+ if ($row['constraint_name'] !== $name) {
+ $name = $row['constraint_name'];
+ $constraints[$name] = array(
+ 'constraint_name' => $name,
+ 'constraint_type' => $row['constraint_type'],
+ 'table_name' => $row['table_name'],
+ );
+ if ('CHECK' == $row['constraint_type']) {
+ $constraints[$name]['check_clause'] = $row['check_clause'];
+ continue;
+ }
+ $constraints[$name]['columns'] = array();
+ $isFK = ('FOREIGN KEY' == $row['constraint_type']);
+ if ($isFK) {
+ $constraints[$name]['referenced_table_schema'] = $row['referenced_table_schema'];
+ $constraints[$name]['referenced_table_name'] = $row['referenced_table_name'];
+ $constraints[$name]['referenced_columns'] = array();
+ $constraints[$name]['match_option'] = $row['match_option'];
+ $constraints[$name]['update_rule'] = $row['update_rule'];
+ $constraints[$name]['delete_rule'] = $row['delete_rule'];
+ }
+ }
+ $constraints[$name]['columns'][] = $row['column_name'];
+ if ($isFK) {
+ $constraints[$name]['referenced_columns'][] = $row['referenced_column_name'];
+ }
+ }
+
+ $this->data['constraints'][$schema][$table] = $constraints;
+ }
+
+ protected function loadTriggerData($schema)
+ {
+ if (isset($this->data['triggers'][$schema])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('triggers', $schema);
+
+ $p = $this->adapter->getPlatform();
+
+ $isColumns = array(
+ 'trigger_name',
+ 'event_manipulation',
+ 'event_object_catalog',
+ 'event_object_schema',
+ 'event_object_table',
+ 'action_order',
+ 'action_condition',
+ 'action_statement',
+ 'action_orientation',
+ array('action_timing' => 'condition_timing'),
+ array('action_reference_old_table' => 'condition_reference_old_table'),
+ array('action_reference_new_table' => 'condition_reference_new_table'),
+ 'created',
+ );
+
+ array_walk($isColumns, function (&$c) use ($p) {
+ if (is_array($c)) {
+ $alias = key($c);
+ $c = $p->quoteIdentifierChain($c);
+ if (is_string($alias)) {
+ $c .= ' ' . $p->quoteIdentifier($alias);
+ }
+ } else {
+ $c = $p->quoteIdentifier($c);
+ }
+ });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $p->quoteIdentifierChain(array('information_schema', 'triggers'))
+ . ' WHERE ';
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= $p->quoteIdentifier('trigger_schema')
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= $p->quoteIdentifier('trigger_schema')
+ . ' != \'information_schema\'';
+ }
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $data = array();
+ foreach ($results->toArray() as $row) {
+ $row = array_change_key_case($row, CASE_LOWER);
+ $row['action_reference_old_row'] = 'OLD';
+ $row['action_reference_new_row'] = 'NEW';
+ if (null !== $row['created']) {
+ $row['created'] = new \DateTime($row['created']);
+ }
+ $data[$row['trigger_name']] = $row;
+ }
+
+ $this->data['triggers'][$schema] = $data;
+ }
+
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Metadata/Source/SqliteMetadata.php zendframework-2.2.6/library/Zend/Db/Metadata/Source/SqliteMetadata.php
--- zendframework-1.10.4/library/Zend/Db/Metadata/Source/SqliteMetadata.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Metadata/Source/SqliteMetadata.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,392 @@
+data['schemas'])) {
+ return;
+ }
+ $this->prepareDataHierarchy('schemas');
+
+ $results = $this->fetchPragma('database_list');
+ foreach ($results as $row) {
+ $schemas[] = $row['name'];
+ }
+ $this->data['schemas'] = $schemas;
+ }
+
+ protected function loadTableNameData($schema)
+ {
+ if (isset($this->data['table_names'][$schema])) {
+ return;
+ }
+ $this->prepareDataHierarchy('table_names', $schema);
+
+ // FEATURE: Filename?
+
+ $p = $this->adapter->getPlatform();
+
+ $sql = 'SELECT "name", "type", "sql" FROM ' . $p->quoteIdentifierChain(array($schema, 'sqlite_master'))
+ . ' WHERE "type" IN (\'table\',\'view\') AND "name" NOT LIKE \'sqlite_%\'';
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+ $tables = array();
+ foreach ($results->toArray() as $row) {
+ if ('table' == $row['type']) {
+ $table = array(
+ 'table_type' => 'BASE TABLE',
+ 'view_definition' => null, // VIEW only
+ 'check_option' => null, // VIEW only
+ 'is_updatable' => null, // VIEW only
+ );
+ } else {
+ $table = array(
+ 'table_type' => 'VIEW',
+ 'view_definition' => null,
+ 'check_option' => 'NONE',
+ 'is_updatable' => false,
+ );
+
+ // Parse out extra data
+ if (null !== ($data = $this->parseView($row['sql']))) {
+ $table = array_merge($table, $data);
+ }
+ }
+ $tables[$row['name']] = $table;
+ }
+ $this->data['table_names'][$schema] = $tables;
+ }
+
+ protected function loadColumnData($table, $schema)
+ {
+ if (isset($this->data['columns'][$schema][$table])) {
+ return;
+ }
+ $this->prepareDataHierarchy('columns', $schema, $table);
+ $this->prepareDataHierarchy('sqlite_columns', $schema, $table);
+
+ $p = $this->adapter->getPlatform();
+
+
+ $results = $this->fetchPragma('table_info', $table, $schema);
+
+ $columns = array();
+
+ foreach ($results as $row) {
+ $columns[$row['name']] = array(
+ // cid appears to be zero-based, ordinal position needs to be one-based
+ 'ordinal_position' => $row['cid'] + 1,
+ 'column_default' => $row['dflt_value'],
+ 'is_nullable' => !((bool) $row['notnull']),
+ 'data_type' => $row['type'],
+ 'character_maximum_length' => null,
+ 'character_octet_length' => null,
+ 'numeric_precision' => null,
+ 'numeric_scale' => null,
+ 'numeric_unsigned' => null,
+ 'erratas' => array(),
+ );
+ // TODO: populate character_ and numeric_values with correct info
+ }
+
+ $this->data['columns'][$schema][$table] = $columns;
+ $this->data['sqlite_columns'][$schema][$table] = $results;
+ }
+
+ protected function loadConstraintData($table, $schema)
+ {
+ if (isset($this->data['constraints'][$schema][$table])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('constraints', $schema, $table);
+
+ $this->loadColumnData($table, $schema);
+ $primaryKey = array();
+
+ foreach ($this->data['sqlite_columns'][$schema][$table] as $col) {
+ if ((bool) $col['pk']) {
+ $primaryKey[] = $col['name'];
+ }
+ }
+
+ if (empty($primaryKey)) {
+ $primaryKey = null;
+ }
+ $constraints = array();
+ $indexes = $this->fetchPragma('index_list', $table, $schema);
+ foreach ($indexes as $index) {
+ if (!((bool) $index['unique'])) {
+ continue;
+ }
+ $constraint = array(
+ 'constraint_name' => $index['name'],
+ 'constraint_type' => 'UNIQUE',
+ 'table_name' => $table,
+ 'columns' => array(),
+ );
+
+ $info = $this->fetchPragma('index_info', $index['name'], $schema);
+
+ foreach ($info as $column) {
+ $constraint['columns'][] = $column['name'];
+ }
+ if ($primaryKey === $constraint['columns']) {
+ $constraint['constraint_type'] = 'PRIMARY KEY';
+ $primaryKey = null;
+ }
+ $constraints[$constraint['constraint_name']] = $constraint;
+ }
+
+ if (null !== $primaryKey) {
+ $constraintName = '_zf_' . $table . '_PRIMARY';
+ $constraints[$constraintName] = array(
+ 'constraint_name' => $constraintName,
+ 'constraint_type' => 'PRIMARY KEY',
+ 'table_name' => $table,
+ 'columns' => $primaryKey,
+ );
+ }
+
+ $foreignKeys = $this->fetchPragma('foreign_key_list', $table, $schema);
+
+ $id = $name = null;
+ foreach ($foreignKeys as $fk) {
+ if ($id !== $fk['id']) {
+ $id = $fk['id'];
+ $name = '_zf_' . $table . '_FOREIGN_KEY_' . ($id + 1);
+ $constraints[$name] = array(
+ 'constraint_name' => $name,
+ 'constraint_type' => 'FOREIGN KEY',
+ 'table_name' => $table,
+ 'columns' => array(),
+ 'referenced_table_schema' => $schema,
+ 'referenced_table_name' => $fk['table'],
+ 'referenced_columns' => array(),
+ // TODO: Verify match, on_update, and on_delete values conform to SQL Standard
+ 'match_option' => strtoupper($fk['match']),
+ 'update_rule' => strtoupper($fk['on_update']),
+ 'delete_rule' => strtoupper($fk['on_delete']),
+ );
+ }
+ $constraints[$name]['columns'][] = $fk['from'];
+ $constraints[$name]['referenced_columns'][] = $fk['to'];
+ }
+
+ $this->data['constraints'][$schema][$table] = $constraints;
+ }
+
+ protected function loadTriggerData($schema)
+ {
+ if (isset($this->data['triggers'][$schema])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('triggers', $schema);
+
+ $p = $this->adapter->getPlatform();
+
+ $sql = 'SELECT "name", "tbl_name", "sql" FROM '
+ . $p->quoteIdentifierChain(array($schema, 'sqlite_master'))
+ . ' WHERE "type" = \'trigger\'';
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+ $triggers = array();
+ foreach ($results->toArray() as $row) {
+ $trigger = array(
+ 'trigger_name' => $row['name'],
+ 'event_manipulation' => null, // in $row['sql']
+ 'event_object_catalog' => null,
+ 'event_object_schema' => $schema,
+ 'event_object_table' => $row['tbl_name'],
+ 'action_order' => 0,
+ 'action_condition' => null, // in $row['sql']
+ 'action_statement' => null, // in $row['sql']
+ 'action_orientation' => 'ROW',
+ 'action_timing' => null, // in $row['sql']
+ 'action_reference_old_table' => null,
+ 'action_reference_new_table' => null,
+ 'action_reference_old_row' => 'OLD',
+ 'action_reference_new_row' => 'NEW',
+ 'created' => null,
+ );
+
+ // Parse out extra data
+ if (null !== ($data = $this->parseTrigger($row['sql']))) {
+ $trigger = array_merge($trigger, $data);
+ }
+ $triggers[$trigger['trigger_name']] = $trigger;
+ }
+
+ $this->data['triggers'][$schema] = $triggers;
+ }
+
+ protected function fetchPragma($name, $value = null, $schema = null)
+ {
+ $p = $this->adapter->getPlatform();
+
+ $sql = 'PRAGMA ';
+
+ if (null !== $schema) {
+ $sql .= $p->quoteIdentifier($schema) . '.';
+ }
+ $sql .= $name;
+
+ if (null !== $value) {
+ $sql .= '(' . $p->quoteTrustedValue($value) . ')';
+ }
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+ if ($results instanceof ResultSetInterface) {
+ return $results->toArray();
+ }
+ return array();
+ }
+
+ protected function parseView($sql)
+ {
+ static $re = null;
+ if (null === $re) {
+ $identifier = $this->getIdentifierRegularExpression();
+ $identifierList = $this->getIdentifierListRegularExpression();
+ $identifierChain = $this->getIdentifierChainRegularExpression();
+ $re = $this->buildRegularExpression(array(
+ 'CREATE',
+ array('TEMP|TEMPORARY'),
+ 'VIEW',
+ array('IF', 'NOT', 'EXISTS'),
+ $identifierChain,
+ 'AS',
+ '(?.+)',
+ array(';'),
+ ));
+ }
+
+ if (!preg_match($re, $sql, $matches)) {
+ return null;
+ }
+ return array(
+ 'view_definition' => $matches['view_definition'],
+ );
+ }
+
+ protected function parseTrigger($sql)
+ {
+ static $re = null;
+ if (null === $re) {
+ $identifier = $this->getIdentifierRegularExpression();
+ $identifierList = $this->getIdentifierListRegularExpression();
+ $identifierChain = $this->getIdentifierChainRegularExpression();
+ $re = $this->buildRegularExpression(array(
+ 'CREATE',
+ array('TEMP|TEMPORARY'),
+ 'TRIGGER',
+ array('IF', 'NOT', 'EXISTS'),
+ $identifierChain,
+ array('(?BEFORE|AFTER|INSTEAD\\s+OF)',),
+ '(?DELETE|INSERT|UPDATE)',
+ array('OF', '(?' . $identifierList . ')'),
+ 'ON',
+ '(?' . $identifier . ')',
+ array('FOR', 'EACH', 'ROW'),
+ array('WHEN', '(?.+)'),
+ '(?BEGIN',
+ '.+',
+ 'END)',
+ array(';'),
+ ));
+ }
+
+ if (!preg_match($re, $sql, $matches)) {
+ return null;
+ }
+ $data = array();
+
+ foreach ($matches as $key => $value) {
+ if (is_string($key)) {
+ $data[$key] = $value;
+ }
+ }
+
+ // Normalize data and populate defaults, if necessary
+
+ $data['event_manipulation'] = strtoupper($data['event_manipulation']);
+ if (empty($data['action_condition'])) {
+ $data['action_condition'] = null;
+ }
+ if (!empty($data['action_timing'])) {
+ $data['action_timing'] = strtoupper($data['action_timing']);
+ if ('I' == $data['action_timing'][0]) {
+ // normalize the white-space between the two words
+ $data['action_timing'] = 'INSTEAD OF';
+ }
+ } else {
+ $data['action_timing'] = 'AFTER';
+ }
+ unset($data['column_usage']);
+
+ return $data;
+ }
+
+ protected function buildRegularExpression(array $re)
+ {
+ foreach ($re as &$value) {
+ if (is_array($value)) {
+ $value = '(?:' . implode('\\s*+', $value) . '\\s*+)?';
+ } else {
+ $value .= '\\s*+';
+ }
+ }
+ unset($value);
+ $re = '/^' . implode('\\s*+', $re) . '$/';
+ return $re;
+ }
+
+ protected function getIdentifierRegularExpression()
+ {
+ static $re = null;
+ if (null === $re) {
+ $re = '(?:' . implode('|', array(
+ '"(?:[^"\\\\]++|\\\\.)*+"',
+ '`(?:[^`]++|``)*+`',
+ '\\[[^\\]]+\\]',
+ '[^\\s\\.]+',
+ )) . ')';
+ }
+
+ return $re;
+ }
+
+ protected function getIdentifierChainRegularExpression()
+ {
+ static $re = null;
+ if (null === $re) {
+ $identifier = $this->getIdentifierRegularExpression();
+ $re = $identifier . '(?:\\s*\\.\\s*' . $identifier . ')*+';
+ }
+ return $re;
+ }
+
+ protected function getIdentifierListRegularExpression()
+ {
+ static $re = null;
+ if (null === $re) {
+ $identifier = $this->getIdentifierRegularExpression();
+ $re = $identifier . '(?:\\s*,\\s*' . $identifier . ')*+';
+ }
+ return $re;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Metadata/Source/SqlServerMetadata.php zendframework-2.2.6/library/Zend/Db/Metadata/Source/SqlServerMetadata.php
--- zendframework-1.10.4/library/Zend/Db/Metadata/Source/SqlServerMetadata.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Metadata/Source/SqlServerMetadata.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,343 @@
+data['schemas'])) {
+ return;
+ }
+ $this->prepareDataHierarchy('schemas');
+
+ $p = $this->adapter->getPlatform();
+
+ $sql = 'SELECT ' . $p->quoteIdentifier('SCHEMA_NAME')
+ . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'SCHEMATA'))
+ . ' WHERE ' . $p->quoteIdentifier('SCHEMA_NAME')
+ . ' != \'INFORMATION_SCHEMA\'';
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $schemas = array();
+ foreach ($results->toArray() as $row) {
+ $schemas[] = $row['SCHEMA_NAME'];
+ }
+
+ $this->data['schemas'] = $schemas;
+ }
+
+ protected function loadTableNameData($schema)
+ {
+ if (isset($this->data['table_names'][$schema])) {
+ return;
+ }
+ $this->prepareDataHierarchy('table_names', $schema);
+
+ $p = $this->adapter->getPlatform();
+
+ $isColumns = array(
+ array('T', 'TABLE_NAME'),
+ array('T', 'TABLE_TYPE'),
+ array('V', 'VIEW_DEFINITION'),
+ array('V', 'CHECK_OPTION'),
+ array('V', 'IS_UPDATABLE'),
+ );
+
+ array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifierChain($c); });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . ' t'
+
+ . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'VIEWS')) . ' v'
+ . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('V', 'TABLE_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('V', 'TABLE_NAME'))
+
+ . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE'))
+ . ' IN (\'BASE TABLE\', \'VIEW\')';
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' != \'INFORMATION_SCHEMA\'';
+ }
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $tables = array();
+ foreach ($results->toArray() as $row) {
+ $tables[$row['TABLE_NAME']] = array(
+ 'table_type' => $row['TABLE_TYPE'],
+ 'view_definition' => $row['VIEW_DEFINITION'],
+ 'check_option' => $row['CHECK_OPTION'],
+ 'is_updatable' => ('YES' == $row['IS_UPDATABLE']),
+ );
+ }
+
+ $this->data['table_names'][$schema] = $tables;
+ }
+
+ protected function loadColumnData($table, $schema)
+ {
+ if (isset($this->data['columns'][$schema][$table])) {
+ return;
+ }
+ $this->prepareDataHierarchy('columns', $schema, $table);
+ $p = $this->adapter->getPlatform();
+
+ $isColumns = array(
+ array('C', 'ORDINAL_POSITION'),
+ array('C', 'COLUMN_DEFAULT'),
+ array('C', 'IS_NULLABLE'),
+ array('C', 'DATA_TYPE'),
+ array('C', 'CHARACTER_MAXIMUM_LENGTH'),
+ array('C', 'CHARACTER_OCTET_LENGTH'),
+ array('C', 'NUMERIC_PRECISION'),
+ array('C', 'NUMERIC_SCALE'),
+ array('C', 'COLUMN_NAME'),
+ );
+
+ array_walk($isColumns, function (&$c) use ($p) { $c = $p->quoteIdentifierChain($c); });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T'
+ . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'COLUMNS')) . 'C'
+ . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('C', 'TABLE_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('C', 'TABLE_NAME'))
+ . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE'))
+ . ' IN (\'BASE TABLE\', \'VIEW\')'
+ . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME'))
+ . ' = ' . $p->quoteTrustedValue($table);
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' != \'INFORMATION_SCHEMA\'';
+ }
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+ $columns = array();
+ foreach ($results->toArray() as $row) {
+ $columns[$row['COLUMN_NAME']] = array(
+ 'ordinal_position' => $row['ORDINAL_POSITION'],
+ 'column_default' => $row['COLUMN_DEFAULT'],
+ 'is_nullable' => ('YES' == $row['IS_NULLABLE']),
+ 'data_type' => $row['DATA_TYPE'],
+ 'character_maximum_length' => $row['CHARACTER_MAXIMUM_LENGTH'],
+ 'character_octet_length' => $row['CHARACTER_OCTET_LENGTH'],
+ 'numeric_precision' => $row['NUMERIC_PRECISION'],
+ 'numeric_scale' => $row['NUMERIC_SCALE'],
+ 'numeric_unsigned' => null,
+ 'erratas' => array(),
+ );
+ }
+
+ $this->data['columns'][$schema][$table] = $columns;
+ }
+
+ protected function loadConstraintData($table, $schema)
+ {
+ if (isset($this->data['constraints'][$schema][$table])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('constraints', $schema, $table);
+
+ $isColumns = array(
+ array('T', 'TABLE_NAME'),
+ array('TC', 'CONSTRAINT_NAME'),
+ array('TC', 'CONSTRAINT_TYPE'),
+ array('KCU', 'COLUMN_NAME'),
+ array('CC', 'CHECK_CLAUSE'),
+ array('RC', 'MATCH_OPTION'),
+ array('RC', 'UPDATE_RULE'),
+ array('RC', 'DELETE_RULE'),
+ array('REFERENCED_TABLE_SCHEMA' => 'KCU2', 'TABLE_SCHEMA'),
+ array('REFERENCED_TABLE_NAME' => 'KCU2', 'TABLE_NAME'),
+ array('REFERENCED_COLUMN_NAME' => 'KCU2', 'COLUMN_NAME'),
+ );
+
+ $p = $this->adapter->getPlatform();
+
+ array_walk($isColumns, function (&$c) use ($p) {
+ $alias = key($c);
+ $c = $p->quoteIdentifierChain($c);
+ if (is_string($alias)) {
+ $c .= ' ' . $p->quoteIdentifier($alias);
+ }
+ });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . ' T'
+
+ . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLE_CONSTRAINTS')) . ' TC'
+ . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('TC', 'TABLE_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('TC', 'TABLE_NAME'))
+
+ . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE')) . ' KCU'
+ . ' ON ' . $p->quoteIdentifierChain(array('TC', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('TC', 'TABLE_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU', 'TABLE_NAME'))
+ . ' AND ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU', 'CONSTRAINT_NAME'))
+
+ . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'CHECK_CONSTRAINTS')) . ' CC'
+ . ' ON ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('CC', 'CONSTRAINT_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('CC', 'CONSTRAINT_NAME'))
+
+ . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'REFERENTIAL_CONSTRAINTS')) . ' RC'
+ . ' ON ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('RC', 'CONSTRAINT_NAME'))
+
+ . ' LEFT JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'KEY_COLUMN_USAGE')) . ' KCU2'
+ . ' ON ' . $p->quoteIdentifierChain(array('RC', 'UNIQUE_CONSTRAINT_SCHEMA'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU2', 'CONSTRAINT_SCHEMA'))
+ . ' AND ' . $p->quoteIdentifierChain(array('RC', 'UNIQUE_CONSTRAINT_NAME'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU2', 'CONSTRAINT_NAME'))
+ . ' AND ' . $p->quoteIdentifierChain(array('KCU', 'ORDINAL_POSITION'))
+ . ' = ' . $p->quoteIdentifierChain(array('KCU2', 'ORDINAL_POSITION'))
+
+ . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME'))
+ . ' = ' . $p->quoteTrustedValue($table)
+ . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE'))
+ . ' IN (\'BASE TABLE\', \'VIEW\')';
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA'))
+ . ' != \'INFORMATION_SCHEMA\'';
+ }
+
+ $sql .= ' ORDER BY CASE ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_TYPE'))
+ . " WHEN 'PRIMARY KEY' THEN 1"
+ . " WHEN 'UNIQUE' THEN 2"
+ . " WHEN 'FOREIGN KEY' THEN 3"
+ . " WHEN 'CHECK' THEN 4"
+ . " ELSE 5 END"
+ . ', ' . $p->quoteIdentifierChain(array('TC', 'CONSTRAINT_NAME'))
+ . ', ' . $p->quoteIdentifierChain(array('KCU', 'ORDINAL_POSITION'));
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $name = null;
+ $constraints = array();
+ $isFK = false;
+ foreach ($results->toArray() as $row) {
+ if ($row['CONSTRAINT_NAME'] !== $name) {
+ $name = $row['CONSTRAINT_NAME'];
+ $constraints[$name] = array(
+ 'constraint_name' => $name,
+ 'constraint_type' => $row['CONSTRAINT_TYPE'],
+ 'table_name' => $row['TABLE_NAME'],
+ );
+ if ('CHECK' == $row['CONSTRAINT_TYPE']) {
+ $constraints[$name]['check_clause'] = $row['CHECK_CLAUSE'];
+ continue;
+ }
+ $constraints[$name]['columns'] = array();
+ $isFK = ('FOREIGN KEY' == $row['CONSTRAINT_TYPE']);
+ if ($isFK) {
+ $constraints[$name]['referenced_table_schema'] = $row['REFERENCED_TABLE_SCHEMA'];
+ $constraints[$name]['referenced_table_name'] = $row['REFERENCED_TABLE_NAME'];
+ $constraints[$name]['referenced_columns'] = array();
+ $constraints[$name]['match_option'] = $row['MATCH_OPTION'];
+ $constraints[$name]['update_rule'] = $row['UPDATE_RULE'];
+ $constraints[$name]['delete_rule'] = $row['DELETE_RULE'];
+ }
+ }
+ $constraints[$name]['columns'][] = $row['COLUMN_NAME'];
+ if ($isFK) {
+ $constraints[$name]['referenced_columns'][] = $row['REFERENCED_COLUMN_NAME'];
+ }
+ }
+
+ $this->data['constraints'][$schema][$table] = $constraints;
+ }
+
+ protected function loadTriggerData($schema)
+ {
+ if (isset($this->data['triggers'][$schema])) {
+ return;
+ }
+
+ $this->prepareDataHierarchy('triggers', $schema);
+
+ $p = $this->adapter->getPlatform();
+
+ $isColumns = array(
+ 'TRIGGER_NAME',
+ 'EVENT_MANIPULATION',
+ 'EVENT_OBJECT_CATALOG',
+ 'EVENT_OBJECT_SCHEMA',
+ 'EVENT_OBJECT_TABLE',
+ 'ACTION_ORDER',
+ 'ACTION_CONDITION',
+ 'ACTION_STATEMENT',
+ 'ACTION_ORIENTATION',
+ 'ACTION_TIMING',
+ 'ACTION_REFERENCE_OLD_TABLE',
+ 'ACTION_REFERENCE_NEW_TABLE',
+ 'ACTION_REFERENCE_OLD_ROW',
+ 'ACTION_REFERENCE_NEW_ROW',
+ 'CREATED',
+ );
+
+ array_walk($isColumns, function (&$c) use ($p) {
+ $c = $p->quoteIdentifier($c);
+ });
+
+ $sql = 'SELECT ' . implode(', ', $isColumns)
+ . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TRIGGERS'))
+ . ' WHERE ';
+
+ if ($schema != self::DEFAULT_SCHEMA) {
+ $sql .= $p->quoteIdentifier('TRIGGER_SCHEMA')
+ . ' = ' . $p->quoteTrustedValue($schema);
+ } else {
+ $sql .= $p->quoteIdentifier('TRIGGER_SCHEMA')
+ . ' != \'INFORMATION_SCHEMA\'';
+ }
+
+ $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
+
+ $data = array();
+ foreach ($results->toArray() as $row) {
+ $row = array_change_key_case($row, CASE_LOWER);
+ if (null !== $row['created']) {
+ $row['created'] = new \DateTime($row['created']);
+ }
+ $data[$row['trigger_name']] = $row;
+ }
+
+ $this->data['triggers'][$schema] = $data;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Profiler/Exception.php zendframework-2.2.6/library/Zend/Db/Profiler/Exception.php
--- zendframework-1.10.4/library/Zend/Db/Profiler/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Profiler/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,40 +0,0 @@
-_label = $label;
- if(!$this->_label) {
- $this->_label = 'Zend_Db_Profiler_Firebug';
- }
- }
-
- /**
- * Enable or disable the profiler. If $enable is false, the profiler
- * is disabled and will not log any queries sent to it.
- *
- * @param boolean $enable
- * @return Zend_Db_Profiler Provides a fluent interface
- */
- public function setEnabled($enable)
- {
- parent::setEnabled($enable);
-
- if ($this->getEnabled()) {
-
- if (!$this->_message) {
- $this->_message = new Zend_Wildfire_Plugin_FirePhp_TableMessage($this->_label);
- $this->_message->setBuffered(true);
- $this->_message->setHeader(array('Time','Event','Parameters'));
- $this->_message->setDestroy(true);
- $this->_message->setOption('includeLineNumbers', false);
- Zend_Wildfire_Plugin_FirePhp::getInstance()->send($this->_message);
- }
-
- } else {
-
- if ($this->_message) {
- $this->_message->setDestroy(true);
- $this->_message = null;
- }
-
- }
-
- return $this;
- }
-
- /**
- * Intercept the query end and log the profiling data.
- *
- * @param integer $queryId
- * @throws Zend_Db_Profiler_Exception
- * @return void
- */
- public function queryEnd($queryId)
- {
- $state = parent::queryEnd($queryId);
-
- if (!$this->getEnabled() || $state == self::IGNORED) {
- return;
- }
-
- $this->_message->setDestroy(false);
-
- $profile = $this->getQueryProfile($queryId);
-
- $this->_totalElapsedTime += $profile->getElapsedSecs();
-
- $this->_message->addRow(array((string)round($profile->getElapsedSecs(),5),
- $profile->getQuery(),
- ($params=$profile->getQueryParams())?$params:null));
-
- $this->updateMessageLabel();
- }
-
- /**
- * Update the label of the message holding the profile info.
- *
- * @return void
- */
- protected function updateMessageLabel()
- {
- if (!$this->_message) {
- return;
- }
- $this->_message->setLabel(str_replace(array('%label%',
- '%totalCount%',
- '%totalDuration%'),
- array($this->_label,
- $this->getTotalNumQueries(),
- (string)round($this->_totalElapsedTime,5)),
- $this->_label_template));
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Profiler/Query.php zendframework-2.2.6/library/Zend/Db/Profiler/Query.php
--- zendframework-1.10.4/library/Zend/Db/Profiler/Query.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Profiler/Query.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,199 +0,0 @@
-_query = $query;
- $this->_queryType = $queryType;
- // by default, and for backward-compatibility, start the click ticking
- $this->start();
- }
-
- /**
- * Clone handler for the query object.
- * @return void
- */
- public function __clone()
- {
- $this->_boundParams = array();
- $this->_endedMicrotime = null;
- $this->start();
- }
-
- /**
- * Starts the elapsed time click ticking.
- * This can be called subsequent to object creation,
- * to restart the clock. For instance, this is useful
- * right before executing a prepared query.
- *
- * @return void
- */
- public function start()
- {
- $this->_startedMicrotime = microtime(true);
- }
-
- /**
- * Ends the query and records the time so that the elapsed time can be determined later.
- *
- * @return void
- */
- public function end()
- {
- $this->_endedMicrotime = microtime(true);
- }
-
- /**
- * Returns true if and only if the query has ended.
- *
- * @return boolean
- */
- public function hasEnded()
- {
- return $this->_endedMicrotime !== null;
- }
-
- /**
- * Get the original SQL text of the query.
- *
- * @return string
- */
- public function getQuery()
- {
- return $this->_query;
- }
-
- /**
- * Get the type of this query (one of the Zend_Db_Profiler::* constants)
- *
- * @return integer
- */
- public function getQueryType()
- {
- return $this->_queryType;
- }
-
- /**
- * @param string $param
- * @param mixed $variable
- * @return void
- */
- public function bindParam($param, $variable)
- {
- $this->_boundParams[$param] = $variable;
- }
-
- /**
- * @param array $param
- * @return void
- */
- public function bindParams(array $params)
- {
- if (array_key_exists(0, $params)) {
- array_unshift($params, null);
- unset($params[0]);
- }
- foreach ($params as $param => $value) {
- $this->bindParam($param, $value);
- }
- }
-
- /**
- * @return array
- */
- public function getQueryParams()
- {
- return $this->_boundParams;
- }
-
- /**
- * Get the elapsed time (in seconds) that the query ran.
- * If the query has not yet ended, false is returned.
- *
- * @return float|false
- */
- public function getElapsedSecs()
- {
- if (null === $this->_endedMicrotime) {
- return false;
- }
-
- return $this->_endedMicrotime - $this->_startedMicrotime;
- }
-}
-
diff -Nru zendframework-1.10.4/library/Zend/Db/Profiler.php zendframework-2.2.6/library/Zend/Db/Profiler.php
--- zendframework-1.10.4/library/Zend/Db/Profiler.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Profiler.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,471 +0,0 @@
-setEnabled($enabled);
- }
-
- /**
- * Enable or disable the profiler. If $enable is false, the profiler
- * is disabled and will not log any queries sent to it.
- *
- * @param boolean $enable
- * @return Zend_Db_Profiler Provides a fluent interface
- */
- public function setEnabled($enable)
- {
- $this->_enabled = (boolean) $enable;
-
- return $this;
- }
-
- /**
- * Get the current state of enable. If True is returned,
- * the profiler is enabled.
- *
- * @return boolean
- */
- public function getEnabled()
- {
- return $this->_enabled;
- }
-
- /**
- * Sets a minimum number of seconds for saving query profiles. If this
- * is set, only those queries whose elapsed time is equal or greater than
- * $minimumSeconds will be saved. To save all queries regardless of
- * elapsed time, set $minimumSeconds to null.
- *
- * @param integer $minimumSeconds OPTIONAL
- * @return Zend_Db_Profiler Provides a fluent interface
- */
- public function setFilterElapsedSecs($minimumSeconds = null)
- {
- if (null === $minimumSeconds) {
- $this->_filterElapsedSecs = null;
- } else {
- $this->_filterElapsedSecs = (integer) $minimumSeconds;
- }
-
- return $this;
- }
-
- /**
- * Returns the minimum number of seconds for saving query profiles, or null if
- * query profiles are saved regardless of elapsed time.
- *
- * @return integer|null
- */
- public function getFilterElapsedSecs()
- {
- return $this->_filterElapsedSecs;
- }
-
- /**
- * Sets the types of query profiles to save. Set $queryType to one of
- * the Zend_Db_Profiler::* constants to only save profiles for that type of
- * query. To save more than one type, logical OR them together. To
- * save all queries regardless of type, set $queryType to null.
- *
- * @param integer $queryTypes OPTIONAL
- * @return Zend_Db_Profiler Provides a fluent interface
- */
- public function setFilterQueryType($queryTypes = null)
- {
- $this->_filterTypes = $queryTypes;
-
- return $this;
- }
-
- /**
- * Returns the types of query profiles saved, or null if queries are saved regardless
- * of their types.
- *
- * @return integer|null
- * @see Zend_Db_Profiler::setFilterQueryType()
- */
- public function getFilterQueryType()
- {
- return $this->_filterTypes;
- }
-
- /**
- * Clears the history of any past query profiles. This is relentless
- * and will even clear queries that were started and may not have
- * been marked as ended.
- *
- * @return Zend_Db_Profiler Provides a fluent interface
- */
- public function clear()
- {
- $this->_queryProfiles = array();
-
- return $this;
- }
-
- /**
- * @param integer $queryId
- * @return integer or null
- */
- public function queryClone(Zend_Db_Profiler_Query $query)
- {
- $this->_queryProfiles[] = clone $query;
-
- end($this->_queryProfiles);
-
- return key($this->_queryProfiles);
- }
-
- /**
- * Starts a query. Creates a new query profile object (Zend_Db_Profiler_Query)
- * and returns the "query profiler handle". Run the query, then call
- * queryEnd() and pass it this handle to make the query as ended and
- * record the time. If the profiler is not enabled, this takes no
- * action and immediately returns null.
- *
- * @param string $queryText SQL statement
- * @param integer $queryType OPTIONAL Type of query, one of the Zend_Db_Profiler::* constants
- * @return integer|null
- */
- public function queryStart($queryText, $queryType = null)
- {
- if (!$this->_enabled) {
- return null;
- }
-
- // make sure we have a query type
- if (null === $queryType) {
- switch (strtolower(substr(ltrim($queryText), 0, 6))) {
- case 'insert':
- $queryType = self::INSERT;
- break;
- case 'update':
- $queryType = self::UPDATE;
- break;
- case 'delete':
- $queryType = self::DELETE;
- break;
- case 'select':
- $queryType = self::SELECT;
- break;
- default:
- $queryType = self::QUERY;
- break;
- }
- }
-
- /**
- * @see Zend_Db_Profiler_Query
- */
- require_once 'Zend/Db/Profiler/Query.php';
- $this->_queryProfiles[] = new Zend_Db_Profiler_Query($queryText, $queryType);
-
- end($this->_queryProfiles);
-
- return key($this->_queryProfiles);
- }
-
- /**
- * Ends a query. Pass it the handle that was returned by queryStart().
- * This will mark the query as ended and save the time.
- *
- * @param integer $queryId
- * @throws Zend_Db_Profiler_Exception
- * @return void
- */
- public function queryEnd($queryId)
- {
- // Don't do anything if the Zend_Db_Profiler is not enabled.
- if (!$this->_enabled) {
- return self::IGNORED;
- }
-
- // Check for a valid query handle.
- if (!isset($this->_queryProfiles[$queryId])) {
- /**
- * @see Zend_Db_Profiler_Exception
- */
- require_once 'Zend/Db/Profiler/Exception.php';
- throw new Zend_Db_Profiler_Exception("Profiler has no query with handle '$queryId'.");
- }
-
- $qp = $this->_queryProfiles[$queryId];
-
- // Ensure that the query profile has not already ended
- if ($qp->hasEnded()) {
- /**
- * @see Zend_Db_Profiler_Exception
- */
- require_once 'Zend/Db/Profiler/Exception.php';
- throw new Zend_Db_Profiler_Exception("Query with profiler handle '$queryId' has already ended.");
- }
-
- // End the query profile so that the elapsed time can be calculated.
- $qp->end();
-
- /**
- * If filtering by elapsed time is enabled, only keep the profile if
- * it ran for the minimum time.
- */
- if (null !== $this->_filterElapsedSecs && $qp->getElapsedSecs() < $this->_filterElapsedSecs) {
- unset($this->_queryProfiles[$queryId]);
- return self::IGNORED;
- }
-
- /**
- * If filtering by query type is enabled, only keep the query if
- * it was one of the allowed types.
- */
- if (null !== $this->_filterTypes && !($qp->getQueryType() & $this->_filterTypes)) {
- unset($this->_queryProfiles[$queryId]);
- return self::IGNORED;
- }
-
- return self::STORED;
- }
-
- /**
- * Get a profile for a query. Pass it the same handle that was returned
- * by queryStart() and it will return a Zend_Db_Profiler_Query object.
- *
- * @param integer $queryId
- * @throws Zend_Db_Profiler_Exception
- * @return Zend_Db_Profiler_Query
- */
- public function getQueryProfile($queryId)
- {
- if (!array_key_exists($queryId, $this->_queryProfiles)) {
- /**
- * @see Zend_Db_Profiler_Exception
- */
- require_once 'Zend/Db/Profiler/Exception.php';
- throw new Zend_Db_Profiler_Exception("Query handle '$queryId' not found in profiler log.");
- }
-
- return $this->_queryProfiles[$queryId];
- }
-
- /**
- * Get an array of query profiles (Zend_Db_Profiler_Query objects). If $queryType
- * is set to one of the Zend_Db_Profiler::* constants then only queries of that
- * type will be returned. Normally, queries that have not yet ended will
- * not be returned unless $showUnfinished is set to True. If no
- * queries were found, False is returned. The returned array is indexed by the query
- * profile handles.
- *
- * @param integer $queryType
- * @param boolean $showUnfinished
- * @return array|false
- */
- public function getQueryProfiles($queryType = null, $showUnfinished = false)
- {
- $queryProfiles = array();
- foreach ($this->_queryProfiles as $key => $qp) {
- if ($queryType === null) {
- $condition = true;
- } else {
- $condition = ($qp->getQueryType() & $queryType);
- }
-
- if (($qp->hasEnded() || $showUnfinished) && $condition) {
- $queryProfiles[$key] = $qp;
- }
- }
-
- if (empty($queryProfiles)) {
- $queryProfiles = false;
- }
-
- return $queryProfiles;
- }
-
- /**
- * Get the total elapsed time (in seconds) of all of the profiled queries.
- * Only queries that have ended will be counted. If $queryType is set to
- * one or more of the Zend_Db_Profiler::* constants, the elapsed time will be calculated
- * only for queries of the given type(s).
- *
- * @param integer $queryType OPTIONAL
- * @return float
- */
- public function getTotalElapsedSecs($queryType = null)
- {
- $elapsedSecs = 0;
- foreach ($this->_queryProfiles as $key => $qp) {
- if (null === $queryType) {
- $condition = true;
- } else {
- $condition = ($qp->getQueryType() & $queryType);
- }
- if (($qp->hasEnded()) && $condition) {
- $elapsedSecs += $qp->getElapsedSecs();
- }
- }
- return $elapsedSecs;
- }
-
- /**
- * Get the total number of queries that have been profiled. Only queries that have ended will
- * be counted. If $queryType is set to one of the Zend_Db_Profiler::* constants, only queries of
- * that type will be counted.
- *
- * @param integer $queryType OPTIONAL
- * @return integer
- */
- public function getTotalNumQueries($queryType = null)
- {
- if (null === $queryType) {
- return count($this->_queryProfiles);
- }
-
- $numQueries = 0;
- foreach ($this->_queryProfiles as $qp) {
- if ($qp->hasEnded() && ($qp->getQueryType() & $queryType)) {
- $numQueries++;
- }
- }
-
- return $numQueries;
- }
-
- /**
- * Get the Zend_Db_Profiler_Query object for the last query that was run, regardless if it has
- * ended or not. If the query has not ended, its end time will be null. If no queries have
- * been profiled, false is returned.
- *
- * @return Zend_Db_Profiler_Query|false
- */
- public function getLastQueryProfile()
- {
- if (empty($this->_queryProfiles)) {
- return false;
- }
-
- end($this->_queryProfiles);
-
- return current($this->_queryProfiles);
- }
-
-}
-
diff -Nru zendframework-1.10.4/library/Zend/Db/README.md zendframework-2.2.6/library/Zend/Db/README.md
--- zendframework-1.10.4/library/Zend/Db/README.md 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/README.md 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+DB Component from ZF2
+=====================
+
+This is the DB component for ZF2.
+
+- File issues at https://github.com/zendframework/zf2/issues
+- Create pull requests against https://github.com/zendframework/zf2
+- Documentation is at http://framework.zend.com/docs
+
+LICENSE
+-------
+
+The files in this archive are released under the [Zend Framework
+license](http://framework.zend.com/license), which is a 3-clause BSD license.
+
diff -Nru zendframework-1.10.4/library/Zend/Db/ResultSet/AbstractResultSet.php zendframework-2.2.6/library/Zend/Db/ResultSet/AbstractResultSet.php
--- zendframework-1.10.4/library/Zend/Db/ResultSet/AbstractResultSet.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/ResultSet/AbstractResultSet.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,281 @@
+buffer)) {
+ $this->buffer = array();
+ }
+
+ if ($dataSource instanceof ResultInterface) {
+ $this->count = $dataSource->count();
+ $this->fieldCount = $dataSource->getFieldCount();
+ $this->dataSource = $dataSource;
+ if ($dataSource->isBuffered()) {
+ $this->buffer = -1;
+ }
+ if (is_array($this->buffer)) {
+ $this->dataSource->rewind();
+ }
+ return $this;
+ }
+
+ if (is_array($dataSource)) {
+ // its safe to get numbers from an array
+ $first = current($dataSource);
+ reset($dataSource);
+ $this->count = count($dataSource);
+ $this->fieldCount = count($first);
+ $this->dataSource = new ArrayIterator($dataSource);
+ $this->buffer = -1; // array's are a natural buffer
+ } elseif ($dataSource instanceof IteratorAggregate) {
+ $this->dataSource = $dataSource->getIterator();
+ } elseif ($dataSource instanceof Iterator) {
+ $this->dataSource = $dataSource;
+ } else {
+ throw new Exception\InvalidArgumentException('DataSource provided is not an array, nor does it implement Iterator or IteratorAggregate');
+ }
+
+ if ($this->count == null && $this->dataSource instanceof Countable) {
+ $this->count = $this->dataSource->count();
+ }
+
+ return $this;
+ }
+
+ public function buffer()
+ {
+ if ($this->buffer === -2) {
+ throw new Exception\RuntimeException('Buffering must be enabled before iteration is started');
+ } elseif ($this->buffer === null) {
+ $this->buffer = array();
+ if ($this->dataSource instanceof ResultInterface) {
+ $this->dataSource->rewind();
+ }
+ }
+ return $this;
+ }
+
+ public function isBuffered()
+ {
+ if ($this->buffer === -1 || is_array($this->buffer)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Get the data source used to create the result set
+ *
+ * @return null|Iterator
+ */
+ public function getDataSource()
+ {
+ return $this->dataSource;
+ }
+
+ /**
+ * Retrieve count of fields in individual rows of the result set
+ *
+ * @return int
+ */
+ public function getFieldCount()
+ {
+ if (null !== $this->fieldCount) {
+ return $this->fieldCount;
+ }
+
+ $dataSource = $this->getDataSource();
+ if (null === $dataSource) {
+ return 0;
+ }
+
+ $dataSource->rewind();
+ if (!$dataSource->valid()) {
+ $this->fieldCount = 0;
+ return 0;
+ }
+
+ $row = $dataSource->current();
+ if (is_object($row) && $row instanceof Countable) {
+ $this->fieldCount = $row->count();
+ return $this->fieldCount;
+ }
+
+ $row = (array) $row;
+ $this->fieldCount = count($row);
+ return $this->fieldCount;
+ }
+
+ /**
+ * Iterator: move pointer to next item
+ *
+ * @return void
+ */
+ public function next()
+ {
+ if ($this->buffer === null) {
+ $this->buffer = -2; // implicitly disable buffering from here on
+ }
+ $this->dataSource->next();
+ $this->position++;
+ }
+
+ /**
+ * Iterator: retrieve current key
+ *
+ * @return mixed
+ */
+ public function key()
+ {
+ return $this->position;
+ }
+
+ /**
+ * Iterator: get current item
+ *
+ * @return array
+ */
+ public function current()
+ {
+ if ($this->buffer === null) {
+ $this->buffer = -2; // implicitly disable buffering from here on
+ } elseif (is_array($this->buffer) && isset($this->buffer[$this->position])) {
+ return $this->buffer[$this->position];
+ }
+ $data = $this->dataSource->current();
+ if (is_array($this->buffer)) {
+ $this->buffer[$this->position] = $data;
+ }
+ return $data;
+ }
+
+ /**
+ * Iterator: is pointer valid?
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ if (is_array($this->buffer) && isset($this->buffer[$this->position])) {
+ return true;
+ }
+ if ($this->dataSource instanceof Iterator) {
+ return $this->dataSource->valid();
+ } else {
+ $key = key($this->dataSource);
+ return ($key !== null);
+ }
+ }
+
+ /**
+ * Iterator: rewind
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ if (!is_array($this->buffer)) {
+ if ($this->dataSource instanceof Iterator) {
+ $this->dataSource->rewind();
+ } else {
+ reset($this->dataSource);
+ }
+ }
+ $this->position = 0;
+ }
+
+ /**
+ * Countable: return count of rows
+ *
+ * @return int
+ */
+ public function count()
+ {
+ if ($this->count !== null) {
+ return $this->count;
+ }
+ $this->count = count($this->dataSource);
+ return $this->count;
+ }
+
+ /**
+ * Cast result set to array of arrays
+ *
+ * @return array
+ * @throws Exception\RuntimeException if any row is not castable to an array
+ */
+ public function toArray()
+ {
+ $return = array();
+ foreach ($this as $row) {
+ if (is_array($row)) {
+ $return[] = $row;
+ } elseif (method_exists($row, 'toArray')) {
+ $return[] = $row->toArray();
+ } elseif ($row instanceof ArrayObject) {
+ $return[] = $row->getArrayCopy();
+ } else {
+ throw new Exception\RuntimeException(
+ 'Rows as part of this DataSource, with type ' . gettype($row) . ' cannot be cast to an array'
+ );
+ }
+ }
+ return $return;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/ResultSet/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Db/ResultSet/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Db/ResultSet/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/ResultSet/Exception/ExceptionInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,16 @@
+setHydrator(($hydrator) ?: new ArraySerializable);
+ $this->setObjectPrototype(($objectPrototype) ?: new ArrayObject);
+ }
+
+ /**
+ * Set the row object prototype
+ *
+ * @param object $objectPrototype
+ * @throws Exception\InvalidArgumentException
+ * @return ResultSet
+ */
+ public function setObjectPrototype($objectPrototype)
+ {
+ if (!is_object($objectPrototype)) {
+ throw new Exception\InvalidArgumentException(
+ 'An object must be set as the object prototype, a ' . gettype($objectPrototype) . ' was provided.'
+ );
+ }
+ $this->objectPrototype = $objectPrototype;
+ return $this;
+ }
+
+ /**
+ * Set the hydrator to use for each row object
+ *
+ * @param HydratorInterface $hydrator
+ * @return HydratingResultSet
+ */
+ public function setHydrator(HydratorInterface $hydrator)
+ {
+ $this->hydrator = $hydrator;
+ return $this;
+ }
+
+ /**
+ * Get the hydrator to use for each row object
+ *
+ * @return HydratorInterface
+ */
+ public function getHydrator()
+ {
+ return $this->hydrator;
+ }
+
+ /**
+ * Iterator: get current item
+ *
+ * @return object
+ */
+ public function current()
+ {
+ if ($this->buffer === null) {
+ $this->buffer = -2; // implicitly disable buffering from here on
+ } elseif (is_array($this->buffer) && isset($this->buffer[$this->position])) {
+ return $this->buffer[$this->position];
+ }
+ $data = $this->dataSource->current();
+ $object = is_array($data) ? $this->hydrator->hydrate($data, clone $this->objectPrototype) : false;
+
+ if (is_array($this->buffer)) {
+ $this->buffer[$this->position] = $object;
+ }
+
+ return $object;
+ }
+
+ /**
+ * Cast result set to array of arrays
+ *
+ * @return array
+ * @throws Exception\RuntimeException if any row is not castable to an array
+ */
+ public function toArray()
+ {
+ $return = array();
+ foreach ($this as $row) {
+ $return[] = $this->getHydrator()->extract($row);
+ }
+ return $return;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/ResultSet/ResultSetInterface.php zendframework-2.2.6/library/Zend/Db/ResultSet/ResultSetInterface.php
--- zendframework-1.10.4/library/Zend/Db/ResultSet/ResultSetInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/ResultSet/ResultSetInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,33 @@
+returnType = (in_array($returnType, array(self::TYPE_ARRAY, self::TYPE_ARRAYOBJECT))) ? $returnType : self::TYPE_ARRAYOBJECT;
+ if ($this->returnType === self::TYPE_ARRAYOBJECT) {
+ $this->setArrayObjectPrototype(($arrayObjectPrototype) ?: new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS));
+ }
+ }
+
+ /**
+ * Set the row object prototype
+ *
+ * @param ArrayObject $arrayObjectPrototype
+ * @throws Exception\InvalidArgumentException
+ * @return ResultSet
+ */
+ public function setArrayObjectPrototype($arrayObjectPrototype)
+ {
+ if (!is_object($arrayObjectPrototype)
+ || (!$arrayObjectPrototype instanceof ArrayObject && !method_exists($arrayObjectPrototype, 'exchangeArray'))
+
+ ) {
+ throw new Exception\InvalidArgumentException('Object must be of type ArrayObject, or at least implement exchangeArray');
+ }
+ $this->arrayObjectPrototype = $arrayObjectPrototype;
+ return $this;
+ }
+
+ /**
+ * Get the row object prototype
+ *
+ * @return ArrayObject
+ */
+ public function getArrayObjectPrototype()
+ {
+ return $this->arrayObjectPrototype;
+ }
+
+ /**
+ * Get the return type to use when returning objects from the set
+ *
+ * @return string
+ */
+ public function getReturnType()
+ {
+ return $this->returnType;
+ }
+
+ /**
+ * @return array|\ArrayObject|null
+ */
+ public function current()
+ {
+ $data = parent::current();
+
+ if ($this->returnType === self::TYPE_ARRAYOBJECT && is_array($data)) {
+ /** @var $ao ArrayObject */
+ $ao = clone $this->arrayObjectPrototype;
+ if ($ao instanceof ArrayObject || method_exists($ao, 'exchangeArray')) {
+ $ao->exchangeArray($data);
+ }
+ return $ao;
+ }
+
+ return $data;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/RowGateway/AbstractRowGateway.php zendframework-2.2.6/library/Zend/Db/RowGateway/AbstractRowGateway.php
--- zendframework-1.10.4/library/Zend/Db/RowGateway/AbstractRowGateway.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/RowGateway/AbstractRowGateway.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,364 @@
+isInitialized) {
+ return;
+ }
+
+ if (!$this->featureSet instanceof Feature\FeatureSet) {
+ $this->featureSet = new Feature\FeatureSet;
+ }
+
+ $this->featureSet->setRowGateway($this);
+ $this->featureSet->apply('preInitialize', array());
+
+ if (!is_string($this->table) && !$this->table instanceof TableIdentifier) {
+ throw new Exception\RuntimeException('This row object does not have a valid table set.');
+ }
+
+ if ($this->primaryKeyColumn == null) {
+ throw new Exception\RuntimeException('This row object does not have a primary key column set.');
+ } elseif (is_string($this->primaryKeyColumn)) {
+ $this->primaryKeyColumn = (array) $this->primaryKeyColumn;
+ }
+
+ if (!$this->sql instanceof Sql) {
+ throw new Exception\RuntimeException('This row object does not have a Sql object set.');
+ }
+
+ $this->featureSet->apply('postInitialize', array());
+
+ $this->isInitialized = true;
+ }
+
+ /**
+ * Populate Data
+ *
+ * @param array $rowData
+ * @param bool $rowExistsInDatabase
+ * @return AbstractRowGateway
+ */
+ public function populate(array $rowData, $rowExistsInDatabase = false)
+ {
+ $this->initialize();
+
+ $this->data = $rowData;
+ if ($rowExistsInDatabase == true) {
+ $this->processPrimaryKeyData();
+ } else {
+ $this->primaryKeyData = null;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param mixed $array
+ * @return array|void
+ */
+ public function exchangeArray($array)
+ {
+ return $this->populate($array, true);
+ }
+
+ /**
+ * Save
+ *
+ * @return int
+ */
+ public function save()
+ {
+ $this->initialize();
+
+ if ($this->rowExistsInDatabase()) {
+
+ // UPDATE
+
+ $data = $this->data;
+ $where = array();
+ $isPkModified = false;
+
+ // primary key is always an array even if its a single column
+ foreach ($this->primaryKeyColumn as $pkColumn) {
+ $where[$pkColumn] = $this->primaryKeyData[$pkColumn];
+ if ($data[$pkColumn] == $this->primaryKeyData[$pkColumn]) {
+ unset($data[$pkColumn]);
+ } else {
+ $isPkModified = true;
+ }
+ }
+
+ $statement = $this->sql->prepareStatementForSqlObject($this->sql->update()->set($data)->where($where));
+ $result = $statement->execute();
+ $rowsAffected = $result->getAffectedRows();
+ unset($statement, $result); // cleanup
+
+ // If one or more primary keys are modified, we update the where clause
+ if ($isPkModified) {
+ foreach ($this->primaryKeyColumn as $pkColumn) {
+ if ($data[$pkColumn] != $this->primaryKeyData[$pkColumn]) {
+ $where[$pkColumn] = $data[$pkColumn];
+ }
+ }
+ }
+ } else {
+
+ // INSERT
+ $insert = $this->sql->insert();
+ $insert->values($this->data);
+
+ $statement = $this->sql->prepareStatementForSqlObject($insert);
+
+ $result = $statement->execute();
+ if (($primaryKeyValue = $result->getGeneratedValue()) && count($this->primaryKeyColumn) == 1) {
+ $this->primaryKeyData = array($this->primaryKeyColumn[0] => $primaryKeyValue);
+ } else {
+ // make primary key data available so that $where can be complete
+ $this->processPrimaryKeyData();
+ }
+ $rowsAffected = $result->getAffectedRows();
+ unset($statement, $result); // cleanup
+
+ $where = array();
+ // primary key is always an array even if its a single column
+ foreach ($this->primaryKeyColumn as $pkColumn) {
+ $where[$pkColumn] = $this->primaryKeyData[$pkColumn];
+ }
+
+ }
+
+ // refresh data
+ $statement = $this->sql->prepareStatementForSqlObject($this->sql->select()->where($where));
+ $result = $statement->execute();
+ $rowData = $result->current();
+ unset($statement, $result); // cleanup
+
+ // make sure data and original data are in sync after save
+ $this->populate($rowData, true);
+
+ // return rows affected
+ return $rowsAffected;
+ }
+
+ /**
+ * Delete
+ *
+ * @return int
+ */
+ public function delete()
+ {
+ $this->initialize();
+
+ $where = array();
+ // primary key is always an array even if its a single column
+ foreach ($this->primaryKeyColumn as $pkColumn) {
+ $where[$pkColumn] = $this->primaryKeyData[$pkColumn];
+ }
+
+ // @todo determine if we need to do a select to ensure 1 row will be affected
+
+ $statement = $this->sql->prepareStatementForSqlObject($this->sql->delete()->where($where));
+ $result = $statement->execute();
+
+ $affectedRows = $result->getAffectedRows();
+ if ($affectedRows == 1) {
+ // detach from database
+ $this->primaryKeyData = null;
+ }
+
+ return $affectedRows;
+ }
+
+ /**
+ * Offset Exists
+ *
+ * @param string $offset
+ * @return bool
+ */
+ public function offsetExists($offset)
+ {
+ return array_key_exists($offset, $this->data);
+ }
+
+ /**
+ * Offset get
+ *
+ * @param string $offset
+ * @return mixed
+ */
+ public function offsetGet($offset)
+ {
+ return $this->data[$offset];
+ }
+
+ /**
+ * Offset set
+ *
+ * @param string $offset
+ * @param mixed $value
+ * @return RowGateway
+ */
+ public function offsetSet($offset, $value)
+ {
+ $this->data[$offset] = $value;
+ return $this;
+ }
+
+ /**
+ * Offset unset
+ *
+ * @param string $offset
+ * @return AbstractRowGateway
+ */
+ public function offsetUnset($offset)
+ {
+ $this->data[$offset] = null;
+ return $this;
+ }
+
+ /**
+ * @return int
+ */
+ public function count()
+ {
+ return count($this->data);
+ }
+
+ /**
+ * To array
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ return $this->data;
+ }
+
+ /**
+ * __get
+ *
+ * @param string $name
+ * @throws Exception\InvalidArgumentException
+ * @return mixed
+ */
+ public function __get($name)
+ {
+ if (array_key_exists($name, $this->data)) {
+ return $this->data[$name];
+ } else {
+ throw new Exception\InvalidArgumentException('Not a valid column in this row: ' . $name);
+ }
+ }
+
+ /**
+ * __set
+ *
+ * @param string $name
+ * @param mixed $value
+ * @return void
+ */
+ public function __set($name, $value)
+ {
+ $this->offsetSet($name, $value);
+ }
+
+ /**
+ * __isset
+ *
+ * @param string $name
+ * @return bool
+ */
+ public function __isset($name)
+ {
+ return $this->offsetExists($name);
+ }
+
+ /**
+ * __unset
+ *
+ * @param string $name
+ * @return void
+ */
+ public function __unset($name)
+ {
+ $this->offsetUnset($name);
+ }
+
+ /**
+ * @return bool
+ */
+ public function rowExistsInDatabase()
+ {
+ return ($this->primaryKeyData !== null);
+ }
+
+ /**
+ * @throws Exception\RuntimeException
+ */
+ protected function processPrimaryKeyData()
+ {
+ $this->primaryKeyData = array();
+ foreach ($this->primaryKeyColumn as $column) {
+ if (!isset($this->data[$column])) {
+ throw new Exception\RuntimeException('While processing primary key data, a known key ' . $column . ' was not found in the data array');
+ }
+ $this->primaryKeyData[$column] = $this->data[$column];
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/RowGateway/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Db/RowGateway/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Db/RowGateway/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/RowGateway/Exception/ExceptionInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,16 @@
+rowGateway = $rowGateway;
+ }
+
+ /**
+ * @throws \Zend\Db\RowGateway\Exception\RuntimeException
+ */
+ public function initialize()
+ {
+ throw new Exception\RuntimeException('This method is not intended to be called on this object.');
+ }
+
+ /**
+ * @return array
+ */
+ public function getMagicMethodSpecifications()
+ {
+ return array();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/RowGateway/Feature/FeatureSet.php zendframework-2.2.6/library/Zend/Db/RowGateway/Feature/FeatureSet.php
--- zendframework-1.10.4/library/Zend/Db/RowGateway/Feature/FeatureSet.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/RowGateway/Feature/FeatureSet.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,149 @@
+addFeatures($features);
+ }
+ }
+
+ public function setRowGateway(AbstractRowGateway $rowGateway)
+ {
+ $this->rowGateway = $rowGateway;
+ foreach ($this->features as $feature) {
+ $feature->setRowGateway($this->rowGateway);
+ }
+ return $this;
+ }
+
+ public function getFeatureByClassName($featureClassName)
+ {
+ $feature = false;
+ foreach ($this->features as $potentialFeature) {
+ if ($potentialFeature instanceof $featureClassName) {
+ $feature = $potentialFeature;
+ break;
+ }
+ }
+ return $feature;
+ }
+
+ public function addFeatures(array $features)
+ {
+ foreach ($features as $feature) {
+ $this->addFeature($feature);
+ }
+ return $this;
+ }
+
+ public function addFeature(AbstractFeature $feature)
+ {
+ $this->features[] = $feature;
+ $feature->setRowGateway($feature);
+ return $this;
+ }
+
+ public function apply($method, $args)
+ {
+ foreach ($this->features as $feature) {
+ if (method_exists($feature, $method)) {
+ $return = call_user_func_array(array($feature, $method), $args);
+ if ($return === self::APPLY_HALT) {
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * @param string $property
+ * @return bool
+ */
+ public function canCallMagicGet($property)
+ {
+ return false;
+ }
+
+ /**
+ * @param string $property
+ * @return mixed
+ */
+ public function callMagicGet($property)
+ {
+ $return = null;
+ return $return;
+ }
+
+ /**
+ * @param string $property
+ * @return bool
+ */
+ public function canCallMagicSet($property)
+ {
+ return false;
+ }
+
+ /**
+ * @param $property
+ * @param $value
+ * @return mixed
+ */
+ public function callMagicSet($property, $value)
+ {
+ $return = null;
+ return $return;
+ }
+
+ /**
+ * @param string $method
+ * @return bool
+ */
+ public function canCallMagicCall($method)
+ {
+ return false;
+ }
+
+ /**
+ * @param string $method
+ * @param array $arguments
+ * @return mixed
+ */
+ public function callMagicCall($method, $arguments)
+ {
+ $return = null;
+ return $return;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/RowGateway/RowGatewayInterface.php zendframework-2.2.6/library/Zend/Db/RowGateway/RowGatewayInterface.php
--- zendframework-1.10.4/library/Zend/Db/RowGateway/RowGatewayInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/RowGateway/RowGatewayInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,16 @@
+primaryKeyColumn = (array) $primaryKeyColumn;
+
+ // set table
+ $this->table = $table;
+
+ // set Sql object
+ if ($adapterOrSql instanceof Sql) {
+ $this->sql = $adapterOrSql;
+ } elseif ($adapterOrSql instanceof Adapter) {
+ $this->sql = new Sql($adapterOrSql, $this->table);
+ } else {
+ throw new Exception\InvalidArgumentException('A valid Sql object was not provided.');
+ }
+
+ if ($this->sql->getTable() !== $this->table) {
+ throw new Exception\InvalidArgumentException('The Sql object provided does not have a table that matches this row object');
+ }
+
+ $this->initialize();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Select/Exception.php zendframework-2.2.6/library/Zend/Db/Select/Exception.php
--- zendframework-1.10.4/library/Zend/Db/Select/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Select/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,39 +0,0 @@
- false,
- self::COLUMNS => array(),
- self::UNION => array(),
- self::FROM => array(),
- self::WHERE => array(),
- self::GROUP => array(),
- self::HAVING => array(),
- self::ORDER => array(),
- self::LIMIT_COUNT => null,
- self::LIMIT_OFFSET => null,
- self::FOR_UPDATE => false
- );
-
- /**
- * Specify legal join types.
- *
- * @var array
- */
- protected static $_joinTypes = array(
- self::INNER_JOIN,
- self::LEFT_JOIN,
- self::RIGHT_JOIN,
- self::FULL_JOIN,
- self::CROSS_JOIN,
- self::NATURAL_JOIN,
- );
-
- /**
- * Specify legal union types.
- *
- * @var array
- */
- protected static $_unionTypes = array(
- self::SQL_UNION,
- self::SQL_UNION_ALL
- );
-
- /**
- * The component parts of a SELECT statement.
- * Initialized to the $_partsInit array in the constructor.
- *
- * @var array
- */
- protected $_parts = array();
-
- /**
- * Tracks which columns are being select from each table and join.
- *
- * @var array
- */
- protected $_tableCols = array();
-
- /**
- * Class constructor
- *
- * @param Zend_Db_Adapter_Abstract $adapter
- */
- public function __construct(Zend_Db_Adapter_Abstract $adapter)
- {
- $this->_adapter = $adapter;
- $this->_parts = self::$_partsInit;
- }
-
- /**
- * Get bind variables
- *
- * @return array
- */
- public function getBind()
- {
- return $this->_bind;
- }
-
- /**
- * Set bind variables
- *
- * @param mixed $bind
- * @return Zend_Db_Select
- */
- public function bind($bind)
- {
- $this->_bind = $bind;
-
- return $this;
- }
-
- /**
- * Makes the query SELECT DISTINCT.
- *
- * @param bool $flag Whether or not the SELECT is DISTINCT (default true).
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function distinct($flag = true)
- {
- $this->_parts[self::DISTINCT] = (bool) $flag;
- return $this;
- }
-
- /**
- * Adds a FROM table and optional columns to the query.
- *
- * The first parameter $name can be a simple string, in which case the
- * correlation name is generated automatically. If you want to specify
- * the correlation name, the first parameter must be an associative
- * array in which the key is the physical table name, and the value is
- * the correlation name. For example, array('table' => 'alias').
- * The correlation name is prepended to all columns fetched for this
- * table.
- *
- * The second parameter can be a single string or Zend_Db_Expr object,
- * or else an array of strings or Zend_Db_Expr objects.
- *
- * The first parameter can be null or an empty string, in which case
- * no correlation name is generated or prepended to the columns named
- * in the second parameter.
- *
- * @param array|string|Zend_Db_Expr $name The table name or an associative array relating table name to
- * correlation name.
- * @param array|string|Zend_Db_Expr $cols The columns to select from this table.
- * @param string $schema The schema name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function from($name, $cols = '*', $schema = null)
- {
- return $this->_join(self::FROM, $name, null, $cols, $schema);
- }
-
- /**
- * Specifies the columns used in the FROM clause.
- *
- * The parameter can be a single string or Zend_Db_Expr object,
- * or else an array of strings or Zend_Db_Expr objects.
- *
- * @param array|string|Zend_Db_Expr $cols The columns to select from this table.
- * @param string $correlationName Correlation name of target table. OPTIONAL
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function columns($cols = '*', $correlationName = null)
- {
- if ($correlationName === null && count($this->_parts[self::FROM])) {
- $correlationNameKeys = array_keys($this->_parts[self::FROM]);
- $correlationName = current($correlationNameKeys);
- }
-
- if (!array_key_exists($correlationName, $this->_parts[self::FROM])) {
- /**
- * @see Zend_Db_Select_Exception
- */
- require_once 'Zend/Db/Select/Exception.php';
- throw new Zend_Db_Select_Exception("No table has been specified for the FROM clause");
- }
-
- $this->_tableCols($correlationName, $cols);
-
- return $this;
- }
-
- /**
- * Adds a UNION clause to the query.
- *
- * The first parameter has to be an array of Zend_Db_Select or
- * sql query strings.
- *
- *
- * $sql1 = $db->select();
- * $sql2 = "SELECT ...";
- * $select = $db->select()
- * ->union(array($sql1, $sql2))
- * ->order("id");
- *
- *
- * @param array $select Array of select clauses for the union.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function union($select = array(), $type = self::SQL_UNION)
- {
- if (!is_array($select)) {
- require_once 'Zend/Db/Select/Exception.php';
- throw new Zend_Db_Select_Exception(
- "union() only accepts an array of Zend_Db_Select instances of sql query strings."
- );
- }
-
- if (!in_array($type, self::$_unionTypes)) {
- require_once 'Zend/Db/Select/Exception.php';
- throw new Zend_Db_Select_Exception("Invalid union type '{$type}'");
- }
-
- foreach ($select as $target) {
- $this->_parts[self::UNION][] = array($target, $type);
- }
-
- return $this;
- }
-
- /**
- * Adds a JOIN table and columns to the query.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param string $cond Join on this condition.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function join($name, $cond, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->joinInner($name, $cond, $cols, $schema);
- }
-
- /**
- * Add an INNER JOIN table and colums to the query
- * Rows in both tables are matched according to the expression
- * in the $cond argument. The result set is comprised
- * of all cases where rows from the left table match
- * rows from the right table.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param string $cond Join on this condition.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function joinInner($name, $cond, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->_join(self::INNER_JOIN, $name, $cond, $cols, $schema);
- }
-
- /**
- * Add a LEFT OUTER JOIN table and colums to the query
- * All rows from the left operand table are included,
- * matching rows from the right operand table included,
- * and the columns from the right operand table are filled
- * with NULLs if no row exists matching the left table.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param string $cond Join on this condition.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function joinLeft($name, $cond, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->_join(self::LEFT_JOIN, $name, $cond, $cols, $schema);
- }
-
- /**
- * Add a RIGHT OUTER JOIN table and colums to the query.
- * Right outer join is the complement of left outer join.
- * All rows from the right operand table are included,
- * matching rows from the left operand table included,
- * and the columns from the left operand table are filled
- * with NULLs if no row exists matching the right table.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param string $cond Join on this condition.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function joinRight($name, $cond, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->_join(self::RIGHT_JOIN, $name, $cond, $cols, $schema);
- }
-
- /**
- * Add a FULL OUTER JOIN table and colums to the query.
- * A full outer join is like combining a left outer join
- * and a right outer join. All rows from both tables are
- * included, paired with each other on the same row of the
- * result set if they satisfy the join condition, and otherwise
- * paired with NULLs in place of columns from the other table.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param string $cond Join on this condition.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function joinFull($name, $cond, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->_join(self::FULL_JOIN, $name, $cond, $cols, $schema);
- }
-
- /**
- * Add a CROSS JOIN table and colums to the query.
- * A cross join is a cartesian product; there is no join condition.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function joinCross($name, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->_join(self::CROSS_JOIN, $name, null, $cols, $schema);
- }
-
- /**
- * Add a NATURAL JOIN table and colums to the query.
- * A natural join assumes an equi-join across any column(s)
- * that appear with the same name in both tables.
- * Only natural inner joins are supported by this API,
- * even though SQL permits natural outer joins as well.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param array|string|Zend_Db_Expr $name The table name.
- * @param array|string $cols The columns to select from the joined table.
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function joinNatural($name, $cols = self::SQL_WILDCARD, $schema = null)
- {
- return $this->_join(self::NATURAL_JOIN, $name, null, $cols, $schema);
- }
-
- /**
- * Adds a WHERE condition to the query by AND.
- *
- * If a value is passed as the second param, it will be quoted
- * and replaced into the condition wherever a question-mark
- * appears. Array values are quoted and comma-separated.
- *
- *
- * // simplest but non-secure
- * $select->where("id = $id");
- *
- * // secure (ID is quoted but matched anyway)
- * $select->where('id = ?', $id);
- *
- * // alternatively, with named binding
- * $select->where('id = :id');
- *
- *
- * Note that it is more correct to use named bindings in your
- * queries for values other than strings. When you use named
- * bindings, don't forget to pass the values when actually
- * making a query:
- *
- *
- * $db->fetchAll($select, array('id' => 5));
- *
- *
- * @param string $cond The WHERE condition.
- * @param mixed $value OPTIONAL The value to quote into the condition.
- * @param constant $type OPTIONAL The type of the given value
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function where($cond, $value = null, $type = null)
- {
- $this->_parts[self::WHERE][] = $this->_where($cond, $value, $type, true);
-
- return $this;
- }
-
- /**
- * Adds a WHERE condition to the query by OR.
- *
- * Otherwise identical to where().
- *
- * @param string $cond The WHERE condition.
- * @param mixed $value OPTIONAL The value to quote into the condition.
- * @param constant $type OPTIONAL The type of the given value
- * @return Zend_Db_Select This Zend_Db_Select object.
- *
- * @see where()
- */
- public function orWhere($cond, $value = null, $type = null)
- {
- $this->_parts[self::WHERE][] = $this->_where($cond, $value, $type, false);
-
- return $this;
- }
-
- /**
- * Adds grouping to the query.
- *
- * @param array|string $spec The column(s) to group by.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function group($spec)
- {
- if (!is_array($spec)) {
- $spec = array($spec);
- }
-
- foreach ($spec as $val) {
- if (preg_match('/\(.*\)/', (string) $val)) {
- $val = new Zend_Db_Expr($val);
- }
- $this->_parts[self::GROUP][] = $val;
- }
-
- return $this;
- }
-
- /**
- * Adds a HAVING condition to the query by AND.
- *
- * If a value is passed as the second param, it will be quoted
- * and replaced into the condition wherever a question-mark
- * appears. See {@link where()} for an example
- *
- * @param string $cond The HAVING condition.
- * @param string|Zend_Db_Expr $val The value to quote into the condition.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function having($cond)
- {
- if (func_num_args() > 1) {
- $val = func_get_arg(1);
- $cond = $this->_adapter->quoteInto($cond, $val);
- }
-
- if ($this->_parts[self::HAVING]) {
- $this->_parts[self::HAVING][] = self::SQL_AND . " ($cond)";
- } else {
- $this->_parts[self::HAVING][] = "($cond)";
- }
-
- return $this;
- }
-
- /**
- * Adds a HAVING condition to the query by OR.
- *
- * Otherwise identical to orHaving().
- *
- * @param string $cond The HAVING condition.
- * @param mixed $val The value to quote into the condition.
- * @return Zend_Db_Select This Zend_Db_Select object.
- *
- * @see having()
- */
- public function orHaving($cond)
- {
- if (func_num_args() > 1) {
- $val = func_get_arg(1);
- $cond = $this->_adapter->quoteInto($cond, $val);
- }
-
- if ($this->_parts[self::HAVING]) {
- $this->_parts[self::HAVING][] = self::SQL_OR . " ($cond)";
- } else {
- $this->_parts[self::HAVING][] = "($cond)";
- }
-
- return $this;
- }
-
- /**
- * Adds a row order to the query.
- *
- * @param mixed $spec The column(s) and direction to order by.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function order($spec)
- {
- if (!is_array($spec)) {
- $spec = array($spec);
- }
-
- // force 'ASC' or 'DESC' on each order spec, default is ASC.
- foreach ($spec as $val) {
- if ($val instanceof Zend_Db_Expr) {
- $expr = $val->__toString();
- if (empty($expr)) {
- continue;
- }
- $this->_parts[self::ORDER][] = $val;
- } else {
- if (empty($val)) {
- continue;
- }
- $direction = self::SQL_ASC;
- if (preg_match('/(.*\W)(' . self::SQL_ASC . '|' . self::SQL_DESC . ')\b/si', $val, $matches)) {
- $val = trim($matches[1]);
- $direction = $matches[2];
- }
- if (preg_match('/\(.*\)/', $val)) {
- $val = new Zend_Db_Expr($val);
- }
- $this->_parts[self::ORDER][] = array($val, $direction);
- }
- }
-
- return $this;
- }
-
- /**
- * Sets a limit count and offset to the query.
- *
- * @param int $count OPTIONAL The number of rows to return.
- * @param int $offset OPTIONAL Start returning after this many rows.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function limit($count = null, $offset = null)
- {
- $this->_parts[self::LIMIT_COUNT] = (int) $count;
- $this->_parts[self::LIMIT_OFFSET] = (int) $offset;
- return $this;
- }
-
- /**
- * Sets the limit and count by page number.
- *
- * @param int $page Limit results to this page number.
- * @param int $rowCount Use this many rows per page.
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function limitPage($page, $rowCount)
- {
- $page = ($page > 0) ? $page : 1;
- $rowCount = ($rowCount > 0) ? $rowCount : 1;
- $this->_parts[self::LIMIT_COUNT] = (int) $rowCount;
- $this->_parts[self::LIMIT_OFFSET] = (int) $rowCount * ($page - 1);
- return $this;
- }
-
- /**
- * Makes the query SELECT FOR UPDATE.
- *
- * @param bool $flag Whether or not the SELECT is FOR UPDATE (default true).
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function forUpdate($flag = true)
- {
- $this->_parts[self::FOR_UPDATE] = (bool) $flag;
- return $this;
- }
-
- /**
- * Get part of the structured information for the currect query.
- *
- * @param string $part
- * @return mixed
- * @throws Zend_Db_Select_Exception
- */
- public function getPart($part)
- {
- $part = strtolower($part);
- if (!array_key_exists($part, $this->_parts)) {
- require_once 'Zend/Db/Select/Exception.php';
- throw new Zend_Db_Select_Exception("Invalid Select part '$part'");
- }
- return $this->_parts[$part];
- }
-
- /**
- * Executes the current select object and returns the result
- *
- * @param integer $fetchMode OPTIONAL
- * @param mixed $bind An array of data to bind to the placeholders.
- * @return PDO_Statement|Zend_Db_Statement
- */
- public function query($fetchMode = null, $bind = array())
- {
- if (!empty($bind)) {
- $this->bind($bind);
- }
-
- $stmt = $this->_adapter->query($this);
- if ($fetchMode == null) {
- $fetchMode = $this->_adapter->getFetchMode();
- }
- $stmt->setFetchMode($fetchMode);
- return $stmt;
- }
-
- /**
- * Converts this object to an SQL SELECT string.
- *
- * @return string|null This object as a SELECT string. (or null if a string cannot be produced.)
- */
- public function assemble()
- {
- $sql = self::SQL_SELECT;
- foreach (array_keys(self::$_partsInit) as $part) {
- $method = '_render' . ucfirst($part);
- if (method_exists($this, $method)) {
- $sql = $this->$method($sql);
- }
- }
- return $sql;
- }
-
- /**
- * Clear parts of the Select object, or an individual part.
- *
- * @param string $part OPTIONAL
- * @return Zend_Db_Select
- */
- public function reset($part = null)
- {
- if ($part == null) {
- $this->_parts = self::$_partsInit;
- } else if (array_key_exists($part, self::$_partsInit)) {
- $this->_parts[$part] = self::$_partsInit[$part];
- }
- return $this;
- }
-
- /**
- * Gets the Zend_Db_Adapter_Abstract for this
- * particular Zend_Db_Select object.
- *
- * @return Zend_Db_Adapter_Abstract
- */
- public function getAdapter()
- {
- return $this->_adapter;
- }
-
- /**
- * Populate the {@link $_parts} 'join' key
- *
- * Does the dirty work of populating the join key.
- *
- * The $name and $cols parameters follow the same logic
- * as described in the from() method.
- *
- * @param null|string $type Type of join; inner, left, and null are currently supported
- * @param array|string|Zend_Db_Expr $name Table name
- * @param string $cond Join on this condition
- * @param array|string $cols The columns to select from the joined table
- * @param string $schema The database name to specify, if any.
- * @return Zend_Db_Select This Zend_Db_Select object
- * @throws Zend_Db_Select_Exception
- */
- protected function _join($type, $name, $cond, $cols, $schema = null)
- {
- if (!in_array($type, self::$_joinTypes) && $type != self::FROM) {
- /**
- * @see Zend_Db_Select_Exception
- */
- require_once 'Zend/Db/Select/Exception.php';
- throw new Zend_Db_Select_Exception("Invalid join type '$type'");
- }
-
- if (count($this->_parts[self::UNION])) {
- require_once 'Zend/Db/Select/Exception.php';
- throw new Zend_Db_Select_Exception("Invalid use of table with " . self::SQL_UNION);
- }
-
- if (empty($name)) {
- $correlationName = $tableName = '';
- } else if (is_array($name)) {
- // Must be array($correlationName => $tableName) or array($ident, ...)
- foreach ($name as $_correlationName => $_tableName) {
- if (is_string($_correlationName)) {
- // We assume the key is the correlation name and value is the table name
- $tableName = $_tableName;
- $correlationName = $_correlationName;
- } else {
- // We assume just an array of identifiers, with no correlation name
- $tableName = $_tableName;
- $correlationName = $this->_uniqueCorrelation($tableName);
- }
- break;
- }
- } else if ($name instanceof Zend_Db_Expr|| $name instanceof Zend_Db_Select) {
- $tableName = $name;
- $correlationName = $this->_uniqueCorrelation('t');
- } else if (preg_match('/^(.+)\s+AS\s+(.+)$/i', $name, $m)) {
- $tableName = $m[1];
- $correlationName = $m[2];
- } else {
- $tableName = $name;
- $correlationName = $this->_uniqueCorrelation($tableName);
- }
-
- // Schema from table name overrides schema argument
- if (!is_object($tableName) && false !== strpos($tableName, '.')) {
- list($schema, $tableName) = explode('.', $tableName);
- }
-
- $lastFromCorrelationName = null;
- if (!empty($correlationName)) {
- if (array_key_exists($correlationName, $this->_parts[self::FROM])) {
- /**
- * @see Zend_Db_Select_Exception
- */
- require_once 'Zend/Db/Select/Exception.php';
- throw new Zend_Db_Select_Exception("You cannot define a correlation name '$correlationName' more than once");
- }
-
- if ($type == self::FROM) {
- // append this from after the last from joinType
- $tmpFromParts = $this->_parts[self::FROM];
- $this->_parts[self::FROM] = array();
- // move all the froms onto the stack
- while ($tmpFromParts) {
- $currentCorrelationName = key($tmpFromParts);
- if ($tmpFromParts[$currentCorrelationName]['joinType'] != self::FROM) {
- break;
- }
- $lastFromCorrelationName = $currentCorrelationName;
- $this->_parts[self::FROM][$currentCorrelationName] = array_shift($tmpFromParts);
- }
- } else {
- $tmpFromParts = array();
- }
- $this->_parts[self::FROM][$correlationName] = array(
- 'joinType' => $type,
- 'schema' => $schema,
- 'tableName' => $tableName,
- 'joinCondition' => $cond
- );
- while ($tmpFromParts) {
- $currentCorrelationName = key($tmpFromParts);
- $this->_parts[self::FROM][$currentCorrelationName] = array_shift($tmpFromParts);
- }
- }
-
- // add to the columns from this joined table
- if ($type == self::FROM && $lastFromCorrelationName == null) {
- $lastFromCorrelationName = true;
- }
- $this->_tableCols($correlationName, $cols, $lastFromCorrelationName);
-
- return $this;
- }
-
- /**
- * Handle JOIN... USING... syntax
- *
- * This is functionality identical to the existing JOIN methods, however
- * the join condition can be passed as a single column name. This method
- * then completes the ON condition by using the same field for the FROM
- * table and the JOIN table.
- *
- *
- * $select = $db->select()->from('table1')
- * ->joinUsing('table2', 'column1');
- *
- * // SELECT * FROM table1 JOIN table2 ON table1.column1 = table2.column2
- *
- *
- * These joins are called by the developer simply by adding 'Using' to the
- * method name. E.g.
- * * joinUsing
- * * joinInnerUsing
- * * joinFullUsing
- * * joinRightUsing
- * * joinLeftUsing
- *
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function _joinUsing($type, $name, $cond, $cols = '*', $schema = null)
- {
- if (empty($this->_parts[self::FROM])) {
- require_once 'Zend/Db/Select/Exception.php';
- throw new Zend_Db_Select_Exception("You can only perform a joinUsing after specifying a FROM table");
- }
-
- $join = $this->_adapter->quoteIdentifier(key($this->_parts[self::FROM]), true);
- $from = $this->_adapter->quoteIdentifier($this->_uniqueCorrelation($name), true);
-
- $cond1 = $from . '.' . $cond;
- $cond2 = $join . '.' . $cond;
- $cond = $cond1 . ' = ' . $cond2;
-
- return $this->_join($type, $name, $cond, $cols, $schema);
- }
-
- /**
- * Generate a unique correlation name
- *
- * @param string|array $name A qualified identifier.
- * @return string A unique correlation name.
- */
- private function _uniqueCorrelation($name)
- {
- if (is_array($name)) {
- $c = end($name);
- } else {
- // Extract just the last name of a qualified table name
- $dot = strrpos($name,'.');
- $c = ($dot === false) ? $name : substr($name, $dot+1);
- }
- for ($i = 2; array_key_exists($c, $this->_parts[self::FROM]); ++$i) {
- $c = $name . '_' . (string) $i;
- }
- return $c;
- }
-
- /**
- * Adds to the internal table-to-column mapping array.
- *
- * @param string $tbl The table/join the columns come from.
- * @param array|string $cols The list of columns; preferably as
- * an array, but possibly as a string containing one column.
- * @param bool|string True if it should be prepended, a correlation name if it should be inserted
- * @return void
- */
- protected function _tableCols($correlationName, $cols, $afterCorrelationName = null)
- {
- if (!is_array($cols)) {
- $cols = array($cols);
- }
-
- if ($correlationName == null) {
- $correlationName = '';
- }
-
- $columnValues = array();
-
- foreach (array_filter($cols) as $alias => $col) {
- $currentCorrelationName = $correlationName;
- if (is_string($col)) {
- // Check for a column matching " AS " and extract the alias name
- if (preg_match('/^(.+)\s+' . self::SQL_AS . '\s+(.+)$/i', $col, $m)) {
- $col = $m[1];
- $alias = $m[2];
- }
- // Check for columns that look like functions and convert to Zend_Db_Expr
- if (preg_match('/\(.*\)/', $col)) {
- $col = new Zend_Db_Expr($col);
- } elseif (preg_match('/(.+)\.(.+)/', $col, $m)) {
- $currentCorrelationName = $m[1];
- $col = $m[2];
- }
- }
- $columnValues[] = array($currentCorrelationName, $col, is_string($alias) ? $alias : null);
- }
-
- if ($columnValues) {
-
- // should we attempt to prepend or insert these values?
- if ($afterCorrelationName === true || is_string($afterCorrelationName)) {
- $tmpColumns = $this->_parts[self::COLUMNS];
- $this->_parts[self::COLUMNS] = array();
- } else {
- $tmpColumns = array();
- }
-
- // find the correlation name to insert after
- if (is_string($afterCorrelationName)) {
- while ($tmpColumns) {
- $this->_parts[self::COLUMNS][] = $currentColumn = array_shift($tmpColumns);
- if ($currentColumn[0] == $afterCorrelationName) {
- break;
- }
- }
- }
-
- // apply current values to current stack
- foreach ($columnValues as $columnValue) {
- array_push($this->_parts[self::COLUMNS], $columnValue);
- }
-
- // finish ensuring that all previous values are applied (if they exist)
- while ($tmpColumns) {
- array_push($this->_parts[self::COLUMNS], array_shift($tmpColumns));
- }
- }
- }
-
- /**
- * Internal function for creating the where clause
- *
- * @param string $condition
- * @param mixed $value optional
- * @param string $type optional
- * @param boolean $bool true = AND, false = OR
- * @return string clause
- */
- protected function _where($condition, $value = null, $type = null, $bool = true)
- {
- if (count($this->_parts[self::UNION])) {
- require_once 'Zend/Db/Select/Exception.php';
- throw new Zend_Db_Select_Exception("Invalid use of where clause with " . self::SQL_UNION);
- }
-
- if ($value !== null) {
- $condition = $this->_adapter->quoteInto($condition, $value, $type);
- }
-
- $cond = "";
- if ($this->_parts[self::WHERE]) {
- if ($bool === true) {
- $cond = self::SQL_AND . ' ';
- } else {
- $cond = self::SQL_OR . ' ';
- }
- }
-
- return $cond . "($condition)";
- }
-
- /**
- * @return array
- */
- protected function _getDummyTable()
- {
- return array();
- }
-
- /**
- * Return a quoted schema name
- *
- * @param string $schema The schema name OPTIONAL
- * @return string|null
- */
- protected function _getQuotedSchema($schema = null)
- {
- if ($schema === null) {
- return null;
- }
- return $this->_adapter->quoteIdentifier($schema, true) . '.';
- }
-
- /**
- * Return a quoted table name
- *
- * @param string $tableName The table name
- * @param string $correlationName The correlation name OPTIONAL
- * @return string
- */
- protected function _getQuotedTable($tableName, $correlationName = null)
- {
- return $this->_adapter->quoteTableAs($tableName, $correlationName, true);
- }
-
- /**
- * Render DISTINCT clause
- *
- * @param string $sql SQL query
- * @return string
- */
- protected function _renderDistinct($sql)
- {
- if ($this->_parts[self::DISTINCT]) {
- $sql .= ' ' . self::SQL_DISTINCT;
- }
-
- return $sql;
- }
-
- /**
- * Render DISTINCT clause
- *
- * @param string $sql SQL query
- * @return string|null
- */
- protected function _renderColumns($sql)
- {
- if (!count($this->_parts[self::COLUMNS])) {
- return null;
- }
-
- $columns = array();
- foreach ($this->_parts[self::COLUMNS] as $columnEntry) {
- list($correlationName, $column, $alias) = $columnEntry;
- if ($column instanceof Zend_Db_Expr) {
- $columns[] = $this->_adapter->quoteColumnAs($column, $alias, true);
- } else {
- if ($column == self::SQL_WILDCARD) {
- $column = new Zend_Db_Expr(self::SQL_WILDCARD);
- $alias = null;
- }
- if (empty($correlationName)) {
- $columns[] = $this->_adapter->quoteColumnAs($column, $alias, true);
- } else {
- $columns[] = $this->_adapter->quoteColumnAs(array($correlationName, $column), $alias, true);
- }
- }
- }
-
- return $sql .= ' ' . implode(', ', $columns);
- }
-
- /**
- * Render FROM clause
- *
- * @param string $sql SQL query
- * @return string
- */
- protected function _renderFrom($sql)
- {
- /*
- * If no table specified, use RDBMS-dependent solution
- * for table-less query. e.g. DUAL in Oracle.
- */
- if (empty($this->_parts[self::FROM])) {
- $this->_parts[self::FROM] = $this->_getDummyTable();
- }
-
- $from = array();
-
- foreach ($this->_parts[self::FROM] as $correlationName => $table) {
- $tmp = '';
-
- $joinType = ($table['joinType'] == self::FROM) ? self::INNER_JOIN : $table['joinType'];
-
- // Add join clause (if applicable)
- if (! empty($from)) {
- $tmp .= ' ' . strtoupper($joinType) . ' ';
- }
-
- $tmp .= $this->_getQuotedSchema($table['schema']);
- $tmp .= $this->_getQuotedTable($table['tableName'], $correlationName);
-
- // Add join conditions (if applicable)
- if (!empty($from) && ! empty($table['joinCondition'])) {
- $tmp .= ' ' . self::SQL_ON . ' ' . $table['joinCondition'];
- }
-
- // Add the table name and condition add to the list
- $from[] = $tmp;
- }
-
- // Add the list of all joins
- if (!empty($from)) {
- $sql .= ' ' . self::SQL_FROM . ' ' . implode("\n", $from);
- }
-
- return $sql;
- }
-
- /**
- * Render UNION query
- *
- * @param string $sql SQL query
- * @return string
- */
- protected function _renderUnion($sql)
- {
- if ($this->_parts[self::UNION]) {
- $parts = count($this->_parts[self::UNION]);
- foreach ($this->_parts[self::UNION] as $cnt => $union) {
- list($target, $type) = $union;
- if ($target instanceof Zend_Db_Select) {
- $target = $target->assemble();
- }
- $sql .= $target;
- if ($cnt < $parts - 1) {
- $sql .= ' ' . $type . ' ';
- }
- }
- }
-
- return $sql;
- }
-
- /**
- * Render WHERE clause
- *
- * @param string $sql SQL query
- * @return string
- */
- protected function _renderWhere($sql)
- {
- if ($this->_parts[self::FROM] && $this->_parts[self::WHERE]) {
- $sql .= ' ' . self::SQL_WHERE . ' ' . implode(' ', $this->_parts[self::WHERE]);
- }
-
- return $sql;
- }
-
- /**
- * Render GROUP clause
- *
- * @param string $sql SQL query
- * @return string
- */
- protected function _renderGroup($sql)
- {
- if ($this->_parts[self::FROM] && $this->_parts[self::GROUP]) {
- $group = array();
- foreach ($this->_parts[self::GROUP] as $term) {
- $group[] = $this->_adapter->quoteIdentifier($term, true);
- }
- $sql .= ' ' . self::SQL_GROUP_BY . ' ' . implode(",\n\t", $group);
- }
-
- return $sql;
- }
-
- /**
- * Render HAVING clause
- *
- * @param string $sql SQL query
- * @return string
- */
- protected function _renderHaving($sql)
- {
- if ($this->_parts[self::FROM] && $this->_parts[self::HAVING]) {
- $sql .= ' ' . self::SQL_HAVING . ' ' . implode(' ', $this->_parts[self::HAVING]);
- }
-
- return $sql;
- }
-
- /**
- * Render ORDER clause
- *
- * @param string $sql SQL query
- * @return string
- */
- protected function _renderOrder($sql)
- {
- if ($this->_parts[self::ORDER]) {
- $order = array();
- foreach ($this->_parts[self::ORDER] as $term) {
- if (is_array($term)) {
- if(is_numeric($term[0]) && strval(intval($term[0])) == $term[0]) {
- $order[] = (int)trim($term[0]) . ' ' . $term[1];
- } else {
- $order[] = $this->_adapter->quoteIdentifier($term[0], true) . ' ' . $term[1];
- }
- } else if (is_numeric($term) && strval(intval($term)) == $term) {
- $order[] = (int)trim($term);
- } else {
- $order[] = $this->_adapter->quoteIdentifier($term, true);
- }
- }
- $sql .= ' ' . self::SQL_ORDER_BY . ' ' . implode(', ', $order);
- }
-
- return $sql;
- }
-
- /**
- * Render LIMIT OFFSET clause
- *
- * @param string $sql SQL query
- * @return string
- */
- protected function _renderLimitoffset($sql)
- {
- $count = 0;
- $offset = 0;
-
- if (!empty($this->_parts[self::LIMIT_OFFSET])) {
- $offset = (int) $this->_parts[self::LIMIT_OFFSET];
- $count = PHP_INT_MAX;
- }
-
- if (!empty($this->_parts[self::LIMIT_COUNT])) {
- $count = (int) $this->_parts[self::LIMIT_COUNT];
- }
-
- /*
- * Add limits clause
- */
- if ($count > 0) {
- $sql = trim($this->_adapter->limit($sql, $count, $offset));
- }
-
- return $sql;
- }
-
- /**
- * Render FOR UPDATE clause
- *
- * @param string $sql SQL query
- * @return string
- */
- protected function _renderForupdate($sql)
- {
- if ($this->_parts[self::FOR_UPDATE]) {
- $sql .= ' ' . self::SQL_FOR_UPDATE;
- }
-
- return $sql;
- }
-
- /**
- * Turn magic function calls into non-magic function calls
- * for joinUsing syntax
- *
- * @param string $method
- * @param array $args OPTIONAL Zend_Db_Table_Select query modifier
- * @return Zend_Db_Select
- * @throws Zend_Db_Select_Exception If an invalid method is called.
- */
- public function __call($method, array $args)
- {
- $matches = array();
-
- /**
- * Recognize methods for Has-Many cases:
- * findParent()
- * findParentBy()
- * Use the non-greedy pattern repeat modifier e.g. \w+?
- */
- if (preg_match('/^join([a-zA-Z]*?)Using$/', $method, $matches)) {
- $type = strtolower($matches[1]);
- if ($type) {
- $type .= ' join';
- if (!in_array($type, self::$_joinTypes)) {
- require_once 'Zend/Db/Select/Exception.php';
- throw new Zend_Db_Select_Exception("Unrecognized method '$method()'");
- }
- if (in_array($type, array(self::CROSS_JOIN, self::NATURAL_JOIN))) {
- require_once 'Zend/Db/Select/Exception.php';
- throw new Zend_Db_Select_Exception("Cannot perform a joinUsing with method '$method()'");
- }
- } else {
- $type = self::INNER_JOIN;
- }
- array_unshift($args, $type);
- return call_user_func_array(array($this, '_joinUsing'), $args);
- }
-
- require_once 'Zend/Db/Select/Exception.php';
- throw new Zend_Db_Select_Exception("Unrecognized method '$method()'");
- }
-
- /**
- * Implements magic method.
- *
- * @return string This object as a SELECT string.
- */
- public function __toString()
- {
- try {
- $sql = $this->assemble();
- } catch (Exception $e) {
- trigger_error($e->getMessage(), E_USER_WARNING);
- $sql = '';
- }
- return (string)$sql;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/AbstractSql.php zendframework-2.2.6/library/Zend/Db/Sql/AbstractSql.php
--- zendframework-1.10.4/library/Zend/Db/Sql/AbstractSql.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/AbstractSql.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,188 @@
+ '', 'subselectCount' => 0);
+
+ /**
+ * @var array
+ */
+ protected $instanceParameterIndex = array();
+
+ protected function processExpression(ExpressionInterface $expression, PlatformInterface $platform, DriverInterface $driver = null, $namedParameterPrefix = null)
+ {
+ // static counter for the number of times this method was invoked across the PHP runtime
+ static $runtimeExpressionPrefix = 0;
+
+ if ($driver && ((!is_string($namedParameterPrefix) || $namedParameterPrefix == ''))) {
+ $namedParameterPrefix = sprintf('expr%04dParam', ++$runtimeExpressionPrefix);
+ }
+
+ $sql = '';
+ $statementContainer = new StatementContainer;
+ $parameterContainer = $statementContainer->getParameterContainer();
+
+ // initialize variables
+ $parts = $expression->getExpressionData();
+
+ if (!isset($this->instanceParameterIndex[$namedParameterPrefix])) {
+ $this->instanceParameterIndex[$namedParameterPrefix] = 1;
+ }
+
+ $expressionParamIndex = &$this->instanceParameterIndex[$namedParameterPrefix];
+
+ foreach ($parts as $part) {
+
+ // if it is a string, simply tack it onto the return sql "specification" string
+ if (is_string($part)) {
+ $sql .= $part;
+ continue;
+ }
+
+ if (!is_array($part)) {
+ throw new Exception\RuntimeException('Elements returned from getExpressionData() array must be a string or array.');
+ }
+
+ // process values and types (the middle and last position of the expression data)
+ $values = $part[1];
+ $types = (isset($part[2])) ? $part[2] : array();
+ foreach ($values as $vIndex => $value) {
+ if (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_IDENTIFIER) {
+ $values[$vIndex] = $platform->quoteIdentifierInFragment($value);
+ } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_VALUE && $value instanceof Select) {
+ // process sub-select
+ if ($driver) {
+ $values[$vIndex] = '(' . $this->processSubSelect($value, $platform, $driver, $parameterContainer) . ')';
+ } else {
+ $values[$vIndex] = '(' . $this->processSubSelect($value, $platform) . ')';
+ }
+ } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_VALUE && $value instanceof ExpressionInterface) {
+ // recursive call to satisfy nested expressions
+ $innerStatementContainer = $this->processExpression($value, $platform, $driver, $namedParameterPrefix . $vIndex . 'subpart');
+ $values[$vIndex] = $innerStatementContainer->getSql();
+ if ($driver) {
+ $parameterContainer->merge($innerStatementContainer->getParameterContainer());
+ }
+ } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_VALUE) {
+
+ // if prepareType is set, it means that this particular value must be
+ // passed back to the statement in a way it can be used as a placeholder value
+ if ($driver) {
+ $name = $namedParameterPrefix . $expressionParamIndex++;
+ $parameterContainer->offsetSet($name, $value);
+ $values[$vIndex] = $driver->formatParameterName($name);
+ continue;
+ }
+
+ // if not a preparable statement, simply quote the value and move on
+ $values[$vIndex] = $platform->quoteValue($value);
+ } elseif (isset($types[$vIndex]) && $types[$vIndex] == ExpressionInterface::TYPE_LITERAL) {
+ $values[$vIndex] = $value;
+ }
+ }
+
+ // after looping the values, interpolate them into the sql string (they might be placeholder names, or values)
+ $sql .= vsprintf($part[0], $values);
+ }
+
+ $statementContainer->setSql($sql);
+ return $statementContainer;
+ }
+
+ /**
+ * @param $specifications
+ * @param $parameters
+ * @return string
+ * @throws Exception\RuntimeException
+ */
+ protected function createSqlFromSpecificationAndParameters($specifications, $parameters)
+ {
+ if (is_string($specifications)) {
+ return vsprintf($specifications, $parameters);
+ }
+
+ $parametersCount = count($parameters);
+ foreach ($specifications as $specificationString => $paramSpecs) {
+ if ($parametersCount == count($paramSpecs)) {
+ break;
+ }
+ unset($specificationString, $paramSpecs);
+ }
+
+ if (!isset($specificationString)) {
+ throw new Exception\RuntimeException(
+ 'A number of parameters was found that is not supported by this specification'
+ );
+ }
+
+ $topParameters = array();
+ foreach ($parameters as $position => $paramsForPosition) {
+ if (isset($paramSpecs[$position]['combinedby'])) {
+ $multiParamValues = array();
+ foreach ($paramsForPosition as $multiParamsForPosition) {
+ $ppCount = count($multiParamsForPosition);
+ if (!isset($paramSpecs[$position][$ppCount])) {
+ throw new Exception\RuntimeException('A number of parameters (' . $ppCount . ') was found that is not supported by this specification');
+ }
+ $multiParamValues[] = vsprintf($paramSpecs[$position][$ppCount], $multiParamsForPosition);
+ }
+ $topParameters[] = implode($paramSpecs[$position]['combinedby'], $multiParamValues);
+ } elseif ($paramSpecs[$position] !== null) {
+ $ppCount = count($paramsForPosition);
+ if (!isset($paramSpecs[$position][$ppCount])) {
+ throw new Exception\RuntimeException('A number of parameters (' . $ppCount . ') was found that is not supported by this specification');
+ }
+ $topParameters[] = vsprintf($paramSpecs[$position][$ppCount], $paramsForPosition);
+ } else {
+ $topParameters[] = $paramsForPosition;
+ }
+ }
+ return vsprintf($specificationString, $topParameters);
+ }
+
+ protected function processSubSelect(Select $subselect, PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if ($driver) {
+ $stmtContainer = new StatementContainer;
+
+ // Track subselect prefix and count for parameters
+ $this->processInfo['subselectCount']++;
+ $subselect->processInfo['subselectCount'] = $this->processInfo['subselectCount'];
+ $subselect->processInfo['paramPrefix'] = 'subselect' . $subselect->processInfo['subselectCount'];
+
+ // call subselect
+ $subselect->prepareStatement(new \Zend\Db\Adapter\Adapter($driver, $platform), $stmtContainer);
+
+ // copy count
+ $this->processInfo['subselectCount'] = $subselect->processInfo['subselectCount'];
+
+ $parameterContainer->merge($stmtContainer->getParameterContainer()->getNamedArray());
+ $sql = $stmtContainer->getSql();
+ } else {
+ $sql = $subselect->getSqlString($platform);
+ }
+ return $sql;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/AlterTable.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/AlterTable.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/AlterTable.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/AlterTable.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,268 @@
+ "ALTER TABLE %1\$s\n",
+ self::ADD_COLUMNS => array(
+ "%1\$s" => array(
+ array(1 => 'ADD COLUMN %1$s', 'combinedby' => ",\n")
+ )
+ ),
+ self::CHANGE_COLUMNS => array(
+ "%1\$s" => array(
+ array(2 => 'CHANGE COLUMN %1$s %2$s', 'combinedby' => ",\n"),
+ )
+ ),
+ self::DROP_COLUMNS => array(
+ "%1\$s" => array(
+ array(1 => 'DROP COLUMN %1$s', 'combinedby' => ",\n"),
+ )
+ ),
+ self::ADD_CONSTRAINTS => array(
+ "%1\$s" => array(
+ array(1 => 'ADD %1$s', 'combinedby' => ",\n"),
+ )
+ ),
+ self::DROP_CONSTRAINTS => array(
+ "%1\$s" => array(
+ array(1 => 'DROP CONSTRAINT %1$s', 'combinedby' => ",\n"),
+ )
+ )
+ );
+
+ /**
+ * @var string
+ */
+ protected $table = '';
+
+ /**
+ * @param string $table
+ */
+ public function __construct($table = '')
+ {
+ ($table) ? $this->setTable($table) : null;
+ }
+
+ /**
+ * @param string $name
+ * @return self
+ */
+ public function setTable($name)
+ {
+ $this->table = $name;
+
+ return $this;
+ }
+
+ /**
+ * @param Column\ColumnInterface $column
+ * @return self
+ */
+ public function addColumn(Column\ColumnInterface $column)
+ {
+ $this->addColumns[] = $column;
+
+ return $this;
+ }
+
+ /**
+ * @param string $name
+ * @param Column\ColumnInterface $column
+ * @return self
+ */
+ public function changeColumn($name, Column\ColumnInterface $column)
+ {
+ $this->changeColumns[$name] = $column;
+
+ return $this;
+ }
+
+ /**
+ * @param string $name
+ * @return self
+ */
+ public function dropColumn($name)
+ {
+ $this->dropColumns[] = $name;
+
+ return $this;
+ }
+
+ /**
+ * @param string $name
+ * @return self
+ */
+ public function dropConstraint($name)
+ {
+ $this->dropConstraints[] = $name;
+
+ return $this;
+ }
+
+ /**
+ * @param Constraint\ConstraintInterface $constraint
+ * @return self
+ */
+ public function addConstraint(Constraint\ConstraintInterface $constraint)
+ {
+ $this->addConstraints[] = $constraint;
+
+ return $this;
+ }
+
+ /**
+ * @param string|null $key
+ * @return array
+ */
+ public function getRawState($key = null)
+ {
+ $rawState = array(
+ self::TABLE => $this->table,
+ self::ADD_COLUMNS => $this->addColumns,
+ self::DROP_COLUMNS => $this->dropColumns,
+ self::CHANGE_COLUMNS => $this->changeColumns,
+ self::ADD_CONSTRAINTS => $this->addConstraints,
+ self::DROP_CONSTRAINTS => $this->dropConstraints,
+ );
+
+ return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState;
+ }
+
+ /**
+ * @param PlatformInterface $adapterPlatform
+ * @return string
+ */
+ public function getSqlString(PlatformInterface $adapterPlatform = null)
+ {
+ // get platform, or create default
+ $adapterPlatform = ($adapterPlatform) ?: new AdapterSql92Platform;
+
+ $sqls = array();
+ $parameters = array();
+
+ foreach ($this->specifications as $name => $specification) {
+ $parameters[$name] = $this->{'process' . $name}($adapterPlatform, null, null, $sqls, $parameters);
+ if ($specification && is_array($parameters[$name]) && ($parameters[$name] != array(array()))) {
+ $sqls[$name] = $this->createSqlFromSpecificationAndParameters($specification, $parameters[$name]);
+ }
+ if (stripos($name, 'table') === false && $parameters[$name] !== array(array())) {
+ $sqls[] = ",\n";
+ }
+ }
+
+ // remove last ,\n
+ array_pop($sqls);
+
+ $sql = implode('', $sqls);
+
+ return $sql;
+ }
+
+ protected function processTable(PlatformInterface $adapterPlatform = null)
+ {
+ return array($adapterPlatform->quoteIdentifier($this->table));
+ }
+
+ protected function processAddColumns(PlatformInterface $adapterPlatform = null)
+ {
+ $sqls = array();
+ foreach ($this->addColumns as $column) {
+ $sqls[] = $this->processExpression($column, $adapterPlatform)->getSql();
+ }
+
+ return array($sqls);
+ }
+
+ protected function processChangeColumns(PlatformInterface $adapterPlatform = null)
+ {
+ $sqls = array();
+ foreach ($this->changeColumns as $name => $column) {
+ $sqls[] = array(
+ $adapterPlatform->quoteIdentifier($name),
+ $this->processExpression($column, $adapterPlatform)->getSql()
+ );
+ }
+
+ return array($sqls);
+ }
+
+ protected function processDropColumns(PlatformInterface $adapterPlatform = null)
+ {
+ $sqls = array();
+ foreach ($this->dropColumns as $column) {
+ $sqls[] = $adapterPlatform->quoteIdentifier($column);
+ }
+
+ return array($sqls);
+ }
+
+ protected function processAddConstraints(PlatformInterface $adapterPlatform = null)
+ {
+ $sqls = array();
+ foreach ($this->addConstraints as $constraint) {
+ $sqls[] = $this->processExpression($constraint, $adapterPlatform);
+ }
+
+ return array($sqls);
+ }
+
+ protected function processDropConstraints(PlatformInterface $adapterPlatform = null)
+ {
+ $sqls = array();
+ foreach ($this->dropConstraints as $constraint) {
+ $sqls[] = $adapterPlatform->quoteIdentifier($constraint);
+ }
+
+ return array($sqls);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/BigInteger.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/BigInteger.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/BigInteger.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/BigInteger.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,18 @@
+setName($name);
+ $this->setLength($length);
+ $this->setNullable($nullable);
+ $this->setDefault($default);
+ $this->setOptions($options);
+ }
+
+ /**
+ * @param int $length
+ * @return self
+ */
+ public function setLength($length)
+ {
+ $this->length = $length;
+ return $this;
+ }
+
+ /**
+ * @return int
+ */
+ public function getLength()
+ {
+ return $this->length;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ $spec = $this->specification;
+
+ $params = array();
+ $params[] = $this->name;
+ $params[] = $this->type;
+
+ if ($this->length) {
+ $params[1] .= ' ' . $this->length;
+ }
+
+ $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL);
+
+ if (!$this->isNullable) {
+ $params[1] .= ' NOT NULL';
+ }
+
+ if ($this->default !== null) {
+ $spec .= ' DEFAULT %s';
+ $params[] = $this->default;
+ $types[] = self::TYPE_VALUE;
+ }
+
+ return array(array(
+ $spec,
+ $params,
+ $types,
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Boolean.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Boolean.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Boolean.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Boolean.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,42 @@
+name = $name;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ $spec = $this->specification;
+ $params = array($this->name);
+ $types = array(self::TYPE_IDENTIFIER);
+
+ return array(array(
+ $spec,
+ $params,
+ $types,
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Char.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Char.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Char.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Char.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,58 @@
+name = $name;
+ $this->length = $length;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ $spec = $this->specification;
+ $params = array();
+
+ $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL);
+ $params[] = $this->name;
+ $params[] = $this->length;
+
+ $types[] = self::TYPE_LITERAL;
+ $params[] = (!$this->isNullable) ? 'NOT NULL' : '';
+
+ $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL;
+ $params[] = ($this->default !== null) ? $this->default : '';
+
+ return array(array(
+ $spec,
+ $params,
+ $types,
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/ColumnInterface.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/ColumnInterface.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/ColumnInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/ColumnInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,20 @@
+setName($name);
+ }
+
+ /**
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param bool $nullable
+ * @return self
+ */
+ public function setNullable($nullable)
+ {
+ $this->isNullable = (bool) $nullable;
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isNullable()
+ {
+ return $this->isNullable;
+ }
+
+ /**
+ * @param null|string|int $default
+ * @return self
+ */
+ public function setDefault($default)
+ {
+ $this->default = $default;
+ return $this;
+ }
+
+ /**
+ * @return null|string|int
+ */
+ public function getDefault()
+ {
+ return $this->default;
+ }
+
+ /**
+ * @param array $options
+ * @return self
+ */
+ public function setOptions(array $options)
+ {
+ $this->options = $options;
+ return $this;
+ }
+
+ /**
+ * @param string $name
+ * @param string $value
+ * @return self
+ */
+ public function setOption($name, $value)
+ {
+ $this->options[$name] = $value;
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ $spec = $this->specification;
+
+ $params = array();
+ $params[] = $this->name;
+ $params[] = $this->type;
+
+ $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL);
+
+ if (!$this->isNullable) {
+ $params[1] .= ' NOT NULL';
+ }
+
+ if ($this->default !== null) {
+ $spec .= ' DEFAULT %s';
+ $params[] = $this->default;
+ $types[] = self::TYPE_VALUE;
+ }
+
+ return array(array(
+ $spec,
+ $params,
+ $types,
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Date.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Date.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Date.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Date.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,50 @@
+name = $name;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ $spec = $this->specification;
+ $params = array();
+
+ $types = array(self::TYPE_IDENTIFIER);
+ $params[] = $this->name;
+
+ $types[] = self::TYPE_LITERAL;
+ $params[] = (!$this->isNullable) ? 'NOT NULL' : '';
+
+ $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL;
+ $params[] = ($this->default !== null) ? $this->default : '';
+
+ return array(array(
+ $spec,
+ $params,
+ $types,
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Decimal.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Decimal.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Decimal.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Decimal.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,69 @@
+name = $name;
+ $this->precision = $precision;
+ $this->scale = $scale;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ $spec = $this->specification;
+ $params = array();
+
+ $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL);
+ $params[] = $this->name;
+ $params[] = $this->precision;
+
+ if ($this->scale !== null) {
+ $params[1] .= ', ' . $this->scale;
+ }
+
+ $types[] = self::TYPE_LITERAL;
+ $params[] = (!$this->isNullable) ? 'NOT NULL' : '';
+
+ $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL;
+ $params[] = ($this->default !== null) ? $this->default : '';
+
+ return array(array(
+ $spec,
+ $params,
+ $types,
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Float.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Float.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Float.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Float.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,66 @@
+name = $name;
+ $this->digits = $digits;
+ $this->decimal = $decimal;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ $spec = $this->specification;
+ $params = array();
+
+ $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL);
+ $params[] = $this->name;
+ $params[] = $this->digits;
+ $params[1] .= ', ' . $this->decimal;
+
+ $types[] = self::TYPE_LITERAL;
+ $params[] = (!$this->isNullable) ? 'NOT NULL' : '';
+
+ $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL;
+ $params[] = ($this->default !== null) ? $this->default : '';
+
+ return array(array(
+ $spec,
+ $params,
+ $types,
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Integer.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Integer.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Integer.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Integer.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,32 @@
+setName($name);
+ $this->setNullable($nullable);
+ $this->setDefault($default);
+ $this->setOptions($options);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Text.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Text.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Text.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Text.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,51 @@
+name = $name;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ $spec = $this->specification;
+ $params = array();
+
+ $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL);
+ $params[] = $this->name;
+
+ $types[] = self::TYPE_LITERAL;
+ $params[] = (!$this->isNullable) ? 'NOT NULL' : '';
+
+ $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL;
+ $params[] = ($this->default !== null) ? $this->default : '';
+
+ return array(array(
+ $spec,
+ $params,
+ $types,
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Time.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Time.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Time.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Time.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,50 @@
+name = $name;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ $spec = $this->specification;
+ $params = array();
+
+ $types = array(self::TYPE_IDENTIFIER);
+ $params[] = $this->name;
+
+ $types[] = self::TYPE_LITERAL;
+ $params[] = (!$this->isNullable) ? 'NOT NULL' : '';
+
+ $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL;
+ $params[] = ($this->default !== null) ? $this->default : '';
+
+ return array(array(
+ $spec,
+ $params,
+ $types,
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Varchar.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Varchar.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Column/Varchar.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Column/Varchar.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,58 @@
+name = $name;
+ $this->length = $length;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ $spec = $this->specification;
+ $params = array();
+
+ $types = array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL);
+ $params[] = $this->name;
+ $params[] = $this->length;
+
+ $types[] = self::TYPE_LITERAL;
+ $params[] = (!$this->isNullable) ? 'NOT NULL' : '';
+
+ $types[] = ($this->default !== null) ? self::TYPE_VALUE : self::TYPE_LITERAL;
+ $params[] = ($this->default !== null) ? $this->default : '';
+
+ return array(array(
+ $spec,
+ $params,
+ $types,
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Constraint/AbstractConstraint.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Constraint/AbstractConstraint.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Constraint/AbstractConstraint.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Constraint/AbstractConstraint.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,58 @@
+setColumns($columns);
+ }
+
+ /**
+ * @param null|string|array $columns
+ * @return self
+ */
+ public function setColumns($columns)
+ {
+ if (!is_array($columns)) {
+ $columns = array($columns);
+ }
+
+ $this->columns = $columns;
+ return $this;
+ }
+
+ /**
+ * @param string $column
+ * @return self
+ */
+ public function addColumn($column)
+ {
+ $this->columns[] = $column;
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getColumns()
+ {
+ return $this->columns;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Constraint/Check.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Constraint/Check.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Constraint/Check.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Constraint/Check.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,45 @@
+expression = $expression;
+ $this->name = $name;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ return array(array(
+ $this->specification,
+ array($this->name, $this->expression),
+ array(self::TYPE_IDENTIFIER, self::TYPE_LITERAL),
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Constraint/ConstraintInterface.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Constraint/ConstraintInterface.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Constraint/ConstraintInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Constraint/ConstraintInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,17 @@
+setName($name);
+ $this->setColumns($column);
+ $this->setReferenceTable($referenceTable);
+ $this->setReferenceColumn($referenceColumn);
+ (!$onDeleteRule) ?: $this->setOnDeleteRule($onDeleteRule);
+ (!$onUpdateRule) ?: $this->setOnUpdateRule($onUpdateRule);
+ }
+
+ /**
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param string $referenceTable
+ * @return self
+ */
+ public function setReferenceTable($referenceTable)
+ {
+ $this->referenceTable = $referenceTable;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getReferenceTable()
+ {
+ return $this->referenceTable;
+ }
+
+ /**
+ * @param string $referenceColumn
+ * @return self
+ */
+ public function setReferenceColumn($referenceColumn)
+ {
+ $this->referenceColumn = $referenceColumn;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getReferenceColumn()
+ {
+ return $this->referenceColumn;
+ }
+
+ /**
+ * @param string $onDeleteRule
+ * @return self
+ */
+ public function setOnDeleteRule($onDeleteRule)
+ {
+ $this->onDeleteRule = $onDeleteRule;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getOnDeleteRule()
+ {
+ return $this->onDeleteRule;
+ }
+
+ /**
+ * @param string $onUpdateRule
+ * @return self
+ */
+ public function setOnUpdateRule($onUpdateRule)
+ {
+ $this->onUpdateRule = $onUpdateRule;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getOnUpdateRule()
+ {
+ return $this->onUpdateRule;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ return array(array(
+ $this->specification,
+ array(
+ $this->name,
+ $this->columns[0],
+ $this->referenceTable,
+ $this->referenceColumn,
+ $this->onDeleteRule,
+ $this->onUpdateRule,
+ ),
+ array(
+ self::TYPE_IDENTIFIER,
+ self::TYPE_IDENTIFIER,
+ self::TYPE_IDENTIFIER,
+ self::TYPE_IDENTIFIER,
+ self::TYPE_LITERAL,
+ self::TYPE_LITERAL,
+ ),
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Constraint/PrimaryKey.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Constraint/PrimaryKey.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Constraint/PrimaryKey.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Constraint/PrimaryKey.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,36 @@
+columns);
+ $newSpecParts = array_fill(0, $colCount, '%s');
+ $newSpecTypes = array_fill(0, $colCount, self::TYPE_IDENTIFIER);
+
+ $newSpec = sprintf($this->specification, implode(', ', $newSpecParts));
+
+ return array(array(
+ $newSpec,
+ $this->columns,
+ $newSpecTypes,
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Constraint/UniqueKey.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Constraint/UniqueKey.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/Constraint/UniqueKey.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/Constraint/UniqueKey.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,55 @@
+setColumns($column);
+ $this->name = $name;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ $colCount = count($this->columns);
+
+ $values = array();
+ $values[] = ($this->name) ? $this->name : '';
+
+ $newSpecTypes = array(self::TYPE_IDENTIFIER);
+ $newSpecParts = array();
+
+ for ($i = 0; $i < $colCount; $i++) {
+ $newSpecParts[] = '%s';
+ $newSpecTypes[] = self::TYPE_IDENTIFIER;
+ }
+
+ $newSpec = str_replace('...', implode(', ', $newSpecParts), $this->specification);
+
+ return array(array(
+ $newSpec,
+ array_merge($values, $this->columns),
+ $newSpecTypes,
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/CreateTable.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/CreateTable.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/CreateTable.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/CreateTable.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,218 @@
+ 'CREATE %1$sTABLE %2$s (',
+ self::COLUMNS => array(
+ "\n %1\$s" => array(
+ array(1 => '%1$s', 'combinedby' => ",\n ")
+ )
+ ),
+ self::CONSTRAINTS => array(
+ "\n %1\$s" => array(
+ array(1 => '%1$s', 'combinedby' => ",\n ")
+ )
+ ),
+ );
+
+ /**
+ * @var string
+ */
+ protected $table = '';
+
+ /**
+ * @param string $table
+ * @param bool $isTemporary
+ */
+ public function __construct($table = '', $isTemporary = false)
+ {
+ $this->table = $table;
+ $this->setTemporary($isTemporary);
+ }
+
+ /**
+ * @param bool $temporary
+ * @return self
+ */
+ public function setTemporary($temporary)
+ {
+ $this->isTemporary = (bool) $temporary;
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isTemporary()
+ {
+ return $this->isTemporary;
+ }
+
+ /**
+ * @param string $name
+ * @return self
+ */
+ public function setTable($name)
+ {
+ $this->table = $name;
+ return $this;
+ }
+
+ /**
+ * @param Column\ColumnInterface $column
+ * @return self
+ */
+ public function addColumn(Column\ColumnInterface $column)
+ {
+ $this->columns[] = $column;
+ return $this;
+ }
+
+ /**
+ * @param Constraint\ConstraintInterface $constraint
+ * @return self
+ */
+ public function addConstraint(Constraint\ConstraintInterface $constraint)
+ {
+ $this->constraints[] = $constraint;
+ return $this;
+ }
+
+ /**
+ * @param string|null $key
+ * @return array
+ */
+ public function getRawState($key = null)
+ {
+ $rawState = array(
+ self::COLUMNS => $this->columns,
+ self::CONSTRAINTS => $this->constraints,
+ self::TABLE => $this->table,
+ );
+
+ return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState;
+ }
+
+ /**
+ * @param PlatformInterface $adapterPlatform
+ * @return string
+ */
+ public function getSqlString(PlatformInterface $adapterPlatform = null)
+ {
+ // get platform, or create default
+ $adapterPlatform = ($adapterPlatform) ?: new AdapterSql92Platform;
+
+ $sqls = array();
+ $parameters = array();
+
+ foreach ($this->specifications as $name => $specification) {
+ if (is_int($name)) {
+ $sqls[] = $specification;
+ continue;
+ }
+
+ $parameters[$name] = $this->{'process' . $name}(
+ $adapterPlatform,
+ null,
+ null,
+ $sqls,
+ $parameters
+ );
+
+
+ if ($specification
+ && is_array($parameters[$name])
+ && ($parameters[$name] != array(array()))
+ ) {
+ $sqls[$name] = $this->createSqlFromSpecificationAndParameters(
+ $specification,
+ $parameters[$name]
+ );
+ }
+
+ if (stripos($name, 'table') === false
+ && $parameters[$name] !== array(array())
+ ) {
+ $sqls[] = ",\n";
+ }
+ }
+
+
+ // remove last ,
+ if (count($sqls) > 2) {
+ array_pop($sqls);
+ }
+
+ $sql = implode('', $sqls) . "\n)";
+
+ return $sql;
+ }
+
+ protected function processTable(PlatformInterface $adapterPlatform = null)
+ {
+ $ret = array();
+ if ($this->isTemporary) {
+ $ret[] = 'TEMPORARY ';
+ } else {
+ $ret[] = '';
+ }
+
+ $ret[] = $adapterPlatform->quoteIdentifier($this->table);
+ return $ret;
+ }
+
+ protected function processColumns(PlatformInterface $adapterPlatform = null)
+ {
+ $sqls = array();
+ foreach ($this->columns as $column) {
+ $sqls[] = $this->processExpression($column, $adapterPlatform)->getSql();
+ }
+ return array($sqls);
+ }
+
+ protected function processConstraints(PlatformInterface $adapterPlatform = null)
+ {
+ $sqls = array();
+ foreach ($this->constraints as $constraint) {
+ $sqls[] = $this->processExpression($constraint, $adapterPlatform)->getSql();
+ }
+ return array($sqls);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/DropTable.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/DropTable.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/DropTable.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/DropTable.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,77 @@
+ 'DROP TABLE %1$s'
+ );
+
+ /**
+ * @var string
+ */
+ protected $table = '';
+
+ /**
+ * @param string $table
+ */
+ public function __construct($table = '')
+ {
+ $this->table = $table;
+ }
+
+ /**
+ * @param null|PlatformInterface $adapterPlatform
+ * @return string
+ */
+ public function getSqlString(PlatformInterface $adapterPlatform = null)
+ {
+ // get platform, or create default
+ $adapterPlatform = ($adapterPlatform) ?: new AdapterSql92Platform;
+
+ $sqls = array();
+ $parameters = array();
+
+ foreach ($this->specifications as $name => $specification) {
+ $parameters[$name] = $this->{'process' . $name}(
+ $adapterPlatform,
+ null,
+ null,
+ $sqls,
+ $parameters
+ );
+
+ if ($specification && is_array($parameters[$name])) {
+ $sqls[$name] = $this->createSqlFromSpecificationAndParameters(
+ $specification,
+ $parameters[$name]
+ );
+ }
+ }
+
+ $sql = implode(' ', $sqls);
+ return $sql;
+ }
+
+ protected function processTable(PlatformInterface $adapterPlatform = null)
+ {
+ return array($adapterPlatform->quoteIdentifier($this->table));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Ddl/SqlInterface.php zendframework-2.2.6/library/Zend/Db/Sql/Ddl/SqlInterface.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Ddl/SqlInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Ddl/SqlInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,16 @@
+ 'DELETE FROM %1$s',
+ self::SPECIFICATION_WHERE => 'WHERE %1$s'
+ );
+
+ /**
+ * @var string|TableIdentifier
+ */
+ protected $table = '';
+
+ /**
+ * @var bool
+ */
+ protected $emptyWhereProtection = true;
+
+ /**
+ * @var array
+ */
+ protected $set = array();
+
+ /**
+ * @var null|string|Where
+ */
+ protected $where = null;
+
+ /**
+ * Constructor
+ *
+ * @param null|string|TableIdentifier $table
+ */
+ public function __construct($table = null)
+ {
+ if ($table) {
+ $this->from($table);
+ }
+ $this->where = new Where();
+ }
+
+ /**
+ * Create from statement
+ *
+ * @param string|TableIdentifier $table
+ * @return Delete
+ */
+ public function from($table)
+ {
+ $this->table = $table;
+ return $this;
+ }
+
+ public function getRawState($key = null)
+ {
+ $rawState = array(
+ 'emptyWhereProtection' => $this->emptyWhereProtection,
+ 'table' => $this->table,
+ 'set' => $this->set,
+ 'where' => $this->where
+ );
+ return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState;
+ }
+
+ /**
+ * Create where clause
+ *
+ * @param Where|\Closure|string|array $predicate
+ * @param string $combination One of the OP_* constants from Predicate\PredicateSet
+ * @return Delete
+ */
+ public function where($predicate, $combination = Predicate\PredicateSet::OP_AND)
+ {
+ if ($predicate instanceof Where) {
+ $this->where = $predicate;
+ } elseif ($predicate instanceof \Closure) {
+ $predicate($this->where);
+ } else {
+
+ if (is_string($predicate)) {
+ // String $predicate should be passed as an expression
+ $predicate = new Predicate\Expression($predicate);
+ $this->where->addPredicate($predicate, $combination);
+ } elseif (is_array($predicate)) {
+
+ foreach ($predicate as $pkey => $pvalue) {
+ // loop through predicates
+
+ if (is_string($pkey) && strpos($pkey, '?') !== false) {
+ // First, process strings that the abstraction replacement character ?
+ // as an Expression predicate
+ $predicate = new Predicate\Expression($pkey, $pvalue);
+
+ } elseif (is_string($pkey)) {
+ // Otherwise, if still a string, do something intelligent with the PHP type provided
+
+ if ($pvalue === null) {
+ // map PHP null to SQL IS NULL expression
+ $predicate = new Predicate\IsNull($pkey, $pvalue);
+ } elseif (is_array($pvalue)) {
+ // if the value is an array, assume IN() is desired
+ $predicate = new Predicate\In($pkey, $pvalue);
+ } else {
+ // otherwise assume that array('foo' => 'bar') means "foo" = 'bar'
+ $predicate = new Predicate\Operator($pkey, Predicate\Operator::OP_EQ, $pvalue);
+ }
+ } elseif ($pvalue instanceof Predicate\PredicateInterface) {
+ // Predicate type is ok
+ $predicate = $pvalue;
+ } else {
+ // must be an array of expressions (with int-indexed array)
+ $predicate = new Predicate\Expression($pvalue);
+ }
+ $this->where->addPredicate($predicate, $combination);
+ }
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Prepare the delete statement
+ *
+ * @param AdapterInterface $adapter
+ * @param StatementContainerInterface $statementContainer
+ * @return void
+ */
+ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
+ {
+ $driver = $adapter->getDriver();
+ $platform = $adapter->getPlatform();
+ $parameterContainer = $statementContainer->getParameterContainer();
+
+ if (!$parameterContainer instanceof ParameterContainer) {
+ $parameterContainer = new ParameterContainer();
+ $statementContainer->setParameterContainer($parameterContainer);
+ }
+
+ $table = $this->table;
+ $schema = null;
+
+ // create quoted table name to use in delete processing
+ if ($table instanceof TableIdentifier) {
+ list($table, $schema) = $table->getTableAndSchema();
+ }
+
+ $table = $platform->quoteIdentifier($table);
+
+ if ($schema) {
+ $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table;
+ }
+
+ $sql = sprintf($this->specifications[self::SPECIFICATION_DELETE], $table);
+
+ // process where
+ if ($this->where->count() > 0) {
+ $whereParts = $this->processExpression($this->where, $platform, $driver, 'where');
+ $parameterContainer->merge($whereParts->getParameterContainer());
+ $sql .= ' ' . sprintf($this->specifications[self::SPECIFICATION_WHERE], $whereParts->getSql());
+ }
+ $statementContainer->setSql($sql);
+ }
+
+ /**
+ * Get the SQL string, based on the platform
+ *
+ * Platform defaults to Sql92 if none provided
+ *
+ * @param null|PlatformInterface $adapterPlatform
+ * @return string
+ */
+ public function getSqlString(PlatformInterface $adapterPlatform = null)
+ {
+ $adapterPlatform = ($adapterPlatform) ?: new Sql92;
+ $table = $this->table;
+ $schema = null;
+
+ // create quoted table name to use in delete processing
+ if ($table instanceof TableIdentifier) {
+ list($table, $schema) = $table->getTableAndSchema();
+ }
+
+ $table = $adapterPlatform->quoteIdentifier($table);
+
+ if ($schema) {
+ $table = $adapterPlatform->quoteIdentifier($schema) . $adapterPlatform->getIdentifierSeparator() . $table;
+ }
+
+ $sql = sprintf($this->specifications[self::SPECIFICATION_DELETE], $table);
+
+ if ($this->where->count() > 0) {
+ $whereParts = $this->processExpression($this->where, $adapterPlatform, null, 'where');
+ $sql .= ' ' . sprintf($this->specifications[self::SPECIFICATION_WHERE], $whereParts->getSql());
+ }
+
+ return $sql;
+ }
+
+ /**
+ * Property overloading
+ *
+ * Overloads "where" only.
+ *
+ * @param string $name
+ * @return mixed
+ */
+ public function __get($name)
+ {
+ switch (strtolower($name)) {
+ case 'where':
+ return $this->where;
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Db/Sql/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Exception/ExceptionInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,16 @@
+setExpression($expression);
+ }
+ if ($parameters) {
+ $this->setParameters($parameters);
+ }
+ if ($types) {
+ $this->setTypes($types);
+ }
+ }
+
+ /**
+ * @param $expression
+ * @return Expression
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setExpression($expression)
+ {
+ if (!is_string($expression) || $expression == '') {
+ throw new Exception\InvalidArgumentException('Supplied expression must be a string.');
+ }
+ $this->expression = $expression;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getExpression()
+ {
+ return $this->expression;
+ }
+
+ /**
+ * @param $parameters
+ * @return Expression
+ * @throws Exception\InvalidArgumentException
+ */
+ public function setParameters($parameters)
+ {
+ if (!is_scalar($parameters) && !is_array($parameters)) {
+ throw new Exception\InvalidArgumentException('Expression parameters must be a scalar or array.');
+ }
+ $this->parameters = $parameters;
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getParameters()
+ {
+ return $this->parameters;
+ }
+
+ /**
+ * @param array $types
+ * @return Expression
+ */
+ public function setTypes(array $types)
+ {
+ $this->types = $types;
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getTypes()
+ {
+ return $this->types;
+ }
+
+ /**
+ * @return array
+ * @throws Exception\RuntimeException
+ */
+ public function getExpressionData()
+ {
+ $parameters = (is_scalar($this->parameters)) ? array($this->parameters) : $this->parameters;
+
+ $types = array();
+ $parametersCount = count($parameters);
+
+ if ($parametersCount == 0 && strpos($this->expression, self::PLACEHOLDER) !== false) {
+ // if there are no parameters, but there is a placeholder
+ $parametersCount = substr_count($this->expression, self::PLACEHOLDER);
+ $parameters = array_fill(0, $parametersCount, null);
+ }
+
+ for ($i = 0; $i < $parametersCount; $i++) {
+ $types[$i] = (isset($this->types[$i]) && ($this->types[$i] == self::TYPE_IDENTIFIER || $this->types[$i] == self::TYPE_LITERAL))
+ ? $this->types[$i] : self::TYPE_VALUE;
+ }
+
+ // assign locally, escaping % signs
+ $expression = str_replace('%', '%%', $this->expression);
+
+ if ($parametersCount > 0) {
+ $count = 0;
+ $expression = str_replace(self::PLACEHOLDER, '%s', $expression, $count);
+ if ($count !== $parametersCount) {
+ throw new Exception\RuntimeException('The number of replacements in the expression does not match the number of parameters');
+ }
+ }
+
+ return array(array(
+ $expression,
+ $parameters,
+ $types
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Having.php zendframework-2.2.6/library/Zend/Db/Sql/Having.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Having.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Having.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+ 'INSERT INTO %1$s (%2$s) VALUES (%3$s)'
+ );
+
+ /**
+ * @var string|TableIdentifier
+ */
+ protected $table = null;
+ protected $columns = array();
+
+ /**
+ * @var array
+ */
+ protected $values = array();
+
+ /**
+ * Constructor
+ *
+ * @param null|string|TableIdentifier $table
+ */
+ public function __construct($table = null)
+ {
+ if ($table) {
+ $this->into($table);
+ }
+ }
+
+ /**
+ * Crete INTO clause
+ *
+ * @param string|TableIdentifier $table
+ * @return Insert
+ */
+ public function into($table)
+ {
+ $this->table = $table;
+ return $this;
+ }
+
+ /**
+ * Specify columns
+ *
+ * @param array $columns
+ * @return Insert
+ */
+ public function columns(array $columns)
+ {
+ $this->columns = $columns;
+ return $this;
+ }
+
+ /**
+ * Specify values to insert
+ *
+ * @param array $values
+ * @param string $flag one of VALUES_MERGE or VALUES_SET; defaults to VALUES_SET
+ * @throws Exception\InvalidArgumentException
+ * @return Insert
+ */
+ public function values(array $values, $flag = self::VALUES_SET)
+ {
+ if (!is_array($values)) {
+ throw new Exception\InvalidArgumentException('values() expects an array of values');
+ }
+
+ // determine if this is assoc or a set of values
+ $keys = array_keys($values);
+ $firstKey = current($keys);
+
+ if ($flag == self::VALUES_SET) {
+ $this->columns = array();
+ $this->values = array();
+ }
+
+ if (is_string($firstKey)) {
+ foreach ($keys as $key) {
+ if (($index = array_search($key, $this->columns)) !== false) {
+ $this->values[$index] = $values[$key];
+ } else {
+ $this->columns[] = $key;
+ $this->values[] = $values[$key];
+ }
+ }
+ } elseif (is_int($firstKey)) {
+ // determine if count of columns should match count of values
+ $this->values = array_merge($this->values, array_values($values));
+ }
+
+ return $this;
+ }
+
+ public function getRawState($key = null)
+ {
+ $rawState = array(
+ 'table' => $this->table,
+ 'columns' => $this->columns,
+ 'values' => $this->values
+ );
+ return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState;
+ }
+
+ /**
+ * Prepare statement
+ *
+ * @param AdapterInterface $adapter
+ * @param StatementContainerInterface $statementContainer
+ * @return void
+ */
+ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
+ {
+ $driver = $adapter->getDriver();
+ $platform = $adapter->getPlatform();
+ $parameterContainer = $statementContainer->getParameterContainer();
+
+ if (!$parameterContainer instanceof ParameterContainer) {
+ $parameterContainer = new ParameterContainer();
+ $statementContainer->setParameterContainer($parameterContainer);
+ }
+
+ $table = $this->table;
+ $schema = null;
+
+ // create quoted table name to use in insert processing
+ if ($table instanceof TableIdentifier) {
+ list($table, $schema) = $table->getTableAndSchema();
+ }
+
+ $table = $platform->quoteIdentifier($table);
+
+ if ($schema) {
+ $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table;
+ }
+
+ $columns = array();
+ $values = array();
+
+ foreach ($this->columns as $cIndex => $column) {
+ $columns[$cIndex] = $platform->quoteIdentifier($column);
+ if (isset($this->values[$cIndex]) && $this->values[$cIndex] instanceof Expression) {
+ $exprData = $this->processExpression($this->values[$cIndex], $platform, $driver);
+ $values[$cIndex] = $exprData->getSql();
+ $parameterContainer->merge($exprData->getParameterContainer());
+ } else {
+ $values[$cIndex] = $driver->formatParameterName($column);
+ if (isset($this->values[$cIndex])) {
+ $parameterContainer->offsetSet($column, $this->values[$cIndex]);
+ } else {
+ $parameterContainer->offsetSet($column, null);
+ }
+ }
+ }
+
+ $sql = sprintf(
+ $this->specifications[self::SPECIFICATION_INSERT],
+ $table,
+ implode(', ', $columns),
+ implode(', ', $values)
+ );
+
+ $statementContainer->setSql($sql);
+ }
+
+ /**
+ * Get SQL string for this statement
+ *
+ * @param null|PlatformInterface $adapterPlatform Defaults to Sql92 if none provided
+ * @return string
+ */
+ public function getSqlString(PlatformInterface $adapterPlatform = null)
+ {
+ $adapterPlatform = ($adapterPlatform) ?: new Sql92;
+ $table = $this->table;
+ $schema = null;
+
+ // create quoted table name to use in insert processing
+ if ($table instanceof TableIdentifier) {
+ list($table, $schema) = $table->getTableAndSchema();
+ }
+
+ $table = $adapterPlatform->quoteIdentifier($table);
+
+ if ($schema) {
+ $table = $adapterPlatform->quoteIdentifier($schema) . $adapterPlatform->getIdentifierSeparator() . $table;
+ }
+
+ $columns = array_map(array($adapterPlatform, 'quoteIdentifier'), $this->columns);
+ $columns = implode(', ', $columns);
+
+ $values = array();
+ foreach ($this->values as $value) {
+ if ($value instanceof Expression) {
+ $exprData = $this->processExpression($value, $adapterPlatform);
+ $values[] = $exprData->getSql();
+ } elseif ($value === null) {
+ $values[] = 'NULL';
+ } else {
+ $values[] = $adapterPlatform->quoteValue($value);
+ }
+ }
+
+ $values = implode(', ', $values);
+
+ return sprintf($this->specifications[self::SPECIFICATION_INSERT], $table, $columns, $values);
+ }
+
+ /**
+ * Overloading: variable setting
+ *
+ * Proxies to values, using VALUES_MERGE strategy
+ *
+ * @param string $name
+ * @param mixed $value
+ * @return Insert
+ */
+ public function __set($name, $value)
+ {
+ $values = array($name => $value);
+ $this->values($values, self::VALUES_MERGE);
+ return $this;
+ }
+
+ /**
+ * Overloading: variable unset
+ *
+ * Proxies to values and columns
+ *
+ * @param string $name
+ * @throws Exception\InvalidArgumentException
+ * @return void
+ */
+ public function __unset($name)
+ {
+ if (($position = array_search($name, $this->columns)) === false) {
+ throw new Exception\InvalidArgumentException('The key ' . $name . ' was not found in this objects column list');
+ }
+
+ unset($this->columns[$position]);
+ unset($this->values[$position]);
+ }
+
+ /**
+ * Overloading: variable isset
+ *
+ * Proxies to columns; does a column of that name exist?
+ *
+ * @param string $name
+ * @return bool
+ */
+ public function __isset($name)
+ {
+ return in_array($name, $this->columns);
+ }
+
+ /**
+ * Overloading: variable retrieval
+ *
+ * Retrieves value by column name
+ *
+ * @param string $name
+ * @throws Exception\InvalidArgumentException
+ * @return mixed
+ */
+ public function __get($name)
+ {
+ if (($position = array_search($name, $this->columns)) === false) {
+ throw new Exception\InvalidArgumentException('The key ' . $name . ' was not found in this objects column list');
+ }
+ return $this->values[$position];
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Literal.php zendframework-2.2.6/library/Zend/Db/Sql/Literal.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Literal.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Literal.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,56 @@
+literal = $literal;
+ }
+
+ /**
+ * @param string $literal
+ * @return Literal
+ */
+ public function setLiteral($literal)
+ {
+ $this->literal = $literal;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getLiteral()
+ {
+ return $this->literal;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ return array(array(
+ str_replace('%', '%%', $this->literal),
+ array(),
+ array()
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Platform/AbstractPlatform.php zendframework-2.2.6/library/Zend/Db/Sql/Platform/AbstractPlatform.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Platform/AbstractPlatform.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Platform/AbstractPlatform.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,110 @@
+subject = $subject;
+ }
+
+ /**
+ * @param $type
+ * @param PlatformDecoratorInterface $decorator
+ */
+ public function setTypeDecorator($type, PlatformDecoratorInterface $decorator)
+ {
+ $this->decorators[$type] = $decorator;
+ }
+
+ /**
+ * @return array|PlatformDecoratorInterface[]
+ */
+ public function getDecorators()
+ {
+ return $this->decorators;
+ }
+
+ /**
+ * @param AdapterInterface $adapter
+ * @param StatementContainerInterface $statementContainer
+ * @throws Exception\RuntimeException
+ * @return void
+ */
+ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
+ {
+ if (!$this->subject instanceof PreparableSqlInterface) {
+ throw new Exception\RuntimeException('The subject does not appear to implement Zend\Db\Sql\PreparableSqlInterface, thus calling prepareStatement() has no effect');
+ }
+
+ $decoratorForType = false;
+ foreach ($this->decorators as $type => $decorator) {
+ if ($this->subject instanceof $type && $decorator instanceof PreparableSqlInterface) {
+ /** @var $decoratorForType PreparableSqlInterface|PlatformDecoratorInterface */
+ $decoratorForType = $decorator;
+ break;
+ }
+ }
+ if ($decoratorForType) {
+ $decoratorForType->setSubject($this->subject);
+ $decoratorForType->prepareStatement($adapter, $statementContainer);
+ } else {
+ $this->subject->prepareStatement($adapter, $statementContainer);
+ }
+ }
+
+ /**
+ * @param null|\Zend\Db\Adapter\Platform\PlatformInterface $adapterPlatform
+ * @return mixed
+ * @throws Exception\RuntimeException
+ */
+ public function getSqlString(PlatformInterface $adapterPlatform = null)
+ {
+ if (!$this->subject instanceof SqlInterface) {
+ throw new Exception\RuntimeException('The subject does not appear to implement Zend\Db\Sql\PreparableSqlInterface, thus calling prepareStatement() has no effect');
+ }
+
+ $decoratorForType = false;
+ foreach ($this->decorators as $type => $decorator) {
+ if ($this->subject instanceof $type && $decorator instanceof SqlInterface) {
+ /** @var $decoratorForType SqlInterface|PlatformDecoratorInterface */
+ $decoratorForType = $decorator;
+ break;
+ }
+ }
+ if ($decoratorForType) {
+ $decoratorForType->setSubject($this->subject);
+ return $decoratorForType->getSqlString($adapterPlatform);
+ }
+
+ return $this->subject->getSqlString($adapterPlatform);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php zendframework-2.2.6/library/Zend/Db/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Platform/Mysql/Ddl/CreateTableDecorator.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,86 @@
+createTable = $subject;
+ }
+
+ /**
+ * @param null|PlatformInterface $platform
+ * @return string
+ */
+ public function getSqlString(PlatformInterface $platform = null)
+ {
+ // localize variables
+ foreach (get_object_vars($this->createTable) as $name => $value) {
+ $this->{$name} = $value;
+ }
+ return parent::getSqlString($platform);
+ }
+
+ protected function processColumns(PlatformInterface $platform = null)
+ {
+ $sqls = array();
+ foreach ($this->columns as $i => $column) {
+ $stmtContainer = $this->processExpression($column, $platform);
+ $sql = $stmtContainer->getSql();
+ $columnOptions = $column->getOptions();
+
+ foreach ($columnOptions as $coName => $coValue) {
+ switch (strtolower(str_replace(array('-', '_', ' '), '', $coName))) {
+ case 'identity':
+ case 'serial':
+ case 'autoincrement':
+ $sql .= ' AUTO_INCREMENT';
+ break;
+ /*
+ case 'primary':
+ case 'primarykey':
+ $sql .= ' PRIMARY KEY';
+ break;
+ case 'unique':
+ case 'uniquekey':
+ $sql .= ' UNIQUE KEY';
+ break;
+ */
+ case 'comment':
+ $sql .= ' COMMENT \'' . $coValue . '\'';
+ break;
+ case 'columnformat':
+ case 'format':
+ $sql .= ' COLUMN_FORMAT ' . strtoupper($coValue);
+ break;
+ case 'storage':
+ $sql .= ' STORAGE ' . strtoupper($coValue);
+ break;
+ }
+ }
+ $stmtContainer->setSql($sql);
+ $sqls[$i] = $stmtContainer;
+ }
+ return array($sqls);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Platform/Mysql/Mysql.php zendframework-2.2.6/library/Zend/Db/Sql/Platform/Mysql/Mysql.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Platform/Mysql/Mysql.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Platform/Mysql/Mysql.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,21 @@
+setTypeDecorator('Zend\Db\Sql\Select', new SelectDecorator());
+ $this->setTypeDecorator('Zend\Db\Sql\Ddl\CreateTable', new Ddl\CreateTableDecorator());
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Platform/Mysql/SelectDecorator.php zendframework-2.2.6/library/Zend/Db/Sql/Platform/Mysql/SelectDecorator.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Platform/Mysql/SelectDecorator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Platform/Mysql/SelectDecorator.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,88 @@
+select = $select;
+ }
+
+ /**
+ * @param AdapterInterface $adapter
+ * @param StatementContainerInterface $statementContainer
+ */
+ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
+ {
+ // localize variables
+ foreach (get_object_vars($this->select) as $name => $value) {
+ $this->{$name} = $value;
+ }
+ parent::prepareStatement($adapter, $statementContainer);
+ }
+
+ /**
+ * @param PlatformInterface $platform
+ * @return string
+ */
+ public function getSqlString(PlatformInterface $platform = null)
+ {
+ // localize variables
+ foreach (get_object_vars($this->select) as $name => $value) {
+ $this->{$name} = $value;
+ }
+ return parent::getSqlString($platform);
+ }
+
+ protected function processLimit(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if ($this->limit === null) {
+ return null;
+ }
+ if ($driver) {
+ $sql = $driver->formatParameterName('limit');
+ $parameterContainer->offsetSet('limit', (int) $this->limit, ParameterContainer::TYPE_INTEGER);
+ } else {
+ $sql = $this->limit;
+ }
+
+ return array($sql);
+ }
+
+ protected function processOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if ($this->offset === null) {
+ return null;
+ }
+ if ($driver) {
+ $parameterContainer->offsetSet('offset', (int) $this->offset, ParameterContainer::TYPE_INTEGER);
+ return array($driver->formatParameterName('offset'));
+ }
+
+ return array($this->offset);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Platform/Oracle/Oracle.php zendframework-2.2.6/library/Zend/Db/Sql/Platform/Oracle/Oracle.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Platform/Oracle/Oracle.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Platform/Oracle/Oracle.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,22 @@
+setTypeDecorator('Zend\Db\Sql\Select', ($selectDecorator) ?: new SelectDecorator());
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Platform/Oracle/SelectDecorator.php zendframework-2.2.6/library/Zend/Db/Sql/Platform/Oracle/SelectDecorator.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Platform/Oracle/SelectDecorator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Platform/Oracle/SelectDecorator.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,182 @@
+select = $select;
+ }
+
+ /**
+ * @see \Zend\Db\Sql\Select::renderTable
+ */
+ protected function renderTable($table, $alias = null)
+ {
+ return $table . ' ' . $alias;
+ }
+
+ /**
+ * @param AdapterInterface $adapter
+ * @param StatementContainerInterface $statementContainer
+ */
+ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
+ {
+ // localize variables
+ foreach (get_object_vars($this->select) as $name => $value) {
+ $this->{$name} = $value;
+ }
+ // set specifications
+ unset($this->specifications[self::LIMIT]);
+ unset($this->specifications[self::OFFSET]);
+
+ $this->specifications['LIMITOFFSET'] = null;
+ parent::prepareStatement($adapter, $statementContainer);
+ }
+
+ /**
+ * @param PlatformInterface $platform
+ * @return string
+ */
+ public function getSqlString(PlatformInterface $platform = null)
+ {
+ // localize variables
+ foreach (get_object_vars($this->select) as $name => $value) {
+ $this->{$name} = $value;
+ }
+
+ // set specifications
+ unset($this->specifications[self::LIMIT]);
+ unset($this->specifications[self::OFFSET]);
+
+ $this->specifications['LIMITOFFSET'] = null;
+ return parent::getSqlString($platform);
+ }
+
+ /**
+ * @param PlatformInterface $platform
+ * @param DriverInterface $driver
+ * @param ParameterContainer $parameterContainer
+ * @param $sqls
+ * @param $parameters
+ * @return null
+ */
+ protected function processLimitOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null, &$sqls, &$parameters)
+ {
+ if ($this->limit === null && $this->offset === null) {
+ return null;
+ }
+
+ $selectParameters = $parameters[self::SELECT];
+
+ $starSuffix = $platform->getIdentifierSeparator() . self::SQL_STAR;
+ foreach ($selectParameters[0] as $i => $columnParameters) {
+ if ($columnParameters[0] == self::SQL_STAR || (isset($columnParameters[1]) && $columnParameters[1] == self::SQL_STAR) || strpos($columnParameters[0], $starSuffix)) {
+ $selectParameters[0] = array(array(self::SQL_STAR));
+ break;
+ }
+ if (isset($columnParameters[1])) {
+ array_shift($columnParameters);
+ $selectParameters[0][$i] = $columnParameters;
+ }
+ }
+
+ if ($this->offset === null) {
+ $this->offset = 0;
+ }
+
+ // first, produce column list without compound names (using the AS portion only)
+ array_unshift($sqls, $this->createSqlFromSpecificationAndParameters(
+ array('SELECT %1$s FROM (SELECT b.%1$s, rownum b_rownum FROM (' => current($this->specifications[self::SELECT])), $selectParameters
+ ));
+
+ if ($parameterContainer) {
+ if ($this->limit === null) {
+ array_push($sqls, ') b ) WHERE b_rownum > (:offset)');
+ $parameterContainer->offsetSet('offset', $this->offset, $parameterContainer::TYPE_INTEGER);
+ } else {
+ // create bottom part of query, with offset and limit using row_number
+ array_push($sqls, ') b WHERE rownum <= (:offset+:limit)) WHERE b_rownum >= (:offset + 1)');
+ $parameterContainer->offsetSet('offset', $this->offset, $parameterContainer::TYPE_INTEGER);
+ $parameterContainer->offsetSet('limit', $this->limit, $parameterContainer::TYPE_INTEGER);
+ }
+ } else {
+ if ($this->limit === null) {
+ array_push($sqls, ') b ) WHERE b_rownum > ('. (int) $this->offset. ')'
+ );
+ } else {
+ array_push($sqls, ') b WHERE rownum <= ('
+ . (int) $this->offset
+ . '+'
+ . (int) $this->limit
+ . ')) WHERE b_rownum >= ('
+ . (int) $this->offset
+ . ' + 1)'
+ );
+ }
+ }
+
+ $sqls[self::SELECT] = $this->createSqlFromSpecificationAndParameters(
+ $this->specifications[self::SELECT], $parameters[self::SELECT]
+ );
+ }
+
+
+ protected function processJoins(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if (!$this->joins) {
+ return null;
+ }
+
+ // process joins
+ $joinSpecArgArray = array();
+ foreach ($this->joins as $j => $join) {
+ $joinSpecArgArray[$j] = array();
+ // type
+ $joinSpecArgArray[$j][] = strtoupper($join['type']);
+ // table name
+ $joinSpecArgArray[$j][] = (is_array($join['name']))
+ ? $platform->quoteIdentifier(current($join['name'])) . ' ' . $platform->quoteIdentifier(key($join['name']))
+ : $platform->quoteIdentifier($join['name']);
+ // on expression
+ $joinSpecArgArray[$j][] = ($join['on'] instanceof ExpressionInterface)
+ ? $this->processExpression($join['on'], $platform, $driver, $this->processInfo['paramPrefix'] . 'join')
+ : $platform->quoteIdentifierInFragment($join['on'], array('=', 'AND', 'OR', '(', ')', 'BETWEEN')); // on
+ if ($joinSpecArgArray[$j][2] instanceof StatementContainerInterface) {
+ if ($parameterContainer) {
+ $parameterContainer->merge($joinSpecArgArray[$j][2]->getParameterContainer());
+ }
+ $joinSpecArgArray[$j][2] = $joinSpecArgArray[$j][2]->getSql();
+ }
+ }
+
+ return array($joinSpecArgArray);
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Platform/PlatformDecoratorInterface.php zendframework-2.2.6/library/Zend/Db/Sql/Platform/PlatformDecoratorInterface.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Platform/PlatformDecoratorInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Platform/PlatformDecoratorInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+adapter = $adapter;
+ $platform = $adapter->getPlatform();
+ switch (strtolower($platform->getName())) {
+ case 'mysql':
+ $platform = new Mysql\Mysql();
+ $this->decorators = $platform->decorators;
+ break;
+ case 'sqlserver':
+ $platform = new SqlServer\SqlServer();
+ $this->decorators = $platform->decorators;
+ break;
+ case 'oracle':
+ $platform = new Oracle\Oracle();
+ $this->decorators = $platform->decorators;
+ break;
+ default:
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Platform/SqlServer/SelectDecorator.php zendframework-2.2.6/library/Zend/Db/Sql/Platform/SqlServer/SelectDecorator.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Platform/SqlServer/SelectDecorator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Platform/SqlServer/SelectDecorator.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,136 @@
+select = $select;
+ }
+
+ /**
+ * @param AdapterInterface $adapter
+ * @param StatementContainerInterface $statementContainer
+ */
+ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
+ {
+ // localize variables
+ foreach (get_object_vars($this->select) as $name => $value) {
+ $this->{$name} = $value;
+ }
+
+ // set specifications
+ unset($this->specifications[self::LIMIT]);
+ unset($this->specifications[self::OFFSET]);
+
+ $this->specifications['LIMITOFFSET'] = null;
+ parent::prepareStatement($adapter, $statementContainer);
+ }
+
+ /**
+ * @param PlatformInterface $platform
+ * @return string
+ */
+ public function getSqlString(PlatformInterface $platform = null)
+ {
+ // localize variables
+ foreach (get_object_vars($this->select) as $name => $value) {
+ $this->{$name} = $value;
+ }
+
+ // set specifications
+ unset($this->specifications[self::LIMIT]);
+ unset($this->specifications[self::OFFSET]);
+
+ $this->specifications['LIMITOFFSET'] = null;
+ return parent::getSqlString($platform);
+ }
+
+ /**
+ * @param PlatformInterface $platform
+ * @param DriverInterface $driver
+ * @param ParameterContainer $parameterContainer
+ * @param $sqls
+ * @param $parameters
+ * @return null
+ */
+ protected function processLimitOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null, &$sqls, &$parameters)
+ {
+ if ($this->limit === null && $this->offset === null) {
+ return null;
+ }
+
+ $selectParameters = $parameters[self::SELECT];
+
+ $starSuffix = $platform->getIdentifierSeparator() . self::SQL_STAR;
+ foreach ($selectParameters[0] as $i => $columnParameters) {
+ if ($columnParameters[0] == self::SQL_STAR || (isset($columnParameters[1]) && $columnParameters[1] == self::SQL_STAR) || strpos($columnParameters[0], $starSuffix)) {
+ $selectParameters[0] = array(array(self::SQL_STAR));
+ break;
+ }
+ if (isset($columnParameters[1])) {
+ array_shift($columnParameters);
+ $selectParameters[0][$i] = $columnParameters;
+ }
+ }
+
+ // first, produce column list without compound names (using the AS portion only)
+ array_unshift($sqls, $this->createSqlFromSpecificationAndParameters(
+ array('SELECT %1$s FROM (' => current($this->specifications[self::SELECT])),
+ $selectParameters
+ ));
+
+ if ($parameterContainer) {
+ // create bottom part of query, with offset and limit using row_number
+ array_push($sqls, ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ?+1 AND ?+?');
+ $parameterContainer->offsetSet('offset', $this->offset);
+ $parameterContainer->offsetSet('limit', $this->limit);
+ $parameterContainer->offsetSetReference('offsetForSum', 'offset');
+ } else {
+ array_push($sqls, ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN '
+ . (int) $this->offset . '+1 AND '
+ . (int) $this->limit . '+' . (int) $this->offset
+ );
+ }
+
+ if (isset($sqls[self::ORDER])) {
+ $orderBy = $sqls[self::ORDER];
+ unset($sqls[self::ORDER]);
+ } else {
+ $orderBy = 'ORDER BY (SELECT 1)';
+ }
+
+ // add a column for row_number() using the order specification
+ $parameters[self::SELECT][0][] = array('ROW_NUMBER() OVER (' . $orderBy . ')', '[__ZEND_ROW_NUMBER]');
+
+ $sqls[self::SELECT] = $this->createSqlFromSpecificationAndParameters(
+ $this->specifications[self::SELECT],
+ $parameters[self::SELECT]
+ );
+
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Platform/SqlServer/SqlServer.php zendframework-2.2.6/library/Zend/Db/Sql/Platform/SqlServer/SqlServer.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Platform/SqlServer/SqlServer.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Platform/SqlServer/SqlServer.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,21 @@
+setTypeDecorator('Zend\Db\Sql\Select', ($selectDecorator) ?: new SelectDecorator());
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Predicate/Between.php zendframework-2.2.6/library/Zend/Db/Sql/Predicate/Between.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Predicate/Between.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Predicate/Between.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,142 @@
+setIdentifier($identifier);
+ }
+ if ($minValue !== null) {
+ $this->setMinValue($minValue);
+ }
+ if ($maxValue !== null) {
+ $this->setMaxValue($maxValue);
+ }
+ }
+
+ /**
+ * Set identifier for comparison
+ *
+ * @param string $identifier
+ * @return Between
+ */
+ public function setIdentifier($identifier)
+ {
+ $this->identifier = $identifier;
+ return $this;
+ }
+
+ /**
+ * Get identifier of comparison
+ *
+ * @return null|string
+ */
+ public function getIdentifier()
+ {
+ return $this->identifier;
+ }
+
+ /**
+ * Set minimum boundary for comparison
+ *
+ * @param int|float|string $minValue
+ * @return Between
+ */
+ public function setMinValue($minValue)
+ {
+ $this->minValue = $minValue;
+ return $this;
+ }
+
+ /**
+ * Get minimum boundary for comparison
+ *
+ * @return null|int|float|string
+ */
+ public function getMinValue()
+ {
+ return $this->minValue;
+ }
+
+ /**
+ * Set maximum boundary for comparison
+ *
+ * @param int|float|string $maxValue
+ * @return Between
+ */
+ public function setMaxValue($maxValue)
+ {
+ $this->maxValue = $maxValue;
+ return $this;
+ }
+
+ /**
+ * Get maximum boundary for comparison
+ *
+ * @return null|int|float|string
+ */
+ public function getMaxValue()
+ {
+ return $this->maxValue;
+ }
+
+ /**
+ * Set specification string to use in forming SQL predicate
+ *
+ * @param string $specification
+ * @return Between
+ */
+ public function setSpecification($specification)
+ {
+ $this->specification = $specification;
+ return $this;
+ }
+
+ /**
+ * Get specification string to use in forming SQL predicate
+ *
+ * @return string
+ */
+ public function getSpecification()
+ {
+ return $this->specification;
+ }
+
+ /**
+ * Return "where" parts
+ *
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ return array(
+ array(
+ $this->getSpecification(),
+ array($this->identifier, $this->minValue, $this->maxValue),
+ array(self::TYPE_IDENTIFIER, self::TYPE_VALUE, self::TYPE_VALUE),
+ ),
+ );
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Predicate/Expression.php zendframework-2.2.6/library/Zend/Db/Sql/Predicate/Expression.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Predicate/Expression.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Predicate/Expression.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,42 @@
+setExpression($expression);
+ }
+
+ if (is_array($valueParameter)) {
+ $this->setParameters($valueParameter);
+ } else {
+ $argNum = func_num_args();
+ if ($argNum > 2 || is_scalar($valueParameter)) {
+ $parameters = array();
+ for ($i = 1; $i < $argNum; $i++) {
+ $parameters[] = func_get_arg($i);
+ }
+ $this->setParameters($parameters);
+ }
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Predicate/In.php zendframework-2.2.6/library/Zend/Db/Sql/Predicate/In.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Predicate/In.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Predicate/In.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,111 @@
+setIdentifier($identifier);
+ }
+ if ($valueSet) {
+ $this->setValueSet($valueSet);
+ }
+ }
+
+ /**
+ * Set identifier for comparison
+ *
+ * @param string $identifier
+ * @return In
+ */
+ public function setIdentifier($identifier)
+ {
+ $this->identifier = $identifier;
+ return $this;
+ }
+
+ /**
+ * Get identifier of comparison
+ *
+ * @return null|string
+ */
+ public function getIdentifier()
+ {
+ return $this->identifier;
+ }
+
+ /**
+ * Set set of values for IN comparison
+ *
+ * @param array $valueSet
+ * @throws Exception\InvalidArgumentException
+ * @return In
+ */
+ public function setValueSet($valueSet)
+ {
+ if (!is_array($valueSet) && !$valueSet instanceof Select) {
+ throw new Exception\InvalidArgumentException(
+ '$valueSet must be either an array or a Zend\Db\Sql\Select object, ' . gettype($valueSet) . ' given'
+ );
+ }
+ $this->valueSet = $valueSet;
+ return $this;
+ }
+
+ public function getValueSet()
+ {
+ return $this->valueSet;
+ }
+
+ /**
+ * Return array of parts for where statement
+ *
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ $values = $this->getValueSet();
+ if ($values instanceof Select) {
+ $specification = $this->selectSpecification;
+ $types = array(self::TYPE_VALUE);
+ $values = array($values);
+ } else {
+ $specification = sprintf($this->valueSpecSpecification, implode(', ', array_fill(0, count($values), '%s')));
+ $types = array_fill(0, count($values), self::TYPE_VALUE);
+ }
+
+ $identifier = $this->getIdentifier();
+ array_unshift($values, $identifier);
+ array_unshift($types, self::TYPE_IDENTIFIER);
+
+ return array(array(
+ $specification,
+ $values,
+ $types,
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Predicate/IsNotNull.php zendframework-2.2.6/library/Zend/Db/Sql/Predicate/IsNotNull.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Predicate/IsNotNull.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Predicate/IsNotNull.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+setIdentifier($identifier);
+ }
+ }
+
+ /**
+ * Set identifier for comparison
+ *
+ * @param string $identifier
+ * @return IsNull
+ */
+ public function setIdentifier($identifier)
+ {
+ $this->identifier = $identifier;
+ return $this;
+ }
+
+ /**
+ * Get identifier of comparison
+ *
+ * @return null|string
+ */
+ public function getIdentifier()
+ {
+ return $this->identifier;
+ }
+
+ /**
+ * Set specification string to use in forming SQL predicate
+ *
+ * @param string $specification
+ * @return IsNull
+ */
+ public function setSpecification($specification)
+ {
+ $this->specification = $specification;
+ return $this;
+ }
+
+ /**
+ * Get specification string to use in forming SQL predicate
+ *
+ * @return string
+ */
+ public function getSpecification()
+ {
+ return $this->specification;
+ }
+
+ /**
+ * Get parts for where statement
+ *
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ return array(array(
+ $this->getSpecification(),
+ array($this->identifier),
+ array(self::TYPE_IDENTIFIER),
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Predicate/Like.php zendframework-2.2.6/library/Zend/Db/Sql/Predicate/Like.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Predicate/Like.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Predicate/Like.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,107 @@
+setIdentifier($identifier);
+ }
+ if ($like) {
+ $this->setLike($like);
+ }
+ }
+
+ /**
+ * @param string $identifier
+ * @return self
+ */
+ public function setIdentifier($identifier)
+ {
+ $this->identifier = $identifier;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getIdentifier()
+ {
+ return $this->identifier;
+ }
+
+ /**
+ * @param string $like
+ * @return self
+ */
+ public function setLike($like)
+ {
+ $this->like = $like;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getLike()
+ {
+ return $this->like;
+ }
+
+ /**
+ * @param string $specification
+ * @return self
+ */
+ public function setSpecification($specification)
+ {
+ $this->specification = $specification;
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getSpecification()
+ {
+ return $this->specification;
+ }
+
+ /**
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ return array(
+ array($this->specification, array($this->identifier, $this->like), array(self::TYPE_IDENTIFIER, self::TYPE_VALUE))
+ );
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Predicate/Literal.php zendframework-2.2.6/library/Zend/Db/Sql/Predicate/Literal.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Predicate/Literal.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Predicate/Literal.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,17 @@
+';
+ const OP_GT = '>';
+
+ const OPERATOR_GREATER_THAN_OR_EQUAL_TO = '>=';
+ const OP_GTE = '>=';
+
+ protected $allowedTypes = array(
+ self::TYPE_IDENTIFIER,
+ self::TYPE_VALUE,
+ );
+
+ protected $left = null;
+ protected $leftType = self::TYPE_IDENTIFIER;
+ protected $operator = self::OPERATOR_EQUAL_TO;
+ protected $right = null;
+ protected $rightType = self::TYPE_VALUE;
+
+ /**
+ * Constructor
+ *
+ * @param int|float|bool|string $left
+ * @param string $operator
+ * @param int|float|bool|string $right
+ * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes}
+ * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes}
+ */
+ public function __construct($left = null, $operator = self::OPERATOR_EQUAL_TO, $right = null, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE)
+ {
+ if ($left !== null) {
+ $this->setLeft($left);
+ }
+
+ if ($operator !== self::OPERATOR_EQUAL_TO) {
+ $this->setOperator($operator);
+ }
+
+ if ($right !== null) {
+ $this->setRight($right);
+ }
+
+ if ($leftType !== self::TYPE_IDENTIFIER) {
+ $this->setLeftType($leftType);
+ }
+
+ if ($rightType !== self::TYPE_VALUE) {
+ $this->setRightType($rightType);
+ }
+ }
+
+ /**
+ * Set left side of operator
+ *
+ * @param int|float|bool|string $left
+ * @return Operator
+ */
+ public function setLeft($left)
+ {
+ $this->left = $left;
+ return $this;
+ }
+
+ /**
+ * Get left side of operator
+ *
+ * @return int|float|bool|string
+ */
+ public function getLeft()
+ {
+ return $this->left;
+ }
+
+ /**
+ * Set parameter type for left side of operator
+ *
+ * @param string $type TYPE_IDENTIFIER or TYPE_VALUE {@see allowedTypes}
+ * @throws Exception\InvalidArgumentException
+ * @return Operator
+ */
+ public function setLeftType($type)
+ {
+ if (!in_array($type, $this->allowedTypes)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Invalid type "%s" provided; must be of type "%s" or "%s"',
+ $type,
+ __CLASS__ . '::TYPE_IDENTIFIER',
+ __CLASS__ . '::TYPE_VALUE'
+ ));
+ }
+ $this->leftType = $type;
+ return $this;
+ }
+
+ /**
+ * Get parameter type on left side of operator
+ *
+ * @return string
+ */
+ public function getLeftType()
+ {
+ return $this->leftType;
+ }
+
+ /**
+ * Set operator string
+ *
+ * @param string $operator
+ * @return Operator
+ */
+ public function setOperator($operator)
+ {
+ $this->operator = $operator;
+ return $this;
+ }
+
+ /**
+ * Get operator string
+ *
+ * @return string
+ */
+ public function getOperator()
+ {
+ return $this->operator;
+ }
+
+ /**
+ * Set right side of operator
+ *
+ * @param int|float|bool|string $value
+ * @return Operator
+ */
+ public function setRight($value)
+ {
+ $this->right = $value;
+ return $this;
+ }
+
+ /**
+ * Get right side of operator
+ *
+ * @return int|float|bool|string
+ */
+ public function getRight()
+ {
+ return $this->right;
+ }
+
+ /**
+ * Set parameter type for right side of operator
+ *
+ * @param string $type TYPE_IDENTIFIER or TYPE_VALUE {@see allowedTypes}
+ * @throws Exception\InvalidArgumentException
+ * @return Operator
+ */
+ public function setRightType($type)
+ {
+ if (!in_array($type, $this->allowedTypes)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Invalid type "%s" provided; must be of type "%s" or "%s"',
+ $type,
+ __CLASS__ . '::TYPE_IDENTIFIER',
+ __CLASS__ . '::TYPE_VALUE'
+ ));
+ }
+ $this->rightType = $type;
+ return $this;
+ }
+
+ /**
+ * Get parameter type on right side of operator
+ *
+ * @return string
+ */
+ public function getRightType()
+ {
+ return $this->rightType;
+ }
+
+ /**
+ * Get predicate parts for where statement
+ *
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ return array(array(
+ '%s ' . $this->operator . ' %s',
+ array($this->left, $this->right),
+ array($this->leftType, $this->rightType)
+ ));
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Predicate/PredicateInterface.php zendframework-2.2.6/library/Zend/Db/Sql/Predicate/PredicateInterface.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Predicate/PredicateInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Predicate/PredicateInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,17 @@
+setUnnest($this);
+ $this->addPredicate($predicateSet, ($this->nextPredicateCombineOperator) ?: $this->defaultCombination);
+ $this->nextPredicateCombineOperator = null;
+ return $predicateSet;
+ }
+
+ /**
+ * Indicate what predicate will be unnested
+ *
+ * @param Predicate $predicate
+ * @return void
+ */
+ public function setUnnest(Predicate $predicate)
+ {
+ $this->unnest = $predicate;
+ }
+
+ /**
+ * Indicate end of nested predicate
+ *
+ * @return Predicate
+ * @throws RuntimeException
+ */
+ public function unnest()
+ {
+ if ($this->unnest == null) {
+ throw new RuntimeException('Not nested');
+ }
+ $unnset = $this->unnest;
+ $this->unnest = null;
+ return $unnset;
+ }
+
+ /**
+ * Create "Equal To" predicate
+ *
+ * Utilizes Operator predicate
+ *
+ * @param int|float|bool|string $left
+ * @param int|float|bool|string $right
+ * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes}
+ * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes}
+ * @return Predicate
+ */
+ public function equalTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE)
+ {
+ $this->addPredicate(
+ new Operator($left, Operator::OPERATOR_EQUAL_TO, $right, $leftType, $rightType),
+ ($this->nextPredicateCombineOperator) ?: $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+
+ return $this;
+ }
+
+ /**
+ * Create "Not Equal To" predicate
+ *
+ * Utilizes Operator predicate
+ *
+ * @param int|float|bool|string $left
+ * @param int|float|bool|string $right
+ * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes}
+ * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes}
+ * @return Predicate
+ */
+ public function notEqualTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE)
+ {
+ $this->addPredicate(
+ new Operator($left, Operator::OPERATOR_NOT_EQUAL_TO, $right, $leftType, $rightType),
+ ($this->nextPredicateCombineOperator) ?: $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+
+ return $this;
+ }
+
+ /**
+ * Create "Less Than" predicate
+ *
+ * Utilizes Operator predicate
+ *
+ * @param int|float|bool|string $left
+ * @param int|float|bool|string $right
+ * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes}
+ * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes}
+ * @return Predicate
+ */
+ public function lessThan($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE)
+ {
+ $this->addPredicate(
+ new Operator($left, Operator::OPERATOR_LESS_THAN, $right, $leftType, $rightType),
+ ($this->nextPredicateCombineOperator) ?: $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+
+ return $this;
+ }
+
+ /**
+ * Create "Greater Than" predicate
+ *
+ * Utilizes Operator predicate
+ *
+ * @param int|float|bool|string $left
+ * @param int|float|bool|string $right
+ * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes}
+ * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes}
+ * @return Predicate
+ */
+ public function greaterThan($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE)
+ {
+ $this->addPredicate(
+ new Operator($left, Operator::OPERATOR_GREATER_THAN, $right, $leftType, $rightType),
+ ($this->nextPredicateCombineOperator) ?: $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+
+ return $this;
+ }
+
+ /**
+ * Create "Less Than Or Equal To" predicate
+ *
+ * Utilizes Operator predicate
+ *
+ * @param int|float|bool|string $left
+ * @param int|float|bool|string $right
+ * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes}
+ * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes}
+ * @return Predicate
+ */
+ public function lessThanOrEqualTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE)
+ {
+ $this->addPredicate(
+ new Operator($left, Operator::OPERATOR_LESS_THAN_OR_EQUAL_TO, $right, $leftType, $rightType),
+ ($this->nextPredicateCombineOperator) ?: $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+
+ return $this;
+ }
+
+ /**
+ * Create "Greater Than Or Equal To" predicate
+ *
+ * Utilizes Operator predicate
+ *
+ * @param int|float|bool|string $left
+ * @param int|float|bool|string $right
+ * @param string $leftType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_IDENTIFIER {@see allowedTypes}
+ * @param string $rightType TYPE_IDENTIFIER or TYPE_VALUE by default TYPE_VALUE {@see allowedTypes}
+ * @return Predicate
+ */
+ public function greaterThanOrEqualTo($left, $right, $leftType = self::TYPE_IDENTIFIER, $rightType = self::TYPE_VALUE)
+ {
+ $this->addPredicate(
+ new Operator($left, Operator::OPERATOR_GREATER_THAN_OR_EQUAL_TO, $right, $leftType, $rightType),
+ ($this->nextPredicateCombineOperator) ?: $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+
+ return $this;
+ }
+
+ /**
+ * Create "Like" predicate
+ *
+ * Utilizes Like predicate
+ *
+ * @param string $identifier
+ * @param string $like
+ * @return Predicate
+ */
+ public function like($identifier, $like)
+ {
+ $this->addPredicate(
+ new Like($identifier, $like),
+ ($this->nextPredicateCombineOperator) ?: $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+
+ return $this;
+ }
+ /**
+ * Create "notLike" predicate
+ *
+ * Utilizes In predicate
+ *
+ * @param string $identifier
+ * @param string $notLike
+ * @return Predicate
+ */
+ public function notLike($identifier, $notLike)
+ {
+ $this->addPredicate(
+ new NotLike($identifier, $notLike),
+ ($this->nextPredicateCombineOperator) ? : $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+ return $this;
+ }
+
+ /**
+ * Create an expression, with parameter placeholders
+ *
+ * @param $expression
+ * @param $parameters
+ * @return $this
+ */
+ public function expression($expression, $parameters)
+ {
+ $this->addPredicate(
+ new Expression($expression, $parameters),
+ ($this->nextPredicateCombineOperator) ?: $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+
+ return $this;
+ }
+
+ /**
+ * Create "Literal" predicate
+ *
+ * Literal predicate, for parameters, use expression()
+ *
+ * @param string $literal
+ * @return Predicate
+ */
+ public function literal($literal)
+ {
+ // process deprecated parameters from previous literal($literal, $parameters = null) signature
+ if (func_num_args() >= 2) {
+ $parameters = func_get_arg(1);
+ $predicate = new Expression($literal, $parameters);
+ }
+
+ // normal workflow for "Literals" here
+ if (!isset($predicate)) {
+ $predicate = new Literal($literal);
+ }
+
+ $this->addPredicate(
+ $predicate,
+ ($this->nextPredicateCombineOperator) ?: $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+
+ return $this;
+ }
+
+ /**
+ * Create "IS NULL" predicate
+ *
+ * Utilizes IsNull predicate
+ *
+ * @param string $identifier
+ * @return Predicate
+ */
+ public function isNull($identifier)
+ {
+ $this->addPredicate(
+ new IsNull($identifier),
+ ($this->nextPredicateCombineOperator) ?: $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+
+ return $this;
+ }
+
+ /**
+ * Create "IS NOT NULL" predicate
+ *
+ * Utilizes IsNotNull predicate
+ *
+ * @param string $identifier
+ * @return Predicate
+ */
+ public function isNotNull($identifier)
+ {
+ $this->addPredicate(
+ new IsNotNull($identifier),
+ ($this->nextPredicateCombineOperator) ?: $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+
+ return $this;
+ }
+
+ /**
+ * Create "in" predicate
+ *
+ * Utilizes In predicate
+ *
+ * @param string $identifier
+ * @param array|\Zend\Db\Sql\Select $valueSet
+ * @return Predicate
+ */
+ public function in($identifier, $valueSet = null)
+ {
+ $this->addPredicate(
+ new In($identifier, $valueSet),
+ ($this->nextPredicateCombineOperator) ?: $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+
+ return $this;
+ }
+
+ /**
+ * Create "between" predicate
+ *
+ * Utilizes Between predicate
+ *
+ * @param string $identifier
+ * @param int|float|string $minValue
+ * @param int|float|string $maxValue
+ * @return Predicate
+ */
+ public function between($identifier, $minValue, $maxValue)
+ {
+ $this->addPredicate(
+ new Between($identifier, $minValue, $maxValue),
+ ($this->nextPredicateCombineOperator) ?: $this->defaultCombination
+ );
+ $this->nextPredicateCombineOperator = null;
+
+ return $this;
+ }
+
+ /**
+ * Overloading
+ *
+ * Overloads "or", "and", "nest", and "unnest"
+ *
+ * @param string $name
+ * @return Predicate
+ */
+ public function __get($name)
+ {
+ switch (strtolower($name)) {
+ case 'or':
+ $this->nextPredicateCombineOperator = self::OP_OR;
+ break;
+ case 'and':
+ $this->nextPredicateCombineOperator = self::OP_AND;
+ break;
+ case 'nest':
+ return $this->nest();
+ case 'unnest':
+ return $this->unnest();
+ }
+ return $this;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Predicate/PredicateSet.php zendframework-2.2.6/library/Zend/Db/Sql/Predicate/PredicateSet.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Predicate/PredicateSet.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Predicate/PredicateSet.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,136 @@
+defaultCombination = $defaultCombination;
+ if ($predicates) {
+ foreach ($predicates as $predicate) {
+ $this->addPredicate($predicate);
+ }
+ }
+ }
+
+ /**
+ * Add predicate to set
+ *
+ * @param PredicateInterface $predicate
+ * @param string $combination
+ * @return PredicateSet
+ */
+ public function addPredicate(PredicateInterface $predicate, $combination = null)
+ {
+ if ($combination === null || !in_array($combination, array(self::OP_AND, self::OP_OR))) {
+ $combination = $this->defaultCombination;
+ }
+
+ if ($combination == self::OP_OR) {
+ $this->orPredicate($predicate);
+ return $this;
+ }
+
+ $this->andPredicate($predicate);
+ return $this;
+ }
+
+ /**
+ * Return the predicates
+ *
+ * @return PredicateInterface[]
+ */
+ public function getPredicates()
+ {
+ return $this->predicates;
+ }
+
+ /**
+ * Add predicate using OR operator
+ *
+ * @param PredicateInterface $predicate
+ * @return PredicateSet
+ */
+ public function orPredicate(PredicateInterface $predicate)
+ {
+ $this->predicates[] = array(self::OP_OR, $predicate);
+ return $this;
+ }
+
+ /**
+ * Add predicate using AND operator
+ *
+ * @param PredicateInterface $predicate
+ * @return PredicateSet
+ */
+ public function andPredicate(PredicateInterface $predicate)
+ {
+ $this->predicates[] = array(self::OP_AND, $predicate);
+ return $this;
+ }
+
+ /**
+ * Get predicate parts for where statement
+ *
+ * @return array
+ */
+ public function getExpressionData()
+ {
+ $parts = array();
+ for ($i = 0, $count = count($this->predicates); $i < $count; $i++) {
+
+ /** @var $predicate PredicateInterface */
+ $predicate = $this->predicates[$i][1];
+
+ if ($predicate instanceof PredicateSet) {
+ $parts[] = '(';
+ }
+
+ $parts = array_merge($parts, $predicate->getExpressionData());
+
+ if ($predicate instanceof PredicateSet) {
+ $parts[] = ')';
+ }
+
+ if (isset($this->predicates[$i+1])) {
+ $parts[] = sprintf(' %s ', $this->predicates[$i+1][0]);
+ }
+ }
+ return $parts;
+ }
+
+ /**
+ * Get count of attached predicates
+ *
+ * @return int
+ */
+ public function count()
+ {
+ return count($this->predicates);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/PreparableSqlInterface.php zendframework-2.2.6/library/Zend/Db/Sql/PreparableSqlInterface.php
--- zendframework-1.10.4/library/Zend/Db/Sql/PreparableSqlInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/PreparableSqlInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,24 @@
+ '%1$s',
+ self::SELECT => array(
+ 'SELECT %1$s FROM %2$s' => array(
+ array(1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '),
+ null
+ ),
+ 'SELECT %1$s %2$s FROM %3$s' => array(
+ null,
+ array(1 => '%1$s', 2 => '%1$s AS %2$s', 'combinedby' => ', '),
+ null
+ ),
+ ),
+ self::JOINS => array(
+ '%1$s' => array(
+ array(3 => '%1$s JOIN %2$s ON %3$s', 'combinedby' => ' ')
+ )
+ ),
+ self::WHERE => 'WHERE %1$s',
+ self::GROUP => array(
+ 'GROUP BY %1$s' => array(
+ array(1 => '%1$s', 'combinedby' => ', ')
+ )
+ ),
+ self::HAVING => 'HAVING %1$s',
+ self::ORDER => array(
+ 'ORDER BY %1$s' => array(
+ array(1 => '%1$s', 2 => '%1$s %2$s', 'combinedby' => ', ')
+ )
+ ),
+ self::LIMIT => 'LIMIT %1$s',
+ self::OFFSET => 'OFFSET %1$s',
+ 'statementEnd' => '%1$s',
+ self::COMBINE => '%1$s ( %2$s )',
+ );
+
+ /**
+ * @var bool
+ */
+ protected $tableReadOnly = false;
+
+ /**
+ * @var bool
+ */
+ protected $prefixColumnsWithTable = true;
+
+ /**
+ * @var string|array|TableIdentifier
+ */
+ protected $table = null;
+
+ /**
+ * @var null|string|Expression
+ */
+ protected $quantifier = null;
+
+ /**
+ * @var array
+ */
+ protected $columns = array(self::SQL_STAR);
+
+ /**
+ * @var array
+ */
+ protected $joins = array();
+
+ /**
+ * @var Where
+ */
+ protected $where = null;
+
+ /**
+ * @var array
+ */
+ protected $order = array();
+
+ /**
+ * @var null|array
+ */
+ protected $group = null;
+
+ /**
+ * @var null|string|array
+ */
+ protected $having = null;
+
+ /**
+ * @var int|null
+ */
+ protected $limit = null;
+
+ /**
+ * @var int|null
+ */
+ protected $offset = null;
+
+ /**
+ * @var array
+ */
+ protected $combine = array();
+
+ /**
+ * Constructor
+ *
+ * @param null|string|array|TableIdentifier $table
+ */
+ public function __construct($table = null)
+ {
+ if ($table) {
+ $this->from($table);
+ $this->tableReadOnly = true;
+ }
+
+ $this->where = new Where;
+ $this->having = new Having;
+ }
+
+ /**
+ * Create from clause
+ *
+ * @param string|array|TableIdentifier $table
+ * @throws Exception\InvalidArgumentException
+ * @return Select
+ */
+ public function from($table)
+ {
+ if ($this->tableReadOnly) {
+ throw new Exception\InvalidArgumentException('Since this object was created with a table and/or schema in the constructor, it is read only.');
+ }
+
+ if (!is_string($table) && !is_array($table) && !$table instanceof TableIdentifier) {
+ throw new Exception\InvalidArgumentException('$table must be a string, array, or an instance of TableIdentifier');
+ }
+
+ if (is_array($table) && (!is_string(key($table)) || count($table) !== 1)) {
+ throw new Exception\InvalidArgumentException('from() expects $table as an array is a single element associative array');
+ }
+
+ $this->table = $table;
+ return $this;
+ }
+
+ /**
+ * @param string|Expression $quantifier DISTINCT|ALL
+ * @return Select
+ */
+ public function quantifier($quantifier)
+ {
+ if (!is_string($quantifier) && !$quantifier instanceof Expression) {
+ throw new Exception\InvalidArgumentException(
+ 'Quantifier must be one of DISTINCT, ALL, or some platform specific Expression object'
+ );
+ }
+ $this->quantifier = $quantifier;
+ return $this;
+ }
+
+ /**
+ * Specify columns from which to select
+ *
+ * Possible valid states:
+ *
+ * array(*)
+ *
+ * array(value, ...)
+ * value can be strings or Expression objects
+ *
+ * array(string => value, ...)
+ * key string will be use as alias,
+ * value can be string or Expression objects
+ *
+ * @param array $columns
+ * @param bool $prefixColumnsWithTable
+ * @return Select
+ */
+ public function columns(array $columns, $prefixColumnsWithTable = true)
+ {
+ $this->columns = $columns;
+ $this->prefixColumnsWithTable = (bool) $prefixColumnsWithTable;
+ return $this;
+ }
+
+ /**
+ * Create join clause
+ *
+ * @param string|array $name
+ * @param string $on
+ * @param string|array $columns
+ * @param string $type one of the JOIN_* constants
+ * @throws Exception\InvalidArgumentException
+ * @return Select
+ */
+ public function join($name, $on, $columns = self::SQL_STAR, $type = self::JOIN_INNER)
+ {
+ if (is_array($name) && (!is_string(key($name)) || count($name) !== 1)) {
+ throw new Exception\InvalidArgumentException(
+ sprintf("join() expects '%s' as an array is a single element associative array", array_shift($name))
+ );
+ }
+ if (!is_array($columns)) {
+ $columns = array($columns);
+ }
+ $this->joins[] = array(
+ 'name' => $name,
+ 'on' => $on,
+ 'columns' => $columns,
+ 'type' => $type
+ );
+ return $this;
+ }
+
+ /**
+ * Create where clause
+ *
+ * @param Where|\Closure|string|array|Predicate\PredicateInterface $predicate
+ * @param string $combination One of the OP_* constants from Predicate\PredicateSet
+ * @throws Exception\InvalidArgumentException
+ * @return Select
+ */
+ public function where($predicate, $combination = Predicate\PredicateSet::OP_AND)
+ {
+ if ($predicate instanceof Where) {
+ $this->where = $predicate;
+ } elseif ($predicate instanceof Predicate\PredicateInterface) {
+ $this->where->addPredicate($predicate, $combination);
+ } elseif ($predicate instanceof \Closure) {
+ $predicate($this->where);
+ } else {
+ if (is_string($predicate)) {
+ // String $predicate should be passed as an expression
+ $predicate = (strpos($predicate, Expression::PLACEHOLDER) !== false)
+ ? new Predicate\Expression($predicate) : new Predicate\Literal($predicate);
+ $this->where->addPredicate($predicate, $combination);
+ } elseif (is_array($predicate)) {
+
+ foreach ($predicate as $pkey => $pvalue) {
+ // loop through predicates
+
+ if (is_string($pkey) && strpos($pkey, '?') !== false) {
+ // First, process strings that the abstraction replacement character ?
+ // as an Expression predicate
+ $predicate = new Predicate\Expression($pkey, $pvalue);
+
+ } elseif (is_string($pkey)) {
+ // Otherwise, if still a string, do something intelligent with the PHP type provided
+
+ if ($pvalue === null) {
+ // map PHP null to SQL IS NULL expression
+ $predicate = new Predicate\IsNull($pkey, $pvalue);
+ } elseif (is_array($pvalue)) {
+ // if the value is an array, assume IN() is desired
+ $predicate = new Predicate\In($pkey, $pvalue);
+ } elseif ($pvalue instanceof Predicate\PredicateInterface) {
+ //
+ throw new Exception\InvalidArgumentException(
+ 'Using Predicate must not use string keys'
+ );
+ } else {
+ // otherwise assume that array('foo' => 'bar') means "foo" = 'bar'
+ $predicate = new Predicate\Operator($pkey, Predicate\Operator::OP_EQ, $pvalue);
+ }
+ } elseif ($pvalue instanceof Predicate\PredicateInterface) {
+ // Predicate type is ok
+ $predicate = $pvalue;
+ } else {
+ // must be an array of expressions (with int-indexed array)
+ $predicate = (strpos($pvalue, Expression::PLACEHOLDER) !== false)
+ ? new Predicate\Expression($pvalue) : new Predicate\Literal($pvalue);
+ }
+ $this->where->addPredicate($predicate, $combination);
+ }
+ }
+ }
+ return $this;
+ }
+
+ public function group($group)
+ {
+ if (is_array($group)) {
+ foreach ($group as $o) {
+ $this->group[] = $o;
+ }
+ } else {
+ $this->group[] = $group;
+ }
+ return $this;
+ }
+
+ /**
+ * Create where clause
+ *
+ * @param Where|\Closure|string|array $predicate
+ * @param string $combination One of the OP_* constants from Predicate\PredicateSet
+ * @return Select
+ */
+ public function having($predicate, $combination = Predicate\PredicateSet::OP_AND)
+ {
+ if ($predicate instanceof Having) {
+ $this->having = $predicate;
+ } elseif ($predicate instanceof \Closure) {
+ $predicate($this->having);
+ } else {
+ if (is_string($predicate)) {
+ $predicate = new Predicate\Expression($predicate);
+ $this->having->addPredicate($predicate, $combination);
+ } elseif (is_array($predicate)) {
+ foreach ($predicate as $pkey => $pvalue) {
+ if (is_string($pkey) && strpos($pkey, '?') !== false) {
+ $predicate = new Predicate\Expression($pkey, $pvalue);
+ } elseif (is_string($pkey)) {
+ $predicate = new Predicate\Operator($pkey, Predicate\Operator::OP_EQ, $pvalue);
+ } else {
+ $predicate = new Predicate\Expression($pvalue);
+ }
+ $this->having->addPredicate($predicate, $combination);
+ }
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * @param string|array $order
+ * @return Select
+ */
+ public function order($order)
+ {
+ if (is_string($order)) {
+ if (strpos($order, ',') !== false) {
+ $order = preg_split('#,\s+#', $order);
+ } else {
+ $order = (array) $order;
+ }
+ } elseif (!is_array($order)) {
+ $order = array($order);
+ }
+ foreach ($order as $k => $v) {
+ if (is_string($k)) {
+ $this->order[$k] = $v;
+ } else {
+ $this->order[] = $v;
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * @param int $limit
+ * @return Select
+ */
+ public function limit($limit)
+ {
+ if (!is_numeric($limit)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s expects parameter to be numeric, "%s" given',
+ __METHOD__,
+ (is_object($limit) ? get_class($limit) : gettype($limit))
+ ));
+ }
+
+ $this->limit = $limit;
+ return $this;
+ }
+
+ /**
+ * @param int $offset
+ * @return Select
+ */
+ public function offset($offset)
+ {
+ if (!is_numeric($offset)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s expects parameter to be numeric, "%s" given',
+ __METHOD__,
+ (is_object($offset) ? get_class($offset) : gettype($offset))
+ ));
+ }
+
+ $this->offset = $offset;
+ return $this;
+ }
+
+ /**
+ * @param Select $select
+ * @param string $type
+ * @param string $modifier
+ * @return Select
+ * @throws Exception\InvalidArgumentException
+ */
+ public function combine(Select $select, $type = self::COMBINE_UNION, $modifier = '')
+ {
+ if ($this->combine !== array()) {
+ throw new Exception\InvalidArgumentException('This Select object is already combined and cannot be combined with multiple Selects objects');
+ }
+ $this->combine = array(
+ 'select' => $select,
+ 'type' => $type,
+ 'modifier' => $modifier
+ );
+ return $this;
+ }
+
+ /**
+ * @param string $part
+ * @return Select
+ * @throws Exception\InvalidArgumentException
+ */
+ public function reset($part)
+ {
+ switch ($part) {
+ case self::TABLE:
+ if ($this->tableReadOnly) {
+ throw new Exception\InvalidArgumentException(
+ 'Since this object was created with a table and/or schema in the constructor, it is read only.'
+ );
+ }
+ $this->table = null;
+ break;
+ case self::QUANTIFIER:
+ $this->quantifier = null;
+ break;
+ case self::COLUMNS:
+ $this->columns = array();
+ break;
+ case self::JOINS:
+ $this->joins = array();
+ break;
+ case self::WHERE:
+ $this->where = new Where;
+ break;
+ case self::GROUP:
+ $this->group = null;
+ break;
+ case self::HAVING:
+ $this->having = new Having;
+ break;
+ case self::LIMIT:
+ $this->limit = null;
+ break;
+ case self::OFFSET:
+ $this->offset = null;
+ break;
+ case self::ORDER:
+ $this->order = array();
+ break;
+ case self::COMBINE:
+ $this->combine = array();
+ break;
+ }
+ return $this;
+ }
+
+ public function setSpecification($index, $specification)
+ {
+ if (!method_exists($this, 'process' . $index)) {
+ throw new Exception\InvalidArgumentException('Not a valid specification name.');
+ }
+ $this->specifications[$index] = $specification;
+ return $this;
+ }
+
+ public function getRawState($key = null)
+ {
+ $rawState = array(
+ self::TABLE => $this->table,
+ self::QUANTIFIER => $this->quantifier,
+ self::COLUMNS => $this->columns,
+ self::JOINS => $this->joins,
+ self::WHERE => $this->where,
+ self::ORDER => $this->order,
+ self::GROUP => $this->group,
+ self::HAVING => $this->having,
+ self::LIMIT => $this->limit,
+ self::OFFSET => $this->offset,
+ self::COMBINE => $this->combine
+ );
+ return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState;
+ }
+
+ /**
+ * Prepare statement
+ *
+ * @param AdapterInterface $adapter
+ * @param StatementContainerInterface $statementContainer
+ * @return void
+ */
+ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
+ {
+ // ensure statement has a ParameterContainer
+ $parameterContainer = $statementContainer->getParameterContainer();
+ if (!$parameterContainer instanceof ParameterContainer) {
+ $parameterContainer = new ParameterContainer();
+ $statementContainer->setParameterContainer($parameterContainer);
+ }
+
+ $sqls = array();
+ $parameters = array();
+ $platform = $adapter->getPlatform();
+ $driver = $adapter->getDriver();
+
+ foreach ($this->specifications as $name => $specification) {
+ $parameters[$name] = $this->{'process' . $name}($platform, $driver, $parameterContainer, $sqls, $parameters);
+ if ($specification && is_array($parameters[$name])) {
+ $sqls[$name] = $this->createSqlFromSpecificationAndParameters($specification, $parameters[$name]);
+ }
+ }
+
+ $sql = implode(' ', $sqls);
+
+ $statementContainer->setSql($sql);
+ return;
+ }
+
+ /**
+ * Get SQL string for statement
+ *
+ * @param null|PlatformInterface $adapterPlatform If null, defaults to Sql92
+ * @return string
+ */
+ public function getSqlString(PlatformInterface $adapterPlatform = null)
+ {
+ // get platform, or create default
+ $adapterPlatform = ($adapterPlatform) ?: new AdapterSql92Platform;
+
+ $sqls = array();
+ $parameters = array();
+
+ foreach ($this->specifications as $name => $specification) {
+ $parameters[$name] = $this->{'process' . $name}($adapterPlatform, null, null, $sqls, $parameters);
+ if ($specification && is_array($parameters[$name])) {
+ $sqls[$name] = $this->createSqlFromSpecificationAndParameters($specification, $parameters[$name]);
+ }
+ }
+
+ $sql = implode(' ', $sqls);
+ return $sql;
+ }
+
+ /**
+ * Returns whether the table is read only or not.
+ *
+ * @return bool
+ */
+ public function isTableReadOnly()
+ {
+ return $this->tableReadOnly;
+ }
+
+ /**
+ * Render table with alias in from/join parts
+ *
+ * @todo move TableIdentifier concatination here
+ * @param string $table
+ * @param string $alias
+ * @return string
+ */
+ protected function renderTable($table, $alias = null)
+ {
+ $sql = $table;
+ if ($alias) {
+ $sql .= ' AS ' . $alias;
+ }
+ return $sql;
+ }
+
+ protected function processStatementStart(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if ($this->combine !== array()) {
+ return array('(');
+ }
+ }
+
+ protected function processStatementEnd(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if ($this->combine !== array()) {
+ return array(')');
+ }
+ }
+
+ /**
+ * Process the select part
+ *
+ * @param PlatformInterface $platform
+ * @param DriverInterface $driver
+ * @param ParameterContainer $parameterContainer
+ * @return null|array
+ */
+ protected function processSelect(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ $expr = 1;
+
+ if (!$this->table) {
+ return null;
+ }
+
+ $table = $this->table;
+ $schema = $alias = null;
+
+ if (is_array($table)) {
+ $alias = key($this->table);
+ $table = current($this->table);
+ }
+
+ // create quoted table name to use in columns processing
+ if ($table instanceof TableIdentifier) {
+ list($table, $schema) = $table->getTableAndSchema();
+ }
+
+ if ($table instanceof Select) {
+ $table = '(' . $this->processSubselect($table, $platform, $driver, $parameterContainer) . ')';
+ } else {
+ $table = $platform->quoteIdentifier($table);
+ }
+
+ if ($schema) {
+ $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table;
+ }
+
+ if ($alias) {
+ $fromTable = $platform->quoteIdentifier($alias);
+ $table = $this->renderTable($table, $fromTable);
+ } else {
+ $fromTable = $table;
+ }
+
+ if ($this->prefixColumnsWithTable) {
+ $fromTable .= $platform->getIdentifierSeparator();
+ } else {
+ $fromTable = '';
+ }
+
+ // process table columns
+ $columns = array();
+ foreach ($this->columns as $columnIndexOrAs => $column) {
+
+ $columnName = '';
+ if ($column === self::SQL_STAR) {
+ $columns[] = array($fromTable . self::SQL_STAR);
+ continue;
+ }
+
+ if ($column instanceof Expression) {
+ $columnParts = $this->processExpression(
+ $column,
+ $platform,
+ $driver,
+ $this->processInfo['paramPrefix'] . ((is_string($columnIndexOrAs)) ? $columnIndexOrAs : 'column')
+ );
+ if ($parameterContainer) {
+ $parameterContainer->merge($columnParts->getParameterContainer());
+ }
+ $columnName .= $columnParts->getSql();
+ } else {
+ $columnName .= $fromTable . $platform->quoteIdentifier($column);
+ }
+
+ // process As portion
+ if (is_string($columnIndexOrAs)) {
+ $columnAs = $platform->quoteIdentifier($columnIndexOrAs);
+ } elseif (stripos($columnName, ' as ') === false) {
+ $columnAs = (is_string($column)) ? $platform->quoteIdentifier($column) : 'Expression' . $expr++;
+ }
+ $columns[] = (isset($columnAs)) ? array($columnName, $columnAs) : array($columnName);
+ }
+
+ $separator = $platform->getIdentifierSeparator();
+
+ // process join columns
+ foreach ($this->joins as $join) {
+ foreach ($join['columns'] as $jKey => $jColumn) {
+ $jColumns = array();
+ if ($jColumn instanceof ExpressionInterface) {
+ $jColumnParts = $this->processExpression(
+ $jColumn,
+ $platform,
+ $driver,
+ $this->processInfo['paramPrefix'] . ((is_string($jKey)) ? $jKey : 'column')
+ );
+ if ($parameterContainer) {
+ $parameterContainer->merge($jColumnParts->getParameterContainer());
+ }
+ $jColumns[] = $jColumnParts->getSql();
+ } else {
+ $name = (is_array($join['name'])) ? key($join['name']) : $name = $join['name'];
+ if ($name instanceof TableIdentifier) {
+ $name = $platform->quoteIdentifier($name->getSchema()) . $separator . $platform->quoteIdentifier($name->getTable());
+ } else {
+ $name = $platform->quoteIdentifier($name);
+ }
+ $jColumns[] = $name . $separator . $platform->quoteIdentifierInFragment($jColumn);
+ }
+ if (is_string($jKey)) {
+ $jColumns[] = $platform->quoteIdentifier($jKey);
+ } elseif ($jColumn !== self::SQL_STAR) {
+ $jColumns[] = $platform->quoteIdentifier($jColumn);
+ }
+ $columns[] = $jColumns;
+ }
+ }
+
+ if ($this->quantifier) {
+ if ($this->quantifier instanceof Expression) {
+ $quantifierParts = $this->processExpression($this->quantifier, $platform, $driver, 'quantifier');
+ if ($parameterContainer) {
+ $parameterContainer->merge($quantifierParts->getParameterContainer());
+ }
+ $quantifier = $quantifierParts->getSql();
+ } else {
+ $quantifier = $this->quantifier;
+ }
+ }
+
+ if (isset($quantifier)) {
+ return array($quantifier, $columns, $table);
+ } else {
+ return array($columns, $table);
+ }
+ }
+
+ protected function processJoins(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if (!$this->joins) {
+ return null;
+ }
+
+ // process joins
+ $joinSpecArgArray = array();
+ foreach ($this->joins as $j => $join) {
+ $joinSpecArgArray[$j] = array();
+ $joinName = null;
+ $joinAs = null;
+
+ // type
+ $joinSpecArgArray[$j][] = strtoupper($join['type']);
+
+ // table name
+ if (is_array($join['name'])) {
+ $joinName = current($join['name']);
+ $joinAs = $platform->quoteIdentifier(key($join['name']));
+ } else {
+ $joinName = $join['name'];
+ }
+ if ($joinName instanceof TableIdentifier) {
+ $joinName = $joinName->getTableAndSchema();
+ $joinName = $platform->quoteIdentifier($joinName[1]) . $platform->getIdentifierSeparator() . $platform->quoteIdentifier($joinName[0]);
+ } else {
+ if ($joinName instanceof Select) {
+ $joinName = '(' . $joinName->processSubSelect($joinName, $platform, $driver, $parameterContainer) . ')';
+ } else {
+ $joinName = $platform->quoteIdentifier($joinName);
+ }
+ }
+ $joinSpecArgArray[$j][] = (isset($joinAs)) ? $joinName . ' AS ' . $joinAs : $joinName;
+
+ // on expression
+ // note: for Expression objects, pass them to processExpression with a prefix specific to each join (used for named parameters)
+ $joinSpecArgArray[$j][] = ($join['on'] instanceof ExpressionInterface)
+ ? $this->processExpression($join['on'], $platform, $driver, $this->processInfo['paramPrefix'] . 'join' . ($j+1) . 'part')
+ : $platform->quoteIdentifierInFragment($join['on'], array('=', 'AND', 'OR', '(', ')', 'BETWEEN', '<', '>')); // on
+ if ($joinSpecArgArray[$j][2] instanceof StatementContainerInterface) {
+ if ($parameterContainer) {
+ $parameterContainer->merge($joinSpecArgArray[$j][2]->getParameterContainer());
+ }
+ $joinSpecArgArray[$j][2] = $joinSpecArgArray[$j][2]->getSql();
+ }
+ }
+
+ return array($joinSpecArgArray);
+ }
+
+ protected function processWhere(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if ($this->where->count() == 0) {
+ return null;
+ }
+ $whereParts = $this->processExpression($this->where, $platform, $driver, $this->processInfo['paramPrefix'] . 'where');
+ if ($parameterContainer) {
+ $parameterContainer->merge($whereParts->getParameterContainer());
+ }
+ return array($whereParts->getSql());
+ }
+
+ protected function processGroup(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if ($this->group === null) {
+ return null;
+ }
+ // process table columns
+ $groups = array();
+ foreach ($this->group as $column) {
+ $columnSql = '';
+ if ($column instanceof Expression) {
+ $columnParts = $this->processExpression($column, $platform, $driver, $this->processInfo['paramPrefix'] . 'group');
+ if ($parameterContainer) {
+ $parameterContainer->merge($columnParts->getParameterContainer());
+ }
+ $columnSql .= $columnParts->getSql();
+ } else {
+ $columnSql .= $platform->quoteIdentifierInFragment($column);
+ }
+ $groups[] = $columnSql;
+ }
+ return array($groups);
+ }
+
+ protected function processHaving(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if ($this->having->count() == 0) {
+ return null;
+ }
+ $whereParts = $this->processExpression($this->having, $platform, $driver, $this->processInfo['paramPrefix'] . 'having');
+ if ($parameterContainer) {
+ $parameterContainer->merge($whereParts->getParameterContainer());
+ }
+ return array($whereParts->getSql());
+ }
+
+ protected function processOrder(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if (empty($this->order)) {
+ return null;
+ }
+ $orders = array();
+ foreach ($this->order as $k => $v) {
+ if ($v instanceof Expression) {
+ /** @var $orderParts \Zend\Db\Adapter\StatementContainer */
+ $orderParts = $this->processExpression($v, $platform, $driver);
+ if ($parameterContainer) {
+ $parameterContainer->merge($orderParts->getParameterContainer());
+ }
+ $orders[] = array($orderParts->getSql());
+ continue;
+ }
+ if (is_int($k)) {
+ if (strpos($v, ' ') !== false) {
+ list($k, $v) = preg_split('# #', $v, 2);
+ } else {
+ $k = $v;
+ $v = self::ORDER_ASCENDING;
+ }
+ }
+ if (strtoupper($v) == self::ORDER_DESCENDING) {
+ $orders[] = array($platform->quoteIdentifierInFragment($k), self::ORDER_DESCENDING);
+ } else {
+ $orders[] = array($platform->quoteIdentifierInFragment($k), self::ORDER_ASCENDING);
+ }
+ }
+ return array($orders);
+ }
+
+ protected function processLimit(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if ($this->limit === null) {
+ return null;
+ }
+
+ $limit = (int) $this->limit;
+
+ if ($driver) {
+ $sql = $driver->formatParameterName('limit');
+ $parameterContainer->offsetSet('limit', $limit, ParameterContainer::TYPE_INTEGER);
+ } else {
+ $sql = $platform->quoteValue($limit);
+ }
+
+ return array($sql);
+ }
+
+ protected function processOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if ($this->offset === null) {
+ return null;
+ }
+
+ $offset = (int) $this->offset;
+
+ if ($driver) {
+ $parameterContainer->offsetSet('offset', $offset, ParameterContainer::TYPE_INTEGER);
+ return array($driver->formatParameterName('offset'));
+ }
+
+ return array($platform->quoteValue($offset));
+ }
+
+ protected function processCombine(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
+ {
+ if ($this->combine == array()) {
+ return null;
+ }
+
+ $type = $this->combine['type'];
+ if ($this->combine['modifier']) {
+ $type .= ' ' . $this->combine['modifier'];
+ }
+ $type = strtoupper($type);
+
+ if ($driver) {
+ $sql = $this->processSubSelect($this->combine['select'], $platform, $driver, $parameterContainer);
+ return array($type, $sql);
+ }
+ return array(
+ $type,
+ $this->processSubSelect($this->combine['select'], $platform)
+ );
+ }
+
+ /**
+ * Variable overloading
+ *
+ * @param string $name
+ * @throws Exception\InvalidArgumentException
+ * @return mixed
+ */
+ public function __get($name)
+ {
+ switch (strtolower($name)) {
+ case 'where':
+ return $this->where;
+ case 'having':
+ return $this->having;
+ default:
+ throw new Exception\InvalidArgumentException('Not a valid magic property for this object');
+ }
+ }
+
+ /**
+ * __clone
+ *
+ * Resets the where object each time the Select is cloned.
+ *
+ * @return void
+ */
+ public function __clone()
+ {
+ $this->where = clone $this->where;
+ $this->having = clone $this->having;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/SqlInterface.php zendframework-2.2.6/library/Zend/Db/Sql/SqlInterface.php
--- zendframework-1.10.4/library/Zend/Db/Sql/SqlInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/SqlInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,17 @@
+adapter = $adapter;
+ if ($table) {
+ $this->setTable($table);
+ }
+ $this->sqlPlatform = ($sqlPlatform) ?: new Platform\Platform($adapter);
+ }
+
+ /**
+ * @return null|\Zend\Db\Adapter\AdapterInterface
+ */
+ public function getAdapter()
+ {
+ return $this->adapter;
+ }
+
+ public function hasTable()
+ {
+ return ($this->table != null);
+ }
+
+ public function setTable($table)
+ {
+ if (is_string($table) || is_array($table) || $table instanceof TableIdentifier) {
+ $this->table = $table;
+ } else {
+ throw new Exception\InvalidArgumentException('Table must be a string, array or instance of TableIdentifier.');
+ }
+ return $this;
+ }
+
+ public function getTable()
+ {
+ return $this->table;
+ }
+
+ public function getSqlPlatform()
+ {
+ return $this->sqlPlatform;
+ }
+
+ public function select($table = null)
+ {
+ if ($this->table !== null && $table !== null) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'This Sql object is intended to work with only the table "%s" provided at construction time.',
+ $this->table
+ ));
+ }
+ return new Select(($table) ?: $this->table);
+ }
+
+ public function insert($table = null)
+ {
+ if ($this->table !== null && $table !== null) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'This Sql object is intended to work with only the table "%s" provided at construction time.',
+ $this->table
+ ));
+ }
+ return new Insert(($table) ?: $this->table);
+ }
+
+ public function update($table = null)
+ {
+ if ($this->table !== null && $table !== null) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'This Sql object is intended to work with only the table "%s" provided at construction time.',
+ $this->table
+ ));
+ }
+ return new Update(($table) ?: $this->table);
+ }
+
+ public function delete($table = null)
+ {
+ if ($this->table !== null && $table !== null) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'This Sql object is intended to work with only the table "%s" provided at construction time.',
+ $this->table
+ ));
+ }
+ return new Delete(($table) ?: $this->table);
+ }
+
+ /**
+ * @param PreparableSqlInterface $sqlObject
+ * @param StatementInterface|null $statement
+ * @return StatementInterface
+ */
+ public function prepareStatementForSqlObject(PreparableSqlInterface $sqlObject, StatementInterface $statement = null)
+ {
+ $statement = ($statement) ?: $this->adapter->getDriver()->createStatement();
+
+ if ($this->sqlPlatform) {
+ $this->sqlPlatform->setSubject($sqlObject);
+ $this->sqlPlatform->prepareStatement($this->adapter, $statement);
+ } else {
+ $sqlObject->prepareStatement($this->adapter, $statement);
+ }
+
+ return $statement;
+ }
+
+ public function getSqlStringForSqlObject(SqlInterface $sqlObject, PlatformInterface $platform = null)
+ {
+ $platform = ($platform) ?: $this->adapter->getPlatform();
+
+ if ($this->sqlPlatform) {
+ $this->sqlPlatform->setSubject($sqlObject);
+ $sqlString = $this->sqlPlatform->getSqlString($platform);
+ } else {
+ $sqlString = $sqlObject->getSqlString($platform);
+ }
+
+ return $sqlString;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/TableIdentifier.php zendframework-2.2.6/library/Zend/Db/Sql/TableIdentifier.php
--- zendframework-1.10.4/library/Zend/Db/Sql/TableIdentifier.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/TableIdentifier.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,81 @@
+table = $table;
+ $this->schema = $schema;
+ }
+
+ /**
+ * @param string $table
+ */
+ public function setTable($table)
+ {
+ $this->table = $table;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTable()
+ {
+ return $this->table;
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasSchema()
+ {
+ return ($this->schema != null);
+ }
+
+ /**
+ * @param $schema
+ */
+ public function setSchema($schema)
+ {
+ $this->schema = $schema;
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getSchema()
+ {
+ return $this->schema;
+ }
+
+ public function getTableAndSchema()
+ {
+ return array($this->table, $this->schema);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Update.php zendframework-2.2.6/library/Zend/Db/Sql/Update.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Update.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Update.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,316 @@
+ 'UPDATE %1$s SET %2$s',
+ self::SPECIFICATION_WHERE => 'WHERE %1$s'
+ );
+
+ /**
+ * @var string|TableIdentifier
+ */
+ protected $table = '';
+
+ /**
+ * @var bool
+ */
+ protected $emptyWhereProtection = true;
+
+ /**
+ * @var array
+ */
+ protected $set = array();
+
+ /**
+ * @var string|Where
+ */
+ protected $where = null;
+
+ /**
+ * Constructor
+ *
+ * @param null|string|TableIdentifier $table
+ */
+ public function __construct($table = null)
+ {
+ if ($table) {
+ $this->table($table);
+ }
+ $this->where = new Where();
+ }
+
+ /**
+ * Specify table for statement
+ *
+ * @param string|TableIdentifier $table
+ * @return Update
+ */
+ public function table($table)
+ {
+ $this->table = $table;
+ return $this;
+ }
+
+ /**
+ * Set key/value pairs to update
+ *
+ * @param array $values Associative array of key values
+ * @param string $flag One of the VALUES_* constants
+ * @throws Exception\InvalidArgumentException
+ * @return Update
+ */
+ public function set(array $values, $flag = self::VALUES_SET)
+ {
+ if ($values == null) {
+ throw new Exception\InvalidArgumentException('set() expects an array of values');
+ }
+
+ if ($flag == self::VALUES_SET) {
+ $this->set = array();
+ }
+
+ foreach ($values as $k => $v) {
+ if (!is_string($k)) {
+ throw new Exception\InvalidArgumentException('set() expects a string for the value key');
+ }
+ $this->set[$k] = $v;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Create where clause
+ *
+ * @param Where|\Closure|string|array $predicate
+ * @param string $combination One of the OP_* constants from Predicate\PredicateSet
+ * @throws Exception\InvalidArgumentException
+ * @return Select
+ */
+ public function where($predicate, $combination = Predicate\PredicateSet::OP_AND)
+ {
+ if ($predicate === null) {
+ throw new Exception\InvalidArgumentException('Predicate cannot be null');
+ }
+
+ if ($predicate instanceof Where) {
+ $this->where = $predicate;
+ } elseif ($predicate instanceof \Closure) {
+ $predicate($this->where);
+ } else {
+ if (is_string($predicate)) {
+ // String $predicate should be passed as an expression
+ $predicate = new Predicate\Expression($predicate);
+ $this->where->addPredicate($predicate, $combination);
+ } elseif (is_array($predicate)) {
+
+ foreach ($predicate as $pkey => $pvalue) {
+ // loop through predicates
+
+ if (is_string($pkey) && strpos($pkey, '?') !== false) {
+ // First, process strings that the abstraction replacement character ?
+ // as an Expression predicate
+ $predicate = new Predicate\Expression($pkey, $pvalue);
+
+ } elseif (is_string($pkey)) {
+ // Otherwise, if still a string, do something intelligent with the PHP type provided
+
+ if ($pvalue === null) {
+ // map PHP null to SQL IS NULL expression
+ $predicate = new Predicate\IsNull($pkey, $pvalue);
+ } elseif (is_array($pvalue)) {
+ // if the value is an array, assume IN() is desired
+ $predicate = new Predicate\In($pkey, $pvalue);
+ } else {
+ // otherwise assume that array('foo' => 'bar') means "foo" = 'bar'
+ $predicate = new Predicate\Operator($pkey, Predicate\Operator::OP_EQ, $pvalue);
+ }
+ } elseif ($pvalue instanceof Predicate\PredicateInterface) {
+ // Predicate type is ok
+ $predicate = $pvalue;
+ } else {
+ // must be an array of expressions (with int-indexed array)
+ $predicate = new Predicate\Expression($pvalue);
+ }
+ $this->where->addPredicate($predicate, $combination);
+ }
+ }
+ }
+ return $this;
+ }
+
+ public function getRawState($key = null)
+ {
+ $rawState = array(
+ 'emptyWhereProtection' => $this->emptyWhereProtection,
+ 'table' => $this->table,
+ 'set' => $this->set,
+ 'where' => $this->where
+ );
+ return (isset($key) && array_key_exists($key, $rawState)) ? $rawState[$key] : $rawState;
+ }
+
+ /**
+ * Prepare statement
+ *
+ * @param AdapterInterface $adapter
+ * @param StatementContainerInterface $statementContainer
+ * @return void
+ */
+ public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
+ {
+ $driver = $adapter->getDriver();
+ $platform = $adapter->getPlatform();
+ $parameterContainer = $statementContainer->getParameterContainer();
+
+ if (!$parameterContainer instanceof ParameterContainer) {
+ $parameterContainer = new ParameterContainer();
+ $statementContainer->setParameterContainer($parameterContainer);
+ }
+
+ $table = $this->table;
+ $schema = null;
+
+ // create quoted table name to use in update processing
+ if ($table instanceof TableIdentifier) {
+ list($table, $schema) = $table->getTableAndSchema();
+ }
+
+ $table = $platform->quoteIdentifier($table);
+
+ if ($schema) {
+ $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table;
+ }
+
+ $set = $this->set;
+ if (is_array($set)) {
+ $setSql = array();
+ foreach ($set as $column => $value) {
+ if ($value instanceof Expression) {
+ $exprData = $this->processExpression($value, $platform, $driver);
+ $setSql[] = $platform->quoteIdentifier($column) . ' = ' . $exprData->getSql();
+ $parameterContainer->merge($exprData->getParameterContainer());
+ } else {
+ $setSql[] = $platform->quoteIdentifier($column) . ' = ' . $driver->formatParameterName($column);
+ $parameterContainer->offsetSet($column, $value);
+ }
+ }
+ $set = implode(', ', $setSql);
+ }
+
+ $sql = sprintf($this->specifications[self::SPECIFICATION_UPDATE], $table, $set);
+
+ // process where
+ if ($this->where->count() > 0) {
+ $whereParts = $this->processExpression($this->where, $platform, $driver, 'where');
+ $parameterContainer->merge($whereParts->getParameterContainer());
+ $sql .= ' ' . sprintf($this->specifications[self::SPECIFICATION_WHERE], $whereParts->getSql());
+ }
+ $statementContainer->setSql($sql);
+ }
+
+ /**
+ * Get SQL string for statement
+ *
+ * @param null|PlatformInterface $adapterPlatform If null, defaults to Sql92
+ * @return string
+ */
+ public function getSqlString(PlatformInterface $adapterPlatform = null)
+ {
+ $adapterPlatform = ($adapterPlatform) ?: new Sql92;
+ $table = $this->table;
+ $schema = null;
+
+ // create quoted table name to use in update processing
+ if ($table instanceof TableIdentifier) {
+ list($table, $schema) = $table->getTableAndSchema();
+ }
+
+ $table = $adapterPlatform->quoteIdentifier($table);
+
+ if ($schema) {
+ $table = $adapterPlatform->quoteIdentifier($schema) . $adapterPlatform->getIdentifierSeparator() . $table;
+ }
+
+ $set = $this->set;
+ if (is_array($set)) {
+ $setSql = array();
+ foreach ($set as $column => $value) {
+ if ($value instanceof Expression) {
+ $exprData = $this->processExpression($value, $adapterPlatform);
+ $setSql[] = $adapterPlatform->quoteIdentifier($column) . ' = ' . $exprData->getSql();
+ } elseif ($value === null) {
+ $setSql[] = $adapterPlatform->quoteIdentifier($column) . ' = NULL';
+ } else {
+ $setSql[] = $adapterPlatform->quoteIdentifier($column) . ' = ' . $adapterPlatform->quoteValue($value);
+ }
+ }
+ $set = implode(', ', $setSql);
+ }
+
+ $sql = sprintf($this->specifications[self::SPECIFICATION_UPDATE], $table, $set);
+ if ($this->where->count() > 0) {
+ $whereParts = $this->processExpression($this->where, $adapterPlatform, null, 'where');
+ $sql .= ' ' . sprintf($this->specifications[self::SPECIFICATION_WHERE], $whereParts->getSql());
+ }
+ return $sql;
+ }
+
+ /**
+ * Variable overloading
+ *
+ * Proxies to "where" only
+ *
+ * @param string $name
+ * @return mixed
+ */
+ public function __get($name)
+ {
+ switch (strtolower($name)) {
+ case 'where':
+ return $this->where;
+ }
+ }
+
+ /**
+ * __clone
+ *
+ * Resets the where object each time the Update is cloned.
+ *
+ * @return void
+ */
+ public function __clone()
+ {
+ $this->where = clone $this->where;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Sql/Where.php zendframework-2.2.6/library/Zend/Db/Sql/Where.php
--- zendframework-1.10.4/library/Zend/Db/Sql/Where.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Sql/Where.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,15 @@
+message = $msg;
- $this->code = $state;
- }
-
-}
-
diff -Nru zendframework-1.10.4/library/Zend/Db/Statement/Db2.php zendframework-2.2.6/library/Zend/Db/Statement/Db2.php
--- zendframework-1.10.4/library/Zend/Db/Statement/Db2.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Statement/Db2.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,360 +0,0 @@
-_adapter->getConnection();
-
- // db2_prepare on i5 emits errors, these need to be
- // suppressed so that proper exceptions can be thrown
- $this->_stmt = @db2_prepare($connection, $sql);
-
- if (!$this->_stmt) {
- /**
- * @see Zend_Db_Statement_Db2_Exception
- */
- require_once 'Zend/Db/Statement/Db2/Exception.php';
- throw new Zend_Db_Statement_Db2_Exception(
- db2_stmt_errormsg(),
- db2_stmt_error()
- );
- }
- }
-
- /**
- * Binds a parameter to the specified variable name.
- *
- * @param mixed $parameter Name the parameter, either integer or string.
- * @param mixed $variable Reference to PHP variable containing the value.
- * @param mixed $type OPTIONAL Datatype of SQL parameter.
- * @param mixed $length OPTIONAL Length of SQL parameter.
- * @param mixed $options OPTIONAL Other options.
- * @return bool
- * @throws Zend_Db_Statement_Db2_Exception
- */
- public function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
- {
- if ($type === null) {
- $type = DB2_PARAM_IN;
- }
-
- if (isset($options['data-type'])) {
- $datatype = $options['data-type'];
- } else {
- $datatype = DB2_CHAR;
- }
-
- if (!db2_bind_param($this->_stmt, $position, "variable", $type, $datatype)) {
- /**
- * @see Zend_Db_Statement_Db2_Exception
- */
- require_once 'Zend/Db/Statement/Db2/Exception.php';
- throw new Zend_Db_Statement_Db2_Exception(
- db2_stmt_errormsg(),
- db2_stmt_error()
- );
- }
-
- return true;
- }
-
- /**
- * Closes the cursor, allowing the statement to be executed again.
- *
- * @return bool
- */
- public function closeCursor()
- {
- if (!$this->_stmt) {
- return false;
- }
- db2_free_stmt($this->_stmt);
- $this->_stmt = false;
- return true;
- }
-
-
- /**
- * Returns the number of columns in the result set.
- * Returns null if the statement has no result set metadata.
- *
- * @return int The number of columns.
- */
- public function columnCount()
- {
- if (!$this->_stmt) {
- return false;
- }
- return db2_num_fields($this->_stmt);
- }
-
- /**
- * Retrieves the error code, if any, associated with the last operation on
- * the statement handle.
- *
- * @return string error code.
- */
- public function errorCode()
- {
- if (!$this->_stmt) {
- return false;
- }
-
- $error = db2_stmt_error();
- if ($error === '') {
- return false;
- }
-
- return $error;
- }
-
- /**
- * Retrieves an array of error information, if any, associated with the
- * last operation on the statement handle.
- *
- * @return array
- */
- public function errorInfo()
- {
- $error = $this->errorCode();
- if ($error === false){
- return false;
- }
-
- /*
- * Return three-valued array like PDO. But DB2 does not distinguish
- * between SQLCODE and native RDBMS error code, so repeat the SQLCODE.
- */
- return array(
- $error,
- $error,
- db2_stmt_errormsg()
- );
- }
-
- /**
- * Executes a prepared statement.
- *
- * @param array $params OPTIONAL Values to bind to parameter placeholders.
- * @return bool
- * @throws Zend_Db_Statement_Db2_Exception
- */
- public function _execute(array $params = null)
- {
- if (!$this->_stmt) {
- return false;
- }
-
- $retval = true;
- if ($params !== null) {
- $retval = @db2_execute($this->_stmt, $params);
- } else {
- $retval = @db2_execute($this->_stmt);
- }
-
- if ($retval === false) {
- /**
- * @see Zend_Db_Statement_Db2_Exception
- */
- require_once 'Zend/Db/Statement/Db2/Exception.php';
- throw new Zend_Db_Statement_Db2_Exception(
- db2_stmt_errormsg(),
- db2_stmt_error());
- }
-
- $this->_keys = array();
- if ($field_num = $this->columnCount()) {
- for ($i = 0; $i < $field_num; $i++) {
- $name = db2_field_name($this->_stmt, $i);
- $this->_keys[] = $name;
- }
- }
-
- $this->_values = array();
- if ($this->_keys) {
- $this->_values = array_fill(0, count($this->_keys), null);
- }
-
- return $retval;
- }
-
- /**
- * Fetches a row from the result set.
- *
- * @param int $style OPTIONAL Fetch mode for this fetch operation.
- * @param int $cursor OPTIONAL Absolute, relative, or other.
- * @param int $offset OPTIONAL Number for absolute or relative cursors.
- * @return mixed Array, object, or scalar depending on fetch mode.
- * @throws Zend_Db_Statement_Db2_Exception
- */
- public function fetch($style = null, $cursor = null, $offset = null)
- {
- if (!$this->_stmt) {
- return false;
- }
-
- if ($style === null) {
- $style = $this->_fetchMode;
- }
-
- switch ($style) {
- case Zend_Db::FETCH_NUM :
- $row = db2_fetch_array($this->_stmt);
- break;
- case Zend_Db::FETCH_ASSOC :
- $row = db2_fetch_assoc($this->_stmt);
- break;
- case Zend_Db::FETCH_BOTH :
- $row = db2_fetch_both($this->_stmt);
- break;
- case Zend_Db::FETCH_OBJ :
- $row = db2_fetch_object($this->_stmt);
- break;
- case Zend_Db::FETCH_BOUND:
- $row = db2_fetch_both($this->_stmt);
- if ($row !== false) {
- return $this->_fetchBound($row);
- }
- break;
- default:
- /**
- * @see Zend_Db_Statement_Db2_Exception
- */
- require_once 'Zend/Db/Statement/Db2/Exception.php';
- throw new Zend_Db_Statement_Db2_Exception("Invalid fetch mode '$style' specified");
- break;
- }
-
- return $row;
- }
-
- /**
- * Fetches the next row and returns it as an object.
- *
- * @param string $class OPTIONAL Name of the class to create.
- * @param array $config OPTIONAL Constructor arguments for the class.
- * @return mixed One object instance of the specified class.
- */
- public function fetchObject($class = 'stdClass', array $config = array())
- {
- $obj = $this->fetch(Zend_Db::FETCH_OBJ);
- return $obj;
- }
-
- /**
- * Retrieves the next rowset (result set) for a SQL statement that has
- * multiple result sets. An example is a stored procedure that returns
- * the results of multiple queries.
- *
- * @return bool
- * @throws Zend_Db_Statement_Db2_Exception
- */
- public function nextRowset()
- {
- /**
- * @see Zend_Db_Statement_Db2_Exception
- */
- require_once 'Zend/Db/Statement/Db2/Exception.php';
- throw new Zend_Db_Statement_Db2_Exception(__FUNCTION__ . '() is not implemented');
- }
-
- /**
- * Returns the number of rows affected by the execution of the
- * last INSERT, DELETE, or UPDATE statement executed by this
- * statement object.
- *
- * @return int The number of rows affected.
- */
- public function rowCount()
- {
- if (!$this->_stmt) {
- return false;
- }
-
- $num = @db2_num_rows($this->_stmt);
-
- if ($num === false) {
- return 0;
- }
-
- return $num;
- }
-
- /**
- * Returns an array containing all of the result set rows.
- *
- * @param int $style OPTIONAL Fetch mode.
- * @param int $col OPTIONAL Column number, if fetch mode is by column.
- * @return array Collection of rows, each in a format by the fetch mode.
- *
- * Behaves like parent, but if limit()
- * is used, the final result removes the extra column
- * 'zend_db_rownum'
- */
- public function fetchAll($style = null, $col = null)
- {
- $data = parent::fetchAll($style, $col);
- $results = array();
- $remove = $this->_adapter->foldCase('ZEND_DB_ROWNUM');
-
- foreach ($data as $row) {
- if (is_array($row) && array_key_exists($remove, $row)) {
- unset($row[$remove]);
- }
- $results[] = $row;
- }
- return $results;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Statement/Exception.php zendframework-2.2.6/library/Zend/Db/Statement/Exception.php
--- zendframework-1.10.4/library/Zend/Db/Statement/Exception.php 2010-01-22 07:57:10.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Statement/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,56 +0,0 @@
-getPrevious() !== null);
- }
-
- /**
- * @return Exception|null
- */
- public function getChainedException()
- {
- return $this->getPrevious();
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Statement/Interface.php zendframework-2.2.6/library/Zend/Db/Statement/Interface.php
--- zendframework-1.10.4/library/Zend/Db/Statement/Interface.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Statement/Interface.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,203 +0,0 @@
-_adapter->getConnection();
-
- $this->_stmt = $mysqli->prepare($sql);
-
- if ($this->_stmt === false || $mysqli->errno) {
- /**
- * @see Zend_Db_Statement_Mysqli_Exception
- */
- require_once 'Zend/Db/Statement/Mysqli/Exception.php';
- throw new Zend_Db_Statement_Mysqli_Exception("Mysqli prepare error: " . $mysqli->error, $mysqli->errno);
- }
- }
-
- /**
- * Binds a parameter to the specified variable name.
- *
- * @param mixed $parameter Name the parameter, either integer or string.
- * @param mixed $variable Reference to PHP variable containing the value.
- * @param mixed $type OPTIONAL Datatype of SQL parameter.
- * @param mixed $length OPTIONAL Length of SQL parameter.
- * @param mixed $options OPTIONAL Other options.
- * @return bool
- * @throws Zend_Db_Statement_Mysqli_Exception
- */
- protected function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
- {
- return true;
- }
-
- /**
- * Closes the cursor and the statement.
- *
- * @return bool
- */
- public function close()
- {
- if ($this->_stmt) {
- $r = $this->_stmt->close();
- $this->_stmt = null;
- return $r;
- }
- return false;
- }
-
- /**
- * Closes the cursor, allowing the statement to be executed again.
- *
- * @return bool
- */
- public function closeCursor()
- {
- if ($stmt = $this->_stmt) {
- $mysqli = $this->_adapter->getConnection();
- while ($mysqli->more_results()) {
- $mysqli->next_result();
- }
- $this->_stmt->free_result();
- return $this->_stmt->reset();
- }
- return false;
- }
-
- /**
- * Returns the number of columns in the result set.
- * Returns null if the statement has no result set metadata.
- *
- * @return int The number of columns.
- */
- public function columnCount()
- {
- if (isset($this->_meta) && $this->_meta) {
- return $this->_meta->field_count;
- }
- return 0;
- }
-
- /**
- * Retrieves the error code, if any, associated with the last operation on
- * the statement handle.
- *
- * @return string error code.
- */
- public function errorCode()
- {
- if (!$this->_stmt) {
- return false;
- }
- return substr($this->_stmt->sqlstate, 0, 5);
- }
-
- /**
- * Retrieves an array of error information, if any, associated with the
- * last operation on the statement handle.
- *
- * @return array
- */
- public function errorInfo()
- {
- if (!$this->_stmt) {
- return false;
- }
- return array(
- substr($this->_stmt->sqlstate, 0, 5),
- $this->_stmt->errno,
- $this->_stmt->error,
- );
- }
-
- /**
- * Executes a prepared statement.
- *
- * @param array $params OPTIONAL Values to bind to parameter placeholders.
- * @return bool
- * @throws Zend_Db_Statement_Mysqli_Exception
- */
- public function _execute(array $params = null)
- {
- if (!$this->_stmt) {
- return false;
- }
-
- // if no params were given as an argument to execute(),
- // then default to the _bindParam array
- if ($params === null) {
- $params = $this->_bindParam;
- }
- // send $params as input parameters to the statement
- if ($params) {
- array_unshift($params, str_repeat('s', count($params)));
- $stmtParams = array();
- foreach ($params as $k => &$value) {
- $stmtParams[$k] = &$value;
- }
- call_user_func_array(
- array($this->_stmt, 'bind_param'),
- $stmtParams
- );
- }
-
- // execute the statement
- $retval = $this->_stmt->execute();
- if ($retval === false) {
- /**
- * @see Zend_Db_Statement_Mysqli_Exception
- */
- require_once 'Zend/Db/Statement/Mysqli/Exception.php';
- throw new Zend_Db_Statement_Mysqli_Exception("Mysqli statement execute error : " . $this->_stmt->error, $this->_stmt->errno);
- }
-
-
- // retain metadata
- if ($this->_meta === null) {
- $this->_meta = $this->_stmt->result_metadata();
- if ($this->_stmt->errno) {
- /**
- * @see Zend_Db_Statement_Mysqli_Exception
- */
- require_once 'Zend/Db/Statement/Mysqli/Exception.php';
- throw new Zend_Db_Statement_Mysqli_Exception("Mysqli statement metadata error: " . $this->_stmt->error, $this->_stmt->errno);
- }
- }
-
- // statements that have no result set do not return metadata
- if ($this->_meta !== false) {
-
- // get the column names that will result
- $this->_keys = array();
- foreach ($this->_meta->fetch_fields() as $col) {
- $this->_keys[] = $this->_adapter->foldCase($col->name);
- }
-
- // set up a binding space for result variables
- $this->_values = array_fill(0, count($this->_keys), null);
-
- // set up references to the result binding space.
- // just passing $this->_values in the call_user_func_array()
- // below won't work, you need references.
- $refs = array();
- foreach ($this->_values as $i => &$f) {
- $refs[$i] = &$f;
- }
-
- $this->_stmt->store_result();
- // bind to the result variables
- call_user_func_array(
- array($this->_stmt, 'bind_result'),
- $this->_values
- );
- }
- return $retval;
- }
-
-
- /**
- * Fetches a row from the result set.
- *
- * @param int $style OPTIONAL Fetch mode for this fetch operation.
- * @param int $cursor OPTIONAL Absolute, relative, or other.
- * @param int $offset OPTIONAL Number for absolute or relative cursors.
- * @return mixed Array, object, or scalar depending on fetch mode.
- * @throws Zend_Db_Statement_Mysqli_Exception
- */
- public function fetch($style = null, $cursor = null, $offset = null)
- {
- if (!$this->_stmt) {
- return false;
- }
- // fetch the next result
- $retval = $this->_stmt->fetch();
- switch ($retval) {
- case null: // end of data
- case false: // error occurred
- $this->_stmt->reset();
- return false;
- default:
- // fallthrough
- }
-
- // make sure we have a fetch mode
- if ($style === null) {
- $style = $this->_fetchMode;
- }
-
- // dereference the result values, otherwise things like fetchAll()
- // return the same values for every entry (because of the reference).
- $values = array();
- foreach ($this->_values as $key => $val) {
- $values[] = $val;
- }
-
- $row = false;
- switch ($style) {
- case Zend_Db::FETCH_NUM:
- $row = $values;
- break;
- case Zend_Db::FETCH_ASSOC:
- $row = array_combine($this->_keys, $values);
- break;
- case Zend_Db::FETCH_BOTH:
- $assoc = array_combine($this->_keys, $values);
- $row = array_merge($values, $assoc);
- break;
- case Zend_Db::FETCH_OBJ:
- $row = (object) array_combine($this->_keys, $values);
- break;
- case Zend_Db::FETCH_BOUND:
- $assoc = array_combine($this->_keys, $values);
- $row = array_merge($values, $assoc);
- return $this->_fetchBound($row);
- break;
- default:
- /**
- * @see Zend_Db_Statement_Mysqli_Exception
- */
- require_once 'Zend/Db/Statement/Mysqli/Exception.php';
- throw new Zend_Db_Statement_Mysqli_Exception("Invalid fetch mode '$style' specified");
- break;
- }
- return $row;
- }
-
- /**
- * Retrieves the next rowset (result set) for a SQL statement that has
- * multiple result sets. An example is a stored procedure that returns
- * the results of multiple queries.
- *
- * @return bool
- * @throws Zend_Db_Statement_Mysqli_Exception
- */
- public function nextRowset()
- {
- /**
- * @see Zend_Db_Statement_Mysqli_Exception
- */
- require_once 'Zend/Db/Statement/Mysqli/Exception.php';
- throw new Zend_Db_Statement_Mysqli_Exception(__FUNCTION__.'() is not implemented');
- }
-
- /**
- * Returns the number of rows affected by the execution of the
- * last INSERT, DELETE, or UPDATE statement executed by this
- * statement object.
- *
- * @return int The number of rows affected.
- */
- public function rowCount()
- {
- if (!$this->_adapter) {
- return false;
- }
- $mysqli = $this->_adapter->getConnection();
- return $mysqli->affected_rows;
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Db/Statement/Oracle/Exception.php zendframework-2.2.6/library/Zend/Db/Statement/Oracle/Exception.php
--- zendframework-1.10.4/library/Zend/Db/Statement/Oracle/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Statement/Oracle/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,59 +0,0 @@
-message = $error['code']." ".$error['message'];
- } else {
- $this->message = $error['code']." ".$error['message']." ";
- $this->message .= substr($error['sqltext'], 0, $error['offset']);
- $this->message .= "*";
- $this->message .= substr($error['sqltext'], $error['offset']);
- }
- $this->code = $error['code'];
- }
- if (!$this->code && $code) {
- $this->code = $code;
- }
- }
-}
-
diff -Nru zendframework-1.10.4/library/Zend/Db/Statement/Oracle.php zendframework-2.2.6/library/Zend/Db/Statement/Oracle.php
--- zendframework-1.10.4/library/Zend/Db/Statement/Oracle.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Statement/Oracle.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,577 +0,0 @@
-_lobAsString = (bool) $lob_as_string;
- return $this;
- }
-
- /**
- * Return whether or not LOB are returned as string
- *
- * @return boolean
- */
- public function getLobAsString()
- {
- return $this->_lobAsString;
- }
-
- /**
- * Prepares statement handle
- *
- * @param string $sql
- * @return void
- * @throws Zend_Db_Statement_Oracle_Exception
- */
- protected function _prepare($sql)
- {
- $connection = $this->_adapter->getConnection();
- $this->_stmt = oci_parse($connection, $sql);
- if (!$this->_stmt) {
- /**
- * @see Zend_Db_Statement_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception(oci_error($connection));
- }
- }
-
- /**
- * Binds a parameter to the specified variable name.
- *
- * @param mixed $parameter Name the parameter, either integer or string.
- * @param mixed $variable Reference to PHP variable containing the value.
- * @param mixed $type OPTIONAL Datatype of SQL parameter.
- * @param mixed $length OPTIONAL Length of SQL parameter.
- * @param mixed $options OPTIONAL Other options.
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- protected function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
- {
- // default value
- if ($type === NULL) {
- $type = SQLT_CHR;
- }
-
- // default value
- if ($length === NULL) {
- $length = -1;
- }
-
- $retval = @oci_bind_by_name($this->_stmt, $parameter, $variable, $length, $type);
- if ($retval === false) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
- }
-
- return true;
- }
-
- /**
- * Closes the cursor, allowing the statement to be executed again.
- *
- * @return bool
- */
- public function closeCursor()
- {
- if (!$this->_stmt) {
- return false;
- }
-
- oci_free_statement($this->_stmt);
- $this->_stmt = false;
- return true;
- }
-
- /**
- * Returns the number of columns in the result set.
- * Returns null if the statement has no result set metadata.
- *
- * @return int The number of columns.
- */
- public function columnCount()
- {
- if (!$this->_stmt) {
- return false;
- }
-
- return oci_num_fields($this->_stmt);
- }
-
-
- /**
- * Retrieves the error code, if any, associated with the last operation on
- * the statement handle.
- *
- * @return string error code.
- */
- public function errorCode()
- {
- if (!$this->_stmt) {
- return false;
- }
-
- $error = oci_error($this->_stmt);
-
- if (!$error) {
- return false;
- }
-
- return $error['code'];
- }
-
-
- /**
- * Retrieves an array of error information, if any, associated with the
- * last operation on the statement handle.
- *
- * @return array
- */
- public function errorInfo()
- {
- if (!$this->_stmt) {
- return false;
- }
-
- $error = oci_error($this->_stmt);
- if (!$error) {
- return false;
- }
-
- if (isset($error['sqltext'])) {
- return array(
- $error['code'],
- $error['message'],
- $error['offset'],
- $error['sqltext'],
- );
- } else {
- return array(
- $error['code'],
- $error['message'],
- );
- }
- }
-
-
- /**
- * Executes a prepared statement.
- *
- * @param array $params OPTIONAL Values to bind to parameter placeholders.
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- public function _execute(array $params = null)
- {
- $connection = $this->_adapter->getConnection();
-
- if (!$this->_stmt) {
- return false;
- }
-
- if ($params !== null) {
- if (!is_array($params)) {
- $params = array($params);
- }
- $error = false;
- foreach (array_keys($params) as $name) {
- if (!@oci_bind_by_name($this->_stmt, $name, $params[$name], -1)) {
- $error = true;
- break;
- }
- }
- if ($error) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
- }
- }
-
- $retval = @oci_execute($this->_stmt, $this->_adapter->_getExecuteMode());
- if ($retval === false) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
- }
-
- $this->_keys = Array();
- if ($field_num = oci_num_fields($this->_stmt)) {
- for ($i = 1; $i <= $field_num; $i++) {
- $name = oci_field_name($this->_stmt, $i);
- $this->_keys[] = $name;
- }
- }
-
- $this->_values = Array();
- if ($this->_keys) {
- $this->_values = array_fill(0, count($this->_keys), null);
- }
-
- return $retval;
- }
-
- /**
- * Fetches a row from the result set.
- *
- * @param int $style OPTIONAL Fetch mode for this fetch operation.
- * @param int $cursor OPTIONAL Absolute, relative, or other.
- * @param int $offset OPTIONAL Number for absolute or relative cursors.
- * @return mixed Array, object, or scalar depending on fetch mode.
- * @throws Zend_Db_Statement_Exception
- */
- public function fetch($style = null, $cursor = null, $offset = null)
- {
- if (!$this->_stmt) {
- return false;
- }
-
- if ($style === null) {
- $style = $this->_fetchMode;
- }
-
- $lob_as_string = $this->getLobAsString() ? OCI_RETURN_LOBS : 0;
-
- switch ($style) {
- case Zend_Db::FETCH_NUM:
- $row = oci_fetch_array($this->_stmt, OCI_NUM | OCI_RETURN_NULLS | $lob_as_string);
- break;
- case Zend_Db::FETCH_ASSOC:
- $row = oci_fetch_array($this->_stmt, OCI_ASSOC | OCI_RETURN_NULLS | $lob_as_string);
- break;
- case Zend_Db::FETCH_BOTH:
- $row = oci_fetch_array($this->_stmt, OCI_BOTH | OCI_RETURN_NULLS | $lob_as_string);
- break;
- case Zend_Db::FETCH_OBJ:
- $row = oci_fetch_object($this->_stmt);
- break;
- case Zend_Db::FETCH_BOUND:
- $row = oci_fetch_array($this->_stmt, OCI_BOTH | OCI_RETURN_NULLS | $lob_as_string);
- if ($row !== false) {
- return $this->_fetchBound($row);
- }
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception(
- array(
- 'code' => 'HYC00',
- 'message' => "Invalid fetch mode '$style' specified"
- )
- );
- break;
- }
-
- if (! $row && $error = oci_error($this->_stmt)) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception($error);
- }
-
- if (is_array($row) && array_key_exists('zend_db_rownum', $row)) {
- unset($row['zend_db_rownum']);
- }
-
- return $row;
- }
-
- /**
- * Returns an array containing all of the result set rows.
- *
- * @param int $style OPTIONAL Fetch mode.
- * @param int $col OPTIONAL Column number, if fetch mode is by column.
- * @return array Collection of rows, each in a format by the fetch mode.
- * @throws Zend_Db_Statement_Exception
- */
- public function fetchAll($style = null, $col = 0)
- {
- if (!$this->_stmt) {
- return false;
- }
-
- // make sure we have a fetch mode
- if ($style === null) {
- $style = $this->_fetchMode;
- }
-
- $flags = OCI_FETCHSTATEMENT_BY_ROW;
-
- switch ($style) {
- case Zend_Db::FETCH_BOTH:
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception(
- array(
- 'code' => 'HYC00',
- 'message' => "OCI8 driver does not support fetchAll(FETCH_BOTH), use fetch() in a loop instead"
- )
- );
- // notreached
- $flags |= OCI_NUM;
- $flags |= OCI_ASSOC;
- break;
- case Zend_Db::FETCH_NUM:
- $flags |= OCI_NUM;
- break;
- case Zend_Db::FETCH_ASSOC:
- $flags |= OCI_ASSOC;
- break;
- case Zend_Db::FETCH_OBJ:
- break;
- case Zend_Db::FETCH_COLUMN:
- $flags = $flags &~ OCI_FETCHSTATEMENT_BY_ROW;
- $flags |= OCI_FETCHSTATEMENT_BY_COLUMN;
- $flags |= OCI_NUM;
- break;
- default:
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception(
- array(
- 'code' => 'HYC00',
- 'message' => "Invalid fetch mode '$style' specified"
- )
- );
- break;
- }
-
- $result = Array();
- if ($flags != OCI_FETCHSTATEMENT_BY_ROW) { /* not Zend_Db::FETCH_OBJ */
- if (! ($rows = oci_fetch_all($this->_stmt, $result, 0, -1, $flags) )) {
- if ($error = oci_error($this->_stmt)) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception($error);
- }
- if (!$rows) {
- return array();
- }
- }
- if ($style == Zend_Db::FETCH_COLUMN) {
- $result = $result[$col];
- }
- foreach ($result as &$row) {
- if (is_array($row) && array_key_exists('zend_db_rownum', $row)) {
- unset($row['zend_db_rownum']);
- }
- }
- } else {
- while (($row = oci_fetch_object($this->_stmt)) !== false) {
- $result [] = $row;
- }
- if ($error = oci_error($this->_stmt)) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception($error);
- }
- }
-
- return $result;
- }
-
-
- /**
- * Returns a single column from the next row of a result set.
- *
- * @param int $col OPTIONAL Position of the column to fetch.
- * @return string
- * @throws Zend_Db_Statement_Exception
- */
- public function fetchColumn($col = 0)
- {
- if (!$this->_stmt) {
- return false;
- }
-
- if (!oci_fetch($this->_stmt)) {
- // if no error, there is simply no record
- if (!$error = oci_error($this->_stmt)) {
- return false;
- }
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception($error);
- }
-
- $data = oci_result($this->_stmt, $col+1); //1-based
- if ($data === false) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
- }
-
- if ($this->getLobAsString()) {
- // instanceof doesn't allow '-', we must use a temporary string
- $type = 'OCI-Lob';
- if ($data instanceof $type) {
- $data = $data->read($data->size());
- }
- }
-
- return $data;
- }
-
- /**
- * Fetches the next row and returns it as an object.
- *
- * @param string $class OPTIONAL Name of the class to create.
- * @param array $config OPTIONAL Constructor arguments for the class.
- * @return mixed One object instance of the specified class.
- * @throws Zend_Db_Statement_Exception
- */
- public function fetchObject($class = 'stdClass', array $config = array())
- {
- if (!$this->_stmt) {
- return false;
- }
-
- $obj = oci_fetch_object($this->_stmt);
-
- if ($error = oci_error($this->_stmt)) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception($error);
- }
-
- /* @todo XXX handle parameters */
-
- return $obj;
- }
-
- /**
- * Retrieves the next rowset (result set) for a SQL statement that has
- * multiple result sets. An example is a stored procedure that returns
- * the results of multiple queries.
- *
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- public function nextRowset()
- {
- /**
- * @see Zend_Db_Statement_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception(
- array(
- 'code' => 'HYC00',
- 'message' => 'Optional feature not implemented'
- )
- );
- }
-
- /**
- * Returns the number of rows affected by the execution of the
- * last INSERT, DELETE, or UPDATE statement executed by this
- * statement object.
- *
- * @return int The number of rows affected.
- * @throws Zend_Db_Statement_Exception
- */
- public function rowCount()
- {
- if (!$this->_stmt) {
- return false;
- }
-
- $num_rows = oci_num_rows($this->_stmt);
-
- if ($num_rows === false) {
- /**
- * @see Zend_Db_Adapter_Oracle_Exception
- */
- require_once 'Zend/Db/Statement/Oracle/Exception.php';
- throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
- }
-
- return $num_rows;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Statement/Pdo/Ibm.php zendframework-2.2.6/library/Zend/Db/Statement/Pdo/Ibm.php
--- zendframework-1.10.4/library/Zend/Db/Statement/Pdo/Ibm.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Statement/Pdo/Ibm.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,94 +0,0 @@
-_adapter->foldCase('ZEND_DB_ROWNUM');
-
- foreach ($data as $row) {
- if (is_array($row) && array_key_exists($remove, $row)) {
- unset($row[$remove]);
- }
- $results[] = $row;
- }
- return $results;
- }
-
- /**
- * Binds a parameter to the specified variable name.
- *
- * @param mixed $parameter Name the parameter, either integer or string.
- * @param mixed $variable Reference to PHP variable containing the value.
- * @param mixed $type OPTIONAL Datatype of SQL parameter.
- * @param mixed $length OPTIONAL Length of SQL parameter.
- * @param mixed $options OPTIONAL Other options.
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- public function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
- {
- try {
- if (($type === null) && ($length === null) && ($options === null)) {
- return $this->_stmt->bindParam($parameter, $variable);
- } else {
- return $this->_stmt->bindParam($parameter, $variable, $type, $length, $options);
- }
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Db/Statement/Pdo/Oci.php zendframework-2.2.6/library/Zend/Db/Statement/Pdo/Oci.php
--- zendframework-1.10.4/library/Zend/Db/Statement/Pdo/Oci.php 2010-02-19 21:27:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Statement/Pdo/Oci.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,91 +0,0 @@
-_adapter->foldCase('zend_db_rownum');
-
- foreach ($data as $row) {
- if (is_array($row) && array_key_exists($remove, $row)) {
- unset($row[$remove]);
- }
- $results[] = $row;
- }
- return $results;
- }
-
-
- /**
- * Fetches a row from the result set.
- *
- * @param int $style OPTIONAL Fetch mode for this fetch operation.
- * @param int $cursor OPTIONAL Absolute, relative, or other.
- * @param int $offset OPTIONAL Number for absolute or relative cursors.
- * @return mixed Array, object, or scalar depending on fetch mode.
- * @throws Zend_Db_Statement_Exception
- */
- public function fetch($style = null, $cursor = null, $offset = null)
- {
- $row = parent::fetch($style, $cursor, $offset);
-
- $remove = $this->_adapter->foldCase('zend_db_rownum');
- if (is_array($row) && array_key_exists($remove, $row)) {
- unset($row[$remove]);
- }
-
- return $row;
- }
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Db/Statement/Pdo.php zendframework-2.2.6/library/Zend/Db/Statement/Pdo.php
--- zendframework-1.10.4/library/Zend/Db/Statement/Pdo.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Statement/Pdo.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,439 +0,0 @@
-_stmt = $this->_adapter->getConnection()->prepare($sql);
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Bind a column of the statement result set to a PHP variable.
- *
- * @param string $column Name the column in the result set, either by
- * position or by name.
- * @param mixed $param Reference to the PHP variable containing the value.
- * @param mixed $type OPTIONAL
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- public function bindColumn($column, &$param, $type = null)
- {
- try {
- if ($type === null) {
- return $this->_stmt->bindColumn($column, $param);
- } else {
- return $this->_stmt->bindColumn($column, $param, $type);
- }
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Binds a parameter to the specified variable name.
- *
- * @param mixed $parameter Name the parameter, either integer or string.
- * @param mixed $variable Reference to PHP variable containing the value.
- * @param mixed $type OPTIONAL Datatype of SQL parameter.
- * @param mixed $length OPTIONAL Length of SQL parameter.
- * @param mixed $options OPTIONAL Other options.
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- protected function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
- {
- try {
- if ($type === null) {
- if (is_bool($variable)) {
- $type = PDO::PARAM_BOOL;
- } elseif ($variable === null) {
- $type = PDO::PARAM_NULL;
- } elseif (is_integer($variable)) {
- $type = PDO::PARAM_INT;
- } else {
- $type = PDO::PARAM_STR;
- }
- }
- return $this->_stmt->bindParam($parameter, $variable, $type, $length, $options);
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Binds a value to a parameter.
- *
- * @param mixed $parameter Name the parameter, either integer or string.
- * @param mixed $value Scalar value to bind to the parameter.
- * @param mixed $type OPTIONAL Datatype of the parameter.
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- public function bindValue($parameter, $value, $type = null)
- {
- if (is_string($parameter) && $parameter[0] != ':') {
- $parameter = ":$parameter";
- }
-
- $this->_bindParam[$parameter] = $value;
-
- try {
- if ($type === null) {
- return $this->_stmt->bindValue($parameter, $value);
- } else {
- return $this->_stmt->bindValue($parameter, $value, $type);
- }
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Closes the cursor, allowing the statement to be executed again.
- *
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- public function closeCursor()
- {
- try {
- return $this->_stmt->closeCursor();
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Returns the number of columns in the result set.
- * Returns null if the statement has no result set metadata.
- *
- * @return int The number of columns.
- * @throws Zend_Db_Statement_Exception
- */
- public function columnCount()
- {
- try {
- return $this->_stmt->columnCount();
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Retrieves the error code, if any, associated with the last operation on
- * the statement handle.
- *
- * @return string error code.
- * @throws Zend_Db_Statement_Exception
- */
- public function errorCode()
- {
- try {
- return $this->_stmt->errorCode();
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Retrieves an array of error information, if any, associated with the
- * last operation on the statement handle.
- *
- * @return array
- * @throws Zend_Db_Statement_Exception
- */
- public function errorInfo()
- {
- try {
- return $this->_stmt->errorInfo();
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Executes a prepared statement.
- *
- * @param array $params OPTIONAL Values to bind to parameter placeholders.
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- public function _execute(array $params = null)
- {
- try {
- if ($params !== null) {
- return $this->_stmt->execute($params);
- } else {
- return $this->_stmt->execute();
- }
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), (int) $e->getCode(), $e);
- }
- }
-
- /**
- * Fetches a row from the result set.
- *
- * @param int $style OPTIONAL Fetch mode for this fetch operation.
- * @param int $cursor OPTIONAL Absolute, relative, or other.
- * @param int $offset OPTIONAL Number for absolute or relative cursors.
- * @return mixed Array, object, or scalar depending on fetch mode.
- * @throws Zend_Db_Statement_Exception
- */
- public function fetch($style = null, $cursor = null, $offset = null)
- {
- if ($style === null) {
- $style = $this->_fetchMode;
- }
- try {
- return $this->_stmt->fetch($style, $cursor, $offset);
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Required by IteratorAggregate interface
- *
- * @return IteratorIterator
- */
- public function getIterator()
- {
- return new IteratorIterator($this->_stmt);
- }
-
- /**
- * Returns an array containing all of the result set rows.
- *
- * @param int $style OPTIONAL Fetch mode.
- * @param int $col OPTIONAL Column number, if fetch mode is by column.
- * @return array Collection of rows, each in a format by the fetch mode.
- * @throws Zend_Db_Statement_Exception
- */
- public function fetchAll($style = null, $col = null)
- {
- if ($style === null) {
- $style = $this->_fetchMode;
- }
- try {
- if ($style == PDO::FETCH_COLUMN) {
- if ($col === null) {
- $col = 0;
- }
- return $this->_stmt->fetchAll($style, $col);
- } else {
- return $this->_stmt->fetchAll($style);
- }
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Returns a single column from the next row of a result set.
- *
- * @param int $col OPTIONAL Position of the column to fetch.
- * @return string
- * @throws Zend_Db_Statement_Exception
- */
- public function fetchColumn($col = 0)
- {
- try {
- return $this->_stmt->fetchColumn($col);
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Fetches the next row and returns it as an object.
- *
- * @param string $class OPTIONAL Name of the class to create.
- * @param array $config OPTIONAL Constructor arguments for the class.
- * @return mixed One object instance of the specified class.
- * @throws Zend_Db_Statement_Exception
- */
- public function fetchObject($class = 'stdClass', array $config = array())
- {
- try {
- return $this->_stmt->fetchObject($class, $config);
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Retrieve a statement attribute.
- *
- * @param integer $key Attribute name.
- * @return mixed Attribute value.
- * @throws Zend_Db_Statement_Exception
- */
- public function getAttribute($key)
- {
- try {
- return $this->_stmt->getAttribute($key);
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Returns metadata for a column in a result set.
- *
- * @param int $column
- * @return mixed
- * @throws Zend_Db_Statement_Exception
- */
- public function getColumnMeta($column)
- {
- try {
- return $this->_stmt->getColumnMeta($column);
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Retrieves the next rowset (result set) for a SQL statement that has
- * multiple result sets. An example is a stored procedure that returns
- * the results of multiple queries.
- *
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- public function nextRowset()
- {
- try {
- return $this->_stmt->nextRowset();
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Returns the number of rows affected by the execution of the
- * last INSERT, DELETE, or UPDATE statement executed by this
- * statement object.
- *
- * @return int The number of rows affected.
- * @throws Zend_Db_Statement_Exception
- */
- public function rowCount()
- {
- try {
- return $this->_stmt->rowCount();
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Set a statement attribute.
- *
- * @param string $key Attribute name.
- * @param mixed $val Attribute value.
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- public function setAttribute($key, $val)
- {
- try {
- return $this->_stmt->setAttribute($key, $val);
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- /**
- * Set the default fetch mode for this statement.
- *
- * @param int $mode The fetch mode.
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- public function setFetchMode($mode)
- {
- $this->_fetchMode = $mode;
- try {
- return $this->_stmt->setFetchMode($mode);
- } catch (PDOException $e) {
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Statement/Sqlsrv/Exception.php zendframework-2.2.6/library/Zend/Db/Statement/Sqlsrv/Exception.php
--- zendframework-1.10.4/library/Zend/Db/Statement/Sqlsrv/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Statement/Sqlsrv/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,61 +0,0 @@
-_adapter->getConnection();
-
- $this->_stmt = sqlsrv_prepare($connection, $sql);
-
- if (!$this->_stmt) {
- require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
- throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors());
- }
-
- $this->_originalSQL = $sql;
- }
-
- /**
- * Binds a parameter to the specified variable name.
- *
- * @param mixed $parameter Name the parameter, either integer or string.
- * @param mixed $variable Reference to PHP variable containing the value.
- * @param mixed $type OPTIONAL Datatype of SQL parameter.
- * @param mixed $length OPTIONAL Length of SQL parameter.
- * @param mixed $options OPTIONAL Other options.
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- protected function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
- {
- //Sql server doesn't support bind by name
- return true;
- }
-
- /**
- * Closes the cursor, allowing the statement to be executed again.
- *
- * @return bool
- */
- public function closeCursor()
- {
- if (!$this->_stmt) {
- return false;
- }
-
- sqlsrv_free_stmt($this->_stmt);
- $this->_stmt = false;
- return true;
- }
-
- /**
- * Returns the number of columns in the result set.
- * Returns null if the statement has no result set metadata.
- *
- * @return int The number of columns.
- */
- public function columnCount()
- {
- if ($this->_stmt && $this->_executed) {
- return sqlsrv_num_fields($this->_stmt);
- }
-
- return 0;
- }
-
-
- /**
- * Retrieves the error code, if any, associated with the last operation on
- * the statement handle.
- *
- * @return string error code.
- */
- public function errorCode()
- {
- if (!$this->_stmt) {
- return false;
- }
-
- $error = sqlsrv_errors();
- if (!$error) {
- return false;
- }
-
- return $error[0]['code'];
- }
-
-
- /**
- * Retrieves an array of error information, if any, associated with the
- * last operation on the statement handle.
- *
- * @return array
- */
- public function errorInfo()
- {
- if (!$this->_stmt) {
- return false;
- }
-
- $error = sqlsrv_errors();
- if (!$error) {
- return false;
- }
-
- return array(
- $error[0]['code'],
- $error[0]['message'],
- );
- }
-
-
- /**
- * Executes a prepared statement.
- *
- * @param array $params OPTIONAL Values to bind to parameter placeholders.
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- public function _execute(array $params = null)
- {
- $connection = $this->_adapter->getConnection();
- if (!$this->_stmt) {
- return false;
- }
-
- if ($params !== null) {
- if (!is_array($params)) {
- $params = array($params);
- }
- $error = false;
-
- // make all params passed by reference
- $params_ = array();
- $temp = array();
- $i = 1;
- foreach ($params as $param) {
- $temp[$i] = $param;
- $params_[] = &$temp[$i];
- $i++;
- }
- $params = $params_;
- }
-
- $this->_stmt = sqlsrv_query($connection, $this->_originalSQL, $params);
-
- if (!$this->_stmt) {
- require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
- throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors());
- }
-
- $this->_executed = true;
-
- return (!$this->_stmt);
- }
-
- /**
- * Fetches a row from the result set.
- *
- * @param int $style OPTIONAL Fetch mode for this fetch operation.
- * @param int $cursor OPTIONAL Absolute, relative, or other.
- * @param int $offset OPTIONAL Number for absolute or relative cursors.
- * @return mixed Array, object, or scalar depending on fetch mode.
- * @throws Zend_Db_Statement_Exception
- */
- public function fetch($style = null, $cursor = null, $offset = null)
- {
- if (!$this->_stmt) {
- return false;
- }
-
- if (null === $style) {
- $style = $this->_fetchMode;
- }
-
- $values = sqlsrv_fetch_array($this->_stmt, SQLSRV_FETCH_ASSOC);
-
- if (!$values && (null !== $error = sqlsrv_errors())) {
- require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
- throw new Zend_Db_Statement_Sqlsrv_Exception($error);
- }
-
- if (null === $values) {
- return null;
- }
-
- if (!$this->_keys) {
- foreach ($values as $key => $value) {
- $this->_keys[] = $this->_adapter->foldCase($key);
- }
- }
-
- $values = array_values($values);
-
- $row = false;
- switch ($style) {
- case Zend_Db::FETCH_NUM:
- $row = $values;
- break;
- case Zend_Db::FETCH_ASSOC:
- $row = array_combine($this->_keys, $values);
- break;
- case Zend_Db::FETCH_BOTH:
- $assoc = array_combine($this->_keys, $values);
- $row = array_merge($values, $assoc);
- break;
- case Zend_Db::FETCH_OBJ:
- $row = (object) array_combine($this->_keys, $values);
- break;
- case Zend_Db::FETCH_BOUND:
- $assoc = array_combine($this->_keys, $values);
- $row = array_merge($values, $assoc);
- $row = $this->_fetchBound($row);
- break;
- default:
- require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
- throw new Zend_Db_Statement_Sqlsrv_Exception("Invalid fetch mode '$style' specified");
- break;
- }
-
- return $row;
- }
-
- /**
- * Returns a single column from the next row of a result set.
- *
- * @param int $col OPTIONAL Position of the column to fetch.
- * @return string
- * @throws Zend_Db_Statement_Exception
- */
- public function fetchColumn($col = 0)
- {
- if (!$this->_stmt) {
- return false;
- }
-
- if (!sqlsrv_fetch($this->_stmt)) {
- if (null !== $error = sqlsrv_errors()) {
- require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
- throw new Zend_Db_Statement_Sqlsrv_Exception($error);
- }
-
- // If no error, there is simply no record
- return false;
- }
-
- $data = sqlsrv_get_field($this->_stmt, $col); //0-based
- if ($data === false) {
- require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
- throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors());
- }
-
- return $data;
- }
-
- /**
- * Fetches the next row and returns it as an object.
- *
- * @param string $class OPTIONAL Name of the class to create.
- * @param array $config OPTIONAL Constructor arguments for the class.
- * @return mixed One object instance of the specified class.
- * @throws Zend_Db_Statement_Exception
- */
- public function fetchObject($class = 'stdClass', array $config = array())
- {
- if (!$this->_stmt) {
- return false;
- }
-
- $obj = sqlsrv_fetch_object($this->_stmt);
-
- if ($error = sqlsrv_errors()) {
- require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
- throw new Zend_Db_Statement_Sqlsrv_Exception($error);
- }
-
- /* @todo XXX handle parameters */
-
- if (null === $obj) {
- return false;
- }
-
- return $obj;
- }
-
- /**
- * Returns metadata for a column in a result set.
- *
- * @param int $column
- * @return mixed
- * @throws Zend_Db_Statement_Sqlsrv_Exception
- */
- public function getColumnMeta($column)
- {
- $fields = sqlsrv_field_metadata($this->_stmt);
-
- if (!$fields) {
- throw new Zend_Db_Statement_Sqlsrv_Exception('Column metadata can not be fetched');
- }
-
- if (!isset($fields[$column])) {
- throw new Zend_Db_Statement_Sqlsrv_Exception('Column index does not exist in statement');
- }
-
- return $fields[$column];
- }
-
- /**
- * Retrieves the next rowset (result set) for a SQL statement that has
- * multiple result sets. An example is a stored procedure that returns
- * the results of multiple queries.
- *
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- public function nextRowset()
- {
- if (sqlsrv_next_result($this->_stmt) === false) {
- require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
- throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors());
- }
-
- //else - moved to next (or there are no more rows)
- }
-
- /**
- * Returns the number of rows affected by the execution of the
- * last INSERT, DELETE, or UPDATE statement executed by this
- * statement object.
- *
- * @return int The number of rows affected.
- * @throws Zend_Db_Statement_Exception
- */
- public function rowCount()
- {
- if (!$this->_stmt) {
- return false;
- }
-
- if (!$this->_executed) {
- return 0;
- }
-
- $num_rows = sqlsrv_rows_affected($this->_stmt);
-
- // Strict check is necessary; 0 is a valid return value
- if ($num_rows === false) {
- require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
- throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors());
- }
-
- return $num_rows;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Statement.php zendframework-2.2.6/library/Zend/Db/Statement.php
--- zendframework-1.10.4/library/Zend/Db/Statement.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Statement.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,485 +0,0 @@
-_adapter = $adapter;
- if ($sql instanceof Zend_Db_Select) {
- $sql = $sql->assemble();
- }
- $this->_parseParameters($sql);
- $this->_prepare($sql);
-
- $this->_queryId = $this->_adapter->getProfiler()->queryStart($sql);
- }
-
- /**
- * Internal method called by abstract statment constructor to setup
- * the driver level statement
- *
- * @return void
- */
- protected function _prepare($sql)
- {
- return;
- }
-
- /**
- * @param string $sql
- * @return void
- */
- protected function _parseParameters($sql)
- {
- $sql = $this->_stripQuoted($sql);
-
- // split into text and params
- $this->_sqlSplit = preg_split('/(\?|\:[a-zA-Z0-9_]+)/',
- $sql, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
-
- // map params
- $this->_sqlParam = array();
- foreach ($this->_sqlSplit as $key => $val) {
- if ($val == '?') {
- if ($this->_adapter->supportsParameters('positional') === false) {
- /**
- * @see Zend_Db_Statement_Exception
- */
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception("Invalid bind-variable position '$val'");
- }
- } else if ($val[0] == ':') {
- if ($this->_adapter->supportsParameters('named') === false) {
- /**
- * @see Zend_Db_Statement_Exception
- */
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception("Invalid bind-variable name '$val'");
- }
- }
- $this->_sqlParam[] = $val;
- }
-
- // set up for binding
- $this->_bindParam = array();
- }
-
- /**
- * Remove parts of a SQL string that contain quoted strings
- * of values or identifiers.
- *
- * @param string $sql
- * @return string
- */
- protected function _stripQuoted($sql)
- {
- // get the character for delimited id quotes,
- // this is usually " but in MySQL is `
- $d = $this->_adapter->quoteIdentifier('a');
- $d = $d[0];
-
- // get the value used as an escaped delimited id quote,
- // e.g. \" or "" or \`
- $de = $this->_adapter->quoteIdentifier($d);
- $de = substr($de, 1, 2);
- $de = str_replace('\\', '\\\\', $de);
-
- // get the character for value quoting
- // this should be '
- $q = $this->_adapter->quote('a');
- $q = $q[0];
-
- // get the value used as an escaped quote,
- // e.g. \' or ''
- $qe = $this->_adapter->quote($q);
- $qe = substr($qe, 1, 2);
- $qe = str_replace('\\', '\\\\', $qe);
-
- // get a version of the SQL statement with all quoted
- // values and delimited identifiers stripped out
- // remove "foo\"bar"
- $sql = preg_replace("/$q($qe|\\\\{2}|[^$q])*$q/", '', $sql);
- // remove 'foo\'bar'
- if (!empty($q)) {
- $sql = preg_replace("/$q($qe|[^$q])*$q/", '', $sql);
- }
-
- return $sql;
- }
-
- /**
- * Bind a column of the statement result set to a PHP variable.
- *
- * @param string $column Name the column in the result set, either by
- * position or by name.
- * @param mixed $param Reference to the PHP variable containing the value.
- * @param mixed $type OPTIONAL
- * @return bool
- */
- public function bindColumn($column, &$param, $type = null)
- {
- $this->_bindColumn[$column] =& $param;
- return true;
- }
-
- /**
- * Binds a parameter to the specified variable name.
- *
- * @param mixed $parameter Name the parameter, either integer or string.
- * @param mixed $variable Reference to PHP variable containing the value.
- * @param mixed $type OPTIONAL Datatype of SQL parameter.
- * @param mixed $length OPTIONAL Length of SQL parameter.
- * @param mixed $options OPTIONAL Other options.
- * @return bool
- */
- public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
- {
- if (!is_int($parameter) && !is_string($parameter)) {
- /**
- * @see Zend_Db_Statement_Exception
- */
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception('Invalid bind-variable position');
- }
-
- $position = null;
- if (($intval = (int) $parameter) > 0 && $this->_adapter->supportsParameters('positional')) {
- if ($intval >= 1 || $intval <= count($this->_sqlParam)) {
- $position = $intval;
- }
- } else if ($this->_adapter->supportsParameters('named')) {
- if ($parameter[0] != ':') {
- $parameter = ':' . $parameter;
- }
- if (in_array($parameter, $this->_sqlParam) !== false) {
- $position = $parameter;
- }
- }
-
- if ($position === null) {
- /**
- * @see Zend_Db_Statement_Exception
- */
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception("Invalid bind-variable position '$parameter'");
- }
-
- // Finally we are assured that $position is valid
- $this->_bindParam[$position] =& $variable;
- return $this->_bindParam($position, $variable, $type, $length, $options);
- }
-
- /**
- * Binds a value to a parameter.
- *
- * @param mixed $parameter Name the parameter, either integer or string.
- * @param mixed $value Scalar value to bind to the parameter.
- * @param mixed $type OPTIONAL Datatype of the parameter.
- * @return bool
- */
- public function bindValue($parameter, $value, $type = null)
- {
- return $this->bindParam($parameter, $value, $type);
- }
-
- /**
- * Executes a prepared statement.
- *
- * @param array $params OPTIONAL Values to bind to parameter placeholders.
- * @return bool
- */
- public function execute(array $params = null)
- {
- /*
- * Simple case - no query profiler to manage.
- */
- if ($this->_queryId === null) {
- return $this->_execute($params);
- }
-
- /*
- * Do the same thing, but with query profiler
- * management before and after the execute.
- */
- $prof = $this->_adapter->getProfiler();
- $qp = $prof->getQueryProfile($this->_queryId);
- if ($qp->hasEnded()) {
- $this->_queryId = $prof->queryClone($qp);
- $qp = $prof->getQueryProfile($this->_queryId);
- }
- if ($params !== null) {
- $qp->bindParams($params);
- } else {
- $qp->bindParams($this->_bindParam);
- }
- $qp->start($this->_queryId);
-
- $retval = $this->_execute($params);
-
- $prof->queryEnd($this->_queryId);
-
- return $retval;
- }
-
- /**
- * Returns an array containing all of the result set rows.
- *
- * @param int $style OPTIONAL Fetch mode.
- * @param int $col OPTIONAL Column number, if fetch mode is by column.
- * @return array Collection of rows, each in a format by the fetch mode.
- */
- public function fetchAll($style = null, $col = null)
- {
- $data = array();
- if ($style === Zend_Db::FETCH_COLUMN && $col === null) {
- $col = 0;
- }
- if ($col === null) {
- while ($row = $this->fetch($style)) {
- $data[] = $row;
- }
- } else {
- while (false !== ($val = $this->fetchColumn($col))) {
- $data[] = $val;
- }
- }
- return $data;
- }
-
- /**
- * Returns a single column from the next row of a result set.
- *
- * @param int $col OPTIONAL Position of the column to fetch.
- * @return string One value from the next row of result set, or false.
- */
- public function fetchColumn($col = 0)
- {
- $data = array();
- $col = (int) $col;
- $row = $this->fetch(Zend_Db::FETCH_NUM);
- if (!is_array($row)) {
- return false;
- }
- return $row[$col];
- }
-
- /**
- * Fetches the next row and returns it as an object.
- *
- * @param string $class OPTIONAL Name of the class to create.
- * @param array $config OPTIONAL Constructor arguments for the class.
- * @return mixed One object instance of the specified class, or false.
- */
- public function fetchObject($class = 'stdClass', array $config = array())
- {
- $obj = new $class($config);
- $row = $this->fetch(Zend_Db::FETCH_ASSOC);
- if (!is_array($row)) {
- return false;
- }
- foreach ($row as $key => $val) {
- $obj->$key = $val;
- }
- return $obj;
- }
-
- /**
- * Retrieve a statement attribute.
- *
- * @param string $key Attribute name.
- * @return mixed Attribute value.
- */
- public function getAttribute($key)
- {
- if (array_key_exists($key, $this->_attribute)) {
- return $this->_attribute[$key];
- }
- }
-
- /**
- * Set a statement attribute.
- *
- * @param string $key Attribute name.
- * @param mixed $val Attribute value.
- * @return bool
- */
- public function setAttribute($key, $val)
- {
- $this->_attribute[$key] = $val;
- }
-
- /**
- * Set the default fetch mode for this statement.
- *
- * @param int $mode The fetch mode.
- * @return bool
- * @throws Zend_Db_Statement_Exception
- */
- public function setFetchMode($mode)
- {
- switch ($mode) {
- case Zend_Db::FETCH_NUM:
- case Zend_Db::FETCH_ASSOC:
- case Zend_Db::FETCH_BOTH:
- case Zend_Db::FETCH_OBJ:
- $this->_fetchMode = $mode;
- break;
- case Zend_Db::FETCH_BOUND:
- default:
- $this->closeCursor();
- /**
- * @see Zend_Db_Statement_Exception
- */
- require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception('invalid fetch mode');
- break;
- }
- }
-
- /**
- * Helper function to map retrieved row
- * to bound column variables
- *
- * @param array $row
- * @return bool True
- */
- public function _fetchBound($row)
- {
- foreach ($row as $key => $value) {
- // bindColumn() takes 1-based integer positions
- // but fetch() returns 0-based integer indexes
- if (is_int($key)) {
- $key++;
- }
- // set results only to variables that were bound previously
- if (isset($this->_bindColumn[$key])) {
- $this->_bindColumn[$key] = $value;
- }
- }
- return true;
- }
-
- /**
- * Gets the Zend_Db_Adapter_Abstract for this
- * particular Zend_Db_Statement object.
- *
- * @return Zend_Db_Adapter_Abstract
- */
- public function getAdapter()
- {
- return $this->_adapter;
- }
-
- /**
- * Gets the resource or object setup by the
- * _parse
- * @return unknown_type
- */
- public function getDriverStatement()
- {
- return $this->_stmt;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Table/Abstract.php zendframework-2.2.6/library/Zend/Db/Table/Abstract.php
--- zendframework-1.10.4/library/Zend/Db/Table/Abstract.php 2010-02-18 18:15:49.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Table/Abstract.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,1510 +0,0 @@
- $config);
- }
-
- if ($config) {
- $this->setOptions($config);
- }
-
- $this->_setup();
- $this->init();
- }
-
- /**
- * setOptions()
- *
- * @param array $options
- * @return Zend_Db_Table_Abstract
- */
- public function setOptions(Array $options)
- {
- foreach ($options as $key => $value) {
- switch ($key) {
- case self::ADAPTER:
- $this->_setAdapter($value);
- break;
- case self::DEFINITION:
- $this->setDefinition($value);
- break;
- case self::DEFINITION_CONFIG_NAME:
- $this->setDefinitionConfigName($value);
- break;
- case self::SCHEMA:
- $this->_schema = (string) $value;
- break;
- case self::NAME:
- $this->_name = (string) $value;
- break;
- case self::PRIMARY:
- $this->_primary = (array) $value;
- break;
- case self::ROW_CLASS:
- $this->setRowClass($value);
- break;
- case self::ROWSET_CLASS:
- $this->setRowsetClass($value);
- break;
- case self::REFERENCE_MAP:
- $this->setReferences($value);
- break;
- case self::DEPENDENT_TABLES:
- $this->setDependentTables($value);
- break;
- case self::METADATA_CACHE:
- $this->_setMetadataCache($value);
- break;
- case self::METADATA_CACHE_IN_CLASS:
- $this->setMetadataCacheInClass($value);
- break;
- case self::SEQUENCE:
- $this->_setSequence($value);
- break;
- default:
- // ignore unrecognized configuration directive
- break;
- }
- }
-
- return $this;
- }
-
- /**
- * setDefinition()
- *
- * @param Zend_Db_Table_Definition $definition
- * @return Zend_Db_Table_Abstract
- */
- public function setDefinition(Zend_Db_Table_Definition $definition)
- {
- $this->_definition = $definition;
- return $this;
- }
-
- /**
- * getDefinition()
- *
- * @return Zend_Db_Table_Definition|null
- */
- public function getDefinition()
- {
- return $this->_definition;
- }
-
- /**
- * setDefinitionConfigName()
- *
- * @param string $definition
- * @return Zend_Db_Table_Abstract
- */
- public function setDefinitionConfigName($definitionConfigName)
- {
- $this->_definitionConfigName = $definitionConfigName;
- return $this;
- }
-
- /**
- * getDefinitionConfigName()
- *
- * @return string
- */
- public function getDefinitionConfigName()
- {
- return $this->_definitionConfigName;
- }
-
- /**
- * @param string $classname
- * @return Zend_Db_Table_Abstract Provides a fluent interface
- */
- public function setRowClass($classname)
- {
- $this->_rowClass = (string) $classname;
-
- return $this;
- }
-
- /**
- * @return string
- */
- public function getRowClass()
- {
- return $this->_rowClass;
- }
-
- /**
- * @param string $classname
- * @return Zend_Db_Table_Abstract Provides a fluent interface
- */
- public function setRowsetClass($classname)
- {
- $this->_rowsetClass = (string) $classname;
-
- return $this;
- }
-
- /**
- * @return string
- */
- public function getRowsetClass()
- {
- return $this->_rowsetClass;
- }
-
- /**
- * Add a reference to the reference map
- *
- * @param string $ruleKey
- * @param string|array $columns
- * @param string $refTableClass
- * @param string|array $refColumns
- * @param string $onDelete
- * @param string $onUpdate
- * @return Zend_Db_Table_Abstract
- */
- public function addReference($ruleKey, $columns, $refTableClass, $refColumns,
- $onDelete = null, $onUpdate = null)
- {
- $reference = array(self::COLUMNS => (array) $columns,
- self::REF_TABLE_CLASS => $refTableClass,
- self::REF_COLUMNS => (array) $refColumns);
-
- if (!empty($onDelete)) {
- $reference[self::ON_DELETE] = $onDelete;
- }
-
- if (!empty($onUpdate)) {
- $reference[self::ON_UPDATE] = $onUpdate;
- }
-
- $this->_referenceMap[$ruleKey] = $reference;
-
- return $this;
- }
-
- /**
- * @param array $referenceMap
- * @return Zend_Db_Table_Abstract Provides a fluent interface
- */
- public function setReferences(array $referenceMap)
- {
- $this->_referenceMap = $referenceMap;
-
- return $this;
- }
-
- /**
- * @param string $tableClassname
- * @param string $ruleKey OPTIONAL
- * @return array
- * @throws Zend_Db_Table_Exception
- */
- public function getReference($tableClassname, $ruleKey = null)
- {
- $thisClass = get_class($this);
- if ($thisClass === 'Zend_Db_Table') {
- $thisClass = $this->_definitionConfigName;
- }
- $refMap = $this->_getReferenceMapNormalized();
- if ($ruleKey !== null) {
- if (!isset($refMap[$ruleKey])) {
- require_once "Zend/Db/Table/Exception.php";
- throw new Zend_Db_Table_Exception("No reference rule \"$ruleKey\" from table $thisClass to table $tableClassname");
- }
- if ($refMap[$ruleKey][self::REF_TABLE_CLASS] != $tableClassname) {
- require_once "Zend/Db/Table/Exception.php";
- throw new Zend_Db_Table_Exception("Reference rule \"$ruleKey\" does not reference table $tableClassname");
- }
- return $refMap[$ruleKey];
- }
- foreach ($refMap as $reference) {
- if ($reference[self::REF_TABLE_CLASS] == $tableClassname) {
- return $reference;
- }
- }
- require_once "Zend/Db/Table/Exception.php";
- throw new Zend_Db_Table_Exception("No reference from table $thisClass to table $tableClassname");
- }
-
- /**
- * @param array $dependentTables
- * @return Zend_Db_Table_Abstract Provides a fluent interface
- */
- public function setDependentTables(array $dependentTables)
- {
- $this->_dependentTables = $dependentTables;
-
- return $this;
- }
-
- /**
- * @return array
- */
- public function getDependentTables()
- {
- return $this->_dependentTables;
- }
-
- /**
- * set the defaultSource property - this tells the table class where to find default values
- *
- * @param string $defaultSource
- * @return Zend_Db_Table_Abstract
- */
- public function setDefaultSource($defaultSource = self::DEFAULT_NONE)
- {
- if (!in_array($defaultSource, array(self::DEFAULT_CLASS, self::DEFAULT_DB, self::DEFAULT_NONE))) {
- $defaultSource = self::DEFAULT_NONE;
- }
-
- $this->_defaultSource = $defaultSource;
- return $this;
- }
-
- /**
- * returns the default source flag that determines where defaultSources come from
- *
- * @return unknown
- */
- public function getDefaultSource()
- {
- return $this->_defaultSource;
- }
-
- /**
- * set the default values for the table class
- *
- * @param array $defaultValues
- * @return Zend_Db_Table_Abstract
- */
- public function setDefaultValues(Array $defaultValues)
- {
- foreach ($defaultValues as $defaultName => $defaultValue) {
- if (array_key_exists($defaultName, $this->_metadata)) {
- $this->_defaultValues[$defaultName] = $defaultValue;
- }
- }
- return $this;
- }
-
- public function getDefaultValues()
- {
- return $this->_defaultValues;
- }
-
-
- /**
- * Sets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects.
- *
- * @param mixed $db Either an Adapter object, or a string naming a Registry key
- * @return void
- */
- public static function setDefaultAdapter($db = null)
- {
- self::$_defaultDb = self::_setupAdapter($db);
- }
-
- /**
- * Gets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects.
- *
- * @return Zend_Db_Adapter_Abstract or null
- */
- public static function getDefaultAdapter()
- {
- return self::$_defaultDb;
- }
-
- /**
- * @param mixed $db Either an Adapter object, or a string naming a Registry key
- * @return Zend_Db_Table_Abstract Provides a fluent interface
- */
- protected function _setAdapter($db)
- {
- $this->_db = self::_setupAdapter($db);
- return $this;
- }
-
- /**
- * Gets the Zend_Db_Adapter_Abstract for this particular Zend_Db_Table object.
- *
- * @return Zend_Db_Adapter_Abstract
- */
- public function getAdapter()
- {
- return $this->_db;
- }
-
- /**
- * @param mixed $db Either an Adapter object, or a string naming a Registry key
- * @return Zend_Db_Adapter_Abstract
- * @throws Zend_Db_Table_Exception
- */
- protected static function _setupAdapter($db)
- {
- if ($db === null) {
- return null;
- }
- if (is_string($db)) {
- require_once 'Zend/Registry.php';
- $db = Zend_Registry::get($db);
- }
- if (!$db instanceof Zend_Db_Adapter_Abstract) {
- require_once 'Zend/Db/Table/Exception.php';
- throw new Zend_Db_Table_Exception('Argument must be of type Zend_Db_Adapter_Abstract, or a Registry key where a Zend_Db_Adapter_Abstract object is stored');
- }
- return $db;
- }
-
- /**
- * Sets the default metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable().
- *
- * If $defaultMetadataCache is null, then no metadata cache is used by default.
- *
- * @param mixed $metadataCache Either a Cache object, or a string naming a Registry key
- * @return void
- */
- public static function setDefaultMetadataCache($metadataCache = null)
- {
- self::$_defaultMetadataCache = self::_setupMetadataCache($metadataCache);
- }
-
- /**
- * Gets the default metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable().
- *
- * @return Zend_Cache_Core or null
- */
- public static function getDefaultMetadataCache()
- {
- return self::$_defaultMetadataCache;
- }
-
- /**
- * Sets the metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable().
- *
- * If $metadataCache is null, then no metadata cache is used. Since there is no opportunity to reload metadata
- * after instantiation, this method need not be public, particularly because that it would have no effect
- * results in unnecessary API complexity. To configure the metadata cache, use the metadataCache configuration
- * option for the class constructor upon instantiation.
- *
- * @param mixed $metadataCache Either a Cache object, or a string naming a Registry key
- * @return Zend_Db_Table_Abstract Provides a fluent interface
- */
- protected function _setMetadataCache($metadataCache)
- {
- $this->_metadataCache = self::_setupMetadataCache($metadataCache);
- return $this;
- }
-
- /**
- * Gets the metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable().
- *
- * @return Zend_Cache_Core or null
- */
- public function getMetadataCache()
- {
- return $this->_metadataCache;
- }
-
- /**
- * Indicate whether metadata should be cached in the class for the duration
- * of the instance
- *
- * @param bool $flag
- * @return Zend_Db_Table_Abstract
- */
- public function setMetadataCacheInClass($flag)
- {
- $this->_metadataCacheInClass = (bool) $flag;
- return $this;
- }
-
- /**
- * Retrieve flag indicating if metadata should be cached for duration of
- * instance
- *
- * @return bool
- */
- public function metadataCacheInClass()
- {
- return $this->_metadataCacheInClass;
- }
-
- /**
- * @param mixed $metadataCache Either a Cache object, or a string naming a Registry key
- * @return Zend_Cache_Core
- * @throws Zend_Db_Table_Exception
- */
- protected static function _setupMetadataCache($metadataCache)
- {
- if ($metadataCache === null) {
- return null;
- }
- if (is_string($metadataCache)) {
- require_once 'Zend/Registry.php';
- $metadataCache = Zend_Registry::get($metadataCache);
- }
- if (!$metadataCache instanceof Zend_Cache_Core) {
- require_once 'Zend/Db/Table/Exception.php';
- throw new Zend_Db_Table_Exception('Argument must be of type Zend_Cache_Core, or a Registry key where a Zend_Cache_Core object is stored');
- }
- return $metadataCache;
- }
-
- /**
- * Sets the sequence member, which defines the behavior for generating
- * primary key values in new rows.
- * - If this is a string, then the string names the sequence object.
- * - If this is boolean true, then the key uses an auto-incrementing
- * or identity mechanism.
- * - If this is boolean false, then the key is user-defined.
- * Use this for natural keys, for example.
- *
- * @param mixed $sequence
- * @return Zend_Db_Table_Adapter_Abstract Provides a fluent interface
- */
- protected function _setSequence($sequence)
- {
- $this->_sequence = $sequence;
-
- return $this;
- }
-
- /**
- * Turnkey for initialization of a table object.
- * Calls other protected methods for individual tasks, to make it easier
- * for a subclass to override part of the setup logic.
- *
- * @return void
- */
- protected function _setup()
- {
- $this->_setupDatabaseAdapter();
- $this->_setupTableName();
- }
-
- /**
- * Initialize database adapter.
- *
- * @return void
- */
- protected function _setupDatabaseAdapter()
- {
- if (! $this->_db) {
- $this->_db = self::getDefaultAdapter();
- if (!$this->_db instanceof Zend_Db_Adapter_Abstract) {
- require_once 'Zend/Db/Table/Exception.php';
- throw new Zend_Db_Table_Exception('No adapter found for ' . get_class($this));
- }
- }
- }
-
- /**
- * Initialize table and schema names.
- *
- * If the table name is not set in the class definition,
- * use the class name itself as the table name.
- *
- * A schema name provided with the table name (e.g., "schema.table") overrides
- * any existing value for $this->_schema.
- *
- * @return void
- */
- protected function _setupTableName()
- {
- if (! $this->_name) {
- $this->_name = get_class($this);
- } else if (strpos($this->_name, '.')) {
- list($this->_schema, $this->_name) = explode('.', $this->_name);
- }
- }
-
- /**
- * Initializes metadata.
- *
- * If metadata cannot be loaded from cache, adapter's describeTable() method is called to discover metadata
- * information. Returns true if and only if the metadata are loaded from cache.
- *
- * @return boolean
- * @throws Zend_Db_Table_Exception
- */
- protected function _setupMetadata()
- {
- if ($this->metadataCacheInClass() && (count($this->_metadata) > 0)) {
- return true;
- }
-
- // Assume that metadata will be loaded from cache
- $isMetadataFromCache = true;
-
- // If $this has no metadata cache but the class has a default metadata cache
- if (null === $this->_metadataCache && null !== self::$_defaultMetadataCache) {
- // Make $this use the default metadata cache of the class
- $this->_setMetadataCache(self::$_defaultMetadataCache);
- }
-
- // If $this has a metadata cache
- if (null !== $this->_metadataCache) {
- // Define the cache identifier where the metadata are saved
-
- //get db configuration
- $dbConfig = $this->_db->getConfig();
-
- // Define the cache identifier where the metadata are saved
- $cacheId = md5( // port:host/dbname:schema.table (based on availabilty)
- (isset($dbConfig['options']['port']) ? ':'.$dbConfig['options']['port'] : null)
- . (isset($dbConfig['options']['host']) ? ':'.$dbConfig['options']['host'] : null)
- . '/'.$dbConfig['dbname'].':'.$this->_schema.'.'.$this->_name
- );
- }
-
- // If $this has no metadata cache or metadata cache misses
- if (null === $this->_metadataCache || !($metadata = $this->_metadataCache->load($cacheId))) {
- // Metadata are not loaded from cache
- $isMetadataFromCache = false;
- // Fetch metadata from the adapter's describeTable() method
- $metadata = $this->_db->describeTable($this->_name, $this->_schema);
- // If $this has a metadata cache, then cache the metadata
- if (null !== $this->_metadataCache && !$this->_metadataCache->save($metadata, $cacheId)) {
- trigger_error('Failed saving metadata to metadataCache', E_USER_NOTICE);
- }
- }
-
- // Assign the metadata to $this
- $this->_metadata = $metadata;
-
- // Return whether the metadata were loaded from cache
- return $isMetadataFromCache;
- }
-
- /**
- * Retrieve table columns
- *
- * @return array
- */
- protected function _getCols()
- {
- if (null === $this->_cols) {
- $this->_setupMetadata();
- $this->_cols = array_keys($this->_metadata);
- }
- return $this->_cols;
- }
-
- /**
- * Initialize primary key from metadata.
- * If $_primary is not defined, discover primary keys
- * from the information returned by describeTable().
- *
- * @return void
- * @throws Zend_Db_Table_Exception
- */
- protected function _setupPrimaryKey()
- {
- if (!$this->_primary) {
- $this->_setupMetadata();
- $this->_primary = array();
- foreach ($this->_metadata as $col) {
- if ($col['PRIMARY']) {
- $this->_primary[ $col['PRIMARY_POSITION'] ] = $col['COLUMN_NAME'];
- if ($col['IDENTITY']) {
- $this->_identity = $col['PRIMARY_POSITION'];
- }
- }
- }
- // if no primary key was specified and none was found in the metadata
- // then throw an exception.
- if (empty($this->_primary)) {
- require_once 'Zend/Db/Table/Exception.php';
- throw new Zend_Db_Table_Exception('A table must have a primary key, but none was found');
- }
- } else if (!is_array($this->_primary)) {
- $this->_primary = array(1 => $this->_primary);
- } else if (isset($this->_primary[0])) {
- array_unshift($this->_primary, null);
- unset($this->_primary[0]);
- }
-
- $cols = $this->_getCols();
- if (! array_intersect((array) $this->_primary, $cols) == (array) $this->_primary) {
- require_once 'Zend/Db/Table/Exception.php';
- throw new Zend_Db_Table_Exception("Primary key column(s) ("
- . implode(',', (array) $this->_primary)
- . ") are not columns in this table ("
- . implode(',', $cols)
- . ")");
- }
-
- $primary = (array) $this->_primary;
- $pkIdentity = $primary[(int) $this->_identity];
-
- /**
- * Special case for PostgreSQL: a SERIAL key implicitly uses a sequence
- * object whose name is "__seq".
- */
- if ($this->_sequence === true && $this->_db instanceof Zend_Db_Adapter_Pdo_Pgsql) {
- $this->_sequence = $this->_db->quoteIdentifier("{$this->_name}_{$pkIdentity}_seq");
- if ($this->_schema) {
- $this->_sequence = $this->_db->quoteIdentifier($this->_schema) . '.' . $this->_sequence;
- }
- }
- }
-
- /**
- * Returns a normalized version of the reference map
- *
- * @return array
- */
- protected function _getReferenceMapNormalized()
- {
- $referenceMapNormalized = array();
-
- foreach ($this->_referenceMap as $rule => $map) {
-
- $referenceMapNormalized[$rule] = array();
-
- foreach ($map as $key => $value) {
- switch ($key) {
-
- // normalize COLUMNS and REF_COLUMNS to arrays
- case self::COLUMNS:
- case self::REF_COLUMNS:
- if (!is_array($value)) {
- $referenceMapNormalized[$rule][$key] = array($value);
- } else {
- $referenceMapNormalized[$rule][$key] = $value;
- }
- break;
-
- // other values are copied as-is
- default:
- $referenceMapNormalized[$rule][$key] = $value;
- break;
- }
- }
- }
-
- return $referenceMapNormalized;
- }
-
- /**
- * Initialize object
- *
- * Called from {@link __construct()} as final step of object instantiation.
- *
- * @return void
- */
- public function init()
- {
- }
-
- /**
- * Returns table information.
- *
- * You can elect to return only a part of this information by supplying its key name,
- * otherwise all information is returned as an array.
- *
- * @param $key The specific info part to return OPTIONAL
- * @return mixed
- */
- public function info($key = null)
- {
- $this->_setupPrimaryKey();
-
- $info = array(
- self::SCHEMA => $this->_schema,
- self::NAME => $this->_name,
- self::COLS => $this->_getCols(),
- self::PRIMARY => (array) $this->_primary,
- self::METADATA => $this->_metadata,
- self::ROW_CLASS => $this->getRowClass(),
- self::ROWSET_CLASS => $this->getRowsetClass(),
- self::REFERENCE_MAP => $this->_referenceMap,
- self::DEPENDENT_TABLES => $this->_dependentTables,
- self::SEQUENCE => $this->_sequence
- );
-
- if ($key === null) {
- return $info;
- }
-
- if (!array_key_exists($key, $info)) {
- require_once 'Zend/Db/Table/Exception.php';
- throw new Zend_Db_Table_Exception('There is no table information for the key "' . $key . '"');
- }
-
- return $info[$key];
- }
-
- /**
- * Returns an instance of a Zend_Db_Table_Select object.
- *
- * @param bool $withFromPart Whether or not to include the from part of the select based on the table
- * @return Zend_Db_Table_Select
- */
- public function select($withFromPart = self::SELECT_WITHOUT_FROM_PART)
- {
- require_once 'Zend/Db/Table/Select.php';
- $select = new Zend_Db_Table_Select($this);
- if ($withFromPart == self::SELECT_WITH_FROM_PART) {
- $select->from($this->info(self::NAME), Zend_Db_Table_Select::SQL_WILDCARD, $this->info(self::SCHEMA));
- }
- return $select;
- }
-
- /**
- * Inserts a new row.
- *
- * @param array $data Column-value pairs.
- * @return mixed The primary key of the row inserted.
- */
- public function insert(array $data)
- {
- $this->_setupPrimaryKey();
-
- /**
- * Zend_Db_Table assumes that if you have a compound primary key
- * and one of the columns in the key uses a sequence,
- * it's the _first_ column in the compound key.
- */
- $primary = (array) $this->_primary;
- $pkIdentity = $primary[(int)$this->_identity];
-
- /**
- * If this table uses a database sequence object and the data does not
- * specify a value, then get the next ID from the sequence and add it
- * to the row. We assume that only the first column in a compound
- * primary key takes a value from a sequence.
- */
- if (is_string($this->_sequence) && !isset($data[$pkIdentity])) {
- $data[$pkIdentity] = $this->_db->nextSequenceId($this->_sequence);
- }
-
- /**
- * If the primary key can be generated automatically, and no value was
- * specified in the user-supplied data, then omit it from the tuple.
- */
- if (array_key_exists($pkIdentity, $data) && $data[$pkIdentity] === null) {
- unset($data[$pkIdentity]);
- }
-
- /**
- * INSERT the new row.
- */
- $tableSpec = ($this->_schema ? $this->_schema . '.' : '') . $this->_name;
- $this->_db->insert($tableSpec, $data);
-
- /**
- * Fetch the most recent ID generated by an auto-increment
- * or IDENTITY column, unless the user has specified a value,
- * overriding the auto-increment mechanism.
- */
- if ($this->_sequence === true && !isset($data[$pkIdentity])) {
- $data[$pkIdentity] = $this->_db->lastInsertId();
- }
-
- /**
- * Return the primary key value if the PK is a single column,
- * else return an associative array of the PK column/value pairs.
- */
- $pkData = array_intersect_key($data, array_flip($primary));
- if (count($primary) == 1) {
- reset($pkData);
- return current($pkData);
- }
-
- return $pkData;
- }
-
- /**
- * Check if the provided column is an identity of the table
- *
- * @param string $column
- * @throws Zend_Db_Table_Exception
- * @return boolean
- */
- public function isIdentity($column)
- {
- $this->_setupPrimaryKey();
-
- if (!isset($this->_metadata[$column])) {
- /**
- * @see Zend_Db_Table_Exception
- */
- require_once 'Zend/Db/Table/Exception.php';
-
- throw new Zend_Db_Table_Exception('Column "' . $column . '" not found in table.');
- }
-
- return (bool) $this->_metadata[$column]['IDENTITY'];
- }
-
- /**
- * Updates existing rows.
- *
- * @param array $data Column-value pairs.
- * @param array|string $where An SQL WHERE clause, or an array of SQL WHERE clauses.
- * @return int The number of rows updated.
- */
- public function update(array $data, $where)
- {
- $tableSpec = ($this->_schema ? $this->_schema . '.' : '') . $this->_name;
- return $this->_db->update($tableSpec, $data, $where);
- }
-
- /**
- * Called by a row object for the parent table's class during save() method.
- *
- * @param string $parentTableClassname
- * @param array $oldPrimaryKey
- * @param array $newPrimaryKey
- * @return int
- */
- public function _cascadeUpdate($parentTableClassname, array $oldPrimaryKey, array $newPrimaryKey)
- {
- $this->_setupMetadata();
- $rowsAffected = 0;
- foreach ($this->_getReferenceMapNormalized() as $map) {
- if ($map[self::REF_TABLE_CLASS] == $parentTableClassname && isset($map[self::ON_UPDATE])) {
- switch ($map[self::ON_UPDATE]) {
- case self::CASCADE:
- $newRefs = array();
- $where = array();
- for ($i = 0; $i < count($map[self::COLUMNS]); ++$i) {
- $col = $this->_db->foldCase($map[self::COLUMNS][$i]);
- $refCol = $this->_db->foldCase($map[self::REF_COLUMNS][$i]);
- if (array_key_exists($refCol, $newPrimaryKey)) {
- $newRefs[$col] = $newPrimaryKey[$refCol];
- }
- $type = $this->_metadata[$col]['DATA_TYPE'];
- $where[] = $this->_db->quoteInto(
- $this->_db->quoteIdentifier($col, true) . ' = ?',
- $oldPrimaryKey[$refCol], $type);
- }
- $rowsAffected += $this->update($newRefs, $where);
- break;
- default:
- // no action
- break;
- }
- }
- }
- return $rowsAffected;
- }
-
- /**
- * Deletes existing rows.
- *
- * @param array|string $where SQL WHERE clause(s).
- * @return int The number of rows deleted.
- */
- public function delete($where)
- {
- $tableSpec = ($this->_schema ? $this->_schema . '.' : '') . $this->_name;
- return $this->_db->delete($tableSpec, $where);
- }
-
- /**
- * Called by parent table's class during delete() method.
- *
- * @param string $parentTableClassname
- * @param array $primaryKey
- * @return int Number of affected rows
- */
- public function _cascadeDelete($parentTableClassname, array $primaryKey)
- {
- $this->_setupMetadata();
- $rowsAffected = 0;
- foreach ($this->_getReferenceMapNormalized() as $map) {
- if ($map[self::REF_TABLE_CLASS] == $parentTableClassname && isset($map[self::ON_DELETE])) {
- switch ($map[self::ON_DELETE]) {
- case self::CASCADE:
- $where = array();
- for ($i = 0; $i < count($map[self::COLUMNS]); ++$i) {
- $col = $this->_db->foldCase($map[self::COLUMNS][$i]);
- $refCol = $this->_db->foldCase($map[self::REF_COLUMNS][$i]);
- $type = $this->_metadata[$col]['DATA_TYPE'];
- $where[] = $this->_db->quoteInto(
- $this->_db->quoteIdentifier($col, true) . ' = ?',
- $primaryKey[$refCol], $type);
- }
- $rowsAffected += $this->delete($where);
- break;
- default:
- // no action
- break;
- }
- }
- }
- return $rowsAffected;
- }
-
- /**
- * Fetches rows by primary key. The argument specifies one or more primary
- * key value(s). To find multiple rows by primary key, the argument must
- * be an array.
- *
- * This method accepts a variable number of arguments. If the table has a
- * multi-column primary key, the number of arguments must be the same as
- * the number of columns in the primary key. To find multiple rows in a
- * table with a multi-column primary key, each argument must be an array
- * with the same number of elements.
- *
- * The find() method always returns a Rowset object, even if only one row
- * was found.
- *
- * @param mixed $key The value(s) of the primary keys.
- * @return Zend_Db_Table_Rowset_Abstract Row(s) matching the criteria.
- * @throws Zend_Db_Table_Exception
- */
- public function find()
- {
- $this->_setupPrimaryKey();
- $args = func_get_args();
- $keyNames = array_values((array) $this->_primary);
-
- if (count($args) < count($keyNames)) {
- require_once 'Zend/Db/Table/Exception.php';
- throw new Zend_Db_Table_Exception("Too few columns for the primary key");
- }
-
- if (count($args) > count($keyNames)) {
- require_once 'Zend/Db/Table/Exception.php';
- throw new Zend_Db_Table_Exception("Too many columns for the primary key");
- }
-
- $whereList = array();
- $numberTerms = 0;
- foreach ($args as $keyPosition => $keyValues) {
- $keyValuesCount = count($keyValues);
- // Coerce the values to an array.
- // Don't simply typecast to array, because the values
- // might be Zend_Db_Expr objects.
- if (!is_array($keyValues)) {
- $keyValues = array($keyValues);
- }
- if ($numberTerms == 0) {
- $numberTerms = $keyValuesCount;
- } else if ($keyValuesCount != $numberTerms) {
- require_once 'Zend/Db/Table/Exception.php';
- throw new Zend_Db_Table_Exception("Missing value(s) for the primary key");
- }
- $keyValues = array_values($keyValues);
- for ($i = 0; $i < $keyValuesCount; ++$i) {
- if (!isset($whereList[$i])) {
- $whereList[$i] = array();
- }
- $whereList[$i][$keyPosition] = $keyValues[$i];
- }
- }
-
- $whereClause = null;
- if (count($whereList)) {
- $whereOrTerms = array();
- $tableName = $this->_db->quoteTableAs($this->_name, null, true);
- foreach ($whereList as $keyValueSets) {
- $whereAndTerms = array();
- foreach ($keyValueSets as $keyPosition => $keyValue) {
- $type = $this->_metadata[$keyNames[$keyPosition]]['DATA_TYPE'];
- $columnName = $this->_db->quoteIdentifier($keyNames[$keyPosition], true);
- $whereAndTerms[] = $this->_db->quoteInto(
- $tableName . '.' . $columnName . ' = ?',
- $keyValue, $type);
- }
- $whereOrTerms[] = '(' . implode(' AND ', $whereAndTerms) . ')';
- }
- $whereClause = '(' . implode(' OR ', $whereOrTerms) . ')';
- }
-
- // issue ZF-5775 (empty where clause should return empty rowset)
- if ($whereClause == null) {
- $rowsetClass = $this->getRowsetClass();
- if (!class_exists($rowsetClass)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($rowsetClass);
- }
- return new $rowsetClass(array('table' => $this, 'rowClass' => $this->getRowClass(), 'stored' => true));
- }
-
- return $this->fetchAll($whereClause);
- }
-
- /**
- * Fetches all rows.
- *
- * Honors the Zend_Db_Adapter fetch mode.
- *
- * @param string|array|Zend_Db_Table_Select $where OPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object.
- * @param string|array $order OPTIONAL An SQL ORDER clause.
- * @param int $count OPTIONAL An SQL LIMIT count.
- * @param int $offset OPTIONAL An SQL LIMIT offset.
- * @return Zend_Db_Table_Rowset_Abstract The row results per the Zend_Db_Adapter fetch mode.
- */
- public function fetchAll($where = null, $order = null, $count = null, $offset = null)
- {
- if (!($where instanceof Zend_Db_Table_Select)) {
- $select = $this->select();
-
- if ($where !== null) {
- $this->_where($select, $where);
- }
-
- if ($order !== null) {
- $this->_order($select, $order);
- }
-
- if ($count !== null || $offset !== null) {
- $select->limit($count, $offset);
- }
-
- } else {
- $select = $where;
- }
-
- $rows = $this->_fetch($select);
-
- $data = array(
- 'table' => $this,
- 'data' => $rows,
- 'readOnly' => $select->isReadOnly(),
- 'rowClass' => $this->getRowClass(),
- 'stored' => true
- );
-
- $rowsetClass = $this->getRowsetClass();
- if (!class_exists($rowsetClass)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($rowsetClass);
- }
- return new $rowsetClass($data);
- }
-
- /**
- * Fetches one row in an object of type Zend_Db_Table_Row_Abstract,
- * or returns null if no row matches the specified criteria.
- *
- * @param string|array|Zend_Db_Table_Select $where OPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object.
- * @param string|array $order OPTIONAL An SQL ORDER clause.
- * @return Zend_Db_Table_Row_Abstract|null The row results per the
- * Zend_Db_Adapter fetch mode, or null if no row found.
- */
- public function fetchRow($where = null, $order = null)
- {
- if (!($where instanceof Zend_Db_Table_Select)) {
- $select = $this->select();
-
- if ($where !== null) {
- $this->_where($select, $where);
- }
-
- if ($order !== null) {
- $this->_order($select, $order);
- }
-
- $select->limit(1);
-
- } else {
- $select = $where->limit(1);
- }
-
- $rows = $this->_fetch($select);
-
- if (count($rows) == 0) {
- return null;
- }
-
- $data = array(
- 'table' => $this,
- 'data' => $rows[0],
- 'readOnly' => $select->isReadOnly(),
- 'stored' => true
- );
-
- $rowClass = $this->getRowClass();
- if (!class_exists($rowClass)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($rowClass);
- }
- return new $rowClass($data);
- }
-
- /**
- * Fetches a new blank row (not from the database).
- *
- * @return Zend_Db_Table_Row_Abstract
- * @deprecated since 0.9.3 - use createRow() instead.
- */
- public function fetchNew()
- {
- return $this->createRow();
- }
-
- /**
- * Fetches a new blank row (not from the database).
- *
- * @param array $data OPTIONAL data to populate in the new row.
- * @param string $defaultSource OPTIONAL flag to force default values into new row
- * @return Zend_Db_Table_Row_Abstract
- */
- public function createRow(array $data = array(), $defaultSource = null)
- {
- $cols = $this->_getCols();
- $defaults = array_combine($cols, array_fill(0, count($cols), null));
-
- // nothing provided at call-time, take the class value
- if ($defaultSource == null) {
- $defaultSource = $this->_defaultSource;
- }
-
- if (!in_array($defaultSource, array(self::DEFAULT_CLASS, self::DEFAULT_DB, self::DEFAULT_NONE))) {
- $defaultSource = self::DEFAULT_NONE;
- }
-
- if ($defaultSource == self::DEFAULT_DB) {
- foreach ($this->_metadata as $metadataName => $metadata) {
- if (($metadata['DEFAULT'] != null) &&
- ($metadata['NULLABLE'] !== true || ($metadata['NULLABLE'] === true && isset($this->_defaultValues[$metadataName]) && $this->_defaultValues[$metadataName] === true)) &&
- (!(isset($this->_defaultValues[$metadataName]) && $this->_defaultValues[$metadataName] === false))) {
- $defaults[$metadataName] = $metadata['DEFAULT'];
- }
- }
- } elseif ($defaultSource == self::DEFAULT_CLASS && $this->_defaultValues) {
- foreach ($this->_defaultValues as $defaultName => $defaultValue) {
- if (array_key_exists($defaultName, $defaults)) {
- $defaults[$defaultName] = $defaultValue;
- }
- }
- }
-
- $config = array(
- 'table' => $this,
- 'data' => $defaults,
- 'readOnly' => false,
- 'stored' => false
- );
-
- $rowClass = $this->getRowClass();
- if (!class_exists($rowClass)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($rowClass);
- }
- $row = new $rowClass($config);
- $row->setFromArray($data);
- return $row;
- }
-
- /**
- * Generate WHERE clause from user-supplied string or array
- *
- * @param string|array $where OPTIONAL An SQL WHERE clause.
- * @return Zend_Db_Table_Select
- */
- protected function _where(Zend_Db_Table_Select $select, $where)
- {
- $where = (array) $where;
-
- foreach ($where as $key => $val) {
- // is $key an int?
- if (is_int($key)) {
- // $val is the full condition
- $select->where($val);
- } else {
- // $key is the condition with placeholder,
- // and $val is quoted into the condition
- $select->where($key, $val);
- }
- }
-
- return $select;
- }
-
- /**
- * Generate ORDER clause from user-supplied string or array
- *
- * @param string|array $order OPTIONAL An SQL ORDER clause.
- * @return Zend_Db_Table_Select
- */
- protected function _order(Zend_Db_Table_Select $select, $order)
- {
- if (!is_array($order)) {
- $order = array($order);
- }
-
- foreach ($order as $val) {
- $select->order($val);
- }
-
- return $select;
- }
-
- /**
- * Support method for fetching rows.
- *
- * @param Zend_Db_Table_Select $select query options.
- * @return array An array containing the row results in FETCH_ASSOC mode.
- */
- protected function _fetch(Zend_Db_Table_Select $select)
- {
- $stmt = $this->_db->query($select);
- $data = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
- return $data;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Table/Definition.php zendframework-2.2.6/library/Zend/Db/Table/Definition.php
--- zendframework-1.10.4/library/Zend/Db/Table/Definition.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Table/Definition.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,131 +0,0 @@
-setConfig($options);
- } elseif (is_array($options)) {
- $this->setOptions($options);
- }
- }
-
- /**
- * setConfig()
- *
- * @param Zend_Config $config
- * @return Zend_Db_Table_Definition
- */
- public function setConfig(Zend_Config $config)
- {
- $this->setOptions($config->toArray());
- return $this;
- }
-
- /**
- * setOptions()
- *
- * @param array $options
- * @return Zend_Db_Table_Definition
- */
- public function setOptions(Array $options)
- {
- foreach ($options as $optionName => $optionValue) {
- $this->setTableConfig($optionName, $optionValue);
- }
- return $this;
- }
-
- /**
- * @param string $tableName
- * @param array $tableConfig
- * @return Zend_Db_Table_Definition
- */
- public function setTableConfig($tableName, array $tableConfig)
- {
- // @todo logic here
- $tableConfig[Zend_Db_Table::DEFINITION_CONFIG_NAME] = $tableName;
- $tableConfig[Zend_Db_Table::DEFINITION] = $this;
-
- if (!isset($tableConfig[Zend_Db_Table::NAME])) {
- $tableConfig[Zend_Db_Table::NAME] = $tableName;
- }
-
- $this->_tableConfigs[$tableName] = $tableConfig;
- return $this;
- }
-
- /**
- * getTableConfig()
- *
- * @param string $tableName
- * @return array
- */
- public function getTableConfig($tableName)
- {
- return $this->_tableConfigs[$tableName];
- }
-
- /**
- * removeTableConfig()
- *
- * @param string $tableName
- */
- public function removeTableConfig($tableName)
- {
- unset($this->_tableConfigs[$tableName]);
- }
-
- /**
- * hasTableConfig()
- *
- * @param string $tableName
- * @return bool
- */
- public function hasTableConfig($tableName)
- {
- return (isset($this->_tableConfigs[$tableName]));
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Table/Exception.php zendframework-2.2.6/library/Zend/Db/Table/Exception.php
--- zendframework-1.10.4/library/Zend/Db/Table/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Table/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,38 +0,0 @@
- value).
- * The keys must match the physical names of columns in the
- * table for which this row is defined.
- *
- * @var array
- */
- protected $_data = array();
-
- /**
- * This is set to a copy of $_data when the data is fetched from
- * a database, specified as a new tuple in the constructor, or
- * when dirty data is posted to the database with save().
- *
- * @var array
- */
- protected $_cleanData = array();
-
- /**
- * Tracks columns where data has been updated. Allows more specific insert and
- * update operations.
- *
- * @var array
- */
- protected $_modifiedFields = array();
-
- /**
- * Zend_Db_Table_Abstract parent class or instance.
- *
- * @var Zend_Db_Table_Abstract
- */
- protected $_table = null;
-
- /**
- * Connected is true if we have a reference to a live
- * Zend_Db_Table_Abstract object.
- * This is false after the Rowset has been deserialized.
- *
- * @var boolean
- */
- protected $_connected = true;
-
- /**
- * A row is marked read only if it contains columns that are not physically represented within
- * the database schema (e.g. evaluated columns/Zend_Db_Expr columns). This can also be passed
- * as a run-time config options as a means of protecting row data.
- *
- * @var boolean
- */
- protected $_readOnly = false;
-
- /**
- * Name of the class of the Zend_Db_Table_Abstract object.
- *
- * @var string
- */
- protected $_tableClass = null;
-
- /**
- * Primary row key(s).
- *
- * @var array
- */
- protected $_primary;
-
- /**
- * Constructor.
- *
- * Supported params for $config are:-
- * - table = class name or object of type Zend_Db_Table_Abstract
- * - data = values of columns in this row.
- *
- * @param array $config OPTIONAL Array of user-specified config options.
- * @return void
- * @throws Zend_Db_Table_Row_Exception
- */
- public function __construct(array $config = array())
- {
- if (isset($config['table']) && $config['table'] instanceof Zend_Db_Table_Abstract) {
- $this->_table = $config['table'];
- $this->_tableClass = get_class($this->_table);
- } elseif ($this->_tableClass !== null) {
- $this->_table = $this->_getTableFromString($this->_tableClass);
- }
-
- if (isset($config['data'])) {
- if (!is_array($config['data'])) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception('Data must be an array');
- }
- $this->_data = $config['data'];
- }
- if (isset($config['stored']) && $config['stored'] === true) {
- $this->_cleanData = $this->_data;
- }
-
- if (isset($config['readOnly']) && $config['readOnly'] === true) {
- $this->setReadOnly(true);
- }
-
- // Retrieve primary keys from table schema
- if (($table = $this->_getTable())) {
- $info = $table->info();
- $this->_primary = (array) $info['primary'];
- }
-
- $this->init();
- }
-
- /**
- * Transform a column name from the user-specified form
- * to the physical form used in the database.
- * You can override this method in a custom Row class
- * to implement column name mappings, for example inflection.
- *
- * @param string $columnName Column name given.
- * @return string The column name after transformation applied (none by default).
- * @throws Zend_Db_Table_Row_Exception if the $columnName is not a string.
- */
- protected function _transformColumn($columnName)
- {
- if (!is_string($columnName)) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception('Specified column is not a string');
- }
- // Perform no transformation by default
- return $columnName;
- }
-
- /**
- * Retrieve row field value
- *
- * @param string $columnName The user-specified column name.
- * @return string The corresponding column value.
- * @throws Zend_Db_Table_Row_Exception if the $columnName is not a column in the row.
- */
- public function __get($columnName)
- {
- $columnName = $this->_transformColumn($columnName);
- if (!array_key_exists($columnName, $this->_data)) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception("Specified column \"$columnName\" is not in the row");
- }
- return $this->_data[$columnName];
- }
-
- /**
- * Set row field value
- *
- * @param string $columnName The column key.
- * @param mixed $value The value for the property.
- * @return void
- * @throws Zend_Db_Table_Row_Exception
- */
- public function __set($columnName, $value)
- {
- $columnName = $this->_transformColumn($columnName);
- if (!array_key_exists($columnName, $this->_data)) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception("Specified column \"$columnName\" is not in the row");
- }
- $this->_data[$columnName] = $value;
- $this->_modifiedFields[$columnName] = true;
- }
-
- /**
- * Unset row field value
- *
- * @param string $columnName The column key.
- * @return Zend_Db_Table_Row_Abstract
- * @throws Zend_Db_Table_Row_Exception
- */
- public function __unset($columnName)
- {
- $columnName = $this->_transformColumn($columnName);
- if (!array_key_exists($columnName, $this->_data)) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception("Specified column \"$columnName\" is not in the row");
- }
- if ($this->isConnected() && in_array($columnName, $this->_table->info('primary'))) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception("Specified column \"$columnName\" is a primary key and should not be unset");
- }
- unset($this->_data[$columnName]);
- return $this;
- }
-
- /**
- * Test existence of row field
- *
- * @param string $columnName The column key.
- * @return boolean
- */
- public function __isset($columnName)
- {
- $columnName = $this->_transformColumn($columnName);
- return array_key_exists($columnName, $this->_data);
- }
-
- /**
- * Store table, primary key and data in serialized object
- *
- * @return array
- */
- public function __sleep()
- {
- return array('_tableClass', '_primary', '_data', '_cleanData', '_readOnly' ,'_modifiedFields');
- }
-
- /**
- * Setup to do on wakeup.
- * A de-serialized Row should not be assumed to have access to a live
- * database connection, so set _connected = false.
- *
- * @return void
- */
- public function __wakeup()
- {
- $this->_connected = false;
- }
-
- /**
- * Proxy to __isset
- * Required by the ArrayAccess implementation
- *
- * @param string $offset
- * @return boolean
- */
- public function offsetExists($offset)
- {
- return $this->__isset($offset);
- }
-
- /**
- * Proxy to __get
- * Required by the ArrayAccess implementation
- *
- * @param string $offset
- * @return string
- */
- public function offsetGet($offset)
- {
- return $this->__get($offset);
- }
-
- /**
- * Proxy to __set
- * Required by the ArrayAccess implementation
- *
- * @param string $offset
- * @param mixed $value
- */
- public function offsetSet($offset, $value)
- {
- $this->__set($offset, $value);
- }
-
- /**
- * Proxy to __unset
- * Required by the ArrayAccess implementation
- *
- * @param string $offset
- */
- public function offsetUnset($offset)
- {
- return $this->__unset($offset);
- }
-
- /**
- * Initialize object
- *
- * Called from {@link __construct()} as final step of object instantiation.
- *
- * @return void
- */
- public function init()
- {
- }
-
- /**
- * Returns the table object, or null if this is disconnected row
- *
- * @return Zend_Db_Table_Abstract|null
- */
- public function getTable()
- {
- return $this->_table;
- }
-
- /**
- * Set the table object, to re-establish a live connection
- * to the database for a Row that has been de-serialized.
- *
- * @param Zend_Db_Table_Abstract $table
- * @return boolean
- * @throws Zend_Db_Table_Row_Exception
- */
- public function setTable(Zend_Db_Table_Abstract $table = null)
- {
- if ($table == null) {
- $this->_table = null;
- $this->_connected = false;
- return false;
- }
-
- $tableClass = get_class($table);
- if (! $table instanceof $this->_tableClass) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception("The specified Table is of class $tableClass, expecting class to be instance of $this->_tableClass");
- }
-
- $this->_table = $table;
- $this->_tableClass = $tableClass;
-
- $info = $this->_table->info();
-
- if ($info['cols'] != array_keys($this->_data)) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception('The specified Table does not have the same columns as the Row');
- }
-
- if (! array_intersect((array) $this->_primary, $info['primary']) == (array) $this->_primary) {
-
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception("The specified Table '$tableClass' does not have the same primary key as the Row");
- }
-
- $this->_connected = true;
- return true;
- }
-
- /**
- * Query the class name of the Table object for which this
- * Row was created.
- *
- * @return string
- */
- public function getTableClass()
- {
- return $this->_tableClass;
- }
-
- /**
- * Test the connected status of the row.
- *
- * @return boolean
- */
- public function isConnected()
- {
- return $this->_connected;
- }
-
- /**
- * Test the read-only status of the row.
- *
- * @return boolean
- */
- public function isReadOnly()
- {
- return $this->_readOnly;
- }
-
- /**
- * Set the read-only status of the row.
- *
- * @param boolean $flag
- * @return boolean
- */
- public function setReadOnly($flag)
- {
- $this->_readOnly = (bool) $flag;
- }
-
- /**
- * Returns an instance of the parent table's Zend_Db_Table_Select object.
- *
- * @return Zend_Db_Table_Select
- */
- public function select()
- {
- return $this->getTable()->select();
- }
-
- /**
- * Saves the properties to the database.
- *
- * This performs an intelligent insert/update, and reloads the
- * properties with fresh data from the table on success.
- *
- * @return mixed The primary key value(s), as an associative array if the
- * key is compound, or a scalar if the key is single-column.
- */
- public function save()
- {
- /**
- * If the _cleanData array is empty,
- * this is an INSERT of a new row.
- * Otherwise it is an UPDATE.
- */
- if (empty($this->_cleanData)) {
- return $this->_doInsert();
- } else {
- return $this->_doUpdate();
- }
- }
-
- /**
- * @return mixed The primary key value(s), as an associative array if the
- * key is compound, or a scalar if the key is single-column.
- */
- protected function _doInsert()
- {
- /**
- * A read-only row cannot be saved.
- */
- if ($this->_readOnly === true) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception('This row has been marked read-only');
- }
-
- /**
- * Run pre-INSERT logic
- */
- $this->_insert();
-
- /**
- * Execute the INSERT (this may throw an exception)
- */
- $data = array_intersect_key($this->_data, $this->_modifiedFields);
- $primaryKey = $this->_getTable()->insert($data);
-
- /**
- * Normalize the result to an array indexed by primary key column(s).
- * The table insert() method may return a scalar.
- */
- if (is_array($primaryKey)) {
- $newPrimaryKey = $primaryKey;
- } else {
- //ZF-6167 Use tempPrimaryKey temporary to avoid that zend encoding fails.
- $tempPrimaryKey = (array) $this->_primary;
- $newPrimaryKey = array(current($tempPrimaryKey) => $primaryKey);
- }
-
- /**
- * Save the new primary key value in _data. The primary key may have
- * been generated by a sequence or auto-increment mechanism, and this
- * merge should be done before the _postInsert() method is run, so the
- * new values are available for logging, etc.
- */
- $this->_data = array_merge($this->_data, $newPrimaryKey);
-
- /**
- * Run post-INSERT logic
- */
- $this->_postInsert();
-
- /**
- * Update the _cleanData to reflect that the data has been inserted.
- */
- $this->_refresh();
-
- return $primaryKey;
- }
-
- /**
- * @return mixed The primary key value(s), as an associative array if the
- * key is compound, or a scalar if the key is single-column.
- */
- protected function _doUpdate()
- {
- /**
- * A read-only row cannot be saved.
- */
- if ($this->_readOnly === true) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception('This row has been marked read-only');
- }
-
- /**
- * Get expressions for a WHERE clause
- * based on the primary key value(s).
- */
- $where = $this->_getWhereQuery(false);
-
- /**
- * Run pre-UPDATE logic
- */
- $this->_update();
-
- /**
- * Compare the data to the modified fields array to discover
- * which columns have been changed.
- */
- $diffData = array_intersect_key($this->_data, $this->_modifiedFields);
-
- /**
- * Were any of the changed columns part of the primary key?
- */
- $pkDiffData = array_intersect_key($diffData, array_flip((array)$this->_primary));
-
- /**
- * Execute cascading updates against dependent tables.
- * Do this only if primary key value(s) were changed.
- */
- if (count($pkDiffData) > 0) {
- $depTables = $this->_getTable()->getDependentTables();
- if (!empty($depTables)) {
- $pkNew = $this->_getPrimaryKey(true);
- $pkOld = $this->_getPrimaryKey(false);
- foreach ($depTables as $tableClass) {
- $t = $this->_getTableFromString($tableClass);
- $t->_cascadeUpdate($this->getTableClass(), $pkOld, $pkNew);
- }
- }
- }
-
- /**
- * Execute the UPDATE (this may throw an exception)
- * Do this only if data values were changed.
- * Use the $diffData variable, so the UPDATE statement
- * includes SET terms only for data values that changed.
- */
- if (count($diffData) > 0) {
- $this->_getTable()->update($diffData, $where);
- }
-
- /**
- * Run post-UPDATE logic. Do this before the _refresh()
- * so the _postUpdate() function can tell the difference
- * between changed data and clean (pre-changed) data.
- */
- $this->_postUpdate();
-
- /**
- * Refresh the data just in case triggers in the RDBMS changed
- * any columns. Also this resets the _cleanData.
- */
- $this->_refresh();
-
- /**
- * Return the primary key value(s) as an array
- * if the key is compound or a scalar if the key
- * is a scalar.
- */
- $primaryKey = $this->_getPrimaryKey(true);
- if (count($primaryKey) == 1) {
- return current($primaryKey);
- }
-
- return $primaryKey;
- }
-
- /**
- * Deletes existing rows.
- *
- * @return int The number of rows deleted.
- */
- public function delete()
- {
- /**
- * A read-only row cannot be deleted.
- */
- if ($this->_readOnly === true) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception('This row has been marked read-only');
- }
-
- $where = $this->_getWhereQuery();
-
- /**
- * Execute pre-DELETE logic
- */
- $this->_delete();
-
- /**
- * Execute cascading deletes against dependent tables
- */
- $depTables = $this->_getTable()->getDependentTables();
- if (!empty($depTables)) {
- $pk = $this->_getPrimaryKey();
- foreach ($depTables as $tableClass) {
- $t = $this->_getTableFromString($tableClass);
- $t->_cascadeDelete($this->getTableClass(), $pk);
- }
- }
-
- /**
- * Execute the DELETE (this may throw an exception)
- */
- $result = $this->_getTable()->delete($where);
-
- /**
- * Execute post-DELETE logic
- */
- $this->_postDelete();
-
- /**
- * Reset all fields to null to indicate that the row is not there
- */
- $this->_data = array_combine(
- array_keys($this->_data),
- array_fill(0, count($this->_data), null)
- );
-
- return $result;
- }
-
- /**
- * Returns the column/value data as an array.
- *
- * @return array
- */
- public function toArray()
- {
- return (array)$this->_data;
- }
-
- /**
- * Sets all data in the row from an array.
- *
- * @param array $data
- * @return Zend_Db_Table_Row_Abstract Provides a fluent interface
- */
- public function setFromArray(array $data)
- {
- $data = array_intersect_key($data, $this->_data);
-
- foreach ($data as $columnName => $value) {
- $this->__set($columnName, $value);
- }
-
- return $this;
- }
-
- /**
- * Refreshes properties from the database.
- *
- * @return void
- */
- public function refresh()
- {
- return $this->_refresh();
- }
-
- /**
- * Retrieves an instance of the parent table.
- *
- * @return Zend_Db_Table_Abstract
- */
- protected function _getTable()
- {
- if (!$this->_connected) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception('Cannot save a Row unless it is connected');
- }
- return $this->_table;
- }
-
- /**
- * Retrieves an associative array of primary keys.
- *
- * @param bool $useDirty
- * @return array
- */
- protected function _getPrimaryKey($useDirty = true)
- {
- if (!is_array($this->_primary)) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception("The primary key must be set as an array");
- }
-
- $primary = array_flip($this->_primary);
- if ($useDirty) {
- $array = array_intersect_key($this->_data, $primary);
- } else {
- $array = array_intersect_key($this->_cleanData, $primary);
- }
- if (count($primary) != count($array)) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception("The specified Table '$this->_tableClass' does not have the same primary key as the Row");
- }
- return $array;
- }
-
- /**
- * Constructs where statement for retrieving row(s).
- *
- * @param bool $useDirty
- * @return array
- */
- protected function _getWhereQuery($useDirty = true)
- {
- $where = array();
- $db = $this->_getTable()->getAdapter();
- $primaryKey = $this->_getPrimaryKey($useDirty);
- $info = $this->_getTable()->info();
- $metadata = $info[Zend_Db_Table_Abstract::METADATA];
-
- // retrieve recently updated row using primary keys
- $where = array();
- foreach ($primaryKey as $column => $value) {
- $tableName = $db->quoteIdentifier($info[Zend_Db_Table_Abstract::NAME], true);
- $type = $metadata[$column]['DATA_TYPE'];
- $columnName = $db->quoteIdentifier($column, true);
- $where[] = $db->quoteInto("{$tableName}.{$columnName} = ?", $value, $type);
- }
- return $where;
- }
-
- /**
- * Refreshes properties from the database.
- *
- * @return void
- */
- protected function _refresh()
- {
- $where = $this->_getWhereQuery();
- $row = $this->_getTable()->fetchRow($where);
-
- if (null === $row) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception('Cannot refresh row as parent is missing');
- }
-
- $this->_data = $row->toArray();
- $this->_cleanData = $this->_data;
- $this->_modifiedFields = array();
- }
-
- /**
- * Allows pre-insert logic to be applied to row.
- * Subclasses may override this method.
- *
- * @return void
- */
- protected function _insert()
- {
- }
-
- /**
- * Allows post-insert logic to be applied to row.
- * Subclasses may override this method.
- *
- * @return void
- */
- protected function _postInsert()
- {
- }
-
- /**
- * Allows pre-update logic to be applied to row.
- * Subclasses may override this method.
- *
- * @return void
- */
- protected function _update()
- {
- }
-
- /**
- * Allows post-update logic to be applied to row.
- * Subclasses may override this method.
- *
- * @return void
- */
- protected function _postUpdate()
- {
- }
-
- /**
- * Allows pre-delete logic to be applied to row.
- * Subclasses may override this method.
- *
- * @return void
- */
- protected function _delete()
- {
- }
-
- /**
- * Allows post-delete logic to be applied to row.
- * Subclasses may override this method.
- *
- * @return void
- */
- protected function _postDelete()
- {
- }
-
- /**
- * Prepares a table reference for lookup.
- *
- * Ensures all reference keys are set and properly formatted.
- *
- * @param Zend_Db_Table_Abstract $dependentTable
- * @param Zend_Db_Table_Abstract $parentTable
- * @param string $ruleKey
- * @return array
- */
- protected function _prepareReference(Zend_Db_Table_Abstract $dependentTable, Zend_Db_Table_Abstract $parentTable, $ruleKey)
- {
- $parentTableName = (get_class($parentTable) === 'Zend_Db_Table') ? $parentTable->getDefinitionConfigName() : get_class($parentTable);
- $map = $dependentTable->getReference($parentTableName, $ruleKey);
-
- if (!isset($map[Zend_Db_Table_Abstract::REF_COLUMNS])) {
- $parentInfo = $parentTable->info();
- $map[Zend_Db_Table_Abstract::REF_COLUMNS] = array_values((array) $parentInfo['primary']);
- }
-
- $map[Zend_Db_Table_Abstract::COLUMNS] = (array) $map[Zend_Db_Table_Abstract::COLUMNS];
- $map[Zend_Db_Table_Abstract::REF_COLUMNS] = (array) $map[Zend_Db_Table_Abstract::REF_COLUMNS];
-
- return $map;
- }
-
- /**
- * Query a dependent table to retrieve rows matching the current row.
- *
- * @param string|Zend_Db_Table_Abstract $dependentTable
- * @param string OPTIONAL $ruleKey
- * @param Zend_Db_Table_Select OPTIONAL $select
- * @return Zend_Db_Table_Rowset_Abstract Query result from $dependentTable
- * @throws Zend_Db_Table_Row_Exception If $dependentTable is not a table or is not loadable.
- */
- public function findDependentRowset($dependentTable, $ruleKey = null, Zend_Db_Table_Select $select = null)
- {
- $db = $this->_getTable()->getAdapter();
-
- if (is_string($dependentTable)) {
- $dependentTable = $this->_getTableFromString($dependentTable);
- }
-
- if (!$dependentTable instanceof Zend_Db_Table_Abstract) {
- $type = gettype($dependentTable);
- if ($type == 'object') {
- $type = get_class($dependentTable);
- }
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception("Dependent table must be a Zend_Db_Table_Abstract, but it is $type");
- }
-
- // even if we are interacting between a table defined in a class and a
- // table via extension, ensure to persist the definition
- if (($tableDefinition = $this->_table->getDefinition()) !== null
- && ($dependentTable->getDefinition() == null)) {
- $dependentTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
- }
-
- if ($select === null) {
- $select = $dependentTable->select();
- } else {
- $select->setTable($dependentTable);
- }
-
- $map = $this->_prepareReference($dependentTable, $this->_getTable(), $ruleKey);
-
- for ($i = 0; $i < count($map[Zend_Db_Table_Abstract::COLUMNS]); ++$i) {
- $parentColumnName = $db->foldCase($map[Zend_Db_Table_Abstract::REF_COLUMNS][$i]);
- $value = $this->_data[$parentColumnName];
- // Use adapter from dependent table to ensure correct query construction
- $dependentDb = $dependentTable->getAdapter();
- $dependentColumnName = $dependentDb->foldCase($map[Zend_Db_Table_Abstract::COLUMNS][$i]);
- $dependentColumn = $dependentDb->quoteIdentifier($dependentColumnName, true);
- $dependentInfo = $dependentTable->info();
- $type = $dependentInfo[Zend_Db_Table_Abstract::METADATA][$dependentColumnName]['DATA_TYPE'];
- $select->where("$dependentColumn = ?", $value, $type);
- }
-
- return $dependentTable->fetchAll($select);
- }
-
- /**
- * Query a parent table to retrieve the single row matching the current row.
- *
- * @param string|Zend_Db_Table_Abstract $parentTable
- * @param string OPTIONAL $ruleKey
- * @param Zend_Db_Table_Select OPTIONAL $select
- * @return Zend_Db_Table_Row_Abstract Query result from $parentTable
- * @throws Zend_Db_Table_Row_Exception If $parentTable is not a table or is not loadable.
- */
- public function findParentRow($parentTable, $ruleKey = null, Zend_Db_Table_Select $select = null)
- {
- $db = $this->_getTable()->getAdapter();
-
- if (is_string($parentTable)) {
- $parentTable = $this->_getTableFromString($parentTable);
- }
-
- if (!$parentTable instanceof Zend_Db_Table_Abstract) {
- $type = gettype($parentTable);
- if ($type == 'object') {
- $type = get_class($parentTable);
- }
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception("Parent table must be a Zend_Db_Table_Abstract, but it is $type");
- }
-
- // even if we are interacting between a table defined in a class and a
- // table via extension, ensure to persist the definition
- if (($tableDefinition = $this->_table->getDefinition()) !== null
- && ($parentTable->getDefinition() == null)) {
- $parentTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
- }
-
- if ($select === null) {
- $select = $parentTable->select();
- } else {
- $select->setTable($parentTable);
- }
-
- $map = $this->_prepareReference($this->_getTable(), $parentTable, $ruleKey);
-
- // iterate the map, creating the proper wheres
- for ($i = 0; $i < count($map[Zend_Db_Table_Abstract::COLUMNS]); ++$i) {
- $dependentColumnName = $db->foldCase($map[Zend_Db_Table_Abstract::COLUMNS][$i]);
- $value = $this->_data[$dependentColumnName];
- // Use adapter from parent table to ensure correct query construction
- $parentDb = $parentTable->getAdapter();
- $parentColumnName = $parentDb->foldCase($map[Zend_Db_Table_Abstract::REF_COLUMNS][$i]);
- $parentColumn = $parentDb->quoteIdentifier($parentColumnName, true);
- $parentInfo = $parentTable->info();
-
- // determine where part
- $type = $parentInfo[Zend_Db_Table_Abstract::METADATA][$parentColumnName]['DATA_TYPE'];
- $nullable = $parentInfo[Zend_Db_Table_Abstract::METADATA][$parentColumnName]['NULLABLE'];
- if ($value === null && $nullable == true) {
- $select->where("$parentColumn IS NULL");
- } elseif ($value === null && $nullable == false) {
- return null;
- } else {
- $select->where("$parentColumn = ?", $value, $type);
- }
-
- }
-
- return $parentTable->fetchRow($select);
- }
-
- /**
- * @param string|Zend_Db_Table_Abstract $matchTable
- * @param string|Zend_Db_Table_Abstract $intersectionTable
- * @param string OPTIONAL $callerRefRule
- * @param string OPTIONAL $matchRefRule
- * @param Zend_Db_Table_Select OPTIONAL $select
- * @return Zend_Db_Table_Rowset_Abstract Query result from $matchTable
- * @throws Zend_Db_Table_Row_Exception If $matchTable or $intersectionTable is not a table class or is not loadable.
- */
- public function findManyToManyRowset($matchTable, $intersectionTable, $callerRefRule = null,
- $matchRefRule = null, Zend_Db_Table_Select $select = null)
- {
- $db = $this->_getTable()->getAdapter();
-
- if (is_string($intersectionTable)) {
- $intersectionTable = $this->_getTableFromString($intersectionTable);
- }
-
- if (!$intersectionTable instanceof Zend_Db_Table_Abstract) {
- $type = gettype($intersectionTable);
- if ($type == 'object') {
- $type = get_class($intersectionTable);
- }
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception("Intersection table must be a Zend_Db_Table_Abstract, but it is $type");
- }
-
- // even if we are interacting between a table defined in a class and a
- // table via extension, ensure to persist the definition
- if (($tableDefinition = $this->_table->getDefinition()) !== null
- && ($intersectionTable->getDefinition() == null)) {
- $intersectionTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
- }
-
- if (is_string($matchTable)) {
- $matchTable = $this->_getTableFromString($matchTable);
- }
-
- if (! $matchTable instanceof Zend_Db_Table_Abstract) {
- $type = gettype($matchTable);
- if ($type == 'object') {
- $type = get_class($matchTable);
- }
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception("Match table must be a Zend_Db_Table_Abstract, but it is $type");
- }
-
- // even if we are interacting between a table defined in a class and a
- // table via extension, ensure to persist the definition
- if (($tableDefinition = $this->_table->getDefinition()) !== null
- && ($matchTable->getDefinition() == null)) {
- $matchTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
- }
-
- if ($select === null) {
- $select = $matchTable->select();
- } else {
- $select->setTable($matchTable);
- }
-
- // Use adapter from intersection table to ensure correct query construction
- $interInfo = $intersectionTable->info();
- $interDb = $intersectionTable->getAdapter();
- $interName = $interInfo['name'];
- $interSchema = isset($interInfo['schema']) ? $interInfo['schema'] : null;
- $matchInfo = $matchTable->info();
- $matchName = $matchInfo['name'];
- $matchSchema = isset($matchInfo['schema']) ? $matchInfo['schema'] : null;
-
- $matchMap = $this->_prepareReference($intersectionTable, $matchTable, $matchRefRule);
-
- for ($i = 0; $i < count($matchMap[Zend_Db_Table_Abstract::COLUMNS]); ++$i) {
- $interCol = $interDb->quoteIdentifier('i' . '.' . $matchMap[Zend_Db_Table_Abstract::COLUMNS][$i], true);
- $matchCol = $interDb->quoteIdentifier('m' . '.' . $matchMap[Zend_Db_Table_Abstract::REF_COLUMNS][$i], true);
- $joinCond[] = "$interCol = $matchCol";
- }
- $joinCond = implode(' AND ', $joinCond);
-
- $select->from(array('i' => $interName), array(), $interSchema)
- ->joinInner(array('m' => $matchName), $joinCond, Zend_Db_Select::SQL_WILDCARD, $matchSchema)
- ->setIntegrityCheck(false);
-
- $callerMap = $this->_prepareReference($intersectionTable, $this->_getTable(), $callerRefRule);
-
- for ($i = 0; $i < count($callerMap[Zend_Db_Table_Abstract::COLUMNS]); ++$i) {
- $callerColumnName = $db->foldCase($callerMap[Zend_Db_Table_Abstract::REF_COLUMNS][$i]);
- $value = $this->_data[$callerColumnName];
- $interColumnName = $interDb->foldCase($callerMap[Zend_Db_Table_Abstract::COLUMNS][$i]);
- $interCol = $interDb->quoteIdentifier("i.$interColumnName", true);
- $interInfo = $intersectionTable->info();
- $type = $interInfo[Zend_Db_Table_Abstract::METADATA][$interColumnName]['DATA_TYPE'];
- $select->where($interDb->quoteInto("$interCol = ?", $value, $type));
- }
-
- $stmt = $select->query();
-
- $config = array(
- 'table' => $matchTable,
- 'data' => $stmt->fetchAll(Zend_Db::FETCH_ASSOC),
- 'rowClass' => $matchTable->getRowClass(),
- 'readOnly' => false,
- 'stored' => true
- );
-
- $rowsetClass = $matchTable->getRowsetClass();
- if (!class_exists($rowsetClass)) {
- try {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($rowsetClass);
- } catch (Zend_Exception $e) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
- $rowset = new $rowsetClass($config);
- return $rowset;
- }
-
- /**
- * Turn magic function calls into non-magic function calls
- * to the above methods.
- *
- * @param string $method
- * @param array $args OPTIONAL Zend_Db_Table_Select query modifier
- * @return Zend_Db_Table_Row_Abstract|Zend_Db_Table_Rowset_Abstract
- * @throws Zend_Db_Table_Row_Exception If an invalid method is called.
- */
- public function __call($method, array $args)
- {
- $matches = array();
-
- if (count($args) && $args[0] instanceof Zend_Db_Table_Select) {
- $select = $args[0];
- } else {
- $select = null;
- }
-
- /**
- * Recognize methods for Has-Many cases:
- * findParent()
- * findParentBy()
- * Use the non-greedy pattern repeat modifier e.g. \w+?
- */
- if (preg_match('/^findParent(\w+?)(?:By(\w+))?$/', $method, $matches)) {
- $class = $matches[1];
- $ruleKey1 = isset($matches[2]) ? $matches[2] : null;
- return $this->findParentRow($class, $ruleKey1, $select);
- }
-
- /**
- * Recognize methods for Many-to-Many cases:
- * findVia()
- * findViaBy()
- * findViaByAnd()
- * Use the non-greedy pattern repeat modifier e.g. \w+?
- */
- if (preg_match('/^find(\w+?)Via(\w+?)(?:By(\w+?)(?:And(\w+))?)?$/', $method, $matches)) {
- $class = $matches[1];
- $viaClass = $matches[2];
- $ruleKey1 = isset($matches[3]) ? $matches[3] : null;
- $ruleKey2 = isset($matches[4]) ? $matches[4] : null;
- return $this->findManyToManyRowset($class, $viaClass, $ruleKey1, $ruleKey2, $select);
- }
-
- /**
- * Recognize methods for Belongs-To cases:
- * find()
- * findBy()
- * Use the non-greedy pattern repeat modifier e.g. \w+?
- */
- if (preg_match('/^find(\w+?)(?:By(\w+))?$/', $method, $matches)) {
- $class = $matches[1];
- $ruleKey1 = isset($matches[2]) ? $matches[2] : null;
- return $this->findDependentRowset($class, $ruleKey1, $select);
- }
-
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception("Unrecognized method '$method()'");
- }
-
-
- /**
- * _getTableFromString
- *
- * @param string $tableName
- * @return Zend_Db_Table_Abstract
- */
- protected function _getTableFromString($tableName)
- {
-
- if ($this->_table instanceof Zend_Db_Table_Abstract) {
- $tableDefinition = $this->_table->getDefinition();
-
- if ($tableDefinition !== null && $tableDefinition->hasTableConfig($tableName)) {
- return new Zend_Db_Table($tableName, $tableDefinition);
- }
- }
-
- // assume the tableName is the class name
- if (!class_exists($tableName)) {
- try {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($tableName);
- } catch (Zend_Exception $e) {
- require_once 'Zend/Db/Table/Row/Exception.php';
- throw new Zend_Db_Table_Row_Exception($e->getMessage(), $e->getCode(), $e);
- }
- }
-
- $options = array();
-
- if (($table = $this->_getTable())) {
- $options['db'] = $table->getAdapter();
- }
-
- if (isset($tableDefinition) && $tableDefinition !== null) {
- $options[Zend_Db_Table_Abstract::DEFINITION] = $tableDefinition;
- }
-
- return new $tableName($options);
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Table/Row/Exception.php zendframework-2.2.6/library/Zend/Db/Table/Row/Exception.php
--- zendframework-1.10.4/library/Zend/Db/Table/Row/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Table/Row/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,38 +0,0 @@
-_table = $config['table'];
- $this->_tableClass = get_class($this->_table);
- }
- if (isset($config['rowClass'])) {
- $this->_rowClass = $config['rowClass'];
- }
- if (!class_exists($this->_rowClass)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($this->_rowClass);
- }
- if (isset($config['data'])) {
- $this->_data = $config['data'];
- }
- if (isset($config['readOnly'])) {
- $this->_readOnly = $config['readOnly'];
- }
- if (isset($config['stored'])) {
- $this->_stored = $config['stored'];
- }
-
- // set the count of rows
- $this->_count = count($this->_data);
-
- $this->init();
- }
-
- /**
- * Store data, class names, and state in serialized object
- *
- * @return array
- */
- public function __sleep()
- {
- return array('_data', '_tableClass', '_rowClass', '_pointer', '_count', '_rows', '_stored',
- '_readOnly');
- }
-
- /**
- * Setup to do on wakeup.
- * A de-serialized Rowset should not be assumed to have access to a live
- * database connection, so set _connected = false.
- *
- * @return void
- */
- public function __wakeup()
- {
- $this->_connected = false;
- }
-
- /**
- * Initialize object
- *
- * Called from {@link __construct()} as final step of object instantiation.
- *
- * @return void
- */
- public function init()
- {
- }
-
- /**
- * Return the connected state of the rowset.
- *
- * @return boolean
- */
- public function isConnected()
- {
- return $this->_connected;
- }
-
- /**
- * Returns the table object, or null if this is disconnected rowset
- *
- * @return Zend_Db_Table_Abstract
- */
- public function getTable()
- {
- return $this->_table;
- }
-
- /**
- * Set the table object, to re-establish a live connection
- * to the database for a Rowset that has been de-serialized.
- *
- * @param Zend_Db_Table_Abstract $table
- * @return boolean
- * @throws Zend_Db_Table_Row_Exception
- */
- public function setTable(Zend_Db_Table_Abstract $table)
- {
- $this->_table = $table;
- $this->_connected = false;
- // @todo This works only if we have iterated through
- // the result set once to instantiate the rows.
- foreach ($this as $row) {
- $connected = $row->setTable($table);
- if ($connected == true) {
- $this->_connected = true;
- }
- }
- return $this->_connected;
- }
-
- /**
- * Query the class name of the Table object for which this
- * Rowset was created.
- *
- * @return string
- */
- public function getTableClass()
- {
- return $this->_tableClass;
- }
-
- /**
- * Rewind the Iterator to the first element.
- * Similar to the reset() function for arrays in PHP.
- * Required by interface Iterator.
- *
- * @return Zend_Db_Table_Rowset_Abstract Fluent interface.
- */
- public function rewind()
- {
- $this->_pointer = 0;
- return $this;
- }
-
- /**
- * Return the current element.
- * Similar to the current() function for arrays in PHP
- * Required by interface Iterator.
- *
- * @return Zend_Db_Table_Row_Abstract current element from the collection
- */
- public function current()
- {
- if ($this->valid() === false) {
- return null;
- }
-
- // do we already have a row object for this position?
- if (empty($this->_rows[$this->_pointer])) {
- $this->_rows[$this->_pointer] = new $this->_rowClass(
- array(
- 'table' => $this->_table,
- 'data' => $this->_data[$this->_pointer],
- 'stored' => $this->_stored,
- 'readOnly' => $this->_readOnly
- )
- );
- }
-
- // return the row object
- return $this->_rows[$this->_pointer];
- }
-
- /**
- * Return the identifying key of the current element.
- * Similar to the key() function for arrays in PHP.
- * Required by interface Iterator.
- *
- * @return int
- */
- public function key()
- {
- return $this->_pointer;
- }
-
- /**
- * Move forward to next element.
- * Similar to the next() function for arrays in PHP.
- * Required by interface Iterator.
- *
- * @return void
- */
- public function next()
- {
- ++$this->_pointer;
- }
-
- /**
- * Check if there is a current element after calls to rewind() or next().
- * Used to check if we've iterated to the end of the collection.
- * Required by interface Iterator.
- *
- * @return bool False if there's nothing more to iterate over
- */
- public function valid()
- {
- return $this->_pointer < $this->_count;
- }
-
- /**
- * Returns the number of elements in the collection.
- *
- * Implements Countable::count()
- *
- * @return int
- */
- public function count()
- {
- return $this->_count;
- }
-
- /**
- * Take the Iterator to position $position
- * Required by interface SeekableIterator.
- *
- * @param int $position the position to seek to
- * @return Zend_Db_Table_Rowset_Abstract
- * @throws Zend_Db_Table_Rowset_Exception
- */
- public function seek($position)
- {
- $position = (int) $position;
- if ($position < 0 || $position >= $this->_count) {
- require_once 'Zend/Db/Table/Rowset/Exception.php';
- throw new Zend_Db_Table_Rowset_Exception("Illegal index $position");
- }
- $this->_pointer = $position;
- return $this;
- }
-
- /**
- * Check if an offset exists
- * Required by the ArrayAccess implementation
- *
- * @param string $offset
- * @return boolean
- */
- public function offsetExists($offset)
- {
- return isset($this->_data[(int) $offset]);
- }
-
- /**
- * Get the row for the given offset
- * Required by the ArrayAccess implementation
- *
- * @param string $offset
- * @return Zend_Db_Table_Row_Abstract
- */
- public function offsetGet($offset)
- {
- $this->_pointer = (int) $offset;
-
- return $this->current();
- }
-
- /**
- * Does nothing
- * Required by the ArrayAccess implementation
- *
- * @param string $offset
- * @param mixed $value
- */
- public function offsetSet($offset, $value)
- {
- }
-
- /**
- * Does nothing
- * Required by the ArrayAccess implementation
- *
- * @param string $offset
- */
- public function offsetUnset($offset)
- {
- }
-
- /**
- * Returns a Zend_Db_Table_Row from a known position into the Iterator
- *
- * @param int $position the position of the row expected
- * @param bool $seek wether or not seek the iterator to that position after
- * @return Zend_Db_Table_Row
- * @throws Zend_Db_Table_Rowset_Exception
- */
- public function getRow($position, $seek = false)
- {
- $key = $this->key();
- try {
- $this->seek($position);
- $row = $this->current();
- } catch (Zend_Db_Table_Rowset_Exception $e) {
- require_once 'Zend/Db/Table/Rowset/Exception.php';
- throw new Zend_Db_Table_Rowset_Exception('No row could be found at position ' . (int) $position, 0, $e);
- }
- if ($seek == false) {
- $this->seek($key);
- }
- return $row;
- }
-
- /**
- * Returns all data as an array.
- *
- * Updates the $_data property with current row object values.
- *
- * @return array
- */
- public function toArray()
- {
- // @todo This works only if we have iterated through
- // the result set once to instantiate the rows.
- foreach ($this->_rows as $i => $row) {
- $this->_data[$i] = $row->toArray();
- }
- return $this->_data;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Db/Table/Rowset/Exception.php zendframework-2.2.6/library/Zend/Db/Table/Rowset/Exception.php
--- zendframework-1.10.4/library/Zend/Db/Table/Rowset/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Table/Rowset/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,37 +0,0 @@
-getAdapter());
-
- $this->setTable($table);
- }
-
- /**
- * Return the table that created this select object
- *
- * @return Zend_Db_Table_Abstract
- */
- public function getTable()
- {
- return $this->_table;
- }
-
- /**
- * Sets the primary table name and retrieves the table schema.
- *
- * @param Zend_Db_Table_Abstract $adapter
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function setTable(Zend_Db_Table_Abstract $table)
- {
- $this->_adapter = $table->getAdapter();
- $this->_info = $table->info();
- $this->_table = $table;
-
- return $this;
- }
-
- /**
- * Sets the integrity check flag.
- *
- * Setting this flag to false skips the checks for table joins, allowing
- * 'hybrid' table rows to be created.
- *
- * @param Zend_Db_Table_Abstract $adapter
- * @return Zend_Db_Select This Zend_Db_Select object.
- */
- public function setIntegrityCheck($flag = true)
- {
- $this->_integrityCheck = $flag;
- return $this;
- }
-
- /**
- * Tests query to determine if expressions or aliases columns exist.
- *
- * @return boolean
- */
- public function isReadOnly()
- {
- $readOnly = false;
- $fields = $this->getPart(Zend_Db_Table_Select::COLUMNS);
- $cols = $this->_info[Zend_Db_Table_Abstract::COLS];
-
- if (!count($fields)) {
- return $readOnly;
- }
-
- foreach ($fields as $columnEntry) {
- $column = $columnEntry[1];
- $alias = $columnEntry[2];
-
- if ($alias !== null) {
- $column = $alias;
- }
-
- switch (true) {
- case ($column == self::SQL_WILDCARD):
- break;
-
- case ($column instanceof Zend_Db_Expr):
- case (!in_array($column, $cols)):
- $readOnly = true;
- break 2;
- }
- }
-
- return $readOnly;
- }
-
- /**
- * Adds a FROM table and optional columns to the query.
- *
- * The table name can be expressed
- *
- * @param array|string|Zend_Db_Expr|Zend_Db_Table_Abstract $name The table name or an
- associative array relating
- table name to correlation
- name.
- * @param array|string|Zend_Db_Expr $cols The columns to select from this table.
- * @param string $schema The schema name to specify, if any.
- * @return Zend_Db_Table_Select This Zend_Db_Table_Select object.
- */
- public function from($name, $cols = self::SQL_WILDCARD, $schema = null)
- {
- if ($name instanceof Zend_Db_Table_Abstract) {
- $info = $name->info();
- $name = $info[Zend_Db_Table_Abstract::NAME];
- if (isset($info[Zend_Db_Table_Abstract::SCHEMA])) {
- $schema = $info[Zend_Db_Table_Abstract::SCHEMA];
- }
- }
-
- return $this->joinInner($name, null, $cols, $schema);
- }
-
- /**
- * Performs a validation on the select query before passing back to the parent class.
- * Ensures that only columns from the primary Zend_Db_Table are returned in the result.
- *
- * @return string|null This object as a SELECT string (or null if a string cannot be produced)
- */
- public function assemble()
- {
- $fields = $this->getPart(Zend_Db_Table_Select::COLUMNS);
- $primary = $this->_info[Zend_Db_Table_Abstract::NAME];
- $schema = $this->_info[Zend_Db_Table_Abstract::SCHEMA];
-
-
- if (count($this->_parts[self::UNION]) == 0) {
-
- // If no fields are specified we assume all fields from primary table
- if (!count($fields)) {
- $this->from($primary, self::SQL_WILDCARD, $schema);
- $fields = $this->getPart(Zend_Db_Table_Select::COLUMNS);
- }
-
- $from = $this->getPart(Zend_Db_Table_Select::FROM);
-
- if ($this->_integrityCheck !== false) {
- foreach ($fields as $columnEntry) {
- list($table, $column) = $columnEntry;
-
- // Check each column to ensure it only references the primary table
- if ($column) {
- if (!isset($from[$table]) || $from[$table]['tableName'] != $primary) {
- require_once 'Zend/Db/Table/Select/Exception.php';
- throw new Zend_Db_Table_Select_Exception('Select query cannot join with another table');
- }
- }
- }
- }
- }
-
- return parent::assemble();
- }
-}
\ No newline at end of file
diff -Nru zendframework-1.10.4/library/Zend/Db/TableGateway/AbstractTableGateway.php zendframework-2.2.6/library/Zend/Db/TableGateway/AbstractTableGateway.php
--- zendframework-1.10.4/library/Zend/Db/TableGateway/AbstractTableGateway.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/TableGateway/AbstractTableGateway.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,488 @@
+isInitialized;
+ }
+
+ /**
+ * Initialize
+ *
+ * @throws Exception\RuntimeException
+ * @return null
+ */
+ public function initialize()
+ {
+ if ($this->isInitialized) {
+ return;
+ }
+
+ if (!$this->featureSet instanceof Feature\FeatureSet) {
+ $this->featureSet = new Feature\FeatureSet;
+ }
+
+ $this->featureSet->setTableGateway($this);
+ $this->featureSet->apply('preInitialize', array());
+
+ if (!$this->adapter instanceof AdapterInterface) {
+ throw new Exception\RuntimeException('This table does not have an Adapter setup');
+ }
+
+ if (!is_string($this->table) && !$this->table instanceof TableIdentifier) {
+ throw new Exception\RuntimeException('This table object does not have a valid table set.');
+ }
+
+ if (!$this->resultSetPrototype instanceof ResultSetInterface) {
+ $this->resultSetPrototype = new ResultSet;
+ }
+
+ if (!$this->sql instanceof Sql) {
+ $this->sql = new Sql($this->adapter, $this->table);
+ }
+
+ $this->featureSet->apply('postInitialize', array());
+
+ $this->isInitialized = true;
+ }
+
+ /**
+ * Get table name
+ *
+ * @return string
+ */
+ public function getTable()
+ {
+ return $this->table;
+ }
+
+ /**
+ * Get adapter
+ *
+ * @return AdapterInterface
+ */
+ public function getAdapter()
+ {
+ return $this->adapter;
+ }
+
+ /**
+ * @return array
+ */
+ public function getColumns()
+ {
+ return $this->columns;
+ }
+
+ /**
+ * @return Feature\FeatureSet
+ */
+ public function getFeatureSet()
+ {
+ return $this->featureSet;
+ }
+
+ /**
+ * Get select result prototype
+ *
+ * @return ResultSet
+ */
+ public function getResultSetPrototype()
+ {
+ return $this->resultSetPrototype;
+ }
+
+ /**
+ * @return Sql
+ */
+ public function getSql()
+ {
+ return $this->sql;
+ }
+
+ /**
+ * Select
+ *
+ * @param Where|\Closure|string|array $where
+ * @return ResultSet
+ */
+ public function select($where = null)
+ {
+ if (!$this->isInitialized) {
+ $this->initialize();
+ }
+
+ $select = $this->sql->select();
+
+ if ($where instanceof \Closure) {
+ $where($select);
+ } elseif ($where !== null) {
+ $select->where($where);
+ }
+
+ return $this->selectWith($select);
+ }
+
+ /**
+ * @param Select $select
+ * @return null|ResultSetInterface
+ * @throws \RuntimeException
+ */
+ public function selectWith(Select $select)
+ {
+ if (!$this->isInitialized) {
+ $this->initialize();
+ }
+ return $this->executeSelect($select);
+ }
+
+ /**
+ * @param Select $select
+ * @return ResultSet
+ * @throws Exception\RuntimeException
+ */
+ protected function executeSelect(Select $select)
+ {
+ $selectState = $select->getRawState();
+ if ($selectState['table'] != $this->table) {
+ throw new Exception\RuntimeException('The table name of the provided select object must match that of the table');
+ }
+
+ if ($selectState['columns'] == array(Select::SQL_STAR)
+ && $this->columns !== array()) {
+ $select->columns($this->columns);
+ }
+
+ // apply preSelect features
+ $this->featureSet->apply('preSelect', array($select));
+
+ // prepare and execute
+ $statement = $this->sql->prepareStatementForSqlObject($select);
+ $result = $statement->execute();
+
+ // build result set
+ $resultSet = clone $this->resultSetPrototype;
+ $resultSet->initialize($result);
+
+ // apply postSelect features
+ $this->featureSet->apply('postSelect', array($statement, $result, $resultSet));
+
+ return $resultSet;
+ }
+
+ /**
+ * Insert
+ *
+ * @param array $set
+ * @return int
+ */
+ public function insert($set)
+ {
+ if (!$this->isInitialized) {
+ $this->initialize();
+ }
+ $insert = $this->sql->insert();
+ $insert->values($set);
+ return $this->executeInsert($insert);
+ }
+
+ /**
+ * @param Insert $insert
+ * @return mixed
+ */
+ public function insertWith(Insert $insert)
+ {
+ if (!$this->isInitialized) {
+ $this->initialize();
+ }
+ return $this->executeInsert($insert);
+ }
+
+ /**
+ * @todo add $columns support
+ *
+ * @param Insert $insert
+ * @return mixed
+ * @throws Exception\RuntimeException
+ */
+ protected function executeInsert(Insert $insert)
+ {
+ $insertState = $insert->getRawState();
+ if ($insertState['table'] != $this->table) {
+ throw new Exception\RuntimeException('The table name of the provided Insert object must match that of the table');
+ }
+
+ // apply preInsert features
+ $this->featureSet->apply('preInsert', array($insert));
+
+ $statement = $this->sql->prepareStatementForSqlObject($insert);
+ $result = $statement->execute();
+ $this->lastInsertValue = $this->adapter->getDriver()->getConnection()->getLastGeneratedValue();
+
+ // apply postInsert features
+ $this->featureSet->apply('postInsert', array($statement, $result));
+
+ return $result->getAffectedRows();
+ }
+
+ /**
+ * Update
+ *
+ * @param array $set
+ * @param string|array|closure $where
+ * @return int
+ */
+ public function update($set, $where = null)
+ {
+ if (!$this->isInitialized) {
+ $this->initialize();
+ }
+ $sql = $this->sql;
+ $update = $sql->update();
+ $update->set($set);
+ if ($where !== null) {
+ $update->where($where);
+ }
+ return $this->executeUpdate($update);
+ }
+
+ /**
+ * @param \Zend\Db\Sql\Update $update
+ * @return mixed
+ */
+ public function updateWith(Update $update)
+ {
+ if (!$this->isInitialized) {
+ $this->initialize();
+ }
+ return $this->executeUpdate($update);
+ }
+
+ /**
+ * @todo add $columns support
+ *
+ * @param Update $update
+ * @return mixed
+ * @throws Exception\RuntimeException
+ */
+ protected function executeUpdate(Update $update)
+ {
+ $updateState = $update->getRawState();
+ if ($updateState['table'] != $this->table) {
+ throw new Exception\RuntimeException('The table name of the provided Update object must match that of the table');
+ }
+
+ // apply preUpdate features
+ $this->featureSet->apply('preUpdate', array($update));
+
+ $statement = $this->sql->prepareStatementForSqlObject($update);
+ $result = $statement->execute();
+
+ // apply postUpdate features
+ $this->featureSet->apply('postUpdate', array($statement, $result));
+
+ return $result->getAffectedRows();
+ }
+
+ /**
+ * Delete
+ *
+ * @param Where|\Closure|string|array $where
+ * @return int
+ */
+ public function delete($where)
+ {
+ if (!$this->isInitialized) {
+ $this->initialize();
+ }
+ $delete = $this->sql->delete();
+ if ($where instanceof \Closure) {
+ $where($delete);
+ } else {
+ $delete->where($where);
+ }
+ return $this->executeDelete($delete);
+ }
+
+ /**
+ * @param Delete $delete
+ * @return mixed
+ */
+ public function deleteWith(Delete $delete)
+ {
+ $this->initialize();
+ return $this->executeDelete($delete);
+ }
+
+ /**
+ * @todo add $columns support
+ *
+ * @param Delete $delete
+ * @return mixed
+ * @throws Exception\RuntimeException
+ */
+ protected function executeDelete(Delete $delete)
+ {
+ $deleteState = $delete->getRawState();
+ if ($deleteState['table'] != $this->table) {
+ throw new Exception\RuntimeException('The table name of the provided Update object must match that of the table');
+ }
+
+ // pre delete update
+ $this->featureSet->apply('preDelete', array($delete));
+
+ $statement = $this->sql->prepareStatementForSqlObject($delete);
+ $result = $statement->execute();
+
+ // apply postDelete features
+ $this->featureSet->apply('postDelete', array($statement, $result));
+
+ return $result->getAffectedRows();
+ }
+
+ /**
+ * Get last insert value
+ *
+ * @return int
+ */
+ public function getLastInsertValue()
+ {
+ return $this->lastInsertValue;
+ }
+
+ /**
+ * __get
+ *
+ * @param string $property
+ * @throws Exception\InvalidArgumentException
+ * @return mixed
+ */
+ public function __get($property)
+ {
+ switch (strtolower($property)) {
+ case 'lastinsertvalue':
+ return $this->lastInsertValue;
+ case 'adapter':
+ return $this->adapter;
+ case 'table':
+ return $this->table;
+ }
+ if ($this->featureSet->canCallMagicGet($property)) {
+ return $this->featureSet->callMagicGet($property);
+ }
+ throw new Exception\InvalidArgumentException('Invalid magic property access in ' . __CLASS__ . '::__get()');
+ }
+
+ /**
+ * @param string $property
+ * @param mixed $value
+ * @return mixed
+ * @throws Exception\InvalidArgumentException
+ */
+ public function __set($property, $value)
+ {
+ if ($this->featureSet->canCallMagicSet($property)) {
+ return $this->featureSet->callMagicSet($property, $value);
+ }
+ throw new Exception\InvalidArgumentException('Invalid magic property access in ' . __CLASS__ . '::__set()');
+ }
+
+ /**
+ * @param $method
+ * @param $arguments
+ * @return mixed
+ * @throws Exception\InvalidArgumentException
+ */
+ public function __call($method, $arguments)
+ {
+ if ($this->featureSet->canCallMagicCall($method)) {
+ return $this->featureSet->callMagicCall($method, $arguments);
+ }
+ throw new Exception\InvalidArgumentException('Invalid method (' . $method . ') called, caught by ' . __CLASS__ . '::__call()');
+ }
+
+ /**
+ * __clone
+ */
+ public function __clone()
+ {
+ $this->resultSetPrototype = (isset($this->resultSetPrototype)) ? clone $this->resultSetPrototype : null;
+ $this->sql = clone $this->sql;
+ if (is_object($this->table)) {
+ $this->table = clone $this->table;
+ }
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/TableGateway/Exception/ExceptionInterface.php zendframework-2.2.6/library/Zend/Db/TableGateway/Exception/ExceptionInterface.php
--- zendframework-1.10.4/library/Zend/Db/TableGateway/Exception/ExceptionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/TableGateway/Exception/ExceptionInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,16 @@
+tableGateway = $tableGateway;
+ }
+
+ public function initialize()
+ {
+ throw new Exception\RuntimeException('This method is not intended to be called on this object.');
+ }
+
+ public function getMagicMethodSpecifications()
+ {
+ return array();
+ }
+
+
+ /*
+ public function preInitialize();
+ public function postInitialize();
+ public function preSelect(Select $select);
+ public function postSelect(StatementInterface $statement, ResultInterface $result, ResultSetInterface $resultSet);
+ public function preInsert(Insert $insert);
+ public function postInsert(StatementInterface $statement, ResultInterface $result);
+ public function preUpdate(Update $update);
+ public function postUpdate(StatementInterface $statement, ResultInterface $result);
+ public function preDelete(Delete $delete);
+ public function postDelete(StatementInterface $statement, ResultInterface $result);
+ */
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/EventFeature/TableGatewayEvent.php zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/EventFeature/TableGatewayEvent.php
--- zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/EventFeature/TableGatewayEvent.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/EventFeature/TableGatewayEvent.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,140 @@
+name;
+ }
+
+ /**
+ * Get target/context from which event was triggered
+ *
+ * @return null|string|object
+ */
+ public function getTarget()
+ {
+ return $this->target;
+ }
+
+ /**
+ * Get parameters passed to the event
+ *
+ * @return array|\ArrayAccess
+ */
+ public function getParams()
+ {
+ return $this->params;
+ }
+
+ /**
+ * Get a single parameter by name
+ *
+ * @param string $name
+ * @param mixed $default Default value to return if parameter does not exist
+ * @return mixed
+ */
+ public function getParam($name, $default = null)
+ {
+ return (isset($this->params[$name]) ? $this->params[$name] : $default);
+ }
+
+ /**
+ * Set the event name
+ *
+ * @param string $name
+ * @return void
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * Set the event target/context
+ *
+ * @param null|string|object $target
+ * @return void
+ */
+ public function setTarget($target)
+ {
+ $this->target = $target;
+ }
+
+ /**
+ * Set event parameters
+ *
+ * @param string $params
+ * @return void
+ */
+ public function setParams($params)
+ {
+ $this->params = $params;
+ }
+
+ /**
+ * Set a single parameter by key
+ *
+ * @param string $name
+ * @param mixed $value
+ * @return void
+ */
+ public function setParam($name, $value)
+ {
+ $this->params[$name] = $value;
+ }
+
+ /**
+ * Indicate whether or not the parent EventManagerInterface should stop propagating events
+ *
+ * @param bool $flag
+ * @return void
+ */
+ public function stopPropagation($flag = true)
+ {
+ return;
+ }
+
+ /**
+ * Has this event indicated event propagation should stop?
+ *
+ * @return bool
+ */
+ public function propagationIsStopped()
+ {
+ return false;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/EventFeature.php zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/EventFeature.php
--- zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/EventFeature.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/EventFeature.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,255 @@
+eventManager = ($eventManager instanceof EventManagerInterface)
+ ? $eventManager
+ : new EventManager;
+
+ $this->eventManager->addIdentifiers(array(
+ 'Zend\Db\TableGateway\TableGateway',
+ ));
+
+ $this->event = ($tableGatewayEvent) ?: new EventFeature\TableGatewayEvent();
+ }
+
+ /**
+ * Retrieve composed event manager instance
+ *
+ * @return EventManagerInterface
+ */
+ public function getEventManager()
+ {
+ return $this->eventManager;
+ }
+
+ /**
+ * Retrieve composed event instance
+ *
+ * @return EventFeature\TableGatewayEvent
+ */
+ public function getEvent()
+ {
+ return $this->event;
+ }
+
+ /**
+ * Initialize feature and trigger "preInitialize" event
+ *
+ * Ensures that the composed TableGateway has identifiers based on the
+ * class name, and that the event target is set to the TableGateway
+ * instance. It then triggers the "preInitialize" event.
+ *
+ * @return void
+ */
+ public function preInitialize()
+ {
+ if (get_class($this->tableGateway) != 'Zend\Db\TableGateway\TableGateway') {
+ $this->eventManager->addIdentifiers(get_class($this->tableGateway));
+ }
+
+ $this->event->setTarget($this->tableGateway);
+ $this->event->setName(__FUNCTION__);
+ $this->eventManager->trigger($this->event);
+ }
+
+ /**
+ * Trigger the "postInitialize" event
+ *
+ * @return void
+ */
+ public function postInitialize()
+ {
+ $this->event->setName(__FUNCTION__);
+ $this->eventManager->trigger($this->event);
+ }
+
+ /**
+ * Trigger the "preSelect" event
+ *
+ * Triggers the "preSelect" event mapping the following parameters:
+ * - $select as "select"
+ *
+ * @param Select $select
+ * @return void
+ */
+ public function preSelect(Select $select)
+ {
+ $this->event->setName(__FUNCTION__);
+ $this->event->setParams(array('select' => $select));
+ $this->eventManager->trigger($this->event);
+ }
+
+ /**
+ * Trigger the "postSelect" event
+ *
+ * Triggers the "postSelect" event mapping the following parameters:
+ * - $statement as "statement"
+ * - $result as "result"
+ * - $resultSet as "result_set"
+ *
+ * @param StatementInterface $statement
+ * @param ResultInterface $result
+ * @param ResultSetInterface $resultSet
+ * @return void
+ */
+ public function postSelect(StatementInterface $statement, ResultInterface $result, ResultSetInterface $resultSet)
+ {
+ $this->event->setName(__FUNCTION__);
+ $this->event->setParams(array(
+ 'statement' => $statement,
+ 'result' => $result,
+ 'result_set' => $resultSet
+ ));
+ $this->eventManager->trigger($this->event);
+ }
+
+ /**
+ * Trigger the "preInsert" event
+ *
+ * Triggers the "preInsert" event mapping the following parameters:
+ * - $insert as "insert"
+ *
+ * @param Insert $insert
+ * @return void
+ */
+ public function preInsert(Insert $insert)
+ {
+ $this->event->setName(__FUNCTION__);
+ $this->event->setParams(array('insert' => $insert));
+ $this->eventManager->trigger($this->event);
+ }
+
+ /**
+ * Trigger the "postInsert" event
+ *
+ * Triggers the "postInsert" event mapping the following parameters:
+ * - $statement as "statement"
+ * - $result as "result"
+ *
+ * @param StatementInterface $statement
+ * @param ResultInterface $result
+ * @return void
+ */
+ public function postInsert(StatementInterface $statement, ResultInterface $result)
+ {
+ $this->event->setName(__FUNCTION__);
+ $this->event->setParams(array(
+ 'statement' => $statement,
+ 'result' => $result,
+ ));
+ $this->eventManager->trigger($this->event);
+ }
+
+ /**
+ * Trigger the "preUpdate" event
+ *
+ * Triggers the "preUpdate" event mapping the following parameters:
+ * - $update as "update"
+ *
+ * @param Update $update
+ * @return void
+ */
+ public function preUpdate(Update $update)
+ {
+ $this->event->setName(__FUNCTION__);
+ $this->event->setParams(array('update' => $update));
+ $this->eventManager->trigger($this->event);
+ }
+
+ /**
+ * Trigger the "postUpdate" event
+ *
+ * Triggers the "postUpdate" event mapping the following parameters:
+ * - $statement as "statement"
+ * - $result as "result"
+ *
+ * @param StatementInterface $statement
+ * @param ResultInterface $result
+ * @return void
+ */
+ public function postUpdate(StatementInterface $statement, ResultInterface $result)
+ {
+ $this->event->setName(__FUNCTION__);
+ $this->event->setParams(array(
+ 'statement' => $statement,
+ 'result' => $result,
+ ));
+ $this->eventManager->trigger($this->event);
+ }
+
+ /**
+ * Trigger the "preDelete" event
+ *
+ * Triggers the "preDelete" event mapping the following parameters:
+ * - $delete as "delete"
+ *
+ * @param Delete $delete
+ * @return void
+ */
+ public function preDelete(Delete $delete)
+ {
+ $this->event->setName(__FUNCTION__);
+ $this->event->setParams(array('delete' => $delete));
+ $this->eventManager->trigger($this->event);
+ }
+
+ /**
+ * Trigger the "postDelete" event
+ *
+ * Triggers the "postDelete" event mapping the following parameters:
+ * - $statement as "statement"
+ * - $result as "result"
+ *
+ * @param StatementInterface $statement
+ * @param ResultInterface $result
+ * @return void
+ */
+ public function postDelete(StatementInterface $statement, ResultInterface $result)
+ {
+ $this->event->setName(__FUNCTION__);
+ $this->event->setParams(array(
+ 'statement' => $statement,
+ 'result' => $result,
+ ));
+ $this->eventManager->trigger($this->event);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/FeatureSet.php zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/FeatureSet.php
--- zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/FeatureSet.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/FeatureSet.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,146 @@
+addFeatures($features);
+ }
+ }
+
+ public function setTableGateway(AbstractTableGateway $tableGateway)
+ {
+ $this->tableGateway = $tableGateway;
+ foreach ($this->features as $feature) {
+ $feature->setTableGateway($this->tableGateway);
+ }
+ return $this;
+ }
+
+ public function getFeatureByClassName($featureClassName)
+ {
+ $feature = false;
+ foreach ($this->features as $potentialFeature) {
+ if ($potentialFeature instanceof $featureClassName) {
+ $feature = $potentialFeature;
+ break;
+ }
+ }
+ return $feature;
+ }
+
+ public function addFeatures(array $features)
+ {
+ foreach ($features as $feature) {
+ $this->addFeature($feature);
+ }
+ return $this;
+ }
+
+ public function addFeature(AbstractFeature $feature)
+ {
+ if ($this->tableGateway instanceof TableGatewayInterface) {
+ $feature->setTableGateway($this->tableGateway);
+ }
+ $this->features[] = $feature;
+ return $this;
+ }
+
+ public function apply($method, $args)
+ {
+ foreach ($this->features as $feature) {
+ if (method_exists($feature, $method)) {
+ $return = call_user_func_array(array($feature, $method), $args);
+ if ($return === self::APPLY_HALT) {
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * @param string $property
+ * @return bool
+ */
+ public function canCallMagicGet($property)
+ {
+ return false;
+ }
+
+ /**
+ * @param string $property
+ * @return mixed
+ */
+ public function callMagicGet($property)
+ {
+ $return = null;
+ return $return;
+ }
+
+ /**
+ * @param string $property
+ * @return bool
+ */
+ public function canCallMagicSet($property)
+ {
+ return false;
+ }
+
+ /**
+ * @param $property
+ * @param $value
+ * @return mixed
+ */
+ public function callMagicSet($property, $value)
+ {
+ $return = null;
+ return $return;
+ }
+
+ /**
+ * @param string $method
+ * @return bool
+ */
+ public function canCallMagicCall($method)
+ {
+ return false;
+ }
+
+ /**
+ * @param string $method
+ * @param array $arguments
+ * @return mixed
+ */
+ public function callMagicCall($method, $arguments)
+ {
+ $return = null;
+ return $return;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/GlobalAdapterFeature.php zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/GlobalAdapterFeature.php
--- zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/GlobalAdapterFeature.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/GlobalAdapterFeature.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,70 @@
+tableGateway->adapter = self::getStaticAdapter();
+ }
+
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/MasterSlaveFeature.php zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/MasterSlaveFeature.php
--- zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/MasterSlaveFeature.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/MasterSlaveFeature.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,93 @@
+slaveAdapter = $slaveAdapter;
+ if ($slaveSql) {
+ $this->slaveSql = $slaveSql;
+ }
+ }
+
+ public function getSlaveAdapter()
+ {
+ return $this->slaveAdapter;
+ }
+
+ /**
+ * @return Sql
+ */
+ public function getSlaveSql()
+ {
+ return $this->slaveSql;
+ }
+
+ /**
+ * after initialization, retrieve the original adapter as "master"
+ */
+ public function postInitialize()
+ {
+ $this->masterSql = $this->tableGateway->sql;
+ if ($this->slaveSql == null) {
+ $this->slaveSql = new Sql(
+ $this->slaveAdapter,
+ $this->tableGateway->sql->getTable(),
+ $this->tableGateway->sql->getSqlPlatform()
+ );
+ }
+ }
+
+ /**
+ * preSelect()
+ * Replace adapter with slave temporarily
+ */
+ public function preSelect()
+ {
+ $this->tableGateway->sql = $this->slaveSql;
+ }
+
+ /**
+ * postSelect()
+ * Ensure to return to the master adapter
+ */
+ public function postSelect()
+ {
+ $this->tableGateway->sql = $this->masterSql;
+ }
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/MetadataFeature.php zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/MetadataFeature.php
--- zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/MetadataFeature.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/MetadataFeature.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,88 @@
+metadata = $metadata;
+ }
+ $this->sharedData['metadata'] = array(
+ 'primaryKey' => null,
+ 'columns' => array()
+ );
+ }
+
+ public function postInitialize()
+ {
+ if ($this->metadata == null) {
+ $this->metadata = new Metadata($this->tableGateway->adapter);
+ }
+
+ // localize variable for brevity
+ $t = $this->tableGateway;
+ $m = $this->metadata;
+
+ // get column named
+ $columns = $m->getColumnNames($t->table);
+ $t->columns = $columns;
+
+ // set locally
+ $this->sharedData['metadata']['columns'] = $columns;
+
+ // process primary key only if table is a table; there are no PK constraints on views
+ if (!($m->getTable($t->table) instanceof TableObject)) {
+ return;
+ }
+
+ $pkc = null;
+
+ foreach ($m->getConstraints($t->table) as $constraint) {
+ /** @var $constraint \Zend\Db\Metadata\Object\ConstraintObject */
+ if ($constraint->getType() == 'PRIMARY KEY') {
+ $pkc = $constraint;
+ break;
+ }
+ }
+
+ if ($pkc === null) {
+ throw new Exception\RuntimeException('A primary key for this column could not be found in the metadata.');
+ }
+
+ if (count($pkc->getColumns()) == 1) {
+ $pkck = $pkc->getColumns();
+ $primaryKey = $pkck[0];
+ } else {
+ $primaryKey = $pkc->getColumns();
+ }
+
+ $this->sharedData['metadata']['primaryKey'] = $primaryKey;
+ }
+
+
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/RowGatewayFeature.php zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/RowGatewayFeature.php
--- zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/RowGatewayFeature.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/RowGatewayFeature.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,68 @@
+constructorArguments = func_get_args();
+ }
+
+ public function postInitialize()
+ {
+ $args = $this->constructorArguments;
+
+ /** @var $resultSetPrototype ResultSet */
+ $resultSetPrototype = $this->tableGateway->resultSetPrototype;
+
+ if (!$this->tableGateway->resultSetPrototype instanceof ResultSet) {
+ throw new Exception\RuntimeException(
+ 'This feature ' . __CLASS__ . ' expects the ResultSet to be an instance of Zend\Db\ResultSet\ResultSet'
+ );
+ }
+
+ if (isset($args[0])) {
+ if (is_string($args[0])) {
+ $primaryKey = $args[0];
+ $rowGatewayPrototype = new RowGateway($primaryKey, $this->tableGateway->table, $this->tableGateway->adapter, $this->tableGateway->sql);
+ $resultSetPrototype->setArrayObjectPrototype($rowGatewayPrototype);
+ } elseif ($args[0] instanceof RowGatewayInterface) {
+ $rowGatewayPrototype = $args[0];
+ $resultSetPrototype->setArrayObjectPrototype($rowGatewayPrototype);
+ }
+ } else {
+ // get from metadata feature
+ $metadata = $this->tableGateway->featureSet->getFeatureByClassName('Zend\Db\TableGateway\Feature\MetadataFeature');
+ if ($metadata === false || !isset($metadata->sharedData['metadata'])) {
+ throw new Exception\RuntimeException(
+ 'No information was provided to the RowGatewayFeature and/or no MetadataFeature could be consulted to find the primary key necessary for RowGateway object creation.'
+ );
+ }
+ $primaryKey = $metadata->sharedData['metadata']['primaryKey'];
+ $rowGatewayPrototype = new RowGateway($primaryKey, $this->tableGateway->table, $this->tableGateway->adapter, $this->tableGateway->sql);
+ $resultSetPrototype->setArrayObjectPrototype($rowGatewayPrototype);
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/SequenceFeature.php zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/SequenceFeature.php
--- zendframework-1.10.4/library/Zend/Db/TableGateway/Feature/SequenceFeature.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/TableGateway/Feature/SequenceFeature.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,128 @@
+primaryKeyField = $primaryKeyField;
+ $this->sequenceName = $sequenceName;
+ }
+
+ /**
+ * @param Insert $insert
+ */
+ public function preInsert(Insert $insert)
+ {
+ $columns = $insert->getRawState('columns');
+ $values = $insert->getRawState('values');
+ $key = array_search($this->primaryKeyField, $columns);
+ if ($key !== false) {
+ $this->sequenceValue = $values[$key];
+ return $insert;
+ }
+
+ $this->sequenceValue = $this->nextSequenceId();
+ if ($this->sequenceValue === null) {
+ return $insert;
+ }
+
+ $insert->values(array($this->primaryKeyField => $this->sequenceValue), Insert::VALUES_MERGE);
+ return $insert;
+ }
+
+ public function postInsert(StatementInterface $statement, ResultInterface $result)
+ {
+ if ($this->sequenceValue !== null) {
+ $this->tableGateway->lastInsertValue = $this->sequenceValue;
+ }
+ }
+
+ /**
+ * Generate a new value from the specified sequence in the database, and return it.
+ * @return int
+ */
+ public function nextSequenceId()
+ {
+ $platform = $this->tableGateway->adapter->getPlatform();
+ $platformName = $platform->getName();
+
+ switch ($platformName) {
+ case 'Oracle':
+ $sql = 'SELECT ' . $platform->quoteIdentifier($this->sequenceName) . '.NEXTVAL FROM dual';
+ break;
+ case 'PostgreSQL':
+ $sql = 'SELECT NEXTVAL(\'' . $this->sequenceName . '\')';
+ break;
+ default :
+ return null;
+ }
+
+ $statement = $this->tableGateway->adapter->createStatement();
+ $statement->prepare($sql);
+ $result = $statement->execute();
+ $sequence = $result->current();
+ unset($statement, $result);
+ return $sequence['nextval'];
+ }
+
+ /**
+ * Return the most recent value from the specified sequence in the database.
+ * @return int
+ */
+ public function lastSequenceId()
+ {
+ $platform = $this->tableGateway->adapter->getPlatform();
+ $platformName = $platform->getName();
+
+ switch ($platformName) {
+ case 'Oracle':
+ $sql = 'SELECT ' . $platform->quoteIdentifier($this->sequenceName) . '.CURRVAL FROM dual';
+ break;
+ case 'PostgreSQL':
+ $sql = 'SELECT CURRVAL(\'' . $this->sequenceName . '\')';
+ break;
+ default :
+ return null;
+ }
+
+ $statement = $this->tableGateway->adapter->createStatement();
+ $statement->prepare($sql);
+ $result = $statement->execute();
+ $sequence = $result->current();
+ unset($statement, $result);
+ return $sequence['currval'];
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/TableGateway/TableGatewayInterface.php zendframework-2.2.6/library/Zend/Db/TableGateway/TableGatewayInterface.php
--- zendframework-1.10.4/library/Zend/Db/TableGateway/TableGatewayInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/TableGateway/TableGatewayInterface.php 2014-03-07 00:22:08.000000000 +0000
@@ -0,0 +1,19 @@
+table = $table;
+
+ // adapter
+ $this->adapter = $adapter;
+
+ // process features
+ if ($features !== null) {
+ if ($features instanceof Feature\AbstractFeature) {
+ $features = array($features);
+ }
+ if (is_array($features)) {
+ $this->featureSet = new Feature\FeatureSet($features);
+ } elseif ($features instanceof Feature\FeatureSet) {
+ $this->featureSet = $features;
+ } else {
+ throw new Exception\InvalidArgumentException(
+ 'TableGateway expects $feature to be an instance of an AbstractFeature or a FeatureSet, or an array of AbstractFeatures'
+ );
+ }
+ } else {
+ $this->featureSet = new Feature\FeatureSet();
+ }
+
+ // result prototype
+ $this->resultSetPrototype = ($resultSetPrototype) ?: new ResultSet;
+
+ // Sql object (factory for select, insert, update, delete)
+ $this->sql = ($sql) ?: new Sql($this->adapter, $this->table);
+
+ // check sql object bound to same table
+ if ($this->sql->getTable() != $this->table) {
+ throw new Exception\InvalidArgumentException('The table inside the provided Sql object must match the table of this TableGateway');
+ }
+
+ $this->initialize();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Db/Table.php zendframework-2.2.6/library/Zend/Db/Table.php
--- zendframework-1.10.4/library/Zend/Db/Table.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db/Table.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,79 +0,0 @@
- $config);
- } else {
- // process this as table with or without a definition
- if ($definition instanceof Zend_Db_Table_Definition
- && $definition->hasTableConfig($config)) {
- // this will have DEFINITION_CONFIG_NAME & DEFINITION
- $config = $definition->getTableConfig($config);
- } else {
- $config = array(self::NAME => $config);
- }
- }
- }
-
- parent::__construct($config);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Db.php zendframework-2.2.6/library/Zend/Db.php
--- zendframework-1.10.4/library/Zend/Db.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Db.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,281 +0,0 @@
-toArray();
- }
-
- /*
- * Convert Zend_Config argument to plain string
- * adapter name and separate config object.
- */
- if ($adapter instanceof Zend_Config) {
- if (isset($adapter->params)) {
- $config = $adapter->params->toArray();
- }
- if (isset($adapter->adapter)) {
- $adapter = (string) $adapter->adapter;
- } else {
- $adapter = null;
- }
- }
-
- /*
- * Verify that adapter parameters are in an array.
- */
- if (!is_array($config)) {
- /**
- * @see Zend_Db_Exception
- */
- require_once 'Zend/Db/Exception.php';
- throw new Zend_Db_Exception('Adapter parameters must be in an array or a Zend_Config object');
- }
-
- /*
- * Verify that an adapter name has been specified.
- */
- if (!is_string($adapter) || empty($adapter)) {
- /**
- * @see Zend_Db_Exception
- */
- require_once 'Zend/Db/Exception.php';
- throw new Zend_Db_Exception('Adapter name must be specified in a string');
- }
-
- /*
- * Form full adapter class name
- */
- $adapterNamespace = 'Zend_Db_Adapter';
- if (isset($config['adapterNamespace'])) {
- if ($config['adapterNamespace'] != '') {
- $adapterNamespace = $config['adapterNamespace'];
- }
- unset($config['adapterNamespace']);
- }
-
- // Adapter no longer normalized- see http://framework.zend.com/issues/browse/ZF-5606
- $adapterName = $adapterNamespace . '_';
- $adapterName .= str_replace(' ', '_', ucwords(str_replace('_', ' ', strtolower($adapter))));
-
- /*
- * Load the adapter class. This throws an exception
- * if the specified class cannot be loaded.
- */
- if (!class_exists($adapterName)) {
- require_once 'Zend/Loader.php';
- Zend_Loader::loadClass($adapterName);
- }
-
- /*
- * Create an instance of the adapter class.
- * Pass the config to the adapter class constructor.
- */
- $dbAdapter = new $adapterName($config);
-
- /*
- * Verify that the object created is a descendent of the abstract adapter type.
- */
- if (! $dbAdapter instanceof Zend_Db_Adapter_Abstract) {
- /**
- * @see Zend_Db_Exception
- */
- require_once 'Zend/Db/Exception.php';
- throw new Zend_Db_Exception("Adapter class '$adapterName' does not extend Zend_Db_Adapter_Abstract");
- }
-
- return $dbAdapter;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Debug/composer.json zendframework-2.2.6/library/Zend/Debug/composer.json
--- zendframework-1.10.4/library/Zend/Debug/composer.json 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Debug/composer.json 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,31 @@
+{
+ "name": "zendframework/zend-debug",
+ "description": " ",
+ "license": "BSD-3-Clause",
+ "keywords": [
+ "zf2",
+ "debug"
+ ],
+ "autoload": {
+ "psr-0": {
+ "Zend\\Debug\\": ""
+ }
+ },
+ "target-dir": "Zend/Debug",
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "zendframework/zend-escaper": "*"
+ },
+ "suggest": {
+ "ext/xdebug": "XDebug, for better backtrace output",
+ "zendframework/zend-escaper": "To support escaped output"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev",
+ "dev-develop": "2.3-dev"
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Debug/Debug.php zendframework-2.2.6/library/Zend/Debug/Debug.php
--- zendframework-1.10.4/library/Zend/Debug/Debug.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Debug/Debug.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,124 @@
+ tags, cleans up newlines and indents, and runs
+ * htmlentities() before output.
+ *
+ * @param mixed $var The variable to dump.
+ * @param string $label OPTIONAL Label to prepend to output.
+ * @param bool $echo OPTIONAL Echo output if true.
+ * @return string
+ */
+ public static function dump($var, $label = null, $echo = true)
+ {
+ // format the label
+ $label = ($label===null) ? '' : rtrim($label) . ' ';
+
+ // var_dump the variable into a buffer and keep the output
+ ob_start();
+ var_dump($var);
+ $output = ob_get_clean();
+
+ // neaten the newlines and indents
+ $output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);
+ if (static::getSapi() == 'cli') {
+ $output = PHP_EOL . $label
+ . PHP_EOL . $output
+ . PHP_EOL;
+ } else {
+ if (null !== static::$escaper) {
+ $output = static::$escaper->escapeHtml($output);
+ } elseif (!extension_loaded('xdebug')) {
+ $output = static::getEscaper()->escapeHtml($output);
+ }
+
+ $output = ''
+ . $label
+ . $output
+ . '
';
+ }
+
+ if ($echo) {
+ echo $output;
+ }
+ return $output;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Debug/README.md zendframework-2.2.6/library/Zend/Debug/README.md
--- zendframework-1.10.4/library/Zend/Debug/README.md 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Debug/README.md 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,15 @@
+Debug Component from ZF2
+========================
+
+This is the Debug component for ZF2.
+
+- File issues at https://github.com/zendframework/zf2/issues
+- Create pull requests against https://github.com/zendframework/zf2
+- Documentation is at http://framework.zend.com/docs
+
+LICENSE
+-------
+
+The files in this archive are released under the [Zend Framework
+license](http://framework.zend.com/license), which is a 3-clause BSD license.
+
diff -Nru zendframework-1.10.4/library/Zend/Debug.php zendframework-2.2.6/library/Zend/Debug.php
--- zendframework-1.10.4/library/Zend/Debug.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Debug.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,108 +0,0 @@
- tags, cleans up newlines and indents, and runs
- * htmlentities() before output.
- *
- * @param mixed $var The variable to dump.
- * @param string $label OPTIONAL Label to prepend to output.
- * @param bool $echo OPTIONAL Echo output if true.
- * @return string
- */
- public static function dump($var, $label=null, $echo=true)
- {
- // format the label
- $label = ($label===null) ? '' : rtrim($label) . ' ';
-
- // var_dump the variable into a buffer and keep the output
- ob_start();
- var_dump($var);
- $output = ob_get_clean();
-
- // neaten the newlines and indents
- $output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);
- if (self::getSapi() == 'cli') {
- $output = PHP_EOL . $label
- . PHP_EOL . $output
- . PHP_EOL;
- } else {
- if(!extension_loaded('xdebug')) {
- $output = htmlspecialchars($output, ENT_QUOTES);
- }
-
- $output = ''
- . $label
- . $output
- . '
';
- }
-
- if ($echo) {
- echo($output);
- }
- return $output;
- }
-
-}
diff -Nru zendframework-1.10.4/library/Zend/Di/composer.json zendframework-2.2.6/library/Zend/Di/composer.json
--- zendframework-1.10.4/library/Zend/Di/composer.json 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/composer.json 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,26 @@
+{
+ "name": "zendframework/zend-di",
+ "description": " ",
+ "license": "BSD-3-Clause",
+ "keywords": [
+ "zf2",
+ "di"
+ ],
+ "autoload": {
+ "psr-0": {
+ "Zend\\Di\\": ""
+ }
+ },
+ "target-dir": "Zend/Di",
+ "require": {
+ "php": ">=5.3.3",
+ "zendframework/zend-code": "self.version",
+ "zendframework/zend-stdlib": "self.version"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev",
+ "dev-develop": "2.3-dev"
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/Config.php zendframework-2.2.6/library/Zend/Di/Config.php
--- zendframework-1.10.4/library/Zend/Di/Config.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/Config.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,196 @@
+data = $options;
+ }
+
+ /**
+ * Configure
+ *
+ * @param Di $di
+ * @return void
+ */
+ public function configure(Di $di)
+ {
+ if (isset($this->data['definition'])) {
+ $this->configureDefinition($di, $this->data['definition']);
+ }
+ if (isset($this->data['instance'])) {
+ $this->configureInstance($di, $this->data['instance']);
+ }
+ }
+
+ /**
+ * @param Di $di
+ * @param array $definition
+ */
+ public function configureDefinition(Di $di, $definition)
+ {
+ foreach ($definition as $definitionType => $definitionData) {
+ switch ($definitionType) {
+ case 'compiler':
+ foreach ($definitionData as $filename) {
+ if (is_readable($filename)) {
+ $di->definitions()->addDefinition(new ArrayDefinition(include $filename), false);
+ }
+ }
+ break;
+ case 'runtime':
+ if (isset($definitionData['enabled']) && !$definitionData['enabled']) {
+ // Remove runtime from definition list if not enabled
+ $definitions = array();
+ foreach ($di->definitions() as $definition) {
+ if (!$definition instanceof RuntimeDefinition) {
+ $definitions[] = $definition;
+ }
+ }
+ $definitionList = new DefinitionList($definitions);
+ $di->setDefinitionList($definitionList);
+ } elseif (isset($definitionData['use_annotations']) && $definitionData['use_annotations']) {
+ /* @var $runtimeDefinition Definition\RuntimeDefinition */
+ $runtimeDefinition = $di
+ ->definitions()
+ ->getDefinitionByType('\Zend\Di\Definition\RuntimeDefinition');
+ $runtimeDefinition->getIntrospectionStrategy()->setUseAnnotations(true);
+ }
+ break;
+ case 'class':
+ foreach ($definitionData as $className => $classData) {
+ $classDefinitions = $di->definitions()->getDefinitionsByType('Zend\Di\Definition\ClassDefinition');
+ foreach ($classDefinitions as $classDefinition) {
+ if (!$classDefinition->hasClass($className)) {
+ unset($classDefinition);
+ }
+ }
+ if (!isset($classDefinition)) {
+ $classDefinition = new Definition\ClassDefinition($className);
+ $di->definitions()->addDefinition($classDefinition, false);
+ }
+ foreach ($classData as $classDefKey => $classDefData) {
+ switch ($classDefKey) {
+ case 'instantiator':
+ $classDefinition->setInstantiator($classDefData);
+ break;
+ case 'supertypes':
+ $classDefinition->setSupertypes($classDefData);
+ break;
+ case 'methods':
+ case 'method':
+ foreach ($classDefData as $methodName => $methodInfo) {
+ if (isset($methodInfo['required'])) {
+ $classDefinition->addMethod($methodName, $methodInfo['required']);
+ unset($methodInfo['required']);
+ }
+ foreach ($methodInfo as $paramName => $paramInfo) {
+ $classDefinition->addMethodParameter($methodName, $paramName, $paramInfo);
+ }
+ }
+ break;
+ default:
+ $methodName = $classDefKey;
+ $methodInfo = $classDefData;
+ if (isset($classDefData['required'])) {
+ $classDefinition->addMethod($methodName, $methodInfo['required']);
+ unset($methodInfo['required']);
+ }
+ foreach ($methodInfo as $paramName => $paramInfo) {
+ $classDefinition->addMethodParameter($methodName, $paramName, $paramInfo);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Configures a given Di instance
+ *
+ * @param Di $di
+ * @param $instanceData
+ */
+ public function configureInstance(Di $di, $instanceData)
+ {
+ $im = $di->instanceManager();
+
+ foreach ($instanceData as $target => $data) {
+ switch (strtolower($target)) {
+ case 'aliases':
+ case 'alias':
+ foreach ($data as $n => $v) {
+ $im->addAlias($n, $v);
+ }
+ break;
+ case 'preferences':
+ case 'preference':
+ foreach ($data as $n => $v) {
+ if (is_array($v)) {
+ foreach ($v as $v2) {
+ $im->addTypePreference($n, $v2);
+ }
+ } else {
+ $im->addTypePreference($n, $v);
+ }
+ }
+ break;
+ default:
+ foreach ($data as $n => $v) {
+ switch ($n) {
+ case 'parameters':
+ case 'parameter':
+ $im->setParameters($target, $v);
+ break;
+ case 'injections':
+ case 'injection':
+ $im->setInjections($target, $v);
+ break;
+ case 'shared':
+ case 'share':
+ $im->setShared($target, $v);
+ break;
+ }
+ }
+ }
+ }
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/Definition/Annotation/Inject.php zendframework-2.2.6/library/Zend/Di/Definition/Annotation/Inject.php
--- zendframework-1.10.4/library/Zend/Di/Definition/Annotation/Inject.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/Definition/Annotation/Inject.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,31 @@
+content = $content;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/Definition/Annotation/Instantiator.php zendframework-2.2.6/library/Zend/Di/Definition/Annotation/Instantiator.php
--- zendframework-1.10.4/library/Zend/Di/Definition/Annotation/Instantiator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/Definition/Annotation/Instantiator.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,31 @@
+content = $content;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/Definition/ArrayDefinition.php zendframework-2.2.6/library/Zend/Di/Definition/ArrayDefinition.php
--- zendframework-1.10.4/library/Zend/Di/Definition/ArrayDefinition.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/Definition/ArrayDefinition.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,176 @@
+ $value) {
+ // force lower names
+ $dataArray[$class] = array_change_key_case($dataArray[$class], CASE_LOWER);
+ }
+ foreach ($dataArray as $class => $definition) {
+ if (isset($definition['methods']) && is_array($definition['methods'])) {
+ foreach ($definition['methods'] as $type => $requirement) {
+ if (!is_int($requirement)) {
+ $dataArray[$class]['methods'][$type] = InjectionMethod::detectMethodRequirement($requirement);
+ }
+ }
+ }
+ }
+ $this->dataArray = $dataArray;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClasses()
+ {
+ return array_keys($this->dataArray);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasClass($class)
+ {
+ return array_key_exists($class, $this->dataArray);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassSupertypes($class)
+ {
+ if (!isset($this->dataArray[$class])) {
+ return array();
+ }
+
+ if (!isset($this->dataArray[$class]['supertypes'])) {
+ return array();
+ }
+
+ return $this->dataArray[$class]['supertypes'];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getInstantiator($class)
+ {
+ if (!isset($this->dataArray[$class])) {
+ return null;
+ }
+
+ if (!isset($this->dataArray[$class]['instantiator'])) {
+ return '__construct';
+ }
+
+ return $this->dataArray[$class]['instantiator'];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethods($class)
+ {
+ if (!isset($this->dataArray[$class])) {
+ return false;
+ }
+
+ if (!isset($this->dataArray[$class]['methods'])) {
+ return false;
+ }
+
+ return (count($this->dataArray[$class]['methods']) > 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethod($class, $method)
+ {
+ if (!isset($this->dataArray[$class])) {
+ return false;
+ }
+
+ if (!isset($this->dataArray[$class]['methods'])) {
+ return false;
+ }
+
+ return array_key_exists($method, $this->dataArray[$class]['methods']);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethods($class)
+ {
+ if (!isset($this->dataArray[$class])) {
+ return array();
+ }
+
+ if (!isset($this->dataArray[$class]['methods'])) {
+ return array();
+ }
+
+ return $this->dataArray[$class]['methods'];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethodParameters($class, $method)
+ {
+ return isset($this->dataArray[$class]['parameters'][$method]);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodParameters($class, $method)
+ {
+ if (!isset($this->dataArray[$class])) {
+ return array();
+ }
+
+ if (!isset($this->dataArray[$class]['parameters'])) {
+ return array();
+ }
+
+ if (!isset($this->dataArray[$class]['parameters'][$method])) {
+ return array();
+ }
+
+ return $this->dataArray[$class]['parameters'][$method];
+ }
+
+ /**
+ * @return array
+ */
+ public function toArray()
+ {
+ return $this->dataArray;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/Definition/Builder/InjectionMethod.php zendframework-2.2.6/library/Zend/Di/Definition/Builder/InjectionMethod.php
--- zendframework-1.10.4/library/Zend/Di/Definition/Builder/InjectionMethod.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/Definition/Builder/InjectionMethod.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,121 @@
+name = $name;
+
+ return $this;
+ }
+
+ /**
+ * @return null|string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param string $name
+ * @param string|null $class
+ * @param mixed|null $isRequired
+ * @param mixed|null $default
+ * @return InjectionMethod
+ */
+ public function addParameter($name, $class = null, $isRequired = null, $default = null)
+ {
+ $this->parameters[] = array(
+ $name,
+ $class,
+ self::detectMethodRequirement($isRequired),
+ $default,
+ );
+
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getParameters()
+ {
+ return $this->parameters;
+ }
+
+ /**
+ *
+ * @param mixed $requirement
+ * @return int
+ */
+ public static function detectMethodRequirement($requirement)
+ {
+ if (is_bool($requirement)) {
+ return $requirement ? Di::METHOD_IS_REQUIRED : Di::METHOD_IS_OPTIONAL;
+ }
+
+ if (null === $requirement) {
+ //This is mismatch to ClassDefinition::addMethod is it ok ? is optional?
+ return Di::METHOD_IS_REQUIRED;
+ }
+
+ if (is_int($requirement)) {
+ return $requirement;
+ }
+
+ if (is_string($requirement)) {
+ switch (strtolower($requirement)) {
+ default:
+ case "require":
+ case "required":
+ return Di::METHOD_IS_REQUIRED;
+ break;
+ case "aware":
+ return Di::METHOD_IS_AWARE;
+ break;
+ case "optional":
+ return Di::METHOD_IS_OPTIONAL;
+ break;
+ case "constructor":
+ return Di::MEHTOD_IS_CONSTRUCTOR;
+ break;
+ case "instantiator":
+ return Di::METHOD_IS_INSTANTIATOR;
+ break;
+ case "eager":
+ return Di::METHOD_IS_EAGER;
+ break;
+ }
+ }
+ return 0;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/Definition/Builder/PhpClass.php zendframework-2.2.6/library/Zend/Di/Definition/Builder/PhpClass.php
--- zendframework-1.10.4/library/Zend/Di/Definition/Builder/PhpClass.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/Definition/Builder/PhpClass.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,175 @@
+name = $name;
+
+ return $this;
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param string|\Callable|array $instantiator
+ * @return PhpClass
+ */
+ public function setInstantiator($instantiator)
+ {
+ $this->instantiator = $instantiator;
+
+ return $this;
+ }
+
+ /**
+ * @return array|\Callable|string
+ */
+ public function getInstantiator()
+ {
+ return $this->instantiator;
+ }
+
+ /**
+ * @param string $superType
+ * @return PhpClass
+ */
+ public function addSuperType($superType)
+ {
+ $this->superTypes[] = $superType;
+
+ return $this;
+ }
+
+ /**
+ * Get super types
+ *
+ * @return array
+ */
+ public function getSuperTypes()
+ {
+ return $this->superTypes;
+ }
+
+ /**
+ * Add injection method
+ *
+ * @param InjectionMethod $injectionMethod
+ * @return PhpClass
+ */
+ public function addInjectionMethod(InjectionMethod $injectionMethod)
+ {
+ $this->injectionMethods[] = $injectionMethod;
+
+ return $this;
+ }
+
+ /**
+ * Create and register an injection method
+ *
+ * Optionally takes the method name.
+ *
+ * This method may be used in lieu of addInjectionMethod() in
+ * order to provide a more fluent interface for building classes with
+ * injection methods.
+ *
+ * @param null|string $name
+ * @return InjectionMethod
+ */
+ public function createInjectionMethod($name = null)
+ {
+ $builder = $this->defaultMethodBuilder;
+ /* @var $method InjectionMethod */
+ $method = new $builder();
+ if (null !== $name) {
+ $method->setName($name);
+ }
+ $this->addInjectionMethod($method);
+
+ return $method;
+ }
+
+ /**
+ * Override which class will be used by {@link createInjectionMethod()}
+ *
+ * @param string $class
+ * @return PhpClass
+ */
+ public function setMethodBuilder($class)
+ {
+ $this->defaultMethodBuilder = $class;
+
+ return $this;
+ }
+
+ /**
+ * Determine what class will be used by {@link createInjectionMethod()}
+ *
+ * Mainly to provide the ability to temporarily override the class used.
+ *
+ * @return string
+ */
+ public function getMethodBuilder()
+ {
+ return $this->defaultMethodBuilder;
+ }
+
+ /**
+ * @return InjectionMethod[]
+ */
+ public function getInjectionMethods()
+ {
+ return $this->injectionMethods;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/Definition/BuilderDefinition.php zendframework-2.2.6/library/Zend/Di/Definition/BuilderDefinition.php
--- zendframework-1.10.4/library/Zend/Di/Definition/BuilderDefinition.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/Definition/BuilderDefinition.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,321 @@
+ $classInfo) {
+ $class = new Builder\PhpClass();
+ $class->setName($className);
+ foreach ($classInfo as $type => $typeData) {
+ switch (strtolower($type)) {
+ case 'supertypes':
+ foreach ($typeData as $superType) {
+ $class->addSuperType($superType);
+ }
+ break;
+ case 'instantiator':
+ $class->setInstantiator($typeData);
+ break;
+ case 'methods':
+ case 'method':
+ foreach ($typeData as $injectionMethodName => $injectionMethodData) {
+ $injectionMethod = new Builder\InjectionMethod();
+ $injectionMethod->setName($injectionMethodName);
+ foreach ($injectionMethodData as $parameterName => $parameterType) {
+ $parameterType = ($parameterType) ?: null; // force empty string to null
+ $injectionMethod->addParameter($parameterName, $parameterType);
+ }
+ $class->addInjectionMethod($injectionMethod);
+ }
+ break;
+
+ }
+ }
+ $this->addClass($class);
+ }
+ }
+
+ /**
+ * Add class
+ *
+ * @param Builder\PhpClass $phpClass
+ * @return BuilderDefinition
+ */
+ public function addClass(Builder\PhpClass $phpClass)
+ {
+ $this->classes[] = $phpClass;
+
+ return $this;
+ }
+
+ /**
+ * Create a class builder object using default class builder class
+ *
+ * This method is a factory that can be used in place of addClass().
+ *
+ * @param null|string $name Optional name of class to assign
+ * @return Builder\PhpClass
+ */
+ public function createClass($name = null)
+ {
+ $builderClass = $this->defaultClassBuilder;
+ /* @var $class Builder\PhpClass */
+ $class = new $builderClass();
+
+ if (null !== $name) {
+ $class->setName($name);
+ }
+
+ $this->addClass($class);
+
+ return $class;
+ }
+
+ /**
+ * Set the class to use with {@link createClass()}
+ *
+ * @param string $class
+ * @return BuilderDefinition
+ */
+ public function setClassBuilder($class)
+ {
+ $this->defaultClassBuilder = $class;
+
+ return $this;
+ }
+
+ /**
+ * Get the class used for {@link createClass()}
+ *
+ * This is primarily to allow developers to temporarily override
+ * the builder strategy.
+ *
+ * @return string
+ */
+ public function getClassBuilder()
+ {
+ return $this->defaultClassBuilder;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClasses()
+ {
+ $classNames = array();
+
+ /* @var $class Builder\PhpClass */
+ foreach ($this->classes as $class) {
+ $classNames[] = $class->getName();
+ }
+
+ return $classNames;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasClass($class)
+ {
+ foreach ($this->classes as $classObj) {
+ if ($classObj->getName() === $class) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @param string $name
+ * @return bool|Builder\PhpClass
+ */
+ protected function getClass($name)
+ {
+ foreach ($this->classes as $classObj) {
+ if ($classObj->getName() === $name) {
+ return $classObj;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @throws \Zend\Di\Exception\RuntimeException
+ */
+ public function getClassSupertypes($class)
+ {
+ $class = $this->getClass($class);
+
+ if ($class === false) {
+ throw new Exception\RuntimeException('Cannot find class object in this builder definition.');
+ }
+
+ return $class->getSuperTypes();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @throws \Zend\Di\Exception\RuntimeException
+ */
+ public function getInstantiator($class)
+ {
+ $class = $this->getClass($class);
+ if ($class === false) {
+ throw new Exception\RuntimeException('Cannot find class object in this builder definition.');
+ }
+
+ return $class->getInstantiator();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @throws \Zend\Di\Exception\RuntimeException
+ */
+ public function hasMethods($class)
+ {
+ /* @var $class \Zend\Di\Definition\Builder\PhpClass */
+ $class = $this->getClass($class);
+ if ($class === false) {
+ throw new Exception\RuntimeException('Cannot find class object in this builder definition.');
+ }
+
+ return (count($class->getInjectionMethods()) > 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @throws \Zend\Di\Exception\RuntimeException
+ */
+ public function getMethods($class)
+ {
+ $class = $this->getClass($class);
+ if ($class === false) {
+ throw new Exception\RuntimeException('Cannot find class object in this builder definition.');
+ }
+ $methods = $class->getInjectionMethods();
+ $methodNames = array();
+
+ /* @var $methodObj Builder\InjectionMethod */
+ foreach ($methods as $methodObj) {
+ $methodNames[] = $methodObj->getName();
+ }
+
+ return $methodNames;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @throws \Zend\Di\Exception\RuntimeException
+ */
+ public function hasMethod($class, $method)
+ {
+ $class = $this->getClass($class);
+ if ($class === false) {
+ throw new Exception\RuntimeException('Cannot find class object in this builder definition.');
+ }
+ $methods = $class->getInjectionMethods();
+
+ /* @var $methodObj Builder\InjectionMethod */
+ foreach ($methods as $methodObj) {
+ if ($methodObj->getName() === $method) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethodParameters($class, $method)
+ {
+ $class = $this->getClass($class);
+ if ($class === false) {
+ return false;
+ }
+ $methods = $class->getInjectionMethods();
+ /* @var $methodObj Builder\InjectionMethod */
+ foreach ($methods as $methodObj) {
+ if ($methodObj->getName() === $method) {
+ $method = $methodObj;
+ }
+ }
+ if (!$method instanceof Builder\InjectionMethod) {
+ return false;
+ }
+
+ /* @var $method Builder\InjectionMethod */
+
+ return (count($method->getParameters()) > 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @throws \Zend\Di\Exception\RuntimeException
+ */
+ public function getMethodParameters($class, $method)
+ {
+ $class = $this->getClass($class);
+
+ if ($class === false) {
+ throw new Exception\RuntimeException('Cannot find class object in this builder definition.');
+ }
+
+ $methods = $class->getInjectionMethods();
+
+ /* @var $methodObj Builder\InjectionMethod */
+ foreach ($methods as $methodObj) {
+ if ($methodObj->getName() === $method) {
+ $method = $methodObj;
+ }
+ }
+
+ if (!$method instanceof Builder\InjectionMethod) {
+ throw new Exception\RuntimeException('Cannot find method object for method ' . $method . ' in this builder definition.');
+ }
+
+ $methodParameters = array();
+
+ /* @var $method Builder\InjectionMethod */
+ foreach ($method->getParameters() as $name => $info) {
+ $methodParameters[$class->getName() . '::' . $method->getName() . ':' . $name] = $info;
+ }
+
+ return $methodParameters;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/Definition/ClassDefinition.php zendframework-2.2.6/library/Zend/Di/Definition/ClassDefinition.php
--- zendframework-1.10.4/library/Zend/Di/Definition/ClassDefinition.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/Definition/ClassDefinition.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,230 @@
+class = $class;
+ }
+
+ /**
+ * @param null|\Callable|array|string $instantiator
+ * @return self
+ */
+ public function setInstantiator($instantiator)
+ {
+ $this->instantiator = $instantiator;
+
+ return $this;
+ }
+
+ /**
+ * @param string[] $supertypes
+ * @return self
+ */
+ public function setSupertypes(array $supertypes)
+ {
+ $this->supertypes = $supertypes;
+
+ return $this;
+ }
+
+ /**
+ * @param string $method
+ * @param mixed|bool|null $isRequired
+ * @return self
+ */
+ public function addMethod($method, $isRequired = null)
+ {
+ if ($isRequired === null) {
+ if ($method === '__construct') {
+ $methodRequirementType = Di::METHOD_IS_CONSTRUCTOR;
+ }
+ $methodRequirementType = Di::METHOD_IS_OPTIONAL;
+ } else {
+ $methodRequirementType = InjectionMethod::detectMethodRequirement($isRequired);
+ }
+
+ $this->methods[$method] = $methodRequirementType;
+
+ return $this;
+ }
+
+ /**
+ * @param $method
+ * @param $parameterName
+ * @param array $parameterInfo (keys: required, type)
+ * @return ClassDefinition
+ */
+ public function addMethodParameter($method, $parameterName, array $parameterInfo)
+ {
+ if (!array_key_exists($method, $this->methods)) {
+ if ($method === '__construct') {
+ $this->methods[$method] = Di::METHOD_IS_CONSTRUCTOR;
+ } else {
+ $this->methods[$method] = Di::METHOD_IS_OPTIONAL;
+ }
+ }
+
+ if (!array_key_exists($method, $this->methodParameters)) {
+ $this->methodParameters[$method] = array();
+ }
+
+ $type = (isset($parameterInfo['type'])) ? $parameterInfo['type'] : null;
+ $required = (isset($parameterInfo['required'])) ? (bool) $parameterInfo['required'] : false;
+ $default = (isset($parameterInfo['default'])) ? $parameterInfo['default'] : null;
+
+ $fqName = $this->class . '::' . $method . ':' . $parameterName;
+ $this->methodParameters[$method][$fqName] = array(
+ $parameterName,
+ $type,
+ $required,
+ $default
+ );
+
+ return $this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClasses()
+ {
+ return array($this->class);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasClass($class)
+ {
+ return ($class === $this->class);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassSupertypes($class)
+ {
+ if ($this->class !== $class) {
+ return array();
+ }
+ return $this->supertypes;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getInstantiator($class)
+ {
+ if ($this->class !== $class) {
+ return null;
+ }
+ return $this->instantiator;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethods($class)
+ {
+ return (count($this->methods) > 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethods($class)
+ {
+ if ($this->class !== $class) {
+ return array();
+ }
+ return $this->methods;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethod($class, $method)
+ {
+ if ($this->class !== $class) {
+ return null;
+ }
+
+ if (is_array($this->methods)) {
+ return array_key_exists($method, $this->methods);
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethodParameters($class, $method)
+ {
+ if ($this->class !== $class) {
+ return false;
+ }
+ return (array_key_exists($method, $this->methodParameters));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodParameters($class, $method)
+ {
+ if ($this->class !== $class) {
+ return null;
+ }
+
+ if (array_key_exists($method, $this->methodParameters)) {
+ return $this->methodParameters[$method];
+ }
+
+ return null;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/Definition/CompilerDefinition.php zendframework-2.2.6/library/Zend/Di/Definition/CompilerDefinition.php
--- zendframework-1.10.4/library/Zend/Di/Definition/CompilerDefinition.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/Definition/CompilerDefinition.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,402 @@
+introspectionStrategy = ($introspectionStrategy) ?: new IntrospectionStrategy();
+ $this->directoryScanner = new AggregateDirectoryScanner();
+ }
+
+ /**
+ * Set introspection strategy
+ *
+ * @param IntrospectionStrategy $introspectionStrategy
+ */
+ public function setIntrospectionStrategy(IntrospectionStrategy $introspectionStrategy)
+ {
+ $this->introspectionStrategy = $introspectionStrategy;
+ }
+
+ /**
+ * @param bool $allowReflectionExceptions
+ */
+ public function setAllowReflectionExceptions($allowReflectionExceptions = true)
+ {
+ $this->allowReflectionExceptions = (bool) $allowReflectionExceptions;
+ }
+
+ /**
+ * Get introspection strategy
+ *
+ * @return IntrospectionStrategy
+ */
+ public function getIntrospectionStrategy()
+ {
+ return $this->introspectionStrategy;
+ }
+
+ /**
+ * Add directory
+ *
+ * @param string $directory
+ */
+ public function addDirectory($directory)
+ {
+ $this->addDirectoryScanner(new DirectoryScanner($directory));
+ }
+
+ /**
+ * Add directory scanner
+ *
+ * @param DirectoryScanner $directoryScanner
+ */
+ public function addDirectoryScanner(DirectoryScanner $directoryScanner)
+ {
+ $this->directoryScanner->addDirectoryScanner($directoryScanner);
+ }
+
+ /**
+ * Add code scanner file
+ *
+ * @param FileScanner $fileScanner
+ */
+ public function addCodeScannerFile(FileScanner $fileScanner)
+ {
+ if ($this->directoryScanner == null) {
+ $this->directoryScanner = new DirectoryScanner();
+ }
+
+ $this->directoryScanner->addFileScanner($fileScanner);
+ }
+
+ /**
+ * Compile
+ *
+ * @return void
+ */
+ public function compile()
+ {
+ /* @var $classScanner \Zend\Code\Scanner\DerivedClassScanner */
+ foreach ($this->directoryScanner->getClassNames() as $class) {
+ $this->processClass($class);
+ }
+ }
+
+ /**
+ * @return ArrayDefinition
+ */
+ public function toArrayDefinition()
+ {
+ return new ArrayDefinition(
+ $this->classes
+ );
+ }
+
+ /**
+ * @param string $class
+ * @throws \ReflectionException
+ */
+ protected function processClass($class)
+ {
+ $strategy = $this->introspectionStrategy; // localize for readability
+
+ try {
+ $rClass = new Reflection\ClassReflection($class);
+ } catch (\ReflectionException $e) {
+ if (!$this->allowReflectionExceptions) {
+ throw $e;
+ }
+
+ return;
+ }
+ $className = $rClass->getName();
+ $matches = null; // used for regex below
+
+ // setup the key in classes
+ $this->classes[$className] = array(
+ 'supertypes' => array(),
+ 'instantiator' => null,
+ 'methods' => array(),
+ 'parameters' => array()
+ );
+
+ $def = &$this->classes[$className]; // localize for brevity
+
+ // class annotations?
+ if ($strategy->getUseAnnotations() == true) {
+ $annotations = $rClass->getAnnotations($strategy->getAnnotationManager());
+
+ if (($annotations instanceof AnnotationCollection)
+ && $annotations->hasAnnotation('Zend\Di\Definition\Annotation\Instantiator')
+ ) {
+ // @todo Instantiator support in annotations
+ }
+ }
+
+ /* @var $rTarget \Zend\Code\Reflection\ClassReflection */
+ $rTarget = $rClass;
+ $supertypes = array();
+ do {
+ $supertypes = array_merge($supertypes, $rTarget->getInterfaceNames());
+ if (!($rTargetParent = $rTarget->getParentClass())) {
+ break;
+ }
+ $supertypes[] = $rTargetParent->getName();
+ $rTarget = $rTargetParent;
+ } while (true);
+
+ $def['supertypes'] = $supertypes;
+
+ if ($def['instantiator'] == null) {
+ if ($rClass->isInstantiable()) {
+ $def['instantiator'] = '__construct';
+ }
+ }
+
+ if ($rClass->hasMethod('__construct')) {
+ $def['methods']['__construct'] = true; // required
+ try {
+ $this->processParams($def, $rClass, $rClass->getMethod('__construct'));
+ } catch (\ReflectionException $e) {
+ if (!$this->allowReflectionExceptions) {
+ throw $e;
+ }
+
+ return;
+ }
+ }
+
+ foreach ($rClass->getMethods(Reflection\MethodReflection::IS_PUBLIC) as $rMethod) {
+
+ $methodName = $rMethod->getName();
+
+ if ($rMethod->getName() === '__construct' || $rMethod->isStatic()) {
+ continue;
+ }
+
+ if ($strategy->getUseAnnotations() == true) {
+ $annotations = $rMethod->getAnnotations($strategy->getAnnotationManager());
+
+ if (($annotations instanceof AnnotationCollection)
+ && $annotations->hasAnnotation('Zend\Di\Definition\Annotation\Inject')
+ ) {
+
+ $def['methods'][$methodName] = true;
+ $this->processParams($def, $rClass, $rMethod);
+ continue;
+ }
+ }
+
+ $methodPatterns = $this->introspectionStrategy->getMethodNameInclusionPatterns();
+
+ // matches a method injection pattern?
+ foreach ($methodPatterns as $methodInjectorPattern) {
+ preg_match($methodInjectorPattern, $methodName, $matches);
+ if ($matches) {
+ $def['methods'][$methodName] = false; // check ot see if this is required?
+ $this->processParams($def, $rClass, $rMethod);
+ continue 2;
+ }
+ }
+
+ // method
+ // by annotation
+ // by setter pattern,
+ // by interface
+
+ }
+
+ $interfaceInjectorPatterns = $this->introspectionStrategy->getInterfaceInjectionInclusionPatterns();
+
+ // matches the interface injection pattern
+ /** @var $rIface \ReflectionClass */
+ foreach ($rClass->getInterfaces() as $rIface) {
+ foreach ($interfaceInjectorPatterns as $interfaceInjectorPattern) {
+ preg_match($interfaceInjectorPattern, $rIface->getName(), $matches);
+ if ($matches) {
+ foreach ($rIface->getMethods() as $rMethod) {
+ if (($rMethod->getName() === '__construct') || !count($rMethod->getParameters())) {
+ // constructor not allowed in interfaces
+ // ignore methods without parameters
+ continue;
+ }
+ $def['methods'][$rMethod->getName()] = true;
+ $this->processParams($def, $rClass, $rMethod);
+ }
+ continue 2;
+ }
+ }
+ }
+ }
+
+ /**
+ * @param array $def
+ * @param \Zend\Code\Reflection\ClassReflection $rClass
+ * @param \Zend\Code\Reflection\MethodReflection $rMethod
+ */
+ protected function processParams(&$def, Reflection\ClassReflection $rClass, Reflection\MethodReflection $rMethod)
+ {
+ if (count($rMethod->getParameters()) === 0) {
+ return;
+ }
+
+ $methodName = $rMethod->getName();
+
+ // @todo annotations here for alternate names?
+
+ $def['parameters'][$methodName] = array();
+
+ foreach ($rMethod->getParameters() as $p) {
+
+ /** @var $p \ReflectionParameter */
+ $actualParamName = $p->getName();
+ $fqName = $rClass->getName() . '::' . $rMethod->getName() . ':' . $p->getPosition();
+ $def['parameters'][$methodName][$fqName] = array();
+
+ // set the class name, if it exists
+ $def['parameters'][$methodName][$fqName][] = $actualParamName;
+ $def['parameters'][$methodName][$fqName][] = ($p->getClass() !== null) ? $p->getClass()->getName() : null;
+ $def['parameters'][$methodName][$fqName][] = !($optional =$p->isOptional());
+ $def['parameters'][$methodName][$fqName][] = $optional && $p->isDefaultValueAvailable() ? $p->getDefaultValue() : null;
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClasses()
+ {
+ return array_keys($this->classes);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasClass($class)
+ {
+ return (array_key_exists($class, $this->classes));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassSupertypes($class)
+ {
+ if (!array_key_exists($class, $this->classes)) {
+ $this->processClass($class);
+ }
+
+ return $this->classes[$class]['supertypes'];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getInstantiator($class)
+ {
+ if (!array_key_exists($class, $this->classes)) {
+ $this->processClass($class);
+ }
+
+ return $this->classes[$class]['instantiator'];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethods($class)
+ {
+ if (!array_key_exists($class, $this->classes)) {
+ $this->processClass($class);
+ }
+
+ return (count($this->classes[$class]['methods']) > 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethod($class, $method)
+ {
+ if (!array_key_exists($class, $this->classes)) {
+ $this->processClass($class);
+ }
+
+ return isset($this->classes[$class]['methods'][$method]);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethods($class)
+ {
+ if (!array_key_exists($class, $this->classes)) {
+ $this->processClass($class);
+ }
+
+ return $this->classes[$class]['methods'];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethodParameters($class, $method)
+ {
+ if (!isset($this->classes[$class])) {
+ return false;
+ }
+
+ return (array_key_exists($method, $this->classes[$class]['parameters']));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodParameters($class, $method)
+ {
+ if (!is_array($this->classes[$class])) {
+ $this->processClass($class);
+ }
+
+ return $this->classes[$class]['parameters'][$method];
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/Definition/DefinitionInterface.php zendframework-2.2.6/library/Zend/Di/Definition/DefinitionInterface.php
--- zendframework-1.10.4/library/Zend/Di/Definition/DefinitionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/Definition/DefinitionInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,101 @@
+annotationManager = ($annotationManager) ?: $this->createDefaultAnnotationManager();
+ }
+
+ /**
+ * Get annotation manager
+ *
+ * @return null|AnnotationManager
+ */
+ public function getAnnotationManager()
+ {
+ return $this->annotationManager;
+ }
+
+ /**
+ * Create default annotation manager
+ *
+ * @return AnnotationManager
+ */
+ public function createDefaultAnnotationManager()
+ {
+ $annotationManager = new AnnotationManager;
+ $parser = new GenericAnnotationParser();
+ $parser->registerAnnotation(new Annotation\Inject());
+ $annotationManager->attach($parser);
+
+ return $annotationManager;
+ }
+
+ /**
+ * set use annotations
+ *
+ * @param bool $useAnnotations
+ */
+ public function setUseAnnotations($useAnnotations)
+ {
+ $this->useAnnotations = (bool) $useAnnotations;
+ }
+
+ /**
+ * Get use annotations
+ *
+ * @return bool
+ */
+ public function getUseAnnotations()
+ {
+ return $this->useAnnotations;
+ }
+
+ /**
+ * Set method name inclusion pattern
+ *
+ * @param array $methodNameInclusionPatterns
+ */
+ public function setMethodNameInclusionPatterns(array $methodNameInclusionPatterns)
+ {
+ $this->methodNameInclusionPatterns = $methodNameInclusionPatterns;
+ }
+
+ /**
+ * Get method name inclusion pattern
+ *
+ * @return array
+ */
+ public function getMethodNameInclusionPatterns()
+ {
+ return $this->methodNameInclusionPatterns;
+ }
+
+ /**
+ * Set interface injection inclusion patterns
+ *
+ * @param array $interfaceInjectionInclusionPatterns
+ */
+ public function setInterfaceInjectionInclusionPatterns(array $interfaceInjectionInclusionPatterns)
+ {
+ $this->interfaceInjectionInclusionPatterns = $interfaceInjectionInclusionPatterns;
+ }
+
+ /**
+ * Get interface injection inclusion patterns
+ *
+ * @return array
+ */
+ public function getInterfaceInjectionInclusionPatterns()
+ {
+ return $this->interfaceInjectionInclusionPatterns;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/Definition/PartialMarker.php zendframework-2.2.6/library/Zend/Di/Definition/PartialMarker.php
--- zendframework-1.10.4/library/Zend/Di/Definition/PartialMarker.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/Definition/PartialMarker.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,14 @@
+introspectionStrategy = ($introspectionStrategy) ?: new IntrospectionStrategy();
+ if ($explicitClasses) {
+ $this->setExplicitClasses($explicitClasses);
+ }
+ }
+
+ /**
+ * @param IntrospectionStrategy $introspectionStrategy
+ * @return void
+ */
+ public function setIntrospectionStrategy(IntrospectionStrategy $introspectionStrategy)
+ {
+ $this->introspectionStrategy = $introspectionStrategy;
+ }
+
+ /**
+ * @return IntrospectionStrategy
+ */
+ public function getIntrospectionStrategy()
+ {
+ return $this->introspectionStrategy;
+ }
+
+ /**
+ * Set explicit classes
+ *
+ * @param array $explicitClasses
+ */
+ public function setExplicitClasses(array $explicitClasses)
+ {
+ $this->explicitLookups = true;
+ foreach ($explicitClasses as $eClass) {
+ $this->classes[$eClass] = true;
+ }
+ $this->classes = $explicitClasses;
+ }
+
+ /**
+ * @param string $class
+ */
+ public function forceLoadClass($class)
+ {
+ $this->processClass($class, true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClasses()
+ {
+ return array_keys($this->classes);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasClass($class)
+ {
+ if ($this->explicitLookups === true) {
+ return (array_key_exists($class, $this->classes));
+ }
+
+ return class_exists($class) || interface_exists($class);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassSupertypes($class)
+ {
+ $this->processClass($class);
+ return $this->classes[$class]['supertypes'];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getInstantiator($class)
+ {
+ $this->processClass($class);
+ return $this->classes[$class]['instantiator'];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethods($class)
+ {
+ $this->processClass($class);
+ return (count($this->classes[$class]['methods']) > 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethod($class, $method)
+ {
+ $this->processClass($class);
+ return isset($this->classes[$class]['methods'][$method]);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethods($class)
+ {
+ $this->processClass($class);
+ return $this->classes[$class]['methods'];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethodParameters($class, $method)
+ {
+ $this->processClass($class);
+ return (array_key_exists($method, $this->classes[$class]['parameters']));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodParameters($class, $method)
+ {
+ $this->processClass($class);
+ return $this->classes[$class]['parameters'][$method];
+ }
+
+ /**
+ * @param string $class
+ */
+ protected function hasProcessedClass($class)
+ {
+ return array_key_exists($class, $this->classes) && is_array($this->classes[$class]);
+ }
+
+ /**
+ * @param string $class
+ * @param bool $forceLoad
+ */
+ protected function processClass($class, $forceLoad = false)
+ {
+ if (!$forceLoad && $this->hasProcessedClass($class)) {
+ return;
+ }
+ $strategy = $this->introspectionStrategy; // localize for readability
+
+ /** @var $rClass \Zend\Code\Reflection\ClassReflection */
+ $rClass = new Reflection\ClassReflection($class);
+ $className = $rClass->getName();
+ $matches = null; // used for regex below
+
+ // setup the key in classes
+ $this->classes[$className] = array(
+ 'supertypes' => array(),
+ 'instantiator' => null,
+ 'methods' => array(),
+ 'parameters' => array()
+ );
+
+ $def = &$this->classes[$className]; // localize for brevity
+
+ // class annotations?
+ if ($strategy->getUseAnnotations() == true) {
+ $annotations = $rClass->getAnnotations($strategy->getAnnotationManager());
+
+ if (($annotations instanceof AnnotationCollection)
+ && $annotations->hasAnnotation('Zend\Di\Definition\Annotation\Instantiator')) {
+ // @todo Instantiator support in annotations
+ }
+ }
+
+ $rTarget = $rClass;
+ $supertypes = array();
+ do {
+ $supertypes = array_merge($supertypes, $rTarget->getInterfaceNames());
+ if (!($rTargetParent = $rTarget->getParentClass())) {
+ break;
+ }
+ $supertypes[] = $rTargetParent->getName();
+ $rTarget = $rTargetParent;
+ } while (true);
+
+ $def['supertypes'] = $supertypes;
+
+ if ($def['instantiator'] == null) {
+ if ($rClass->isInstantiable()) {
+ $def['instantiator'] = '__construct';
+ }
+ }
+
+ if ($rClass->hasMethod('__construct')) {
+ $def['methods']['__construct'] = Di::METHOD_IS_CONSTRUCTOR; // required
+ $this->processParams($def, $rClass, $rClass->getMethod('__construct'));
+ }
+
+ foreach ($rClass->getMethods(Reflection\MethodReflection::IS_PUBLIC) as $rMethod) {
+
+ $methodName = $rMethod->getName();
+
+ if ($rMethod->getName() === '__construct' || $rMethod->isStatic()) {
+ continue;
+ }
+
+ if ($strategy->getUseAnnotations() == true) {
+ $annotations = $rMethod->getAnnotations($strategy->getAnnotationManager());
+
+ if (($annotations instanceof AnnotationCollection)
+ && $annotations->hasAnnotation('Zend\Di\Definition\Annotation\Inject')) {
+
+ // use '@inject' and search for parameters
+ $def['methods'][$methodName] = Di::METHOD_IS_EAGER;
+ $this->processParams($def, $rClass, $rMethod);
+ continue;
+ }
+ }
+
+ $methodPatterns = $this->introspectionStrategy->getMethodNameInclusionPatterns();
+
+ // matches a method injection pattern?
+ foreach ($methodPatterns as $methodInjectorPattern) {
+ preg_match($methodInjectorPattern, $methodName, $matches);
+ if ($matches) {
+ $def['methods'][$methodName] = Di::METHOD_IS_OPTIONAL; // check ot see if this is required?
+ $this->processParams($def, $rClass, $rMethod);
+ continue 2;
+ }
+ }
+
+ // method
+ // by annotation
+ // by setter pattern,
+ // by interface
+
+ }
+
+ $interfaceInjectorPatterns = $this->introspectionStrategy->getInterfaceInjectionInclusionPatterns();
+
+ // matches the interface injection pattern
+ /** @var $rIface \ReflectionClass */
+ foreach ($rClass->getInterfaces() as $rIface) {
+ foreach ($interfaceInjectorPatterns as $interfaceInjectorPattern) {
+ preg_match($interfaceInjectorPattern, $rIface->getName(), $matches);
+ if ($matches) {
+ foreach ($rIface->getMethods() as $rMethod) {
+ if (($rMethod->getName() === '__construct') || !count($rMethod->getParameters())) {
+ // constructor not allowed in interfaces
+ // Don't call interface methods without a parameter (Some aware interfaces define setters in ZF2)
+ continue;
+ }
+ $def['methods'][$rMethod->getName()] = Di::METHOD_IS_AWARE;
+ $this->processParams($def, $rClass, $rMethod);
+ }
+ continue 2;
+ }
+ }
+ }
+ }
+
+ /**
+ * @param array $def
+ * @param \Zend\Code\Reflection\ClassReflection $rClass
+ * @param \Zend\Code\Reflection\MethodReflection $rMethod
+ */
+ protected function processParams(&$def, Reflection\ClassReflection $rClass, Reflection\MethodReflection $rMethod)
+ {
+ if (count($rMethod->getParameters()) === 0) {
+ return;
+ }
+
+ $methodName = $rMethod->getName();
+
+ // @todo annotations here for alternate names?
+
+ $def['parameters'][$methodName] = array();
+
+ foreach ($rMethod->getParameters() as $p) {
+
+ /** @var $p \ReflectionParameter */
+ $actualParamName = $p->getName();
+
+ $fqName = $rClass->getName() . '::' . $rMethod->getName() . ':' . $p->getPosition();
+
+ $def['parameters'][$methodName][$fqName] = array();
+
+ // set the class name, if it exists
+ $def['parameters'][$methodName][$fqName][] = $actualParamName;
+ $def['parameters'][$methodName][$fqName][] = ($p->getClass() !== null) ? $p->getClass()->getName() : null;
+ $def['parameters'][$methodName][$fqName][] = !($optional = $p->isOptional() && $p->isDefaultValueAvailable());
+ $def['parameters'][$methodName][$fqName][] = $optional ? $p->getDefaultValue() : null;
+ }
+
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/DefinitionList.php zendframework-2.2.6/library/Zend/Di/DefinitionList.php
--- zendframework-1.10.4/library/Zend/Di/DefinitionList.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/DefinitionList.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,257 @@
+push($definition);
+ }
+ }
+
+ /**
+ * Add definitions
+ *
+ * @param Definition\DefinitionInterface $definition
+ * @param bool $addToBackOfList
+ * @return void
+ */
+ public function addDefinition(Definition\DefinitionInterface $definition, $addToBackOfList = true)
+ {
+ if ($addToBackOfList) {
+ $this->push($definition);
+ } else {
+ $this->unshift($definition);
+ }
+ }
+
+ /**
+ * @param string $type
+ * @return Definition\DefinitionInterface[]
+ */
+ public function getDefinitionsByType($type)
+ {
+ $definitions = array();
+ foreach ($this as $definition) {
+ if ($definition instanceof $type) {
+ $definitions[] = $definition;
+ }
+ }
+
+ return $definitions;
+ }
+
+ /**
+ * Get definition by type
+ *
+ * @param string $type
+ * @return Definition\DefinitionInterface
+ */
+ public function getDefinitionByType($type)
+ {
+ foreach ($this as $definition) {
+ if ($definition instanceof $type) {
+ return $definition;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @param string $class
+ * @return bool|Definition\DefinitionInterface
+ */
+ public function getDefinitionForClass($class)
+ {
+ /** @var $definition Definition\DefinitionInterface */
+ foreach ($this as $definition) {
+ if ($definition->hasClass($class)) {
+ return $definition;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @param string $class
+ * @return bool|Definition\DefinitionInterface
+ */
+ public function forClass($class)
+ {
+ return $this->getDefinitionForClass($class);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClasses()
+ {
+ $classes = array();
+ /** @var $definition Definition\DefinitionInterface */
+ foreach ($this as $definition) {
+ $classes = array_merge($classes, $definition->getClasses());
+ }
+
+ return $classes;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasClass($class)
+ {
+ /** @var $definition Definition\DefinitionInterface */
+ foreach ($this as $definition) {
+ if ($definition->hasClass($class)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassSupertypes($class)
+ {
+ $supertypes = array();
+ /** @var $definition Definition\DefinitionInterface */
+ foreach ($this as $definition) {
+ if ($definition->hasClass($class)) {
+ $supertypes = array_merge($supertypes, $definition->getClassSupertypes($class));
+ if ($definition instanceof Definition\PartialMarker) {
+ continue;
+ }
+
+ return $supertypes;
+ }
+ }
+ return $supertypes;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getInstantiator($class)
+ {
+ /** @var $definition Definition\DefinitionInterface */
+ foreach ($this as $definition) {
+ if ($definition->hasClass($class)) {
+ $value = $definition->getInstantiator($class);
+ if ($value === null && $definition instanceof Definition\PartialMarker) {
+ continue;
+ }
+
+ return $value;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethods($class)
+ {
+ /** @var $definition Definition\DefinitionInterface */
+ foreach ($this as $definition) {
+ if ($definition->hasClass($class)) {
+ if ($definition->hasMethods($class) === false && $definition instanceof Definition\PartialMarker) {
+ continue;
+ }
+
+ return $definition->hasMethods($class);
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethod($class, $method)
+ {
+ if (!$this->hasMethods($class)) {
+ return false;
+ }
+
+ /** @var $definition Definition\DefinitionInterface */
+ foreach ($this as $definition) {
+ if ($definition->hasClass($class) && $definition->hasMethod($class, $method)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethods($class)
+ {
+ /** @var $definition Definition\DefinitionInterface */
+ $methods = array();
+ foreach ($this as $definition) {
+ if ($definition->hasClass($class)) {
+ if (!$definition instanceof Definition\PartialMarker) {
+ return array_merge($definition->getMethods($class), $methods);
+ }
+
+ $methods = array_merge($definition->getMethods($class), $methods);
+ }
+ }
+
+ return $methods;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function hasMethodParameters($class, $method)
+ {
+ $methodParameters = $this->getMethodParameters($class, $method);
+
+ return ($methodParameters !== array());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodParameters($class, $method)
+ {
+ /** @var $definition Definition\DefinitionInterface */
+ foreach ($this as $definition) {
+ if ($definition->hasClass($class) && $definition->hasMethod($class, $method) && $definition->hasMethodParameters($class, $method)) {
+ return $definition->getMethodParameters($class, $method);
+ }
+ }
+
+ return array();
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/DependencyInjectionInterface.php zendframework-2.2.6/library/Zend/Di/DependencyInjectionInterface.php
--- zendframework-1.10.4/library/Zend/Di/DependencyInjectionInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/DependencyInjectionInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,25 @@
+definitions = ($definitions) ?: new DefinitionList(new Definition\RuntimeDefinition());
+ $this->instanceManager = ($instanceManager) ?: new InstanceManager();
+
+ if ($config) {
+ $this->configure($config);
+ }
+ }
+
+ /**
+ * Provide a configuration object to configure this instance
+ *
+ * @param Config $config
+ * @return void
+ */
+ public function configure(Config $config)
+ {
+ $config->configure($this);
+ }
+
+ /**
+ * @param DefinitionList $definitions
+ * @return self
+ */
+ public function setDefinitionList(DefinitionList $definitions)
+ {
+ $this->definitions = $definitions;
+
+ return $this;
+ }
+
+ /**
+ * @return DefinitionList
+ */
+ public function definitions()
+ {
+ return $this->definitions;
+ }
+
+ /**
+ * Set the instance manager
+ *
+ * @param InstanceManager $instanceManager
+ * @return Di
+ */
+ public function setInstanceManager(InstanceManager $instanceManager)
+ {
+ $this->instanceManager = $instanceManager;
+
+ return $this;
+ }
+
+ /**
+ *
+ * @return InstanceManager
+ */
+ public function instanceManager()
+ {
+ return $this->instanceManager;
+ }
+
+ /**
+ * @param $name
+ * @param array $params
+ * @param string $method
+ * @return array
+ */
+ protected function getCallParameters($name, array $params, $method = "__construct")
+ {
+ $im = $this->instanceManager;
+ $class = $im->hasAlias($name) ? $im->getClassFromAlias($name) : $name;
+ if ($this->definitions->hasClass($class)) {
+ $callParameters = array();
+ if ($this->definitions->hasMethod($class, $method)) {
+ foreach ($this->definitions->getMethodParameters($class, $method) as $param) {
+ if (isset($params[$param[0]])) {
+ $callParameters[$param[0]] = $params[$param[0]];
+ }
+ }
+ }
+ return $callParameters;
+ }
+ return $params;
+ }
+
+ /**
+ * Lazy-load a class
+ *
+ * Attempts to load the class (or service alias) provided. If it has been
+ * loaded before, the previous instance will be returned (unless the service
+ * definition indicates shared instances should not be used).
+ *
+ * @param string $name Class name or service alias
+ * @param null|array $params Parameters to pass to the constructor
+ * @return object|null
+ */
+ public function get($name, array $params = array())
+ {
+ array_push($this->instanceContext, array('GET', $name, null));
+
+ $im = $this->instanceManager;
+
+ $callParameters = $this->getCallParameters($name, $params);
+ if ($callParameters) {
+ $fastHash = $im->hasSharedInstanceWithParameters($name, $callParameters, true);
+ if ($fastHash) {
+ array_pop($this->instanceContext);
+ return $im->getSharedInstanceWithParameters(null, array(), $fastHash);
+ }
+ }
+
+ if ($im->hasSharedInstance($name, $callParameters)) {
+ array_pop($this->instanceContext);
+ return $im->getSharedInstance($name, $callParameters);
+ }
+
+
+ $config = $im->getConfig($name);
+ $instance = $this->newInstance($name, $params, $config['shared']);
+ array_pop($this->instanceContext);
+
+ return $instance;
+ }
+
+ /**
+ * Retrieve a new instance of a class
+ *
+ * Forces retrieval of a discrete instance of the given class, using the
+ * constructor parameters provided.
+ *
+ * @param mixed $name Class name or service alias
+ * @param array $params Parameters to pass to the constructor
+ * @param bool $isShared
+ * @return object|null
+ * @throws Exception\ClassNotFoundException
+ * @throws Exception\RuntimeException
+ */
+ public function newInstance($name, array $params = array(), $isShared = true)
+ {
+ // localize dependencies
+ $definitions = $this->definitions;
+ $instanceManager = $this->instanceManager();
+
+ if ($instanceManager->hasAlias($name)) {
+ $class = $instanceManager->getClassFromAlias($name);
+ $alias = $name;
+ } else {
+ $class = $name;
+ $alias = null;
+ }
+
+ array_push($this->instanceContext, array('NEW', $class, $alias));
+
+ if (!$definitions->hasClass($class)) {
+ $aliasMsg = ($alias) ? '(specified by alias ' . $alias . ') ' : '';
+ throw new Exception\ClassNotFoundException(
+ 'Class ' . $aliasMsg . $class . ' could not be located in provided definitions.'
+ );
+ }
+
+ $instantiator = $definitions->getInstantiator($class);
+ $injectionMethods = array();
+ $injectionMethods[$class] = $definitions->getMethods($class);
+
+ foreach ($definitions->getClassSupertypes($class) as $supertype) {
+ $injectionMethods[$supertype] = $definitions->getMethods($supertype);
+ }
+
+ if ($instantiator === '__construct') {
+ $instance = $this->createInstanceViaConstructor($class, $params, $alias);
+ if (array_key_exists('__construct', $injectionMethods)) {
+ unset($injectionMethods['__construct']);
+ }
+ } elseif (is_callable($instantiator, false)) {
+ $instance = $this->createInstanceViaCallback($instantiator, $params, $alias);
+ } else {
+ if (is_array($instantiator)) {
+ $msg = sprintf(
+ 'Invalid instantiator: %s::%s() is not callable.',
+ isset($instantiator[0]) ? $instantiator[0] : 'NoClassGiven',
+ isset($instantiator[1]) ? $instantiator[1] : 'NoMethodGiven'
+ );
+ } else {
+ $msg = sprintf(
+ 'Invalid instantiator of type "%s" for "%s".',
+ gettype($instantiator),
+ $name
+ );
+ }
+ throw new Exception\RuntimeException($msg);
+ }
+
+ if ($isShared) {
+ if ($callParameters = $this->getCallParameters($name, $params)) {
+ $this->instanceManager->addSharedInstanceWithParameters($instance, $name, $callParameters);
+ } else {
+ $this->instanceManager->addSharedInstance($instance, $name);
+ }
+ }
+
+ $this->handleInjectDependencies($instance, $injectionMethods, $params, $class, $alias, $name);
+
+ array_pop($this->instanceContext);
+
+ return $instance;
+ }
+
+ /**
+ * Inject dependencies
+ *
+ * @param object $instance
+ * @param array $params
+ * @return void
+ */
+ public function injectDependencies($instance, array $params = array())
+ {
+ $definitions = $this->definitions();
+ $class = $this->getClass($instance);
+ $injectionMethods = array(
+ $class => ($definitions->hasClass($class)) ? $definitions->getMethods($class) : array()
+ );
+ $parent = $class;
+ while ($parent = get_parent_class($parent)) {
+ if ($definitions->hasClass($parent)) {
+ $injectionMethods[$parent] = $definitions->getMethods($parent);
+ }
+ }
+ foreach (class_implements($class) as $interface) {
+ if ($definitions->hasClass($interface)) {
+ $injectionMethods[$interface] = $definitions->getMethods($interface);
+ }
+ }
+ $this->handleInjectDependencies($instance, $injectionMethods, $params, $class, null, null);
+ }
+
+ /**
+ * @param object $instance
+ * @param array $injectionMethods
+ * @param array $params
+ * @param string|null $instanceClass
+ * @param string|null$instanceAlias
+ * @param string $requestedName
+ * @throws Exception\RuntimeException
+ */
+ protected function handleInjectDependencies($instance, $injectionMethods, $params, $instanceClass, $instanceAlias, $requestedName)
+ {
+ // localize dependencies
+ $definitions = $this->definitions;
+ $instanceManager = $this->instanceManager();
+
+ $calledMethods = array('__construct' => true);
+
+ if ($injectionMethods) {
+ foreach ($injectionMethods as $type => $typeInjectionMethods) {
+ foreach ($typeInjectionMethods as $typeInjectionMethod => $methodRequirementType) {
+ if (!isset($calledMethods[$typeInjectionMethod])) {
+ if ($this->resolveAndCallInjectionMethodForInstance($instance, $typeInjectionMethod, $params, $instanceAlias, $methodRequirementType, $type)) {
+ $calledMethods[$typeInjectionMethod] = true;
+ }
+ }
+ }
+ }
+
+ if ($requestedName) {
+ $instanceConfig = $instanceManager->getConfig($requestedName);
+
+ if ($instanceConfig['injections']) {
+ $objectsToInject = $methodsToCall = array();
+ foreach ($instanceConfig['injections'] as $injectName => $injectValue) {
+ if (is_int($injectName) && is_string($injectValue)) {
+ $objectsToInject[] = $this->get($injectValue, $params);
+ } elseif (is_string($injectName) && is_array($injectValue)) {
+ if (is_string(key($injectValue))) {
+ $methodsToCall[] = array('method' => $injectName, 'args' => $injectValue);
+ } else {
+ foreach ($injectValue as $methodCallArgs) {
+ $methodsToCall[] = array('method' => $injectName, 'args' => $methodCallArgs);
+ }
+ }
+ } elseif (is_object($injectValue)) {
+ $objectsToInject[] = $injectValue;
+ } elseif (is_int($injectName) && is_array($injectValue)) {
+ throw new Exception\RuntimeException(
+ 'An injection was provided with a keyed index and an array of data, try using'
+ . ' the name of a particular method as a key for your injection data.'
+ );
+ }
+ }
+ if ($objectsToInject) {
+ foreach ($objectsToInject as $objectToInject) {
+ $calledMethods = array('__construct' => true);
+ foreach ($injectionMethods as $type => $typeInjectionMethods) {
+ foreach ($typeInjectionMethods as $typeInjectionMethod => $methodRequirementType) {
+ if (!isset($calledMethods[$typeInjectionMethod])) {
+ $methodParams = $definitions->getMethodParameters($type, $typeInjectionMethod);
+ if ($methodParams) {
+ foreach ($methodParams as $methodParam) {
+ $objectToInjectClass = $this->getClass($objectToInject);
+ if ($objectToInjectClass == $methodParam[1] || self::isSubclassOf($objectToInjectClass, $methodParam[1])) {
+ if ($this->resolveAndCallInjectionMethodForInstance($instance, $typeInjectionMethod, array($methodParam[0] => $objectToInject), $instanceAlias, self::METHOD_IS_REQUIRED, $type)) {
+ $calledMethods[$typeInjectionMethod] = true;
+ }
+ continue 3;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if ($methodsToCall) {
+ foreach ($methodsToCall as $methodInfo) {
+ $this->resolveAndCallInjectionMethodForInstance($instance, $methodInfo['method'], $methodInfo['args'], $instanceAlias, self::METHOD_IS_REQUIRED, $instanceClass);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Retrieve a class instance based on class name
+ *
+ * Any parameters provided will be used as constructor arguments. If any
+ * given parameter is a DependencyReference object, it will be fetched
+ * from the container so that the instance may be injected.
+ *
+ * @param string $class
+ * @param array $params
+ * @param string|null $alias
+ * @return object
+ */
+ protected function createInstanceViaConstructor($class, $params, $alias = null)
+ {
+ $callParameters = array();
+ if ($this->definitions->hasMethod($class, '__construct')) {
+ $callParameters = $this->resolveMethodParameters($class, '__construct', $params, $alias, self::METHOD_IS_CONSTRUCTOR, true);
+ }
+
+ if (!class_exists($class)) {
+ if (interface_exists($class)) {
+ throw new Exception\ClassNotFoundException(sprintf(
+ 'Cannot instantiate interface "%s"',
+ $class
+ ));
+ }
+ throw new Exception\ClassNotFoundException(sprintf(
+ 'Class "%s" does not exist; cannot instantiate',
+ $class
+ ));
+ }
+
+ // Hack to avoid Reflection in most common use cases
+ switch (count($callParameters)) {
+ case 0:
+ return new $class();
+ case 1:
+ return new $class($callParameters[0]);
+ case 2:
+ return new $class($callParameters[0], $callParameters[1]);
+ case 3:
+ return new $class($callParameters[0], $callParameters[1], $callParameters[2]);
+ default:
+ $r = new \ReflectionClass($class);
+
+ return $r->newInstanceArgs($callParameters);
+ }
+ }
+
+ /**
+ * Get an object instance from the defined callback
+ *
+ * @param callable $callback
+ * @param array $params
+ * @param string $alias
+ * @return object
+ * @throws Exception\InvalidCallbackException
+ * @throws Exception\RuntimeException
+ */
+ protected function createInstanceViaCallback($callback, $params, $alias)
+ {
+ if (!is_callable($callback)) {
+ throw new Exception\InvalidCallbackException('An invalid constructor callback was provided');
+ }
+
+ if (is_array($callback)) {
+ $class = (is_object($callback[0])) ? $this->getClass($callback[0]) : $callback[0];
+ $method = $callback[1];
+ } elseif (is_string($callback) && strpos($callback, '::') !== false) {
+ list($class, $method) = explode('::', $callback, 2);
+ } else {
+ throw new Exception\RuntimeException('Invalid callback type provided to ' . __METHOD__);
+ }
+
+ $callParameters = array();
+ if ($this->definitions->hasMethod($class, $method)) {
+ $callParameters = $this->resolveMethodParameters($class, $method, $params, $alias, self::METHOD_IS_INSTANTIATOR, true);
+ }
+
+ return call_user_func_array($callback, $callParameters);
+ }
+
+ /**
+ * This parameter will handle any injection methods and resolution of
+ * dependencies for such methods
+ *
+ * @param object $instance
+ * @param string $method
+ * @param array $params
+ * @param string $alias
+ * @param bool $methodRequirementType
+ * @param string|null $methodClass
+ * @return bool
+ */
+ protected function resolveAndCallInjectionMethodForInstance($instance, $method, $params, $alias, $methodRequirementType, $methodClass = null)
+ {
+ $methodClass = ($methodClass) ?: $this->getClass($instance);
+ $callParameters = $this->resolveMethodParameters($methodClass, $method, $params, $alias, $methodRequirementType);
+ if ($callParameters == false) {
+ return false;
+ }
+ if ($callParameters !== array_fill(0, count($callParameters), null)) {
+ call_user_func_array(array($instance, $method), $callParameters);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Resolve parameters referencing other services
+ *
+ * @param string $class
+ * @param string $method
+ * @param array $callTimeUserParams
+ * @param string $alias
+ * @param int|bolean $methodRequirementType
+ * @param bool $isInstantiator
+ * @throws Exception\MissingPropertyException
+ * @throws Exception\CircularDependencyException
+ * @return array
+ */
+ protected function resolveMethodParameters($class, $method, array $callTimeUserParams, $alias, $methodRequirementType, $isInstantiator = false)
+ {
+ //for BC
+ if (is_bool($methodRequirementType)) {
+ if ($isInstantiator) {
+ $methodRequirementType = Di::METHOD_IS_INSTANTIATOR;
+ } elseif ($methodRequirementType) {
+ $methodRequirementType = Di::METHOD_IS_REQUIRED;
+ } else {
+ $methodRequirementType = Di::METHOD_IS_OPTIONAL;
+ }
+ }
+ // parameters for this method, in proper order, to be returned
+ $resolvedParams = array();
+
+ // parameter requirements from the definition
+ $injectionMethodParameters = $this->definitions->getMethodParameters($class, $method);
+
+ // computed parameters array
+ $computedParams = array(
+ 'value' => array(),
+ 'retrieval' => array(),
+ 'optional' => array()
+ );
+
+ // retrieve instance configurations for all contexts
+ $iConfig = array();
+ $aliases = $this->instanceManager->getAliases();
+
+ // for the alias in the dependency tree
+ if ($alias && $this->instanceManager->hasConfig($alias)) {
+ $iConfig['thisAlias'] = $this->instanceManager->getConfig($alias);
+ }
+
+ // for the current class in the dependency tree
+ if ($this->instanceManager->hasConfig($class)) {
+ $iConfig['thisClass'] = $this->instanceManager->getConfig($class);
+ }
+
+ // for the parent class, provided we are deeper than one node
+ if (isset($this->instanceContext[0])) {
+ list($requestedClass, $requestedAlias) = ($this->instanceContext[0][0] == 'NEW')
+ ? array($this->instanceContext[0][1], $this->instanceContext[0][2])
+ : array($this->instanceContext[1][1], $this->instanceContext[1][2]);
+ } else {
+ $requestedClass = $requestedAlias = null;
+ }
+
+ if ($requestedClass != $class && $this->instanceManager->hasConfig($requestedClass)) {
+ $iConfig['requestedClass'] = $this->instanceManager->getConfig($requestedClass);
+
+ if (array_key_exists('parameters', $iConfig['requestedClass'])) {
+ $newParameters = array();
+
+ foreach($iConfig['requestedClass']['parameters'] as $name=>$parameter) {
+ $newParameters[$requestedClass.'::'.$method.'::'.$name] = $parameter;
+ }
+
+ $iConfig['requestedClass']['parameters'] = $newParameters;
+ }
+
+ if ($requestedAlias) {
+ $iConfig['requestedAlias'] = $this->instanceManager->getConfig($requestedAlias);
+ }
+ }
+
+ // This is a 2 pass system for resolving parameters
+ // first pass will find the sources, the second pass will order them and resolve lookups if they exist
+ // MOST methods will only have a single parameters to resolve, so this should be fast
+
+ foreach ($injectionMethodParameters as $fqParamPos => $info) {
+ list($name, $type, $isRequired) = $info;
+
+ $fqParamName = substr_replace($fqParamPos, ':' . $info[0], strrpos($fqParamPos, ':'));
+
+ // PRIORITY 1 - consult user provided parameters
+ if (isset($callTimeUserParams[$fqParamPos]) || isset($callTimeUserParams[$name])) {
+
+ if (isset($callTimeUserParams[$fqParamPos])) {
+ $callTimeCurValue =& $callTimeUserParams[$fqParamPos];
+ } elseif (isset($callTimeUserParams[$fqParamName])) {
+ $callTimeCurValue =& $callTimeUserParams[$fqParamName];
+ } else {
+ $callTimeCurValue =& $callTimeUserParams[$name];
+ }
+
+ if ($type !== false && is_string($callTimeCurValue)) {
+ if ($this->instanceManager->hasAlias($callTimeCurValue)) {
+ // was an alias provided?
+ $computedParams['retrieval'][$fqParamPos] = array(
+ $callTimeUserParams[$name],
+ $this->instanceManager->getClassFromAlias($callTimeCurValue)
+ );
+ } elseif ($this->definitions->hasClass($callTimeUserParams[$name])) {
+ // was a known class provided?
+ $computedParams['retrieval'][$fqParamPos] = array(
+ $callTimeCurValue,
+ $callTimeCurValue
+ );
+ } else {
+ // must be a value
+ $computedParams['value'][$fqParamPos] = $callTimeCurValue;
+ }
+ } else {
+ // int, float, null, object, etc
+ $computedParams['value'][$fqParamPos] = $callTimeCurValue;
+ }
+ unset($callTimeCurValue);
+ continue;
+ }
+
+ // PRIORITY 2 -specific instance configuration (thisAlias) - this alias
+ // PRIORITY 3 -THEN specific instance configuration (thisClass) - this class
+ // PRIORITY 4 -THEN specific instance configuration (requestedAlias) - requested alias
+ // PRIORITY 5 -THEN specific instance configuration (requestedClass) - requested class
+
+ foreach (array('thisAlias', 'thisClass', 'requestedAlias', 'requestedClass') as $thisIndex) {
+ // check the provided parameters config
+ if (isset($iConfig[$thisIndex]['parameters'][$fqParamPos])
+ || isset($iConfig[$thisIndex]['parameters'][$fqParamName])
+ || isset($iConfig[$thisIndex]['parameters'][$name])) {
+
+ if (isset($iConfig[$thisIndex]['parameters'][$fqParamPos])) {
+ $iConfigCurValue =& $iConfig[$thisIndex]['parameters'][$fqParamPos];
+ } elseif (isset($iConfig[$thisIndex]['parameters'][$fqParamName])) {
+ $iConfigCurValue =& $iConfig[$thisIndex]['parameters'][$fqParamName];
+ } else {
+ $iConfigCurValue =& $iConfig[$thisIndex]['parameters'][$name];
+ }
+
+ if ($type === false && is_string($iConfigCurValue)) {
+ $computedParams['value'][$fqParamPos] = $iConfigCurValue;
+ } elseif (is_string($iConfigCurValue)
+ && isset($aliases[$iConfigCurValue])) {
+ $computedParams['retrieval'][$fqParamPos] = array(
+ $iConfig[$thisIndex]['parameters'][$name],
+ $this->instanceManager->getClassFromAlias($iConfigCurValue)
+ );
+ } elseif (is_string($iConfigCurValue)
+ && $this->definitions->hasClass($iConfigCurValue)) {
+ $computedParams['retrieval'][$fqParamPos] = array(
+ $iConfigCurValue,
+ $iConfigCurValue
+ );
+ } elseif (is_object($iConfigCurValue)
+ && $iConfigCurValue instanceof Closure
+ && $type !== 'Closure') {
+ /* @var $iConfigCurValue Closure */
+ $computedParams['value'][$fqParamPos] = $iConfigCurValue();
+ } else {
+ $computedParams['value'][$fqParamPos] = $iConfigCurValue;
+ }
+ unset($iConfigCurValue);
+ continue 2;
+ }
+
+ }
+
+ // PRIORITY 6 - globally preferred implementations
+
+ // next consult alias level preferred instances
+ // RESOLVE_EAGER wants to inject the cross-cutting concerns.
+ // If you want to retrieve an instance from TypePreferences,
+ // use AwareInterface or specify the method requirement option METHOD_IS_EAGER at ClassDefinition
+ if ($methodRequirementType & self::RESOLVE_EAGER) {
+ if ($alias && $this->instanceManager->hasTypePreferences($alias)) {
+ $pInstances = $this->instanceManager->getTypePreferences($alias);
+ foreach ($pInstances as $pInstance) {
+ if (is_object($pInstance)) {
+ $computedParams['value'][$fqParamPos] = $pInstance;
+ continue 2;
+ }
+ $pInstanceClass = ($this->instanceManager->hasAlias($pInstance)) ?
+ $this->instanceManager->getClassFromAlias($pInstance) : $pInstance;
+ if ($pInstanceClass === $type || self::isSubclassOf($pInstanceClass, $type)) {
+ $computedParams['retrieval'][$fqParamPos] = array($pInstance, $pInstanceClass);
+ continue 2;
+ }
+ }
+ }
+
+ // next consult class level preferred instances
+ if ($type && $this->instanceManager->hasTypePreferences($type)) {
+ $pInstances = $this->instanceManager->getTypePreferences($type);
+ foreach ($pInstances as $pInstance) {
+ if (is_object($pInstance)) {
+ $computedParams['value'][$fqParamPos] = $pInstance;
+ continue 2;
+ }
+ $pInstanceClass = ($this->instanceManager->hasAlias($pInstance)) ?
+ $this->instanceManager->getClassFromAlias($pInstance) : $pInstance;
+ if ($pInstanceClass === $type || self::isSubclassOf($pInstanceClass, $type)) {
+ $computedParams['retrieval'][$fqParamPos] = array($pInstance, $pInstanceClass);
+ continue 2;
+ }
+ }
+ }
+ }
+ if (!$isRequired) {
+ $computedParams['optional'][$fqParamPos] = true;
+ }
+
+ if ($type && $isRequired && ($methodRequirementType & self::RESOLVE_EAGER)) {
+ $computedParams['retrieval'][$fqParamPos] = array($type, $type);
+ }
+
+ }
+
+ $index = 0;
+ foreach ($injectionMethodParameters as $fqParamPos => $value) {
+ $name = $value[0];
+
+ if (isset($computedParams['value'][$fqParamPos])) {
+ // if there is a value supplied, use it
+ $resolvedParams[$index] = $computedParams['value'][$fqParamPos];
+ } elseif (isset($computedParams['retrieval'][$fqParamPos])) {
+ // detect circular dependencies! (they can only happen in instantiators)
+ if ($isInstantiator && in_array($computedParams['retrieval'][$fqParamPos][1], $this->currentDependencies)
+ && (!isset($alias) || in_array($computedParams['retrieval'][$fqParamPos][0], $this->currentAliasDependenencies))
+ ) {
+ $msg = "Circular dependency detected: $class depends on {$value[1]} and viceversa";
+ if (isset($alias)) {
+ $msg .= " (Aliased as $alias)";
+ }
+ throw new Exception\CircularDependencyException($msg);
+ }
+
+ array_push($this->currentDependencies, $class);
+ if(isset($alias)) {
+ array_push($this->currentAliasDependenencies, $alias);
+ }
+
+ $dConfig = $this->instanceManager->getConfig($computedParams['retrieval'][$fqParamPos][0]);
+
+ try {
+ if ($dConfig['shared'] === false) {
+ $resolvedParams[$index] = $this->newInstance($computedParams['retrieval'][$fqParamPos][0], $callTimeUserParams, false);
+ } else {
+ $resolvedParams[$index] = $this->get($computedParams['retrieval'][$fqParamPos][0], $callTimeUserParams);
+ }
+ } catch (DiRuntimeException $e) {
+ if ($methodRequirementType & self::RESOLVE_STRICT) {
+ //finally ( be aware to do at the end of flow)
+ array_pop($this->currentDependencies);
+ if(isset($alias)) {
+ array_pop($this->currentAliasDependenencies);
+ }
+ // if this item was marked strict,
+ // plus it cannot be resolve, and no value exist, bail out
+ throw new Exception\MissingPropertyException(sprintf(
+ 'Missing %s for parameter ' . $name . ' for ' . $class . '::' . $method,
+ (($value[0] === null) ? 'value' : 'instance/object' )
+ ),
+ $e->getCode(),
+ $e);
+ } else {
+ //finally ( be aware to do at the end of flow)
+ array_pop($this->currentDependencies);
+ if(isset($alias)) {
+ array_pop($this->currentAliasDependenencies);
+ }
+ return false;
+ }
+ } catch (ServiceManagerException $e) {
+ // Zend\ServiceManager\Exception\ServiceNotCreatedException
+ if ($methodRequirementType & self::RESOLVE_STRICT) {
+ //finally ( be aware to do at the end of flow)
+ array_pop($this->currentDependencies);
+ if(isset($alias)) {
+ array_pop($this->currentAliasDependenencies);
+ }
+ // if this item was marked strict,
+ // plus it cannot be resolve, and no value exist, bail out
+ throw new Exception\MissingPropertyException(sprintf(
+ 'Missing %s for parameter ' . $name . ' for ' . $class . '::' . $method,
+ (($value[0] === null) ? 'value' : 'instance/object' )
+ ),
+ $e->getCode(),
+ $e);
+ } else {
+ //finally ( be aware to do at the end of flow)
+ array_pop($this->currentDependencies);
+ if(isset($alias)) {
+ array_pop($this->currentAliasDependenencies);
+ }
+ return false;
+ }
+ }
+ array_pop($this->currentDependencies);
+ if(isset($alias)) {
+ array_pop($this->currentAliasDependenencies);
+ }
+ } elseif (!array_key_exists($fqParamPos, $computedParams['optional'])) {
+ if ($methodRequirementType & self::RESOLVE_STRICT) {
+ // if this item was not marked as optional,
+ // plus it cannot be resolve, and no value exist, bail out
+ throw new Exception\MissingPropertyException(sprintf(
+ 'Missing %s for parameter ' . $name . ' for ' . $class . '::' . $method,
+ (($value[0] === null) ? 'value' : 'instance/object' )
+ ));
+ } else {
+ return false;
+ }
+ } else {
+ $resolvedParams[$index] = $value[3];
+ }
+
+ $index++;
+ }
+
+ return $resolvedParams; // return ordered list of parameters
+ }
+
+ /**
+ * Utility method used to retrieve the class of a particular instance. This is here to allow extending classes to
+ * override how class names are resolved
+ *
+ * @internal this method is used by the ServiceLocator\DependencyInjectorProxy class to interact with instances
+ * and is a hack to be used internally until a major refactor does not split the `resolveMethodParameters`. Do not
+ * rely on its functionality.
+ * @param Object $instance
+ * @return string
+ */
+ protected function getClass($instance)
+ {
+ return get_class($instance);
+ }
+
+ /**
+ * Checks if the object has this class as one of its parents
+ *
+ * @see https://bugs.php.net/bug.php?id=53727
+ * @see https://github.com/zendframework/zf2/pull/1807
+ *
+ * @param string $className
+ * @param $type
+ * @return bool
+ */
+ protected static function isSubclassOf($className, $type)
+ {
+ if (is_subclass_of($className, $type)) {
+ return true;
+ }
+ if (version_compare(PHP_VERSION, '5.3.7', '>=')) {
+ return false;
+ }
+ if (!interface_exists($type)) {
+ return false;
+ }
+ $r = new ReflectionClass($className);
+
+ return $r->implementsInterface($type);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/Display/Console.php zendframework-2.2.6/library/Zend/Di/Display/Console.php
--- zendframework-1.10.4/library/Zend/Di/Display/Console.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/Display/Console.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,178 @@
+addRuntimeClasses($runtimeClasses);
+ $console->render($di);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param null|Di $di
+ */
+ public function __construct(Di $di = null)
+ {
+ $this->di = ($di) ?: new Di;
+ }
+
+ /**
+ * @param string[] $runtimeClasses
+ */
+ public function addRuntimeClasses(array $runtimeClasses)
+ {
+ foreach ($runtimeClasses as $runtimeClass) {
+ $this->addRuntimeClass($runtimeClass);
+ }
+ }
+
+ /**
+ * @param string $runtimeClass
+ */
+ public function addRuntimeClass($runtimeClass)
+ {
+ $this->runtimeClasses[] = $runtimeClass;
+ }
+
+ public function render()
+ {
+
+ $knownClasses = array();
+
+ echo 'Definitions' . PHP_EOL . PHP_EOL;
+
+ foreach ($this->di->definitions() as $definition) {
+ $this->renderDefinition($definition);
+ foreach ($definition->getClasses() as $class) {
+ $knownClasses[] = $class;
+ $this->renderClassDefinition($definition, $class);
+ }
+ if (count($definition->getClasses()) == 0) {
+ echo PHP_EOL .' No Classes Found' . PHP_EOL . PHP_EOL;
+ }
+ }
+
+ if ($this->runtimeClasses)
+ echo ' Runtime classes:' . PHP_EOL;
+
+ $unknownRuntimeClasses = array_diff($this->runtimeClasses, $knownClasses);
+ foreach ($unknownRuntimeClasses as $runtimeClass) {
+ $definition = $this->di->definitions()->getDefinitionForClass($runtimeClass);
+ $this->renderClassDefinition($definition, $runtimeClass);
+ }
+
+ echo PHP_EOL . 'Instance Configuration Info:' . PHP_EOL;
+
+ echo PHP_EOL . ' Aliases:' . PHP_EOL;
+
+ $configuredTypes = array();
+ foreach ($this->di->instanceManager()->getAliases() as $alias => $class) {
+ echo ' ' . $alias . ' [type: ' . $class . ']' . PHP_EOL;
+ $configuredTypes[] = $alias;
+ }
+
+ echo PHP_EOL . ' Classes:' . PHP_EOL;
+
+ foreach ($this->di->instanceManager()->getClasses() as $class) {
+ echo ' ' . $class . PHP_EOL;
+ $configuredTypes[] = $class;
+ }
+
+ echo PHP_EOL . ' Configurations:' . PHP_EOL;
+
+ foreach ($configuredTypes as $type) {
+ $info = $this->di->instanceManager()->getConfig($type);
+ echo ' ' . $type . PHP_EOL;
+
+ if ($info['parameters']) {
+ echo ' parameters:' . PHP_EOL;
+ foreach ($info['parameters'] as $param => $value) {
+ echo ' ' . $param . ' = ' . $value . PHP_EOL;
+ }
+ }
+
+ if ($info['injections']) {
+ echo ' injections:' . PHP_EOL;
+ foreach ($info['injections'] as $injection => $value) {
+ var_dump($injection, $value);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * @param object $definition
+ */
+ protected function renderDefinition($definition)
+ {
+ echo ' Definition Type: ' . get_class($definition) . PHP_EOL;
+ $r = new \ReflectionClass($definition);
+ foreach ($r->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $property) {
+ $property->setAccessible(true);
+ echo ' internal property: ' . $property->getName();
+ $value = $property->getValue($definition);
+ if (is_object($value)) {
+ echo ' instance of ' . get_class($value);
+ } else {
+ echo ' = ' . $value;
+ }
+ echo PHP_EOL;
+ }
+ }
+
+ /**
+ * @param \Zend\Di\Definition\DefinitionInterface $definition
+ * @param string $class
+ */
+ protected function renderClassDefinition($definition, $class)
+ {
+ echo PHP_EOL . ' Parameters For Class: ' . $class . PHP_EOL;
+ foreach ($definition->getMethods($class) as $methodName => $methodIsRequired) {
+ foreach ($definition->getMethodParameters($class, $methodName) as $fqName => $pData) {
+ echo ' ' . $pData[0] . ' [type: ';
+ echo ($pData[1]) ? $pData[1] : 'scalar';
+ echo ($pData[2] === true && $methodIsRequired) ? ', required' : ', not required';
+ echo ', injection-method: ' . $methodName;
+ echo ' fq-name: ' . $fqName;
+ echo ']' . PHP_EOL;
+ }
+ }
+ echo PHP_EOL;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/Exception/CircularDependencyException.php zendframework-2.2.6/library/Zend/Di/Exception/CircularDependencyException.php
--- zendframework-1.10.4/library/Zend/Di/Exception/CircularDependencyException.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/Exception/CircularDependencyException.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,16 @@
+ array(), 'hashLong' => array());
+
+ /**
+ * Array of class aliases
+ * @var array key: alias, value: class
+ */
+ protected $aliases = array();
+
+ /**
+ * The template to use for housing configuration information
+ * @var array
+ */
+ protected $configurationTemplate = array(
+ /**
+ * alias|class => alias|class
+ * interface|abstract => alias|class|object
+ * name => value
+ */
+ 'parameters' => array(),
+ /**
+ * injection type => array of ordered method params
+ */
+ 'injections' => array(),
+ /**
+ * alias|class => bool
+ */
+ 'shared' => true
+ );
+
+ /**
+ * An array of instance configuration data
+ * @var array
+ */
+ protected $configurations = array();
+
+ /**
+ * An array of globally preferred implementations for interfaces/abstracts
+ * @var array
+ */
+ protected $typePreferences = array();
+
+ /**
+ * Does this instance manager have this shared instance
+ * @param string $classOrAlias
+ * @return bool
+ */
+ public function hasSharedInstance($classOrAlias)
+ {
+ return isset($this->sharedInstances[$classOrAlias]);
+ }
+
+ /**
+ * getSharedInstance()
+ */
+ public function getSharedInstance($classOrAlias)
+ {
+ return $this->sharedInstances[$classOrAlias];
+ }
+
+ /**
+ * Add shared instance
+ *
+ * @param object $instance
+ * @param string $classOrAlias
+ * @throws Exception\InvalidArgumentException
+ */
+ public function addSharedInstance($instance, $classOrAlias)
+ {
+ if (!is_object($instance)) {
+ throw new Exception\InvalidArgumentException('This method requires an object to be shared. Class or Alias given: ' . $classOrAlias);
+ }
+
+ $this->sharedInstances[$classOrAlias] = $instance;
+ }
+
+ /**
+ * hasSharedInstanceWithParameters()
+ *
+ * @param string $classOrAlias
+ * @param array $params
+ * @param bool $returnFastHashLookupKey
+ * @return bool|string
+ */
+ public function hasSharedInstanceWithParameters($classOrAlias, array $params, $returnFastHashLookupKey = false)
+ {
+ ksort($params);
+ $hashKey = $this->createHashForKeys($classOrAlias, array_keys($params));
+ if (isset($this->sharedInstancesWithParams['hashShort'][$hashKey])) {
+ $hashValue = $this->createHashForValues($classOrAlias, $params);
+ if (isset($this->sharedInstancesWithParams['hashLong'][$hashKey . '/' . $hashValue])) {
+ return ($returnFastHashLookupKey) ? $hashKey . '/' . $hashValue : true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * addSharedInstanceWithParameters()
+ *
+ * @param object $instance
+ * @param string $classOrAlias
+ * @param array $params
+ * @return void
+ */
+ public function addSharedInstanceWithParameters($instance, $classOrAlias, array $params)
+ {
+ ksort($params);
+ $hashKey = $this->createHashForKeys($classOrAlias, array_keys($params));
+ $hashValue = $this->createHashForValues($classOrAlias, $params);
+
+ if (!isset($this->sharedInstancesWithParams[$hashKey])
+ || !is_array($this->sharedInstancesWithParams[$hashKey])) {
+ $this->sharedInstancesWithParams[$hashKey] = array();
+ }
+
+ $this->sharedInstancesWithParams['hashShort'][$hashKey] = true;
+ $this->sharedInstancesWithParams['hashLong'][$hashKey . '/' . $hashValue] = $instance;
+ }
+
+ /**
+ * Retrieves an instance by its name and the parameters stored at its instantiation
+ *
+ * @param string $classOrAlias
+ * @param array $params
+ * @param bool|null $fastHashFromHasLookup
+ * @return object|bool false if no instance was found
+ */
+ public function getSharedInstanceWithParameters($classOrAlias, array $params, $fastHashFromHasLookup = null)
+ {
+ if ($fastHashFromHasLookup) {
+ return $this->sharedInstancesWithParams['hashLong'][$fastHashFromHasLookup];
+ }
+
+ ksort($params);
+ $hashKey = $this->createHashForKeys($classOrAlias, array_keys($params));
+ if (isset($this->sharedInstancesWithParams['hashShort'][$hashKey])) {
+ $hashValue = $this->createHashForValues($classOrAlias, $params);
+ if (isset($this->sharedInstancesWithParams['hashLong'][$hashKey . '/' . $hashValue])) {
+ return $this->sharedInstancesWithParams['hashLong'][$hashKey . '/' . $hashValue];
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Check for an alias
+ *
+ * @param string $alias
+ * @return bool
+ */
+ public function hasAlias($alias)
+ {
+ return (isset($this->aliases[$alias]));
+ }
+
+ /**
+ * Get aliases
+ *
+ * @return array
+ */
+ public function getAliases()
+ {
+ return $this->aliases;
+ }
+
+ /**
+ * getClassFromAlias()
+ *
+ * @param string
+ * @return string|bool
+ * @throws Exception\RuntimeException
+ */
+ public function getClassFromAlias($alias)
+ {
+ if (!isset($this->aliases[$alias])) {
+ return false;
+ }
+ $r = 0;
+ while (isset($this->aliases[$alias])) {
+ $alias = $this->aliases[$alias];
+ $r++;
+ if ($r > 100) {
+ throw new Exception\RuntimeException(
+ sprintf('Possible infinite recursion in DI alias! Max recursion of 100 levels reached at alias "%s".', $alias)
+ );
+ }
+ }
+
+ return $alias;
+ }
+
+ /**
+ * @param string $alias
+ * @return string|bool
+ * @throws Exception\RuntimeException
+ */
+ protected function getBaseAlias($alias)
+ {
+ if (!$this->hasAlias($alias)) {
+ return false;
+ }
+ $lastAlias = false;
+ $r = 0;
+ while (isset($this->aliases[$alias])) {
+ $lastAlias = $alias;
+ $alias = $this->aliases[$alias];
+ $r++;
+ if ($r > 100) {
+ throw new Exception\RuntimeException(
+ sprintf('Possible infinite recursion in DI alias! Max recursion of 100 levels reached at alias "%s".', $alias)
+ );
+ }
+ }
+
+ return $lastAlias;
+ }
+
+ /**
+ * Add alias
+ *
+ * @throws Exception\InvalidArgumentException
+ * @param string $alias
+ * @param string $class
+ * @param array $parameters
+ * @return void
+ */
+ public function addAlias($alias, $class, array $parameters = array())
+ {
+ if (!preg_match('#^[a-zA-Z0-9-_]+$#', $alias)) {
+ throw new Exception\InvalidArgumentException(
+ 'Aliases must be alphanumeric and can contain dashes and underscores only.'
+ );
+ }
+ $this->aliases[$alias] = $class;
+ if ($parameters) {
+ $this->setParameters($alias, $parameters);
+ }
+ }
+
+ /**
+ * Check for configuration
+ *
+ * @param string $aliasOrClass
+ * @return bool
+ */
+ public function hasConfig($aliasOrClass)
+ {
+ $key = ($this->hasAlias($aliasOrClass)) ? 'alias:' . $this->getBaseAlias($aliasOrClass) : $aliasOrClass;
+ if (!isset($this->configurations[$key])) {
+ return false;
+ }
+ if ($this->configurations[$key] === $this->configurationTemplate) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Sets configuration for a single alias/class
+ *
+ * @param string $aliasOrClass
+ * @param array $configuration
+ * @param bool $append
+ */
+ public function setConfig($aliasOrClass, array $configuration, $append = false)
+ {
+ $key = ($this->hasAlias($aliasOrClass)) ? 'alias:' . $this->getBaseAlias($aliasOrClass) : $aliasOrClass;
+ if (!isset($this->configurations[$key]) || !$append) {
+ $this->configurations[$key] = $this->configurationTemplate;
+ }
+ // Ignore anything but 'parameters' and 'injections'
+ $configuration = array(
+ 'parameters' => isset($configuration['parameters']) ? $configuration['parameters'] : array(),
+ 'injections' => isset($configuration['injections']) ? $configuration['injections'] : array(),
+ 'shared' => isset($configuration['shared']) ? $configuration['shared'] : true
+ );
+ $this->configurations[$key] = array_replace_recursive($this->configurations[$key], $configuration);
+ }
+
+ /**
+ * Get classes
+ *
+ * @return array
+ */
+ public function getClasses()
+ {
+ $classes = array();
+ foreach ($this->configurations as $name => $data) {
+ if (strpos($name, 'alias') === 0) continue;
+ $classes[] = $name;
+ }
+
+ return $classes;
+ }
+
+ /**
+ * @param string $aliasOrClass
+ * @return array
+ */
+ public function getConfig($aliasOrClass)
+ {
+ $key = ($this->hasAlias($aliasOrClass)) ? 'alias:' . $this->getBaseAlias($aliasOrClass) : $aliasOrClass;
+ if (isset($this->configurations[$key])) {
+ return $this->configurations[$key];
+ }
+
+ return $this->configurationTemplate;
+ }
+
+ /**
+ * setParameters() is a convenience method for:
+ * setConfig($type, array('parameters' => array(...)), true);
+ *
+ * @param string $aliasOrClass Alias or Class
+ * @param array $parameters Multi-dim array of parameters and their values
+ * @return void
+ */
+ public function setParameters($aliasOrClass, array $parameters)
+ {
+ $this->setConfig($aliasOrClass, array('parameters' => $parameters), true);
+ }
+
+ /**
+ * setInjections() is a convenience method for:
+ * setConfig($type, array('injections' => array(...)), true);
+ *
+ * @param string $aliasOrClass Alias or Class
+ * @param array $injections Multi-dim array of methods and their parameters
+ * @return void
+ */
+ public function setInjections($aliasOrClass, array $injections)
+ {
+ $this->setConfig($aliasOrClass, array('injections' => $injections), true);
+ }
+
+ /**
+ * Set shared
+ *
+ * @param string $aliasOrClass
+ * @param bool $isShared
+ * @return void
+ */
+ public function setShared($aliasOrClass, $isShared)
+ {
+ $this->setConfig($aliasOrClass, array('shared' => (bool) $isShared), true);
+ }
+
+ /**
+ * Check for type preferences
+ *
+ * @param string $interfaceOrAbstract
+ * @return bool
+ */
+ public function hasTypePreferences($interfaceOrAbstract)
+ {
+ $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract;
+
+ return (isset($this->typePreferences[$key]) && $this->typePreferences[$key]);
+ }
+
+ /**
+ * Set type preference
+ *
+ * @param string $interfaceOrAbstract
+ * @param array $preferredImplementations
+ * @return InstanceManager
+ */
+ public function setTypePreference($interfaceOrAbstract, array $preferredImplementations)
+ {
+ $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract;
+ foreach ($preferredImplementations as $preferredImplementation) {
+ $this->addTypePreference($key, $preferredImplementation);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Get type preferences
+ *
+ * @param string $interfaceOrAbstract
+ * @return array
+ */
+ public function getTypePreferences($interfaceOrAbstract)
+ {
+ $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract;
+ if (isset($this->typePreferences[$key])) {
+ return $this->typePreferences[$key];
+ }
+
+ return array();
+ }
+
+ /**
+ * Unset type preferences
+ *
+ * @param string $interfaceOrAbstract
+ * @return void
+ */
+ public function unsetTypePreferences($interfaceOrAbstract)
+ {
+ $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract;
+ unset($this->typePreferences[$key]);
+ }
+
+ /**
+ * Adds a type preference. A type preference is a redirection to a preferred alias or type when an abstract type
+ * $interfaceOrAbstract is requested
+ *
+ * @param string $interfaceOrAbstract
+ * @param string $preferredImplementation
+ * @return self
+ */
+ public function addTypePreference($interfaceOrAbstract, $preferredImplementation)
+ {
+ $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract;
+ if (!isset($this->typePreferences[$key])) {
+ $this->typePreferences[$key] = array();
+ }
+ $this->typePreferences[$key][] = $preferredImplementation;
+
+ return $this;
+ }
+
+ /**
+ * Removes a previously set type preference
+ *
+ * @param string $interfaceOrAbstract
+ * @param string $preferredType
+ * @return bool|self
+ */
+ public function removeTypePreference($interfaceOrAbstract, $preferredType)
+ {
+ $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract;
+ if (!isset($this->typePreferences[$key]) || !in_array($preferredType, $this->typePreferences[$key])) {
+ return false;
+ }
+ unset($this->typePreferences[$key][array_search($key, $this->typePreferences)]);
+
+ return $this;
+ }
+
+ /**
+ * @param string $classOrAlias
+ * @param string[] $paramKeys
+ * @return string
+ */
+ protected function createHashForKeys($classOrAlias, $paramKeys)
+ {
+ return $classOrAlias . ':' . implode('|', $paramKeys);
+ }
+
+ /**
+ * @param string $classOrAlias
+ * @param array $paramValues
+ * @return string
+ */
+ protected function createHashForValues($classOrAlias, $paramValues)
+ {
+ $hashValue = '';
+ foreach ($paramValues as $param) {
+ switch (gettype($param)) {
+ case 'object':
+ $hashValue .= spl_object_hash($param) . '|';
+ break;
+ case 'integer':
+ case 'string':
+ case 'boolean':
+ case 'NULL':
+ case 'double':
+ $hashValue .= $param . '|';
+ break;
+ case 'array':
+ $hashValue .= 'Array|';
+ break;
+ case 'resource':
+ $hashValue .= 'resource|';
+ break;
+ }
+ }
+
+ return $hashValue;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/LocatorInterface.php zendframework-2.2.6/library/Zend/Di/LocatorInterface.php
--- zendframework-1.10.4/library/Zend/Di/LocatorInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/LocatorInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,22 @@
+di = $di;
+ $this->definitions = $di->definitions();
+ $this->instanceManager = $di->instanceManager();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @return GeneratorInstance
+ */
+ public function get($name, array $params = array())
+ {
+ return parent::get($name, $params);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @return GeneratorInstance
+ */
+ public function newInstance($name, array $params = array(), $isShared = true)
+ {
+ $instance = parent::newInstance($name, $params, $isShared);
+
+ if ($instance instanceof GeneratorInstance) {
+ /* @var $instance GeneratorInstance */
+ $instance->setShared($isShared);
+
+ // When a callback is used, we don't know instance the class name.
+ // That's why we assume $name as the instance alias
+ if (null === $instance->getName()) {
+ $instance->setAlias($name);
+ }
+ }
+
+ return $instance;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @return GeneratorInstance
+ */
+ public function createInstanceViaConstructor($class, $params, $alias = null)
+ {
+ $callParameters = array();
+
+ if ($this->di->definitions->hasMethod($class, '__construct')
+ && (count($this->di->definitions->getMethodParameters($class, '__construct')) > 0)
+ ) {
+ $callParameters = $this->resolveMethodParameters($class, '__construct', $params, $alias, true, true);
+ $callParameters = $callParameters ?: array();
+ }
+
+ return new GeneratorInstance($class, $alias, '__construct', $callParameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @throws \Zend\Di\Exception\InvalidCallbackException
+ * @return GeneratorInstance
+ */
+ public function createInstanceViaCallback($callback, $params, $alias)
+ {
+ if (is_string($callback)) {
+ $callback = explode('::', $callback);
+ }
+
+ if (!is_callable($callback)) {
+ throw new Exception\InvalidCallbackException('An invalid constructor callback was provided');
+ }
+
+ if (!is_array($callback) || is_object($callback[0])) {
+ throw new Exception\InvalidCallbackException(
+ 'For purposes of service locator generation, constructor callbacks must refer to static methods only'
+ );
+ }
+
+ $class = $callback[0];
+ $method = $callback[1];
+
+ $callParameters = array();
+ if ($this->di->definitions->hasMethod($class, $method)) {
+ $callParameters = $this->resolveMethodParameters($class, $method, $params, $alias, true, true);
+ }
+
+ $callParameters = $callParameters ?: array();
+
+ return new GeneratorInstance(null, $alias, $callback, $callParameters);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function handleInjectionMethodForObject($class, $method, $params, $alias, $isRequired)
+ {
+ return array(
+ 'method' => $method,
+ 'params' => $this->resolveMethodParameters($class, $method, $params, $alias, $isRequired),
+ );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function resolveAndCallInjectionMethodForInstance($instance, $method, $params, $alias, $methodIsRequired, $methodClass = null)
+ {
+ if (!$instance instanceof GeneratorInstance) {
+ return parent::resolveAndCallInjectionMethodForInstance($instance, $method, $params, $alias, $methodIsRequired, $methodClass);
+ }
+
+ /* @var $instance GeneratorInstance */
+ $methodClass = $instance->getClass();
+ $callParameters = $this->resolveMethodParameters($methodClass, $method, $params, $alias, $methodIsRequired);
+
+ if ($callParameters !== false) {
+ $instance->addMethod(array(
+ 'method' => $method,
+ 'params' => $callParameters,
+ ));
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function getClass($instance)
+ {
+ if ($instance instanceof GeneratorInstance) {
+ /* @var $instance GeneratorInstance */
+
+ return $instance->getClass();
+ }
+
+ return parent::getClass($instance);
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/ServiceLocator/GeneratorInstance.php zendframework-2.2.6/library/Zend/Di/ServiceLocator/GeneratorInstance.php
--- zendframework-1.10.4/library/Zend/Di/ServiceLocator/GeneratorInstance.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/ServiceLocator/GeneratorInstance.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,196 @@
+class = $class;
+ $this->alias = $alias;
+ $this->constructor = $constructor;
+ $this->params = $params;
+ }
+
+ /**
+ * Retrieves the best available name for this instance (instance alias first then class name)
+ *
+ * @return string|null
+ */
+ public function getName()
+ {
+ return $this->alias ? $this->alias : $this->class;
+ }
+
+ /**
+ * Class of the instance. Null if class is unclear (such as when the instance is produced by a callback)
+ *
+ * @return string|null
+ */
+ public function getClass()
+ {
+ return $this->class;
+ }
+
+ /**
+ * Alias for the instance (if any)
+ *
+ * @return string|null
+ */
+ public function getAlias()
+ {
+ return $this->alias;
+ }
+
+ /**
+ * Set class name
+ *
+ * In the case of an instance created via a callback, we need to set the
+ * class name after creating the generator instance.
+ *
+ * @param string $class
+ * @return GeneratorInstance
+ */
+ public function setClass($class)
+ {
+ $this->class = $class;
+
+ return $this;
+ }
+
+ /**
+ * Set instance alias
+ *
+ * @param string $alias
+ * @return GeneratorInstance
+ */
+ public function setAlias($alias)
+ {
+ $this->alias = $alias;
+
+ return $this;
+ }
+
+ /**
+ * Get instantiator
+ *
+ * @return mixed constructor method name or callable responsible for generating instance
+ */
+ public function getConstructor()
+ {
+ return $this->constructor;
+ }
+
+ /**
+ * Parameters passed to the instantiator as an ordered list of parameters. Each parameter that refers to another
+ * instance fetched recursively is a GeneratorInstance itself
+ *
+ * @return array
+ */
+ public function getParams()
+ {
+ return $this->params;
+ }
+
+ /**
+ * Set methods
+ *
+ * @param array $methods
+ * @return GeneratorInstance
+ */
+ public function setMethods(array $methods)
+ {
+ $this->methods = $methods;
+
+ return $this;
+ }
+
+ /**
+ * Add a method called on the instance
+ *
+ * @param $method
+ * @return GeneratorInstance
+ */
+ public function addMethod($method)
+ {
+ $this->methods[] = $method;
+
+ return $this;
+ }
+
+ /**
+ * Retrieves a list of methods that are called on the instance in their call order. Each returned element has form
+ * array('method' => 'methodName', 'params' => array( ... ordered list of call parameters ... ), where every call
+ * parameter that is a recursively fetched instance is a GeneratorInstance itself
+ *
+ * @return array
+ */
+ public function getMethods()
+ {
+ return $this->methods;
+ }
+
+ /**
+ * @param bool $shared
+ */
+ public function setShared($shared)
+ {
+ $this->shared = (bool) $shared;
+ }
+
+ /**
+ * Retrieves whether the instance is shared or not
+ *
+ * @return bool
+ */
+ public function isShared()
+ {
+ return $this->shared;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/ServiceLocator/Generator.php zendframework-2.2.6/library/Zend/Di/ServiceLocator/Generator.php
--- zendframework-1.10.4/library/Zend/Di/ServiceLocator/Generator.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/ServiceLocator/Generator.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,342 @@
+injector = new DependencyInjectorProxy($injector);
+ }
+
+ /**
+ * Set the class name for the generated service locator container
+ *
+ * @param string $name
+ * @return Generator
+ */
+ public function setContainerClass($name)
+ {
+ $this->containerClass = $name;
+
+ return $this;
+ }
+
+ /**
+ * Set the namespace to use for the generated class file
+ *
+ * @param string $namespace
+ * @return Generator
+ */
+ public function setNamespace($namespace)
+ {
+ $this->namespace = $namespace;
+
+ return $this;
+ }
+
+ /**
+ * Construct, configure, and return a PHP class file code generation object
+ *
+ * Creates a Zend\Code\Generator\FileGenerator object that has
+ * created the specified class and service locator methods.
+ *
+ * @param null|string $filename
+ * @throws \Zend\Di\Exception\RuntimeException
+ * @return FileGenerator
+ */
+ public function getCodeGenerator($filename = null)
+ {
+ $injector = $this->injector;
+ $im = $injector->instanceManager();
+ $indent = ' ';
+ $aliases = $this->reduceAliases($im->getAliases());
+ $caseStatements = array();
+ $getters = array();
+ $definitions = $injector->definitions();
+
+ $fetched = array_unique(array_merge($definitions->getClasses(), $im->getAliases()));
+
+ foreach ($fetched as $name) {
+ $getter = $this->normalizeAlias($name);
+ $meta = $injector->get($name);
+ $params = $meta->getParams();
+
+ // Build parameter list for instantiation
+ foreach ($params as $key => $param) {
+ if (null === $param || is_scalar($param) || is_array($param)) {
+ $string = var_export($param, 1);
+ if (strstr($string, '::__set_state(')) {
+ throw new Exception\RuntimeException('Arguments in definitions may not contain objects');
+ }
+ $params[$key] = $string;
+ } elseif ($param instanceof GeneratorInstance) {
+ /* @var $param GeneratorInstance */
+ $params[$key] = sprintf('$this->%s()', $this->normalizeAlias($param->getName()));
+ } else {
+ $message = sprintf('Unable to use object arguments when building containers. Encountered with "%s", parameter of type "%s"', $name, get_class($param));
+ throw new Exception\RuntimeException($message);
+ }
+ }
+
+ // Strip null arguments from the end of the params list
+ $reverseParams = array_reverse($params, true);
+ foreach ($reverseParams as $key => $param) {
+ if ('NULL' === $param) {
+ unset($params[$key]);
+ continue;
+ }
+ break;
+ }
+
+ // Create instantiation code
+ $constructor = $meta->getConstructor();
+ if ('__construct' != $constructor) {
+ // Constructor callback
+ $callback = var_export($constructor, 1);
+ if (strstr($callback, '::__set_state(')) {
+ throw new Exception\RuntimeException('Unable to build containers that use callbacks requiring object instances');
+ }
+ if (count($params)) {
+ $creation = sprintf('$object = call_user_func(%s, %s);', $callback, implode(', ', $params));
+ } else {
+ $creation = sprintf('$object = call_user_func(%s);', $callback);
+ }
+ } else {
+ // Normal instantiation
+ $className = '\\' . ltrim($name, '\\');
+ $creation = sprintf('$object = new %s(%s);', $className, implode(', ', $params));
+ }
+
+ // Create method call code
+ $methods = '';
+ foreach ($meta->getMethods() as $methodData) {
+ if (!isset($methodData['name']) && !isset($methodData['method'])) {
+ continue;
+ }
+ $methodName = isset($methodData['name']) ? $methodData['name'] : $methodData['method'];
+ $methodParams = $methodData['params'];
+
+ // Create method parameter representation
+ foreach ($methodParams as $key => $param) {
+ if (null === $param || is_scalar($param) || is_array($param)) {
+ $string = var_export($param, 1);
+ if (strstr($string, '::__set_state(')) {
+ throw new Exception\RuntimeException('Arguments in definitions may not contain objects');
+ }
+ $methodParams[$key] = $string;
+ } elseif ($param instanceof GeneratorInstance) {
+ $methodParams[$key] = sprintf('$this->%s()', $this->normalizeAlias($param->getName()));
+ } else {
+ $message = sprintf('Unable to use object arguments when generating method calls. Encountered with class "%s", method "%s", parameter of type "%s"', $name, $methodName, get_class($param));
+ throw new Exception\RuntimeException($message);
+ }
+ }
+
+ // Strip null arguments from the end of the params list
+ $reverseParams = array_reverse($methodParams, true);
+ foreach ($reverseParams as $key => $param) {
+ if ('NULL' === $param) {
+ unset($methodParams[$key]);
+ continue;
+ }
+ break;
+ }
+
+ $methods .= sprintf("\$object->%s(%s);\n", $methodName, implode(', ', $methodParams));
+ }
+
+ // Generate caching statement
+ $storage = '';
+ if ($im->hasSharedInstance($name, $params)) {
+ $storage = sprintf("\$this->services['%s'] = \$object;\n", $name);
+ }
+
+ // Start creating getter
+ $getterBody = '';
+
+ // Create fetch of stored service
+ if ($im->hasSharedInstance($name, $params)) {
+ $getterBody .= sprintf("if (isset(\$this->services['%s'])) {\n", $name);
+ $getterBody .= sprintf("%sreturn \$this->services['%s'];\n}\n\n", $indent, $name);
+ }
+
+ // Creation and method calls
+ $getterBody .= sprintf("%s\n", $creation);
+ $getterBody .= $methods;
+
+ // Stored service
+ $getterBody .= $storage;
+
+ // End getter body
+ $getterBody .= "return \$object;\n";
+
+ $getterDef = new MethodGenerator();
+ $getterDef->setName($getter);
+ $getterDef->setBody($getterBody);
+ $getters[] = $getterDef;
+
+ // Get cases for case statements
+ $cases = array($name);
+ if (isset($aliases[$name])) {
+ $cases = array_merge($aliases[$name], $cases);
+ }
+
+ // Build case statement and store
+ $statement = '';
+ foreach ($cases as $value) {
+ $statement .= sprintf("%scase '%s':\n", $indent, $value);
+ }
+ $statement .= sprintf("%sreturn \$this->%s();\n", str_repeat($indent, 2), $getter);
+
+ $caseStatements[] = $statement;
+ }
+
+ // Build switch statement
+ $switch = sprintf("switch (%s) {\n%s\n", '$name', implode("\n", $caseStatements));
+ $switch .= sprintf("%sdefault:\n%sreturn parent::get(%s, %s);\n", $indent, str_repeat($indent, 2), '$name', '$params');
+ $switch .= "}\n\n";
+
+ // Build get() method
+ $nameParam = new ParameterGenerator();
+ $nameParam->setName('name');
+ $paramsParam = new ParameterGenerator();
+ $paramsParam->setName('params')
+ ->setType('array')
+ ->setDefaultValue(array());
+
+ $get = new MethodGenerator();
+ $get->setName('get');
+ $get->setParameters(array(
+ $nameParam,
+ $paramsParam,
+ ));
+ $get->setBody($switch);
+
+ // Create getters for aliases
+ $aliasMethods = array();
+ foreach ($aliases as $class => $classAliases) {
+ foreach ($classAliases as $alias) {
+ $aliasMethods[] = $this->getCodeGenMethodFromAlias($alias, $class);
+ }
+ }
+
+ // Create class code generation object
+ $container = new ClassGenerator();
+ $container->setName($this->containerClass)
+ ->setExtendedClass('ServiceLocator')
+ ->addMethodFromGenerator($get)
+ ->addMethods($getters)
+ ->addMethods($aliasMethods);
+
+ // Create PHP file code generation object
+ $classFile = new FileGenerator();
+ $classFile->setUse('Zend\Di\ServiceLocator')
+ ->setClass($container);
+
+ if (null !== $this->namespace) {
+ $classFile->setNamespace($this->namespace);
+ }
+
+ if (null !== $filename) {
+ $classFile->setFilename($filename);
+ }
+
+ return $classFile;
+ }
+
+ /**
+ * Reduces aliases
+ *
+ * Takes alias list and reduces it to a 2-dimensional array of
+ * class names pointing to an array of aliases that resolve to
+ * it.
+ *
+ * @param array $aliasList
+ * @return array
+ */
+ protected function reduceAliases(array $aliasList)
+ {
+ $reduced = array();
+ $aliases = array_keys($aliasList);
+ foreach ($aliasList as $alias => $service) {
+ if (in_array($service, $aliases)) {
+ do {
+ $service = $aliasList[$service];
+ } while (in_array($service, $aliases));
+ }
+ if (!isset($reduced[$service])) {
+ $reduced[$service] = array();
+ }
+ $reduced[$service][] = $alias;
+ }
+
+ return $reduced;
+ }
+
+ /**
+ * Create a PhpMethod code generation object named after a given alias
+ *
+ * @param string $alias
+ * @param string $class Class to which alias refers
+ * @return MethodGenerator
+ */
+ protected function getCodeGenMethodFromAlias($alias, $class)
+ {
+ $alias = $this->normalizeAlias($alias);
+ $method = new MethodGenerator();
+ $method->setName($alias);
+ $method->setBody(sprintf('return $this->get(\'%s\');', $class));
+
+ return $method;
+ }
+
+ /**
+ * Normalize an alias to a getter method name
+ *
+ * @param string $alias
+ * @return string
+ */
+ protected function normalizeAlias($alias)
+ {
+ $normalized = preg_replace('/[^a-zA-Z0-9]/', ' ', $alias);
+ $normalized = 'get' . str_replace(' ', '', ucwords($normalized));
+
+ return $normalized;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/ServiceLocatorInterface.php zendframework-2.2.6/library/Zend/Di/ServiceLocatorInterface.php
--- zendframework-1.10.4/library/Zend/Di/ServiceLocatorInterface.php 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/ServiceLocatorInterface.php 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,23 @@
+
+ * protected $map = array('foo' => 'getFoo');
+ *
+ *
+ * When encountered, the return value of that method will be used.
+ *
+ * Methods mapped in this way may expect a single, array argument, the
+ * $params passed to {@link get()}, if any.
+ *
+ * @var array
+ */
+ protected $map = array();
+
+ /**
+ * Registered services and cached values
+ *
+ * @var array
+ */
+ protected $services = array();
+
+ /**
+ * {@inheritDoc}
+ */
+ public function set($name, $service)
+ {
+ $this->services[$name] = $service;
+
+ return $this;
+ }
+
+ /**
+ * Retrieve a registered service
+ *
+ * Tests first if a value is registered for the service, and, if so,
+ * returns it.
+ *
+ * If the value returned is a non-object callback or closure, the return
+ * value is retrieved, stored, and returned. Parameters passed to the method
+ * are passed to the callback, but only on the first retrieval.
+ *
+ * If the service requested matches a method in the method map, the return
+ * value of that method is returned. Parameters are passed to the matching
+ * method.
+ *
+ * @param string $name
+ * @param array $params
+ * @return mixed
+ */
+ public function get($name, array $params = array())
+ {
+ if (!isset($this->services[$name])) {
+ if (!isset($this->map[$name])) {
+ return null;
+ }
+ $method = $this->map[$name];
+
+ return $this->$method($params);
+ }
+
+ $service = $this->services[$name];
+ if ($service instanceof Closure
+ || (!is_object($service) && is_callable($service))
+ ) {
+ $this->services[$name] = $service = call_user_func_array($service, $params);
+ }
+
+ return $service;
+ }
+}
diff -Nru zendframework-1.10.4/library/Zend/Di/TODO zendframework-2.2.6/library/Zend/Di/TODO
--- zendframework-1.10.4/library/Zend/Di/TODO 1970-01-01 00:00:00.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Di/TODO 2014-03-07 00:22:10.000000000 +0000
@@ -0,0 +1,103 @@
+TODO
+
+- Make compiler able to be definition-aware for purposes of derived class
+ information. Basically, allow attaching other Definition objects to a compiler
+ which it will then consult during compile() in order to flesh out dependency
+ details. Use case: a concrete DbTable object in a user library. In this case,
+ currently compiling against that object will provide no supertypes; having the
+ ability to attach a previously created definition would allow the compiler to
+ check against those and provide information as it locates it.
+
+- Integrate the EventManager into the Compiler and Code\Scanner in order to
+ allow attaching listeners to interesting events. Use cases include logging and
+ debugging during definition compilation.
+
+- Ability to provide both class properties and method-specific parameters via
+ configuration (which solves disambiguation when multiple methods specify the
+ same parameter names)
+
+ Proposed solution:
+
+ array(
+ 'properties' => array(
+ 'Zend\Foo\Bar' => array(
+ 'public' => true,
+ 'methods' => array(
+ '__construct' => array(
+ 'params' => array(
+ 'foo' => 'bar',
+ ),
+ 'class' => 'Some\Default\Class'
+ ),
+ 'setConfig' => array(
+ 'params' => array(
+ 'bar' => 'baz',
+ ),
+ ),
+ ),
+ ),
+ ),
+ )
+
+- Ability to pass configuration to a generated ServiceLocator
+
+- Skip optional arguments if not passed in configuration or part of definition
+ (current behavior is to raise an exception if *any* arguments are missing)
+
+- Scoped Containers:
+
+ Described here:
+ http://picocontainer.org/scopes.html
+
+ This is something that should be explored when we start using these containers
+ with ServiceLocators inside an application. While part of this has to do with
+ garbage collection in Java (something we need not worry with in PHP since there
+ is no persistent in-memory objects), the interesting use case would be having a
+ container cloned from another container that has more or less (a subset) of the
+ definitions available to the Container's newInstance() and get() facilities.
+
+- Better Strategy Management
+
+ Currently, the strategies for determining dependencies is hard coded into the
+ various definitions. Ideally, we'd be able to have configurable strategies
+ that the definitions can then utilize to do their job:
+
+ http://picocontainer.org/injection.html
+
+ We currently support constructor injection and setter injection (methods prefixed
+ by set[A-Z])
+
+- Annotation Parsing
+
+ Ideally, at some point, Zend\Code\Scanner will support Annotation parsing. When
+ this is possible, we'd like to be able to use @inject similar to
+ http://picocontainer.org/annotated-method-injection.html
+
+- SuperType Resolution
+
+ (partially done inside resolveMethodParameters with is_subtype_of())
+
+ If a class claims it needs a dependency of not an object, but a particular
+ interface, the ability to find an object that suits that dependency, either
+ through a concept called 'Preferred Objects' or via a 'Property'. The
+ following should be supported:
+
+ The compiler also needs to be aware of other definitions when looking up SuperTypes
+
+ $definition = new AggregateDefinition();
+ $definition->addDefinition('Zend\Controller\DiDefinition');
+
+ $compiler = new Compiler()
+ $compiler->addDefinition($definition);
+ $compiler->addCodeScanner(__DIR__ . 'My/Blog');
+ $array = $compiler->compile()
+ $definition->addDefinition(new ArrayDefinition($array));
+
+- Performance & Benchmarking
+
+ Zend\Code\Scanner- check memory usage, perhaps use gc_collect_cycles() to free memory,
+ we'll have to do this on large scan bases.
+
+ Benchmark compiler: reflection vs. code scanner
+
+
diff -Nru zendframework-1.10.4/library/Zend/Dojo/BuildLayer.php zendframework-2.2.6/library/Zend/Dojo/BuildLayer.php
--- zendframework-1.10.4/library/Zend/Dojo/BuildLayer.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/BuildLayer.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,536 +0,0 @@
- 'release',
- 'optimize' => 'shrinksafe',
- 'layerOptimize' => 'shrinksafe',
- 'copyTests' => false,
- 'loader' => 'default',
- 'cssOptimize' => 'comments',
- );
-
- /**
- * Associative array of module/path pairs for the build profile
- * @var array
- */
- protected $_profilePrefixes = array();
-
- /**
- * Zend_View reference
- * @var Zend_View_Interface
- */
- protected $_view;
-
- /**
- * Constructor
- *
- * @param array|Zend_Config $options
- * @return void
- * @throws Zend_Dojo_Exception for invalid option argument
- */
- public function __construct($options = null)
- {
- if (null !== $options) {
- if ($options instanceof Zend_Config) {
- $options = $options->toArray();
- } elseif (!is_array($options)) {
- require_once 'Zend/Dojo/Exception.php';
- throw new Zend_Dojo_Exception('Invalid options provided to constructor');
- }
- $this->setOptions($options);
- }
- }
-
- /**
- * Set options
- *
- * Proxies to any setter that matches an option key.
- *
- * @param array $options
- * @return Zend_Dojo_BuildLayer
- */
- public function setOptions(array $options)
- {
- $methods = get_class_methods($this);
- foreach ($options as $key => $value) {
- $method = 'set' . ucfirst($key);
- if (in_array($method, $methods)) {
- $this->$method($value);
- }
- }
- return $this;
- }
-
- /**
- * Set View object
- *
- * @param Zend_View_Interface $view
- * @return Zend_Dojo_BuildLayer
- */
- public function setView(Zend_View_Interface $view)
- {
- $this->_view = $view;
- return $this;
- }
-
- /**
- * Retrieve view object
- *
- * @return Zend_View_Interface|null
- */
- public function getView()
- {
- return $this->_view;
- }
-
- /**
- * Set dojo() view helper instance
- *
- * @param Zend_Dojo_View_Helper_Dojo_Container $helper
- * @return Zend_Dojo_BuildLayer
- */
- public function setDojoHelper(Zend_Dojo_View_Helper_Dojo_Container $helper)
- {
- $this->_dojo = $helper;
- return $this;
- }
-
- /**
- * Retrieve dojo() view helper instance
- *
- * Will retrieve it from the view object if not registered.
- *
- * @return Zend_Dojo_View_Helper_Dojo_Container
- * @throws Zend_Dojo_Exception if not registered and no view object found
- */
- public function getDojoHelper()
- {
- if (null === $this->_dojo) {
- if (null === ($view = $this->getView())) {
- require_once 'Zend/Dojo/Exception.php';
- throw new Zend_Dojo_Exception('View object not registered; cannot retrieve dojo helper');
- }
- $helper = $view->getHelper('dojo');
- $this->setDojoHelper($view->dojo());
- }
- return $this->_dojo;
- }
-
- /**
- * Set custom layer name; e.g. "custom.main"
- *
- * @param string $name
- * @return Zend_Dojo_BuildLayer
- */
- public function setLayerName($name)
- {
- if (!preg_match('/^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/i', $name)) {
- require_once 'Zend/Dojo/Exception.php';
- throw new Zend_Dojo_Exception('Invalid layer name provided; must be of form[a-z][a-z0-9_](\.[a-z][a-z0-9_])+');
- }
- $this->_layerName = $name;
- return $this;
- }
-
- /**
- * Retrieve custom layer name
- *
- * @return string|null
- */
- public function getLayerName()
- {
- return $this->_layerName;
- }
-
- /**
- * Set the path to the custom layer script
- *
- * Should be a path relative to dojo.js
- *
- * @param string $path
- * @return Zend_Dojo_BuildLayer
- */
- public function setLayerScriptPath($path)
- {
- $this->_layerScriptPath = (string) $path;
- return $this;
- }
-
- /**
- * Get custom layer script path
- *
- * @return string|null
- */
- public function getLayerScriptPath()
- {
- return $this->_layerScriptPath;
- }
-
- /**
- * Set flag indicating whether or not to consume JS aggregated in dojo()
- * view helper
- *
- * @param bool $flag
- * @return Zend_Dojo_BuildLayer
- */
- public function setConsumeJavascript($flag)
- {
- $this->_consumeJavascript = (bool) $flag;
- return $this;
- }
-
- /**
- * Get flag indicating whether or not to consume JS aggregated in dojo()
- * view helper
- *
- * @return bool
- */
- public function consumeJavascript()
- {
- return $this->_consumeJavascript;
- }
-
- /**
- * Set flag indicating whether or not to consume dojo.addOnLoad events
- * aggregated in dojo() view helper
- *
- * @param bool $flag
- * @return Zend_Dojo_BuildLayer
- */
- public function setConsumeOnLoad($flag)
- {
- $this->_consumeOnLoad = (bool) $flag;
- return $this;
- }
-
- /**
- * Get flag indicating whether or not to consume dojo.addOnLoad events aggregated in dojo() view helper
- *
- * @return bool
- */
- public function consumeOnLoad()
- {
- return $this->_consumeOnLoad;
- }
-
- /**
- * Set many build profile options at once
- *
- * @param array $options
- * @return Zend_Dojo_BuildLayer
- */
- public function setProfileOptions(array $options)
- {
- $this->_profileOptions += $options;
- return $this;
- }
-
- /**
- * Add many build profile options at once
- *
- * @param array $options
- * @return Zend_Dojo_BuildLayer
- */
- public function addProfileOptions(array $options)
- {
- $this->_profileOptions = $this->_profileOptions + $options;
- return $this;
- }
-
- /**
- * Add a single build profile option
- *
- * @param string $key
- * @param value $value
- * @return Zend_Dojo_BuildLayer
- */
- public function addProfileOption($key, $value)
- {
- $this->_profileOptions[(string) $key] = $value;
- return $this;
- }
-
- /**
- * Is a given build profile option set?
- *
- * @param string $key
- * @return bool
- */
- public function hasProfileOption($key)
- {
- return array_key_exists((string) $key, $this->_profileOptions);
- }
-
- /**
- * Retrieve a single build profile option
- *
- * Returns null if profile option does not exist.
- *
- * @param string $key
- * @return mixed
- */
- public function getProfileOption($key)
- {
- if ($this->hasProfileOption($key)) {
- return $this->_profileOptions[(string) $key];
- }
- return null;
- }
-
- /**
- * Get all build profile options
- *
- * @return array
- */
- public function getProfileOptions()
- {
- return $this->_profileOptions;
- }
-
- /**
- * Remove a build profile option
- *
- * @param string $name
- * @return Zend_Dojo_BuildLayer
- */
- public function removeProfileOption($name)
- {
- if ($this->hasProfileOption($name)) {
- unset($this->_profileOptions[(string) $name]);
- }
- return $this;
- }
-
- /**
- * Remove all build profile options
- *
- * @return Zend_Dojo_BuildLayer
- */
- public function clearProfileOptions()
- {
- $this->_profileOptions = array();
- return $this;
- }
-
- /**
- * Add a build profile dependency prefix
- *
- * If just the prefix is passed, sets path to "../$prefix".
- *
- * @param string $prefix
- * @param null|string $path
- * @return Zend_Dojo_BuildLayer
- */
- public function addProfilePrefix($prefix, $path = null)
- {
- if (null === $path) {
- $path = '../' . $prefix;
- }
- $this->_profilePrefixes[$prefix] = array($prefix, $path);
- return $this;
- }
-
- /**
- * Set multiple dependency prefixes for bulid profile
- *
- * @param array $prefixes
- * @return Zend_Dojo_BuildLayer
- */
- public function setProfilePrefixes(array $prefixes)
- {
- foreach ($prefixes as $prefix => $path) {
- $this->addProfilePrefix($prefix, $path);
- }
- return $this;
- }
-
- /**
- * Get build profile dependency prefixes
- *
- * @return array
- */
- public function getProfilePrefixes()
- {
- $layerName = $this->getLayerName();
- if (null !== $layerName) {
- $prefix = $this->_getPrefix($layerName);
- if (!array_key_exists($prefix, $this->_profilePrefixes)) {
- $this->addProfilePrefix($prefix);
- }
- }
- $view = $this->getView();
- if (!empty($view)) {
- $helper = $this->getDojoHelper();
- if ($helper) {
- $modules = $helper->getModules();
- foreach ($modules as $module) {
- $prefix = $this->_getPrefix($module);
- if (!array_key_exists($prefix, $this->_profilePrefixes)) {
- $this->addProfilePrefix($prefix);
- }
- }
- }
- }
- return $this->_profilePrefixes;
- }
-
- /**
- * Generate module layer script
- *
- * @return string
- */
- public function generateLayerScript()
- {
- $helper = $this->getDojoHelper();
- $layerName = $this->getLayerName();
- $modulePaths = $helper->getModulePaths();
- $modules = $helper->getModules();
- $onLoadActions = $helper->getOnLoadActions();
- $javascript = $helper->getJavascript();
-
- $content = 'dojo.provide("' . $layerName . '");' . "\n\n(function(){\n";
-
- foreach ($modulePaths as $module => $path) {
- $content .= sprintf("dojo.registerModulePath(\"%s\", \"%s\");\n", $module, $path);
- }
- foreach ($modules as $module) {
- $content .= sprintf("dojo.require(\"%s\");\n", $module);
- }
-
- if ($this->consumeOnLoad()) {
- foreach ($helper->getOnLoadActions() as $callback) {
- $content .= sprintf("dojo.addOnLoad(%s);\n", $callback);
- }
- }
- if ($this->consumeJavascript()) {
- $javascript = implode("\n", $helper->getJavascript());
- if (!empty($javascript)) {
- $content .= "\n" . $javascript . "\n";
- }
- }
-
- $content .= "})();";
-
- return $content;
- }
-
- /**
- * Generate build profile
- *
- * @return string
- */
- public function generateBuildProfile()
- {
- $profileOptions = $this->getProfileOptions();
- $layerName = $this->getLayerName();
- $layerScriptPath = $this->getLayerScriptPath();
- $profilePrefixes = $this->getProfilePrefixes();
-
- if (!array_key_exists('releaseName', $profileOptions)) {
- $profileOptions['releaseName'] = substr($layerName, 0, strpos($layerName, '.'));
- }
-
- $profile = $profileOptions;
- $profile['layers'] = array(array(
- 'name' => $layerScriptPath,
- 'layerDependencies' => array(),
- 'dependencies' => array($layerName),
- ));
- $profile['prefixes'] = array_values($profilePrefixes);
-
- return 'dependencies = ' . $this->_filterJsonProfileToJavascript($profile) . ';';
- }
-
- /**
- * Retrieve module prefix
- *
- * @param string $module
- * @return void
- */
- protected function _getPrefix($module)
- {
- $segments = explode('.', $module, 2);
- return $segments[0];
- }
-
- /**
- * Filter a JSON build profile to JavaScript
- *
- * @param string $profile
- * @return string
- */
- protected function _filterJsonProfileToJavascript($profile)
- {
- require_once 'Zend/Json.php';
- $profile = Zend_Json::encode($profile);
- $profile = preg_replace('/"([^"]*)":/', '$1:', $profile);
- $profile = preg_replace('/' . preg_quote('\\') . '/', '', $profile);
- return $profile;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Data.php zendframework-2.2.6/library/Zend/Dojo/Data.php
--- zendframework-1.10.4/library/Zend/Dojo/Data.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Data.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,563 +0,0 @@
-setIdentifier($identifier);
- }
- if (null !== $items) {
- $this->setItems($items);
- }
- if (null !== $label) {
- $this->setLabel($label);
- }
- }
-
- /**
- * Set the items to collect
- *
- * @param array|Traversable $items
- * @return Zend_Dojo_Data
- */
- public function setItems($items)
- {
- $this->clearItems();
- return $this->addItems($items);
- }
-
- /**
- * Set an individual item, optionally by identifier (overwrites)
- *
- * @param array|object $item
- * @param string|null $identifier
- * @return Zend_Dojo_Data
- */
- public function setItem($item, $id = null)
- {
- $item = $this->_normalizeItem($item, $id);
- $this->_items[$item['id']] = $item['data'];
- return $this;
- }
-
- /**
- * Add an individual item, optionally by identifier
- *
- * @param array|object $item
- * @param string|null $id
- * @return Zend_Dojo_Data
- */
- public function addItem($item, $id = null)
- {
- $item = $this->_normalizeItem($item, $id);
-
- if ($this->hasItem($item['id'])) {
- require_once 'Zend/Dojo/Exception.php';
- throw new Zend_Dojo_Exception('Overwriting items using addItem() is not allowed');
- }
-
- $this->_items[$item['id']] = $item['data'];
-
- return $this;
- }
-
- /**
- * Add multiple items at once
- *
- * @param array|Traversable $items
- * @return Zend_Dojo_Data
- */
- public function addItems($items)
- {
- if (!is_array($items) && (!is_object($items) || !($items instanceof Traversable))) {
- require_once 'Zend/Dojo/Exception.php';
- throw new Zend_Dojo_Exception('Only arrays and Traversable objects may be added to ' . __CLASS__);
- }
-
- foreach ($items as $item) {
- $this->addItem($item);
- }
-
- return $this;
- }
-
- /**
- * Get all items as an array
- *
- * Serializes items to arrays.
- *
- * @return array
- */
- public function getItems()
- {
- return $this->_items;
- }
-
- /**
- * Does an item with the given identifier exist?
- *
- * @param string|int $id
- * @return bool
- */
- public function hasItem($id)
- {
- return array_key_exists($id, $this->_items);
- }
-
- /**
- * Retrieve an item by identifier
- *
- * Item retrieved will be flattened to an array.
- *
- * @param string $id
- * @return array
- */
- public function getItem($id)
- {
- if (!$this->hasItem($id)) {
- return null;
- }
-
- return $this->_items[$id];
- }
-
- /**
- * Remove item by identifier
- *
- * @param string $id
- * @return Zend_Dojo_Data
- */
- public function removeItem($id)
- {
- if ($this->hasItem($id)) {
- unset($this->_items[$id]);
- }
-
- return $this;
- }
-
- /**
- * Remove all items at once
- *
- * @return Zend_Dojo_Data
- */
- public function clearItems()
- {
- $this->_items = array();
- return $this;
- }
-
-
- /**
- * Set identifier for item lookups
- *
- * @param string|int|null $identifier
- * @return Zend_Dojo_Data
- */
- public function setIdentifier($identifier)
- {
- if (null === $identifier) {
- $this->_identifier = null;
- } elseif (is_string($identifier)) {
- $this->_identifier = $identifier;
- } elseif (is_numeric($identifier)) {
- $this->_identifier = (int) $identifier;
- } else {
- require_once 'Zend/Dojo/Exception.php';
- throw new Zend_Dojo_Exception('Invalid identifier; please use a string or integer');
- }
-
- return $this;
- }
-
- /**
- * Retrieve current item identifier
- *
- * @return string|int|null
- */
- public function getIdentifier()
- {
- return $this->_identifier;
- }
-
-
- /**
- * Set label to use for displaying item associations
- *
- * @param string|null $label
- * @return Zend_Dojo_Data
- */
- public function setLabel($label)
- {
- if (null === $label) {
- $this->_label = null;
- } else {
- $this->_label = (string) $label;
- }
- return $this;
- }
-
- /**
- * Retrieve item association label
- *
- * @return string|null
- */
- public function getLabel()
- {
- return $this->_label;
- }
-
- /**
- * Set metadata by key or en masse
- *
- * @param string|array $spec
- * @param mixed $value
- * @return Zend_Dojo_Data
- */
- public function setMetadata($spec, $value = null)
- {
- if (is_string($spec) && (null !== $value)) {
- $this->_metadata[$spec] = $value;
- } elseif (is_array($spec)) {
- foreach ($spec as $key => $value) {
- $this->setMetadata($key, $value);
- }
- }
- return $this;
- }
-
- /**
- * Get metadata item or all metadata
- *
- * @param null|string $key Metadata key when pulling single metadata item
- * @return mixed
- */
- public function getMetadata($key = null)
- {
- if (null === $key) {
- return $this->_metadata;
- }
-
- if (array_key_exists($key, $this->_metadata)) {
- return $this->_metadata[$key];
- }
-
- return null;
- }
-
- /**
- * Clear individual or all metadata item(s)
- *
- * @param null|string $key
- * @return Zend_Dojo_Data
- */
- public function clearMetadata($key = null)
- {
- if (null === $key) {
- $this->_metadata = array();
- } elseif (array_key_exists($key, $this->_metadata)) {
- unset($this->_metadata[$key]);
- }
- return $this;
- }
-
- /**
- * Load object from array
- *
- * @param array $data
- * @return Zend_Dojo_Data
- */
- public function fromArray(array $data)
- {
- if (array_key_exists('identifier', $data)) {
- $this->setIdentifier($data['identifier']);
- }
- if (array_key_exists('label', $data)) {
- $this->setLabel($data['label']);
- }
- if (array_key_exists('items', $data) && is_array($data['items'])) {
- $this->setItems($data['items']);
- } else {
- $this->clearItems();
- }
- return $this;
- }
-
- /**
- * Load object from JSON
- *
- * @param string $json
- * @return Zend_Dojo_Data
- */
- public function fromJson($json)
- {
- if (!is_string($json)) {
- require_once 'Zend/Dojo/Exception.php';
- throw new Zend_Dojo_Exception('fromJson() expects JSON input');
- }
- require_once 'Zend/Json.php';
- $data = Zend_Json::decode($json);
- return $this->fromArray($data);
- }
-
- /**
- * Seralize entire data structure, including identifier and label, to array
- *
- * @return array
- */
- public function toArray()
- {
- if (null === ($identifier = $this->getIdentifier())) {
- require_once 'Zend/Dojo/Exception.php';
- throw new Zend_Dojo_Exception('Serialization requires that an identifier be present in the object; first call setIdentifier()');
- }
-
- $array = array(
- 'identifier' => $identifier,
- 'items' => array_values($this->getItems()),
- );
-
- $metadata = $this->getMetadata();
- if (!empty($metadata)) {
- foreach ($metadata as $key => $value) {
- $array[$key] = $value;
- }
- }
-
- if (null !== ($label = $this->getLabel())) {
- $array['label'] = $label;
- }
-
- return $array;
- }
-
- /**
- * Serialize to JSON (dojo.data format)
- *
- * @return string
- */
- public function toJson()
- {
- require_once 'Zend/Json.php';
- return Zend_Json::encode($this->toArray());
- }
-
- /**
- * Serialize to string (proxy to {@link toJson()})
- *
- * @return string
- */
- public function __toString()
- {
- return $this->toJson();
- }
-
- /**
- * ArrayAccess: does offset exist?
- *
- * @param string|int $offset
- * @return bool
- */
- public function offsetExists($offset)
- {
- return (null !== $this->getItem($offset));
- }
-
- /**
- * ArrayAccess: retrieve by offset
- *
- * @param string|int $offset
- * @return array
- */
- public function offsetGet($offset)
- {
- return $this->getItem($offset);
- }
-
- /**
- * ArrayAccess: set value by offset
- *
- * @param string $offset
- * @param array|object|null $value
- * @return void
- */
- public function offsetSet($offset, $value)
- {
- $this->setItem($value, $offset);
- }
-
- /**
- * ArrayAccess: unset value by offset
- *
- * @param string $offset
- * @return void
- */
- public function offsetUnset($offset)
- {
- $this->removeItem($offset);
- }
-
- /**
- * Iterator: get current value
- *
- * @return array
- */
- public function current()
- {
- return current($this->_items);
- }
-
- /**
- * Iterator: get current key
- *
- * @return string|int
- */
- public function key()
- {
- return key($this->_items);
- }
-
- /**
- * Iterator: get next item
- *
- * @return void
- */
- public function next()
- {
- return next($this->_items);
- }
-
- /**
- * Iterator: rewind to first value in collection
- *
- * @return void
- */
- public function rewind()
- {
- return reset($this->_items);
- }
-
- /**
- * Iterator: is item valid?
- *
- * @return bool
- */
- public function valid()
- {
- return (bool) $this->current();
- }
-
- /**
- * Countable: how many items are present
- *
- * @return int
- */
- public function count()
- {
- return count($this->_items);
- }
-
- /**
- * Normalize an item to attach to the collection
- *
- * @param array|object $item
- * @param string|int|null $id
- * @return array
- */
- protected function _normalizeItem($item, $id)
- {
- if (null === ($identifier = $this->getIdentifier())) {
- require_once 'Zend/Dojo/Exception.php';
- throw new Zend_Dojo_Exception('You must set an identifier prior to adding items');
- }
-
- if (!is_object($item) && !is_array($item)) {
- require_once 'Zend/Dojo/Exception.php';
- throw new Zend_Dojo_Exception('Only arrays and objects may be attached');
- }
-
- if (is_object($item)) {
- if (method_exists($item, 'toArray')) {
- $item = $item->toArray();
- } else {
- $item = get_object_vars($item);
- }
- }
-
- if ((null === $id) && !array_key_exists($identifier, $item)) {
- require_once 'Zend/Dojo/Exception.php';
- throw new Zend_Dojo_Exception('Item must contain a column matching the currently set identifier');
- } elseif (null === $id) {
- $id = $item[$identifier];
- } else {
- $item[$identifier] = $id;
- }
-
- return array(
- 'id' => $id,
- 'data' => $item,
- );
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Exception.php zendframework-2.2.6/library/Zend/Dojo/Exception.php
--- zendframework-1.10.4/library/Zend/Dojo/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,35 +0,0 @@
-_helper) {
- require_once 'Zend/Form/Decorator/Exception.php';
- throw new Zend_Form_Decorator_Exception('No view helper specified fo DijitContainer decorator');
- }
- return $this->_helper;
- }
-
- /**
- * Get element attributes
- *
- * @return array
- */
- public function getAttribs()
- {
- if (null === $this->_attribs) {
- $attribs = $this->getElement()->getAttribs();
- if (array_key_exists('dijitParams', $attribs)) {
- unset($attribs['dijitParams']);
- }
- $this->_attribs = $attribs;
- }
- return $this->_attribs;
- }
-
- /**
- * Get dijit option parameters
- *
- * @return array
- */
- public function getDijitParams()
- {
- if (null === $this->_dijitParams) {
- $attribs = $this->getElement()->getAttribs();
- if (array_key_exists('dijitParams', $attribs)) {
- $this->_dijitParams = $attribs['dijitParams'];
- } else {
- $this->_dijitParams = array();
- }
-
- $options = $this->getOptions();
- if (array_key_exists('dijitParams', $options)) {
- $this->_dijitParams = array_merge($this->_dijitParams, $options['dijitParams']);
- $this->removeOption('dijitParams');
- }
- }
-
- // Ensure we have a title param
- if (!array_key_exists('title', $this->_dijitParams)) {
- $this->_dijitParams['title'] = $this->getTitle();
- }
-
- return $this->_dijitParams;
- }
-
- /**
- * Get title
- *
- * @return string
- */
- public function getTitle()
- {
- if (null === $this->_title) {
- $title = null;
- if (null !== ($element = $this->getElement())) {
- if (method_exists($element, 'getLegend')) {
- $title = $element->getLegend();
- }
- }
- if (empty($title) && (null !== ($title = $this->getOption('legend')))) {
- $this->removeOption('legend');
- }
- if (empty($title) && (null !== ($title = $this->getOption('title')))) {
- $this->removeOption('title');
- }
-
- if (!empty($title)) {
- if (null !== ($translator = $element->getTranslator())) {
- $title = $translator->translate($title);
- }
- $this->_title = $title;
- }
- }
-
- return (empty($this->_title) ? '' : $this->_title);
- }
-
- /**
- * Render a dijit layout container
- *
- * Replaces $content entirely from currently set element.
- *
- * @param string $content
- * @return string
- */
- public function render($content)
- {
- $element = $this->getElement();
- $view = $element->getView();
- if (null === $view) {
- return $content;
- }
-
- $dijitParams = $this->getDijitParams();
- $attribs = array_merge($this->getAttribs(), $this->getOptions());
-
- if (array_key_exists('legend', $attribs)) {
- if (!array_key_exists('title', $dijitParams) || empty($dijitParams['title'])) {
- $dijitParams['title'] = $attribs['legend'];
- }
- unset($attribs['legend']);
- }
-
- $helper = $this->getHelper();
- $id = $element->getId() . '-' . $helper;
-
- if ($view->dojo()->hasDijit($id)) {
- trigger_error(sprintf('Duplicate dijit ID detected for id "%s; temporarily generating uniqid"', $id), E_USER_WARNING);
- $base = $id;
- do {
- $id = $base . '-' . uniqid();
- } while ($view->dojo()->hasDijit($id));
- }
-
- return $view->$helper($id, $content, $dijitParams, $attribs);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Decorator/DijitElement.php zendframework-2.2.6/library/Zend/Dojo/Form/Decorator/DijitElement.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Decorator/DijitElement.php 2010-01-25 20:25:57.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Decorator/DijitElement.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,193 +0,0 @@
-_attribs) {
- $this->_attribs = parent::getElementAttribs();
- if (array_key_exists('dijitParams', $this->_attribs)) {
- $this->setDijitParams($this->_attribs['dijitParams']);
- unset($this->_attribs['dijitParams']);
- }
- }
-
- return $this->_attribs;
- }
-
- /**
- * Set a single dijit option parameter
- *
- * @param string $key
- * @param mixed $value
- * @return Zend_Dojo_Form_Decorator_DijitContainer
- */
- public function setDijitParam($key, $value)
- {
- $this->_dijitParams[(string) $key] = $value;
- return $this;
- }
-
- /**
- * Set dijit option parameters
- *
- * @param array $params
- * @return Zend_Dojo_Form_Decorator_DijitContainer
- */
- public function setDijitParams(array $params)
- {
- $this->_dijitParams = array_merge($this->_dijitParams, $params);
- return $this;
- }
-
- /**
- * Retrieve a single dijit option parameter
- *
- * @param string $key
- * @return mixed|null
- */
- public function getDijitParam($key)
- {
- $this->getElementAttribs();
- $key = (string) $key;
- if (array_key_exists($key, $this->_dijitParams)) {
- return $this->_dijitParams[$key];
- }
-
- return null;
- }
-
- /**
- * Get dijit option parameters
- *
- * @return array
- */
- public function getDijitParams()
- {
- $this->getElementAttribs();
- return $this->_dijitParams;
- }
-
- /**
- * Render an element using a view helper
- *
- * Determine view helper from 'helper' option, or, if none set, from
- * the element type. Then call as
- * helper($element->getName(), $element->getValue(), $element->getAttribs())
- *
- * @param string $content
- * @return string
- * @throws Zend_Form_Decorator_Exception if element or view are not registered
- */
- public function render($content)
- {
- $element = $this->getElement();
- $view = $element->getView();
- if (null === $view) {
- require_once 'Zend/Form/Decorator/Exception.php';
- throw new Zend_Form_Decorator_Exception('DijitElement decorator cannot render without a registered view object');
- }
-
- $options = null;
- $helper = $this->getHelper();
- $separator = $this->getSeparator();
- $value = $this->getValue($element);
- $attribs = $this->getElementAttribs();
- $name = $element->getFullyQualifiedName();
-
- $dijitParams = $this->getDijitParams();
- $dijitParams['required'] = $element->isRequired();
-
- $id = $element->getId();
- if ($view->dojo()->hasDijit($id)) {
- trigger_error(sprintf('Duplicate dijit ID detected for id "%s; temporarily generating uniqid"', $id), E_USER_NOTICE);
- $base = $id;
- do {
- $id = $base . '-' . uniqid();
- } while ($view->dojo()->hasDijit($id));
- }
- $attribs['id'] = $id;
-
- if (array_key_exists('options', $attribs)) {
- $options = $attribs['options'];
- }
-
- $elementContent = $view->$helper($name, $value, $dijitParams, $attribs, $options);
- switch ($this->getPlacement()) {
- case self::APPEND:
- return $content . $separator . $elementContent;
- case self::PREPEND:
- return $elementContent . $separator . $content;
- default:
- return $elementContent;
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Decorator/DijitForm.php zendframework-2.2.6/library/Zend/Dojo/Form/Decorator/DijitForm.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Decorator/DijitForm.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Decorator/DijitForm.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,61 +0,0 @@
-getElement();
- $view = $element->getView();
- if (null === $view) {
- return $content;
- }
-
- $dijitParams = $this->getDijitParams();
- $attribs = array_merge($this->getAttribs(), $this->getOptions());
-
- return $view->form($element->getName(), $attribs, $content);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Decorator/SplitContainer.php zendframework-2.2.6/library/Zend/Dojo/Form/Decorator/SplitContainer.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Decorator/SplitContainer.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Decorator/SplitContainer.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,43 +0,0 @@
-addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator');
- }
-
- /**
- * Set the view object
- *
- * Ensures that the view object has the dojo view helper path set.
- *
- * @param Zend_View_Interface $view
- * @return Zend_Dojo_Form_Element_Dijit
- */
- public function setView(Zend_View_Interface $view = null)
- {
- if (null !== $view) {
- if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
- $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
- }
- }
- return parent::setView($view);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/Button.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/Button.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/Button.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/Button.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,121 +0,0 @@
- $options);
- }
-
- parent::__construct($spec, $options);
- }
-
- /**
- * Return label
- *
- * If no label is present, returns the currently set name.
- *
- * If a translator is present, returns the translated label.
- *
- * @return string
- */
- public function getLabel()
- {
- $value = parent::getLabel();
-
- if (null === $value) {
- $value = $this->getName();
- }
-
- if (null !== ($translator = $this->getTranslator())) {
- return $translator->translate($value);
- }
-
- return $value;
- }
-
- /**
- * Has this submit button been selected?
- *
- * @return bool
- */
- public function isChecked()
- {
- $value = $this->getValue();
-
- if (empty($value)) {
- return false;
- }
- if ($value != $this->getLabel()) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Default decorators
- *
- * Uses only 'DijitElement' and 'DtDdWrapper' decorators by default.
- *
- * @return void
- */
- public function loadDefaultDecorators()
- {
- if ($this->loadDefaultDecoratorsIsDisabled()) {
- return;
- }
-
- $decorators = $this->getDecorators();
- if (empty($decorators)) {
- $this->addDecorator('DijitElement')
- ->addDecorator('DtDdWrapper');
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/CheckBox.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/CheckBox.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/CheckBox.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/CheckBox.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,206 +0,0 @@
- '1',
- 'uncheckedValue' => '0',
- );
-
- /**
- * Value when checked
- * @var string
- */
- protected $_checkedValue = '1';
-
- /**
- * Value when not checked
- * @var string
- */
- protected $_uncheckedValue = '0';
-
- /**
- * Current value
- * @var string 0 or 1
- */
- protected $_value = '0';
-
- /**
- * Set options
- *
- * Intercept checked and unchecked values and set them early; test stored
- * value against checked and unchecked values after configuration.
- *
- * @param array $options
- * @return Zend_Form_Element_Checkbox
- */
- public function setOptions(array $options)
- {
- if (array_key_exists('checkedValue', $options)) {
- $this->setCheckedValue($options['checkedValue']);
- unset($options['checkedValue']);
- }
- if (array_key_exists('uncheckedValue', $options)) {
- $this->setUncheckedValue($options['uncheckedValue']);
- unset($options['uncheckedValue']);
- }
- parent::setOptions($options);
-
- $curValue = $this->getValue();
- $test = array($this->getCheckedValue(), $this->getUncheckedValue());
- if (!in_array($curValue, $test)) {
- $this->setValue($curValue);
- }
-
- return $this;
- }
-
- /**
- * Set value
- *
- * If value matches checked value, sets to that value, and sets the checked
- * flag to true.
- *
- * Any other value causes the unchecked value to be set as the current
- * value, and the checked flag to be set as false.
- *
- *
- * @param mixed $value
- * @return Zend_Form_Element_Checkbox
- */
- public function setValue($value)
- {
- if ($value == $this->getCheckedValue()) {
- parent::setValue($value);
- $this->checked = true;
- } else {
- parent::setValue($this->getUncheckedValue());
- $this->checked = false;
- }
- return $this;
- }
-
- /**
- * Set checked value
- *
- * @param string $value
- * @return Zend_Form_Element_Checkbox
- */
- public function setCheckedValue($value)
- {
- $this->_checkedValue = (string) $value;
- $this->options['checkedValue'] = $value;
- return $this;
- }
-
- /**
- * Get value when checked
- *
- * @return string
- */
- public function getCheckedValue()
- {
- return $this->_checkedValue;
- }
-
- /**
- * Set unchecked value
- *
- * @param string $value
- * @return Zend_Form_Element_Checkbox
- */
- public function setUncheckedValue($value)
- {
- $this->_uncheckedValue = (string) $value;
- $this->options['uncheckedValue'] = $value;
- return $this;
- }
-
- /**
- * Get value when not checked
- *
- * @return string
- */
- public function getUncheckedValue()
- {
- return $this->_uncheckedValue;
- }
-
- /**
- * Set checked flag
- *
- * @param bool $flag
- * @return Zend_Form_Element_Checkbox
- */
- public function setChecked($flag)
- {
- $this->checked = (bool) $flag;
- if ($this->checked) {
- $this->setValue($this->getCheckedValue());
- } else {
- $this->setValue($this->getUncheckedValue());
- }
- return $this;
- }
-
- /**
- * Get checked flag
- *
- * @return bool
- */
- public function isChecked()
- {
- return $this->checked;
- }
-}
-
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/ComboBox.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/ComboBox.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/ComboBox.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/ComboBox.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,186 +0,0 @@
-hasDijitParam('store')) {
- $this->dijitParams['store'] = array();
- }
- return $this->dijitParams['store'];
- }
-
- /**
- * Set datastore identifier
- *
- * @param string $identifier
- * @return Zend_Dojo_Form_Element_ComboBox
- */
- public function setStoreId($identifier)
- {
- $store = $this->getStoreInfo();
- $store['store'] = (string) $identifier;
- $this->setDijitParam('store', $store);
- return $this;
- }
-
- /**
- * Get datastore identifier
- *
- * @return string|null
- */
- public function getStoreId()
- {
- $store = $this->getStoreInfo();
- if (array_key_exists('store', $store)) {
- return $store['store'];
- }
- return null;
- }
-
- /**
- * Set datastore dijit type
- *
- * @param string $dojoType
- * @return Zend_Dojo_Form_Element_ComboBox
- */
- public function setStoreType($dojoType)
- {
- $store = $this->getStoreInfo();
- $store['type'] = (string) $dojoType;
- $this->setDijitParam('store', $store);
- return $this;
- }
-
- /**
- * Get datastore dijit type
- *
- * @return string|null
- */
- public function getStoreType()
- {
- $store = $this->getStoreInfo();
- if (array_key_exists('type', $store)) {
- return $store['type'];
- }
- return null;
- }
-
- /**
- * Set datastore parameters
- *
- * @param array $params
- * @return Zend_Dojo_Form_Element_ComboBox
- */
- public function setStoreParams(array $params)
- {
- $store = $this->getStoreInfo();
- $store['params'] = $params;
- $this->setDijitParam('store', $store);
- return $this;
- }
-
- /**
- * Get datastore params
- *
- * @return array
- */
- public function getStoreParams()
- {
- $store = $this->getStoreInfo();
- if (array_key_exists('params', $store)) {
- return $store['params'];
- }
- return array();
- }
-
- /**
- * Set autocomplete flag
- *
- * @param bool $flag
- * @return Zend_Dojo_Form_Element_ComboBox
- */
- public function setAutocomplete($flag)
- {
- $this->setDijitParam('autocomplete', (bool) $flag);
- return $this;
- }
-
- /**
- * Get autocomplete flag
- *
- * @return bool
- */
- public function getAutocomplete()
- {
- if (!$this->hasDijitParam('autocomplete')) {
- return false;
- }
- return $this->getDijitParam('autocomplete');
- }
-
- /**
- * Is the value valid?
- *
- * @param string $value
- * @param mixed $context
- * @return bool
- */
- public function isValid($value, $context = null)
- {
- $storeInfo = $this->getStoreInfo();
- if (!empty($storeInfo)) {
- $this->setRegisterInArrayValidator(false);
- }
- return parent::isValid($value, $context);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/CurrencyTextBox.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/CurrencyTextBox.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/CurrencyTextBox.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/CurrencyTextBox.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,120 +0,0 @@
-setDijitParam('currency', (string) $currency);
- return $this;
- }
-
- /**
- * Retrieve currency
- *
- * @return string|null
- */
- public function getCurrency()
- {
- return $this->getDijitParam('currency');
- }
-
- /**
- * Set currency symbol
- *
- * Casts to string, uppercases, and trims to three characters.
- *
- * @param string $symbol
- * @return Zend_Dojo_Form_Element_CurrencyTextBox
- */
- public function setSymbol($symbol)
- {
- $symbol = strtoupper((string) $symbol);
- $length = strlen($symbol);
- if (3 > $length) {
- require_once 'Zend/Form/Element/Exception.php';
- throw new Zend_Form_Element_Exception('Invalid symbol provided; please provide ISO 4217 alphabetic currency code');
- }
- if (3 < $length) {
- $symbol = substr($symbol, 0, 3);
- }
-
- $this->setConstraint('symbol', $symbol);
- return $this;
- }
-
- /**
- * Retrieve symbol
- *
- * @return string|null
- */
- public function getSymbol()
- {
- return $this->getConstraint('symbol');
- }
-
- /**
- * Set whether currency is fractional
- *
- * @param bool $flag
- * @return Zend_Dojo_Form_Element_CurrencyTextBox
- */
- public function setFractional($flag)
- {
- $this->setConstraint('fractional', (bool) $flag);
- return $this;
- }
-
- /**
- * Get whether or not to present fractional values
- *
- * @return bool
- */
- public function getFractional()
- {
- return ('true' == $this->getConstraint('fractional'));
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/DateTextBox.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/DateTextBox.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/DateTextBox.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/DateTextBox.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,214 +0,0 @@
-setConstraint('am,pm', (bool) $flag);
- return $this;
- }
-
- /**
- * Retrieve am,pm flag
- *
- * @return bool
- */
- public function getAmPm()
- {
- if (!$this->hasConstraint('am,pm')) {
- return false;
- }
- return ('true' ==$this->getConstraint('am,pm'));
- }
-
- /**
- * Set strict flag
- *
- * @param bool $strict
- * @return Zend_Dojo_Form_Element_DateTextBox
- */
- public function setStrict($flag)
- {
- $this->setConstraint('strict', (bool) $flag);
- return $this;
- }
-
- /**
- * Retrieve strict flag
- *
- * @return bool
- */
- public function getStrict()
- {
- if (!$this->hasConstraint('strict')) {
- return false;
- }
- return ('true' == $this->getConstraint('strict'));
- }
-
- /**
- * Set locale
- *
- * @param string $locale
- * @return Zend_Dojo_Form_Element_DateTextBox
- */
- public function setLocale($locale)
- {
- $this->setConstraint('locale', (string) $locale);
- return $this;
- }
-
- /**
- * Retrieve locale
- *
- * @return string|null
- */
- public function getLocale()
- {
- return $this->getConstraint('locale');
- }
-
- /**
- * Set date format pattern
- *
- * @param string $pattern
- * @return Zend_Dojo_Form_Element_NumberTextBox
- */
- public function setDatePattern($pattern)
- {
- $this->setConstraint('datePattern', (string) $pattern);
- return $this;
- }
-
- /**
- * Retrieve date format pattern
- *
- * @return string|null
- */
- public function getDatePattern()
- {
- return $this->getConstraint('datePattern');
- }
-
- /**
- * Set numeric format formatLength
- *
- * @see $_allowedFormatTypes
- * @param string $formatLength
- * @return Zend_Dojo_Form_Element_NumberTextBox
- */
- public function setFormatLength($formatLength)
- {
- $formatLength = strtolower($formatLength);
- if (!in_array($formatLength, $this->_allowedFormatTypes)) {
- require_once 'Zend/Form/Element/Exception.php';
- throw new Zend_Form_Element_Exception(sprintf('Invalid formatLength "%s" specified', $formatLength));
- }
-
- $this->setConstraint('formatLength', $formatLength);
- return $this;
- }
-
- /**
- * Retrieve formatLength
- *
- * @return string|null
- */
- public function getFormatLength()
- {
- return $this->getConstraint('formatLength');
- }
-
- /**
- * Set numeric format Selector
- *
- * @see $_allowedSelectorTypes
- * @param string $selector
- * @return Zend_Dojo_Form_Element_NumberTextBox
- */
- public function setSelector($selector)
- {
- $selector = strtolower($selector);
- if (!in_array($selector, $this->_allowedSelectorTypes)) {
- require_once 'Zend/Form/Element/Exception.php';
- throw new Zend_Form_Element_Exception(sprintf('Invalid Selector "%s" specified', $selector));
- }
-
- $this->setConstraint('selector', $selector);
- return $this;
- }
-
- /**
- * Retrieve selector
- *
- * @return string|null
- */
- public function getSelector()
- {
- return $this->getConstraint('selector');
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/DijitMulti.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/DijitMulti.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/DijitMulti.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/DijitMulti.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,304 +0,0 @@
-'.
- * @var string
- */
- protected $_separator = '
';
-
- /**
- * Which values are translated already?
- * @var array
- */
- protected $_translated = array();
-
- /**
- * Retrieve separator
- *
- * @return mixed
- */
- public function getSeparator()
- {
- return $this->_separator;
- }
-
- /**
- * Set separator
- *
- * @param mixed $separator
- * @return self
- */
- public function setSeparator($separator)
- {
- $this->_separator = $separator;
- return $this;
- }
-
- /**
- * Retrieve options array
- *
- * @return array
- */
- protected function _getMultiOptions()
- {
- if (null === $this->options || !is_array($this->options)) {
- $this->options = array();
- }
-
- return $this->options;
- }
-
- /**
- * Add an option
- *
- * @param string $option
- * @param string $value
- * @return Zend_Form_Element_Multi
- */
- public function addMultiOption($option, $value = '')
- {
- $option = (string) $option;
- $this->_getMultiOptions();
- if (!$this->_translateOption($option, $value)) {
- $this->options[$option] = $value;
- }
-
- return $this;
- }
-
- /**
- * Add many options at once
- *
- * @param array $options
- * @return Zend_Form_Element_Multi
- */
- public function addMultiOptions(array $options)
- {
- foreach ($options as $option => $value) {
- if (is_array($value)
- && array_key_exists('key', $value)
- && array_key_exists('value', $value)
- ) {
- $this->addMultiOption($value['key'], $value['value']);
- } else {
- $this->addMultiOption($option, $value);
- }
- }
- return $this;
- }
-
- /**
- * Set all options at once (overwrites)
- *
- * @param array $options
- * @return Zend_Form_Element_Multi
- */
- public function setMultiOptions(array $options)
- {
- $this->clearMultiOptions();
- return $this->addMultiOptions($options);
- }
-
- /**
- * Retrieve single multi option
- *
- * @param string $option
- * @return mixed
- */
- public function getMultiOption($option)
- {
- $option = (string) $option;
- $this->_getMultiOptions();
- if (isset($this->options[$option])) {
- $this->_translateOption($option, $this->options[$option]);
- return $this->options[$option];
- }
-
- return null;
- }
-
- /**
- * Retrieve options
- *
- * @return array
- */
- public function getMultiOptions()
- {
- $this->_getMultiOptions();
- foreach ($this->options as $option => $value) {
- $this->_translateOption($option, $value);
- }
- return $this->options;
- }
-
- /**
- * Remove a single multi option
- *
- * @param string $option
- * @return bool
- */
- public function removeMultiOption($option)
- {
- $option = (string) $option;
- $this->_getMultiOptions();
- if (isset($this->options[$option])) {
- unset($this->options[$option]);
- if (isset($this->_translated[$option])) {
- unset($this->_translated[$option]);
- }
- return true;
- }
-
- return false;
- }
-
- /**
- * Clear all options
- *
- * @return Zend_Form_Element_Multi
- */
- public function clearMultiOptions()
- {
- $this->options = array();
- $this->_translated = array();
- return $this;
- }
-
- /**
- * Set flag indicating whether or not to auto-register inArray validator
- *
- * @param bool $flag
- * @return Zend_Form_Element_Multi
- */
- public function setRegisterInArrayValidator($flag)
- {
- $this->_registerInArrayValidator = (bool) $flag;
- return $this;
- }
-
- /**
- * Get status of auto-register inArray validator flag
- *
- * @return bool
- */
- public function registerInArrayValidator()
- {
- return $this->_registerInArrayValidator;
- }
-
- /**
- * Is the value provided valid?
- *
- * Autoregisters InArray validator if necessary.
- *
- * @param string $value
- * @param mixed $context
- * @return bool
- */
- public function isValid($value, $context = null)
- {
- if ($this->registerInArrayValidator()) {
- if (!$this->getValidator('InArray')) {
- $options = $this->getMultiOptions();
- $this->addValidator(
- 'InArray',
- true,
- array(array_keys($options))
- );
- }
- }
- return parent::isValid($value, $context);
- }
-
- /**
- * Translate an option
- *
- * @param string $option
- * @param string $value
- * @return bool
- */
- protected function _translateOption($option, $value)
- {
- if (!isset($this->_translated[$option])) {
- $this->options[$option] = $this->_translateValue($value);
- if ($this->options[$option] === $value) {
- return false;
- }
- $this->_translated[$option] = true;
- return true;
- }
-
- return false;
- }
-
- /**
- * Translate a value
- *
- * @param array|string $value
- * @return array|string
- */
- protected function _translateValue($value)
- {
- if (is_array($value)) {
- foreach ($value as $key => $val) {
- $value[$key] = $this->_translateValue($val);
- }
- return $value;
- } else {
- if (null !== ($translator = $this->getTranslator())) {
- if ($translator->isTranslated($value)) {
- return $translator->translate($value);
- }
- }
- return $value;
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/Dijit.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/Dijit.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/Dijit.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/Dijit.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,189 +0,0 @@
-addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator');
- parent::__construct($spec, $options);
- }
-
- /**
- * Set a dijit parameter
- *
- * @param string $key
- * @param mixed $value
- * @return Zend_Dojo_Form_Element_Dijit
- */
- public function setDijitParam($key, $value)
- {
- $key = (string) $key;
- $this->dijitParams[$key] = $value;
- return $this;
- }
-
- /**
- * Set multiple dijit params at once
- *
- * @param array $params
- * @return Zend_Dojo_Form_Element_Dijit
- */
- public function setDijitParams(array $params)
- {
- $this->dijitParams = array_merge($this->dijitParams, $params);
- return $this;
- }
-
- /**
- * Does the given dijit parameter exist?
- *
- * @param string $key
- * @return bool
- */
- public function hasDijitParam($key)
- {
- return array_key_exists($key, $this->dijitParams);
- }
-
- /**
- * Get a single dijit parameter
- *
- * @param string $key
- * @return mixed
- */
- public function getDijitParam($key)
- {
- $key = (string) $key;
- if ($this->hasDijitParam($key)) {
- return $this->dijitParams[$key];
- }
- return null;
- }
-
- /**
- * Retrieve all dijit parameters
- *
- * @return array
- */
- public function getDijitParams()
- {
- return $this->dijitParams;
- }
-
- /**
- * Remove a single dijit parameter
- *
- * @param string $key
- * @return Zend_Dojo_Form_Element_Dijit
- */
- public function removeDijitParam($key)
- {
- $key = (string) $key;
- if (array_key_exists($key, $this->dijitParams)) {
- unset($this->dijitParams[$key]);
- }
- return $this;
- }
-
- /**
- * Clear all dijit parameters
- *
- * @return Zend_Dojo_Form_Element_Dijit
- */
- public function clearDijitParams()
- {
- $this->dijitParams = array();
- return $this;
- }
-
- /**
- * Load default decorators
- *
- * @return void
- */
- public function loadDefaultDecorators()
- {
- if ($this->loadDefaultDecoratorsIsDisabled()) {
- return;
- }
-
- $decorators = $this->getDecorators();
- if (empty($decorators)) {
- $this->addDecorator('DijitElement')
- ->addDecorator('Errors')
- ->addDecorator('Description', array('tag' => 'p', 'class' => 'description'))
- ->addDecorator('HtmlTag', array('tag' => 'dd'))
- ->addDecorator('Label', array('tag' => 'dt'));
- }
- }
-
- /**
- * Set the view object
- *
- * Ensures that the view object has the dojo view helper path set.
- *
- * @param Zend_View_Interface $view
- * @return Zend_Dojo_Form_Element_Dijit
- */
- public function setView(Zend_View_Interface $view = null)
- {
- if (null !== $view) {
- if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
- $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
- }
- }
- return parent::setView($view);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/Editor.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/Editor.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/Editor.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/Editor.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,599 +0,0 @@
-getCaptureEvents();
- if (in_array($event, $captureEvents)) {
- return $this;
- }
-
- $captureEvents[] = (string) $event;
- $this->setDijitParam('captureEvents', $captureEvents);
- return $this;
- }
-
- /**
- * Add multiple capture events
- *
- * @param array $events
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function addCaptureEvents(array $events)
- {
- foreach ($events as $event) {
- $this->addCaptureEvent($event);
- }
- return $this;
- }
-
- /**
- * Overwrite many capture events at once
- *
- * @param array $events
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function setCaptureEvents(array $events)
- {
- $this->clearCaptureEvents();
- $this->addCaptureEvents($events);
- return $this;
- }
-
- /**
- * Get all capture events
- *
- * @return array
- */
- public function getCaptureEvents()
- {
- if (!$this->hasDijitParam('captureEvents')) {
- return array();
- }
- return $this->getDijitParam('captureEvents');
- }
-
- /**
- * Is a given capture event registered?
- *
- * @param string $event
- * @return bool
- */
- public function hasCaptureEvent($event)
- {
- $captureEvents = $this->getCaptureEvents();
- return in_array((string) $event, $captureEvents);
- }
-
- /**
- * Remove a given capture event
- *
- * @param string $event
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function removeCaptureEvent($event)
- {
- $event = (string) $event;
- $captureEvents = $this->getCaptureEvents();
- if (false === ($index = array_search($event, $captureEvents))) {
- return $this;
- }
- unset($captureEvents[$index]);
- $this->setDijitParam('captureEvents', $captureEvents);
- return $this;
- }
-
- /**
- * Clear all capture events
- *
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function clearCaptureEvents()
- {
- return $this->removeDijitParam('captureEvents');
- }
-
- /**
- * Add a single event to the dijit
- *
- * @param string $event
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function addEvent($event)
- {
- $event = (string) $event;
- $events = $this->getEvents();
- if (in_array($event, $events)) {
- return $this;
- }
-
- $events[] = (string) $event;
- $this->setDijitParam('events', $events);
- return $this;
- }
-
- /**
- * Add multiple events
- *
- * @param array $events
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function addEvents(array $events)
- {
- foreach ($events as $event) {
- $this->addEvent($event);
- }
- return $this;
- }
-
- /**
- * Overwrite many events at once
- *
- * @param array $events
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function setEvents(array $events)
- {
- $this->clearEvents();
- $this->addEvents($events);
- return $this;
- }
-
- /**
- * Get all events
- *
- * @return array
- */
- public function getEvents()
- {
- if (!$this->hasDijitParam('events')) {
- return array();
- }
- return $this->getDijitParam('events');
- }
-
- /**
- * Is a given event registered?
- *
- * @param string $event
- * @return bool
- */
- public function hasEvent($event)
- {
- $events = $this->getEvents();
- return in_array((string) $event, $events);
- }
-
- /**
- * Remove a given event
- *
- * @param string $event
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function removeEvent($event)
- {
- $events = $this->getEvents();
- if (false === ($index = array_search($event, $events))) {
- return $this;
- }
- unset($events[$index]);
- $this->setDijitParam('events', $events);
- return $this;
- }
-
- /**
- * Clear all events
- *
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function clearEvents()
- {
- return $this->removeDijitParam('events');
- }
-
- /**
- * Add a single editor plugin
- *
- * @param string $plugin
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function addPlugin($plugin)
- {
- $plugin = (string) $plugin;
- $plugins = $this->getPlugins();
- if (in_array($plugin, $plugins)) {
- return $this;
- }
-
- $plugins[] = (string) $plugin;
- $this->setDijitParam('plugins', $plugins);
- return $this;
- }
-
- /**
- * Add multiple plugins
- *
- * @param array $plugins
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function addPlugins(array $plugins)
- {
- foreach ($plugins as $plugin) {
- $this->addPlugin($plugin);
- }
- return $this;
- }
-
- /**
- * Overwrite many plugins at once
- *
- * @param array $plugins
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function setPlugins(array $plugins)
- {
- $this->clearPlugins();
- $this->addPlugins($plugins);
- return $this;
- }
-
- /**
- * Get all plugins
- *
- * @return array
- */
- public function getPlugins()
- {
- if (!$this->hasDijitParam('plugins')) {
- return array();
- }
- return $this->getDijitParam('plugins');
- }
-
- /**
- * Is a given plugin registered?
- *
- * @param string $plugin
- * @return bool
- */
- public function hasPlugin($plugin)
- {
- $plugins = $this->getPlugins();
- return in_array((string) $plugin, $plugins);
- }
-
- /**
- * Remove a given plugin
- *
- * @param string $plugin
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function removePlugin($plugin)
- {
- $plugins = $this->getPlugins();
- if (false === ($index = array_search($plugin, $plugins))) {
- return $this;
- }
- unset($plugins[$index]);
- $this->setDijitParam('plugins', $plugins);
- return $this;
- }
-
- /**
- * Clear all plugins
- *
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function clearPlugins()
- {
- return $this->removeDijitParam('plugins');
- }
-
- /**
- * Set edit action interval
- *
- * @param int $interval
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function setEditActionInterval($interval)
- {
- return $this->setDijitParam('editActionInterval', (int) $interval);
- }
-
- /**
- * Get edit action interval; defaults to 3
- *
- * @return int
- */
- public function getEditActionInterval()
- {
- if (!$this->hasDijitParam('editActionInterval')) {
- $this->setEditActionInterval(3);
- }
- return $this->getDijitParam('editActionInterval');
- }
-
- /**
- * Set focus on load flag
- *
- * @param bool $flag
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function setFocusOnLoad($flag)
- {
- return $this->setDijitParam('focusOnLoad', (bool) $flag);
- }
-
- /**
- * Retrieve focus on load flag
- *
- * @return bool
- */
- public function getFocusOnLoad()
- {
- if (!$this->hasDijitParam('focusOnLoad')) {
- return false;
- }
- return $this->getDijitParam('focusOnLoad');
- }
-
- /**
- * Set editor height
- *
- * @param string|int $height
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function setHeight($height)
- {
- if (!preg_match('/^\d+(em|px|%)?$/i', $height)) {
- require_once 'Zend/Form/Element/Exception.php';
- throw new Zend_Form_Element_Exception('Invalid height provided; must be integer or CSS measurement');
- }
- if (!preg_match('/(em|px|%)$/', $height)) {
- $height .= 'px';
- }
- return $this->setDijitParam('height', $height);
- }
-
- /**
- * Retrieve height
- *
- * @return string
- */
- public function getHeight()
- {
- if (!$this->hasDijitParam('height')) {
- return '300px';
- }
- return $this->getDijitParam('height');
- }
-
- /**
- * Set whether or not to inherit parent's width
- *
- * @param bool $flag
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function setInheritWidth($flag)
- {
- return $this->setDijitParam('inheritWidth', (bool) $flag);
- }
-
- /**
- * Whether or not to inherit the parent's width
- *
- * @return bool
- */
- public function getInheritWidth()
- {
- if (!$this->hasDijitParam('inheritWidth')) {
- return false;
- }
- return $this->getDijitParam('inheritWidth');
- }
-
- /**
- * Set minimum height of editor
- *
- * @param string|int $minHeight
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function setMinHeight($minHeight)
- {
- if (!preg_match('/^\d+(em)?$/i', $minHeight)) {
- require_once 'Zend/Form/Element/Exception.php';
- throw new Zend_Form_Element_Exception('Invalid minHeight provided; must be integer or CSS measurement');
- }
- if ('em' != substr($minHeight, -2)) {
- $minHeight .= 'em';
- }
- return $this->setDijitParam('minHeight', $minHeight);
- }
-
- /**
- * Get minimum height of editor
- *
- * @return string
- */
- public function getMinHeight()
- {
- if (!$this->hasDijitParam('minHeight')) {
- return '1em';
- }
- return $this->getDijitParam('minHeight');
- }
-
- /**
- * Add a custom stylesheet
- *
- * @param string $styleSheet
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function addStyleSheet($styleSheet)
- {
- $stylesheets = $this->getStyleSheets();
- if (strstr($stylesheets, ';')) {
- $stylesheets = explode(';', $stylesheets);
- } elseif (!empty($stylesheets)) {
- $stylesheets = (array) $stylesheets;
- } else {
- $stylesheets = array();
- }
- if (!in_array($styleSheet, $stylesheets)) {
- $stylesheets[] = (string) $styleSheet;
- }
- return $this->setDijitParam('styleSheets', implode(';', $stylesheets));
- }
-
- /**
- * Add multiple custom stylesheets
- *
- * @param array $styleSheets
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function addStyleSheets(array $styleSheets)
- {
- foreach ($styleSheets as $styleSheet) {
- $this->addStyleSheet($styleSheet);
- }
- return $this;
- }
-
- /**
- * Overwrite all stylesheets
- *
- * @param array $styleSheets
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function setStyleSheets(array $styleSheets)
- {
- $this->clearStyleSheets();
- return $this->addStyleSheets($styleSheets);
- }
-
- /**
- * Get all stylesheets
- *
- * @return string
- */
- public function getStyleSheets()
- {
- if (!$this->hasDijitParam('styleSheets')) {
- return '';
- }
- return $this->getDijitParam('styleSheets');
- }
-
- /**
- * Is a given stylesheet registered?
- *
- * @param string $styleSheet
- * @return bool
- */
- public function hasStyleSheet($styleSheet)
- {
- $styleSheets = $this->getStyleSheets();
- $styleSheets = explode(';', $styleSheets);
- return in_array($styleSheet, $styleSheets);
- }
-
- /**
- * Remove a single stylesheet
- *
- * @param string $styleSheet
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function removeStyleSheet($styleSheet)
- {
- $styleSheets = $this->getStyleSheets();
- $styleSheets = explode(';', $styleSheets);
- if (false !== ($index = array_search($styleSheet, $styleSheets))) {
- unset($styleSheets[$index]);
- $this->setDijitParam('styleSheets', implode(';', $styleSheets));
- }
- return $this;
- }
-
- /**
- * Clear all stylesheets
- *
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function clearStyleSheets()
- {
- if ($this->hasDijitParam('styleSheets')) {
- $this->removeDijitParam('styleSheets');
- }
- return $this;
- }
-
- /**
- * Set update interval
- *
- * @param int $interval
- * @return Zend_Dojo_Form_Element_Editor
- */
- public function setUpdateInterval($interval)
- {
- return $this->setDijitParam('updateInterval', (int) $interval);
- }
-
- /**
- * Get update interval
- *
- * @return int
- */
- public function getUpdateInterval()
- {
- if (!$this->hasDijitParam('updateInterval')) {
- return 200;
- }
- return $this->getDijitParam('updateInterval');
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/FilteringSelect.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/FilteringSelect.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/FilteringSelect.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/FilteringSelect.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,48 +0,0 @@
-hasDijitParam('topDecoration')) {
- return $this->getDijitParam('topDecoration');
- }
- return array();
- }
-
- /**
- * Set dijit to use with top decoration
- *
- * @param mixed $dijit
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setTopDecorationDijit($dijit)
- {
- $decoration = $this->getTopDecoration();
- $decoration['dijit'] = (string) $dijit;
- $this->setDijitParam('topDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set container to use with top decoration
- *
- * @param mixed $container
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setTopDecorationContainer($container)
- {
- $decoration = $this->getTopDecoration();
- $decoration['container'] = (string) $container;
- $this->setDijitParam('topDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set labels to use with top decoration
- *
- * @param array $labels
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setTopDecorationLabels(array $labels)
- {
- $decoration = $this->getTopDecoration();
- $decoration['labels'] = array_values($labels);
- $this->setDijitParam('topDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set params to use with top decoration
- *
- * @param array $params
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setTopDecorationParams(array $params)
- {
- $decoration = $this->getTopDecoration();
- $decoration['params'] = $params;
- $this->setDijitParam('topDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set attribs to use with top decoration
- *
- * @param array $attribs
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setTopDecorationAttribs(array $attribs)
- {
- $decoration = $this->getTopDecoration();
- $decoration['attribs'] = $attribs;
- $this->setDijitParam('topDecoration', $decoration);
- return $this;
- }
-
- /**
- * Get bottom decoration data
- *
- * @return array
- */
- public function getBottomDecoration()
- {
- if ($this->hasDijitParam('bottomDecoration')) {
- return $this->getDijitParam('bottomDecoration');
- }
- return array();
- }
-
- /**
- * Set dijit to use with bottom decoration
- *
- * @param mixed $dijit
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setBottomDecorationDijit($dijit)
- {
- $decoration = $this->getBottomDecoration();
- $decoration['dijit'] = (string) $dijit;
- $this->setDijitParam('bottomDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set container to use with bottom decoration
- *
- * @param mixed $container
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setBottomDecorationContainer($container)
- {
- $decoration = $this->getBottomDecoration();
- $decoration['container'] = (string) $container;
- $this->setDijitParam('bottomDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set labels to use with bottom decoration
- *
- * @param array $labels
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setBottomDecorationLabels(array $labels)
- {
- $decoration = $this->getBottomDecoration();
- $decoration['labels'] = array_values($labels);
- $this->setDijitParam('bottomDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set params to use with bottom decoration
- *
- * @param array $params
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setBottomDecorationParams(array $params)
- {
- $decoration = $this->getBottomDecoration();
- $decoration['params'] = $params;
- $this->setDijitParam('bottomDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set attribs to use with bottom decoration
- *
- * @param array $attribs
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setBottomDecorationAttribs(array $attribs)
- {
- $decoration = $this->getBottomDecoration();
- $decoration['attribs'] = $attribs;
- $this->setDijitParam('bottomDecoration', $decoration);
- return $this;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/NumberSpinner.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/NumberSpinner.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/NumberSpinner.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/NumberSpinner.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,245 +0,0 @@
-setDijitParam('defaultTimeout', (int) $timeout);
- return $this;
- }
-
- /**
- * Retrieve defaultTimeout
- *
- * @return int|null
- */
- public function getDefaultTimeout()
- {
- return $this->getDijitParam('defaultTimeout');
- }
-
- /**
- * Set timeoutChangeRate
- *
- * @param int $rate
- * @return Zend_Dojo_Form_Element_NumberSpinner
- */
- public function setTimeoutChangeRate($rate)
- {
- $this->setDijitParam('timeoutChangeRate', (int) $rate);
- return $this;
- }
-
- /**
- * Retrieve timeoutChangeRate
- *
- * @return int|null
- */
- public function getTimeoutChangeRate()
- {
- return $this->getDijitParam('timeoutChangeRate');
- }
-
- /**
- * Set largeDelta
- *
- * @param int $delta
- * @return Zend_Dojo_Form_Element_NumberSpinner
- */
- public function setLargeDelta($delta)
- {
- $this->setDijitParam('largeDelta', (int) $delta);
- return $this;
- }
-
- /**
- * Retrieve largeDelta
- *
- * @return int|null
- */
- public function getLargeDelta()
- {
- return $this->getDijitParam('largeDelta');
- }
-
- /**
- * Set smallDelta
- *
- * @param int $delta
- * @return Zend_Dojo_Form_Element_NumberSpinner
- */
- public function setSmallDelta($delta)
- {
- $this->setDijitParam('smallDelta', (int) $delta);
- return $this;
- }
-
- /**
- * Retrieve smallDelta
- *
- * @return int|null
- */
- public function getSmallDelta()
- {
- return $this->getDijitParam('smallDelta');
- }
-
- /**
- * Set intermediateChanges flag
- *
- * @param bool $flag
- * @return Zend_Dojo_Form_Element_TextBox
- */
- public function setIntermediateChanges($flag)
- {
- $this->setDijitParam('intermediateChanges', (bool) $flag);
- return $this;
- }
-
- /**
- * Retrieve intermediateChanges flag
- *
- * @return bool
- */
- public function getIntermediateChanges()
- {
- if (!$this->hasDijitParam('intermediateChanges')) {
- return false;
- }
- return $this->getDijitParam('intermediateChanges');
- }
-
- /**
- * Set rangeMessage
- *
- * @param string $message
- * @return Zend_Dojo_Form_Element_NumberSpinner
- */
- public function setRangeMessage($message)
- {
- $this->setDijitParam('rangeMessage', (string) $message);
- return $this;
- }
-
- /**
- * Retrieve rangeMessage
- *
- * @return string|null
- */
- public function getRangeMessage()
- {
- return $this->getDijitParam('rangeMessage');
- }
-
- /**
- * Set minimum value
- *
- * @param int $value
- * @return Zend_Dojo_Form_Element_NumberSpinner
- */
- public function setMin($value)
- {
- $constraints = array();
- if ($this->hasDijitParam('constraints')) {
- $constraints = $this->getDijitParam('constraints');
- }
- $constraints['min'] = (int) $value;
- $this->setDijitParam('constraints', $constraints);
- return $this;
- }
-
- /**
- * Get minimum value
- *
- * @return null|int
- */
- public function getMin()
- {
- if (!$this->hasDijitParam('constraints')) {
- return null;
- }
- $constraints = $this->getDijitParam('constraints');
- if (!array_key_exists('min', $constraints)) {
- return null;
- }
- return $constraints['min'];
- }
-
- /**
- * Set maximum value
- *
- * @param int $value
- * @return Zend_Dojo_Form_Element_NumberSpinner
- */
- public function setMax($value)
- {
- $constraints = array();
- if ($this->hasDijitParam('constraints')) {
- $constraints = $this->getDijitParam('constraints');
- }
- $constraints['max'] = (int) $value;
- $this->setDijitParam('constraints', $constraints);
- return $this;
- }
-
- /**
- * Get maximum value
- *
- * @return null|int
- */
- public function getMax()
- {
- if (!$this->hasDijitParam('constraints')) {
- return null;
- }
- $constraints = $this->getDijitParam('constraints');
- if (!array_key_exists('max', $constraints)) {
- return null;
- }
- return $constraints['max'];
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/NumberTextBox.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/NumberTextBox.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/NumberTextBox.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/NumberTextBox.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,173 +0,0 @@
-setConstraint('locale', (string) $locale);
- return $this;
- }
-
- /**
- * Retrieve locale
- *
- * @return string|null
- */
- public function getLocale()
- {
- return $this->getConstraint('locale');
- }
-
- /**
- * Set numeric format pattern
- *
- * @param string $pattern
- * @return Zend_Dojo_Form_Element_NumberTextBox
- */
- public function setPattern($pattern)
- {
- $this->setConstraint('pattern', (string) $pattern);
- return $this;
- }
-
- /**
- * Retrieve numeric format pattern
- *
- * @return string|null
- */
- public function getPattern()
- {
- return $this->getConstraint('pattern');
- }
-
- /**
- * Set numeric format type
- *
- * @see $_allowedTypes
- * @param string $type
- * @return Zend_Dojo_Form_Element_NumberTextBox
- */
- public function setType($type)
- {
- $type = strtolower($type);
- if (!in_array($type, $this->_allowedTypes)) {
- require_once 'Zend/Form/Element/Exception.php';
- throw new Zend_Form_Element_Exception(sprintf('Invalid numeric type "%s" specified', $type));
- }
-
- $this->setConstraint('type', $type);
- return $this;
- }
-
- /**
- * Retrieve type
- *
- * @return string|null
- */
- public function getType()
- {
- return $this->getConstraint('type');
- }
-
- /**
- * Set decimal places
- *
- * @param int $places
- * @return Zend_Dojo_Form_Element_NumberTextBox
- */
- public function setPlaces($places)
- {
- $this->setConstraint('places', (int) $places);
- return $this;
- }
-
- /**
- * Retrieve decimal places
- *
- * @return int|null
- */
- public function getPlaces()
- {
- return $this->getConstraint('places');
- }
-
- /**
- * Set strict flag
- *
- * @param bool $strict
- * @return Zend_Dojo_Form_Element_NumberTextBox
- */
- public function setStrict($flag)
- {
- $this->setConstraint('strict', (bool) $flag);
- return $this;
- }
-
- /**
- * Retrieve strict flag
- *
- * @return bool
- */
- public function getStrict()
- {
- if (!$this->hasConstraint('strict')) {
- return false;
- }
- return ('true' == $this->getConstraint('strict'));
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/PasswordTextBox.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/PasswordTextBox.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/PasswordTextBox.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/PasswordTextBox.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,42 +0,0 @@
-setDijitParam('clickSelect', (bool) $flag);
- return $this;
- }
-
- /**
- * Retrieve clickSelect flag
- *
- * @return bool
- */
- public function getClickSelect()
- {
- if (!$this->hasDijitParam('clickSelect')) {
- return false;
- }
- return $this->getDijitParam('clickSelect');
- }
-
- /**
- * Set intermediateChanges flag
- *
- * @param bool $intermediateChanges
- * @return Zend_Dojo_Form_Element_TextBox
- */
- public function setIntermediateChanges($flag)
- {
- $this->setDijitParam('intermediateChanges', (bool) $flag);
- return $this;
- }
-
- /**
- * Retrieve intermediateChanges flag
- *
- * @return bool
- */
- public function getIntermediateChanges()
- {
- if (!$this->hasDijitParam('intermediateChanges')) {
- return false;
- }
- return $this->getDijitParam('intermediateChanges');
- }
-
- /**
- * Set showButtons flag
- *
- * @param bool $showButtons
- * @return Zend_Dojo_Form_Element_TextBox
- */
- public function setShowButtons($flag)
- {
- $this->setDijitParam('showButtons', (bool) $flag);
- return $this;
- }
-
- /**
- * Retrieve showButtons flag
- *
- * @return bool
- */
- public function getShowButtons()
- {
- if (!$this->hasDijitParam('showButtons')) {
- return false;
- }
- return $this->getDijitParam('showButtons');
- }
-
- /**
- * Set discreteValues
- *
- * @param int $value
- * @return Zend_Dojo_Form_Element_TextBox
- */
- public function setDiscreteValues($value)
- {
- $this->setDijitParam('discreteValues', (int) $value);
- return $this;
- }
-
- /**
- * Retrieve discreteValues
- *
- * @return int|null
- */
- public function getDiscreteValues()
- {
- return $this->getDijitParam('discreteValues');
- }
-
- /**
- * Set maximum
- *
- * @param int $value
- * @return Zend_Dojo_Form_Element_TextBox
- */
- public function setMaximum($value)
- {
- $this->setDijitParam('maximum', (int) $value);
- return $this;
- }
-
- /**
- * Retrieve maximum
- *
- * @return int|null
- */
- public function getMaximum()
- {
- return $this->getDijitParam('maximum');
- }
-
- /**
- * Set minimum
- *
- * @param int $value
- * @return Zend_Dojo_Form_Element_TextBox
- */
- public function setMinimum($value)
- {
- $this->setDijitParam('minimum', (int) $value);
- return $this;
- }
-
- /**
- * Retrieve minimum
- *
- * @return int|null
- */
- public function getMinimum()
- {
- return $this->getDijitParam('minimum');
- }
-
- /**
- * Set pageIncrement
- *
- * @param int $value
- * @return Zend_Dojo_Form_Element_TextBox
- */
- public function setPageIncrement($value)
- {
- $this->setDijitParam('pageIncrement', (int) $value);
- return $this;
- }
-
- /**
- * Retrieve pageIncrement
- *
- * @return int|null
- */
- public function getPageIncrement()
- {
- return $this->getDijitParam('pageIncrement');
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/SubmitButton.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/SubmitButton.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/SubmitButton.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/SubmitButton.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,42 +0,0 @@
-setDijitParam('lowercase', (bool) $flag);
- return $this;
- }
-
- /**
- * Retrieve lowercase flag
- *
- * @return bool
- */
- public function getLowercase()
- {
- if (!$this->hasDijitParam('lowercase')) {
- return false;
- }
- return $this->getDijitParam('lowercase');
- }
-
- /**
- * Set propercase flag
- *
- * @param bool $propercase
- * @return Zend_Dojo_Form_Element_TextBox
- */
- public function setPropercase($flag)
- {
- $this->setDijitParam('propercase', (bool) $flag);
- return $this;
- }
-
- /**
- * Retrieve propercase flag
- *
- * @return bool
- */
- public function getPropercase()
- {
- if (!$this->hasDijitParam('propercase')) {
- return false;
- }
- return $this->getDijitParam('propercase');
- }
-
- /**
- * Set uppercase flag
- *
- * @param bool $uppercase
- * @return Zend_Dojo_Form_Element_TextBox
- */
- public function setUppercase($flag)
- {
- $this->setDijitParam('uppercase', (bool) $flag);
- return $this;
- }
-
- /**
- * Retrieve uppercase flag
- *
- * @return bool
- */
- public function getUppercase()
- {
- if (!$this->hasDijitParam('uppercase')) {
- return false;
- }
- return $this->getDijitParam('uppercase');
- }
-
- /**
- * Set trim flag
- *
- * @param bool $trim
- * @return Zend_Dojo_Form_Element_TextBox
- */
- public function setTrim($flag)
- {
- $this->setDijitParam('trim', (bool) $flag);
- return $this;
- }
-
- /**
- * Retrieve trim flag
- *
- * @return bool
- */
- public function getTrim()
- {
- if (!$this->hasDijitParam('trim')) {
- return false;
- }
- return $this->getDijitParam('trim');
- }
-
- /**
- * Set maxLength
- *
- * @param int $length
- * @return Zend_Dojo_Form_Element_TextBox
- */
- public function setMaxLength($length)
- {
- $this->setDijitParam('maxLength', (int) $length);
- return $this;
- }
-
- /**
- * Retrieve maxLength
- *
- * @return int|null
- */
- public function getMaxLength()
- {
- return $this->getDijitParam('maxLength');
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/TimeTextBox.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/TimeTextBox.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/TimeTextBox.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/TimeTextBox.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,152 +0,0 @@
-setConstraint('timePattern', (string) $pattern);
- return $this;
- }
-
- /**
- * Retrieve time format pattern
- *
- * @return string|null
- */
- public function getTimePattern()
- {
- return $this->getConstraint('timePattern');
- }
-
- /**
- * Set clickableIncrement
- *
- * @param string $format
- * @return Zend_Dojo_Form_Element_NumberTextBox
- */
- public function setClickableIncrement($format)
- {
- $format = (string) $format;
- $this->_validateIso8601($format);
- $this->setConstraint('clickableIncrement', $format);
- return $this;
- }
-
- /**
- * Retrieve clickableIncrement
- *
- * @return string|null
- */
- public function getClickableIncrement()
- {
- return $this->getConstraint('clickableIncrement');
- }
-
- /**
- * Set visibleIncrement
- *
- * @param string $format
- * @return Zend_Dojo_Form_Element_NumberTextBox
- */
- public function setVisibleIncrement($format)
- {
- $format = (string) $format;
- $this->_validateIso8601($format);
- $this->setConstraint('visibleIncrement', $format);
- return $this;
- }
-
- /**
- * Retrieve visibleIncrement
- *
- * @return string|null
- */
- public function getVisibleIncrement()
- {
- return $this->getConstraint('visibleIncrement');
- }
-
- /**
- * Set visibleRange
- *
- * @param string $format
- * @return Zend_Dojo_Form_Element_NumberTextBox
- */
- public function setVisibleRange($format)
- {
- $format = (string) $format;
- $this->_validateIso8601($format);
- $this->setConstraint('visibleRange', $format);
- return $this;
- }
-
- /**
- * Retrieve visibleRange
- *
- * @return string|null
- */
- public function getVisibleRange()
- {
- return $this->getConstraint('visibleRange');
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/ValidationTextBox.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/ValidationTextBox.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/ValidationTextBox.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/ValidationTextBox.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,218 +0,0 @@
-setDijitParam('invalidMessage', (string) $message);
- return $this;
- }
-
- /**
- * Retrieve invalidMessage
- *
- * @return string|null
- */
- public function getInvalidMessage()
- {
- return $this->getDijitParam('invalidMessage');
- }
-
- /**
- * Set promptMessage
- *
- * @param string $message
- * @return Zend_Dojo_Form_Element_ValidationTextBox
- */
- public function setPromptMessage($message)
- {
- $this->setDijitParam('promptMessage', (string) $message);
- return $this;
- }
-
- /**
- * Retrieve promptMessage
- *
- * @return string|null
- */
- public function getPromptMessage()
- {
- return $this->getDijitParam('promptMessage');
- }
-
- /**
- * Set regExp
- *
- * @param string $regexp
- * @return Zend_Dojo_Form_Element_ValidationTextBox
- */
- public function setRegExp($regexp)
- {
- $this->setDijitParam('regExp', (string) $regexp);
- return $this;
- }
-
- /**
- * Retrieve regExp
- *
- * @return string|null
- */
- public function getRegExp()
- {
- return $this->getDijitParam('regExp');
- }
-
- /**
- * Set an individual constraint
- *
- * @param string $key
- * @param mixed $value
- * @return Zend_Dojo_Form_Element_ValidationTextBox
- */
- public function setConstraint($key, $value)
- {
- $constraints = $this->getConstraints();
- $constraints[(string) $key] = $value;
- $this->setConstraints($constraints);
- return $this;
- }
-
- /**
- * Set validation constraints
- *
- * Refer to Dojo dijit.form.ValidationTextBox documentation for valid
- * structure.
- *
- * @param array $constraints
- * @return Zend_Dojo_Form_Element_ValidationTextBox
- */
- public function setConstraints(array $constraints)
- {
- array_walk_recursive($constraints, array($this, '_castBoolToString'));
- $this->setDijitParam('constraints', $constraints);
- return $this;
- }
-
- /**
- * Is the given constraint set?
- *
- * @param string $key
- * @return bool
- */
- public function hasConstraint($key)
- {
- $constraints = $this->getConstraints();
- return array_key_exists((string)$key, $constraints);
- }
-
- /**
- * Get an individual constraint
- *
- * @param string $key
- * @return mixed
- */
- public function getConstraint($key)
- {
- $key = (string) $key;
- if (!$this->hasConstraint($key)) {
- return null;
- }
- return $this->dijitParams['constraints'][$key];
- }
-
- /**
- * Get constraints
- *
- * @return array
- */
- public function getConstraints()
- {
- if ($this->hasDijitParam('constraints')) {
- return $this->getDijitParam('constraints');
- }
- return array();
- }
-
- /**
- * Remove a single constraint
- *
- * @param string $key
- * @return Zend_Dojo_Form_Element_ValidationTextBox
- */
- public function removeConstraint($key)
- {
- $key = (string) $key;
- if ($this->hasConstraint($key)) {
- unset($this->dijitParams['constraints'][$key]);
- }
- return $this;
- }
-
- /**
- * Clear all constraints
- *
- * @return Zend_Dojo_Form_Element_ValidationTextBox
- */
- public function clearConstraints()
- {
- return $this->removeDijitParam('constraints');
- }
-
- /**
- * Cast a boolean value to a string
- *
- * @param mixed $item
- * @param string $key
- * @return void
- */
- protected function _castBoolToString(&$item, $key)
- {
- if (is_bool($item)) {
- $item = ($item) ? 'true' : 'false';
- }
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/Element/VerticalSlider.php zendframework-2.2.6/library/Zend/Dojo/Form/Element/VerticalSlider.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/Element/VerticalSlider.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/Element/VerticalSlider.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,208 +0,0 @@
-hasDijitParam('leftDecoration')) {
- return $this->getDijitParam('leftDecoration');
- }
- return array();
- }
-
- /**
- * Set dijit to use with left decoration
- *
- * @param mixed $dijit
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setLeftDecorationDijit($dijit)
- {
- $decoration = $this->getLeftDecoration();
- $decoration['dijit'] = (string) $dijit;
- $this->setDijitParam('leftDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set container to use with left decoration
- *
- * @param mixed $container
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setLeftDecorationContainer($container)
- {
- $decoration = $this->getLeftDecoration();
- $decoration['container'] = (string) $container;
- $this->setDijitParam('leftDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set labels to use with left decoration
- *
- * @param array $labels
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setLeftDecorationLabels(array $labels)
- {
- $decoration = $this->getLeftDecoration();
- $decoration['labels'] = array_values($labels);
- $this->setDijitParam('leftDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set params to use with left decoration
- *
- * @param array $params
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setLeftDecorationParams(array $params)
- {
- $decoration = $this->getLeftDecoration();
- $decoration['params'] = $params;
- $this->setDijitParam('leftDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set attribs to use with left decoration
- *
- * @param array $attribs
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setLeftDecorationAttribs(array $attribs)
- {
- $decoration = $this->getLeftDecoration();
- $decoration['attribs'] = $attribs;
- $this->setDijitParam('leftDecoration', $decoration);
- return $this;
- }
-
- /**
- * Get right decoration data
- *
- * @return array
- */
- public function getRightDecoration()
- {
- if ($this->hasDijitParam('rightDecoration')) {
- return $this->getDijitParam('rightDecoration');
- }
- return array();
- }
-
- /**
- * Set dijit to use with right decoration
- *
- * @param mixed $dijit
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setRightDecorationDijit($dijit)
- {
- $decoration = $this->getRightDecoration();
- $decoration['dijit'] = (string) $dijit;
- $this->setDijitParam('rightDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set container to use with right decoration
- *
- * @param mixed $container
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setRightDecorationContainer($container)
- {
- $decoration = $this->getRightDecoration();
- $decoration['container'] = (string) $container;
- $this->setDijitParam('rightDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set labels to use with right decoration
- *
- * @param array $labels
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setRightDecorationLabels(array $labels)
- {
- $decoration = $this->getRightDecoration();
- $decoration['labels'] = array_values($labels);
- $this->setDijitParam('rightDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set params to use with right decoration
- *
- * @param array $params
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setRightDecorationParams(array $params)
- {
- $decoration = $this->getRightDecoration();
- $decoration['params'] = $params;
- $this->setDijitParam('rightDecoration', $decoration);
- return $this;
- }
-
- /**
- * Set attribs to use with right decoration
- *
- * @param array $attribs
- * @return Zend_Dojo_Form_Element_HorizontalSlider
- */
- public function setRightDecorationAttribs(array $attribs)
- {
- $decoration = $this->getRightDecoration();
- $decoration['attribs'] = $attribs;
- $this->setDijitParam('rightDecoration', $decoration);
- return $this;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form/SubForm.php zendframework-2.2.6/library/Zend/Dojo/Form/SubForm.php
--- zendframework-1.10.4/library/Zend/Dojo/Form/SubForm.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form/SubForm.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,94 +0,0 @@
-addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
- ->addPrefixPath('Zend_Dojo_Form_Element', 'Zend/Dojo/Form/Element', 'element')
- ->addElementPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
- ->addDisplayGroupPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator')
- ->setDefaultDisplayGroupClass('Zend_Dojo_Form_DisplayGroup');
- parent::__construct($options);
- }
-
- /**
- * Load the default decorators
- *
- * @return void
- */
- public function loadDefaultDecorators()
- {
- if ($this->loadDefaultDecoratorsIsDisabled()) {
- return;
- }
-
- $decorators = $this->getDecorators();
- if (empty($decorators)) {
- $this->addDecorator('FormElements')
- ->addDecorator('HtmlTag', array('tag' => 'dl'))
- ->addDecorator('ContentPane');
- }
- }
-
- /**
- * Get view
- *
- * @return Zend_View_Interface
- */
- public function getView()
- {
- $view = parent::getView();
- if (!$this->_dojoViewPathRegistered) {
- if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
- $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
- }
- $this->_dojoViewPathRegistered = true;
- }
- return $view;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/Form.php zendframework-2.2.6/library/Zend/Dojo/Form.php
--- zendframework-1.10.4/library/Zend/Dojo/Form.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/Form.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,89 +0,0 @@
-addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
- ->addPrefixPath('Zend_Dojo_Form_Element', 'Zend/Dojo/Form/Element', 'element')
- ->addElementPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')
- ->addDisplayGroupPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator')
- ->setDefaultDisplayGroupClass('Zend_Dojo_Form_DisplayGroup');
- parent::__construct($options);
- }
-
- /**
- * Load the default decorators
- *
- * @return void
- */
- public function loadDefaultDecorators()
- {
- if ($this->loadDefaultDecoratorsIsDisabled()) {
- return;
- }
-
- $decorators = $this->getDecorators();
- if (empty($decorators)) {
- $this->addDecorator('FormElements')
- ->addDecorator('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form_dojo'))
- ->addDecorator('DijitForm');
- }
- }
-
- /**
- * Set the view object
- *
- * Ensures that the view object has the dojo view helper path set.
- *
- * @param Zend_View_Interface $view
- * @return Zend_Dojo_Form_Element_Dijit
- */
- public function setView(Zend_View_Interface $view = null)
- {
- if (null !== $view) {
- if (false === $view->getPluginLoader('helper')->getPaths('Zend_Dojo_View_Helper')) {
- $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
- }
- }
- return parent::setView($view);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Exception.php zendframework-2.2.6/library/Zend/Dojo/View/Exception.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Exception.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Exception.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,37 +0,0 @@
-_createLayoutContainer($id, $content, $params, $attribs);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/AccordionPane.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/AccordionPane.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/AccordionPane.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/AccordionPane.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,66 +0,0 @@
-_createLayoutContainer($id, $content, $params, $attribs);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/BorderContainer.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/BorderContainer.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/BorderContainer.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/BorderContainer.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,79 +0,0 @@
-_styleIsRegistered) {
- $this->view->headStyle()->appendStyle('html, body { height: 100%; width: 100%; margin: 0; padding: 0; }');
- $this->_styleIsRegistered = true;
- }
-
- // and now we create it:
- return $this->_createLayoutContainer($id, $content, $params, $attribs);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/Button.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/Button.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/Button.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/Button.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,68 +0,0 @@
-_prepareDijit($attribs, $params, 'element');
-
- return $this->view->formButton($id, $value, $attribs);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/CheckBox.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/CheckBox.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/CheckBox.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/CheckBox.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,100 +0,0 @@
-_prepareDijit($attribs, $params, 'element');
-
- // strip options so they don't show up in markup
- if (array_key_exists('options', $attribs)) {
- unset($attribs['options']);
- }
-
- // and now we create it:
- $html = '';
- if (!strstr($id, '[]')) {
- // hidden element for unchecked value
- $html .= $this->_renderHiddenElement($id, $checkboxInfo['uncheckedValue']);
- }
-
- // and final element
- $html .= $this->_createFormElement($id, $checkboxInfo['checkedValue'], $params, $attribs);
-
- return $html;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/ComboBox.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/ComboBox.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/ComboBox.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/ComboBox.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,151 +0,0 @@
-_renderStore($params['store'], $id))) {
- $params['store'] = $params['store']['store'];
- if (is_string($store)) {
- $html .= $store;
- }
- $html .= $this->_createFormElement($id, $value, $params, $attribs);
- return $html;
- }
- unset($params['store']);
- } elseif (array_key_exists('store', $params)) {
- if (array_key_exists('storeType', $params)) {
- $storeParams = array(
- 'store' => $params['store'],
- 'type' => $params['storeType'],
- );
- unset($params['storeType']);
- if (array_key_exists('storeParams', $params)) {
- $storeParams['params'] = $params['storeParams'];
- unset($params['storeParams']);
- }
- if (false !== ($store = $this->_renderStore($storeParams, $id))) {
- if (is_string($store)) {
- $html .= $store;
- }
- }
- }
- $html .= $this->_createFormElement($id, $value, $params, $attribs);
- return $html;
- }
-
- // do as normal select
- $attribs = $this->_prepareDijit($attribs, $params, 'element');
- return $this->view->formSelect($id, $value, $attribs, $options);
- }
-
- /**
- * Render data store element
- *
- * Renders to dojo view helper
- *
- * @param array $params
- * @return string|false
- */
- protected function _renderStore(array $params, $id)
- {
- if (!array_key_exists('store', $params) || !array_key_exists('type', $params)) {
- return false;
- }
-
- $this->dojo->requireModule($params['type']);
-
- $extraParams = array();
- $storeParams = array(
- 'dojoType' => $params['type'],
- 'jsId' => $params['store'],
- );
-
- if (array_key_exists('params', $params)) {
- $storeParams = array_merge($storeParams, $params['params']);
- $extraParams = $params['params'];
- }
-
- if ($this->_useProgrammatic()) {
- if (!$this->_useProgrammaticNoScript()) {
- require_once 'Zend/Json.php';
- $this->dojo->addJavascript('var ' . $storeParams['jsId'] . ";\n");
- $js = $storeParams['jsId'] . ' = '
- . 'new ' . $storeParams['dojoType'] . '('
- . Zend_Json::encode($extraParams)
- . ");\n";
- $js = "function() {\n$js\n}";
- $this->dojo->_addZendLoad($js);
- }
- return true;
- }
-
- return '_htmlAttribs($storeParams) . '>
';
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/ContentPane.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/ContentPane.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/ContentPane.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/ContentPane.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,66 +0,0 @@
-_createLayoutContainer($id, $content, $params, $attribs);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/CurrencyTextBox.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/CurrencyTextBox.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/CurrencyTextBox.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/CurrencyTextBox.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,68 +0,0 @@
-_createFormElement($id, $value, $params, $attribs);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/CustomDijit.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/CustomDijit.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/CustomDijit.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/CustomDijit.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,112 +0,0 @@
-_defaultDojoType)
- ) {
- require_once 'Zend/Dojo/View/Exception.php';
- throw new Zend_Dojo_View_Exception('No dojoType specified; cannot create dijit');
- } elseif (array_key_exists('dojoType', $params)) {
- $this->_dijit = $params['dojoType'];
- $this->_module = $params['dojoType'];
- unset($params['dojoType']);
- } else {
- $this->_dijit = $this->_defaultDojoType;
- $this->_module = $this->_defaultDojoType;
- }
-
- if (array_key_exists('rootNode', $params)) {
- $this->setRootNode($params['rootNode']);
- unset($params['rootNode']);
- }
-
- return $this->_createLayoutContainer($id, $value, $params, $attribs);
- }
-
- /**
- * Begin capturing content.
- *
- * Requires that either the {@link $_defaultDojotype} property is set, or
- * that you pass a value to the "dojoType" key of the $params argument.
- *
- * @param string $id
- * @param array $params
- * @param array $attribs
- * @return void
- */
- public function captureStart($id, array $params = array(), array $attribs = array())
- {
- if (!array_key_exists('dojoType', $params)
- && (null === $this->_defaultDojoType)
- ) {
- require_once 'Zend/Dojo/View/Exception.php';
- throw new Zend_Dojo_View_Exception('No dojoType specified; cannot create dijit');
- } elseif (array_key_exists('dojoType', $params)) {
- $this->_dijit = $params['dojoType'];
- $this->_module = $params['dojoType'];
- unset($params['dojoType']);
- } else {
- $this->_dijit = $this->_defaultDojoType;
- $this->_module = $this->_defaultDojoType;
- }
-
- return parent::captureStart($id, $params, $attribs);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/DateTextBox.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/DateTextBox.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/DateTextBox.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/DateTextBox.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,68 +0,0 @@
-_createFormElement($id, $value, $params, $attribs);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/DijitContainer.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/DijitContainer.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/DijitContainer.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/DijitContainer.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,92 +0,0 @@
-_captureLock)) {
- require_once 'Zend/Dojo/View/Exception.php';
- throw new Zend_Dojo_View_Exception(sprintf('Lock already exists for id "%s"', $id));
- }
-
- $this->_captureLock[$id] = true;
- $this->_captureInfo[$id] = array(
- 'params' => $params,
- 'attribs' => $attribs,
- );
-
- ob_start();
- return;
- }
-
- /**
- * Finish capturing content for layout container
- *
- * @param string $id
- * @return string
- */
- public function captureEnd($id)
- {
- if (!array_key_exists($id, $this->_captureLock)) {
- require_once 'Zend/Dojo/View/Exception.php';
- throw new Zend_Dojo_View_Exception(sprintf('No capture lock exists for id "%s"; nothing to capture', $id));
- }
-
- $content = ob_get_clean();
- extract($this->_captureInfo[$id]);
- unset($this->_captureLock[$id], $this->_captureInfo[$id]);
- return $this->_createLayoutContainer($id, $content, $params, $attribs);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/Dijit.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/Dijit.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/Dijit.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/Dijit.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,344 +0,0 @@
-dojo = $this->view->dojo();
- $this->dojo->enable();
- return $this;
- }
-
-
- /**
- * Get root node type
- *
- * @return string
- */
- public function getRootNode()
- {
- return $this->_rootNode;
- }
-
- /**
- * Set root node type
- *
- * @param string $value
- * @return Zend_Dojo_View_Helper_Dijit
- */
- public function setRootNode($value)
- {
- $this->_rootNode = $value;
- return $this;
- }
-
- /**
- * Whether or not to use declarative dijit creation
- *
- * @return bool
- */
- protected function _useDeclarative()
- {
- return Zend_Dojo_View_Helper_Dojo::useDeclarative();
- }
-
- /**
- * Whether or not to use programmatic dijit creation
- *
- * @return bool
- */
- protected function _useProgrammatic()
- {
- return Zend_Dojo_View_Helper_Dojo::useProgrammatic();
- }
-
- /**
- * Whether or not to use programmatic dijit creation w/o script creation
- *
- * @return bool
- */
- protected function _useProgrammaticNoScript()
- {
- return Zend_Dojo_View_Helper_Dojo::useProgrammaticNoScript();
- }
-
- /**
- * Create a layout container
- *
- * @param int $id
- * @param string $content
- * @param array $params
- * @param array $attribs
- * @param string|null $dijit
- * @return string
- */
- protected function _createLayoutContainer($id, $content, array $params, array $attribs, $dijit = null)
- {
- $attribs['id'] = $id;
- $attribs = $this->_prepareDijit($attribs, $params, 'layout', $dijit);
-
- $nodeType = $this->getRootNode();
- $html = '<' . $nodeType . $this->_htmlAttribs($attribs) . '>'
- . $content
- . "$nodeType>\n";
-
- return $html;
- }
-
- /**
- * Create HTML representation of a dijit form element
- *
- * @param string $id
- * @param string $value
- * @param array $params
- * @param array $attribs
- * @param string|null $dijit
- * @return string
- */
- public function _createFormElement($id, $value, array $params, array $attribs, $dijit = null)
- {
- if (!array_key_exists('id', $attribs)) {
- $attribs['id'] = $id;
- }
- $attribs['name'] = $id;
- $attribs['value'] = (string) $value;
- $attribs['type'] = $this->_elementType;
-
- $attribs = $this->_prepareDijit($attribs, $params, 'element', $dijit);
-
- $html = '_htmlAttribs($attribs)
- . $this->getClosingBracket();
- return $html;
- }
-
- /**
- * Merge attributes and parameters
- *
- * Also sets up requires
- *
- * @param array $attribs
- * @param array $params
- * @param string $type
- * @param string $dijit Dijit type to use (otherwise, pull from $_dijit)
- * @return array
- */
- protected function _prepareDijit(array $attribs, array $params, $type, $dijit = null)
- {
- $this->dojo->requireModule($this->_module);
-
- switch ($type) {
- case 'layout':
- $stripParams = array('id');
- break;
- case 'element':
- $stripParams = array('id', 'name', 'value', 'type');
- foreach (array('checked', 'disabled', 'readonly') as $attrib) {
- if (array_key_exists($attrib, $attribs)) {
- if ($attribs[$attrib]) {
- $attribs[$attrib] = $attrib;
- } else {
- unset($attribs[$attrib]);
- }
- }
- }
- break;
- case 'textarea':
- $stripParams = array('id', 'name', 'type', 'degrade');
- break;
- default:
- }
-
- foreach ($stripParams as $param) {
- if (array_key_exists($param, $params)) {
- unset($params[$param]);
- }
- }
-
- // Normalize constraints, if present
- foreach ($this->_jsonParams as $param) {
- if (array_key_exists($param, $params)) {
- require_once 'Zend/Json.php';
-
- if (is_array($params[$param])) {
- $values = array();
- foreach ($params[$param] as $key => $value) {
- if (!is_scalar($value)) {
- continue;
- }
- $values[$key] = $value;
- }
- } elseif (is_string($params[$param])) {
- $values = (array) $params[$param];
- } else {
- $values = array();
- }
- $values = Zend_Json::encode($values);
- if ($this->_useDeclarative()) {
- $values = str_replace('"', "'", $values);
- }
- $params[$param] = $values;
- }
- }
-
- $dijit = (null === $dijit) ? $this->_dijit : $dijit;
- if ($this->_useDeclarative()) {
- $attribs = array_merge($attribs, $params);
- if (isset($attribs['required'])) {
- $attribs['required'] = ($attribs['required']) ? 'true' : 'false';
- }
- $attribs['dojoType'] = $dijit;
- } elseif (!$this->_useProgrammaticNoScript()) {
- $this->_createDijit($dijit, $attribs['id'], $params);
- }
-
- return $attribs;
- }
-
- /**
- * Create a dijit programmatically
- *
- * @param string $dijit
- * @param string $id
- * @param array $params
- * @return void
- */
- protected function _createDijit($dijit, $id, array $params)
- {
- $params['dojoType'] = $dijit;
-
- array_walk_recursive($params, array($this, '_castBoolToString'));
-
- $this->dojo->setDijit($id, $params);
- }
-
- /**
- * Cast a boolean to a string value
- *
- * @param mixed $item
- * @param string $key
- * @return void
- */
- protected function _castBoolToString(&$item, $key)
- {
- if (!is_bool($item)) {
- return;
- }
- $item = ($item) ? "true" : "false";
- }
-
- /**
- * Render a hidden element to hold a value
- *
- * @param string $id
- * @param string|int|float $value
- * @return string
- */
- protected function _renderHiddenElement($id, $value)
- {
- $hiddenAttribs = array(
- 'name' => $id,
- 'value' => (string) $value,
- 'type' => 'hidden',
- );
- return '_htmlAttribs($hiddenAttribs) . $this->getClosingBracket();
- }
-
- /**
- * Create JS function for retrieving parent form
- *
- * @return void
- */
- protected function _createGetParentFormFunction()
- {
- $function =<<dojo->addJavascript($function);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/Dojo/Container.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/Dojo/Container.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/Dojo/Container.php 2010-03-31 17:38:19.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/Dojo/Container.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,1199 +0,0 @@
-view = $view;
- }
-
- /**
- * Enable dojo
- *
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function enable()
- {
- $this->_enabled = true;
- return $this;
- }
-
- /**
- * Disable dojo
- *
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function disable()
- {
- $this->_enabled = false;
- return $this;
- }
-
- /**
- * Is dojo enabled?
- *
- * @return bool
- */
- public function isEnabled()
- {
- return $this->_enabled;
- }
-
- /**
- * Add options for the Dojo Container to use
- *
- * @param array|Zend_Config Array or Zend_Config object with options to use
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function setOptions($options)
- {
- if($options instanceof Zend_Config) {
- $options = $options->toArray();
- }
-
- foreach($options as $key => $value) {
- $key = strtolower($key);
- switch($key) {
- case 'requiremodules':
- $this->requireModule($value);
- break;
- case 'modulepaths':
- foreach($value as $module => $path) {
- $this->registerModulePath($module, $path);
- }
- break;
- case 'layers':
- $value = (array) $value;
- foreach($value as $layer) {
- $this->addLayer($layer);
- }
- break;
- case 'cdnbase':
- $this->setCdnBase($value);
- break;
- case 'cdnversion':
- $this->setCdnVersion($value);
- break;
- case 'cdndojopath':
- $this->setCdnDojoPath($value);
- break;
- case 'localpath':
- $this->setLocalPath($value);
- break;
- case 'djconfig':
- $this->setDjConfig($value);
- break;
- case 'stylesheetmodules':
- $value = (array) $value;
- foreach($value as $module) {
- $this->addStylesheetModule($module);
- }
- break;
- case 'stylesheets':
- $value = (array) $value;
- foreach($value as $stylesheet) {
- $this->addStylesheet($stylesheet);
- }
- break;
- case 'registerdojostylesheet':
- $this->registerDojoStylesheet($value);
- break;
- }
- }
-
- return $this;
- }
-
- /**
- * Specify one or multiple modules to require
- *
- * @param string|array $modules
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function requireModule($modules)
- {
- if (!is_string($modules) && !is_array($modules)) {
- require_once 'Zend/Dojo/View/Exception.php';
- throw new Zend_Dojo_View_Exception('Invalid module name specified; must be a string or an array of strings');
- }
-
- $modules = (array) $modules;
-
- foreach ($modules as $mod) {
- if (!preg_match('/^[a-z][a-z0-9._-]+$/i', $mod)) {
- require_once 'Zend/Dojo/View/Exception.php';
- throw new Zend_Dojo_View_Exception(sprintf('Module name specified, "%s", contains invalid characters', (string) $mod));
- }
-
- if (!in_array($mod, $this->_modules)) {
- $this->_modules[] = $mod;
- }
- }
-
- return $this;
- }
-
- /**
- * Retrieve list of modules to require
- *
- * @return array
- */
- public function getModules()
- {
- return $this->_modules;
- }
-
- /**
- * Register a module path
- *
- * @param string $module The module to register a path for
- * @param string $path The path to register for the module
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function registerModulePath($module, $path)
- {
- $path = (string) $path;
- if (!in_array($module, $this->_modulePaths)) {
- $this->_modulePaths[$module] = $path;
- }
-
- return $this;
- }
-
- /**
- * List registered module paths
- *
- * @return array
- */
- public function getModulePaths()
- {
- return $this->_modulePaths;
- }
-
- /**
- * Add layer (custom build) path
- *
- * @param string $path
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function addLayer($path)
- {
- $path = (string) $path;
- if (!in_array($path, $this->_layers)) {
- $this->_layers[] = $path;
- }
-
- return $this;
- }
-
- /**
- * Get registered layers
- *
- * @return array
- */
- public function getLayers()
- {
- return $this->_layers;
- }
-
- /**
- * Remove a registered layer
- *
- * @param string $path
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function removeLayer($path)
- {
- $path = (string) $path;
- $layers = array_flip($this->_layers);
- if (array_key_exists($path, $layers)) {
- unset($layers[$path]);
- $this->_layers = array_keys($layers);
- }
- return $this;
- }
-
- /**
- * Clear all registered layers
- *
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function clearLayers()
- {
- $this->_layers = array();
- return $this;
- }
-
- /**
- * Set CDN base path
- *
- * @param string $url
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function setCdnBase($url)
- {
- $this->_cdnBase = (string) $url;
- return $this;
- }
-
- /**
- * Return CDN base URL
- *
- * @return string
- */
- public function getCdnBase()
- {
- return $this->_cdnBase;
- }
-
- /**
- * Use CDN, using version specified
- *
- * @param string $version
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function setCdnVersion($version = null)
- {
- $this->enable();
- if (preg_match('/^[1-9]\.[0-9](\.[0-9])?$/', $version)) {
- $this->_cdnVersion = $version;
- }
- return $this;
- }
-
- /**
- * Get CDN version
- *
- * @return string
- */
- public function getCdnVersion()
- {
- return $this->_cdnVersion;
- }
-
- /**
- * Set CDN path to dojo (relative to CDN base + version)
- *
- * @param string $path
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function setCdnDojoPath($path)
- {
- $this->_cdnDojoPath = (string) $path;
- return $this;
- }
-
- /**
- * Get CDN path to dojo (relative to CDN base + version)
- *
- * @return string
- */
- public function getCdnDojoPath()
- {
- return $this->_cdnDojoPath;
- }
-
- /**
- * Are we using the CDN?
- *
- * @return bool
- */
- public function useCdn()
- {
- return !$this->useLocalPath();
- }
-
- /**
- * Set path to local dojo
- *
- * @param string $path
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function setLocalPath($path)
- {
- $this->enable();
- $this->_localPath = (string) $path;
- return $this;
- }
-
- /**
- * Get local path to dojo
- *
- * @return string
- */
- public function getLocalPath()
- {
- return $this->_localPath;
- }
-
- /**
- * Are we using a local path?
- *
- * @return bool
- */
- public function useLocalPath()
- {
- return (null === $this->_localPath) ? false : true;
- }
-
- /**
- * Set Dojo configuration
- *
- * @param string $option
- * @param mixed $value
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function setDjConfig(array $config)
- {
- $this->_djConfig = $config;
- return $this;
- }
-
- /**
- * Set Dojo configuration option
- *
- * @param string $option
- * @param mixed $value
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function setDjConfigOption($option, $value)
- {
- $option = (string) $option;
- $this->_djConfig[$option] = $value;
- return $this;
- }
-
- /**
- * Retrieve dojo configuration values
- *
- * @return array
- */
- public function getDjConfig()
- {
- return $this->_djConfig;
- }
-
- /**
- * Get dojo configuration value
- *
- * @param string $option
- * @param mixed $default
- * @return mixed
- */
- public function getDjConfigOption($option, $default = null)
- {
- $option = (string) $option;
- if (array_key_exists($option, $this->_djConfig)) {
- return $this->_djConfig[$option];
- }
- return $default;
- }
-
- /**
- * Add a stylesheet by module name
- *
- * @param string $module
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function addStylesheetModule($module)
- {
- if (!preg_match('/^[a-z0-9]+\.[a-z0-9_-]+(\.[a-z0-9_-]+)*$/i', $module)) {
- require_once 'Zend/Dojo/View/Exception.php';
- throw new Zend_Dojo_View_Exception('Invalid stylesheet module specified');
- }
- if (!in_array($module, $this->_stylesheetModules)) {
- $this->_stylesheetModules[] = $module;
- }
- return $this;
- }
-
- /**
- * Get all stylesheet modules currently registered
- *
- * @return array
- */
- public function getStylesheetModules()
- {
- return $this->_stylesheetModules;
- }
-
- /**
- * Add a stylesheet
- *
- * @param string $path
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function addStylesheet($path)
- {
- $path = (string) $path;
- if (!in_array($path, $this->_stylesheets)) {
- $this->_stylesheets[] = (string) $path;
- }
- return $this;
- }
-
- /**
- * Register the dojo.css stylesheet?
- *
- * With no arguments, returns the status of the flag; with arguments, sets
- * the flag and returns the object.
- *
- * @param null|bool $flag
- * @return Zend_Dojo_View_Helper_Dojo_Container|bool
- */
- public function registerDojoStylesheet($flag = null)
- {
- if (null === $flag) {
- return $this->_registerDojoStylesheet;
- }
-
- $this->_registerDojoStylesheet = (bool) $flag;
- return $this;
- }
-
- /**
- * Retrieve registered stylesheets
- *
- * @return array
- */
- public function getStylesheets()
- {
- return $this->_stylesheets;
- }
-
- /**
- * Add a script to execute onLoad
- *
- * dojo.addOnLoad accepts:
- * - function name
- * - lambda
- *
- * @param string $callback Lambda
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function addOnLoad($callback)
- {
- if (!in_array($callback, $this->_onLoadActions, true)) {
- $this->_onLoadActions[] = $callback;
- }
- return $this;
- }
-
- /**
- * Prepend an onLoad event to the list of onLoad actions
- *
- * @param string $callback Lambda
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function prependOnLoad($callback)
- {
- if (!in_array($callback, $this->_onLoadActions, true)) {
- array_unshift($this->_onLoadActions, $callback);
- }
- return $this;
- }
-
- /**
- * Retrieve all registered onLoad actions
- *
- * @return array
- */
- public function getOnLoadActions()
- {
- return $this->_onLoadActions;
- }
-
- /**
- * Start capturing routines to run onLoad
- *
- * @return bool
- */
- public function onLoadCaptureStart()
- {
- if ($this->_captureLock) {
- require_once 'Zend/Dojo/View/Exception.php';
- throw new Zend_Dojo_View_Exception('Cannot nest onLoad captures');
- }
-
- $this->_captureLock = true;
- ob_start();
- return;
- }
-
- /**
- * Stop capturing routines to run onLoad
- *
- * @return bool
- */
- public function onLoadCaptureEnd()
- {
- $data = ob_get_clean();
- $this->_captureLock = false;
-
- $this->addOnLoad($data);
- return true;
- }
-
- /**
- * Add a programmatic dijit
- *
- * @param string $id
- * @param array $params
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function addDijit($id, array $params)
- {
- if (array_key_exists($id, $this->_dijits)) {
- require_once 'Zend/Dojo/View/Exception.php';
- throw new Zend_Dojo_View_Exception(sprintf('Duplicate dijit with id "%s" already registered', $id));
- }
-
- $this->_dijits[$id] = array(
- 'id' => $id,
- 'params' => $params,
- );
-
- return $this;
- }
-
- /**
- * Set a programmatic dijit (overwrites)
- *
- * @param string $id
- * @param array $params
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function setDijit($id, array $params)
- {
- $this->removeDijit($id);
- return $this->addDijit($id, $params);
- }
-
- /**
- * Add multiple dijits at once
- *
- * Expects an array of id => array $params pairs
- *
- * @param array $dijits
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function addDijits(array $dijits)
- {
- foreach ($dijits as $id => $params) {
- $this->addDijit($id, $params);
- }
- return $this;
- }
-
- /**
- * Set multiple dijits at once (overwrites)
- *
- * Expects an array of id => array $params pairs
- *
- * @param array $dijits
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function setDijits(array $dijits)
- {
- $this->clearDijits();
- return $this->addDijits($dijits);
- }
-
- /**
- * Is the given programmatic dijit already registered?
- *
- * @param string $id
- * @return bool
- */
- public function hasDijit($id)
- {
- return array_key_exists($id, $this->_dijits);
- }
-
- /**
- * Retrieve a dijit by id
- *
- * @param string $id
- * @return array|null
- */
- public function getDijit($id)
- {
- if ($this->hasDijit($id)) {
- return $this->_dijits[$id]['params'];
- }
- return null;
- }
-
- /**
- * Retrieve all dijits
- *
- * Returns dijits as an array of assoc arrays
- *
- * @return array
- */
- public function getDijits()
- {
- return array_values($this->_dijits);
- }
-
- /**
- * Remove a programmatic dijit if it exists
- *
- * @param string $id
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function removeDijit($id)
- {
- if (array_key_exists($id, $this->_dijits)) {
- unset($this->_dijits[$id]);
- }
-
- return $this;
- }
-
- /**
- * Clear all dijits
- *
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function clearDijits()
- {
- $this->_dijits = array();
- return $this;
- }
-
- /**
- * Render dijits as JSON structure
- *
- * @return string
- */
- public function dijitsToJson()
- {
- require_once 'Zend/Json.php';
- return Zend_Json::encode($this->getDijits());
- }
-
- /**
- * Create dijit loader functionality
- *
- * @return void
- */
- public function registerDijitLoader()
- {
- if (!$this->_dijitLoaderRegistered) {
- $js =<<requireModule('dojo.parser');
- $this->_addZendLoad($js);
- $this->addJavascript('var zendDijits = ' . $this->dijitsToJson() . ';');
- $this->_dijitLoaderRegistered = true;
- }
- }
-
- /**
- * Add arbitrary javascript to execute in dojo JS container
- *
- * @param string $js
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function addJavascript($js)
- {
- $js = preg_replace('/^\s*(.*?)\s*$/s', '$1', $js);
- if (!in_array(substr($js, -1), array(';', '}'))) {
- $js .= ';';
- }
-
- if (in_array($js, $this->_javascriptStatements)) {
- return $this;
- }
-
- $this->_javascriptStatements[] = $js;
- return $this;
- }
-
- /**
- * Return all registered javascript statements
- *
- * @return array
- */
- public function getJavascript()
- {
- return $this->_javascriptStatements;
- }
-
- /**
- * Clear arbitrary javascript stack
- *
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function clearJavascript()
- {
- $this->_javascriptStatements = array();
- return $this;
- }
-
- /**
- * Capture arbitrary javascript to include in dojo script
- *
- * @return void
- */
- public function javascriptCaptureStart()
- {
- if ($this->_captureLock) {
- require_once 'Zend/Dojo/View/Exception.php';
- throw new Zend_Dojo_View_Exception('Cannot nest captures');
- }
-
- $this->_captureLock = true;
- ob_start();
- return;
- }
-
- /**
- * Finish capturing arbitrary javascript to include in dojo script
- *
- * @return true
- */
- public function javascriptCaptureEnd()
- {
- $data = ob_get_clean();
- $this->_captureLock = false;
-
- $this->addJavascript($data);
- return true;
- }
-
- /**
- * String representation of dojo environment
- *
- * @return string
- */
- public function __toString()
- {
- if (!$this->isEnabled()) {
- return '';
- }
-
- $this->_isXhtml = $this->view->doctype()->isXhtml();
-
- if (Zend_Dojo_View_Helper_Dojo::useDeclarative()) {
- if (null === $this->getDjConfigOption('parseOnLoad')) {
- $this->setDjConfigOption('parseOnLoad', true);
- }
- }
-
- if (!empty($this->_dijits)) {
- $this->registerDijitLoader();
- }
-
- $html = $this->_renderStylesheets() . PHP_EOL
- . $this->_renderDjConfig() . PHP_EOL
- . $this->_renderDojoScriptTag() . PHP_EOL
- . $this->_renderLayers() . PHP_EOL
- . $this->_renderExtras();
- return $html;
- }
-
- /**
- * Retrieve local path to dojo resources for building relative paths
- *
- * @return string
- */
- protected function _getLocalRelativePath()
- {
- if (null === $this->_localRelativePath) {
- $localPath = $this->getLocalPath();
- $localPath = preg_replace('|[/\\\\]dojo[/\\\\]dojo.js[^/\\\\]*$|i', '', $localPath);
- $this->_localRelativePath = $localPath;
- }
- return $this->_localRelativePath;
- }
-
- /**
- * Render dojo stylesheets
- *
- * @return string
- */
- protected function _renderStylesheets()
- {
- if ($this->useCdn()) {
- $base = $this->getCdnBase()
- . $this->getCdnVersion();
- } else {
- $base = $this->_getLocalRelativePath();
- }
-
- $registeredStylesheets = $this->getStylesheetModules();
- foreach ($registeredStylesheets as $stylesheet) {
- $themeName = substr($stylesheet, strrpos($stylesheet, '.') + 1);
- $stylesheet = str_replace('.', '/', $stylesheet);
- $stylesheets[] = $base . '/' . $stylesheet . '/' . $themeName . '.css';
- }
-
- foreach ($this->getStylesheets() as $stylesheet) {
- $stylesheets[] = $stylesheet;
- }
-
- if ($this->_registerDojoStylesheet) {
- $stylesheets[] = $base . '/dojo/resources/dojo.css';
- }
-
- if (empty($stylesheets)) {
- return '';
- }
-
- array_reverse($stylesheets);
- $style = '';
-
- return $style;
- }
-
- /**
- * Render DjConfig values
- *
- * @return string
- */
- protected function _renderDjConfig()
- {
- $djConfigValues = $this->getDjConfig();
- if (empty($djConfigValues)) {
- return '';
- }
-
- require_once 'Zend/Json.php';
- $scriptTag = '';
-
- return $scriptTag;
- }
-
- /**
- * Render dojo script tag
- *
- * Renders Dojo script tag by utilizing either local path provided or the
- * CDN. If any djConfig values were set, they will be serialized and passed
- * with that attribute.
- *
- * @return string
- */
- protected function _renderDojoScriptTag()
- {
- if ($this->useCdn()) {
- $source = $this->getCdnBase()
- . $this->getCdnVersion()
- . $this->getCdnDojoPath();
- } else {
- $source = $this->getLocalPath();
- }
-
- $scriptTag = '';
- return $scriptTag;
- }
-
- /**
- * Render layers (custom builds) as script tags
- *
- * @return string
- */
- protected function _renderLayers()
- {
- $layers = $this->getLayers();
- if (empty($layers)) {
- return '';
- }
-
- $enc = 'UTF-8';
- if ($this->view instanceof Zend_View_Interface
- && method_exists($this->view, 'getEncoding')
- ) {
- $enc = $this->view->getEncoding();
- }
-
- $html = array();
- foreach ($layers as $path) {
- $html[] = sprintf(
- '',
- htmlspecialchars($path, ENT_QUOTES, $enc)
- );
- }
-
- return implode("\n", $html);
- }
-
- /**
- * Render dojo module paths and requires
- *
- * @return string
- */
- protected function _renderExtras()
- {
- $js = array();
- $modulePaths = $this->getModulePaths();
- if (!empty($modulePaths)) {
- foreach ($modulePaths as $module => $path) {
- $js[] = 'dojo.registerModulePath("' . $this->view->escape($module) . '", "' . $this->view->escape($path) . '");';
- }
- }
-
- $modules = $this->getModules();
- if (!empty($modules)) {
- foreach ($modules as $module) {
- $js[] = 'dojo.require("' . $this->view->escape($module) . '");';
- }
- }
-
- $onLoadActions = array();
- // Get Zend specific onLoad actions; these will always be first to
- // ensure that dijits are created in the correct order
- foreach ($this->_getZendLoadActions() as $callback) {
- $onLoadActions[] = 'dojo.addOnLoad(' . $callback . ');';
- }
-
- // Get all other onLoad actions
- foreach ($this->getOnLoadActions() as $callback) {
- $onLoadActions[] = 'dojo.addOnLoad(' . $callback . ');';
- }
-
- $javascript = implode("\n ", $this->getJavascript());
-
- $content = '';
- if (!empty($js)) {
- $content .= implode("\n ", $js) . "\n";
- }
-
- if (!empty($onLoadActions)) {
- $content .= implode("\n ", $onLoadActions) . "\n";
- }
-
- if (!empty($javascript)) {
- $content .= $javascript . "\n";
- }
-
- if (preg_match('/^\s*$/s', $content)) {
- return '';
- }
-
- $html = '';
- return $html;
- }
-
- /**
- * Add an onLoad action related to ZF dijit creation
- *
- * This method is public, but prefixed with an underscore to indicate that
- * it should not normally be called by userland code. It is pertinent to
- * ensuring that the correct order of operations occurs during dijit
- * creation.
- *
- * @param string $callback
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function _addZendLoad($callback)
- {
- if (!in_array($callback, $this->_zendLoadActions, true)) {
- $this->_zendLoadActions[] = $callback;
- }
- return $this;
- }
-
- /**
- * Retrieve all ZF dijit callbacks
- *
- * @return array
- */
- public function _getZendLoadActions()
- {
- return $this->_zendLoadActions;
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/Dojo.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/Dojo.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/Dojo.php 2010-01-06 02:05:09.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/Dojo.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,176 +0,0 @@
-_container = $registry[__CLASS__];
- }
-
- /**
- * Set view object
- *
- * @param Zend_Dojo_View_Interface $view
- * @return void
- */
- public function setView(Zend_View_Interface $view)
- {
- $this->view = $view;
- $this->_container->setView($view);
- }
-
- /**
- * Return dojo container
- *
- * @return Zend_Dojo_View_Helper_Dojo_Container
- */
- public function dojo()
- {
- return $this->_container;
- }
-
- /**
- * Proxy to container methods
- *
- * @param string $method
- * @param array $args
- * @return mixed
- * @throws Zend_Dojo_View_Exception For invalid method calls
- */
- public function __call($method, $args)
- {
- if (!method_exists($this->_container, $method)) {
- require_once 'Zend/Dojo/View/Exception.php';
- throw new Zend_Dojo_View_Exception(sprintf('Invalid method "%s" called on dojo view helper', $method));
- }
-
- return call_user_func_array(array($this->_container, $method), $args);
- }
-
- /**
- * Set whether or not dijits should be created declaratively
- *
- * @return void
- */
- public static function setUseDeclarative()
- {
- self::$_useProgrammatic = false;
- }
-
- /**
- * Set whether or not dijits should be created programmatically
- *
- * Optionally, specifiy whether or not dijit helpers should generate the
- * programmatic dojo.
- *
- * @param int $style
- * @return void
- */
- public static function setUseProgrammatic($style = self::PROGRAMMATIC_SCRIPT)
- {
- if (!in_array($style, array(self::PROGRAMMATIC_SCRIPT, self::PROGRAMMATIC_NOSCRIPT))) {
- $style = self::PROGRAMMATIC_SCRIPT;
- }
- self::$_useProgrammatic = $style;
- }
-
- /**
- * Should dijits be created declaratively?
- *
- * @return bool
- */
- public static function useDeclarative()
- {
- return (false === self::$_useProgrammatic);
- }
-
- /**
- * Should dijits be created programmatically?
- *
- * @return bool
- */
- public static function useProgrammatic()
- {
- return (false !== self::$_useProgrammatic);
- }
-
- /**
- * Should dijits be created programmatically but without scripts?
- *
- * @return bool
- */
- public static function useProgrammaticNoScript()
- {
- return (self::PROGRAMMATIC_NOSCRIPT === self::$_useProgrammatic);
- }
-}
diff -Nru zendframework-1.10.4/library/Zend/Dojo/View/Helper/Editor.php zendframework-2.2.6/library/Zend/Dojo/View/Helper/Editor.php
--- zendframework-1.10.4/library/Zend/Dojo/View/Helper/Editor.php 2010-01-07 14:18:34.000000000 +0000
+++ zendframework-2.2.6/library/Zend/Dojo/View/Helper/Editor.php 1970-01-01 00:00:00.000000000 +0000
@@ -1,187 +0,0 @@
- 'LinkDialog',
- 'insertImage' => 'LinkDialog',
- 'fontName' => 'FontChoice',
- 'fontSize' => 'FontChoice',
- 'formatBlock' => 'FontChoice',
- 'foreColor' => 'TextColor',
- 'hiliteColor' => 'TextColor'
- );
-
- /**
- * JSON-encoded parameters
- * @var array
- */
- protected $_jsonParams = array('captureEvents', 'events', 'plugins');
-
- /**
- * dijit.Editor
- *
- * @param string $id
- * @param string $value
- * @param array $params
- * @param array $attribs
- * @return string
- */
- public function editor($id, $value = null, $params = array(), $attribs = array())
- {
- if (isset($params['plugins'])) {
- foreach ($this->_getRequiredModules($params['plugins']) as $module) {
- $this->dojo->requireModule($module);
- }
- }
-
- // Previous versions allowed specifying "degrade" to allow using a
- // textarea instead of a div -- but this is insecure. Removing the
- // parameter if set to prevent its injection in the dijit.
- if (isset($params['degrade'])) {
- unset($params['degrade']);
- }
-
- $hiddenName = $id;
- if (array_key_exists('id', $attribs)) {
- $hiddenId = $attribs['id'];
- } else {
- $hiddenId = $hiddenName;
- }
- $hiddenId = $this->_normalizeId($hiddenId);
-
- $textareaName = $this->_normalizeEditorName($hiddenName);
- $textareaId = $hiddenId . '-Editor';
-
- $hiddenAttribs = array(
- 'id' => $hiddenId,
- 'name' => $hiddenName,
- 'value' => $value,
- 'type' => 'hidden',
- );
- $attribs['id'] = $textareaId;
-
- $this->_createGetParentFormFunction();
- $this->_createEditorOnSubmit($hiddenId, $textareaId);
-
- $attribs = $this->_prepareDijit($attribs, $params, 'textarea');
-
- $html = '_htmlAttribs($hiddenAttribs) . $this->getClosingBracket();
- $html .= '_htmlAttribs($attribs) . '>'
- . $value
- . "
\n";
-
- // Embed a textarea in a