Skip to content

Commit

Permalink
Merge pull request #439 from padraic/cs-fixes
Browse files Browse the repository at this point in the history
CS fixes to PSR-2 level
  • Loading branch information
padraic committed Feb 15, 2015
2 parents 4cb1b37 + d8f67de commit f699a69
Show file tree
Hide file tree
Showing 47 changed files with 82 additions and 93 deletions.
10 changes: 6 additions & 4 deletions library/Mockery.php
Expand Up @@ -135,7 +135,9 @@ public static function self()
*/
public static function close()
{
if (is_null(self::$_container)) return;
if (is_null(self::$_container)) {
return;
}

self::$_container->mockery_teardown();
self::$_container->mockery_close();
Expand Down Expand Up @@ -483,7 +485,7 @@ public static function formatObjects(array $objects = null)
$formatting = true;
$parts = array();

foreach($objects as $object) {
foreach ($objects as $object) {
$parts[get_class($object)] = self::objectToArray($object);
}

Expand Down Expand Up @@ -563,7 +565,7 @@ private static function extractGetters($object, $nesting)

try {
$getters[$name] = self::cleanupNesting($object->$name(), $nesting);
} catch(\Exception $e) {
} catch (\Exception $e) {
$getters[$name] = '!! ' . get_class($e) . ': ' . $e->getMessage() . ' !!';
}
}
Expand Down Expand Up @@ -619,7 +621,7 @@ public static function parseShouldReturnArgs(\Mockery\MockInterface $mock, $args

foreach ($args as $arg) {
if (is_array($arg)) {
foreach($arg as $k => $v) {
foreach ($arg as $k => $v) {
$expectation = self::buildDemeterChain($mock, $k, $add)->andReturn($v);
$composite->add($expectation);
}
Expand Down
Expand Up @@ -24,4 +24,3 @@ protected function assertPostConditions()
\Mockery::close();
}
}

2 changes: 1 addition & 1 deletion library/Mockery/Adapter/Phpunit/MockeryTestCase.php
Expand Up @@ -12,7 +12,7 @@ protected function assertPostConditions()
$this->closeMockery();

parent::assertPostConditions();
}
}

protected function addMockeryExpectationsToAssertionCount()
{
Expand Down
28 changes: 21 additions & 7 deletions library/Mockery/Adapter/Phpunit/TestListener.php
Expand Up @@ -63,17 +63,31 @@ public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
/**
* The Listening methods below are not required for Mockery
*/
public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time) {}
public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
}

public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time) {}
public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time)
{
}

public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) {}
public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
}

public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) {}
public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
}

public function addRiskyTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) {}
public function addRiskyTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
}

public function endTestSuite(\PHPUnit_Framework_TestSuite $suite) {}
public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
{
}

public function startTest(\PHPUnit_Framework_Test $test) {}
public function startTest(\PHPUnit_Framework_Test $test)
{
}
}
1 change: 0 additions & 1 deletion library/Mockery/CompositeExpectation.php
Expand Up @@ -124,5 +124,4 @@ public function __toString()
$return .= implode(', ', $parts) . ']';
return $return;
}

}
1 change: 0 additions & 1 deletion library/Mockery/Configuration.php
Expand Up @@ -128,5 +128,4 @@ public function getInternalClassMethodParamMaps()
{
return $this->_internalClassParamMap;
}

}
21 changes: 12 additions & 9 deletions library/Mockery/Container.php
Expand Up @@ -101,7 +101,7 @@ public function mock()
$finalArg = end($args);
reset($args);
if (is_callable($finalArg) && is_object($finalArg)) {
$expectationClosure = array_pop($args);
$expectationClosure = array_pop($args);
}
}

