Skip to content

Commit 10470a9

Browse files
committed
Jet Core
------------------------- Backward compatibility with PHP < 8.4
1 parent 40aa733 commit 10470a9

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

_tools/studio/application/Classes/ClassCreator/Class/Property.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ public function setHooks( string $hooks ): void
162162
$this->hooks = $hooks;
163163
}
164164

165+
/** @noinspection PhpUnnecessaryCurlyVarSyntaxInspection */
165166
public function createStdHook(
166167
string $set_type,
167168
?string $set_code=null

library/Jet/DataModel/Definition/Property.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,15 @@ public function getDefaultValue(): mixed
282282

283283
$r = new ReflectionObject( $i );
284284
$p = $r->getProperty( $this->getName() );
285-
$p->setAccessible(true);
286-
287-
return $p->getValue($i);
285+
286+
if(PHP_VERSION_ID >= 80400) {
287+
return $p->getRawValue( $i );
288+
} else {
289+
if(PHP_VERSION_ID<80100) {
290+
$p->setAccessible(true);
291+
}
292+
return $p->getValue( $i );
293+
}
288294
}
289295

290296
/**
@@ -333,7 +339,17 @@ public function loadPropertyValue( object $obj, string $property_name, array $da
333339

334340
$r = new ReflectionObject( $obj );
335341
$p = $r->getProperty( $property_name );
336-
$p->setRawValue( $obj, $value );
342+
343+
if(PHP_VERSION_ID >= 80400) {
344+
$p->setRawValue( $obj, $value );
345+
} else {
346+
if(PHP_VERSION_ID<80100) {
347+
$p->setAccessible(true);
348+
$p->setValue( $obj, $value );
349+
} else {
350+
$p->setValue( $obj, $value );
351+
}
352+
}
337353
}
338354

339355
/**

library/Jet/Form/Definition.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,16 @@ protected function getDefaultValue() : mixed
255255

256256
$ref = new ReflectionClass($this->context_object);
257257
$property = $ref->getProperty($this->getPropertyName());
258-
return $property->getRawValue( $this->context_object );
258+
259+
if(PHP_VERSION_ID >= 80400) {
260+
return $property->getRawValue( $this->context_object );
261+
} else {
262+
if(PHP_VERSION_ID<80100) {
263+
$property->setAccessible(true);
264+
}
265+
266+
return $property->getValue( $this->context_object );
267+
}
259268

260269
}
261270

0 commit comments

Comments
 (0)