Skip to content

Commit cb37c41

Browse files
authored
fix: do not define blank node types (#375)
1 parent 847fd3c commit cb37c41

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/TypesGenerator.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,6 @@ public function generate(array $graphs, array $config): array
236236
*/
237237
private function buildClass(array $graphs, array $cardinalities, string $typeName, RdfResource $type, array $propertiesMap, array $config): ?SchemaClass
238238
{
239-
if ($type->isBNode()) {
240-
// Ignore blank nodes
241-
return null;
242-
}
243-
244239
if ($type->isA('owl:DeprecatedClass')) {
245240
if (!isset($config['types'][$typeName])) {
246241
return null;
@@ -444,6 +439,10 @@ private function defineTypesToGenerate(array $graphs, array $config): array
444439
}
445440
foreach (self::$classTypes as $classType) {
446441
foreach ($graph->allOfType($classType) as $type) {
442+
if ($type->isBNode()) {
443+
continue;
444+
}
445+
447446
$typeName = $this->phpTypeConverter->escapeIdentifier($type->localName());
448447
if (!($config['types'][$typeName]['exclude'] ?? false)) {
449448
if ($config['resolveTypes'] || $vocabAllTypes) {

tests/TypesGeneratorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ private function getGraphs(): array
224224
$nodeGraph->addResource('https://gitlab.com/mmorg/nodefr-2/CompetencyWorldEntity', 'rdf:type', 'rdfs:Class');
225225
$nodeGraph->addResource('https://gitlab.com/mmorg/nodefr-2/CompetencyWorldEntity', 'rdfs:subClassOf', 'https://schema.org/Thing');
226226

227+
$nodeGraph->addResource('_:b0_n0', 'rdf:type', 'rdfs:Class');
228+
227229
$nodeGraph->addResource('https://gitlab.com/mmorg/nodefr-2/hasAppellation', 'rdf:type', 'rdf:Property');
228230
$nodeGraph->addResource('https://gitlab.com/mmorg/nodefr-2/hasAppellation', 'schema:domainIncludes', 'https://gitlab.com/mmorg/nodefr-2/CompetencyWorldEntity');
229231
$nodeGraph->addResource('https://gitlab.com/mmorg/nodefr-2/hasAppellation', 'schema:rangeIncludes', 'https://schema.org/Text');

0 commit comments

Comments
 (0)