Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelcom committed Sep 6, 2015
2 parents 7577890 + 685d9aa commit 773746d
Show file tree
Hide file tree
Showing 37 changed files with 20,783 additions and 93 deletions.
37 changes: 17 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
CHANGELOG
=========
# CHANGELOG

1.0.0RC04
---------
## 1.0.0
First major release:
- issue #32 - Wrong Header Namespace ?
- issue #31 - Unable to create function parameter for method "mapIpndDetailsToNumber" with type "NULL"
- **BC**:
- \Generator\Generator::_generateClasses_() has been renamed to _generatePackage_

## 1.0.0RC04
- issue #29 - Throw an exception instead of returning false
- add getValidValues to EnumType generated class
- issue #28 - Define the destination folder name for each type
Expand All @@ -16,12 +21,10 @@ CHANGELOG
- issue #13 - classmap and namespaces are wrong when not using a prefix
- issue #21 - Inherited class generates wrong object in php

1.0.0RC03
---------
## 1.0.0RC03
- Fix URL to download phar file

1.0.0RC02
---------
## 1.0.0RC02
- Add wsdltophp.phar file using Box project to create it, ```wsdltophp.phar``` should be used from now instead of ```console```
- Move classes under src folder, rename Tests to tests, rename Resources to resources, update composer.json and phpunit accordingly
- **BC**:
Expand All @@ -47,8 +50,7 @@ CHANGELOG
- Remove no more used methods/constants from Model\AbstractModel
- Add editor config file

1.0.0RC01
---------
## 1.0.0RC01
- First major release candidate version
- Deep refactoring of all old original classes
- Performance optimizations
Expand All @@ -70,23 +72,18 @@ CHANGELOG
- SubCategory,
- InheritsClassIdentifier

0.0.5
-----
## 0.0.5
- Fix unit tests according to previous changes

0.0.4
-----
## 0.0.4
- issue #9 - Leading zero not taken into account in enumeration classes
- 10 - --wsdl-genautoload=false also controls creation of sample.php file (console mode)

0.0.3
-----
## 0.0.3
- 7 - PHP warning on str_repeat()

0.0.2
-----
## 0.0.2
- Create tag with correct composer.json file

