Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client generator #56

Merged
merged 16 commits into from
Nov 24, 2017
Merged

Client generator #56

merged 16 commits into from
Nov 24, 2017

Conversation

janvernieuwe
Copy link
Member

@janvernieuwe janvernieuwe commented Jul 28, 2017

Ready for review

Copy link
Contributor

@veewee veewee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small remarks on the WIP. I'll have to play around with it and try some 'crappy' soap servers to see how it behaves.

@@ -32,7 +46,7 @@ class Config implements ConfigInterface
* @var array
*/
protected $soapOptions = [
'trace' => false,
'trace' => false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @internal param string $xsdName
* @internal param Property[] $properties
*/
public function __construct($name, $namespace, ClientMethodMap $methods)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use strict string types here

/**
* @var Method[]
*/
private $parameters;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type is Parameter[] instead of Method[]

* @internal param string $xsdName
* @internal param Property[] $properties
*/
public function __construct($functionString, $parameterNamespace = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strict types. Instead of null you can use an empty string

public function __construct($functionString, $parameterNamespace = null)
{
$this->parameterNamespace = $parameterNamespace ?: '';
$this->parameters = $this->parseParameters($functionString);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parsing should not occur in the constructor.
You can create a names constructor for this or maybe it's even better to move the parsing to a separate class or to the SoapClient class. This last one makes the package more consistent.

$properties = explode(',', $properties[1]);
foreach ($properties as $property) {
list($type) = explode(' ', $property);
$parameters[] = new Parameter($type, $this->parameterNamespace.'\\'.$type);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the parameter namespace for? The model should be as close to soap as possible. The namespace shouldn't be here I think

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the type namespace

*/
public function __construct(array $methods, $parameterNamespace = null)
{
foreach ($methods as $method) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably better to move this logic to the names constructor instead?

* @param string $parameterNamespace
* @return ClientMethodMap
*/
public static function fromSoapClient(SoapClient $client, $parameterNamespace = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string $parameterNamespace = ''

*
* @package Phpro\SoapClient\Console\Command
*/
class GenerateClientCommand extends Command
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one looks hard on the type generator command. Maybe we can move some logic to helpers?
Maybe we can also rethink the commands a bit - since I do not think they are working 100% like they should.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already have so many changes, I'd prefer it if we can do this in a separate issue.

'return $this->call(\'%1$s\', $%1$s);',
$param->getName()
),
'returntype' => '\\'.$method->getParameterNamespace().'\\'.$method->getReturnType(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be normalized. @tombevers is working on a TypeChecker in #61

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should i wait on Tom's PR?

@veewee veewee changed the title Client generator (WiP) Client generator Sep 29, 2017
@janvernieuwe janvernieuwe added this to the 0.5.3 milestone Oct 27, 2017
@veewee veewee modified the milestones: 0.5.3, 0.6.0 Oct 27, 2017
@janvernieuwe janvernieuwe merged commit 524c5c2 into phpro:master Nov 24, 2017
@veewee veewee mentioned this pull request Nov 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants