Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for php 5 #292

Merged
merged 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions .github/workflows/runTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@ jobs:
fail-fast: false
matrix:
php-versions:
- '5.3'
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
- '8.4'
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
Expand Down Expand Up @@ -61,15 +58,14 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies for PHP < 8.0
if: matrix.php-versions != '8.0' && matrix.php-versions != '8.1' && matrix.php-versions != '8.2'
run: composer install --prefer-dist --no-progress

- name: Install PHPUnit 8 for PHP 8
if: matrix.php-versions == '8.0' || matrix.php-versions == '8.1' || matrix.php-versions == '8.2'
- name: Install dependencies
run: |
composer require --dev phpunit/phpunit:8.5.17 --ignore-platform-reqs
git apply --reject --whitespace=fix src/test/patches/php8-return-types.diff
composer install --prefer-dist --no-progress

- name: Run test suite
if: matrix.php-versions == '7.1'
run: composer run-script test -- --no-coverage

- name: Run test suite
if: matrix.php-versions > '7.1'
run: composer run-script test -- --coverage-text
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
1.6.?? (2022-??-??)
1.6.12 (2024-??-??)
-------------------

* Drop php 5 and 7.0 support as new versions enforced a syntax change that is not compatible with the old versions.

1.6.11 (2022-07-26)
-------------------

* Add support for PHP 8.2's `$content` property in `vfsStreamWrapper`
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
"wiki": "https://github.com/bovigo/vfsStream/wiki"
},
"require": {
"php": ">=5.3.0"
"php": ">=7.1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.5|^5.0"
"phpunit/phpunit": "^7.5||^8.5||^9.6",
"yoast/phpunit-polyfills": "^2.0"
},
"autoload": {
"psr-0": { "org\\bovigo\\vfs\\": "src/main/php" }
Expand Down
3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
printerClass="PHPUnit_TextUI_ResultPrinter"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
Expand Down Expand Up @@ -41,4 +40,4 @@
<ini name="memory_limit" value="-1"/>
<ini name="error_reporting" value="30719"/> <!-- E_ALL | E_STRICT -->
</php>
</phpunit>
</phpunit>
46 changes: 4 additions & 42 deletions src/test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,15 @@ class_alias('\PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase');
class_alias('PHPUnit\Framework\Error\Warning', 'PHPUnit_Framework_Error');
}

if (!class_exists("PHPUnit_Util_ErrorHandler"))
{
class PHPUnit_Util_ErrorHandler {
public static function handleError($errno, $errstr, $errfile, $errline)
{
$errorHandler = new \PHPUnit\Util\ErrorHandler(
true,
true,
true,
true
);

return $errorHandler($errno, $errstr, $errfile, $errline);
}
}
}

if (!class_exists("PHPUnit_TextUI_ResultPrinter"))
{
class PHPUnit_TextUI_ResultPrinter extends \PHPUnit\TextUI\ResultPrinter {}
}

