Permalink
Browse files

Merge branch 'master' of git://github.com/zendframework/zf2

  • Loading branch information...
2 parents 4c938d8 + 5f06010 commit 010bbb80bb1460210c147df83a86e4c3731703a6 @sgehrig sgehrig committed Apr 1, 2011
Showing with 521 additions and 413 deletions.
  1. +27 −3 library/Zend/Amf/Adobe/Introspector.php
  2. +3 −6 library/Zend/Application/Application.php
  3. +19 −4 library/Zend/CodeGenerator/Php/PhpFile.php
  4. +10 −0 library/Zend/CodeGenerator/Php/PhpPropertyValue.php
  5. +0 −3 library/Zend/CodeGenerator/Php/PhpValue.php
  6. +2 −5 library/Zend/Form/Decorator/HtmlTag.php
  7. +1 −1 library/Zend/Json/Json.php
  8. +3 −3 library/Zend/Log/Writer/Db.php
  9. +1 −1 library/Zend/View/Helper/FormImage.php
  10. +1 −1 library/Zend/View/Helper/FormRadio.php
  11. +1 −1 library/Zend/View/Helper/FormText.php
  12. +1 −1 library/Zend/View/Helper/HeadLink.php
  13. +1 −1 library/Zend/View/Helper/HeadMeta.php
  14. +3 −3 library/Zend/View/PhpRenderer.php
  15. +1 −1 library/Zend/View/TemplatePathStack.php
  16. +8 −3 library/Zend/Wildfire/Channel/HttpHeaders.php
  17. +11 −11 tests/Zend/Amf/Adobe/IntrospectorTest.php
  18. +22 −0 tests/Zend/CodeGenerator/Php/PhpFileTest.php
  19. +21 −0 tests/Zend/CodeGenerator/Php/PhpMethodTest.php
  20. +4 −3 tests/Zend/CodeGenerator/Php/PhpParameterTest.php
  21. +1 −1 tests/Zend/CodeGenerator/Php/PhpPropertyValueTest.php
  22. +2 −2 tests/Zend/Log/Formatter/FirebugTest.php
  23. +5 −16 tests/Zend/Log/Formatter/SimpleTest.php
  24. +2 −2 tests/Zend/Log/Formatter/XmlTest.php
  25. +3 −14 tests/Zend/Log/LoggerTest.php
  26. +12 −0 tests/Zend/Log/TestAsset/CustomFirebugFormatter.php
  27. +12 −0 tests/Zend/Log/TestAsset/CustomSyslogWriter.php
  28. +14 −0 tests/Zend/Log/TestAsset/FirePhpHeader.php
  29. +12 −0 tests/Zend/Log/TestAsset/MockDbAdapter.php
  30. +16 −0 tests/Zend/Log/TestAsset/MockFormatter.php
  31. +52 −0 tests/Zend/Log/TestAsset/MockHttpResponse.php
  32. +10 −0 tests/Zend/Log/TestAsset/StringObject.php
  33. +3 −14 tests/Zend/Log/Writer/DbTest.php
  34. +7 −79 tests/Zend/Log/Writer/FirebugTest.php
  35. +4 −4 tests/Zend/Log/Writer/MailTest.php
  36. +1 −1 tests/Zend/Log/Writer/StreamTest.php
  37. +117 −124 tests/Zend/Log/Writer/SyslogTest.php
  38. +1 −1 tests/Zend/Log/Writer/ZendMonitorTest.php
  39. +8 −4 tests/Zend/View/Helper/FormTextTest.php
  40. +26 −42 tests/Zend/View/Helper/HeadLinkTest.php
  41. +47 −52 tests/Zend/View/Helper/HeadMetaTest.php
  42. +26 −6 tests/Zend/Wildfire/WildfireTest.php
