diff --git a/docs/01-getting-started.md b/docs/01-getting-started.md index 00fb0e9f..91fa9bd2 100644 --- a/docs/01-getting-started.md +++ b/docs/01-getting-started.md @@ -42,7 +42,7 @@ A full basic example looks like this: load(); $me = $foaf->primaryTopic(); echo "My name is: ".$me->get('foaf:name')."\n"; diff --git a/examples/foafinfo.php b/examples/foafinfo.php index 5e1538bf..c231d67d 100644 --- a/examples/foafinfo.php +++ b/examples/foafinfo.php @@ -22,7 +22,7 @@

EasyRdf FOAF Info Example

- 50]); ?> + 50]); ?> diff --git a/examples/graph_direct.php b/examples/graph_direct.php index 0fd9c3bd..e39de147 100644 --- a/examples/graph_direct.php +++ b/examples/graph_direct.php @@ -23,17 +23,17 @@ $graph->addLiteral('http://example.com/joe', 'foaf:name', 'Joseph Bloggs'); $graph->add('http://example.com/joe', 'rdfs:label', 'Joe'); -$graph->setType('http://njh.me/', 'foaf:Person'); -$graph->add('http://njh.me/', 'rdfs:label', 'Nick'); -$graph->addLiteral('http://njh.me/', 'foaf:name', 'Nicholas Humfrey'); -$graph->addResource('http://njh.me/', 'foaf:homepage', 'http://www.aelius.com/njh/'); +$graph->setType('https://www.aelius.com/njh/', 'foaf:Person'); +$graph->add('https://www.aelius.com/njh/', 'rdfs:label', 'Nick'); +$graph->addLiteral('https://www.aelius.com/njh/', 'foaf:name', 'Nicholas Humfrey'); +$graph->addResource('https://www.aelius.com/njh/', 'foaf:homepage', 'http://www.aelius.com/njh/'); ?>

Name: get('http://example.com/joe', 'foaf:name'); ?>
Names: join('http://example.com/joe', 'foaf:name'); ?>
- Label: label('http://njh.me/'); ?>
+ Label: label('https://www.aelius.com/njh/'); ?>
Properties: properties('http://example.com/joe')); ?>
PropertyUris: propertyUris('http://example.com/joe')); ?>
People: allOfType('foaf:Person')); ?>
diff --git a/lib/Literal.php b/lib/Literal.php index e53c1a42..848968f9 100644 --- a/lib/Literal.php +++ b/lib/Literal.php @@ -107,7 +107,7 @@ public static function create($value, $lang = null, $datatype = null) } // Work out what class to use for this datatype - if (isset(self::$datatypeMap[$datatype])) { + if (is_string($datatype) && isset(self::$datatypeMap[$datatype])) { $class = self::$datatypeMap[$datatype]; } else { $class = 'EasyRdf\Literal'; diff --git a/lib/Parser/RdfXml.php b/lib/Parser/RdfXml.php index e8f3422c..c11e1a96 100644 --- a/lib/Parser/RdfXml.php +++ b/lib/Parser/RdfXml.php @@ -813,8 +813,6 @@ public function parse($graph, $data, $format, $baseUri) } } - xml_parser_free($this->xmlParser); - return $this->tripleCount; } } diff --git a/lib/Parser/Turtle.php b/lib/Parser/Turtle.php index ad414edd..5cb9e917 100644 --- a/lib/Parser/Turtle.php +++ b/lib/Parser/Turtle.php @@ -1195,11 +1195,15 @@ public static function isWhitespace($c) return "\x20" == $c || "\x09" == $c || "\x0A" == $c || "\x0D" == $c; } - /** @ignore */ + /** + * @param non-empty-string $c + * + * @ignore + */ public static function isPrefixStartChar($c) { // ord - Convert the first byte of a string to a value between 0 and 255 - $o = \ord($c); + $o = \ord($c[0]); return $o >= 0x41 && $o <= 0x5A // A-Z @@ -1220,11 +1224,15 @@ public static function isNameStartChar($c) || self::isPrefixStartChar($c); } - /** @ignore */ + /** + * @param non-empty-string $c + * + * @ignore + */ public static function isNameChar($c) { // ord - Convert the first byte of a string to a value between 0 and 255 - $o = \ord($c); + $o = \ord($c[0]); return self::isNameStartChar($c) diff --git a/tests/EasyRdf/Sparql/ResultTest.php b/tests/EasyRdf/Sparql/ResultTest.php index bceb4fa1..ad6f9e6c 100644 --- a/tests/EasyRdf/Sparql/ResultTest.php +++ b/tests/EasyRdf/Sparql/ResultTest.php @@ -459,7 +459,12 @@ public function testDumpUnknownType() 'ReflectionProperty::setAccessible() is not available.' ); } else { - $reflector->setAccessible(true); + // TODO: remove this if-clause when dropping 8.0.x support + // From documentation > http://php.net/manual/en/reflectionproperty.setaccessible.php: + // As of PHP 8.1.0, calling this method has no effect; all properties are accessible by default. + if (version_compare(PHP_VERSION, '8.1.0', '<')) { + $reflector->setAccessible(true); + } } $reflector->setValue($result, 'foobar'); diff --git a/tests/ExampleTest/FoafinfoTest.php b/tests/ExampleTest/FoafinfoTest.php index 7b7e0f90..ac1ec3e4 100644 --- a/tests/ExampleTest/FoafinfoTest.php +++ b/tests/ExampleTest/FoafinfoTest.php @@ -45,31 +45,8 @@ public function testNoParams() $this->assertStringContainsString('EasyRdf FOAF Info Example', $output); $this->assertStringContainsString('

EasyRdf FOAF Info Example

', $output); $this->assertStringContainsString( - '', + '', $output ); } - - public function testNjh() - { - $output = executeExample( - 'foafinfo.php', - ['uri' => 'http://njh.me/foaf.rdf'] - ); - - $this->assertStringContainsString('EasyRdf FOAF Info Example', $output); - $this->assertStringContainsString('

EasyRdf FOAF Info Example

', $output); - $this->assertStringContainsString('
Name:
Nicholas J Humfrey
', $output); - $this->assertStringContainsString( - '
Homepage:
http://www.aelius.com/njh/
', - $output - ); - - $this->assertStringContainsString('

Known Persons

', $output); - $this->assertStringContainsString('>Patrick Sinclair', $output); - $this->assertStringContainsString('>Yves Raimond', $output); - - $this->assertStringContainsString('

Interests

', $output); - $this->assertStringContainsString('>RDF', $output); - } } diff --git a/tests/ExampleTest/GraphdirectTest.php b/tests/ExampleTest/GraphdirectTest.php index 42d16698..62a145ce 100644 --- a/tests/ExampleTest/GraphdirectTest.php +++ b/tests/ExampleTest/GraphdirectTest.php @@ -58,7 +58,7 @@ public function test() $output ); $this->assertStringContainsString( - 'People: http://example.com/joe, http://njh.me/
', + 'People: http://example.com/joe, https://www.aelius.com/njh/
', $output ); $this->assertStringContainsString('Unknown:
', $output);