Skip to content

Commit

Permalink
Fix Yii::autoload() fails if the class was included before.
Browse files Browse the repository at this point in the history
```php
Yii::autoload(ArrayHelper::class);
Yii::autoload(ArrayHelper::class);
```
caused:
Cannot redeclare class yii\helpers\ArrayHelper in /app/vendor/yiisoft/yii2/helpers/ArrayHelper.php
  • Loading branch information
g19i85g authored and g19i85g committed Jul 16, 2015
1 parent d8a3aaf commit 9ae4da4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
10 changes: 4 additions & 6 deletions WebService.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ public function generateWsdl()
if(is_object($this->provider))
$providerClass=get_class($this->provider);
else{
\Yii::autoload($this->provider);
$providerClass=$this->provider;
}
if($this->wsdlCacheDuration>0 && $this->cacheID!==false && ($cache=\Yii::$app->get($this->cacheID,false))!==null)
Expand Down Expand Up @@ -241,7 +240,7 @@ public function run()
// We need to end application explicitly because of
// http://bugs.php.net/bug.php?id=49513
\Yii::$app->state = Application::STATE_AFTER_REQUEST;
\Yii::$app->trigger(Application::EVENT_AFTER_REQUEST);
\Yii::$app->trigger(Application::EVENT_AFTER_REQUEST);
$reflect = new \ReflectionClass($e);
$server->fault($reflect->getShortName(), $message);
exit(1);
Expand Down Expand Up @@ -283,7 +282,6 @@ protected function getOptions()
$options['encoding']=$this->encoding;
foreach($this->classMap as $type=>$className)
{
\Yii::autoload($className);
if(is_int($type))
$type=$className;
$options['classmap'][$type]=$className;
Expand Down Expand Up @@ -326,7 +324,7 @@ public function __call($name,$arguments)
{
return call_user_func_array(array($this->object,$name),$arguments);
}

/**
* Returns the fully qualified name of this class.
* @return string the fully qualified name of this class.
Expand Down Expand Up @@ -377,9 +375,9 @@ public function __call($name,$arguments)
{
$result = call_user_func_array(array($this->object, $name), $arguments);
}
return $result === null ? $result : array($name . 'Result' => $result);
return $result === null ? $result : array($name . 'Result' => $result);
}

/**
* Returns the fully qualified name of this class.
* @return string the fully qualified name of this class.
Expand Down
1 change: 0 additions & 1 deletion WsdlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ protected function processType($type)
}
else
{ // process class / complex type
\Yii::autoload($type);
$class=new \ReflectionClass($type);

$type=$class->getShortName();
Expand Down

0 comments on commit 9ae4da4

Please sign in to comment.