@@ -23,6 +23,9 @@
*/
namespace Zend\Amf\Adobe;
+use Zend\Amf\Exception,
+ SplFileInfo;
+
/**
* This class implements a service for generating AMF service descriptions as XML.
*
@@ -91,7 +94,9 @@ public function introspect($serviceClass, $options = array())
// Introspect!
if (!class_exists($serviceClass)) {
- \Zend\Loader::loadClass($serviceClass, $this->_getServicePath());
+ if (!$this->_loadClass($serviceClass)) {
+ return $this->_returnError('Invalid service name; class does not exist');
+ }
}
$serv = $this->_xml->createElement('service-description');
@@ -100,7 +105,7 @@ public function introspect($serviceClass, $options = array())
$this->_types = $this->_xml->createElement('types');
$this->_ops = $this->_xml->createElement('operations');
- $r = \Zend\Server\Reflection::reflectClass($serviceClass);
+ $r = \Zend\Server\Reflection\Reflection::reflectClass($serviceClass);
$this->_addService($r, $this->_ops);
$serv->appendChild($this->_types);
@@ -306,6 +311,25 @@ protected function _registerType($typename)
*/
protected function _returnError($msg)
{
- return 'ERROR: $msg';
+ return "ERROR: $msg";
+ }
+
+ /**
+ * Load a service class from the service path
+ *
+ * @param string $class
+ * @return bool
+ */
+ protected function _loadClass($class)
+ {
+ $file = str_replace(array('\\', '_'), DIRECTORY_SEPARATOR, $class) . '.php';
+ foreach ($this->_getServicePath() as $path) {
+ $fileinfo = new SplFileInfo($path . DIRECTORY_SEPARATOR . $file);
+ if ($fileinfo->isReadable()) {
+ require_once $fileinfo->getRealPath();
+ return true;
+ }
+ }
+ return false;
}
}
@@ -124,8 +124,8 @@ public function getAutoloader()
/**
* Set autoloader
- *
- * @param \Zend\Loader\SplAutoloader $autoloader
+ *
+ * @param \Zend\Loader\SplAutoloader $autoloader
* @return Application
*/
public function setAutoloader(\Zend\Loader\SplAutoloader $autoloader)
@@ -314,10 +314,7 @@ public function setIncludePaths(array $paths)
public function setAutoloaderNamespaces(array $namespaces)
{
$autoloader = $this->getAutoloader();
-
- foreach ($namespaces as $namespace) {
- $autoloader->registerNamespace($namespace);
- }
+ $autoloader->registerNamespaces($namespaces);
return $this;
}
@@ -496,10 +496,6 @@ public function generate()
$output = '<?php' . self::LINE_FEED;
}
- if ($namespace = $this->getNamespace()) {
- // @todo
- }
-
// if there are markers, put the body into the output
$body = $this->getBody();
if (preg_match('#/\* Zend_CodeGenerator_Php_File-(.*?)Marker:#', $body)) {
@@ -521,6 +517,11 @@ public function generate()
// newline
$output .= self::LINE_FEED;
+ // namespace, if any
+ if ($namespace = $this->getNamespace()) {
+ $output .= sprintf('namespace %s;%s', $namespace, str_repeat(self::LINE_FEED, 2));
+ }
+
// process required files
// @todo marker replacement for required files
$requiredFiles = $this->getRequiredFiles();
@@ -532,6 +533,20 @@ public function generate()
$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)) {
@@ -35,4 +35,14 @@
class PhpPropertyValue extends PhpValue
{
protected $_topMostValue = true;
+
+ /**
+ * generate()
+ *
+ * @return string
+ */
+ public function generate()
+ {
+ return parent::generate() . ';';
+ }
}
@@ -308,7 +308,6 @@ public function generate()
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++;
@@ -332,8 +331,6 @@ public function generate()
);
}
- $output .= ';';
-
return $output;
}
}
@@ -24,8 +24,7 @@
*/
namespace Zend\Form\Decorator;
-use Zend\Filter,
- Zend\View\AbstractView;
+use Zend\Filter;
/**
* Zend_Form_Decorator_Element_HtmlTag
@@ -247,9 +246,7 @@ protected function _getEncoding()
$this->_encoding = 'UTF-8';
} elseif (null === ($view = $element->getView())) {
$this->_encoding = 'UTF-8';
- } elseif (!$view instanceof AbstractView
- && !method_exists($view, 'getEncoding')
- ) {
+ } elseif (!method_exists($view, 'getEncoding')) {
$this->_encoding = 'UTF-8';
} else {
$this->_encoding = $view->getEncoding();
@@ -39,7 +39,7 @@
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
-class JSON
+class Json
{
/**
* How objects should be encoded -- arrays or as StdClass. TYPE_ARRAY is 1
@@ -42,21 +42,21 @@ class Db extends AbstractWriter
*
* @var Zend_Db_Adapter
*/
- private $_db;
+ protected $_db;
/**
* Name of the log table in the database
*
* @var string
*/
- private $_table;
+ protected $_table;
/**
* Relates database columns names to log data field keys.
*
* @var null|array
*/
- private $_columnMap;
+ protected $_columnMap;
/**
* Class constructor
@@ -83,7 +83,7 @@ public function direct($name = null, $value = null, $attribs = null)
// XHTML or HTML end tag?
$endTag = ' />';
- if (($this->view instanceof \Zend\View\AbstractView) && !$this->view->broker('doctype')->isXhtml()) {
+ if (method_exists($this->view, 'broker') && !$this->view->broker('doctype')->isXhtml()) {
$endTag= '>';
}
@@ -126,7 +126,7 @@ public function direct($name = null, $value = null, $attribs = null, $options =
// XHTML or HTML end tag?
$endTag = ' />';
- if (($this->view instanceof \Zend\View\AbstractView) && !$this->view->broker('doctype')->isXhtml()) {
+ if (method_exists($this->view, 'broker') && !$this->view->broker('doctype')->isXhtml()) {
$endTag= '>';
}
@@ -69,7 +69,7 @@ public function direct($name = null, $value = null, $attribs = null)
// XHTML or HTML end tag?
$endTag = ' />';
- if (($this->view instanceof \Zend\View\AbstractView) && !$this->view->broker('doctype')->isXhtml()) {
+ if (method_exists($this->view, 'broker') && !$this->view->broker('doctype')->isXhtml()) {
$endTag= '>';
}
@@ -284,7 +284,7 @@ public function itemToString(\stdClass $item)
}
}
- if ($this->view instanceof View\AbstractView) {
+ if (method_exists($this->view, 'broker')) {
$link .= ($this->view->broker('doctype')->isXhtml()) ? '/>' : '>';
} else {
$link .= '/>';
@@ -337,7 +337,7 @@ public function itemToString(\stdClass $item)
$modifiersString .= $key . '="' . $this->_escape($value) . '" ';
}
- if ($this->view instanceof View\AbstractView) {
+ if (method_exists($this->view, 'broker')) {
if ($this->view->broker('doctype')->isHtml5()
&& $type == 'charset') {
$tpl = ($this->view->broker('doctype')->isXhtml())
@@ -93,7 +93,7 @@ public function __construct($config = array())
*
* Returns the object instance, as it is its own template engine
*
- * @return \Zend\View\AbstractView
+ * @return \Zend\View\PhpRenderer
*/
public function getEngine()
{
@@ -162,7 +162,7 @@ public function resolver($name = null)
* Expects either an array, or an object implementing ArrayAccess.
*
* @param array|ArrayAccess $variables
- * @return AbstractView
+ * @return PhpRenderer
*/
public function setVars($variables)
{
@@ -243,7 +243,7 @@ public function broker($helper = null, array $options = null)
* Set filter chain
*
* @param FilterChain $filters
- * @return Zend\View\AbstractView
+ * @return Zend\View\PhpRenderer
*/
public function setFilterChain(FilterChain $filters)
{
@@ -191,7 +191,7 @@ public function getPaths()
* Set LFI protection flag
*
* @param bool $flag
- * @return \Zend\View\AbstractView
+ * @return \Zend\View\TemplatePathStack
*/
public function setLfiProtection($flag)
{
@@ -23,9 +23,10 @@
* @namespace
*/
namespace Zend\Wildfire\Channel;
-use Zend\Wildfire;
-use Zend\Wildfire\Protocol;
-use Zend\Controller;
+use Zend\Wildfire,
+ Zend\Wildfire\Protocol,
+ Zend\Controller,
+ Zend\Controller\Request\Http as HttpRequest;
/**
* Implements communication via HTTP request and response headers for Wildfire Protocols.
@@ -260,6 +261,10 @@ public function isReady($forceCheckRequest=false)
return true;
}
+ if (!($this->getRequest() instanceof HttpRequest)) {
+ return false;
+ }
+
return ($this->getResponse()->canSendHeaders()
&& (preg_match_all(
'/\s?FirePHP\/([\.\d]*)\s?/si',
@@ -41,41 +41,41 @@ public function setUp()
public function testIntrospectionDoesNotIncludeConstructor()
{
- $xml = $this->introspector->introspect('ZendTest.AMF.TestAsset.IntrospectorTest');
+ $xml = $this->introspector->introspect('ZendTest.Amf.TestAsset.IntrospectorTest');
$this->assertNotContains('__construct', $xml);
}
public function testIntrospectionDoesNotIncludeMagicMethods()
{
- $xml = $this->introspector->introspect('ZendTest.AMF.TestAsset.IntrospectorTest');
+ $xml = $this->introspector->introspect('ZendTest.Amf.TestAsset.IntrospectorTest');
$this->assertNotContains('__get', $xml);
}
public function testIntrospectionContainsPublicPropertiesOfReturnClassTypes()
{
- $xml = $this->introspector->introspect('ZendTest.AMF.TestAsset.IntrospectorTest');
+ $xml = $this->introspector->introspect('ZendTest.Amf.TestAsset.IntrospectorTest');
$this->assertRegexp('/<type[^>]*(name="' . preg_quote('ZendTest\\Amf\\TestAsset\\IntrospectorTestCustomType') . '")/', $xml, $xml);
$this->assertRegexp('/<property[^>]*(name="foo")/', $xml, $xml);
$this->assertRegexp('/<property[^>]*(type="string")/', $xml, $xml);
}
public function testIntrospectionDoesNotContainNonPublicPropertiesOfReturnClassTypes()
{
- $xml = $this->introspector->introspect('ZendTest.AMF.TestAsset.IntrospectorTest');
+ $xml = $this->introspector->introspect('ZendTest.Amf.TestAsset.IntrospectorTest');
$this->assertNotRegexp('/<property[^>]*(name="_bar")/', $xml, $xml);
}
public function testIntrospectionContainsPublicMethods()
{
- $xml = $this->introspector->introspect('ZendTest.AMF.TestAsset.IntrospectorTest');
+ $xml = $this->introspector->introspect('ZendTest.Amf.TestAsset.IntrospectorTest');
$this->assertRegexp('/<operation[^>]*(name="foobar")/', $xml, $xml);
$this->assertRegexp('/<operation[^>]*(name="barbaz")/', $xml, $xml);
$this->assertRegexp('/<operation[^>]*(name="bazbat")/', $xml, $xml);
}
public function testIntrospectionContainsOperationForEachPrototypeOfAPublicMethod()
{
- $xml = $this->introspector->introspect('ZendTest.AMF.TestAsset.IntrospectorTest');
+ $xml = $this->introspector->introspect('ZendTest.Amf.TestAsset.IntrospectorTest');
$this->assertEquals(4, substr_count($xml, 'name="foobar"'));
$this->assertEquals(1, substr_count($xml, 'name="barbaz"'));
$this->assertEquals(1, substr_count($xml, 'name="bazbat"'));
@@ -93,27 +93,27 @@ public function testPassingDirectoriesOptionShouldResolveServiceClassAndType()
public function testMissingPropertyDocblockInTypedClassShouldReportTypeAsUnknown()
{
- $xml = $this->introspector->introspect('ZendTest.AMF.TestAsset.IntrospectorTest');
+ $xml = $this->introspector->introspect('ZendTest.Amf.TestAsset.IntrospectorTest');
if (!preg_match('/(<property[^>]*(name="baz")[^>]*>)/', $xml, $matches)) {
- $this->fail('Baz property of ZendTest.AMF.TestAsset.IntrospectorTestCustomType not found');
+ $this->fail('Baz property of ZendTest.Amf.TestAsset.IntrospectorTestCustomType not found');
}
$node = $matches[1];
$this->assertContains('type="Unknown"', $node, $node);
}
public function testPropertyDocblockWithoutAnnotationInTypedClassShouldReportTypeAsUnknown()
{
- $xml = $this->introspector->introspect('ZendTest.AMF.TestAsset.IntrospectorTest');
+ $xml = $this->introspector->introspect('ZendTest.Amf.TestAsset.IntrospectorTest');
if (!preg_match('/(<property[^>]*(name="bat")[^>]*>)/', $xml, $matches)) {
- $this->fail('Bat property of ZendTest.AMF.TestAsset.IntrospectorTestCustomType not found');
+ $this->fail('Bat property of ZendTest.Amf.TestAsset.IntrospectorTestCustomType not found');
}
$node = $matches[1];
$this->assertContains('type="Unknown"', $node, $node);
}
public function testTypedClassWithExplicitTypeShouldReportAsThatType()
{
- $xml = $this->introspector->introspect('ZendTest.AMF.TestAsset.IntrospectorTest');
+ $xml = $this->introspector->introspect('ZendTest.Amf.TestAsset.IntrospectorTest');
$this->assertRegexp('/<type[^>]*(name="explicit")/', $xml, $xml);
}
}
Oops, something went wrong.

0 comments on commit 010bbb8

Please sign in to comment.