Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
],
"require": {
"php": "^7.1|^8.0",
"goetas-webservices/soap-reader": "^0.3.1",
"goetas-webservices/wsdl-reader": "^0.3",
"goetas-webservices/soap-reader": "*",
"goetas-webservices/wsdl-reader": "*",
"goetas-webservices/xsd2php": "^0.4.1",
"symfony/dependency-injection": "^2.2|^3.0|^4.0|^5.0",
"symfony/config": "^2.2|^3.0|^4.0|^5.0",
"symfony/yaml": "^2.1|^3.0|^4.0|^5.0",
"doctrine/inflector": "^1.0"
"symfony/dependency-injection": "^2.2|^3.0|^4.0|^5.0|^6.0",
"symfony/config": "^2.2|^3.0|^4.0|^5.0|^6.0|^7.0",
"symfony/yaml": "^5.4|^6.0|^7.0",
"doctrine/inflector": "^1.0|^2.0|^3.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0|^8.0",
Expand Down
20 changes: 12 additions & 8 deletions src/Generation/JmsSoapConverter.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
namespace GoetasWebservices\WsdlToPhp\Generation;

use Doctrine\Common\Inflector\Inflector;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
use GoetasWebservices\XML\SOAPReader\Soap\OperationMessage;
use GoetasWebservices\XML\SOAPReader\Soap\Service;
use GoetasWebservices\Xsd\XsdToPhp\Jms\YamlConverter;
Expand All @@ -14,9 +15,12 @@ class JmsSoapConverter extends SoapConverter
protected $converter;
private $classes = [];

private Inflector $inflector;

public function __construct(YamlConverter $converter, array $baseNs = array())
{
$this->converter = $converter;
$this->inflector = InflectorFactory::create()->build();
parent::__construct($baseNs);
}

Expand Down Expand Up @@ -83,7 +87,7 @@ private function visitOperation(\GoetasWebservices\XML\SOAPReader\Soap\Operation
private function visitMessage(OperationMessage $message, $hint, \GoetasWebservices\XML\SOAPReader\Soap\Operation $operation, Service $service)
{
if (!isset($this->classes[spl_object_hash($message)])) {
$className = $this->findPHPName($message, Inflector::classify($hint), $this->baseNs[$service->getVersion()]['parts']);
$className = $this->findPHPName($message, $this->inflector->classify($hint), $this->baseNs[$service->getVersion()]['parts']);
$class = array();
$data = array();
$envelopeData["xml_namespaces"] = ['SOAP' => $this->soapEnvelopeNs];
Expand All @@ -96,7 +100,7 @@ private function visitMessage(OperationMessage $message, $hint, \GoetasWebservic

$this->classes[spl_object_hash($message)] = &$class;

$messageClassName = $this->findPHPName($message, Inflector::classify($hint), $this->baseNs[$service->getVersion()]['messages']);
$messageClassName = $this->findPHPName($message, $this->inflector->classify($hint), $this->baseNs[$service->getVersion()]['messages']);
$envelopeClass = array();
$envelopeData = array();
$envelopeClass[$messageClassName] = &$envelopeData;
Expand Down Expand Up @@ -125,7 +129,7 @@ private function visitMessage(OperationMessage $message, $hint, \GoetasWebservic

$headersData["xml_namespaces"] = ['SOAP' => $this->soapEnvelopeNs];

$className = $this->findPHPName($message, Inflector::classify($hint), $this->baseNs[$service->getVersion()]['headers']);
$className = $this->findPHPName($message, $this->inflector->classify($hint), $this->baseNs[$service->getVersion()]['headers']);

$headersClass[$className] = &$headersData;
$this->classes[] = &$headersClass;
Expand Down Expand Up @@ -172,8 +176,8 @@ private function visitMessageParts(&$data, array $parts, $wrapper = null)
$c = $this->converter->visitType($part->getType());
}

$property["accessor"]["getter"] = "get" . Inflector::classify($name);
$property["accessor"]["setter"] = "set" . Inflector::classify($name);
$property["accessor"]["getter"] = "get" . $this->inflector->classify($name);
$property["accessor"]["setter"] = "set" . $this->inflector->classify($name);

$property["serialized_name"] = $name;

Expand All @@ -183,13 +187,13 @@ private function visitMessageParts(&$data, array $parts, $wrapper = null)
$property["type"] = key($c);
}

$data['properties'][Inflector::camelize($name)] = $property;
$data['properties'][$this->inflector->camelize($name)] = $property;
}
}

private function findPHPName(OperationMessage $message, $hint = '', $nsadd = '')
{
$name = Inflector::classify($message->getMessage()->getOperation()->getName()) . $hint;
$name = $this->inflector->classify($message->getMessage()->getOperation()->getName()) . $hint;
$targetNs = $message->getMessage()->getDefinition()->getTargetNamespace();

$namespaces = $this->converter->getNamespaces();
Expand Down
18 changes: 11 additions & 7 deletions src/Generation/PhpSoapConverter.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
namespace GoetasWebservices\WsdlToPhp\Generation;

use Doctrine\Common\Inflector\Inflector;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
use Exception;
use GoetasWebservices\XML\SOAPReader\Soap\OperationMessage;
use GoetasWebservices\XML\SOAPReader\Soap\Service;
Expand All @@ -15,9 +16,12 @@ class PhpSoapConverter extends SoapConverter

private $converter;

private Inflector $inflector;

public function __construct(PhpConverter $converter, array $baseNs = array())
{
$this->converter = $converter;
$this->inflector = InflectorFactory::create()->build();
parent::__construct($baseNs);
}

Expand Down Expand Up @@ -63,8 +67,8 @@ private function visitMessage(OperationMessage $message, $hint, \GoetasWebservic

$this->classes['__' . spl_object_hash($message)] = $bodyClass = new PHPClass();

list ($name, $ns) = $this->findPHPName($message, Inflector::classify($hint));
$bodyClass->setName(Inflector::classify($name));
list ($name, $ns) = $this->findPHPName($message, $this->inflector->classify($hint));
$bodyClass->setName($this->inflector->classify($name));
$bodyClass->setNamespace($ns . $this->baseNs[$service->getVersion()]['parts']);
if ($message->getBody()->getParts()) {
$this->classes[$bodyClass->getFullName()] = $bodyClass;
Expand All @@ -73,7 +77,7 @@ private function visitMessage(OperationMessage $message, $hint, \GoetasWebservic
$this->visitMessageParts($bodyClass, $message->getBody()->getParts());

$envelopeClass = new PHPClass();
$envelopeClass->setName(Inflector::classify($name));
$envelopeClass->setName($this->inflector->classify($name));
$envelopeClass->setNamespace($ns . $this->baseNs[$service->getVersion()]['messages']);
$envelopeClass->setImplements(['GoetasWebservices\SoapServices\Metadata\Envelope\Envelope']);
$this->classes[$envelopeClass->getFullName()] = $envelopeClass;
Expand All @@ -86,7 +90,7 @@ private function visitMessage(OperationMessage $message, $hint, \GoetasWebservic

$property = new PHPProperty('header');
$headerClass = new PHPClass();
$headerClass->setName(Inflector::classify($name));
$headerClass->setName($this->inflector->classify($name));
$headerClass->setNamespace($ns . $this->baseNs[$service->getVersion()]['headers']);

$this->classes[$headerClass->getFullName()] = $headerClass;
Expand All @@ -112,10 +116,10 @@ private function visitMessageParts(PHPClass $class, array $parts)
$property = new PHPProperty();

if ($part->getElement()) {
$property->setName(Inflector::camelize($part->getElement()->getName()));
$property->setName($this->inflector->camelize($part->getElement()->getName()));
$property->setType($this->converter->visitElementDef($part->getElement()));
} else {
$property->setName(Inflector::camelize($part->getName()));
$property->setName($this->inflector->camelize($part->getName()));
$property->setType($this->converter->visitType($part->getType()));
}

Expand Down
21 changes: 13 additions & 8 deletions src/Generation/SoapConverter.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
namespace GoetasWebservices\WsdlToPhp\Generation;

use Doctrine\Common\Inflector\Inflector;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;
use GoetasWebservices\XML\SOAPReader\Soap\OperationMessage;
use GoetasWebservices\XML\SOAPReader\Soap\Service;
use GoetasWebservices\Xsd\XsdToPhp\Jms\YamlConverter;
Expand All @@ -24,11 +25,15 @@ abstract class SoapConverter
]
];

private Inflector $inflector;

public function __construct(array $baseNs = array())
{
if ($baseNs){
$this->baseNs = $baseNs;
}

$this->inflector = InflectorFactory::create()->build();
}

public function visitServices(array $services)
Expand Down Expand Up @@ -94,7 +99,7 @@ private function visitOperation(\GoetasWebservices\XML\SOAPReader\Soap\Operation
private function visitMessage(OperationMessage $message, $hint, \GoetasWebservices\XML\SOAPReader\Soap\Operation $operation, Service $service)
{
if (!isset($this->classes[spl_object_hash($message)])) {
$className = $this->findPHPName($message, Inflector::classify($hint), $this->baseNs[$service->getVersion()]['parts']);
$className = $this->findPHPName($message, $this->inflector->classify($hint), $this->baseNs[$service->getVersion()]['parts']);
$class = array();
$data = array();
$envelopeData["xml_namespaces"] = ['SOAP' => $this->soapEnvelopeNs];
Expand All @@ -107,7 +112,7 @@ private function visitMessage(OperationMessage $message, $hint, \GoetasWebservic

$this->classes[spl_object_hash($message)] = &$class;

$messageClassName = $this->findPHPName($message, Inflector::classify($hint), $this->baseNs[$service->getVersion()]['messages']);
$messageClassName = $this->findPHPName($message, $this->inflector->classify($hint), $this->baseNs[$service->getVersion()]['messages']);
$envelopeClass = array();
$envelopeData = array();
$envelopeClass[$messageClassName] = &$envelopeData;
Expand Down Expand Up @@ -135,7 +140,7 @@ private function visitMessage(OperationMessage $message, $hint, \GoetasWebservic

$headersData["xml_namespaces"] = ['SOAP' => $this->soapEnvelopeNs];

$className = $this->findPHPName($message, Inflector::classify($hint), $this->baseNs[$service->getVersion()]['headers']);
$className = $this->findPHPName($message, $this->inflector->classify($hint), $this->baseNs[$service->getVersion()]['headers']);

$headersClass[$className] = &$headersData;
$this->classes[] = &$headersClass;
Expand Down Expand Up @@ -172,8 +177,8 @@ private function visitMessageParts(&$data, array $parts, $wrapper = null)
$property["access_type"] = "public_method";


$property["accessor"]["getter"] = "get" . Inflector::classify($part->getName());
$property["accessor"]["setter"] = "set" . Inflector::classify($part->getName());
$property["accessor"]["getter"] = "get" . $this->inflector->classify($part->getName());
$property["accessor"]["setter"] = "set" . $this->inflector->classify($part->getName());


if ($part->getElement()) {
Expand All @@ -191,13 +196,13 @@ private function visitMessageParts(&$data, array $parts, $wrapper = null)
$property["type"] = key($c);
}

$data['properties'][Inflector::camelize($part->getName())] = $property;
$data['properties'][$this->inflector->camelize($part->getName())] = $property;
}
}

private function findPHPName(OperationMessage $message, $hint = '', $nsadd = '')
{
$name = Inflector::classify($message->getMessage()->getOperation()->getName()) . $hint;
$name = $this->inflector->classify($message->getMessage()->getOperation()->getName()) . $hint;
$targetNs = $message->getMessage()->getDefinition()->getTargetNamespace();

$namespaces = $this->converter->getNamespaces();
Expand Down