Skip to content

Commit

Permalink
SCA/CS/PHPDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
SpacePossum authored and sebastianbergmann committed Jul 9, 2017
1 parent fa5711d commit 4bc5697
Show file tree
Hide file tree
Showing 33 changed files with 147 additions and 144 deletions.
34 changes: 17 additions & 17 deletions src/Framework/Assert.php
Expand Up @@ -174,7 +174,7 @@ public static function assertArrayNotHasKey($key, $array, $message = '')
public static function assertContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
{
if (\is_array($haystack) ||
\is_object($haystack) && $haystack instanceof Traversable) {
(\is_object($haystack) && $haystack instanceof Traversable)) {
$constraint = new TraversableContains(
$needle,
$checkForObjectIdentity,
Expand Down Expand Up @@ -239,7 +239,7 @@ public static function assertAttributeContains($needle, $haystackAttributeName,
public static function assertNotContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
{
if (\is_array($haystack) ||
\is_object($haystack) && $haystack instanceof Traversable) {
(\is_object($haystack) && $haystack instanceof Traversable)) {
$constraint = new LogicalNot(
new TraversableContains(
$needle,
Expand Down Expand Up @@ -305,8 +305,8 @@ public static function assertAttributeNotContains($needle, $haystackAttributeNam
*/
public static function assertContainsOnly($type, $haystack, $isNativeType = null, $message = '')
{
if (!(\is_array($haystack) ||
\is_object($haystack) && $haystack instanceof Traversable)) {
if (!\is_array($haystack) &&
!(\is_object($haystack) && $haystack instanceof Traversable)) {
throw InvalidArgumentHelper::factory(
2,
'array or traversable'
Expand All @@ -330,14 +330,14 @@ public static function assertContainsOnly($type, $haystack, $isNativeType = null
/**
* Asserts that a haystack contains only instances of a given classname
*
* @param string $classname
* @param array|Traversable $haystack
* @param string $message
* @param string $classname
* @param array|\Traversable $haystack
* @param string $message
*/
public static function assertContainsOnlyInstancesOf($classname, $haystack, $message = '')
{
if (!(\is_array($haystack) ||
\is_object($haystack) && $haystack instanceof Traversable)) {
if (!\is_array($haystack) &&
!(\is_object($haystack) && $haystack instanceof Traversable)) {
throw InvalidArgumentHelper::factory(
2,
'array or traversable'
Expand Down Expand Up @@ -384,8 +384,8 @@ public static function assertAttributeContainsOnly($type, $haystackAttributeName
*/
public static function assertNotContainsOnly($type, $haystack, $isNativeType = null, $message = '')
{
if (!(\is_array($haystack) ||
\is_object($haystack) && $haystack instanceof Traversable)) {
if (!\is_array($haystack) &&
!(\is_object($haystack) && $haystack instanceof Traversable)) {
throw InvalidArgumentHelper::factory(
2,
'array or traversable'
Expand Down Expand Up @@ -1692,9 +1692,9 @@ public static function assertNotRegExp($pattern, $string, $message = '')
* Assert that the size of two arrays (or `Countable` or `Traversable` objects)
* is the same.
*
* @param array|Countable|Traversable $expected
* @param array|Countable|Traversable $actual
* @param string $message
* @param array|\Countable|\Traversable $expected
* @param array|\Countable|\Traversable $actual
* @param string $message
*/
public static function assertSameSize($expected, $actual, $message = '')
{
Expand All @@ -1721,9 +1721,9 @@ public static function assertSameSize($expected, $actual, $message = '')
* Assert that the size of two arrays (or `Countable` or `Traversable` objects)
* is not the same.
*
* @param array|Countable|Traversable $expected
* @param array|Countable|Traversable $actual
* @param string $message
* @param array|\Countable|\Traversable $expected
* @param array|\Countable|\Traversable $actual
* @param string $message
*/
public static function assertNotSameSize($expected, $actual, $message = '')
{
Expand Down
18 changes: 9 additions & 9 deletions src/Framework/Assert/Functions.php
Expand Up @@ -481,9 +481,9 @@ function assertContainsOnly($type, $haystack, $isNativeType = null, $message = '
/**
* Asserts that a haystack contains only instances of a given classname
*
* @param string $classname
* @param array|Traversable $haystack
* @param string $message
* @param string $classname
* @param array|\Traversable $haystack
* @param string $message
*/
function assertContainsOnlyInstancesOf($classname, $haystack, $message = '')
{
Expand Down Expand Up @@ -957,9 +957,9 @@ function assertNotSame($expected, $actual, $message = '')
* Assert that the size of two arrays (or `Countable` or `Traversable` objects)
* is not the same.
*
* @param array|Countable|Traversable $expected
* @param array|Countable|Traversable $actual
* @param string $message
* @param array|\Countable|\Traversable $expected
* @param array|\Countable|\Traversable $actual
* @param string $message
*/
function assertNotSameSize($expected, $actual, $message = '')
{
Expand Down Expand Up @@ -1031,9 +1031,9 @@ function assertSame($expected, $actual, $message = '')
* Assert that the size of two arrays (or `Countable` or `Traversable` objects)
* is the same.
*
* @param array|Countable|Traversable $expected
* @param array|Countable|Traversable $actual
* @param string $message
* @param array|\Countable|\Traversable $expected
* @param array|\Countable|\Traversable $actual
* @param string $message
*/
function assertSameSize($expected, $actual, $message = '')
{
Expand Down
6 changes: 3 additions & 3 deletions src/Framework/Constraint/Count.php
Expand Up @@ -45,9 +45,9 @@ protected function matches($other)
}

/**
* @param \Countable|\Traversable\|array $other
* @param \Countable|\Traversable|array $other
*
* @return int
* @return int|null
*/
protected function getCountOf($other)
{
Expand Down Expand Up @@ -97,7 +97,7 @@ protected function getCountOf($other)
protected function getCountOfGenerator(Generator $generator)
{
for ($count = 0; $generator->valid(); $generator->next()) {
$count += 1;
++$count;
}

return $count;
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/Constraint/IsType.php
Expand Up @@ -108,7 +108,7 @@ protected function matches($other)
return \is_bool($other);

case 'null':
return \is_null($other);
return null === $other;

case 'array':
return \is_array($other);
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/Constraint/SameSize.php
Expand Up @@ -17,7 +17,7 @@ class SameSize extends Count
protected $expectedCount;

/**
* @param \Countable|\Traversable\|array $expected
* @param \Countable|\Traversable|array $expected
*/
public function __construct($expected)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/DataProviderTestSuite.php
Expand Up @@ -14,7 +14,7 @@ class DataProviderTestSuite extends TestSuite
/**
* Sets the dependencies of a TestCase.
*
* @param array $dependencies
* @param string[] $dependencies
*/
public function setDependencies(array $dependencies)
{
Expand Down
23 changes: 11 additions & 12 deletions src/Framework/TestCase.php
Expand Up @@ -206,7 +206,7 @@ abstract class TestCase extends Assert implements Test, SelfDescribing
private $name;

/**
* @var array
* @var string[]
*/
private $dependencies = [];

Expand Down Expand Up @@ -504,7 +504,7 @@ public function expectOutputRegex($expectedRegex)
throw new Exception;
}

if (\is_string($expectedRegex) || \is_null($expectedRegex)) {
if (\is_string($expectedRegex) || null === $expectedRegex) {
$this->outputExpectedRegex = $expectedRegex;
}
}
Expand All @@ -518,7 +518,7 @@ public function expectOutputString($expectedString)
throw new Exception;
}

if (\is_string($expectedString) || \is_null($expectedString)) {
if (\is_string($expectedString) || null === $expectedString) {
$this->outputExpectedString = $expectedString;
}
}
Expand Down Expand Up @@ -745,7 +745,7 @@ public function hasFailed()
*
* @param TestResult $result
*
* @return TestResult
* @return TestResult|null
*
* @throws Exception
*/
Expand Down Expand Up @@ -1192,7 +1192,7 @@ public function setName($name)
/**
* Sets the dependencies of a TestCase.
*
* @param array $dependencies
* @param string[] $dependencies
*/
public function setDependencies(array $dependencies)
{
Expand Down Expand Up @@ -1234,7 +1234,7 @@ public function setBeStrictAboutChangesToGlobalState($beStrictAboutChangesToGlob
*/
public function setBackupGlobals($backupGlobals)
{
if (\is_null($this->backupGlobals) && \is_bool($backupGlobals)) {
if (null === $this->backupGlobals && \is_bool($backupGlobals)) {
$this->backupGlobals = $backupGlobals;
}
}
Expand All @@ -1246,7 +1246,7 @@ public function setBackupGlobals($backupGlobals)
*/
public function setBackupStaticAttributes($backupStaticAttributes)
{
if (\is_null($this->backupStaticAttributes) &&
if (null === $this->backupStaticAttributes &&
\is_bool($backupStaticAttributes)) {
$this->backupStaticAttributes = $backupStaticAttributes;
}
Expand Down Expand Up @@ -1422,8 +1422,7 @@ protected function setLocale()
throw new Exception;
}

$category = $args[0];
$locale = $args[1];
list($category, $locale) = $args;

$categories = [
LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME
Expand Down Expand Up @@ -1509,8 +1508,8 @@ protected function createConfiguredMock($originalClassName, array $configuration
/**
* Returns a partial test double for the specified class.
*
* @param string $originalClassName
* @param array $methods
* @param string $originalClassName
* @param string[] $methods
*
* @return PHPUnit_Framework_MockObject_MockObject
*
Expand Down Expand Up @@ -2382,7 +2381,7 @@ private function shouldInvocationMockerBeReset(PHPUnit_Framework_MockObject_Mock

/**
* @param array $testArguments
* @param array $originalTestArguments
* @param array $visited
*/
private function registerMockObjectsFromTestArguments(array $testArguments, array &$visited = [])
{
Expand Down
32 changes: 15 additions & 17 deletions src/Framework/TestSuite.php
Expand Up @@ -74,7 +74,7 @@ class TestSuite implements Test, SelfDescribing, IteratorAggregate
/**
* The tests in the test suite.
*
* @var array
* @var TestCase[]
*/
protected $tests = [];

Expand Down Expand Up @@ -266,19 +266,17 @@ public function addTestSuite($testClass)
} elseif ($testClass instanceof ReflectionClass) {
$suiteMethod = false;

if (!$testClass->isAbstract()) {
if ($testClass->hasMethod(BaseTestRunner::SUITE_METHODNAME)) {
$method = $testClass->getMethod(
BaseTestRunner::SUITE_METHODNAME
);
if (!$testClass->isAbstract() && $testClass->hasMethod(BaseTestRunner::SUITE_METHODNAME)) {
$method = $testClass->getMethod(
BaseTestRunner::SUITE_METHODNAME
);

if ($method->isStatic()) {
$this->addTest(
$method->invoke(null, $testClass->getName())
);
if ($method->isStatic()) {
$this->addTest(
$method->invoke(null, $testClass->getName())
);

$suiteMethod = true;
}
$suiteMethod = true;
}
}

Expand Down Expand Up @@ -324,7 +322,7 @@ public function addTestFile($filename)

// The diff is empty in case a parent class (with test methods) is added
// AFTER a child class that inherited from it. To account for that case,
// cumulate all discovered classes, so the parent class may be found in
// accumulate all discovered classes, so the parent class may be found in
// a later invocation.
if (!empty($newClasses)) {
// On the assumption that test classes are defined first in files,
Expand Down Expand Up @@ -801,7 +799,7 @@ public function setName($name)
*
* @param int|false
*
* @return Test
* @return Test|false
*/
public function testAt($index)
{
Expand Down Expand Up @@ -942,7 +940,7 @@ protected static function incompleteTest($class, $methodName, $message)
*/
public function setbeStrictAboutChangesToGlobalState($beStrictAboutChangesToGlobalState)
{
if (\is_null($this->beStrictAboutChangesToGlobalState) && \is_bool($beStrictAboutChangesToGlobalState)) {
if (null === $this->beStrictAboutChangesToGlobalState && \is_bool($beStrictAboutChangesToGlobalState)) {
$this->beStrictAboutChangesToGlobalState = $beStrictAboutChangesToGlobalState;
}
}
Expand All @@ -952,7 +950,7 @@ public function setbeStrictAboutChangesToGlobalState($beStrictAboutChangesToGlob
*/
public function setBackupGlobals($backupGlobals)
{
if (\is_null($this->backupGlobals) && \is_bool($backupGlobals)) {
if (null === $this->backupGlobals && \is_bool($backupGlobals)) {
$this->backupGlobals = $backupGlobals;
}
}
Expand All @@ -962,7 +960,7 @@ public function setBackupGlobals($backupGlobals)
*/
public function setBackupStaticAttributes($backupStaticAttributes)
{
if (\is_null($this->backupStaticAttributes) && \is_bool($backupStaticAttributes)) {
if (null === $this->backupStaticAttributes && \is_bool($backupStaticAttributes)) {
$this->backupStaticAttributes = $backupStaticAttributes;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Runner/BaseTestRunner.php
Expand Up @@ -49,7 +49,7 @@ public function getLoader()
* @param string $suiteClassFile
* @param mixed $suffixes
*
* @return Test
* @return Test|null
*/
public function getTest($suiteClassName, $suiteClassFile = '', $suffixes = '')
{
Expand Down
5 changes: 5 additions & 0 deletions src/Runner/PhptTestCase.php
Expand Up @@ -433,6 +433,11 @@ protected function parseIniSection($content)
return \preg_split('/\n|\r/', $content, -1, PREG_SPLIT_NO_EMPTY);
}

/**
* @param string $content
*
* @return array<string, string>
*/
protected function parseEnvSection($content)
{
$env = [];
Expand Down

0 comments on commit 4bc5697

Please sign in to comment.