From d395845eb1b2641ec3426efe00ec47e29ea3badd Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Fri, 14 Jun 2024 21:46:22 +1200 Subject: [PATCH] ENH Use class name instead of self --- src/DataFormatter.php | 6 +++--- src/DataFormatter/JSONDataFormatter.php | 4 ++-- src/DataFormatter/XMLDataFormatter.php | 6 +++--- src/RestfulServer.php | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/DataFormatter.php b/src/DataFormatter.php index 79ef2a3..c0109c1 100644 --- a/src/DataFormatter.php +++ b/src/DataFormatter.php @@ -136,7 +136,7 @@ abstract class DataFormatter public static function for_extensions($extensions) { foreach ($extensions as $extension) { - if ($formatter = self::for_extension($extension)) { + if ($formatter = DataFormatter::for_extension($extension)) { return $formatter; } } @@ -178,7 +178,7 @@ abstract class DataFormatter public static function for_mimetypes($mimetypes) { foreach ($mimetypes as $mimetype) { - if ($formatter = self::for_mimetype($mimetype)) { + if ($formatter = DataFormatter::for_mimetype($mimetype)) { return $formatter; } } @@ -286,7 +286,7 @@ abstract class DataFormatter /** * Returns all fields on the object which should be shown - * in the output. Can be customised through {@link self::setCustomFields()}. + * in the output. Can be customised through {@link DataFormatter::setCustomFields()}. * * @param DataObject $obj * @return array diff --git a/src/DataFormatter/JSONDataFormatter.php b/src/DataFormatter/JSONDataFormatter.php index 6f846f0..fbd2b96 100644 --- a/src/DataFormatter/JSONDataFormatter.php +++ b/src/DataFormatter/JSONDataFormatter.php @@ -89,7 +89,7 @@ class JSONDataFormatter extends DataFormatter continue; } - $fieldValue = self::cast($obj->obj($fieldName)); + $fieldValue = JSONDataFormatter::cast($obj->obj($fieldName)); $mappedFieldName = $this->getFieldAlias($className, $fieldName); $serobj->$mappedFieldName = $fieldValue; } @@ -120,7 +120,7 @@ class JSONDataFormatter extends DataFormatter $serobj->$relName = ArrayData::array_to_object(array( "className" => $relClass, "href" => "$href.json", - "id" => self::cast($obj->obj($fieldName)) + "id" => JSONDataFormatter::cast($obj->obj($fieldName)) )); } diff --git a/src/DataFormatter/XMLDataFormatter.php b/src/DataFormatter/XMLDataFormatter.php index 58737b0..c4ba879 100644 --- a/src/DataFormatter/XMLDataFormatter.php +++ b/src/DataFormatter/XMLDataFormatter.php @@ -262,7 +262,7 @@ class XMLDataFormatter extends DataFormatter */ public function convertStringToArray($strData) { - return self::xml2array($strData); + return XMLDataFormatter::xml2array($strData); } /** @@ -299,7 +299,7 @@ class XMLDataFormatter extends DataFormatter // This will throw an exception if the XML contains references to any internal entities // that were defined in an before it was removed $xml = new SimpleXMLElement($val ?? ''); - return self::recursiveXMLToArray($xml); + return XMLDataFormatter::recursiveXMLToArray($xml); } /** @@ -326,7 +326,7 @@ class XMLDataFormatter extends DataFormatter } // for CDATA $r = []; foreach ($xml as $key => $value) { - $r[$key] = self::recursiveXMLToArray($value); + $r[$key] = XMLDataFormatter::recursiveXMLToArray($value); } // Attributes if (isset($a)) { diff --git a/src/RestfulServer.php b/src/RestfulServer.php index 977c3e2..4f94f03 100644 --- a/src/RestfulServer.php +++ b/src/RestfulServer.php @@ -48,7 +48,7 @@ class RestfulServer extends Controller /** * If no extension is given in the request, resolve to this extension - * (and subsequently the {@link self::$default_mimetype}. + * (and subsequently the {@link RestfulServer::$default_mimetype}. * * @config * @var string @@ -362,7 +362,7 @@ class RestfulServer extends Controller /** * Returns a dataformatter instance based on the request - * extension or mimetype. Falls back to {@link self::$default_extension}. + * extension or mimetype. Falls back to {@link RestfulServer::$default_extension}. * * @param boolean $includeAcceptHeader Determines wether to inspect and prioritize any HTTP Accept headers * @param string Classname of a DataObject @@ -884,7 +884,7 @@ class RestfulServer extends Controller protected function resolveClassName(HTTPRequest $request) { $className = $request->param('ClassName'); - $aliases = self::config()->get('endpoint_aliases'); + $aliases = static::config()->get('endpoint_aliases'); return empty($aliases[$className]) ? $this->unsanitiseClassName($className) : $aliases[$className]; }