diff --git a/composer.json b/composer.json index ed2fa54..5fa0c7b 100644 --- a/composer.json +++ b/composer.json @@ -7,8 +7,7 @@ "symfony/finder": "^3.4 || ^4.0", "symfony/yaml": "^3.4 || ^4.0", "marcj/topsort": "^1 || ^2", - "psr/simple-cache": "^1.0", - "silverstripe/framework": "4.13.x-dev" + "psr/simple-cache": "^1.0" }, "require-dev": { "phpunit/phpunit": "^9.5", @@ -21,4 +20,4 @@ "SilverStripe\\Config\\Tests\\": "tests/" } } -} \ No newline at end of file +} diff --git a/src/Collections/DeltaConfigCollection.php b/src/Collections/DeltaConfigCollection.php index 7f5e870..b464519 100644 --- a/src/Collections/DeltaConfigCollection.php +++ b/src/Collections/DeltaConfigCollection.php @@ -151,7 +151,11 @@ public function isDeltaReset($class = null) */ public function unserialize($serialized) { - Deprecation::notice('1.6.0', 'Use __unserialize() instead'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.6.0', 'Use __unserialize() instead'); + } else { + user_error(__METHOD__ . ' is deprecated. Use __unserialize() instead', E_USER_DEPRECATED); + } parent::unserialize($serialized); $this->postInit(); } diff --git a/src/Collections/MemoryConfigCollection.php b/src/Collections/MemoryConfigCollection.php index 6ffe745..f8211a7 100644 --- a/src/Collections/MemoryConfigCollection.php +++ b/src/Collections/MemoryConfigCollection.php @@ -118,7 +118,11 @@ public function checkForDeprecatedConfig($class, $name): void $deprecated = $this->getClassConfig('__deprecated', true); $data = $deprecated['config'][strtolower($class)][$name] ?? []; if (!empty($data)) { - Deprecation::notice($data['version'], $data['message'], Deprecation::SCOPE_CONFIG); + if (class_exists(Deprecation::class)) { + Deprecation::notice($data['version'], $data['message'], Deprecation::SCOPE_CONFIG); + } else { + user_error($data['message'], E_USER_DEPRECATED); + } } } @@ -216,7 +220,11 @@ public function getAll() */ public function update($class, $name, $value) { - Deprecation::notice('1.0.0', 'Use merge() instead'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.0.0', 'Use merge() instead'); + } else { + user_error(__METHOD__ . ' is deprecated. Use merge() instead', E_USER_DEPRECATED); + } $this->merge($class, $name, $value); return $this; } @@ -229,7 +237,14 @@ public function update($class, $name, $value) public function merge($class, $name, $value) { if (!is_array($value)) { - Deprecation::notice('1.12.0', 'Use set() if $value is not an array instead'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.12.0', 'Use set() if $value is not an array instead'); + } else { + user_error( + 'Non-array values for the $value argument in ' . __METHOD__ + . ' are deprecated. Use set() if $value is not an array instead', E_USER_DEPRECATED + ); + } } // Detect mergeable config $existing = $this->get($class, $name, true); @@ -297,7 +312,11 @@ public function __unserialize(array $data): void */ public function serialize() { - Deprecation::notice('1.12.0', 'Use __serialize() instead'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.12.0', 'Use __serialize() instead'); + } else { + user_error(__METHOD__ . ' is deprecated. Use __serialize() instead', E_USER_DEPRECATED); + } return serialize($this->__serialize()); } @@ -311,7 +330,11 @@ public function serialize() */ public function unserialize($serialized) { - Deprecation::notice('1.12.0', 'Use __unserialize() instead'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.12.0', 'Use __unserialize() instead'); + } else { + user_error(__METHOD__ . ' is deprecated. Use __unserialize() instead', E_USER_DEPRECATED); + } $data = unserialize($serialized ?? ''); $this->__unserialize($data); } diff --git a/src/Middleware/MiddlewareCommon.php b/src/Middleware/MiddlewareCommon.php index bbfd279..acc2eb3 100644 --- a/src/Middleware/MiddlewareCommon.php +++ b/src/Middleware/MiddlewareCommon.php @@ -75,7 +75,11 @@ public function __unserialize(array $data): void */ public function serialize() { - Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it'); + } else { + user_error(__METHOD__ . ' is deprecated. Will be removed without equivalent functionality to replace it', E_USER_DEPRECATED); + } return json_encode(array_values($this->__serialize() ?? [])); } @@ -89,7 +93,11 @@ public function serialize() */ public function unserialize($serialized) { - Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it'); + if (class_exists(Deprecation::class)) { + Deprecation::notice('1.12.0', 'Will be removed without equivalent functionality to replace it'); + } else { + user_error(__METHOD__ . ' is deprecated. Will be removed without equivalent functionality to replace it', E_USER_DEPRECATED); + } $values = json_decode($serialized ?? '', true); foreach (array_keys($this->__serialize() ?? []) as $i => $key) { if (!property_exists($this, $key ?? '')) {