/**
* A modified version of PHPUnit's TestCase to rid ourselves of deprecation
* warnings since we're using two different versions of PHPUnit in this branch
* (PHPUnit 4 and 5).
*/
class BC_PHPUnit_Framework_TestCase extends \PHPUnit_Framework_TestCase {
class BC_PHPUnit_Framework_TestCase extends \PHPUnit\Framework\TestCase {

use \Yoast\PHPUnitPolyfills\Polyfills\AssertionRenames;

public function bc_expectException($exception)
{
if (method_exists($this, 'expectException')) {
Expand All @@ -63,22 +44,3 @@ public function bc_getMock($originalClassName, $methods = array(), array $argume
return parent::getMock($originalClassName, $methods, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $cloneArguments, $callOriginalMethods, $proxyTarget);
}
}

// The only deprecation warnings we need to ignore/handle are in PHP 7.4 so far
if (PHP_VERSION_ID >= 70400) {
function customErrorHandler($errno, $errstr, $errfile, $errline) {
// We know about this deprecation warning exists and it's already been
// fixed in the 2.x branch. For BC reasons in the 1.x branch, we'll
// ignore this warning to let tests pass.
if ($errno === E_DEPRECATED) {
if ($errstr === "Function ReflectionType::__toString() is deprecated") {
return true;
}
}

// Any other error should be left up to PHPUnit to handle
return \PHPUnit_Util_ErrorHandler::handleError($errno, $errstr, $errfile, $errline);
}

set_error_handler("customErrorHandler");
}
21 changes: 0 additions & 21 deletions src/test/patches/php8-return-types.diff

This file was deleted.

4 changes: 2 additions & 2 deletions src/test/php/org/bovigo/vfs/DirectoryIterationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DirectoryIterationTestCase extends vfsStreamWrapperBaseTestCase
/**
* clean up test environment
*/
public function tearDown()
public function tearDown(): void
{
vfsStream::enableDotfiles();
}
Expand Down Expand Up @@ -315,4 +315,4 @@ public function recursiveDirectoryIterationWithDotsDisabled()
$pathes
);
}
}
}
6 changes: 3 additions & 3 deletions src/test/php/org/bovigo/vfs/FilenameTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FilenameTestCase extends \BC_PHPUnit_Framework_TestCase
/**
* set up test environment
*/
public function setUp()
public function setUp(): void
{
vfsStream::setup('root');
$this->rootDir = vfsStream::url('root');
Expand Down Expand Up @@ -53,11 +53,11 @@ public function worksWithCorrectName()

/**
* @test
* @expectedException UnexpectedValueException
* @expectedExceptionMessage ailed to open dir
*/
public function doesNotWorkWithInvalidName()
{
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionMessage('ailed to open dir');
$results = array();
$it = new \RecursiveDirectoryIterator($this->rootDir . '/lost found/');
foreach ($it as $f) {
Expand Down
9 changes: 6 additions & 3 deletions src/test/php/org/bovigo/vfs/PermissionsTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs;
use PHPUnit\Framework\Error;

/**
* Test for permissions related functionality.
*
Expand All @@ -23,7 +25,7 @@ class PermissionsTestCase extends \BC_PHPUnit_Framework_TestCase
/**
* set up test environment
*/
public function setup()
public function setUp(): void
{
$structure = array('test_directory' => array('test.file' => ''));
$this->root = vfsStream::setup('root', null, $structure);
Expand Down Expand Up @@ -92,13 +94,14 @@ public function canNotChangeGroupWhenFileNotOwned()
/**
* @test
* @group issue_107
* @expectedException PHPUnit_Framework_Error
* @expectedExceptionMessage Can not create new file in non-writable path root
* @requires PHP 5.4
* @since 1.5.0
*/
public function touchOnNonWriteableDirectoryTriggersError()
{
$this->expectException(Error\Warning::class);
$this->expectExceptionMessage('Can not create new file in non-writable path root');

$this->root->chmod(0555);
touch($this->root->url() . '/touch.txt');
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/php/org/bovigo/vfs/QuotaTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class QuotaTestCase extends \BC_PHPUnit_Framework_TestCase
/**
* set up test environment
*/
public function setUp()
public function setUp(): void
{
$this->quota = new Quota(10);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LargeFileContentTestCase extends \BC_PHPUnit_Framework_TestCase
/**
* set up test environment
*/
public function setUp()
public function setUp(): void
{
$this->largeFileContent = new LargeFileContent(100);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class StringBasedFileContentTestCase extends \BC_PHPUnit_Framework_TestCase
/**
* set up test environment
*/
public function setUp()
public function setUp(): void
{
$this->stringBasedFileContent = new StringBasedFileContent('foobarbaz');
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/php/org/bovigo/vfs/vfsStreamBlockTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class vfsStreamBlockTestCase extends \BC_PHPUnit_Framework_TestCase
*/
protected $block;

public function setUp()
public function setUp(): void
{
$this->block = new vfsStreamBlock('foo');
}
Expand Down Expand Up @@ -73,10 +73,10 @@ public function addStructure()
/**
* tests that a blank name for a block device throws an exception
* @test
* @expectedException org\bovigo\vfs\vfsStreamException
*/
public function createWithEmptyName()
{
$this->expectException(vfsStreamException::class);
$structure = array(
'topLevel' => array(
'thisIsAFile' => 'file contents',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class vfsStreamContainerIteratorTestCase extends \BC_PHPUnit_Framework_TestCase
/**
* set up test environment
*/
public function setUp()
public function setUp(): void
{
$this->dir = new vfsStreamDirectory('foo');
$this->mockChild1 = $this->bc_getMock('org\\bovigo\\vfs\\vfsStreamContent');
Expand All @@ -53,7 +53,7 @@ public function setUp()
/**
* clean up test environment
*/
public function tearDown()
public function tearDown(): void
{
vfsStream::enableDotfiles();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class vfsStreamDirectoryIssue134TestCase extends \BC_PHPUnit_Framework_TestCase
/**
* set up test environment
*/
public function setUp()
public function setUp(): void
{
$this->rootDirectory = vfsStream::newDirectory('/');
$this->rootDirectory->addChild(vfsStream::newDirectory('var/log/app'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class vfsStreamDirectoryIssue18TestCase extends \BC_PHPUnit_Framework_TestCase
/**
* set up test environment
*/
public function setUp()
public function setUp(): void
{
$this->rootDirectory = vfsStream::newDirectory('/');
$this->rootDirectory->addChild(vfsStream::newDirectory('var/log/app'));
Expand Down
6 changes: 3 additions & 3 deletions src/test/php/org/bovigo/vfs/vfsStreamDirectoryTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class vfsStreamDirectoryTestCase extends \BC_PHPUnit_Framework_TestCase
/**
* set up test environment
*/
public function setUp()
public function setUp(): void
{
$this->dir = new vfsStreamDirectory('foo');
}
Expand All @@ -32,10 +32,10 @@ public function setUp()
* assure that a directory seperator inside the name throws an exception
*
* @test
* @expectedException org\bovigo\vfs\vfsStreamException
*/
public function invalidCharacterInName()
{
$this->expectException(vfsStreamException::class);
$dir = new vfsStreamDirectory('foo/bar');
}

Expand Down Expand Up @@ -72,10 +72,10 @@ public function rename()
* renaming the directory to an invalid name throws a vfsStreamException
*
* @test
* @expectedException org\bovigo\vfs\vfsStreamException
*/
public function renameToInvalidNameThrowsvfsStreamException()
{
$this->expectException(vfsStreamException::class);
$this->dir->rename('foo/baz');
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/php/org/bovigo/vfs/vfsStreamExLockTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class vfsStreamExLockTestCase extends \BC_PHPUnit_Framework_TestCase
/**
* set up test environment
*/
protected function setUp()
public function setUp(): void
{
$root = vfsStream::setup();
vfsStream::newFile('testfile')->at($root);
Expand Down
4 changes: 2 additions & 2 deletions src/test/php/org/bovigo/vfs/vfsStreamFileTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class vfsStreamFileTestCase extends \BC_PHPUnit_Framework_TestCase
/**
* set up test environment
*/
public function setUp()
public function setUp(): void
{
$this->file = new vfsStreamFile('foo');
}
Expand Down Expand Up @@ -327,11 +327,11 @@ public function withContentAcceptsAnyFileContentInstance()
/**
* @test
* @group issue_79
* @expectedException \InvalidArgumentException
* @since 1.3.0
*/
public function withContentThrowsInvalidArgumentExceptionWhenContentIsNoStringAndNoFileContent()
{
$this->expectException(\InvalidArgumentException::class);
$this->file->withContent(313);
}
}
Loading
Loading