Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
padraic authored and StyleCIBot committed Apr 14, 2017
1 parent 12e3ebf commit 8c66b8c
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 35 deletions.
4 changes: 2 additions & 2 deletions library/Mockery.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Mockery

/**
* Defines the global helper functions
*
*
* @return void
*/
public static function globalHelpers()
Expand Down Expand Up @@ -475,7 +475,7 @@ public static function formatArgs($method, array $arguments = null)
*/
private static function formatArgument($argument, $depth = 0)
{
if ($argument instanceOf MatcherAbstract) {
if ($argument instanceof MatcherAbstract) {
return (string) $argument;
}

Expand Down
2 changes: 1 addition & 1 deletion library/Mockery/Generator/MockConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ protected function getAllMethods()
$methods = array_merge($methods, $class->getMethods());
}

foreach ($this->getTargetTraits() AS $trait) {
foreach ($this->getTargetTraits() as $trait) {
foreach ($trait->getMethods() as $method) {
if ($method->isAbstract()) {
$methods[] = $method;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ protected function renderTypeHint(Parameter $param)
$typeHint = trim($param->getTypeHintAsString());

if (!empty($typeHint)) {

if (!in_array($typeHint, $languageTypeHints)) {
$typeHint = '\\'.$typeHint;
}
Expand Down
2 changes: 1 addition & 1 deletion library/Mockery/Matcher/AnyArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @category Mockery
* @package Mockery
* @copyright Copyright (c) 2017 Dave Marshall
* @copyright Copyright (c) 2017 Dave Marshall
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
*/

Expand Down
1 change: 0 additions & 1 deletion library/Mockery/Matcher/ArgumentListMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@

interface ArgumentListMatcher
{

}
2 changes: 1 addition & 1 deletion library/Mockery/Matcher/NoArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @category Mockery
* @package Mockery
* @copyright Copyright (c) 2017 Dave Marshall
* @copyright Copyright (c) 2017 Dave Marshall
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
*/

Expand Down
4 changes: 2 additions & 2 deletions library/Mockery/Matcher/Subset.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(array $expected, $strict = true)

/**
* @param array $expected Expected subset of data
*
*
* @return Subset
*/
public static function strict(array $expected)
Expand All @@ -47,7 +47,7 @@ public static function strict(array $expected)

/**
* @param array $expected Expected subset of data
*
*
* @return Subset
*/
public static function loose(array $expected)
Expand Down
13 changes: 9 additions & 4 deletions library/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Mockery\Matcher\AnyArgs;
use Mockery\Matcher\NoArgs;

/**
* Mockery
*
Expand All @@ -22,25 +23,29 @@
*/

if (!function_exists("mock")) {
function mock(...$args) {
function mock(...$args)
{
return call_user_func_array([Mockery::class, "mock"], $args);
}
}

if (!function_exists("spy")) {
function spy(...$args) {
function spy(...$args)
{
return call_user_func_array([Mockery::class, "spy"], $args);
}
}

if (!function_exists("namedMock")) {
function namedMock(...$args) {
function namedMock(...$args)
{
return call_user_func_array([Mockery::class, "namedMock"], $args);
}
}

if (!function_exists("anyArgs")) {
function anyArgs() {
function anyArgs()
{
return new AnyArgs();
}
}
21 changes: 17 additions & 4 deletions tests/Mockery/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,10 @@ public function testMethodParamsPassedByReferenceHaveReferencePreserved()
{
$m = $this->container->mock('MockeryTestRef1');
$m->shouldReceive('foo')->with(
Mockery::on(function (&$a) {$a += 1;return true;}),
Mockery::on(function (&$a) {
$a += 1;
return true;
}),
Mockery::any()
);
$a = 1;
Expand All @@ -770,7 +773,11 @@ public function testMethodParamsPassedByReferenceHaveReferencePreserved()
public function testMethodParamsPassedByReferenceThroughWithArgsHaveReferencePreserved()
{
$m = $this->container->mock('MockeryTestRef1');
$m->shouldReceive('foo')->withArgs(function (&$a, $b) {$a += 1; $b += 1; return true;});
$m->shouldReceive('foo')->withArgs(function (&$a, $b) {
$a += 1;
$b += 1;
return true;
});
$a = 1;
$b = 1;
$m->foo($a, $b);
Expand All @@ -794,7 +801,10 @@ public function testCanOverrideExpectedParametersOfInternalPHPClassesToPreserveR
@$m = $this->container->mock('DateTime');
$this->assertInstanceOf("Mockery\MockInterface", $m, "Mocking failed, remove @ error suppresion to debug");
$m->shouldReceive('modify')->with(
Mockery::on(function (&$string) {$string = 'foo'; return true;})
Mockery::on(function (&$string) {
$string = 'foo';
return true;
})
);
$data ='bar';
$m->modify($data);
Expand All @@ -820,7 +830,10 @@ public function testCanOverrideExpectedParametersOfExtensionPHPClassesToPreserve
@$m = $this->container->mock('MongoCollection');
$this->assertInstanceOf("Mockery\MockInterface", $m, "Mocking failed, remove @ error suppresion to debug");
$m->shouldReceive('insert')->with(
Mockery::on(function (&$data) {$data['_id'] = 123; return true;}),
Mockery::on(function (&$data) {
$data['_id'] = 123;
return true;
}),
Mockery::type('array')
);
$data = array('a'=>1,'b'=>2);
Expand Down
1 change: 0 additions & 1 deletion tests/Mockery/ExpectationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2148,7 +2148,6 @@ public function it_uses_a_matchers_to_string_method_in_the_exception_output()

Mockery::close();
}

}

interface IWater
Expand Down
4 changes: 3 additions & 1 deletion tests/Mockery/Fixtures/MethodWithIterableTypeHints.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@

class MethodWithIterableTypeHints
{
public function foo(iterable $bar): iterable {}
public function foo(iterable $bar): iterable
{
}
}
12 changes: 9 additions & 3 deletions tests/Mockery/Fixtures/MethodWithNullableTypedParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@

class MethodWithNullableTypedParameter
{
public function foo(?string $bar) {}
public function foo(?string $bar)
{
}

public function bar(string $bar = null) {}
public function bar(string $bar = null)
{
}

public function baz(?string $bar = null) {}
public function baz(?string $bar = null)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@

class MethodWithParametersWithDefaultValues
{
public function foo($bar = null) {}
public function foo($bar = null)
{
}

public function bar(string $bar = null) {}
public function bar(string $bar = null)
{
}
}
4 changes: 3 additions & 1 deletion tests/Mockery/Fixtures/MethodWithVoidReturnType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@

class MethodWithVoidReturnType
{
public function foo(): void {}
public function foo(): void
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*/
class MockeryCanMockClassesWithSemiReservedWordsTest extends \PHPUnit_Framework_TestCase
{
/**
* @test
/**
* @test
*/
public function smoke_test()
{
Expand Down
10 changes: 5 additions & 5 deletions tests/Mockery/MockingMethodsWithNullableParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

/**
*/
class MockingVoidMethodsWithNullableParametersTest extends MockeryTestCase
class MockingMethodsWithNullableParametersTest extends MockeryTestCase
{
protected function setUp()
{
Expand All @@ -37,8 +37,8 @@ protected function tearDown()
$this->container->mockery_close();
}

/**
* @test
/**
* @test
* @requires PHP 7.1.0RC3
*/
public function it_can_handle_nullable_typed_parameters()
Expand All @@ -49,8 +49,8 @@ public function it_can_handle_nullable_typed_parameters()
$this->assertTrue($mock instanceof \test\Mockery\Fixtures\MethodWithNullableTypedParameter);
}

/**
* @test
/**
* @test
*/
public function it_can_handle_default_parameters()
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Mockery/TraitsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ public function it_can_create_an_object_using_multiple_traits()

trait SimpleTrait
{
function foo()
public function foo()
{
return 'bar';
}
}

trait TraitWithAbstractMethod
{
function baz()
public function baz()
{
return $this->doBaz();
}

abstract function doBaz();
abstract public function doBaz();
}

0 comments on commit 8c66b8c

Please sign in to comment.