1

recently I've recognized that the project opis/closure is facing issues with deprecated serialization solution for php 8.1.1. So I created a fork of that and tried to fix the issue, while I was fixing the issue, I tried to test the output with the phpunit. but I've got some errors shown bellow. can you please check and feed me back about how to solve these issues:

Title Description
Operating system macintosh
PHP version: PHP 8.1.1 (cli) (built: Dec 17 2021 23:49:52) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.1, Copyright (c) Zend Technologies
PHP Unit version: PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
Project Git repo: https://github.com/rhashnull/closure (my fork)

The error message:

PHP Fatal error:  Uncaught Error: Class "Opis\Closure\SerializableClosure" not found in /<private_path>/Projects/closure/tests/ClosureTest.php:447
Stack trace:
#0 phar:///usr/local/Cellar/phpunit/9.5.10/bin/phpunit/phpunit/Util/FileLoader.php(56): include_once()
#1 phar:///usr/local/Cellar/phpunit/9.5.10/bin/phpunit/phpunit/Util/FileLoader.php(43): PHPUnit\Util\FileLoader::load('/Users/arash/Pr...')
#2 phar:///usr/local/Cellar/phpunit/9.5.10/bin/phpunit/phpunit/Framework/TestSuite.php(311): PHPUnit\Util\FileLoader::checkAndLoad('/Users/arash/Pr...')
#3 phar:///usr/local/Cellar/phpunit/9.5.10/bin/phpunit/phpunit/Framework/TestSuite.php(394): PHPUnit\Framework\TestSuite->addTestFile('/Users/arash/Pr...')
#4 phar:///usr/local/Cellar/phpunit/9.5.10/bin/phpunit/phpunit/Runner/BaseTestRunner.php(85): PHPUnit\Framework\TestSuite->addTestFiles(Array)
#5 phar:///usr/local/Cellar/phpunit/9.5.10/bin/phpunit/phpunit/TextUI/Command.php(108): PHPUnit\Runner\BaseTestRunner->getTest('/Users/arash/Pr...', Array)

phpunit.xml

<phpunit bootstrap="./vendor/autoload.php" verbose="true">
    <testsuites>
        <testsuite name="Main">
            <file phpVersion="5.4.0" phpVersionOperator=">=">./tests/ClosureTest.php</file>
        </testsuite>
        <testsuite name="Serialize">
            <file phpVersion="5.4.0" phpVersionOperator=">=">./tests/SerializeTest.php</file>
        </testsuite>
        <testsuite name="Recursive">
            <file phpVersion="7.1.0" phpVersionOperator="&lt;">./tests/RecursiveArrayTest.php</file>
        </testsuite>
        <testsuite name="Signed">
            <file phpVersion="5.4.0" phpVersionOperator=">=">./tests/SignedClosureTest.php</file>
        </testsuite>
        <testsuite name="Namespace">
            <file phpVersion="5.5.0" phpVersionOperator=">=">./tests/NamespaceTest.php</file>
            <file phpVersion="5.5.0" phpVersionOperator=">=">./tests/NamespaceUnqualifiedTest.php</file>
            <file phpVersion="5.5.0" phpVersionOperator=">=">./tests/NamespaceFullyQualifiedTest.php</file>
            <file phpVersion="5.5.0" phpVersionOperator=">=">./tests/NamespacePartiallyQualifiedTest.php</file>
        </testsuite>
        <testsuite name="ReflectionClosure">
            <file phpVersion="5.4.0" phpVersionOperator=">=">./tests/ReflectionClosureTest.php</file>
        </testsuite>
        <testsuite name="ReflectionClosure2">
            <file phpVersion="7.0.0" phpVersionOperator=">=">./tests/ReflectionClosure2Test.php</file>
        </testsuite>
        <testsuite name="ReflectionClosure3">
            <file phpVersion="7.1.0" phpVersionOperator=">=">./tests/ReflectionClosure3Test.php</file>
        </testsuite>
        <testsuite name="ReflectionClosure4">
            <file phpVersion="7.2.0" phpVersionOperator=">=">./tests/ReflectionClosure4Test.php</file>
        </testsuite>
        <testsuite name="ReflectionClosure5">
            <file phpVersion="7.4.0" phpVersionOperator=">=">./tests/ReflectionClosure5Test.php</file>
            <file phpVersion="7.4.0" phpVersionOperator=">=">./tests/NamespaceGroupTest.php</file>
        </testsuite>
        <testsuite name="ReflectionClosure6">
            <file phpVersion="8.0.0-dev" phpVersionOperator=">=">./tests/ReflectionClosure6Test.php</file>
        </testsuite>
    </testsuites>
</phpunit>

composer.json

{
    "name": "opis/closure",
    "description": "A library that can be used to serialize closures (anonymous functions) and arbitrary objects.",
    "keywords": ["closure", "serialization", "function", "serializable", "serialize", "anonymous functions"],
    "homepage": "https://opis.io/closure",
    "license": "MIT",
    "authors": [
        {
            "name": "Marius Sarca",
            "email": "marius.sarca@gmail.com"
        },
        {
            "name": "Sorin Sarca",
            "email": "sarca_sorin@hotmail.com"
        }
    ],
    "require": {
        "php": "^5.4 || ^7.0 || ^8.0"
    },
    "require-dev": {
        "jeremeamia/superclosure": "^2.0",
        "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
    },
    "autoload": {
        "psr-4": {
            "Opis\\Closure\\": "src/"
        },
        "files": ["functions.php"]
    },
    "autoload-dev": {
        "psr-4": {
            "Opis\\Closure\\Test\\": "tests/"
        }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "3.6.x-dev"
        }
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true
    }
}

Special thanks to your attention.

matiaslauriti
  • 7,065
  • 4
  • 31
  • 43
Arash Khajelou
  • 560
  • 3
  • 16

0 Answers0