Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Issues found by hphp static analysis #4444

Closed
wants to merge 11 commits into from
Expand Up @@ -282,14 +282,14 @@ public function getLibOption($id, $key)
throw new Exception\RuntimeException("No resource with id '{$id}'");
}

$constValue = $this->normalizeLibOptionKey($key);
$this->normalizeLibOptionKey($key);
$resource = & $this->resources[$id];

if ($resource instanceof MemcachedResource) {
return $resource->getOption($constValue);
return $resource->getOption($key);
}

return isset($resource['lib_options'][$constValue]) ? $resource['lib_options'][$constValue] : null;
return isset($resource['lib_options'][$key]) ? $resource['lib_options'][$key] : null;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions library/Zend/Cache/Storage/Adapter/RedisResourceManager.php
Expand Up @@ -329,14 +329,14 @@ public function getLibOption($id, $key)
throw new Exception\RuntimeException("No resource with id '{$id}'");
}

$constValue = $this->normalizeLibOptionKey($key);
$this->normalizeLibOptionKey($key);
$resource = & $this->resources[$id];

if ($resource instanceof RedisResource) {
return $resource->getOption($constValue);
return $resource->getOption($key);
}

return isset($resource['lib_options'][$constValue]) ? $resource['lib_options'][$constValue] : null;
return isset($resource['lib_options'][$key]) ? $resource['lib_options'][$key] : null;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions library/Zend/Code/Generator/DocBlockGenerator.php
Expand Up @@ -171,11 +171,11 @@ public function setTag($tag)
if (is_array($tag)) {
$tag = new DockBlockTag($tag);
} elseif (!$tag instanceof DockBlockTag) {
throw new Exception\InvalidArgumentException(
throw new Exception\InvalidArgumentException(sprintf(
'%s expects either an array of method options or an instance of %s\DocBlock\Tag',
__METHOD__,
__NAMESPACE__
);
));
}

$this->tags[] = $tag;
Expand Down
7 changes: 5 additions & 2 deletions library/Zend/Code/Scanner/Util.php
Expand Up @@ -26,9 +26,12 @@ class Util
* @return void
* @throws Exception\InvalidArgumentException
*/
public static function resolveImports(&$value, $key = null, stdClass $data)
public static function resolveImports(&$value, $key = null, stdClass $data = null)
{
if (!property_exists($data, 'uses') || !property_exists($data, 'namespace')) {
if (!is_object($data)
|| !property_exists($data, 'uses')
|| !property_exists($data, 'namespace')
) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects a data object containing "uses" and "namespace" properties; on or both missing',
__METHOD__
Expand Down
4 changes: 1 addition & 3 deletions library/Zend/Feed/Reader/Extension/CreativeCommons/Entry.php
Expand Up @@ -53,9 +53,7 @@ public function getLicenses()

$licenses = array_unique($licenses);
} else {
$cc = new Feed(
$this->domDocument, $this->data['type'], $this->xpath
);
$cc = new Feed();
$licenses = $cc->getLicenses();
}

Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Mail/Storage/Folder/Maildir.php
Expand Up @@ -193,7 +193,7 @@ public function selectFolder($globalName)
throw new Exception\RuntimeException("{$this->currentFolder} is not selectable", 0, $e);
}
// seems like file has vanished; rebuilding folder tree - but it's still an exception
$this->_buildFolderTree($this->rootdir);
$this->_buildFolderTree();
throw new Exception\RuntimeException('seems like the maildir has vanished, I\'ve rebuild the ' .
'folder tree, search for an other folder and try again', 0, $e);
}
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Mvc/View/Console/RouteNotFoundStrategy.php
Expand Up @@ -162,7 +162,7 @@ public function handleRouteNotFoundError(MvcEvent $e)
$banner = $this->getConsoleBanner($console, $mm);

// Get application usage information
$usage = $this->getConsoleUsage($console, $scriptName, $mm, $router);
$usage = $this->getConsoleUsage($console, $scriptName, $mm);

// Inject the text into view
$result = $banner ? rtrim($banner, "\r\n") : '';
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Mvc/View/Http/RouteNotFoundStrategy.php
Expand Up @@ -193,7 +193,7 @@ public function prepareNotFoundViewModel(MvcEvent $e)
$model->setTemplate($this->getNotFoundTemplate());

// If displaying reasons, inject the reason
$this->injectNotFoundReason($model, $e);
$this->injectNotFoundReason($model);

// If displaying exceptions, inject
$this->injectException($model, $e);
Expand Down
7 changes: 5 additions & 2 deletions library/Zend/Serializer/Adapter/PythonPickle.php
Expand Up @@ -421,7 +421,9 @@ protected function writeArrayDict($value)
$this->memorize($value);

foreach ($value as $k => $v) {
$this->pickle .= $this->write($k) . $this->write($v) . self::OP_SETITEM;
$this->write($k);
$this->write($v);
$this->pickle .= self::OP_SETITEM;
}
}

Expand All @@ -441,7 +443,8 @@ protected function writeArrayList(array $value)
$this->memorize($value);

foreach ($value as $v) {
$this->pickle .= $this->write($v) . self::OP_APPEND;
$this->write($v);
$this->pickle .= self::OP_APPEND;
}
}

Expand Down
4 changes: 2 additions & 2 deletions library/Zend/ServiceManager/Di/DiAbstractServiceFactory.php
Expand Up @@ -40,10 +40,10 @@ public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $
{
$this->serviceLocator = $serviceLocator;
if ($requestedName) {
return $this->get($requestedName, array(), true);
return $this->get($requestedName, array());
}

return $this->get($serviceName, array(), true);
return $this->get($serviceName, array());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/ServiceManager/Di/DiServiceFactory.php
Expand Up @@ -81,7 +81,7 @@ public function __construct(Di $di, $name, array $parameters = array(), $useServ
public function createService(ServiceLocatorInterface $serviceLocator)
{
$this->serviceLocator = $serviceLocator;
return $this->get($this->name, $this->parameters, true);
return $this->get($this->name, $this->parameters);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Validator/File/ExcludeMimeType.php
Expand Up @@ -87,7 +87,7 @@ public function isValid($value, $file = null)

if (empty($this->type)) {
$this->error(self::NOT_DETECTED);
false;
return false;
}

$mimetype = $this->getMimeType(true);
Expand Down