-
Notifications
You must be signed in to change notification settings - Fork 146
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
base: main
Are you sure you want to change the base?
Conversation
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
|
(cherry picked from commit d9f55cb1b9822ada5231bf19fdf0f15a8c848615)
d336b02
to
b9baef8
Compare
@@ -73,6 +73,7 @@ public function __construct($uri, $graph) | |||
* @throws \OutOfBoundsException | |||
* @throws \InvalidArgumentException | |||
*/ | |||
#[\ReturnTypeWillChange] |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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)."=\"". |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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.
@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. |
@njh PHP 8.1 has hit rc3 :) |
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:
|
@bircher I'll add it to this PR given a minute. |
@njh, any chance to see this committed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Hi everyone Any changed? it's ready? PHP will update to 8.2 tomorrow... and esayRDF will not work with this version... Thanks! |
@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.
|
Built on top of #383rebased on top of main now contains only PHP 8.1 changes.