Expand Down Expand Up @@ -156,7 +156,7 @@ public function mock()
. ' an existing class or interface');
}
$class = $parts[0];
$parts[1] = str_replace(' ','', $parts[1]);
$parts[1] = str_replace(' ', '', $parts[1]);
$partialMethods = explode(',', strtolower(rtrim($parts[1], ']')));
$builder->addTarget($class);
$builder->setWhiteListedMethods($partialMethods);
Expand All @@ -176,7 +176,10 @@ public function mock()
continue;
} elseif (is_array($arg) && !empty($arg) && array_keys($arg) !== range(0, count($arg) - 1)) {
// if associative array
if(array_key_exists(self::BLOCKS, $arg)) $blocks = $arg[self::BLOCKS]; unset($arg[self::BLOCKS]);
if (array_key_exists(self::BLOCKS, $arg)) {
$blocks = $arg[self::BLOCKS];
}
unset($arg[self::BLOCKS]);
$quickdefs = array_shift($args);
continue;
} elseif (is_array($arg)) {
Expand Down Expand Up @@ -230,7 +233,6 @@ public function mock()

public function instanceMock()
{

}

public function getLoader()
Expand All @@ -249,7 +251,6 @@ public function getGenerator()
*/
public function getKeyOfDemeterMockFor($method)
{

$keys = array_keys($this->_mocks);
$match = preg_grep("/__demeter_{$method}$/", $keys);
if (count($match) == 1) {
Expand Down Expand Up @@ -292,7 +293,7 @@ public function mockery_teardown()
*/
public function mockery_verify()
{
foreach($this->_mocks as $mock) {
foreach ($this->_mocks as $mock) {
$mock->mockery_verify();
}
}
Expand All @@ -304,7 +305,7 @@ public function mockery_verify()
*/
public function mockery_close()
{
foreach($this->_mocks as $mock) {
foreach ($this->_mocks as $mock) {
$mock->mockery_teardown();
}
$this->_mocks = array();
Expand Down Expand Up @@ -396,7 +397,7 @@ public function mockery_validateOrder($method, $order, \Mockery\MockInterface $m
public function mockery_getExpectationCount()
{
$count = 0;
foreach($this->_mocks as $mock) {
foreach ($this->_mocks as $mock) {
$count += $mock->mockery_getExpectationCount();
}
return $count;
Expand Down Expand Up @@ -445,7 +446,9 @@ public function self()
*/
public function fetchMock($reference)
{
if (isset($this->_mocks[$reference])) return $this->_mocks[$reference];
if (isset($this->_mocks[$reference])) {
return $this->_mocks[$reference];
}
}

protected function _getInstance($mockName, $constructorArgs = null)
Expand Down
2 changes: 1 addition & 1 deletion library/Mockery/CountValidator/AtLeast.php
Expand Up @@ -19,6 +19,7 @@
*/

namespace Mockery\CountValidator;

use Mockery;

class AtLeast extends CountValidatorAbstract
Expand Down Expand Up @@ -59,5 +60,4 @@ public function validate($n)
throw $exception;
}
}

}
2 changes: 1 addition & 1 deletion library/Mockery/CountValidator/AtMost.php
Expand Up @@ -19,6 +19,7 @@
*/

namespace Mockery\CountValidator;

use Mockery;

class AtMost extends CountValidatorAbstract
Expand Down Expand Up @@ -48,5 +49,4 @@ public function validate($n)
throw $exception;
}
}

}
1 change: 0 additions & 1 deletion library/Mockery/CountValidator/CountValidatorAbstract.php
Expand Up @@ -67,5 +67,4 @@ public function isEligible($n)
* @return bool
*/
abstract public function validate($n);

}
3 changes: 1 addition & 2 deletions library/Mockery/CountValidator/Exact.php
Expand Up @@ -19,6 +19,7 @@
*/

namespace Mockery\CountValidator;

use Mockery;

class Exact extends CountValidatorAbstract
Expand Down Expand Up @@ -46,8 +47,6 @@ public function validate($n)
->setExpectedCount($this->_limit)
->setActualCount($n);
throw $exception;

}
}

}
1 change: 0 additions & 1 deletion library/Mockery/CountValidator/Exception.php
Expand Up @@ -22,5 +22,4 @@

class Exception extends \OutOfBoundsException
{

}
1 change: 0 additions & 1 deletion library/Mockery/Exception.php
Expand Up @@ -22,5 +22,4 @@

class Exception extends \UnexpectedValueException
{

}
2 changes: 1 addition & 1 deletion library/Mockery/Exception/InvalidCountException.php
Expand Up @@ -19,6 +19,7 @@
*/

namespace Mockery\Exception;

use Mockery;
use Mockery\Exception\RuntimeException;

Expand Down Expand Up @@ -99,5 +100,4 @@ public function getExpectedCountComparative()
{
return $this->expectedComparative;
}

}
2 changes: 1 addition & 1 deletion library/Mockery/Exception/InvalidOrderException.php
Expand Up @@ -19,6 +19,7 @@
*/

namespace Mockery\Exception;

use Mockery;

class InvalidOrderException extends Mockery\Exception
Expand Down Expand Up @@ -80,5 +81,4 @@ public function getMockName()
{
return $this->getMock()->mockery_getName();
}

}
Expand Up @@ -19,6 +19,7 @@
*/

namespace Mockery\Exception;

use Mockery;

class NoMatchingExpectationException extends Mockery\Exception
Expand Down Expand Up @@ -67,5 +68,4 @@ public function getMockName()
{
return $this->getMock()->mockery_getName();
}

}
1 change: 0 additions & 1 deletion library/Mockery/Exception/RuntimeException.php
Expand Up @@ -22,5 +22,4 @@

class RuntimeException extends \Exception
{

}
15 changes: 8 additions & 7 deletions library/Mockery/Expectation.php
Expand Up @@ -280,10 +280,10 @@ public function verify()
*/
public function matchArgs(array $args)
{
if(empty($this->_expectedArgs) && !$this->_noArgsExpectation) {
if (empty($this->_expectedArgs) && !$this->_noArgsExpectation) {
return true;
}
if(count($args) !== count($this->_expectedArgs)) {
if (count($args) !== count($this->_expectedArgs)) {
return false;
}
$argCount = count($args);
Expand Down Expand Up @@ -317,13 +317,13 @@ protected function _matchArg($expected, &$actual)
$result = preg_match($expected, (string) $actual);
restore_error_handler();

if($result) {
if ($result) {
return true;
}
}
if (is_string($expected) && is_object($actual)) {
$result = $actual instanceof $expected;
if($result) {
if ($result) {
return true;
}
}
Expand Down Expand Up @@ -536,7 +536,9 @@ public function zeroOrMoreTimes()
*/
public function times($limit = null)
{
if (is_null($limit)) return $this;
if (is_null($limit)) {
return $this;
}
$this->_countValidators[] = new $this->_countValidatorClass($this, $limit);
$this->_countValidatorClass = 'Mockery\CountValidator\Exact';
return $this;
Expand Down Expand Up @@ -672,7 +674,7 @@ public function getOrderNumber()
public function byDefault()
{
$director = $this->_mock->mockery_getExpectationsFor($this->_name);
if(!empty($director)) {
if (!empty($director)) {
$director->makeExpectationDefault($this);
}
return $this;
Expand Down Expand Up @@ -724,5 +726,4 @@ public function getName()
{
return $this->_name;
}

}
1 change: 0 additions & 1 deletion library/Mockery/ExpectationDirector.php
Expand Up @@ -200,5 +200,4 @@ public function getExpectationCount()
{
return count($this->getExpectations());
}

}
1 change: 0 additions & 1 deletion library/Mockery/ExpectationInterface.php
Expand Up @@ -20,7 +20,6 @@
*/
namespace Mockery;


interface ExpectationInterface
{
/**
Expand Down

0 comments on commit f699a69

Please sign in to comment.