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

PHP 8.1 compatibility #384

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alexpott
Copy link
Contributor

@alexpott alexpott commented Aug 24, 2021

Built on top of #383 rebased on top of main now contains only PHP 8.1 changes.

@alexpott
Copy link
Contributor Author

So none of the nightly php builds on travis are php 8.1 ... ho hum. So let's not pretend... here's the output from running the tests locally on PHP 8.1

$ COMPOSER_FLAGS="--no-ansi --no-interaction --ignore-platform-reqs" make -e test-lib
/usr/local/php5/bin/php composer.phar --no-ansi --no-interaction --ignore-platform-reqs install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead.
Package zendframework/zend-http is abandoned, you should avoid using it. Use laminas/laminas-http instead.
Package zendframework/zend-loader is abandoned, you should avoid using it. Use laminas/laminas-loader instead.
Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead.
Package zendframework/zend-uri is abandoned, you should avoid using it. Use laminas/laminas-uri instead.
Package zendframework/zend-validator is abandoned, you should avoid using it. Use laminas/laminas-validator instead.
Generating autoload files
44 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
mkdir -p reports
/usr/local/php5/bin/php -d memory_limit=1G vendor/bin/phpunit -c config/phpunit.xml --testsuite "EasyRdf Library"
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.

Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

.............................................................   61 / 1363 (  4%)
.............................................................  122 / 1363 (  8%)
.............................................................  183 / 1363 ( 13%)
.............................................................  244 / 1363 ( 17%)
.............................................................  305 / 1363 ( 22%)
.............................................................  366 / 1363 ( 26%)
.....................................................S.......  427 / 1363 ( 31%)
.........I...................................................  488 / 1363 ( 35%)
.............................................................  549 / 1363 ( 40%)
.............................................................  610 / 1363 ( 44%)
.............................................................  671 / 1363 ( 49%)
.........................................................SSSS  732 / 1363 ( 53%)
SS...............I...........................................  793 / 1363 ( 58%)
..........I................................................I.  854 / 1363 ( 62%)
.....II...............................................I.....I  915 / 1363 ( 67%)
IIIIII.......................................................  976 / 1363 ( 71%)
...I......................................................... 1037 / 1363 ( 76%)
............................................................. 1098 / 1363 ( 80%)
..........................SSSSSSSSSSSSSSS.................... 1159 / 1363 ( 85%)
..SSS........................................................ 1220 / 1363 ( 89%)
............................................................. 1281 / 1363 ( 93%)
............................................................. 1342 / 1363 ( 98%)
.....................                                         1363 / 1363 (100%)

Time: 00:02.014, Memory: 194.06 MB

OK, but incomplete, skipped, or risky tests!
Tests: 1363, Assertions: 2663, Skipped: 25, Incomplete: 15.

$ php -v
PHP 8.1.0-dev (cli) (built: Aug 21 2021 00:33:10) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.0-dev, Copyright (c), by Zend Technologies

lib/Http/Response.php Outdated Show resolved Hide resolved
@alexpott alexpott force-pushed the php8.1-compatibility+php8-testing branch from d336b02 to b9baef8 Compare September 1, 2021 09:53
@alexpott alexpott changed the title PHP 8.1 compatibility + Testing on PHP 8.1 PHP 8.1 compatibility Sep 1, 2021
@@ -73,6 +73,7 @@ public function __construct($uri, $graph)
* @throws \OutOfBoundsException
* @throws \InvalidArgumentException
*/
#[\ReturnTypeWillChange]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This annotation allows us to suppress a deprecation notice triggered by PHP 8.1 - it will require fixing once PHP 9 is released. Since PHP 7.1 is the minimum version we could choose to add the return types here. I went the annotation route because changing or adding a return type should have a new major as per semver.

@@ -267,7 +267,7 @@ public static function guessFormat($data, $filename = null)
}

// Then try and guess by the first 1024 bytes of content
$short = substr($data, 0, 1024);
$short = substr($data ?? '', 0, 1024);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the main PHP 8.1 is that built-in function that use to accept NULLs in string arguments will now trigger a deprecation.

@@ -199,10 +199,10 @@ public function htmlLink($text = null, $options = array())
);
}

$html .= " ".htmlspecialchars($key)."=\"".
htmlspecialchars($value)."\"";
$html .= " ".htmlspecialchars($key, ENT_COMPAT)."=\"".
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://php.watch/versions/8.1/html-entity-default-value-changes - adding ENT_COMPAT preserves the current behaviour.

@@ -167,7 +167,7 @@ public function testParseFileRelativeUri()

$doc = $graph->get('foaf:PersonalProfileDocument', '^rdf:type');
$this->assertClass('EasyRdf\Resource', $doc);
$this->assertRegExp('|^file://.+/fixtures/foaf\.rdf$|', $doc->getUri());
$this->assertMatchesRegularExpression('|^file://.+/fixtures/foaf\.rdf$|', $doc->getUri());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertRegExp is deprecated in PHPUnit - the polyfill allows us to use the current method when running tests on the older versions of PHPUnit.

@alexpott
Copy link
Contributor Author

@njh PHP 8.1 has now hit RC2. It'd be great to land this and get a new release out so that projects that have EasyRDF as a dependency can have a stable release when PHP 8.1 lands.

@alexpott
Copy link
Contributor Author

alexpott commented Oct 6, 2021

@njh PHP 8.1 has hit rc3 :)

@alexpott
Copy link
Contributor Author

alexpott commented Oct 6, 2021

@njh I've created #387 to make it easier to add PHP 8.1 testing - if that's merged before this one then I can add PHP 8.1 testing here.

@bircher
Copy link

bircher commented Jan 12, 2022

I don't know if I should open a new PR, but I found another php 8.1 deprecation warning, fixed similar to this PR, this is the change:

diff --git a/lib/Sparql/Client.php b/lib/Sparql/Client.php
index e12d089..424755f 100644
--- a/lib/Sparql/Client.php
+++ b/lib/Sparql/Client.php
@@ -71,7 +71,7 @@ class Client
     {
         $this->queryUri = $queryUri;
 
-        if (strlen(parse_url($queryUri, PHP_URL_QUERY)) > 0) {
+        if (strlen(parse_url($queryUri, PHP_URL_QUERY) ?? '') > 0) {
             $this->queryUri_has_params = true;
         } else {
             $this->queryUri_has_params = false;

@alexpott
Copy link
Contributor Author

@bircher I'll add it to this PR given a minute.

@claudiu-cristea
Copy link

@njh, any chance to see this committed?

Copy link

@dunglas dunglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@renderpci
Copy link

Hi everyone

Any changed? it's ready? PHP will update to 8.2 tomorrow... and esayRDF will not work with this version...

Thanks!

@zozlak
Copy link
Collaborator

zozlak commented Dec 9, 2022

@renderpci we have three (sic!) pull requests for making EasyRdf compatible with the PHP 8.1 just the last @njh's activity was 16 months ago and he's the only person with pull request merging rights.

I'm afraid this constitutes an abandoned project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants