<commit_before><?php
class commands_GeneratePhpClient extends commands_AbstractChangedevCommand
{
	/**
	 * @return String
	 */
	function getUsage()
	{
		return "<className>";
	}

	/**
	 * @return String
	 */
	function getDescription()
	{
		return "generate PHP client for a given webservice";
	}

	/**
	 * @param String[] $params
	 * @param array<String, String> $options where the option array key is the option name, the potential option value or true
	 */
	protected function validateArgs($params, $options)
	{
		return count($params) == 1;
	}

	/**
	 * @param Integer $completeParamCount the parameters that are already complete in the command line
	 * @param String[] $params
	 * @param array<String, String> $options where the option array key is the option name, the potential option value or true
	 * @return String[] or null
	 */
	function getParameters($completeParamCount, $params, $options, $current)
	{
		if ($completeParamCount == 0)
		{
			$this->loadFramework();
			return ClassResolver::getClassNames($current);
		}
	}

	/**
	 * @param String[] $params
	 * @param array<String, String> $options where the option array key is the option name, the potential option value or true
	 * @see c_ChangescriptCommand::parseArgs($args)
	 */
	function _execute($params, $options)
	{
		$className = $params[0];
		$this->loadFramework();
		$class = new ReflectionClass($className);
		if (!$class->implementsInterface("webservices_WebService"))
		{
			return $this->quitError("$className does not implement webservices_WebService interface");
		}
		


		ob_start();
		echo "<?php\n";
echo '
class wscli_array implements Iterator, ArrayAccess
{
    private $position = 0;  
    public $items = array();  
    
    
    public function rewind() {$this->position = 0;}
    public function current() {return $this->items[$this->position];}
    public function key() {return $this->position;}
    public function next() {++$this->position;}
    public function valid() {return isset($this->items[$this->position]);}
    
 	public function offsetSet($offset, $value) 
 	{
        if (is_null($offset))
        {
            $this->items[] = $value;
        } 
        else 
        {
            $this->items[$offset] = $value;
        }
    }
    public function offsetExists($offset) {return isset($this->items[$offset]);}
    public function offsetUnset($offset) {unset($this->items[$offset]);}
    public function offsetGet($offset) {return isset($this->items[$offset]) ? $this->items[$offset] : null;}
}
';
		
		$classmap = array();
		$wsdlTypes = webservices_ModuleService::getInstance()->getServiceTypeDefinitions($className);
		foreach ($wsdlTypes->getTypes() as $xsdComplex) 
		{
			//$xsdComplex = new webservices_XsdComplex();
			if ($xsdComplex->isArray()) 
			{
				$classmap[$xsdComplex->getType()] = 'wscli_array';
			}
			else
			{
				$classmap[$xsdComplex->getType()] = 'cl_' . $xsdComplex->getType();
			}
		}
		
		foreach ($classmap as $wsdlTypeName => $cn) 
		{
			if ($cn === 'wscli_array') {continue;}
			
			$xsdComplex = $wsdlTypes->getType($wsdlTypeName);
			echo "class $cn {\n";
			foreach ($xsdComplex->getXsdElementArray() as $propName => $xsdPropType) 
			{
				if ($xsdPropType->isArray())<commit_msg>[UPDATE] Mise a jour de la generation du client php d'un webservice<commit_after><?php
class commands_GeneratePhpClient extends commands_AbstractChangedevCommand
{
	/**
	 * @return String
	 */
	function getUsage()
	{
		return "<className>";
	}

	/**
	 * @return String
	 */
	function getDescription()
	{
		return "generate PHP client for a given webservice";
	}

	/**
	 * @param String[] $params
	 * @param array<String, String> $options where the option array key is the option name, the potential option value or true
	 */
	protected function validateArgs($params, $options)
	{
		return count($params) == 1;
	}

	/**
	 * @param Integer $completeParamCount the parameters that are already complete in the command line
	 * @param String[] $params
	 * @param array<String, String> $options where the option array key is the option name, the potential option value or true
	 * @return String[] or null
	 */
	function getParameters($completeParamCount, $params, $options, $current)
	{
		if ($completeParamCount == 0)
		{
			$this->loadFramework();
			return ClassResolver::getClassNames($current);
		}
	}

	/**
	 * @param String[] $params
	 * @param array<String, String> $options where the option array key is the option name, the potential option value or true
	 * @see c_ChangescriptCommand::parseArgs($args)
	 */
	function _execute($params, $options)
	{
		$className = $params[0];
		$this->loadFramework();
		$class = new ReflectionClass($className);
		if (!$class->implementsInterface("webservices_WebService"))
		{
			return $this->quitError("$className does not implement webservices_WebService interface");
		}
		


		ob_start();
		echo "<?php\n";
echo '
class cl_array implements Iterator, ArrayAccess
{
    private $position = 0;  
    public $items = array();  
    
    
    public function rewind() {$this->position = 0;}
    public function current() {return $this->items[$this->position];}
    public function key() {return $this->position;}
    public function next() {++$this->position;}
    public function valid() {return isset($this->items[$this->position]);}
    
 	public function offsetSet($offset, $value) 
 	{
        if (is_null($offset))
        {
            $this->items[] = $value;
        } 
        else 
        {
            $this->items[$offset] = $value;
        }
    }
    public function offsetExists($offset) {return isset($this->items[$offset]);}
    public function offsetUnset($offset) {unset($this->items[$offset]);}
    public function offsetGet($offset) {return isset($this->items[$offset]) ? $this->items[$offset] : null;}
}
';
		
		$classmap = array();
		$wsdlTypes = webservices_ModuleService::getInstance()->getServiceTypeDefinitions($className);
		foreach ($wsdlTypes->getTypes() as $xsdComplex) 
		{
			//$xsdComplex = new webservices_XsdComplex();
			if ($xsdComplex->isArray()) 
			{
				$classmap[$xsdComplex->getType()] = 'cl_array';
			}
			else
			{
				$classmap[$xsdComplex->getType()] = 'cl_' . $xsdComplex->getType();
			}
		}
		
		foreach ($classmap as $wsdlTypeName => $cn) 
		{
			if ($cn === 'cl_array') {continue;}
			
			$xsdComplex = $wsdlTypes->getType($wsdlTypeName);
			echo "class $cn {\n";
			foreach ($xsdComplex->getXsdElementArray() as $propName => $xsdPropType) 
			{
				if ($xsdPropType->isArray())
{'fraction_non_alphanumeric': 0.1474250576479631, 'fraction_numerical': 0.0015372790161414297, 'mean_word_length': 3.74198250728863, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1069921', 'n_tokens_mistral': 2135, 'n_tokens_neox': 1919, 'n_words': 512}