Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions PHPCSUtils/TestUtils/ConfigDouble.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private function preventAutoDiscoveryScreenWidth()
public function getStaticConfigProperty($name)
{
$property = new ReflectionProperty('PHP_CodeSniffer\Config', $name);
$property->setAccessible(true);
(\PHP_VERSION_ID < 80100) && $property->setAccessible(true);

if ($name === 'overriddenDefaults' && \version_compare($this->phpcsVersion, '3.99.99', '>')) {
return $property->getValue($this);
Expand All @@ -236,14 +236,14 @@ public function getStaticConfigProperty($name)
public function setStaticConfigProperty($name, $value)
{
$property = new ReflectionProperty('PHP_CodeSniffer\Config', $name);
$property->setAccessible(true);
(\PHP_VERSION_ID < 80100) && $property->setAccessible(true);

if ($name === 'overriddenDefaults' && \version_compare($this->phpcsVersion, '3.99.99', '>')) {
$property->setValue($this, $value);
} else {
$property->setValue(null, $value);
}

$property->setAccessible(false);
(\PHP_VERSION_ID < 80100) && $property->setAccessible(false);
}
}
4 changes: 2 additions & 2 deletions PHPCSUtils/TestUtils/UtilityMethodTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ public static function resetTestFile()
public static function setStaticConfigProperty($name, $value)
{
$property = new ReflectionProperty('PHP_CodeSniffer\Config', $name);
$property->setAccessible(true);
(\PHP_VERSION_ID < 80100) && $property->setAccessible(true);
$property->setValue(null, $value);
$property->setAccessible(false);
(\PHP_VERSION_ID < 80100) && $property->setAccessible(false);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Tests/AssertPropertySame.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public static function getObjectPropertyValue($objectUnderTest, $propertyName)
return $objectUnderTest->$propertyName;
}

$property->setAccessible(true);
(\PHP_VERSION_ID < 80100) && $property->setAccessible(true);
$value = $property->getValue($objectUnderTest);
$property->setAccessible(false);
(\PHP_VERSION_ID < 80100) && $property->setAccessible(false);

return $value;
} catch (ReflectionException $e) {
Expand Down
6 changes: 3 additions & 3 deletions Tests/TestUtils/ConfigDouble/ConfigDoubleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function testDestruct()
private function getStaticConfigProperty($name, $config = null)
{
$property = new ReflectionProperty('PHP_CodeSniffer\Config', $name);
$property->setAccessible(true);
(\PHP_VERSION_ID < 80100) && $property->setAccessible(true);

if ($name === 'overriddenDefaults' && \version_compare(Helper::getVersion(), '3.99.99', '>')) {
// The `overriddenDefaults` property is no longer static on PHPCS 4.0+.
Expand Down Expand Up @@ -330,8 +330,8 @@ public static function setStaticConfigProperty($name, $value)
}

$property = new ReflectionProperty('PHP_CodeSniffer\Config', $name);
$property->setAccessible(true);
(\PHP_VERSION_ID < 80100) && $property->setAccessible(true);
$property->setValue(null, $value);
$property->setAccessible(false);
(\PHP_VERSION_ID < 80100) && $property->setAccessible(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function testTearDownCleansUpStaticConfigProperties()
private function getStaticConfigProperty($name, $config = null)
{
$property = new ReflectionProperty('PHP_CodeSniffer\Config', $name);
$property->setAccessible(true);
(\PHP_VERSION_ID < 80100) && $property->setAccessible(true);

if ($name === 'overriddenDefaults'
&& (self::$phpcsVersion === '0' || \version_compare(self::$phpcsVersion, '3.99.99', '>'))
Expand Down
4 changes: 2 additions & 2 deletions Tests/Tokens/Collections/PropertyBasedTokenArraysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ final class PropertyBasedTokenArraysTest extends TestCase
public function testPropertyBasedTokenArrays($name)
{
$reflProp = new ReflectionProperty('PHPCSUtils\Tokens\Collections', $name);
$reflProp->setAccessible(true);
(\PHP_VERSION_ID < 80100) && $reflProp->setAccessible(true);
$expected = $reflProp->getValue();
$reflProp->setAccessible(false);
(\PHP_VERSION_ID < 80100) && $reflProp->setAccessible(false);

$this->assertSame($expected, Collections::$name());
}
Expand Down