Skip to content

Commit

Permalink
switched to reduced PHP CS Fixer rule set (PSR12); ported code
Browse files Browse the repository at this point in the history
  • Loading branch information
k00ni committed Feb 13, 2024
1 parent 39e4fa4 commit 7ea1e8a
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 33 deletions.
5 changes: 2 additions & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
$config = new Config();
$config
->setFinder($finder)
->setRiskyAllowed(true)
->setRiskyAllowed(false)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PSR12' => true,
'phpdoc_summary' => false,
])
;
Expand Down
8 changes: 4 additions & 4 deletions examples/basic_sparql.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
<?php
$result = $sparql->query(
'SELECT * WHERE {'.
' ?country rdf:type dbo:Country .'.
' ?country rdfs:label ?label .'.
' FILTER ( lang(?label) = "en" )'.
'} ORDER BY ?label LIMIT 10'
' ?country rdf:type dbo:Country .'.
' ?country rdfs:label ?label .'.
' FILTER ( lang(?label) = "en" )'.
'} ORDER BY ?label LIMIT 10'
);
foreach ($result as $row) {
echo '<li>'.link_to($row->label, $row->country)."</li>\n";
Expand Down
10 changes: 5 additions & 5 deletions lib/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static function newAndLoad($uri, $format = null)
* @param string $uri The URI of the resource
* @param mixed $types RDF type of a new resource (e.g. foaf:Person)
*
* @return resource
* @return \EasyRdf\Resource
*
* @throws \InvalidArgumentException
*/
Expand Down Expand Up @@ -204,7 +204,7 @@ protected function classForResource($uri)
*
* @param mixed $types RDF type of a new blank node (e.g. foaf:Person)
*
* @return resource The new blank node
* @return \EasyRdf\Resource The new blank node
*/
public function newBNode($types = [])
{
Expand Down Expand Up @@ -717,7 +717,7 @@ public function getLiteral($resource, $property, $lang = null)
* @param string $resource The URI of the resource (e.g. http://example.com/joe#me)
* @param string|array $property The name of the property (e.g. foaf:name)
*
* @return resource Resource associated with the property
* @return \EasyRdf\Resource Resource associated with the property
*/
public function getResource($resource, $property)
{
Expand Down Expand Up @@ -1479,7 +1479,7 @@ public function type($resource = null)
* may be arbitrary.
* This method will return null if the resource has no type.
*
* @return resource|null A type associated with the resource
* @return \EasyRdf\Resource|null A type associated with the resource
*/
public function typeAsResource($resource = null)
{
Expand Down Expand Up @@ -1627,7 +1627,7 @@ public function label($resource = null, $lang = null)

/** Get the primary topic of the graph
*
* @return resource|null the primary topic of the document
* @return \EasyRdf\Resource|null the primary topic of the document
*/
public function primaryTopic($resource = null)
{
Expand Down
8 changes: 4 additions & 4 deletions lib/Parser/RdfXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,11 @@ protected function startState1($t, $a)
if (isset($a[$this->rdf.'ID'])) {
$s['type'] = 'uri';
$s['value'] = $s['x_base']->resolve('#'.$a[$this->rdf.'ID']);
/* about */
/* about */
} elseif (isset($a[$this->rdf.'about'])) {
$s['type'] = 'uri';
$s['value'] = $s['x_base']->resolve($a[$this->rdf.'about']);
/* bnode */
/* bnode */
} else {
$s['type'] = 'bnode';
if (isset($a[$this->rdf.'nodeID'])) {
Expand Down Expand Up @@ -341,7 +341,7 @@ protected function startState1($t, $a)
$this->add($supS['value'], $this->rdf.'rest', $coll['value'], $supS['type'], $coll['type']);
$this->add($coll['value'], $this->rdf.'first', $s['value'], $coll['type'], $s['type']);
$this->pushS($coll);
/* normal sub-node */
/* normal sub-node */
} elseif (isset($supS['p']) && $supS['p']) {
$this->add($supS['value'], $supS['p'], $s['value'], $supS['type'], $s['type']);
}
Expand Down Expand Up @@ -452,7 +452,7 @@ protected function startState2($t, $a)
$o['type']
);
}
/* parseType */
/* parseType */
} elseif (isset($a[$this->rdf.'parseType'])) {
if ('Literal' === $a[$this->rdf.'parseType']) {
$s['o_xml_level'] = 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/RdfNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public static function splitUri($uri, $createNamespace = false)

if (\is_object($uri) && ($uri instanceof Resource)) {
$uri = $uri->getUri();
// @phpstan-ignore-next-line
// @phpstan-ignore-next-line
} elseif (false === \is_string($uri)) {
throw new \InvalidArgumentException('$uri should be a string or EasyRdf\Resource');
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ public function type()
* may be arbitrary.
* This method will return null if the resource has no type.
*
* @return resource a type assocated with the resource
* @return \EasyRdf\Resource a type assocated with the resource
*/
public function typeAsResource()
{
Expand Down Expand Up @@ -663,7 +663,7 @@ public function setType($type)
*
* Returns null if no primary topic is available.
*
* @return resource the primary topic of this resource
* @return \EasyRdf\Resource the primary topic of this resource
*/
public function primaryTopic()
{
Expand Down
6 changes: 0 additions & 6 deletions lib/XMLParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ class XMLParser extends \XMLReader
/** Callback to call when significant whitespace is encountered */
public $whitespaceCallback;

public bool $isEmptyElement;

public string $name;

public int $nodeType;

/** Parse an XML string. Calls the callback methods
* when various nodes of an XML document are encountered
*/
Expand Down
9 changes: 6 additions & 3 deletions tests/EasyRdf/FormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ public function testGetDefaultMimeType()
public function testGetDefaultMimeTypeNoDefault()
{
$format2 = Format::register('my2', 'Other Format');
$this->assertStringEquals('',
$this->assertStringEquals(
'',
$format2->getDefaultMimeType()
);
}
Expand Down Expand Up @@ -370,7 +371,8 @@ public function testGetDefaultExtension()
public function testGetExtensionNoDefault()
{
$format2 = Format::register('my2', 'Other Format');
$this->assertStringEquals('',
$this->assertStringEquals(
'',
$format2->getDefaultExtension()
);
}
Expand Down Expand Up @@ -692,7 +694,8 @@ public function testGuessFormatByFilenameUnknown()

public function testGuessFormatUnknown()
{
$this->assertStringEquals('',
$this->assertStringEquals(
'',
Format::guessFormat('blah blah blah')
);
}
Expand Down
12 changes: 8 additions & 4 deletions tests/EasyRdf/GraphTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,8 @@ public function testGetPropertyWithBadLiteral()
{
$this->graph->addLiteral($this->uri, 'foaf:homepage', 'http://example.com/');
$this->graph->addLiteral('http://example.com/', 'dc:title', 'My Homepage');
$this->assertStringEquals('',
$this->assertStringEquals(
'',
$this->graph->get($this->uri, 'foaf:homepage/dc:title')
);
}
Expand Down Expand Up @@ -782,14 +783,16 @@ public function testGetBnodeResource()

public function testGetNonExistantLiteral()
{
$this->assertStringEquals('',
$this->assertStringEquals(
'',
$this->graph->getLiteral($this->uri, 'rdf:type')
);
}

public function testGetNonExistantResource()
{
$this->assertStringEquals('',
$this->assertStringEquals(
'',
$this->graph->get('foo:bar', 'foo:bar')
);
}
Expand Down Expand Up @@ -2127,7 +2130,8 @@ public function testMagicGet()
public function testMagicGetNonExistant()
{
RdfNamespace::setDefault('rdf');
$this->assertStringEquals('',
$this->assertStringEquals(
'',
$this->graph->test
);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/EasyRdf/Http/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ public function testUnsetHeader()
{
$this->client->setHeaders('Accept-Encoding', 'gzip,deflate');
$this->client->setHeaders('Accept-Encoding', null);
$this->assertStringEquals('',
$this->assertStringEquals(
'',
$this->client->getHeader('Accept-encoding'),
'Returned value of header is expected to be null'
);
Expand Down

0 comments on commit 7ea1e8a

Please sign in to comment.