Skip to content
Browse files

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

  • Loading branch information...
2 parents 28ff442 + bf23582 commit 188816b4293afc08247d9104aa291f22b088383d @sgehrig sgehrig committed Oct 24, 2011
View
35 library/Zend/Code/Generator/FileGeneratorRegistry.php
@@ -2,10 +2,37 @@
namespace Zend\Code\Generator;
+use Zend\Code\Generator\Exception\RuntimeException;
+
class FileGeneratorRegistry
{
- /**
- * @todo Complete this when Zend\Tool get's refractored as it is the only
- * piece that cares if its "double reflecting" file generators
- */
+ /**
+ * @var array[string]\Zend\Code\Generator\FileGenerator $_fileCodeGenerators registry for Zend\Code\Generator\FileGenerator
+ */
+ static private $_fileCodeGenerators = array();
+
+ /**
+ * Registry for the Zend_Code package. Zend_Tool uses this
+ *
+ * @param FileGenerator $fileCodeGenerator
+ * @param string $fileName
+ * @throws RuntimeException
+ */
+ public static function registerFileCodeGenerator(FileGenerator $fileCodeGenerator, $fileName = null)
+ {
+ if ($fileName == null) {
+ $fileName = $fileCodeGenerator->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);
+
+ self::$_fileCodeGenerators[$fileName] = $fileCodeGenerator;
+
+ }
}
View
68 library/Zend/Dom/Query.php
@@ -61,6 +61,12 @@ class Query
protected $_docType;
/**
+ * Document encoding
+ * @var null|string
+ */
+ protected $_encoding;
+
+ /**
* XPath namespaces
* @var array
*/
@@ -72,68 +78,104 @@ class Query
* @param null|string $document
* @return void
*/
- public function __construct($document = null)
+ public function __construct($document = null, $encoding = null)
{
+ $this->setEncoding($encoding);
$this->setDocument($document);
}
/**
+ * Set document encoding
+ *
+ * @param string $encoding
+ * @return \Zend\Dom\Query
+ */
+ public function setEncoding($encoding)
+ {
+ $this->_encoding = (null === $encoding) ? null : (string) $encoding;
+ return $this;
+ }
+
+ /**
+ * Get document encoding
+ *
+ * @return null|string
+ */
+ public function getEncoding()
+ {
+ return $this->_encoding;
+ }
+
+ /**
* Set document to query
*
* @param string $document
+ * @param null|string $encoding Document encoding
* @return \Zend\Dom\Query
*/
- public function setDocument($document)
+ public function setDocument($document, $encoding = null)
{
if (0 === strlen($document)) {
return $this;
}
// breaking XML declaration to make syntax highlighting work
if ('<' . '?xml' == substr(trim($document), 0, 5)) {
- return $this->setDocumentXml($document);
+ return $this->setDocumentXml($document, $encoding);
}
if (strstr($document, 'DTD XHTML')) {
- return $this->setDocumentXhtml($document);
+ return $this->setDocumentXhtml($document, $encoding);
}
- return $this->setDocumentHtml($document);
+ return $this->setDocumentHtml($document, $encoding);
}
/**
* Register HTML document
*
* @param string $document
+ * @param null|string $encoding Document encoding
* @return \Zend\Dom\Query
*/
- public function setDocumentHtml($document)
+ public function setDocumentHtml($document, $encoding = null)
{
$this->_document = (string) $document;
$this->_docType = self::DOC_HTML;
+ if (null !== $encoding) {
+ $this->setEncoding($encoding);
+ }
return $this;
}
/**
* Register XHTML document
*
* @param string $document
+ * @param null|string $encoding Document encoding
* @return \Zend\Dom\Query
*/
- public function setDocumentXhtml($document)
+ public function setDocumentXhtml($document, $encoding = null)
{
$this->_document = (string) $document;
$this->_docType = self::DOC_XHTML;
+ if (null !== $encoding) {
+ $this->setEncoding($encoding);
+ }
return $this;
}
/**
* Register XML document
*
* @param string $document
+ * @param null|string $encoding Document encoding
* @return \Zend\Dom\Query
*/
- public function setDocumentXml($document)
+ public function setDocumentXml($document, $encoding = null)
{
$this->_document = (string) $document;
$this->_docType = self::DOC_XML;
+ if (null !== $encoding) {
+ $this->setEncoding($encoding);
+ }
return $this;
}
@@ -192,8 +234,14 @@ public function queryXpath($xpathQuery, $query = null)
throw new Exception\RuntimeException('Cannot query; no document registered');
}
+ $encoding = $this->getEncoding();
libxml_use_internal_errors(true);
- $domDoc = new \DOMDocument;
+ if (null === $encoding) {
+ $domDoc = new \DOMDocument('1.0');
+ } else {
+ $domDoc = new \DOMDocument('1.0', $encoding);
+ }
+
$type = $this->getDocumentType();
switch ($type) {
case self::DOC_XML:
@@ -247,4 +295,4 @@ protected function _getNodeList($document, $xpathQuery)
$xpathQuery = (string) $xpathQuery;
return $xpath->query($xpathQuery);
}
-}
+}
View
31 library/Zend/Soap/AutoDiscover.php
@@ -108,21 +108,21 @@ public function __construct($strategy = true, $uri=null, $wsdlClass=null)
/**
* Set the location at which the WSDL file will be availabe.
*
- * @throws \Zend\Soap\AutoDiscover\Exception
* @param Uri\Uri|string $uri
* @return \Zend\Soap\AutoDiscover
+ * @throws \Zend\Soap\Exception\InvalidArgumentException
*/
public function setUri($uri)
{
- if(!is_string($uri) && !($uri instanceof Uri\Uri)) {
+ if (!is_string($uri) && !($uri instanceof Uri\Uri)) {
throw new Exception\InvalidArgumentException(
'No uri given to \Zend\Soap\AutoDiscover::setUri as string or \Zend\Uri\Uri instance.'
);
}
$this->_uri = $uri;
// change uri in WSDL file also if existant
- if($this->_wsdl instanceof Wsdl) {
+ if ($this->_wsdl instanceof Wsdl) {
$this->_wsdl->setUri($uri);
}
@@ -151,13 +151,13 @@ public function getUri()
/**
* Set the name of the WSDL handling class.
*
- * @throws \Zend\Soap\AutoDiscover\Exception
* @param string $wsdlClass
* @return \Zend\Soap\AutoDiscover
+ * @throws \Zend\Soap\Exception\InvalidArgumentException
*/
public function setWsdlClass($wsdlClass)
{
- if(!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend\Soap\Wsdl')) {
+ if (!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend\Soap\Wsdl')) {
throw new Exception\InvalidArgumentException(
'No \Zend\Soap\Wsdl subclass given to Zend\Soap\AutoDiscover::setWsdlClass as string.'
);
@@ -185,6 +185,7 @@ public function getWsdlClass()
*
* @param array $operationStyle
* @return \Zend\Soap\AutoDiscover
+ * @throws \Zend\Soap\Exception\InvalidArgumentException
*/
public function setOperationBodyStyle(array $operationStyle=array())
{
@@ -288,6 +289,7 @@ public function setComplexTypeStrategy($strategy)
* @param string $class Class Name
* @param string $namespace Class Namspace - Not Used
* @param array $argv Arguments to instantiate the class - Not Used
+ * @return \Zend\Soap\AutoDiscover
*/
public function setClass($class, $namespace = '', $argv = null)
{
@@ -311,13 +313,16 @@ public function setClass($class, $namespace = '', $argv = null)
$this->_addFunctionToWsdl($method, $wsdl, $port, $binding);
}
$this->_wsdl = $wsdl;
+
+ return $this;
}
/**
* Add a Single or Multiple Functions to the WSDL
*
* @param string $function Function Name
* @param string $namespace Function namespace - Not Used
+ * @return \Zend\Soap\AutoDiscover
*/
public function addFunction($function, $namespace = '')
{
@@ -353,6 +358,8 @@ public function addFunction($function, $namespace = '')
$this->_addFunctionToWsdl($method, $wsdl, $port, $binding);
}
$this->_wsdl = $wsdl;
+
+ return $this;
}
/**
@@ -460,7 +467,11 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding)
}
// Add the binding operation
- $operation = $wsdl->addBindingOperation($binding, $functionName, $this->_operationBodyStyle, $this->_operationBodyStyle);
+ if($isOneWayMessage == false) {
+ $operation = $wsdl->addBindingOperation($binding, $functionName, $this->_operationBodyStyle, $this->_operationBodyStyle);
+ } else {
+ $operation = $wsdl->addBindingOperation($binding, $functionName, $this->_operationBodyStyle);
+ }
$wsdl->addSoapOperation($operation, $uri . '#' . $functionName);
// Add the function name to the list
@@ -472,6 +483,7 @@ protected function _addFunctionToWsdl($function, $wsdl, $port, $binding)
*
* @param string $fault
* @param string|int $code
+ * @throws \Zend\Soap\Exception\UnexpectedValueException
*/
public function fault($fault = null, $code = null)
{
@@ -495,6 +507,8 @@ public function handle($request = false)
* Proxy to WSDL dump function
*
* @param string $filename
+ * @return boolean
+ * @throws \Zend\Soap\Exception\RuntimeException
*/
public function dump($filename)
{
@@ -507,6 +521,9 @@ public function dump($filename)
/**
* Proxy to WSDL toXml() function
+ *
+ * @return string
+ * @throws \Zend\Soap\Exception\RuntimeException
*/
public function toXml()
{
@@ -531,6 +548,7 @@ public function getFunctions()
* Load Functions
*
* @param unknown_type $definition
+ * @throws \Zend\Soap\Exception\RuntimeException
*/
public function loadFunctions($definition)
{
@@ -541,6 +559,7 @@ public function loadFunctions($definition)
* Set Persistance
*
* @param int $mode
+ * @throws \Zend\Soap\Exception\RuntimeException
*/
public function setPersistence($mode)
{
View
23 library/Zend/Soap/Client.php
@@ -313,7 +313,7 @@ public function getOptions()
* ugly hack as I don't know if checking for '=== null'
* breaks some other option
*/
- if ($key == 'user_agent') {
+ if (in_array($key, array('user_agent', 'cache_wsdl', 'compression'))) {
if ($value === null) {
unset($options[$key]);
}
@@ -752,13 +752,16 @@ public function getHttpsCertPassphrase()
/**
* Set compression options
*
- * @param int $compressionOptions
+ * @param int|null $compressionOptions
* @return \Zend\Soap\Client\Client
*/
public function setCompressionOptions($compressionOptions)
{
- $this->_compression = $compressionOptions;
-
+ if ($compressionOptions === null) {
+ $this->_compression = null;
+ } else {
+ $this->_compression = (int)$compressionOptions;
+ }
$this->_soapClient = null;
return $this;
@@ -836,17 +839,23 @@ public function getSoapFeatures()
/**
* Set the SOAP WSDL Caching Options
*
- * @param string|int|boolean $caching
+ * @param string|int|boolean|null $caching
* @return \Zend\Soap\Client\Client
*/
- public function setWSDLCache($options)
+ public function setWSDLCache($caching)
{
- $this->_cache_wsdl = $options;
+ if ($caching === null) {
+ $this->_cache_wsdl = null;
+ } else {
+ $this->_cache_wsdl = (int)$caching;
+ }
return $this;
}
/**
* Get current SOAP WSDL Caching option
+ *
+ * @return int
*/
public function getWSDLCache()
{
View
3 library/Zend/Soap/Client/Local.php
@@ -84,8 +84,7 @@ public function _doRequest(Common $client, $request, $location, $action, $versio
// Perform request as is
ob_start();
$this->_server->handle($request);
- $response = ob_get_contents();
- ob_end_clean();
+ $response = ob_get_clean();
return $response;
}
View
2 library/Zend/Soap/Server.php
@@ -809,7 +809,7 @@ public function handle($request = null)
$soap->fault("Sender", $setRequestException->getMessage());
} else {
try {
- $soap->handle($request);
+ $soap->handle($this->_request);
} catch (\Exception $e) {
$fault = $this->fault($e);
$soap->fault($fault->faultcode, $fault->faultstring);
View
4 library/Zend/Soap/Wsdl.php
@@ -314,8 +314,8 @@ public function addBindingOperation($binding, $name, $input = false, $output = f
if (isset($fault['name'])) {
$node->setAttribute('name', $fault['name']);
}
- $soap_node = $this->_dom->createElement('soap:body');
- foreach ($output as $name => $value) {
+ $soap_node = $this->_dom->createElement('soap:fault');
+ foreach ($fault as $name => $value) {
$soap_node->setAttribute($name, $value);
}
$node->appendChild($soap_node);
View
8 library/Zend/Tool/Project/Context/Content/Engine/CodeGenerator.php
@@ -24,8 +24,8 @@
*/
namespace Zend\Tool\Project\Context\Content\Engine;
-use Zend\CodeGenerator\AbstractCodeGenerator,
- Zend\CodeGenerator\Php as PhpCodeGenerator,
+use Zend\Code\Generator\AbstractGenerator,
+ Zend\Code\Generator\FileGenerator,
Zend\Tool\Framework\Client\Storage,
Zend\Tool\Project\Context,
Zend\Tool\Project\Exception;
@@ -92,12 +92,12 @@ public function getContent(Context $context, $method, $parameters)
if (method_exists($context, 'getCodeGenerator')) {
$codeGenerator = $context->getCodeGenerator();
} else {
- $codeGenerator = new PhpCodeGenerator\PhpFile();
+ $codeGenerator = new FileGenerator();
}
$codeGenerator = include $streamUri;
- if (!$codeGenerator instanceof AbstractCodeGenerator) {
+ if (!$codeGenerator instanceof AbstractGenerator) {
throw new Exception\RuntimeException('Custom file at ' . $streamUri . ' did not return the $codeGenerator object.');
}
View
19 library/Zend/Tool/Project/Context/Zf/ActionMethod.php
@@ -25,17 +25,20 @@
namespace Zend\Tool\Project\Context\Zf;
use Zend\Tool\Project\Context\Context,
- Zend\CodeGenerator\Php,
Zend\Tool\Project\Context\Exception,
- Zend\Tool\Project\Profile\Resource\Resource;
+ Zend\Tool\Project\Profile\Resource\Resource,
+ Zend\Code\Generator\FileGenerator,
+ Zend\Code\Generator\ClassGenerator,
+ Zend\Code\Generator\MethodGenerator;
+
/**
* This class is the front most class for utilizing Zend\Tool\Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
- * @uses \Zend\CodeGenerator\Php\PhpFile
+ * @uses \Zend\Code\Generator\ClassGenerator
* @uses \Zend\Reflection\ReflectionFile
* @uses \Zend\Tool\Project\Context\Exception
* @uses \Zend\Tool\Project\Context
@@ -186,11 +189,9 @@ public static function createActionMethod($controllerPath, $actionName, $body =
return false;
}
- $controllerCodeGenFile = Php\PhpFile::fromReflectedFileName($controllerPath, true, true);
- $controllerCodeGenFile->getClass()->setMethod(array(
- 'name' => $actionName . 'Action',
- 'body' => $body
- ));
+ $controllerCodeGenFile = FileGenerator::fromReflectedFileName($controllerPath, true, true);
+ $controllerCodeGenFile->setClass(new ClassGenerator(basename($controllerPath, '.php')));
+ $controllerCodeGenFile->getClass()->setMethod(new MethodGenerator($actionName . 'Action', array(), MethodGenerator::FLAG_PUBLIC, $body));
file_put_contents($controllerPath, $controllerCodeGenFile->generate());
return true;
@@ -209,7 +210,7 @@ public static function hasActionMethod($controllerPath, $actionName)
return false;
}
- $controllerCodeGenFile = Php\PhpFile::fromReflectedFileName($controllerPath, true, true);
+ $controllerCodeGenFile = FileGenerator::fromReflectedFileName($controllerPath, true, true);
return $controllerCodeGenFile->getClass()->hasMethod($actionName . 'Action');
}
View
15 library/Zend/Tool/Project/Context/Zf/BootstrapFile.php
@@ -32,8 +32,8 @@
* items within a specific project.
*
* @uses \Zend\Application\Application
- * @uses \Zend\CodeGenerator\Php\PhpClass
- * @uses \Zend\CodeGenerator\Php\PhpFile
+ * @uses \Zend\Code\Generator\ClassGenerator
+ * @uses \Zend\Code\Generator\FileGenerator
* @uses \Zend\Tool\Project\Context\Filesystem\File
* @uses \Zend\Tool\Project\Exception
* @category Zend
@@ -97,14 +97,11 @@ public function init()
public function getContents()
{
- $codeGenFile = new \Zend\CodeGenerator\Php\PhpFile(array(
+ $codeGenFile = new \Zend\Code\Generator\FileGenerator(array(
'classes' => array(
- new \Zend\CodeGenerator\Php\PhpClass(array(
- 'name' => 'Bootstrap',
- 'extendedClass' => '\Zend\Application\Bootstrap',
- )),
- )
- ));
+ new \Zend\Code\Generator\ClassGenerator('Bootstrap', null, null, '\Zend\Application\Bootstrap'),
+ )
+ ));
return $codeGenFile->generate();
}
View
71 library/Zend/Tool/Project/Context/Zf/ControllerFile.php
@@ -24,17 +24,20 @@
*/
namespace Zend\Tool\Project\Context\Zf;
-use Zend\CodeGenerator\Php;
+use Zend\Code\Generator\FileGeneratorRegistry,
+ Zend\Code\Generator\MethodGenerator,
+ Zend\Code\Generator\ClassGenerator,
+ Zend\Code\Generator\FileGenerator;
/**
* This class is the front most class for utilizing Zend\Tool\Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
- * @uses \Zend\CodeGenerator\Php\PhpClass
- * @uses \Zend\CodeGenerator\Php\PhpFile
- * @uses \Zend\CodeGenerator\Php\PhpMethod
+ * @uses \Zend\Code\Generator\ClassGenerator
+ * @uses \Zend\Code\Generator\FileGenerator
+ * @uses \Zend\Code\Generator\MethodGenerator
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
@@ -112,35 +115,19 @@ public function getContents()
$className = ($this->_moduleName) ? ucfirst($this->_moduleName) . '\\' : '';
$className .= ucfirst($this->_controllerName) . 'Controller';
- $codeGenFile = new Php\PhpFile(array(
- 'fileName' => $this->getPath(),
- 'classes' => array(
- new Php\PhpClass(array(
- 'name' => $className,
- 'extendedClass' => '\Zend\Controller\Action',
- 'methods' => array(
- new Php\PhpMethod(array(
- 'name' => 'init',
- 'body' => '/* Initialize action controller here */',
- ))
- )
- ))
- )
- ));
-
-
+ $codeGenFile = new FileGenerator();
+ $codeGenFile->setFilename($this->getPath());
+ $cg = new ClassGenerator($className);
+ $cg->setMethod(new MethodGenerator('init', array(), null, '/* Initialize action controller here */'));
+ $codeGenFile->setClass($cg);
+
if ($className == 'ErrorController') {
-
- $codeGenFile = new Php\PhpFile(array(
- 'fileName' => $this->getPath(),
- 'classes' => array(
- new Php\PhpClass(array(
- 'name' => $className,
- 'extendedClass' => 'Zend\Controller\Action',
- 'methods' => array(
- new Php\PhpMethod(array(
- 'name' => 'errorAction',
- 'body' => <<<'EOS'
+
+ $codeGenFile = new FileGenerator();
+ $codeGenFile->setFilename($this->getPath());
+ $cg = new ClassGenerator($className);
+
+ $cg->setMethods(array(new MethodGenerator('errorAction', array(), null, <<<'EOS'
$errors = $this->_getParam('error_handler');
if (!$errors || !$errors instanceof \ArrayObject) {
@@ -178,10 +165,7 @@ public function getContents()
$this->view->vars()->request = $errors->request;
EOS
- )),
- new Php\PhpMethod(array(
- 'name' => 'getLog',
- 'body' => <<<'EOS'
+ ), new MethodGenerator('getLog', array(), null, <<<'EOS'
/* @var $bootstrap Zend\Application\Bootstrap */
$bootstrap = $this->getInvokeArg('bootstrap');
if (!$bootstrap->getBroker()->hasPlugin('Log')) {
@@ -190,16 +174,13 @@ public function getContents()
$log = $bootstrap->getResource('Log');
return $log;
EOS
- )),
- )
- ))
)
- ));
-
+ )
+ );
}
// store the generator into the registry so that the addAction command can use the same object later
- Php\PhpFile::registerFileCodeGenerator($codeGenFile); // REQUIRES filename to be set
+ FileGeneratorRegistry::registerFileCodeGenerator($codeGenFile); // REQUIRES filename to be set
return $codeGenFile->generate();
}
@@ -211,18 +192,18 @@ public function getContents()
public function addAction($actionName)
{
$classCodeGen = $this->getCodeGenerator();
- $classCodeGen->setMethod(array('name' => $actionName . 'Action', 'body' => ' // action body here'));
+ $classCodeGen->setMethod(new MethodGenerator($actionName . 'Action', array(), null, ' // action body here'));
file_put_contents($this->getPath(), $classCodeGen->generate());
}
/**
* getCodeGenerator()
*
- * @return \Zend\CodeGenerator\Php\PhpClass
+ * @return \Zend\Code\Generator\FileGenerator
*/
public function getCodeGenerator()
{
- $codeGenFile = Php\PhpFile::fromReflectedFileName($this->getPath());
+ $codeGenFile = FileGenerator::fromReflectedFileName($this->getPath());
$codeGenFileClasses = $codeGenFile->getClasses();
$class = array_shift($codeGenFileClasses);
return $class;
View
29 library/Zend/Tool/Project/Context/Zf/DbTableFile.php
@@ -23,17 +23,19 @@
* @namespace
*/
namespace Zend\Tool\Project\Context\Zf;
-use Zend\CodeGenerator\Php;
+use Zend\Code\Generator\FileGenerator,
+ Zend\Code\Generator\ClassGenerator,
+ Zend\Code\Generator\PropertyGenerator;
/**
* This class is the front most class for utilizing Zend\Tool\Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
- * @uses \Zend\CodeGenerator\Php\PhpClass
- * @uses \Zend\CodeGenerator\Php\PhpFile
- * @uses \Zend\CodeGenerator\Php\PhpProperty
+ * @uses \Zend\Code\Generator\ClassGenerator
+ * @uses \Zend\Code\Generator\FileGenerator
+ * @uses \Zend\Code\Generator\PropertyGenerator
* @uses \Zend\Tool\Project\Context\Zf\AbstractClassFile
* @category Zend
* @package Zend_Tool
@@ -78,23 +80,12 @@ public function getContents()
{
$className = $this->getFullClassName($this->_dbTableName, 'Model\DbTable');
- $codeGenFile = new Php\PhpFile(array(
- 'fileName' => $this->getPath(),
- 'classes' => array(
- new Php\PhpClass(array(
- 'name' => $className,
- 'extendedClass' => '\Zend\Db\Table\AbstractTable',
- 'properties' => array(
- new Php\PhpProperty(array(
- 'name' => '_name',
- 'visibility' => Php\PhpProperty::VISIBILITY_PROTECTED,
- 'defaultValue' => $this->_actualTableName
- ))
- ),
-
- ))
+ $codeGenFile = new FileGenerator($this->getPath());
+ $codeGenFile->setClass(new ClassGenerator($className, null, null, '\Zend\Db\Table\AbstractTable', null, array(
+ new PropertyGenerator('_name', $this->_actualTableName, PropertyGenerator::FLAG_PROTECTED),
)
));
+
return $codeGenFile->generate();
}
View
30 library/Zend/Tool/Project/Context/Zf/FormFile.php
@@ -23,16 +23,18 @@
* @namespace
*/
namespace Zend\Tool\Project\Context\Zf;
+use Zend\Code\Generator\MethodGenerator,
+ Zend\Code\Generator\ClassGenerator;
/**
* This class is the front most class for utilizing Zend\Tool\Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
- * @uses \Zend\CodeGenerator\Php\PhpClass
- * @uses \Zend\CodeGenerator\Php\PhpFile
- * @uses \Zend\CodeGenerator\Php\PhpMethod
+ * @uses \Zend\Code\Generator\ClassGenerator
+ * @uses \Zend\Code\Generator\FileGenerator
+ * @uses \Zend\Code\Generator\MethodGenerator
* @uses \Zend\Tool\Project\Context\Zf\AbstractClassFile
* @category Zend
* @package Zend_Tool
@@ -95,22 +97,12 @@ public function getContents()
$className = $this->getFullClassName($this->_formName, 'Form');
- $codeGenFile = new \Zend\CodeGenerator\Php\PhpFile(array(
- 'fileName' => $this->getPath(),
- 'classes' => array(
- new \Zend\CodeGenerator\Php\PhpClass(array(
- 'name' => $className,
- 'extendedClass' => '\Zend\Form\Form',
- 'methods' => array(
- new \Zend\CodeGenerator\Php\PhpMethod(array(
- 'name' => 'init',
- 'body' => '/* Form Elements & Other Definitions Here ... */',
- ))
- )
-
- ))
- )
- ));
+ $codeGenFile = new \Zend\Code\Generator\FileGenerator();
+ $codeGenFile->setFilename($this->getPath());
+ $codeGenFile->setClass(new \Zend\Code\Generator\ClassGenerator($className, null, null, '\Zend\Form\Form', array(), array(),
+ new MethodGenerator('init', array(), MethodGenerator::FLAG_PUBLIC, '/* Form Elements & Other Definitions Here ... */')
+ ));
+
return $codeGenFile->generate();
}
}
View
16 library/Zend/Tool/Project/Context/Zf/ModelFile.php
@@ -30,8 +30,8 @@
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
- * @uses \Zend\CodeGenerator\Php\PhpClass
- * @uses \Zend\CodeGenerator\Php\PhpFile
+ * @uses \Zend\Code\Generator\ClassGenerator
+ * @uses \Zend\Code\Generator\FileGenerator
* @uses \Zend\Tool\Project\Context\Zf\AbstractClassFile
* @category Zend
* @package Zend_Tool
@@ -94,14 +94,10 @@ public function getContents()
$className = $this->getFullClassName($this->_modelName, 'Model');
- $codeGenFile = new \Zend\CodeGenerator\Php\PhpFile(array(
- 'fileName' => $this->getPath(),
- 'classes' => array(
- new \Zend\CodeGenerator\Php\PhpClass(array(
- 'name' => $className,
- ))
- )
- ));
+ $codeGenFile = new \Zend\Code\Generator\FileGenerator();
+ $codeGenFile->setFilename($this->getPath());
+ $codeGenFile->setClass(new \Zend\Code\Generator\ClassGenerator($className));
+
return $codeGenFile->generate();
}
View
24 library/Zend/Tool/Project/Context/Zf/ProjectProviderFile.php
@@ -24,15 +24,18 @@
*/
namespace Zend\Tool\Project\Context\Zf;
+use Zend\Code\Generator\ClassGenerator,
+ Zend\Code\Generator\MethodGenerator;
+
/**
* This class is the front most class for utilizing Zend\Tool\Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
- * @uses \Zend\CodeGenerator\Php\PhpClass
- * @uses \Zend\CodeGenerator\Php\PhpFile
- * @uses \Zend\CodeGenerator\Php\PhpMethod
+ * @uses \Zend\Code\Generator\ClassGenerator
+ * @uses \Zend\Code\Generator\FileGenerator
+ * @uses \Zend\Code\Generator\MethodGenerator
* @uses \Zend\Filter\Word\DashToCamelCase
* @uses \Zend\Tool\Project\Context\Filesystem\File
* @category Zend
@@ -120,26 +123,19 @@ public function getContents()
$className = $filter->filter($this->_projectProviderName) . 'Provider';
- $class = new \Zend\CodeGenerator\Php\PhpClass(array(
- 'name' => $className,
- 'extendedClass' => '\Zend\Tool\Project\Provider\AbstractProvider'
- ));
+ $class = new ClassGenerator($className, null, null, '\Zend\Tool\Project\Provider\AbstractProvider');
$methods = array();
foreach ($this->_actionNames as $actionName) {
- $methods[] = new \Zend\CodeGenerator\Php\PhpMethod(array(
- 'name' => $actionName,
- 'body' => ' /** @todo Implementation */'
- ));
+ $methods[] = new MethodGenerator($actionName, array(), MethodGenerator::FLAG_PUBLIC, ' /** @todo Implementation */');
}
if ($methods) {
$class->setMethods($methods);
}
- $codeGenFile = new \Zend\CodeGenerator\Php\PhpFile(array(
- 'classes' => array($class)
- ));
+ $codeGenFile = new \Zend\Code\Generator\FileGenerator();
+ $codeGenFile->setClass($class);
return $codeGenFile->generate();
}
View
8 library/Zend/Tool/Project/Context/Zf/PublicIndexFile.php
@@ -30,7 +30,7 @@
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
- * @uses \Zend\CodeGenerator\Php\PhpFile
+ * @uses \Zend\Code\Generator\FileGenerator
* @uses \Zend\Tool\Project\Context\Filesystem\File
* @category Zend
* @package Zend_Tool
@@ -62,8 +62,8 @@ public function getName()
*/
public function getContents()
{
- $codeGenerator = new \Zend\CodeGenerator\Php\PhpFile(array(
- 'body' => <<<'EOS'
+ $codeGenerator = new \Zend\Code\Generator\FileGenerator();
+ $codeGenerator->setBody( <<<'EOS'
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
@@ -90,7 +90,7 @@ public function getContents()
->run();
EOS
- ));
+ );
return $codeGenerator->generate();
}
View
41 library/Zend/Tool/Project/Context/Zf/TestApplicationControllerFile.php
@@ -23,17 +23,19 @@
* @namespace
*/
namespace Zend\Tool\Project\Context\Zf;
-use Zend\CodeGenerator\Php;
+use Zend\Code\Generator\FileGenerator,
+ Zend\Code\Generator\MethodGenerator,
+ Zend\Code\Generator\ClassGenerator;
/**
* This class is the front most class for utilizing Zend\Tool\Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
- * @uses \Zend\CodeGenerator\Php\PhpClass
- * @uses \Zend\CodeGenerator\Php\PhpFile
- * @uses \Zend\CodeGenerator\Php\PhpMethod
+ * @uses \Zend\Code\Generator\ClassGenerator
+ * @uses \Zend\Code\Generator\FileGenerator
+ * @uses \Zend\Code\Generator\MethodGenerator
* @uses \Zend\Filter\Word\DashToCamelCase
* @uses \Zend\Tool\Project\Context\Filesystem\File
* @category Zend
@@ -84,27 +86,18 @@ public function getContents()
$className = $filter->filter($this->_forControllerName) . 'ControllerTest';
- $codeGenFile = new Php\PhpFile(array(
- 'requiredFiles' => array(
- 'PHPUnit/Framework/TestCase.php'
- ),
- 'classes' => array(
- new Php\PhpClass(array(
- 'name' => $className,
- 'extendedClass' => 'PHPUnit_Framework_TestCase',
- 'methods' => array(
- new Php\PhpMethod(array(
- 'name' => 'setUp',
- 'body' => ' /* Setup Routine */'
- )),
- new Php\PhpMethod(array(
- 'name' => 'tearDown',
- 'body' => ' /* Tear Down Routine */'
- ))
- )
- ))
+ $codeGenFile = new FileGenerator();
+ $codeGenFile->setRequiredFiles(array(
+ 'PHPUnit/Framework/TestCase.php'
+ ));
+ $codeGenFile->setClass(new ClassGenerator($className, null, null, 'PHPUnit_Framework_TestCase', array(), array(), array(
+ 'methods' => array(
+ new MethodGenerator('setUp', array(), MethodGenerator::FLAG_PUBLIC, ' /* Setup Routine */'),
+ new MethodGenerator('tearDown', array(), MethodGenerator::FLAG_PUBLIC, ' /* Tear Down Routine */')
+ )
)
- ));
+ )
+ );
return $codeGenFile->generate();
}
View
38 library/Zend/Tool/Project/Context/Zf/TestLibraryFile.php
@@ -23,17 +23,19 @@
* @namespace
*/
namespace Zend\Tool\Project\Context\Zf;
-use Zend\CodeGenerator\Php;
+use Zend\Code\Generator\FileGenerator,
+ Zend\Code\Generator\ClassGenerator,
+ Zend\Code\Generator\MethodGenerator;
/**
* This class is the front most class for utilizing Zend\Tool\Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
- * @uses \Zend\CodeGenerator\Php\PhpClass
- * @uses \Zend\CodeGenerator\Php\PhpFile
- * @uses \Zend\CodeGenerator\Php\PhpMethod
+ * @uses \Zend\Code\Generator\ClassGenerator
+ * @uses \Zend\Code\Generator\FileGenerator
+ * @uses \Zend\Code\Generator\MethodGenerator
* @uses \Zend\Filter\Word\DashToCamelCase
* @uses \Zend\Tool\Project\Context\Filesystem\File
* @category Zend
@@ -84,28 +86,18 @@ public function getContents()
$className = $filter->filter($this->_forClassName) . 'Test';
- $codeGenFile = new Php\PhpFile(array(
- 'requiredFiles' => array(
+ $codeGenFile = new FileGenerator();
+ $codeGenFile->setRequiredFiles(array(
'PHPUnit/Framework/TestCase.php'
- ),
- 'classes' => array(
- new Php\PhpClass(array(
- 'name' => $className,
- 'extendedClass' => 'PHPUnit_Framework_TestCase',
- 'methods' => array(
- new Php\PhpMethod(array(
- 'name' => 'setUp',
- 'body' => ' /* Setup Routine */'
- )),
- new Php\PhpMethod(array(
- 'name' => 'tearDown',
- 'body' => ' /* Tear Down Routine */'
- ))
- )
- ))
+ ));
+ $codeGenFile->setClasses(array(
+ new ClassGenerator($className, null, null, 'PHPUnit_Framework_TestCase', array(), array(), array(
+ new MethodGenerator('setUp', array(), MethodGenerator::FLAG_PUBLIC, ' /* Setup Routine */'),
+ new MethodGenerator('tearDown', array(), MethodGenerator::FLAG_PUBLIC, ' /* Tear Down Routine */'),
+ )
)
));
-
+
return $codeGenFile->generate();
}
View
8 library/Zend/Tool/Project/Context/Zf/TestPHPUnitBootstrapFile.php
@@ -24,7 +24,7 @@
*/
namespace Zend\Tool\Project\Context\Zf;
-use Zend\CodeGenerator\Php\PhpFile,
+use Zend\Code\Generator\FileGenerator,
Zend\Tool\Project\Context\Filesystem\File as FileContext;
/**
@@ -59,8 +59,8 @@ public function getName()
*/
public function getContents()
{
- $codeGenerator = new PhpFile(array(
- 'body' => <<<EOS
+ $codeGenerator = new FileGenerator();
+ $codeGenerator->setBody( <<<EOS
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
@@ -82,7 +82,7 @@ public function getContents()
\$loader->register();
EOS
- ));
+ );
return $codeGenerator->generate();
}
View
41 tests/Zend/Dom/QueryTest.php
@@ -244,4 +244,45 @@ public function testCssSelectorShouldFindNodesWhenMatchingMultipleAttributes()
$results = $this->query->execute('input[type="hidden"][value="0"]');
$this->assertEquals(1, count($results));
}
+
+ /**
+ * @group ZF-3938
+ */
+ public function testAllowsSpecifyingEncodingAtConstruction()
+ {
+ $doc = new Query($this->getHtml(), 'iso-8859-1');
+ $this->assertEquals('iso-8859-1', $doc->getEncoding());
+ }
+
+ /**
+ * @group ZF-3938
+ */
+ public function testAllowsSpecifyingEncodingWhenSettingDocument()
+ {
+ $this->query->setDocument($this->getHtml(), 'iso-8859-1');
+ $this->assertEquals('iso-8859-1', $this->query->getEncoding());
+ }
+
+ /**
+ * @group ZF-3938
+ */
+ public function testAllowsSpecifyingEncodingViaSetter()
+ {
+ $this->query->setEncoding('iso-8859-1');
+ $this->assertEquals('iso-8859-1', $this->query->getEncoding());
+ }
+
+ /**
+ * @group ZF-3938
+ */
+ public function testSpecifyingEncodingSetsEncodingOnDomDocument()
+ {
+ $this->query->setDocument($this->getHtml(), 'utf-8');
+ $test = $this->query->execute('.foo');
+ $this->assertInstanceof('\\Zend\\Dom\\NodeList', $test);
+ $doc = $test->getDocument();
+ $this->assertInstanceof('\\DOMDocument', $doc);
+ $this->assertEquals('utf-8', $doc->encoding);
+ }
+
}
View
1 tests/Zend/Soap/AutoDiscoverTest.php
@@ -499,7 +499,6 @@ function testAddFunctionMultiple()
'<operation name="ZendTest.Soap.TestAsset.TestFunc2">'.
'<soap:operation soapAction="' . $scriptUri . '#ZendTest.Soap.TestAsset.TestFunc2"/>'.
'<input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></input>'.
- '<output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="' . $scriptUri . '"/></output>'.
'</operation>'.
'<operation name="ZendTest.Soap.TestAsset.TestFunc3">'.
'<soap:operation soapAction="' . $scriptUri . '#ZendTest.Soap.TestAsset.TestFunc3"/>'.
View
43 tests/Zend/Soap/ClientTest.php
@@ -204,6 +204,49 @@ public function testUserAgentAllowsEmptyString()
$this->assertArrayNotHasKey('user_agent', $options);
}
+ /**
+ * @group ZF-10542
+ */
+ public function testAllowNumericZeroAsValueForCacheWsdlOption()
+ {
+ $client = new Client();
+ $this->assertNull($client->getWsdlCache());
+ $options = $client->getOptions();
+ $this->assertArrayNotHasKey('cache_wsdl', $options);
+
+ $client->setWsdlCache(WSDL_CACHE_NONE);
+ $this->assertSame(WSDL_CACHE_NONE, $client->getWsdlCache());
+ $options = $client->getOptions();
+ $this->assertSame(WSDL_CACHE_NONE, $options['cache_wsdl']);
+
+ $client->setWsdlCache(null);
+ $this->assertNull($client->getWsdlCache());
+ $options = $client->getOptions();
+ $this->assertArrayNotHasKey('cache_wsdl', $options);
+ }
+
+ /**
+ * @group ZF-10542
+ */
+ public function testAllowNumericZeroAsValueForCompressionOptions()
+ {
+ $client = new Client();
+ $this->assertNull($client->getCompressionOptions());
+ $options = $client->getOptions();
+ $this->assertArrayNotHasKey('compression', $options);
+
+ $client->setCompressionOptions(SOAP_COMPRESSION_GZIP);
+ $this->assertSame(SOAP_COMPRESSION_GZIP, $client->getCompressionOptions());
+ $options = $client->getOptions();
+ $this->assertSame(SOAP_COMPRESSION_GZIP, $options['compression']);
+
+ $client->setCompressionOptions(null);
+ $this->assertNull($client->getCompressionOptions());
+ $options = $client->getOptions();
+ $this->assertArrayNotHasKey('compression', $options);
+ }
+
+
public function testGetFunctions()
{
$server = new Server(__DIR__ . '/TestAsset/wsdl_example.wsdl');
View
10 tests/Zend/Soap/ServerTest.php
@@ -851,4 +851,14 @@ public function testSetAndGetWSDLCache()
$this->assertTrue(isset($options['cache_wsdl']));
$this->assertEquals(100, $options['cache_wsdl']);
}
+
+ /**
+ * @group ZF-11411
+ */
+ public function testHandleUsesProperRequestParameter()
+ {
+ $server = new \ZendTest\Soap\TestAsset\MockServer();
+ $r = $server->handle(new \DOMDocument('1.0', 'UTF-8'));
+ $this->assertTrue(is_string($server->mockSoapServer->handle[0]));
+ }
}
View
18 tests/Zend/Soap/TestAsset/commontypes.php
@@ -549,6 +549,24 @@ class TestData2 {
public $property2;
}
+class MockSoapServer {
+ public $handle = null;
+ public function handle()
+ {
+ $this->handle = func_get_args();
+ }
+ public function __call($name, $args) {}
+}
+
+class MockServer extends \Zend\Soap\Server {
+ public $mockSoapServer = null;
+ protected function _getSoap() {
+ $this->mockSoapServer = new MockSoapServer();
+ return $this->mockSoapServer;
+ }
+}
+
+
/** Server test classes */
class ServerTestClass
{
View
2 tests/Zend/Soap/Wsdl/ArrayOfTypeComplexStrategyTest.php
@@ -127,7 +127,7 @@ public function testArrayOfObjectWithObject()
);
$this->assertContains(
- '<xsd:complexType name="ZendTest.Soap.TestAsset.ComplexObjectWithObjectStructure"><xsd:all><xsd:element name="object" type="tns:ZendTest.Soap.TestAsset.ComplexTest"/></xsd:all></xsd:complexType>',
+ '<xsd:complexType name="ZendTest.Soap.TestAsset.ComplexObjectWithObjectStructure"><xsd:all><xsd:element name="object" type="tns:ZendTest.Soap.TestAsset.ComplexTest" nillable="true"/></xsd:all></xsd:complexType>',
$wsdl,
$wsdl
);
View
10 tests/Zend/Soap/WsdlTest.php
@@ -204,7 +204,7 @@ function testAddBindingOperation()
'operation3',
array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"),
array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"),
- array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/")
+ array('name' => 'MyFault','use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/")
);
$this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()),
@@ -234,8 +234,8 @@ function testAddBindingOperation()
. '<output>'
. '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
. '</output>'
- . '<fault>'
- . '<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
+ . '<fault name="MyFault">'
+ . '<soap:fault name="MyFault" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>'
. '</fault>'
. '</operation>'
. '</binding>'
@@ -620,8 +620,8 @@ function testAddComplexType()
. '<xsd:schema targetNamespace="http://localhost/MyService.php">'
. '<xsd:complexType name="ZendTest.Soap.TestAsset.WsdlTestClass">'
. '<xsd:all>'
- . '<xsd:element name="var1" type="xsd:int"/>'
- . '<xsd:element name="var2" type="xsd:string"/>'
+ . '<xsd:element name="var1" type="xsd:int" nillable="true"/>'
+ . '<xsd:element name="var2" type="xsd:string" nillable="true"/>'
. '</xsd:all>'
. '</xsd:complexType>'
. '</xsd:schema>'

0 comments on commit 188816b

Please sign in to comment.
Something went wrong with that request. Please try again.