Skip to content

Commit

Permalink
Merge 'mabe/CodeOptimations'
Browse files Browse the repository at this point in the history
Conflicts:
	library/Zend/Feed/Reader/Reader.php
  • Loading branch information
weierophinney committed Jul 29, 2010
2 parents 5f8f06a + baea9f9 commit 4307b16
Show file tree
Hide file tree
Showing 48 changed files with 85 additions and 80 deletions.
11 changes: 7 additions & 4 deletions library/Zend/Amf/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,17 @@ protected function _checkAcl($object, $function)
return true;
}
if($object) {
$class = is_object($object)?get_class($object):$object;
$class = is_object($object) ? get_class($object) : $object;
if(!$this->_acl->hasResource($class)) {
$this->_acl->addResource(new \Zend\Acl\Resource\GenericResource($class));
}
$call = array($object, "initAcl");
if(is_callable($call) && !call_user_func($call, $this->_acl)) {
if (method_exists($object, 'initAcl')) {
// if initAcl returns false, no ACL check
return true;
if ($isObject && $object->initAcl($this->_acl)) {
return true;
} elseif ($class::initAcl($this->_acl)) {
return true;
}
}
} else {
$class = null;
Expand Down
7 changes: 3 additions & 4 deletions library/Zend/Application/Resource/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,13 @@ protected function _setDefaults($type)
if(isset($options[$key]['email']) &&
!is_numeric($options[$key]['email']))
{
$method = array('Zend\\Mail\\Mail', 'setDefault' . ucfirst($type));
$method = 'setDefault' . ucfirst($type);
if(isset($options[$key]['name']) &&
!is_numeric($options[$key]['name']))
{
call_user_func($method, $options[$key]['email'],
$options[$key]['name']);
\Zend\Mail\Mail::$method($options[$key]['email'], $options[$key]['name']);
} else {
call_user_func($method, $options[$key]['email']);
\Zend\Mail\Mail::$method($options[$key]['email']);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Barcode/Renderer/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public function render()
$this->draw();
header("Content-Type: image/" . $this->_imageType);
$functionName = 'image' . $this->_imageType;
call_user_func($functionName, $this->_resource);
$functionName($this->_resource);
@imagedestroy($this->_resource);
}

Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Cache/Backend/StaticBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,6 @@ protected function _octdec($val)
*/
protected function _decodeId($id)
{
return pack('H*', $id);;
return pack('H*', $id);
}
}
2 changes: 1 addition & 1 deletion library/Zend/Controller/Router/Rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ protected function _getRouteFromConfig(Config\Config $info)
throw new \InvalidArgumentException('Class name ' . $class . ' does not exist.');
}

$route = call_user_func(array($class, 'getInstance'), $info);
$route = $class::getInstance($info);

if (isset($info->abstract) && $info->abstract && method_exists($route, 'isAbstract')) {
$route->isAbstract(true);
Expand Down
5 changes: 3 additions & 2 deletions library/Zend/GData/App/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ public function __get($name)
{
$method = 'get'.ucfirst($name);
if (method_exists($this, $method)) {
return call_user_func(array(&$this, $method));
return $this->$method();
} else if (property_exists($this, "_${name}")) {
return $this->{'_' . $name};
} else {
Expand All @@ -496,12 +496,13 @@ public function __get($name)
*
* @param string $name
* @param string $value
* @return void
*/
public function __set($name, $val)
{
$method = 'set'.ucfirst($name);
if (method_exists($this, $method)) {
return call_user_func(array(&$this, $method), $val);
$this->$method($val);
} else if (isset($this->{'_' . $name}) || ($this->{'_' . $name} === null)) {
$this->{'_' . $name} = $val;
} else {
Expand Down
5 changes: 3 additions & 2 deletions library/Zend/GData/App/BaseMediaSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function __get($name)
{
$method = 'get'.ucfirst($name);
if (method_exists($this, $method)) {
return call_user_func(array(&$this, $method));
return $this->$method();
} else if (property_exists($this, "_${name}")) {
return $this->{'_' . $name};
} else {
Expand All @@ -132,12 +132,13 @@ public function __get($name)
*
* @param string $name
* @param string $value
* @return void
*/
public function __set($name, $val)
{
$method = 'set'.ucfirst($name);
if (method_exists($this, $method)) {
return call_user_func(array(&$this, $method), $val);
$this->$method($val);
} else if (isset($this->{'_' . $name}) || ($this->{'_' . $name} === null)) {
$this->{'_' . $name} = $val;
} else {
Expand Down
5 changes: 2 additions & 3 deletions library/Zend/GData/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,11 @@ public function getCategory()
return $this->_category;
}


public function __get($name)
{
$method = 'get'.ucfirst($name);
if (method_exists($this, $method)) {
return call_user_func(array(&$this, $method));
return $this->$method();
} else {
throw new App\Exception('Property ' . $name . ' does not exist');
}
Expand All @@ -408,7 +407,7 @@ public function __set($name, $val)
{
$method = 'set'.ucfirst($name);
if (method_exists($this, $method)) {
return call_user_func(array(&$this, $method), $val);
$this->$method($val);
} else {
throw new App\Exception('Property ' . $name . ' does not exist');
}
Expand Down
6 changes: 4 additions & 2 deletions library/Zend/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ public static function loadClass($class, $dirs = null)
$className = ltrim($class, '\\');
$file = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$file = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
$file = (DIRECTORY_SEPARATOR != '\\') // small speed up on windows
? str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR
: $namespace . DIRECTORY_SEPARATOR;
}
$file .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';

Expand Down
18 changes: 9 additions & 9 deletions library/Zend/Locale/PhpMath.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ class PhpMath extends Math
public static function disable()
{
self::$_bcmathDisabled = true;
self::$add = 'Zend\\Locale\\PhpMath::Add';
self::$sub = 'Zend\\Locale\\PhpMath::Sub';
self::$pow = 'Zend\\Locale\\PhpMath::Pow';
self::$mul = 'Zend\\Locale\\PhpMath::Mul';
self::$div = 'Zend\\Locale\\PhpMath::Div';
self::$comp = 'Zend\\Locale\\PhpMath::Comp';
self::$sqrt = 'Zend\\Locale\\PhpMath::Sqrt';
self::$mod = 'Zend\\Locale\\PhpMath::Mod';
self::$scale = 'Zend\\Locale\\PhpMath::Scale';
self::$add = 'Zend\Locale\PhpMath::Add';
self::$sub = 'Zend\Locale\PhpMath::Sub';
self::$pow = 'Zend\Locale\PhpMath::Pow';
self::$mul = 'Zend\Locale\PhpMath::Mul';
self::$div = 'Zend\Locale\PhpMath::Div';
self::$comp = 'Zend\Locale\PhpMath::Comp';
self::$sqrt = 'Zend\Locale\PhpMath::Sqrt';
self::$mod = 'Zend\Locale\PhpMath::Mod';
self::$scale = 'Zend\Locale\PhpMath::Scale';

self::$defaultScale = 0;
self::$defaultPrecision = 1;
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Log/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected function _constructFromConfig($type, $config, $namespace)
);
}

return call_user_func(array($className, 'factory'), $params);
return $className::factory($params);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/OAuth/Config/StandardConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function setSignatureMethod($method)
. $method
. '. Supported are HMAC-SHA1, RSA-SHA1, PLAINTEXT and HMAC-SHA256');
}
$this->_signatureMethod = $method;;
$this->_signatureMethod = $method;
return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Reflection/ReflectionFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ protected function _reflect()
// Name of something
case T_STRING:
if ($functionTrapped) {
$this->_functions[] = ($this->_namespace) ? $this->_namespace . $value : $value;;
$this->_functions[] = ($this->_namespace) ? $this->_namespace . $value : $value;
$functionTrapped = false;
} elseif ($classTrapped) {
$this->_classes[] = ($this->_namespace) ? $this->_namespace . $value : $value;
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Service/Amazon/Amazon.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ protected function _prepareOptions($query, array $options, array $defaultOptions
$options = array_merge($defaultOptions, $options);

if($this->_secretKey !== null) {
$options['Timestamp'] = gmdate("Y-m-d\TH:i:s\Z");;
$options['Timestamp'] = gmdate("Y-m-d\TH:i:s\Z");
ksort($options);
$options['Signature'] = self::computeSignature($this->_baseUri, $this->_secretKey, $options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace Zend\Session\Configuration;

use Zend\Validator\Hostname\Hostname as HostnameValidator,
Zend\Session\Exception as SessionException;;
Zend\Session\Exception as SessionException;

/**
* Session configuration proxying to session INI options
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/SignalSlot/GlobalSignals.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static function emitUntil($callback, $signal, $args = null)
$signals = self::getInstance();
$args = func_get_args();
$args = array_slice($args, 2);
return call_user_func(array($signals, 'emitUntil'), $callback, $signal, $args);
return $signals->emitUntil($callback, $signal, $args);
}

/**
Expand Down
7 changes: 3 additions & 4 deletions library/Zend/Soap/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -963,11 +963,10 @@ public function getLastMethod()
public function _doRequest(Client\Common $client, $request, $location, $action, $version, $one_way = null)
{
// Perform request as is
if ($one_way == null) {
return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version);
} else {
return call_user_func(array($client,'SoapClient::__doRequest'), $request, $location, $action, $version, $one_way);
if ($one_way === null) {
return $client->__doRequest($request, $location, $action, $version);
}
return $client->__doRequest($request, $location, $action, $version, $one_way);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions library/Zend/Stdlib/SignalHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ protected function _validateStringCallback($callback)
throw new InvalidCallbackException('Provided callback is not a function or a class');
}

$object = new $callback();
if (!is_callable($object)) {
// check __invoke before instantiating
if (!method_exists($callback, '__invoke')) {
throw new InvalidCallbackException('Class provided as a callback does not implement __invoke');
}
$object = new $callback();

$this->_callback = $object;
$this->_isValidCallback = true;
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Tool/Project/Context/Filesystem/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected function _initFileOnlyContext()
if ($this->_resource->hasAttribute('defaultContentCallback')) {
$contentFunc = $this->_resource->getAttribute('defaultContentCallback');
if (is_callable($contentFunc)) {
$this->_content = call_user_func_array($contentFunc, array($this));
$this->_content = call_user_func($contentFunc, $this);
}
}
if ($this->_filesystemName == null) {
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Validator/Barcode/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function checksum($value)
$checksum = $this->getChecksum();
if (!empty($checksum)) {
if (method_exists($this, $checksum)) {
return call_user_func(array($this, $checksum), $value);
return $this->$checksum($value);
}
}

Expand Down
2 changes: 1 addition & 1 deletion library/Zend/View/AbstractView.php
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ private function _filter($buffer)
foreach ($this->_filter as $name) {
// load and apply the filter class
$filter = $this->getFilter($name);
$buffer = call_user_func(array($filter, 'filter'), $buffer);
$buffer = $filter->filter($buffer);
}

// done!
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/XmlRpc/Server/Fault.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function __construct(\Exception $e)
// Notify exception observers, if present
if (!empty(self::$_observers)) {
foreach (array_keys(self::$_observers) as $observer) {
call_user_func(array($observer, 'observe'), $this);
$observer::observe($this);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function ZendTest_Autoloader($class)
break;
default:
$file = false;
break;;
break;
}

if ($file) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Zend/Feed/Reader/Feed/RssTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ public function testGetsAuthorArrayFromRss090_Dc10()
$this->assertEquals(array(
array('name'=>'Joe Bloggs'), array('name'=>'Jane Bloggs')
), (array) $feed->getAuthors());
$this->assertEquals(array('Joe Bloggs','Jane Bloggs'), $feed->getAuthors()->getValues());;
$this->assertEquals(array('Joe Bloggs','Jane Bloggs'), $feed->getAuthors()->getValues());
}

// DC 1.1
Expand Down
2 changes: 1 addition & 1 deletion tests/Zend/Feed/Writer/Renderer/Entry/RssTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function setUp()
$this->_validEntry = $this->_validWriter->createEntry();
$this->_validEntry->setTitle('This is a test entry.');
$this->_validEntry->setDescription('This is a test entry description.');
$this->_validEntry->setLink('http://www.example.com/1');;
$this->_validEntry->setLink('http://www.example.com/1');
$this->_validWriter->addEntry($this->_validEntry);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Zend/GData/Books/VolumeFeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private function verifyAllSamplePropertiesAreCorrect ($volumeFeed) {
$this->assertEquals('http://schemas.google.com/g/2005#kind', $volumeFeed->category[0]->scheme);
$this->assertEquals('http://schemas.google.com/books/2008#volume', $volumeFeed->category[0]->term);
$this->assertEquals('text', $volumeFeed->title->type);
$this->assertEquals('Search results for Hamlet', $volumeFeed->title->text);;
$this->assertEquals('Search results for Hamlet', $volumeFeed->title->text);
$this->assertEquals('self', $volumeFeed->getLink('self')->rel);
$this->assertEquals('application/atom+xml', $volumeFeed->getLink('self')->type);
$this->assertEquals('http://www.google.com/books/feeds/volumes?q=Hamlet&start-index=3&max-results=5', $volumeFeed->getLink('self')->href);
Expand Down
2 changes: 1 addition & 1 deletion tests/Zend/GData/GApps/EmailListEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private function verifyAllSamplePropertiesAreCorrect ($emailListEntry) {
$this->assertEquals('http://schemas.google.com/g/2005#kind', $emailListEntry->category[0]->scheme);
$this->assertEquals('http://schemas.google.com/apps/2006#emailList', $emailListEntry->category[0]->term);
$this->assertEquals('text', $emailListEntry->title->type);
$this->assertEquals('us-sales', $emailListEntry->title->text);;
$this->assertEquals('us-sales', $emailListEntry->title->text);
$this->assertEquals('self', $emailListEntry->getLink('self')->rel);
$this->assertEquals('application/atom+xml', $emailListEntry->getLink('self')->type);
$this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales', $emailListEntry->getLink('self')->href);
Expand Down
2 changes: 1 addition & 1 deletion tests/Zend/GData/GApps/EmailListRecipientEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private function verifyAllSamplePropertiesAreCorrect ($emailListRecipientEntry)
$this->assertEquals('http://schemas.google.com/g/2005#kind', $emailListRecipientEntry->category[0]->scheme);
$this->assertEquals('http://schemas.google.com/apps/2006#emailList.recipient', $emailListRecipientEntry->category[0]->term);
$this->assertEquals('text', $emailListRecipientEntry->title->type);
$this->assertEquals('SusanJones', $emailListRecipientEntry->title->text);;
$this->assertEquals('SusanJones', $emailListRecipientEntry->title->text);
$this->assertEquals('self', $emailListRecipientEntry->getLink('self')->rel);
$this->assertEquals('application/atom+xml', $emailListRecipientEntry->getLink('self')->type);
$this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/emailList/2.0/us-sales/recipient/SusanJones%40example.com', $emailListRecipientEntry->getLink('self')->href);
Expand Down
2 changes: 1 addition & 1 deletion tests/Zend/GData/GApps/NicknameEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private function verifyAllSamplePropertiesAreCorrect ($nicknameEntry) {
$this->assertEquals('http://schemas.google.com/g/2005#kind', $nicknameEntry->category[0]->scheme);
$this->assertEquals('http://schemas.google.com/apps/2006#nickname', $nicknameEntry->category[0]->term);
$this->assertEquals('text', $nicknameEntry->title->type);
$this->assertEquals('Susy', $nicknameEntry->title->text);;
$this->assertEquals('Susy', $nicknameEntry->title->text);
$this->assertEquals('self', $nicknameEntry->getLink('self')->rel);
$this->assertEquals('application/atom+xml', $nicknameEntry->getLink('self')->type);
$this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/nickname/2.0/Susy', $nicknameEntry->getLink('self')->href);
Expand Down
2 changes: 1 addition & 1 deletion tests/Zend/GData/GApps/UserEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private function verifyAllSamplePropertiesAreCorrect ($userEntry) {
$this->assertEquals('http://schemas.google.com/g/2005#kind', $userEntry->category[0]->scheme);
$this->assertEquals('http://schemas.google.com/apps/2006#user', $userEntry->category[0]->term);
$this->assertEquals('text', $userEntry->title->type);
$this->assertEquals('SusanJones', $userEntry->title->text);;
$this->assertEquals('SusanJones', $userEntry->title->text);
$this->assertEquals('self', $userEntry->getLink('self')->rel);
$this->assertEquals('application/atom+xml', $userEntry->getLink('self')->type);
$this->assertEquals('https://apps-apis.google.com/a/feeds/example.com/user/2.0/SusanJones', $userEntry->getLink('self')->href);
Expand Down
2 changes: 1 addition & 1 deletion tests/Zend/GData/YouTube/ActivityEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private function verifyAllSamplePropertiesAreCorrect ($activityEntry) {
$this->assertEquals('http://gdata.youtube.com/schemas/2007#userEvent',
$activityEntry->category[1]->term);
$this->assertEquals('tayzonzay has favorited a video',
$activityEntry->title->text);;
$activityEntry->title->text);

$this->assertEquals('self', $activityEntry->getLink('self')->rel);
$this->assertEquals('application/atom+xml',
Expand Down
2 changes: 1 addition & 1 deletion tests/Zend/GData/YouTube/ActivityFeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private function verifyAllSamplePropertiesAreCorrect ($activityFeed) {
$this->assertEquals('http://gdata.youtube.com/schemas/2007#userEvent',
$activityFeed->category[0]->term);
$this->assertEquals('Activity of tayzonzay',
$activityFeed->title->text);;
$activityFeed->title->text);

$this->assertEquals('self', $activityFeed->getLink('self')->rel);
$this->assertEquals('application/atom+xml',
Expand Down
4 changes: 2 additions & 2 deletions tests/Zend/GData/YouTube/CommentEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ private function verifyAllSamplePropertiesAreCorrect ($commentEntry) {
$this->assertEquals('http://schemas.google.com/g/2005#kind', $commentEntry->category[0]->scheme);
$this->assertEquals('http://gdata.youtube.com/schemas/2007#comment', $commentEntry->category[0]->term);
$this->assertEquals('text', $commentEntry->title->type);
$this->assertEquals('how to turn ...', $commentEntry->title->text);;
$this->assertEquals('how to turn ...', $commentEntry->title->text);
$this->assertEquals('text', $commentEntry->content->type);
$this->assertEquals('how to turn rejection and heartbreak into something positive is the big mystery of life but you\'re managed to turn it to your advantage with a beautiful song. Who was she?', $commentEntry->content->text);;
$this->assertEquals('how to turn rejection and heartbreak into something positive is the big mystery of life but you\'re managed to turn it to your advantage with a beautiful song. Who was she?', $commentEntry->content->text);
$this->assertEquals('self', $commentEntry->getLink('self')->rel);
$this->assertEquals('application/atom+xml', $commentEntry->getLink('self')->type);
$this->assertEquals('http://gdata.youtube.com/feeds/videos/Lnio-pqLPgg/comments/CE0314DEBFFC9052', $commentEntry->getLink('self')->href);
Expand Down
Loading

0 comments on commit 4307b16

Please sign in to comment.