0.0.1
-----
## 0.0.1
- Initial version created from original project WsdlToPhp.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ $ phpunit
```
You have several ```testsuite```s available which run test in the proper order:

- **command**: tests command class
- **configuration**: tests configuration readers
- **utils**: tests utils class
- **domhandler**: tests dom handlers (Basic and Wsdl + Tag)
Expand Down
Binary file modified bin/wsdltophp.phar
Binary file not shown.
7 changes: 7 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
</php>
<testsuites>
<testsuite name="full">
<directory>./tests/Command/</directory>
<directory>./tests/ConfigurationReader/</directory>
<directory>./tests/Generator</directory>
<file>./tests/DomHandler/DomDocumentHandlerTest.php</file>
<file>./tests/DomHandler/NodeHandlerTest.php</file>
<file>./tests/DomHandler/ElementHandlerTest.php</file>
<file>./tests/DomHandler/AttributeHandlerTest.php</file>
<file>./tests/DomHandler/NameSpaceHandlerTest.php</file>
<file>./tests/DomHandler/Wsdl/WsdlHandlerTest.php</file>
<directory>./tests/DomHandler/Wsdl/Tag/</directory>
<directory>./tests/File</directory>
Expand All @@ -24,6 +26,10 @@
<directory>./tests/Parser/</directory>
</testsuite>

<testsuite name="command">
<directory>./tests/Command/</directory>
</testsuite>

<testsuite name="configuration">
<directory>./tests/ConfigurationReader/</directory>
</testsuite>
Expand All @@ -45,6 +51,7 @@
<file>./tests/DomHandler/NodeHandlerTest.php</file>
<file>./tests/DomHandler/ElementHandlerTest.php</file>
<file>./tests/DomHandler/AttributeHandlerTest.php</file>
<file>./tests/DomHandler/NameSpaceHandlerTest.php</file>
<file>./tests/DomHandler/Wsdl/WsdlHandlerTest.php</file>
<directory>./tests/DomHandler/Wsdl/Tag/</directory>
</testsuite>
Expand Down
23 changes: 9 additions & 14 deletions src/Command/GeneratePackageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ protected function execute(InputInterface $input, OutputInterface $output)

$this->initGeneratorOptions();

if ($this->canExecute()) {
if ($this->canExecute() === true) {
$this
->initGenerator()
->getGenerator()
->generateClasses();
} else {
->generatePackage();
} elseif ($this->canExecute() === false) {
$this->writeLn(" Generation not launched, use \"--force\" option to force generation");
$this->writeLn(" Used generator's options:");
$this->writeLn(" " . implode(PHP_EOL . ' ', $this->formatArrayForConsole($this->generatorOptions->toArray())));
Expand Down Expand Up @@ -143,17 +143,12 @@ protected function initGeneratorOptions()
foreach ($this->getPackageGenerationCommandLineOptions() as $optionName=>$optionMethod) {
$optionValue = $this->formatOptionValue($this->input->getOption($optionName));
if ($optionValue !== null) {
$setOption = sprintf('set%s', $optionMethod);
if (method_exists($generatorOptions, $setOption)) {
call_user_func_array(array(
$generatorOptions,
$setOption,
), array(
$optionValue,
));
} else {
$this->writeLn(sprintf('Method "%s" not found', $setOption));
}
call_user_func_array(array(
$generatorOptions,
sprintf('set%s', $optionMethod),
), array(
$optionValue,
));
}
}
$this->generatorOptions = $generatorOptions;
Expand Down
7 changes: 7 additions & 0 deletions src/ConfigurationReader/AbstractYamlReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,11 @@ protected function parseSimpleArray($filename, $mainKey)
}
return $values[$mainKey];
}
/**
* For tests purpose only!
*/
public static function resetInstances()
{
self::$instances = array();
}
}
11 changes: 0 additions & 11 deletions src/DomHandler/NameSpaceHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ public function __construct(\DOMNameSpaceNode $nameSpaceNode, AbstractDomDocumen
parent::__construct(new \DOMAttr($nameSpaceNode->nodeName, $nameSpaceNode->nodeValue), $domDocumentHandler, $index);
$this->nodeNameSpace = $nameSpaceNode;
}
/**
* @see \WsdlToPhp\PackageGenerator\DomHandler\AbstractNodeHandler::getParent()
* @return AbstractNodeHandler
*/
public function getParent()
{
if ($this->nodeNameSpace->parentNode instanceof \DOMNode) {
return $this->getDomDocumentHandler()->getHandler($this->nodeNameSpace->parentNode);
}
return null;
}
/**
* value is always with [http|https]:// so we need to keep the full value
* @param bool $withNamespace
Expand Down
24 changes: 18 additions & 6 deletions src/DomHandler/Wsdl/Tag/AbstractTagImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@

abstract class AbstractTagImport extends AbstractTag
{
/**
* @var string
*/
const ATTRIBUTE_LOCATION = 'location';
/**
* @var string
*/
const ATTRIBUTE_SCHEMA_LOCATION = 'schemaLocation';
/**
* @var string
*/
const ATTRIBUTE_SCHEMA_LOCATION_ = 'schemalocation';
/**
* Return the correct location attribute value
* @return string
*/
public function getLocationAttribute()
{
$location = '';
if ($this->hasAttribute('location')) {
$location = $this->getAttribute('location')->getValue(true);
} elseif ($this->hasAttribute('schemaLocation')) {
$location = $this->getAttribute('schemaLocation')->getValue(true);
} elseif ($this->hasAttribute('schemalocation')) {
$location = $this->getAttribute('schemaLocation')->getValue(true);
if ($this->hasAttribute(self::ATTRIBUTE_LOCATION)) {
$location = $this->getAttribute(self::ATTRIBUTE_LOCATION)->getValue(true);
} elseif ($this->hasAttribute(self::ATTRIBUTE_SCHEMA_LOCATION)) {
$location = $this->getAttribute(self::ATTRIBUTE_SCHEMA_LOCATION)->getValue(true);
} elseif ($this->hasAttribute(self::ATTRIBUTE_SCHEMA_LOCATION_)) {
$location = $this->getAttribute(self::ATTRIBUTE_SCHEMA_LOCATION_)->getValue(true);
}
if (!empty($location) && substr($location, 0, 2) === './') {
$location = substr($location, 2);
Expand Down
38 changes: 29 additions & 9 deletions src/DomHandler/Wsdl/Tag/TagHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,39 @@ public function getHeaderName()
*/
public function getHeaderNamespace()
{
$messageNamespace = $this->getAttributeMessageNamespace();
if (empty($messageNamespace) || ($namespace = $this->getDomDocumentHandler()->getNamespaceUri($messageNamespace)) === '') {
$part = $this->getPartTag();
$namespace = '';
if ($part instanceof TagPart) {
$finalNamespace = $part->getFinalNamespace();
if (!empty($finalNamespace)) {
$namespace = $this->getDomDocumentHandler()->getNamespaceUri($finalNamespace);
}
$namespace = $this->getHeaderNamespaceFromPart();
if (empty($namespace)) {
$namespace = $this->getHeaderNamespaceFromMessage();
}
return $namespace;
}
/**
* @return string
*/
protected function getHeaderNamespaceFromPart()
{
$part = $this->getPartTag();
$namespace = '';
if ($part instanceof TagPart) {
$finalNamespace = $part->getFinalNamespace();
if (!empty($finalNamespace)) {
$namespace = $this->getDomDocumentHandler()->getNamespaceUri($finalNamespace);
}
}
return $namespace;
}
/**
* @return string
*/
protected function getHeaderNamespaceFromMessage()
{
$namespace = '';
$messageNamespace = $this->getAttributeMessageNamespace();
if (!empty($messageNamespace)) {
$namespace = $this->getDomDocumentHandler()->getNamespaceUri($messageNamespace);
}
return $namespace;
}
/**
* @return string
*/
Expand Down
2 changes: 1 addition & 1 deletion src/File/AbstractOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected function getMethodParameter($name, $type = null)
try {
return new PhpFunctionParameter($name, PhpFunctionParameter::NO_VALUE, $type);
} catch (\InvalidArgumentException $exception) {
throw new \InvalidArgumentException(sprintf('Unable to create function parameter for method "%s" with type "%s"', $this->getMethod()->getName(), var_export($type, true)), __LINE__, $exception);
throw new \InvalidArgumentException(sprintf('Unable to create function parameter for method "%s" with type "%s" and name "%s"', $this->getMethod()->getName(), var_export($type, true), $name), __LINE__, $exception);
}
}
/**
Expand Down
9 changes: 6 additions & 3 deletions src/File/StructEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ protected function getClassMethods(MethodContainer $methods)
*/
protected function getMethodAnnotationBlock(PhpMethod $method)
{
$block = null;
switch ($method->getName()) {
case self::METHOD_GET_VALID_VALUES:
return $this->getEnumGetValidValuesAnnotationBlock();
$block = $this->getEnumGetValidValuesAnnotationBlock();
break;
case self::METHOD_VALUE_IS_VALID:
return $this->getEnumValueIsValidAnnotationBlock();
$block = $this->getEnumValueIsValidAnnotationBlock();
break;
}
return null;
return $block;
}
/**
* @return PhpMethod
Expand Down
15 changes: 3 additions & 12 deletions src/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ public function getFiles()
protected function initDirectory()
{
Utils::createDirectory($this->getOptions()->getDestination());
if (!is_dir($this->getOptionDestination())) {
throw new \InvalidArgumentException(sprintf('Unable to use dir "%s" as dir does not exists and its creation has been impossible', $this->getOptionDestination()), __LINE__);
if (!is_writable($this->getOptionDestination())) {
throw new \InvalidArgumentException(sprintf('Unable to use dir "%s" as dir does not exists, its creation has been impossible or it\'s not writable', $this->getOptionDestination()), __LINE__);
}
return $this;
}
Expand Down Expand Up @@ -170,7 +170,7 @@ protected function doGenerate()
* Generates all classes based on options
* @return Generator
*/
public function generateClasses()
public function generatePackage()
{
return $this
->doSanityChecks()
Expand Down Expand Up @@ -772,15 +772,6 @@ public function getOptions()
{
return $this->options;
}
/**
* @param GeneratorSoapClient $soapClient
* @return Generator
*/
protected function setSoapClient(GeneratorSoapClient $soapClient)
{
$this->soapClient = $soapClient;
return $this;
}
/**
* @return GeneratorSoapClient
*/
Expand Down
8 changes: 2 additions & 6 deletions src/Model/AbstractModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,8 @@ public function __construct(Generator $generator, $name)
public function getExtendsClassName()
{
$extends = '';
if (($model = $this->getInheritedMoel()) instanceof Struct) {
if ($model->getIsStruct()) {
$extends = $model->getPackagedName();
}
} elseif (class_exists($this->getInheritance()) && stripos($this->getInheritance(), $this->getGenerator()->getOptionPrefix()) === 0) {
$extends = $this->getInheritance();
if (($model = $this->getInheritedMoel()) instanceof Struct && $model->getIsStruct()) {
$extends = $model->getPackagedName();
}
if (empty($extends)) {
$extends = $this->getExtends(true);
Expand Down
1 change: 1 addition & 0 deletions src/Model/Struct.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public function getAttributes($includeInheritanceAttributes = false, $requiredFi
}
/**
* @param bool $includeInheritanceAttributes
* @param bool $requiredFirst
* @return StructAttributeContainer
*/
protected function getAllAttributes($includeInheritanceAttributes, $requiredFirst)
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Wsdl/AbstractTagInputOutputParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function parseInputOutput(AbstractTagOperationElement $tag)
$types = array();
foreach ($parts as $part) {
if (($type = $this->getTypeFromPart($part)) !== '') {
$types[] = $type;
$types[$part->getAttributeName()] = $type;
}
}
$this->setKnownType($method, $types);
Expand Down
4 changes: 3 additions & 1 deletion src/Parser/Wsdl/TagHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use WsdlToPhp\PackageGenerator\DomHandler\Wsdl\Wsdl as WsdlDocument;
use WsdlToPhp\PackageGenerator\DomHandler\Wsdl\Tag\TagHeader as Header;
use WsdlToPhp\PackageGenerator\DomHandler\Wsdl\Tag\TagOperation as Operation;
use WsdlToPhp\PackageGenerator\DomHandler\Wsdl\Tag\TagInput as Input;
use WsdlToPhp\PackageGenerator\Model\Wsdl;
use WsdlToPhp\PackageGenerator\Model\Method;

Expand Down Expand Up @@ -50,7 +51,8 @@ protected function parsingTag()
public function parseHeader(Header $header)
{
$operation = $header->getParentOperation();
if ($operation instanceof Operation) {
$input = $header->getParentInput();
if ($operation instanceof Operation && $input instanceof Input) {
$serviceMethod = $this->getModel($operation);
if ($serviceMethod instanceof Method && !$this->isSoapHeaderAlreadyDefined($serviceMethod, $header->getHeaderName())) {
$serviceMethod
Expand Down
Loading

0 comments on commit 773746d

Please sign in to comment.