From a63360270da07f601827a5f2cada7642d72020e2 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 5 Jun 2024 17:02:30 +1200 Subject: [PATCH] ENH Use class name instead of self --- src/Config/Configuration.php | 6 +- src/Controller.php | 8 +- src/Dev/Benchmark.php | 8 +- src/Dev/DevelopmentAdmin.php | 4 +- src/Middleware/QueryCachingMiddleware.php | 2 +- src/PersistedQuery/FileProvider.php | 2 +- src/PersistedQuery/HTTPProvider.php | 4 +- src/PersistedQuery/JSONStringProvider.php | 2 +- .../PersistedQueryMappingProvider.php | 2 +- src/QueryHandler/QueryHandler.php | 10 +- src/QueryHandler/QueryStateProvider.php | 4 +- src/QueryHandler/RequestContextProvider.php | 4 +- src/QueryHandler/SchemaConfigProvider.php | 4 +- src/QueryHandler/TokenContextProvider.php | 4 +- src/QueryHandler/UserContextProvider.php | 4 +- src/Schema/BulkLoader/AbstractBulkLoader.php | 6 +- src/Schema/BulkLoader/BulkLoaderSet.php | 6 +- src/Schema/BulkLoader/Collection.php | 6 +- src/Schema/BulkLoader/ExtensionLoader.php | 2 +- src/Schema/BulkLoader/FilepathLoader.php | 2 +- src/Schema/BulkLoader/InheritanceLoader.php | 2 +- src/Schema/BulkLoader/NamespaceLoader.php | 2 +- src/Schema/BulkLoader/Registry.php | 8 +- src/Schema/BulkLoader/RegistryBackend.php | 2 +- src/Schema/DataObject/CreateCreator.php | 6 +- src/Schema/DataObject/DataObjectModel.php | 2 +- src/Schema/DataObject/FieldAccessor.php | 6 +- src/Schema/DataObject/InheritanceChain.php | 4 +- src/Schema/DataObject/InterfaceBuilder.php | 4 +- .../DataObject/Plugin/CanViewPermission.php | 4 +- .../Plugin/DBFieldArgs/DBFieldArgsPlugin.php | 2 +- src/Schema/DataObject/Plugin/DBFieldTypes.php | 2 +- src/Schema/DataObject/Plugin/FirstResult.php | 2 +- src/Schema/DataObject/Plugin/Inheritance.php | 2 +- .../DataObject/Plugin/InheritedPlugins.php | 2 +- src/Schema/DataObject/Plugin/Paginator.php | 2 +- .../QueryFilter/FieldFilterRegistry.php | 2 +- .../QueryFilter/FilterRegistryInterface.php | 2 +- .../Plugin/QueryFilter/QueryFilter.php | 2 +- src/Schema/DataObject/Plugin/QuerySort.php | 4 +- .../DataObject/Plugin/ScalarDBField.php | 2 +- src/Schema/DataObject/UpdateCreator.php | 4 +- src/Schema/Field/Argument.php | 8 +- src/Schema/Field/Field.php | 28 ++--- src/Schema/Field/ModelField.php | 2 +- src/Schema/Logger.php | 36 +++---- src/Schema/Plugin/PaginationPlugin.php | 2 +- src/Schema/Plugin/SortPlugin.php | 6 +- src/Schema/Resolver/EncodedResolver.php | 8 +- src/Schema/Schema.php | 100 +++++++++--------- src/Schema/SchemaBuilder.php | 4 +- src/Schema/SchemaConfig.php | 4 +- src/Schema/Services/NestedInputBuilder.php | 6 +- src/Schema/Services/SchemaTranscriber.php | 4 +- src/Schema/Storage/AbstractTypeRegistry.php | 12 +-- src/Schema/Storage/CodeGenerationStore.php | 6 +- src/Schema/Type/Enum.php | 6 +- src/Schema/Type/InterfaceType.php | 2 +- src/Schema/Type/ModelType.php | 14 +-- src/Schema/Type/Scalar.php | 8 +- src/Schema/Type/Type.php | 18 ++-- src/Schema/Type/UnionType.php | 8 +- tests/Fake/FakeSiteTree.php | 4 +- tests/Schema/AbstractTypeRegistryTest.php | 8 +- .../FakeInheritanceUnionBuilder.php | 4 +- .../DataObject/FakeInterfaceBuilder.php | 8 +- 66 files changed, 232 insertions(+), 232 deletions(-) diff --git a/src/Config/Configuration.php b/src/Config/Configuration.php index 5027ee2b..bbe707a8 100644 --- a/src/Config/Configuration.php +++ b/src/Config/Configuration.php @@ -85,7 +85,7 @@ private function path($path, callable $callback): void * @return $this * @throws SchemaBuilderException */ - public function set($path, $value): self + public function set($path, $value): Configuration { $this->path($path, function (&$scope, $part) use ($value) { $scope[$part] = $value; @@ -100,7 +100,7 @@ public function set($path, $value): self * @return $this * @throws SchemaBuilderException */ - public function unset($path): self + public function unset($path): Configuration { $this->path($path, function (&$scope, $part) { unset($scope[$part]); @@ -113,7 +113,7 @@ public function unset($path): self * @param array $settings * @return $this */ - public function apply(array $settings): self + public function apply(array $settings): Configuration { $this->settings = Priority::mergeArray($settings, $this->settings); diff --git a/src/Controller.php b/src/Controller.php index 8c352c9a..0683eb5e 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -245,7 +245,7 @@ public function getMergedCorsConfig(): array return array_merge($defaults, $override); } - public function setCorsConfig(array $config): self + public function setCorsConfig(array $config): Controller { $this->corsConfig = array_merge($this->corsConfig, $config); @@ -326,7 +326,7 @@ protected function getRequestOrigin(HTTPRequest $request): ?string protected function handleOptions(HTTPRequest $request): HTTPResponse { $response = HTTPResponse::create(); - $corsConfig = Config::inst()->get(self::class, 'cors'); + $corsConfig = Config::inst()->get(Controller::class, 'cors'); if ($corsConfig['Enabled']) { // CORS config is enabled and the request is an OPTIONS pre-flight. // Process the CORS config and add appropriate headers. @@ -390,7 +390,7 @@ protected function getRequestUser(HTTPRequest $request): ?Member return $member; } - public function setSchemaKey(string $schemaKey): self + public function setSchemaKey(string $schemaKey): Controller { $this->schemaKey = $schemaKey; return $this; @@ -406,7 +406,7 @@ public function getQueryHandler(): QueryHandlerInterface return $this->queryHandler; } - public function setQueryHandler(QueryHandlerInterface $queryHandler): self + public function setQueryHandler(QueryHandlerInterface $queryHandler): Controller { $this->queryHandler = $queryHandler; return $this; diff --git a/src/Dev/Benchmark.php b/src/Dev/Benchmark.php index ef9271a3..a922954d 100644 --- a/src/Dev/Benchmark.php +++ b/src/Dev/Benchmark.php @@ -16,10 +16,10 @@ class Benchmark public static function start(string $id): void { - if (isset(self::$benchmarks[$id])) { + if (isset(Benchmark::$benchmarks[$id])) { throw new \Exception(sprintf('Benchmark ID %s has already started', $id)); } - self::$benchmarks[$id] = microtime(true); + Benchmark::$benchmarks[$id] = microtime(true); } /** @@ -31,7 +31,7 @@ public static function start(string $id): void */ public static function end(string $id, string $message = null, bool $return = true): ?string { - $benchmark = self::$benchmarks[$id] ?? null; + $benchmark = Benchmark::$benchmarks[$id] ?? null; if (!$benchmark) { throw new \Exception(sprintf('Benchmark ID %s was never started', $id)); } @@ -40,7 +40,7 @@ public static function end(string $id, string $message = null, bool $return = tr $ms = $rounded * 1000; $result = $message ? sprintf($message, $ms) : sprintf('[%s]: %sms', $id, $ms); - unset(self::$benchmarks[$id]); + unset(Benchmark::$benchmarks[$id]); if ($return) { return $result; diff --git a/src/Dev/DevelopmentAdmin.php b/src/Dev/DevelopmentAdmin.php index 14ae689b..d1e29cc0 100644 --- a/src/Dev/DevelopmentAdmin.php +++ b/src/Dev/DevelopmentAdmin.php @@ -62,7 +62,7 @@ public function index(HTTPRequest $request) echo '