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 '
';
$evenOdd = "odd";
- foreach (self::get_links() as $action => $description) {
+ foreach (DevelopmentAdmin::get_links() as $action => $description) {
echo "- /dev/graphql/$action:"
. " $description
\n";
$evenOdd = ($evenOdd == "odd") ? "even" : "odd";
@@ -74,7 +74,7 @@ public function index(HTTPRequest $request)
} else {
echo "SILVERSTRIPE CMS GRAPHQL TOOLS\n--------------------------\n\n";
echo "You can execute any of the following commands:\n\n";
- foreach (self::get_links() as $action => $description) {
+ foreach (DevelopmentAdmin::get_links() as $action => $description) {
echo " sake dev/graphql/$action: $description\n";
}
echo "\n\n";
diff --git a/src/Middleware/QueryCachingMiddleware.php b/src/Middleware/QueryCachingMiddleware.php
index 2df91664..4f6b53b9 100644
--- a/src/Middleware/QueryCachingMiddleware.php
+++ b/src/Middleware/QueryCachingMiddleware.php
@@ -74,7 +74,7 @@ public function getCache(): CacheInterface
return $this->cache;
}
- public function setCache(CacheInterface $cache): self
+ public function setCache(CacheInterface $cache): QueryCachingMiddleware
{
$this->cache = $cache;
return $this;
diff --git a/src/PersistedQuery/FileProvider.php b/src/PersistedQuery/FileProvider.php
index 7a1720ef..d35a266e 100644
--- a/src/PersistedQuery/FileProvider.php
+++ b/src/PersistedQuery/FileProvider.php
@@ -65,7 +65,7 @@ public function getByID(string $queryID, string $schemaKey = 'default'): ?string
return isset($mapping[$queryID]) ? $mapping[$queryID] : null;
}
- public function setSchemaMapping(array $mapping): self
+ public function setSchemaMapping(array $mapping): FileProvider
{
$this->schemaToPath = $mapping;
diff --git a/src/PersistedQuery/HTTPProvider.php b/src/PersistedQuery/HTTPProvider.php
index 99649e93..6d35911f 100644
--- a/src/PersistedQuery/HTTPProvider.php
+++ b/src/PersistedQuery/HTTPProvider.php
@@ -105,7 +105,7 @@ public function getByID(string $queryID, string $schemaKey = 'default'): ?string
return isset($mapping[$queryID]) ? $mapping[$queryID] : null;
}
- public function setSchemaMapping(array $mapping): self
+ public function setSchemaMapping(array $mapping): HTTPProvider
{
foreach ($mapping as $schemaKey => $url) {
if (!filter_var($url, FILTER_VALIDATE_URL)) {
@@ -128,7 +128,7 @@ public function getSchemaMapping(): array
return $this->schemaToURL;
}
- public function setClient(HTTPClient $client): self
+ public function setClient(HTTPClient $client): HTTPProvider
{
$this->client = $client;
diff --git a/src/PersistedQuery/JSONStringProvider.php b/src/PersistedQuery/JSONStringProvider.php
index ad98051a..c9e3efd0 100644
--- a/src/PersistedQuery/JSONStringProvider.php
+++ b/src/PersistedQuery/JSONStringProvider.php
@@ -67,7 +67,7 @@ public function getByID(string $queryID, string $schemaKey = 'default'): ?string
return isset($mapping[$queryID]) ? $mapping[$queryID] : null;
}
- public function setSchemaMapping(array $mapping): self
+ public function setSchemaMapping(array $mapping): JSONStringProvider
{
foreach ($mapping as $schemaKey => $queryMap) {
if (!is_string($queryMap)) {
diff --git a/src/PersistedQuery/PersistedQueryMappingProvider.php b/src/PersistedQuery/PersistedQueryMappingProvider.php
index 58b9eb6d..77db85ab 100644
--- a/src/PersistedQuery/PersistedQueryMappingProvider.php
+++ b/src/PersistedQuery/PersistedQueryMappingProvider.php
@@ -17,7 +17,7 @@ public function getByID(string $queryID, string $schemaKey = 'default'): ?string
/**
* Sets mapping of query mapping to schema keys
*/
- public function setSchemaMapping(array $mapping): self;
+ public function setSchemaMapping(array $mapping): PersistedQueryMappingProvider;
public function getSchemaMapping(): array;
}
diff --git a/src/QueryHandler/QueryHandler.php b/src/QueryHandler/QueryHandler.php
index 600fa6eb..8ab46b2a 100644
--- a/src/QueryHandler/QueryHandler.php
+++ b/src/QueryHandler/QueryHandler.php
@@ -52,7 +52,7 @@ class QueryHandler implements
*/
private array $contextProviders = [];
- private array $errorFormatter = [self::class, 'formatError'];
+ private array $errorFormatter = [QueryHandler::class, 'formatError'];
/**
* @config
@@ -226,7 +226,7 @@ public function serialiseResult(ExecutionResult $executionResult): array
* @param callable $errorFormatter
* @return QueryHandler
*/
- public function setErrorFormatter(callable $errorFormatter): self
+ public function setErrorFormatter(callable $errorFormatter): QueryHandler
{
$this->errorFormatter = $errorFormatter;
return $this;
@@ -236,7 +236,7 @@ public function setErrorFormatter(callable $errorFormatter): self
* @param callable $errorHandler
* @return QueryHandler
*/
- public function setErrorHandler(callable $errorHandler): self
+ public function setErrorHandler(callable $errorHandler): QueryHandler
{
$this->errorHandler = $errorHandler;
return $this;
@@ -254,7 +254,7 @@ public function getMiddlewares(): array
* @param QueryMiddleware[] $middlewares
* @return $this
*/
- public function setMiddlewares(array $middlewares): self
+ public function setMiddlewares(array $middlewares): QueryHandler
{
foreach ($middlewares as $middleware) {
if ($middleware instanceof QueryMiddleware) {
@@ -268,7 +268,7 @@ public function setMiddlewares(array $middlewares): self
* @param QueryMiddleware $middleware
* @return $this
*/
- public function addMiddleware(QueryMiddleware $middleware): self
+ public function addMiddleware(QueryMiddleware $middleware): QueryHandler
{
$this->middlewares[] = $middleware;
return $this;
diff --git a/src/QueryHandler/QueryStateProvider.php b/src/QueryHandler/QueryStateProvider.php
index 845b1bb9..72bc2376 100644
--- a/src/QueryHandler/QueryStateProvider.php
+++ b/src/QueryHandler/QueryStateProvider.php
@@ -30,13 +30,13 @@ public function __construct()
public static function get(array $context): Configuration
{
- return $context[self::KEY] ?? new Configuration();
+ return $context[QueryStateProvider::KEY] ?? new Configuration();
}
public function provideContext(): array
{
return [
- self::KEY => $this->queryState,
+ QueryStateProvider::KEY => $this->queryState,
];
}
}
diff --git a/src/QueryHandler/RequestContextProvider.php b/src/QueryHandler/RequestContextProvider.php
index 617e837b..0cf83a51 100644
--- a/src/QueryHandler/RequestContextProvider.php
+++ b/src/QueryHandler/RequestContextProvider.php
@@ -30,7 +30,7 @@ public function __construct(HTTPRequest $request)
*/
public static function get(array $context)
{
- return $context[self::HTTP_METHOD] ?? null;
+ return $context[RequestContextProvider::HTTP_METHOD] ?? null;
}
/**
@@ -46,7 +46,7 @@ public function provideContext(): array
}
return [
- self::HTTP_METHOD => $method,
+ RequestContextProvider::HTTP_METHOD => $method,
];
}
}
diff --git a/src/QueryHandler/SchemaConfigProvider.php b/src/QueryHandler/SchemaConfigProvider.php
index 903972ae..3804df4a 100644
--- a/src/QueryHandler/SchemaConfigProvider.php
+++ b/src/QueryHandler/SchemaConfigProvider.php
@@ -30,7 +30,7 @@ public function __construct(SchemaConfig $schemaConfig)
*/
public static function get(array $context): SchemaConfig
{
- return $context[self::KEY] ?? new SchemaConfig();
+ return $context[SchemaConfigProvider::KEY] ?? new SchemaConfig();
}
/**
@@ -39,7 +39,7 @@ public static function get(array $context): SchemaConfig
public function provideContext(): array
{
return [
- self::KEY => $this->schemaConfig,
+ SchemaConfigProvider::KEY => $this->schemaConfig,
];
}
}
diff --git a/src/QueryHandler/TokenContextProvider.php b/src/QueryHandler/TokenContextProvider.php
index 20108691..97b5a885 100644
--- a/src/QueryHandler/TokenContextProvider.php
+++ b/src/QueryHandler/TokenContextProvider.php
@@ -29,7 +29,7 @@ public function __construct(string $token = '')
*/
public static function get(array $context): ?string
{
- return $context[self::KEY] ?? null;
+ return $context[TokenContextProvider::KEY] ?? null;
}
/**
@@ -38,7 +38,7 @@ public static function get(array $context): ?string
public function provideContext(): array
{
return [
- self::KEY => $this->token,
+ TokenContextProvider::KEY => $this->token,
];
}
}
diff --git a/src/QueryHandler/UserContextProvider.php b/src/QueryHandler/UserContextProvider.php
index 1a3c0952..a759ac45 100644
--- a/src/QueryHandler/UserContextProvider.php
+++ b/src/QueryHandler/UserContextProvider.php
@@ -23,7 +23,7 @@ public function __construct(?Member $member = null)
public static function get(array $context): ?Member
{
- return $context[self::KEY] ?? null;
+ return $context[UserContextProvider::KEY] ?? null;
}
/**
@@ -32,7 +32,7 @@ public static function get(array $context): ?Member
public function provideContext(): array
{
return [
- self::KEY => $this->member,
+ UserContextProvider::KEY => $this->member,
];
}
}
diff --git a/src/Schema/BulkLoader/AbstractBulkLoader.php b/src/Schema/BulkLoader/AbstractBulkLoader.php
index 2d9afc27..900c59fd 100644
--- a/src/Schema/BulkLoader/AbstractBulkLoader.php
+++ b/src/Schema/BulkLoader/AbstractBulkLoader.php
@@ -42,7 +42,7 @@ public function __construct(array $include = [], array $exclude = [])
* @param array $include
* @return $this
*/
- public function include(array $include): self
+ public function include(array $include): AbstractBulkLoader
{
$this->includeList = $include;
@@ -53,7 +53,7 @@ public function include(array $include): self
* @param array $exclude
* @return $this
*/
- public function exclude(array $exclude): self
+ public function exclude(array $exclude): AbstractBulkLoader
{
$this->excludeList = $exclude;
@@ -65,7 +65,7 @@ public function exclude(array $exclude): self
* @return AbstractBulkLoader
* @throws SchemaBuilderException
*/
- public function applyConfig(array $config): self
+ public function applyConfig(array $config): AbstractBulkLoader
{
Schema::assertValidConfig($config, ['include', 'exclude'], ['include']);
$include = $config['include'];
diff --git a/src/Schema/BulkLoader/BulkLoaderSet.php b/src/Schema/BulkLoader/BulkLoaderSet.php
index 18cacc80..c2e89d4a 100644
--- a/src/Schema/BulkLoader/BulkLoaderSet.php
+++ b/src/Schema/BulkLoader/BulkLoaderSet.php
@@ -49,7 +49,7 @@ public function __construct(array $loaders = [], ?Collection $initialCollection
* @return $this
* @throws SchemaBuilderException
*/
- public function applyConfig(array $config): self
+ public function applyConfig(array $config): BulkLoaderSet
{
$registry = Registry::inst();
foreach ($config as $loaderID => $loaderConfig) {
@@ -67,7 +67,7 @@ public function applyConfig(array $config): self
* @param AbstractBulkLoader $loader
* @return $this
*/
- public function addLoader(AbstractBulkLoader $loader): self
+ public function addLoader(AbstractBulkLoader $loader): BulkLoaderSet
{
$this->loaders[] = $loader;
@@ -101,7 +101,7 @@ public function process(): Collection
* @param array $loaders
* @return $this
*/
- public function setLoaders(array $loaders): self
+ public function setLoaders(array $loaders): BulkLoaderSet
{
foreach ($loaders as $loader) {
if (!$loader instanceof AbstractBulkLoader) {
diff --git a/src/Schema/BulkLoader/Collection.php b/src/Schema/BulkLoader/Collection.php
index 4e7d4daf..b9bafea5 100644
--- a/src/Schema/BulkLoader/Collection.php
+++ b/src/Schema/BulkLoader/Collection.php
@@ -31,7 +31,7 @@ public function __construct(array $manifest = [])
* @return $this
* @throws Exception
*/
- public function setManifest(array $manifest): self
+ public function setManifest(array $manifest): Collection
{
$this->manifest = $manifest;
@@ -42,7 +42,7 @@ public function setManifest(array $manifest): self
* @param string $class
* @return $this
*/
- public function removeClass(string $class): self
+ public function removeClass(string $class): Collection
{
unset($this->manifest[$class]);
@@ -53,7 +53,7 @@ public function removeClass(string $class): self
* @param string $path
* @return $this
*/
- public function removeFile(string $path): self
+ public function removeFile(string $path): Collection
{
$class = array_search($path, $this->manifest ?? []);
unset($this->manifest[$class]);
diff --git a/src/Schema/BulkLoader/ExtensionLoader.php b/src/Schema/BulkLoader/ExtensionLoader.php
index c3a38909..4f18ec49 100644
--- a/src/Schema/BulkLoader/ExtensionLoader.php
+++ b/src/Schema/BulkLoader/ExtensionLoader.php
@@ -15,7 +15,7 @@ class ExtensionLoader extends AbstractBulkLoader
public static function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return ExtensionLoader::IDENTIFIER;
}
public function collect(Collection $collection): Collection
diff --git a/src/Schema/BulkLoader/FilepathLoader.php b/src/Schema/BulkLoader/FilepathLoader.php
index d8d2849b..d43c9ecf 100644
--- a/src/Schema/BulkLoader/FilepathLoader.php
+++ b/src/Schema/BulkLoader/FilepathLoader.php
@@ -15,7 +15,7 @@ class FilepathLoader extends AbstractBulkLoader
public static function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return FilepathLoader::IDENTIFIER;
}
public function collect(Collection $collection): Collection
diff --git a/src/Schema/BulkLoader/InheritanceLoader.php b/src/Schema/BulkLoader/InheritanceLoader.php
index a4844063..70b97264 100644
--- a/src/Schema/BulkLoader/InheritanceLoader.php
+++ b/src/Schema/BulkLoader/InheritanceLoader.php
@@ -13,7 +13,7 @@ class InheritanceLoader extends AbstractBulkLoader
public static function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return InheritanceLoader::IDENTIFIER;
}
public function collect(Collection $collection): Collection
diff --git a/src/Schema/BulkLoader/NamespaceLoader.php b/src/Schema/BulkLoader/NamespaceLoader.php
index a4bc382b..0f77458f 100644
--- a/src/Schema/BulkLoader/NamespaceLoader.php
+++ b/src/Schema/BulkLoader/NamespaceLoader.php
@@ -11,7 +11,7 @@ class NamespaceLoader extends AbstractBulkLoader
public static function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return NamespaceLoader::IDENTIFIER;
}
public function collect(Collection $collection): Collection
diff --git a/src/Schema/BulkLoader/Registry.php b/src/Schema/BulkLoader/Registry.php
index 8415b6da..3c9699b6 100644
--- a/src/Schema/BulkLoader/Registry.php
+++ b/src/Schema/BulkLoader/Registry.php
@@ -18,16 +18,16 @@ class Registry
*/
public static function inst(): RegistryBackend
{
- if (self::$inst) {
- return self::$inst;
+ if (Registry::$inst) {
+ return Registry::$inst;
}
$subclasses = array_values(ClassInfo::subclassesFor(AbstractBulkLoader::class, false) ?? []);
$bulkLoaders = array_map(function ($className) {
return Injector::inst()->get($className);
}, $subclasses ?? []);
- self::$inst = RegistryBackend::create(...$bulkLoaders);
+ Registry::$inst = RegistryBackend::create(...$bulkLoaders);
- return self::$inst;
+ return Registry::$inst;
}
}
diff --git a/src/Schema/BulkLoader/RegistryBackend.php b/src/Schema/BulkLoader/RegistryBackend.php
index e1b701e0..eba3d3d7 100644
--- a/src/Schema/BulkLoader/RegistryBackend.php
+++ b/src/Schema/BulkLoader/RegistryBackend.php
@@ -31,7 +31,7 @@ public function __construct(...$instances)
* @param Identifiable[] $instances
* @return $this
*/
- public function setInstances(array $instances): self
+ public function setInstances(array $instances): RegistryBackend
{
foreach ($instances as $instance) {
if (!is_subclass_of($instance, Identifiable::class)) {
diff --git a/src/Schema/DataObject/CreateCreator.php b/src/Schema/DataObject/CreateCreator.php
index 9c6c559a..d3fa8802 100644
--- a/src/Schema/DataObject/CreateCreator.php
+++ b/src/Schema/DataObject/CreateCreator.php
@@ -60,7 +60,7 @@ public function createOperation(
if (!$mutationName) {
$mutationName = 'create' . ucfirst($typeName ?? '');
}
- $inputTypeName = self::inputTypeName($typeName);
+ $inputTypeName = CreateCreator::inputTypeName($typeName);
return ModelMutation::create($model, $mutationName)
->setType($typeName)
@@ -151,7 +151,7 @@ public function provideInputTypes(ModelType $modelType, array $config = []): arr
}
}
$inputType = InputType::create(
- self::inputTypeName($modelType->getName()),
+ CreateCreator::inputTypeName($modelType->getName()),
[
'fields' => $fieldMap
]
@@ -172,7 +172,7 @@ public function getFieldAccessor(): FieldAccessor
* @param FieldAccessor $fieldAccessor
* @return CreateCreator
*/
- public function setFieldAccessor(FieldAccessor $fieldAccessor): self
+ public function setFieldAccessor(FieldAccessor $fieldAccessor): CreateCreator
{
$this->fieldAccessor = $fieldAccessor;
return $this;
diff --git a/src/Schema/DataObject/DataObjectModel.php b/src/Schema/DataObject/DataObjectModel.php
index 2345c41a..d66ad48b 100644
--- a/src/Schema/DataObject/DataObjectModel.php
+++ b/src/Schema/DataObject/DataObjectModel.php
@@ -272,7 +272,7 @@ public function getFieldAccessor(): FieldAccessor
* @param FieldAccessor $fieldAccessor
* @return DataObjectModel
*/
- public function setFieldAccessor(FieldAccessor $fieldAccessor): self
+ public function setFieldAccessor(FieldAccessor $fieldAccessor): DataObjectModel
{
$this->fieldAccessor = $fieldAccessor;
return $this;
diff --git a/src/Schema/DataObject/FieldAccessor.php b/src/Schema/DataObject/FieldAccessor.php
index 1ec766cf..801d6629 100644
--- a/src/Schema/DataObject/FieldAccessor.php
+++ b/src/Schema/DataObject/FieldAccessor.php
@@ -237,14 +237,14 @@ private function getCaseInsensitiveMapping(
($includeRelations ? '_relations' : ''),
($includeInherirted ? '_inherited' : '')
]) ?? '');
- $cached = self::$__mappingCache[$cacheKey] ?? null;
+ $cached = FieldAccessor::$__mappingCache[$cacheKey] ?? null;
if (!$cached) {
$normalFields = $this->getAccessibleFields($dataObject, $includeRelations, $includeInherirted);
$lowercaseFields = array_map('strtolower', $normalFields ?? []);
$lookup = array_combine($lowercaseFields ?? [], $normalFields ?? []);
- self::$__mappingCache[$cacheKey] = $lookup;
+ FieldAccessor::$__mappingCache[$cacheKey] = $lookup;
}
- return self::$__mappingCache[$cacheKey];
+ return FieldAccessor::$__mappingCache[$cacheKey];
}
/**
diff --git a/src/Schema/DataObject/InheritanceChain.php b/src/Schema/DataObject/InheritanceChain.php
index b86160eb..2575836a 100644
--- a/src/Schema/DataObject/InheritanceChain.php
+++ b/src/Schema/DataObject/InheritanceChain.php
@@ -97,7 +97,7 @@ public function hasAncestors(): bool
* @param array $ancestors
* @return $this
*/
- public function hideAncestors(array $ancestors): self
+ public function hideAncestors(array $ancestors): InheritanceChain
{
$this->hiddenAncestors = $ancestors;
@@ -142,7 +142,7 @@ public function hasDescendants(): bool
* @param array $descendants
* @return $this
*/
- public function hideDescendants(array $descendants): self
+ public function hideDescendants(array $descendants): InheritanceChain
{
$this->hiddenDescendants = $descendants;
diff --git a/src/Schema/DataObject/InterfaceBuilder.php b/src/Schema/DataObject/InterfaceBuilder.php
index 42254957..6ff35c3d 100644
--- a/src/Schema/DataObject/InterfaceBuilder.php
+++ b/src/Schema/DataObject/InterfaceBuilder.php
@@ -61,7 +61,7 @@ public function createInterfaces(ModelType $modelType, array $interfaceStack = [
{
$interface = ModelInterfaceType::create(
$modelType,
- self::interfaceName($modelType->getName(), $this->getSchema()->getConfig())
+ InterfaceBuilder::interfaceName($modelType->getName(), $this->getSchema()->getConfig())
)
->setTypeResolver([AbstractTypeResolver::class, 'resolveType']);
@@ -116,7 +116,7 @@ public function applyBaseInterface(): InterfaceBuilder
if (empty($commonFields)) {
return $this;
}
- $baseInterface = InterfaceType::create(self::BASE_INTERFACE_NAME);
+ $baseInterface = InterfaceType::create(InterfaceBuilder::BASE_INTERFACE_NAME);
foreach ($commonFields as $fieldName => $fieldType) {
$baseInterface->addField(
FieldAccessor::singleton()->formatField($fieldName),
diff --git a/src/Schema/DataObject/Plugin/CanViewPermission.php b/src/Schema/DataObject/Plugin/CanViewPermission.php
index a8adfcf1..ce91e36d 100644
--- a/src/Schema/DataObject/Plugin/CanViewPermission.php
+++ b/src/Schema/DataObject/Plugin/CanViewPermission.php
@@ -27,7 +27,7 @@ class CanViewPermission extends AbstractCanViewPermission
*/
public function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return CanViewPermission::IDENTIFIER;
}
protected function getPermissionResolver(): callable
@@ -66,7 +66,7 @@ public static function permissionCheck($obj, array $args, array $context, Resolv
'Plugin "%s" cannot be applied to field "%s" because it does not resolve to an object, array,
or implementation of %s. You may need to implement a custom permission checker that extends %s.
Otherwise, try returning an instance of %s or another implementation of %s.',
- self::IDENTIFIER,
+ CanViewPermission::IDENTIFIER,
$info->fieldName,
Filterable::class,
AbstractCanViewPermission::class,
diff --git a/src/Schema/DataObject/Plugin/DBFieldArgs/DBFieldArgsPlugin.php b/src/Schema/DataObject/Plugin/DBFieldArgs/DBFieldArgsPlugin.php
index 07e3e9ca..5eaeb3bc 100644
--- a/src/Schema/DataObject/Plugin/DBFieldArgs/DBFieldArgsPlugin.php
+++ b/src/Schema/DataObject/Plugin/DBFieldArgs/DBFieldArgsPlugin.php
@@ -22,7 +22,7 @@ class DBFieldArgsPlugin implements SchemaUpdater, ModelTypePlugin
*/
public function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return DBFieldArgsPlugin::IDENTIFIER;
}
/**
diff --git a/src/Schema/DataObject/Plugin/DBFieldTypes.php b/src/Schema/DataObject/Plugin/DBFieldTypes.php
index 6f800bc0..c09b5c6a 100644
--- a/src/Schema/DataObject/Plugin/DBFieldTypes.php
+++ b/src/Schema/DataObject/Plugin/DBFieldTypes.php
@@ -26,7 +26,7 @@ class DBFieldTypes implements ModelTypePlugin
*/
public function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return DBFieldTypes::IDENTIFIER;
}
/**
diff --git a/src/Schema/DataObject/Plugin/FirstResult.php b/src/Schema/DataObject/Plugin/FirstResult.php
index f31db1ad..2a8f610f 100644
--- a/src/Schema/DataObject/Plugin/FirstResult.php
+++ b/src/Schema/DataObject/Plugin/FirstResult.php
@@ -18,7 +18,7 @@ class FirstResult implements ModelQueryPlugin
public function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return FirstResult::IDENTIFIER;
}
/**
diff --git a/src/Schema/DataObject/Plugin/Inheritance.php b/src/Schema/DataObject/Plugin/Inheritance.php
index 6175157d..4283b55d 100644
--- a/src/Schema/DataObject/Plugin/Inheritance.php
+++ b/src/Schema/DataObject/Plugin/Inheritance.php
@@ -26,7 +26,7 @@ class Inheritance implements PluginInterface, SchemaUpdater, ModelTypePlugin
public function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return Inheritance::IDENTIFIER;
}
/**
diff --git a/src/Schema/DataObject/Plugin/InheritedPlugins.php b/src/Schema/DataObject/Plugin/InheritedPlugins.php
index 657a1141..5fc9177a 100644
--- a/src/Schema/DataObject/Plugin/InheritedPlugins.php
+++ b/src/Schema/DataObject/Plugin/InheritedPlugins.php
@@ -22,7 +22,7 @@ class InheritedPlugins implements ModelTypePlugin
public function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return InheritedPlugins::IDENTIFIER;
}
/**
diff --git a/src/Schema/DataObject/Plugin/Paginator.php b/src/Schema/DataObject/Plugin/Paginator.php
index fa515d0e..c425ed60 100644
--- a/src/Schema/DataObject/Plugin/Paginator.php
+++ b/src/Schema/DataObject/Plugin/Paginator.php
@@ -23,7 +23,7 @@ class Paginator extends PaginationPlugin
public function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return Paginator::IDENTIFIER;
}
public static function paginate(array $context): Closure
diff --git a/src/Schema/DataObject/Plugin/QueryFilter/FieldFilterRegistry.php b/src/Schema/DataObject/Plugin/QueryFilter/FieldFilterRegistry.php
index 7c3aa049..3670505a 100644
--- a/src/Schema/DataObject/Plugin/QueryFilter/FieldFilterRegistry.php
+++ b/src/Schema/DataObject/Plugin/QueryFilter/FieldFilterRegistry.php
@@ -28,7 +28,7 @@ public function __construct(...$filters)
* @return $this
* @throws InvalidArgumentException
*/
- public function addFilter(FieldFilterInterface $filter, ?string $identifier = null): self
+ public function addFilter(FieldFilterInterface $filter, ?string $identifier = null): FieldFilterRegistry
{
$id = $identifier ?: $filter->getIdentifier();
if (!preg_match('/^[A-Za-z0-9_]+$/', $id ?? '')) {
diff --git a/src/Schema/DataObject/Plugin/QueryFilter/FilterRegistryInterface.php b/src/Schema/DataObject/Plugin/QueryFilter/FilterRegistryInterface.php
index 077a3a8f..b668a00f 100644
--- a/src/Schema/DataObject/Plugin/QueryFilter/FilterRegistryInterface.php
+++ b/src/Schema/DataObject/Plugin/QueryFilter/FilterRegistryInterface.php
@@ -16,5 +16,5 @@ public function getFilterByIdentifier(string $identifier): ?FieldFilterInterface
*/
public function getAll();
- public function addFilter(FieldFilterInterface $filter, ?string $identifier = null): self;
+ public function addFilter(FieldFilterInterface $filter, ?string $identifier = null): FilterRegistryInterface;
}
diff --git a/src/Schema/DataObject/Plugin/QueryFilter/QueryFilter.php b/src/Schema/DataObject/Plugin/QueryFilter/QueryFilter.php
index 8271473e..d7a4fc84 100644
--- a/src/Schema/DataObject/Plugin/QueryFilter/QueryFilter.php
+++ b/src/Schema/DataObject/Plugin/QueryFilter/QueryFilter.php
@@ -33,7 +33,7 @@ class QueryFilter extends AbstractQueryFilterPlugin
*/
public function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return QueryFilter::IDENTIFIER;
}
protected function getResolver(array $config): callable
diff --git a/src/Schema/DataObject/Plugin/QuerySort.php b/src/Schema/DataObject/Plugin/QuerySort.php
index 14f1adee..8b953021 100644
--- a/src/Schema/DataObject/Plugin/QuerySort.php
+++ b/src/Schema/DataObject/Plugin/QuerySort.php
@@ -32,7 +32,7 @@ class QuerySort extends AbstractQuerySortPlugin
public function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return QuerySort::IDENTIFIER;
}
protected function getResolver(array $config): callable
@@ -108,7 +108,7 @@ public static function sort(array $context): closure
return $list;
}
- $sortArgs = self::getSortArgs($info, $args, $fieldName);
+ $sortArgs = QuerySort::getSortArgs($info, $args, $fieldName);
$paths = NestedInputBuilder::buildPathsFromArgs($sortArgs);
if (empty($paths)) {
return $list;
diff --git a/src/Schema/DataObject/Plugin/ScalarDBField.php b/src/Schema/DataObject/Plugin/ScalarDBField.php
index 34c3b8dd..7ba711db 100644
--- a/src/Schema/DataObject/Plugin/ScalarDBField.php
+++ b/src/Schema/DataObject/Plugin/ScalarDBField.php
@@ -20,7 +20,7 @@ class ScalarDBField implements ModelTypePlugin
public function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return ScalarDBField::IDENTIFIER;
}
/**
diff --git a/src/Schema/DataObject/UpdateCreator.php b/src/Schema/DataObject/UpdateCreator.php
index 68549ca7..9d12a365 100644
--- a/src/Schema/DataObject/UpdateCreator.php
+++ b/src/Schema/DataObject/UpdateCreator.php
@@ -62,7 +62,7 @@ public function createOperation(
if (!$mutationName) {
$mutationName = 'update' . ucfirst($typeName ?? '');
}
- $inputTypeName = self::inputTypeName($typeName);
+ $inputTypeName = UpdateCreator::inputTypeName($typeName);
return ModelMutation::create($model, $mutationName)
->setType($typeName)
@@ -169,7 +169,7 @@ public function provideInputTypes(ModelType $modelType, array $config = []): arr
}
}
$inputType = InputType::create(
- self::inputTypeName($modelType->getName()),
+ UpdateCreator::inputTypeName($modelType->getName()),
[
'fields' => $fieldMap
]
diff --git a/src/Schema/Field/Argument.php b/src/Schema/Field/Argument.php
index f85fcf32..5e224fa1 100644
--- a/src/Schema/Field/Argument.php
+++ b/src/Schema/Field/Argument.php
@@ -91,7 +91,7 @@ public function applyConfig(array $config)
* @return $this
* @throws SchemaBuilderException
*/
- public function setType($type): self
+ public function setType($type): Argument
{
Schema::invariant(
is_string($type) || $type instanceof EncodedType,
@@ -127,7 +127,7 @@ public function getName(): ?string
* @param string $name
* @return Argument
*/
- public function setName(string $name): self
+ public function setName(string $name): Argument
{
$this->name = $name;
return $this;
@@ -159,7 +159,7 @@ public function getDefaultValue()
* @param bool|int|string|null $defaultValue
* @return Argument
*/
- public function setDefaultValue($defaultValue): self
+ public function setDefaultValue($defaultValue): Argument
{
$this->defaultValue = $defaultValue;
return $this;
@@ -177,7 +177,7 @@ public function getDescription(): ?string
* @param string|null $description
* @return Argument
*/
- public function setDescription(?string $description): self
+ public function setDescription(?string $description): Argument
{
$this->description = $description;
return $this;
diff --git a/src/Schema/Field/Field.php b/src/Schema/Field/Field.php
index c005ac17..7c75067f 100644
--- a/src/Schema/Field/Field.php
+++ b/src/Schema/Field/Field.php
@@ -206,7 +206,7 @@ public function applyConfig(array $config)
* @param callable|null $callback
* @return Field
*/
- public function addArg(string $argName, $config, ?callable $callback = null): self
+ public function addArg(string $argName, $config, ?callable $callback = null): Field
{
$argObj = $config instanceof Argument ? $config : Argument::create($argName, $config);
$this->args[$argObj->getName()] = $argObj;
@@ -221,7 +221,7 @@ public function addArg(string $argName, $config, ?callable $callback = null): se
* @return $this
* @throws SchemaBuilderException
*/
- public function setArgs(array $args): self
+ public function setArgs(array $args): Field
{
Schema::assertValidConfig($args);
foreach ($args as $argName => $config) {
@@ -238,7 +238,7 @@ public function setArgs(array $args): self
* @param Field $field
* @return Field
*/
- public function mergeWith(Field $field): self
+ public function mergeWith(Field $field): Field
{
foreach ($field->getArgs() as $arg) {
$this->args[$arg->getName()] = clone $arg;
@@ -282,7 +282,7 @@ public function validate(): void
* @return Field
* @throws SchemaBuilderException
*/
- public function setType($type, $required = false): self
+ public function setType($type, $required = false): Field
{
Schema::invariant(
!is_array($type),
@@ -306,7 +306,7 @@ public function setType($type, $required = false): self
* @param string $modelTypeDef
* @return $this
*/
- public function setTypeAsModel(string $modelTypeDef): self
+ public function setTypeAsModel(string $modelTypeDef): Field
{
$this->typeAsModel = $modelTypeDef;
@@ -333,7 +333,7 @@ public function getName(): ?string
* @param string $name
* @return Field
*/
- public function setName(string $name): self
+ public function setName(string $name): Field
{
$this->name = $name;
return $this;
@@ -387,7 +387,7 @@ public function getNamedType(): string
* @return $this
* @throws SchemaBuilderException
*/
- public function setNamedType(string $name): self
+ public function setNamedType(string $name): Field
{
$currentType = $this->getType();
$newType = preg_replace('/[A-Za-z_0-9]+/', $name ?? '', $currentType ?? '');
@@ -431,7 +431,7 @@ public function getDescription(): ?string
* @param string|null $description
* @return Field
*/
- public function setDescription(?string $description): self
+ public function setDescription(?string $description): Field
{
$this->description = $description;
return $this;
@@ -449,7 +449,7 @@ public function getResolver(): ?ResolverReference
* @param array|string|ResolverReference|null $resolver
* @return Field
*/
- public function setResolver($resolver): self
+ public function setResolver($resolver): Field
{
if ($resolver) {
$this->resolver = $resolver instanceof ResolverReference
@@ -474,7 +474,7 @@ public function getResolverContext(): ?array
* @param array|null $resolverContext
* @return Field
*/
- public function setResolverContext(?array $resolverContext): self
+ public function setResolverContext(?array $resolverContext): Field
{
$this->resolverContext = $resolverContext;
return $this;
@@ -485,7 +485,7 @@ public function setResolverContext(?array $resolverContext): self
* @param $value
* @return Field
*/
- public function addResolverContext(string $key, $value): self
+ public function addResolverContext(string $key, $value): Field
{
$this->resolverContext[$key] = $value;
@@ -497,7 +497,7 @@ public function addResolverContext(string $key, $value): self
* @param array|null $context
* @return $this
*/
- public function addResolverMiddleware($resolver, ?array $context = null): self
+ public function addResolverMiddleware($resolver, ?array $context = null): Field
{
return $this->decorateResolver(EncodedResolver::MIDDLEWARE, $resolver, $context);
}
@@ -507,7 +507,7 @@ public function addResolverMiddleware($resolver, ?array $context = null): self
* @param array|null $context
* @return $this
*/
- public function addResolverAfterware($resolver, ?array $context = null): self
+ public function addResolverAfterware($resolver, ?array $context = null): Field
{
return $this->decorateResolver(EncodedResolver::AFTERWARE, $resolver, $context);
}
@@ -575,7 +575,7 @@ public function validatePlugin(string $pluginName, $plugin): void
* @param array|null $context
* @return Field
*/
- private function decorateResolver(string $position, $resolver, ?array $context = null): self
+ private function decorateResolver(string $position, $resolver, ?array $context = null): Field
{
if ($resolver) {
$ref = $resolver instanceof ResolverReference
diff --git a/src/Schema/Field/ModelField.php b/src/Schema/Field/ModelField.php
index 9ff7ebc7..76b40a07 100644
--- a/src/Schema/Field/ModelField.php
+++ b/src/Schema/Field/ModelField.php
@@ -139,7 +139,7 @@ public function getProperty(): ?string
* @param string|null $property
* @return ModelField
*/
- public function setProperty(?string $property): self
+ public function setProperty(?string $property): ModelField
{
$this->property = $property;
diff --git a/src/Schema/Logger.php b/src/Schema/Logger.php
index 1b29bffb..cfb49a6d 100644
--- a/src/Schema/Logger.php
+++ b/src/Schema/Logger.php
@@ -31,9 +31,9 @@ class Logger implements LoggerInterface
const ALERT = 550;
const EMERGENCY = 600;
- private int $level = self::INFO;
+ private int $level = Logger::INFO;
- public function setVerbosity(int $level): self
+ public function setVerbosity(int $level): Logger
{
$this->level = $level;
@@ -42,24 +42,24 @@ public function setVerbosity(int $level): self
public function alert(Stringable|string $message, array $context = []):void
{
- if ($this->level > self::ALERT) {
+ if ($this->level > Logger::ALERT) {
return;
}
- $this->output($message, strtoupper(__FUNCTION__), self::RED);
+ $this->output($message, strtoupper(__FUNCTION__), Logger::RED);
}
public function critical(Stringable|string $message, array $context = []): void
{
- if ($this->level > self::CRITICAL) {
+ if ($this->level > Logger::CRITICAL) {
return;
}
- $this->output($message, strtoupper(__FUNCTION__), self::RED);
+ $this->output($message, strtoupper(__FUNCTION__), Logger::RED);
}
public function debug(Stringable|string $message, array $context = []): void
{
- if ($this->level > self::DEBUG) {
+ if ($this->level > Logger::DEBUG) {
return;
}
@@ -68,29 +68,29 @@ public function debug(Stringable|string $message, array $context = []): void
public function emergency(Stringable|string $message, array $context = []): void
{
- if ($this->level > self::EMERGENCY) {
+ if ($this->level > Logger::EMERGENCY) {
return;
}
- $this->output($message, strtoupper(__FUNCTION__), self::RED);
+ $this->output($message, strtoupper(__FUNCTION__), Logger::RED);
}
public function error(Stringable|string $message, array $context = []): void
{
- if ($this->level > self::ERROR) {
+ if ($this->level > Logger::ERROR) {
return;
}
- $this->output($message, strtoupper(__FUNCTION__), self::RED);
+ $this->output($message, strtoupper(__FUNCTION__), Logger::RED);
}
public function info(Stringable|string $message, array $context = []): void
{
- if ($this->level > self::INFO) {
+ if ($this->level > Logger::INFO) {
return;
}
- $this->output($message, strtoupper(__FUNCTION__), self::CYAN);
+ $this->output($message, strtoupper(__FUNCTION__), Logger::CYAN);
}
public function log($level, Stringable|string $message, array $context = []): void
@@ -100,20 +100,20 @@ public function log($level, Stringable|string $message, array $context = []): vo
public function notice(Stringable|string $message, array $context = []): void
{
- if ($this->level > self::NOTICE) {
+ if ($this->level > Logger::NOTICE) {
return;
}
- $this->output($message, strtoupper(__FUNCTION__), self::YELLOW);
+ $this->output($message, strtoupper(__FUNCTION__), Logger::YELLOW);
}
public function warning(Stringable|string $message, array $context = []): void
{
- if ($this->level > self::WARNING) {
+ if ($this->level > Logger::WARNING) {
return;
}
- $this->output($message, strtoupper(__FUNCTION__), self::YELLOW);
+ $this->output($message, strtoupper(__FUNCTION__), Logger::YELLOW);
}
public function output(string $msg, ?string $prefix = null, ?string $colour = null): void
@@ -123,7 +123,7 @@ public function output(string $msg, ?string $prefix = null, ?string $colour = nu
'%s%s%s%s',
$colour && $cli ? $colour :'',
$prefix ? '[' . $prefix . ']: ' : '',
- $colour && $cli ? self::RESET : '',
+ $colour && $cli ? Logger::RESET : '',
$msg
);
if ($cli) {
diff --git a/src/Schema/Plugin/PaginationPlugin.php b/src/Schema/Plugin/PaginationPlugin.php
index 98a2b345..2390eb60 100644
--- a/src/Schema/Plugin/PaginationPlugin.php
+++ b/src/Schema/Plugin/PaginationPlugin.php
@@ -43,7 +43,7 @@ class PaginationPlugin implements FieldPlugin, SchemaUpdater
public function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return PaginationPlugin::IDENTIFIER;
}
/**
diff --git a/src/Schema/Plugin/SortPlugin.php b/src/Schema/Plugin/SortPlugin.php
index 399bfcb1..06c6ffa9 100644
--- a/src/Schema/Plugin/SortPlugin.php
+++ b/src/Schema/Plugin/SortPlugin.php
@@ -41,7 +41,7 @@ class SortPlugin implements FieldPlugin, SchemaUpdater
public function getIdentifier(): string
{
- return self::IDENTIFIER;
+ return SortPlugin::IDENTIFIER;
}
public static function updateSchema(Schema $schema): void
@@ -60,7 +60,7 @@ public function apply(Field $field, Schema $schema, array $config = []): void
Schema::invariant(
!empty($fields),
'%s requires a "fields" parameter to be passed to its config that maps field name to type name',
- self::getIdentifier()
+ SortPlugin::getIdentifier()
);
$sortFieldName = $this->config()->get('field_name');
$input = InputType::create($name);
@@ -98,7 +98,7 @@ public static function sort(array $context): Closure
return $list;
}
- $sortArgs = self::getSortArgs($info, $args, $fieldName);
+ $sortArgs = SortPlugin::getSortArgs($info, $args, $fieldName);
$list = $list->sort($sortArgs);
return $list;
diff --git a/src/Schema/Resolver/EncodedResolver.php b/src/Schema/Resolver/EncodedResolver.php
index a0db838d..8c106235 100644
--- a/src/Schema/Resolver/EncodedResolver.php
+++ b/src/Schema/Resolver/EncodedResolver.php
@@ -89,7 +89,7 @@ public function getContext(): ?array
return $this->context;
}
- public function setContext(?array $context): self
+ public function setContext(?array $context): EncodedResolver
{
$this->context = $context;
return $this;
@@ -106,7 +106,7 @@ public function getRef(): ResolverReference
* @return EncodedResolver
* @throws SchemaBuilderException
*/
- public function addContext(string $key, $val): self
+ public function addContext(string $key, $val): EncodedResolver
{
Schema::invariant(
is_scalar($val) || is_array($val),
@@ -119,7 +119,7 @@ public function addContext(string $key, $val): self
return $this;
}
- public function addMiddleware(EncodedResolver $ref): self
+ public function addMiddleware(EncodedResolver $ref): EncodedResolver
{
$this->middleware[] = $ref;
@@ -131,7 +131,7 @@ public function getResolverMiddlewares(): array
return $this->middleware;
}
- public function addAfterware(EncodedResolver $ref): self
+ public function addAfterware(EncodedResolver $ref): EncodedResolver
{
$this->afterware[] = $ref;
diff --git a/src/Schema/Schema.php b/src/Schema/Schema.php
index 1cb4b968..f4d778ad 100644
--- a/src/Schema/Schema.php
+++ b/src/Schema/Schema.php
@@ -70,7 +70,7 @@ class Schema implements ConfigurationApplier
* @config
* @var callable
*/
- private static $pluraliser = [self::class, 'pluraliser'];
+ private static $pluraliser = [Schema::class, 'pluraliser'];
private static bool $verbose = false;
@@ -119,8 +119,8 @@ class Schema implements ConfigurationApplier
public function __construct(string $schemaKey, ?SchemaConfig $schemaConfig = null)
{
$this->schemaKey = $schemaKey;
- $this->queryType = Type::create(self::QUERY_TYPE);
- $this->mutationType = Type::create(self::MUTATION_TYPE);
+ $this->queryType = Type::create(Schema::QUERY_TYPE);
+ $this->mutationType = Type::create(Schema::MUTATION_TYPE);
$this->schemaConfig = $schemaConfig ?: SchemaConfig::create();
$this->state = Configuration::create();
@@ -142,31 +142,31 @@ public function applyConfig(array $schemaConfig): Schema
}
$validConfigKeys = [
- self::TYPES,
- self::QUERIES,
- self::MUTATIONS,
- self::INTERFACES,
- self::UNIONS,
- self::BULK_LOAD,
- self::MODELS,
- self::ENUMS,
- self::SCALARS,
- self::SCHEMA_CONFIG,
+ Schema::TYPES,
+ Schema::QUERIES,
+ Schema::MUTATIONS,
+ Schema::INTERFACES,
+ Schema::UNIONS,
+ Schema::BULK_LOAD,
+ Schema::MODELS,
+ Schema::ENUMS,
+ Schema::SCALARS,
+ Schema::SCHEMA_CONFIG,
'execute',
- self::SOURCE,
+ Schema::SOURCE,
];
static::assertValidConfig($schemaConfig, $validConfigKeys);
- $types = $schemaConfig[self::TYPES] ?? [];
- $queries = $schemaConfig[self::QUERIES] ?? [];
- $mutations = $schemaConfig[self::MUTATIONS] ?? [];
- $interfaces = $schemaConfig[self::INTERFACES] ?? [];
- $unions = $schemaConfig[self::UNIONS] ?? [];
- $bulkLoad = $schemaConfig[self::BULK_LOAD] ?? [];
- $models = $schemaConfig[self::MODELS] ?? [];
- $enums = $schemaConfig[self::ENUMS] ?? [];
- $scalars = $schemaConfig[self::SCALARS] ?? [];
- $config = $schemaConfig[self::SCHEMA_CONFIG] ?? [];
+ $types = $schemaConfig[Schema::TYPES] ?? [];
+ $queries = $schemaConfig[Schema::QUERIES] ?? [];
+ $mutations = $schemaConfig[Schema::MUTATIONS] ?? [];
+ $interfaces = $schemaConfig[Schema::INTERFACES] ?? [];
+ $unions = $schemaConfig[Schema::UNIONS] ?? [];
+ $bulkLoad = $schemaConfig[Schema::BULK_LOAD] ?? [];
+ $models = $schemaConfig[Schema::MODELS] ?? [];
+ $enums = $schemaConfig[Schema::ENUMS] ?? [];
+ $scalars = $schemaConfig[Schema::SCALARS] ?? [];
+ $config = $schemaConfig[Schema::SCHEMA_CONFIG] ?? [];
$this->getConfig()->apply($config);
@@ -546,9 +546,9 @@ private function process(): void
$this->addType($modelType);
}
- $this->types[self::QUERY_TYPE] = $this->queryType;
+ $this->types[Schema::QUERY_TYPE] = $this->queryType;
if ($this->mutationType->exists()) {
- $this->types[self::MUTATION_TYPE] = $this->mutationType;
+ $this->types[Schema::MUTATION_TYPE] = $this->mutationType;
}
// Resolver discovery
@@ -565,11 +565,11 @@ public function createStoreableSchema(): StorableSchema
$this->process();
$schema = StorableSchema::create(
[
- self::TYPES => $this->getTypes(),
- self::ENUMS => $this->getEnums(),
- self::INTERFACES => $this->getInterfaces(),
- self::UNIONS => $this->getUnions(),
- self::SCALARS => $this->getScalars()
+ Schema::TYPES => $this->getTypes(),
+ Schema::ENUMS => $this->getEnums(),
+ Schema::INTERFACES => $this->getInterfaces(),
+ Schema::UNIONS => $this->getUnions(),
+ Schema::SCALARS => $this->getScalars()
],
$this->getConfig()
);
@@ -597,14 +597,14 @@ public function getState(): Configuration
return $this->state;
}
- public function addQuery(Field $query): self
+ public function addQuery(Field $query): Schema
{
$this->queryType->addField($query->getName(), $query);
return $this;
}
- public function addMutation(Field $mutation): self
+ public function addMutation(Field $mutation): Schema
{
$this->mutationType->addField($mutation->getName(), $mutation);
@@ -614,7 +614,7 @@ public function addMutation(Field $mutation): self
/**
* @throws SchemaBuilderException
*/
- public function addType(Type $type, ?callable $callback = null): self
+ public function addType(Type $type, ?callable $callback = null): Schema
{
$existing = $this->types[$type->getName()] ?? null;
$typeObj = $existing ? $existing->mergeWith($type) : $type;
@@ -625,7 +625,7 @@ public function addType(Type $type, ?callable $callback = null): self
return $this;
}
- public function removeType(string $type): self
+ public function removeType(string $type): Schema
{
unset($this->types[$type]);
@@ -710,13 +710,13 @@ public function getTypeOrModel(string $name): ?Type
return $this->getType($name) ?: $this->getModel($name);
}
- public function addEnum(Enum $enum): self
+ public function addEnum(Enum $enum): Schema
{
$this->enums[$enum->getName()] = $enum;
return $this;
}
- public function removeEnum(string $name): self
+ public function removeEnum(string $name): Schema
{
unset($this->enums[$name]);
return $this;
@@ -745,13 +745,13 @@ public function getScalar(string $name): ?Scalar
return $this->scalars[$name] ?? null;
}
- public function addScalar(Scalar $scalar): self
+ public function addScalar(Scalar $scalar): Schema
{
$this->scalars[$scalar->getName()] = $scalar;
return $this;
}
- public function removeScalar(string $name): self
+ public function removeScalar(string $name): Schema
{
unset($this->scalars[$name]);
return $this;
@@ -799,7 +799,7 @@ public function getModel(string $name): ?ModelType
/**
* @throws SchemaBuilderException
*/
- public function addModelbyClassName(string $class, ?callable $callback = null): self
+ public function addModelbyClassName(string $class, ?callable $callback = null): Schema
{
$model = $this->createModel($class);
Schema::invariant(
@@ -816,7 +816,7 @@ public function addModelbyClassName(string $class, ?callable $callback = null):
return $this->addModel($model);
}
- public function removeModelByClassName(string $class): self
+ public function removeModelByClassName(string $class): Schema
{
if ($model = $this->getModelByClassName($class)) {
$this->removeModel($model->getName());
@@ -825,7 +825,7 @@ public function removeModelByClassName(string $class): self
return $this;
}
- public function removeModel(string $name): self
+ public function removeModel(string $name): Schema
{
unset($this->models[$name]);
return $this;
@@ -847,7 +847,7 @@ public function getModelByClassName(string $class): ?ModelType
* This may include types that do not appear in any queries.
* @throws SchemaBuilderException
*/
- public function eagerLoad(string $name): self
+ public function eagerLoad(string $name): Schema
{
$this->getConfig()->set("eagerLoadTypes.$name", $name);
return $this;
@@ -856,7 +856,7 @@ public function eagerLoad(string $name): self
/**
* @throws SchemaBuilderException
*/
- public function lazyLoad(string $name): self
+ public function lazyLoad(string $name): Schema
{
$this->getConfig()->unset("eagerLoadTypes.$name");
return $this;
@@ -902,7 +902,7 @@ public function findOrMakeModel(string $class): ModelType
/**
* @throws SchemaBuilderException
*/
- public function addInterface(InterfaceType $type, ?callable $callback = null): self
+ public function addInterface(InterfaceType $type, ?callable $callback = null): Schema
{
$existing = $this->interfaces[$type->getName()] ?? null;
$typeObj = $existing ? $existing->mergeWith($type) : $type;
@@ -913,7 +913,7 @@ public function addInterface(InterfaceType $type, ?callable $callback = null): s
return $this;
}
- public function removeInterface(string $name): self
+ public function removeInterface(string $name): Schema
{
unset($this->interfaces[$name]);
@@ -941,7 +941,7 @@ public function getImplementorsOf(string $interfaceName): array
});
}
- public function addUnion(UnionType $union, ?callable $callback = null): self
+ public function addUnion(UnionType $union, ?callable $callback = null): Schema
{
$existing = $this->unions[$union->getName()] ?? null;
$typeObj = $existing ? $existing->mergeWith($union) : $union;
@@ -952,7 +952,7 @@ public function addUnion(UnionType $union, ?callable $callback = null): self
return $this;
}
- public function removeUnion(string $name): self
+ public function removeUnion(string $name): Schema
{
unset($this->unions[$name]);
return $this;
@@ -971,7 +971,7 @@ public function getUnions(): array
/**
* @throws SchemaBuilderException
*/
- public function applyBulkLoader(AbstractBulkLoader $loader, array $modelConfig): self
+ public function applyBulkLoader(AbstractBulkLoader $loader, array $modelConfig): Schema
{
$set = $this->getDefaultBulkLoaderSet();
$set->addLoader($loader);
@@ -982,7 +982,7 @@ public function applyBulkLoader(AbstractBulkLoader $loader, array $modelConfig):
/**
* @throws SchemaBuilderException
*/
- public function applyBulkLoaders(BulkLoaderSet $loaders, array $modelConfig): self
+ public function applyBulkLoaders(BulkLoaderSet $loaders, array $modelConfig): Schema
{
$collection = $loaders->process();
$count = 0;
diff --git a/src/Schema/SchemaBuilder.php b/src/Schema/SchemaBuilder.php
index e090a598..cec03da8 100644
--- a/src/Schema/SchemaBuilder.php
+++ b/src/Schema/SchemaBuilder.php
@@ -142,7 +142,7 @@ public function boot(string $key): Schema
if ($data === false) {
continue;
}
- $sourcedConfig = self::getSchemaConfigFromSource($key, $data);
+ $sourcedConfig = SchemaBuilder::getSchemaConfigFromSource($key, $data);
$mergedSchema = Priority::mergeArray($sourcedConfig, $mergedSchema);
}
@@ -158,7 +158,7 @@ public function boot(string $key): Schema
if ($data === false) {
continue;
}
- $sourcedConfig = self::getSchemaConfigFromSource($key, $data);
+ $sourcedConfig = SchemaBuilder::getSchemaConfigFromSource($key, $data);
$mergedSchema = Priority::mergeArray($sourcedConfig, $mergedSchema);
}
diff --git a/src/Schema/SchemaConfig.php b/src/Schema/SchemaConfig.php
index 641ec9bf..636d1b0f 100644
--- a/src/Schema/SchemaConfig.php
+++ b/src/Schema/SchemaConfig.php
@@ -116,7 +116,7 @@ public static function pluralise(string $typeName): string
* @return $this
* @throws SchemaBuilderException
*/
- public function setTypeMapping(array $typeMapping): self
+ public function setTypeMapping(array $typeMapping): SchemaConfig
{
return $this->set('typeMapping', $typeMapping);
}
@@ -134,7 +134,7 @@ public function getTypeMapping(): array
* @return $this
* @throws SchemaBuilderException
*/
- public function setFieldMapping(array $fields): self
+ public function setFieldMapping(array $fields): SchemaConfig
{
return $this->set('fieldMapping', $fields);
}
diff --git a/src/Schema/Services/NestedInputBuilder.php b/src/Schema/Services/NestedInputBuilder.php
index b9241257..44f17af1 100644
--- a/src/Schema/Services/NestedInputBuilder.php
+++ b/src/Schema/Services/NestedInputBuilder.php
@@ -129,7 +129,7 @@ protected function buildAllFieldsConfig(Type $type): array
]);
// Prevent stupid recursion in self-referential relationships, e.g. Parent
if ($namedType === $type->getName()) {
- $map[$fieldObj->getName()] = self::SELF_REFERENTIAL;
+ $map[$fieldObj->getName()] = NestedInputBuilder::SELF_REFERENTIAL;
} elseif ($seen) {
continue;
} else {
@@ -213,7 +213,7 @@ protected function addInputTypesToSchema(
$isScalar = (bool) Schema::isInternalType($fieldType) || $this->schema->getEnum($fieldType);
- if ($data === self::SELF_REFERENTIAL) {
+ if ($data === NestedInputBuilder::SELF_REFERENTIAL) {
$inputType->addField($fieldName, $inputType->getName());
} elseif (!is_array($data) && !$nestedType && $isScalar) {
// Regular field, e.g. scalar
@@ -269,7 +269,7 @@ public function getRootType(): ?InputType
/**
* @throws SchemaBuilderException
*/
- public function setResolveConfig(array $config): self
+ public function setResolveConfig(array $config): NestedInputBuilder
{
foreach ($config as $fieldName => $data) {
Schema::invariant(
diff --git a/src/Schema/Services/SchemaTranscriber.php b/src/Schema/Services/SchemaTranscriber.php
index 3c694806..16632152 100644
--- a/src/Schema/Services/SchemaTranscriber.php
+++ b/src/Schema/Services/SchemaTranscriber.php
@@ -79,7 +79,7 @@ public function getRootDir(): string
return $this->rootDir;
}
- public function setRootDir(string $rootDir): self
+ public function setRootDir(string $rootDir): SchemaTranscriber
{
$this->rootDir = $rootDir;
return $this;
@@ -126,7 +126,7 @@ private function generateCacheFilename(): string
{
return Path::join(
$this->rootDir,
- $this->name . '.' . self::CACHE_FILENAME
+ $this->name . '.' . SchemaTranscriber::CACHE_FILENAME
);
}
}
diff --git a/src/Schema/Storage/AbstractTypeRegistry.php b/src/Schema/Storage/AbstractTypeRegistry.php
index d12dbb4a..a34e3c1a 100644
--- a/src/Schema/Storage/AbstractTypeRegistry.php
+++ b/src/Schema/Storage/AbstractTypeRegistry.php
@@ -47,7 +47,7 @@ public static function get(string $typename)
try {
return static::fromCache($typename);
} catch (Exception $e) {
- if (!preg_match('/(Missing|Unknown) graphql/', $e->getMessage()) || !self::canRebuildOnMissing()) {
+ if (!preg_match('/(Missing|Unknown) graphql/', $e->getMessage()) || !AbstractTypeRegistry::canRebuildOnMissing()) {
throw $e;
}
// Try to rebuild the whole schema as fallback.
@@ -59,7 +59,7 @@ public static function get(string $typename)
$schema = $builder->boot($key);
try {
$builder->build($schema, true);
- $path = self::getRebuildOnMissingPath();
+ $path = AbstractTypeRegistry::getRebuildOnMissingPath();
file_put_contents($path, time());
} catch (EmptySchemaException $e) {
// noop
@@ -77,16 +77,16 @@ private static function canRebuildOnMissing(): bool
) {
return false;
}
- if (!self::config()->get('rebuild_on_missing_schema_file')) {
+ if (!static::config()->get('rebuild_on_missing_schema_file')) {
return false;
}
- $path = self::getRebuildOnMissingPath();
+ $path = static::getRebuildOnMissingPath();
if (!(is_writable(dirname($path)))) {
return false;
}
if (file_exists($path)) {
$lastRebuildTimestamp = (int) trim(file_get_contents($path));
- $minInterval = self::config()->get('rebuild_on_missing_schema_file_minimum_interval');
+ $minInterval = static::config()->get('rebuild_on_missing_schema_file_minimum_interval');
if ((time() - $lastRebuildTimestamp) < $minInterval) {
return false;
}
@@ -96,7 +96,7 @@ private static function canRebuildOnMissing(): bool
private static function getRebuildOnMissingPath(): string
{
- return static::getSourceDirectory() . DIRECTORY_SEPARATOR . self::getRebuildOnMissingFilename();
+ return static::getSourceDirectory() . DIRECTORY_SEPARATOR . AbstractTypeRegistry::getRebuildOnMissingFilename();
}
private static function getRebuildOnMissingFilename(): string
diff --git a/src/Schema/Storage/CodeGenerationStore.php b/src/Schema/Storage/CodeGenerationStore.php
index c2c27496..7cdae02c 100644
--- a/src/Schema/Storage/CodeGenerationStore.php
+++ b/src/Schema/Storage/CodeGenerationStore.php
@@ -134,7 +134,7 @@ public function persistSchema(StorableSchema $schema): void
$templateDir = static::getTemplateDir();
$obfuscator = $this->getObfuscator();
$globals = [
- 'typeClassName' => self::TYPE_CLASS_NAME,
+ 'typeClassName' => CodeGenerationStore::TYPE_CLASS_NAME,
'namespace' => $this->getNamespace(),
'obfuscator' => $obfuscator,
];
@@ -288,7 +288,7 @@ public function getSchema(bool $useCache = true): GraphQLSchema
}
require_once($this->getSchemaFilename());
- $registryClass = $this->getClassName(self::TYPE_CLASS_NAME);
+ $registryClass = $this->getClassName(CodeGenerationStore::TYPE_CLASS_NAME);
$hasMutations = method_exists($registryClass, Schema::MUTATION_TYPE ?? '');
$schemaConfig = new GraphqLSchemaConfig();
$callback = call_user_func([$registryClass, Schema::QUERY_TYPE]);
@@ -375,7 +375,7 @@ public function setObfuscator(NameObfuscator $obfuscator): CodeGenerationStore
return $this;
}
- public function setVerbose(bool $bool): self
+ public function setVerbose(bool $bool): CodeGenerationStore
{
$this->verbose = $bool;
diff --git a/src/Schema/Type/Enum.php b/src/Schema/Type/Enum.php
index ad1b1138..600acc98 100644
--- a/src/Schema/Type/Enum.php
+++ b/src/Schema/Type/Enum.php
@@ -84,7 +84,7 @@ public function getValues(): array
return $this->values;
}
- public function setValues(array $values): self
+ public function setValues(array $values): Enum
{
$this->values = $values;
return $this;
@@ -93,7 +93,7 @@ public function setValues(array $values): self
/**
* @param mixed $val
*/
- public function addValue(string $key, $val = null): self
+ public function addValue(string $key, $val = null): Enum
{
if ($val === null) {
$this->values[$key] = $key;
@@ -104,7 +104,7 @@ public function addValue(string $key, $val = null): self
return $this;
}
- public function removeValue(string $key): self
+ public function removeValue(string $key): Enum
{
unset($this->values[$key]);
diff --git a/src/Schema/Type/InterfaceType.php b/src/Schema/Type/InterfaceType.php
index 7f4ba4a2..35c8a9cd 100644
--- a/src/Schema/Type/InterfaceType.php
+++ b/src/Schema/Type/InterfaceType.php
@@ -50,7 +50,7 @@ public function getEncodedTypeResolver(): EncodedResolver
* @param array|string|ResolverReference|null $resolver
* @return $this
*/
- public function setTypeResolver($resolver): self
+ public function setTypeResolver($resolver): InterfaceType
{
if ($resolver) {
$this->typeResolver = $resolver instanceof ResolverReference
diff --git a/src/Schema/Type/ModelType.php b/src/Schema/Type/ModelType.php
index cc77c101..076828e2 100644
--- a/src/Schema/Type/ModelType.php
+++ b/src/Schema/Type/ModelType.php
@@ -172,7 +172,7 @@ public function addField(string $fieldName, $fieldConfig = true, ?callable $call
* @return $this
* @throws SchemaBuilderException
*/
- public function addFields(array $fields): self
+ public function addFields(array $fields): ModelType
{
if (ArrayLib::is_associative($fields)) {
foreach ($fields as $fieldName => $config) {
@@ -190,7 +190,7 @@ public function addFields(array $fields): self
/**
* @throws SchemaBuilderException
*/
- public function addAllFields(): self
+ public function addAllFields(): ModelType
{
$initialFields = $this->getInitialFields();
foreach ($initialFields as $fieldName => $fieldType) {
@@ -208,7 +208,7 @@ public function addAllFields(): self
/**
* @throws SchemaBuilderException
*/
- public function addAllOperations(): self
+ public function addAllOperations(): ModelType
{
Schema::invariant(
$this->getModel() instanceof OperationProvider,
@@ -232,7 +232,7 @@ public function addAllOperations(): self
/**
* @throws SchemaBuilderException
*/
- public function applyOperationsConfig(array $operations): self
+ public function applyOperationsConfig(array $operations): ModelType
{
Schema::assertValidConfig($operations);
foreach ($operations as $operationName => $data) {
@@ -283,14 +283,14 @@ public function mergeWith(Type $type): Type
return parent::mergeWith($type);
}
- public function addOperation(string $operationName, array $config = []): self
+ public function addOperation(string $operationName, array $config = []): ModelType
{
$this->operationCreators[$operationName] = $config;
return $this;
}
- public function removeOperation(string $operationName): self
+ public function removeOperation(string $operationName): ModelType
{
unset($this->operationCreators[$operationName]);
return $this;
@@ -300,7 +300,7 @@ public function removeOperation(string $operationName): self
/**
* @throws SchemaBuilderException
*/
- public function updateOperation(string $operationName, array $config = []): self
+ public function updateOperation(string $operationName, array $config = []): ModelType
{
Schema::invariant(
isset($this->operationCreators[$operationName]),
diff --git a/src/Schema/Type/Scalar.php b/src/Schema/Type/Scalar.php
index 52d45149..d16e9d16 100644
--- a/src/Schema/Type/Scalar.php
+++ b/src/Schema/Type/Scalar.php
@@ -70,7 +70,7 @@ public function getName(): ?string
/**
* @throws SchemaBuilderException
*/
- public function setName(string $name): self
+ public function setName(string $name): Scalar
{
Schema::assertValidName($name);
$this->name = $name;
@@ -87,7 +87,7 @@ public function getEncodedSerialiser(): EncodedResolver
return EncodedResolver::create($this->getSerialiser());
}
- public function setSerialiser(ResolverReference $serialiser): self
+ public function setSerialiser(ResolverReference $serialiser): Scalar
{
$this->serialiser = $serialiser;
return $this;
@@ -103,7 +103,7 @@ public function getEncodedValueParser(): EncodedResolver
return EncodedResolver::create($this->getValueParser());
}
- public function setValueParser(ResolverReference $valueParser): self
+ public function setValueParser(ResolverReference $valueParser): Scalar
{
$this->valueParser = $valueParser;
return $this;
@@ -119,7 +119,7 @@ public function getEncodedLiteralParser(): EncodedResolver
return EncodedResolver::create($this->getLiteralParser());
}
- public function setLiteralParser(ResolverReference $literalParser): self
+ public function setLiteralParser(ResolverReference $literalParser): Scalar
{
$this->literalParser = $literalParser;
return $this;
diff --git a/src/Schema/Type/Type.php b/src/Schema/Type/Type.php
index 604f033d..8535972a 100644
--- a/src/Schema/Type/Type.php
+++ b/src/Schema/Type/Type.php
@@ -89,7 +89,7 @@ public function getName(): ?string
return $this->name;
}
- public function setName(string $name): self
+ public function setName(string $name): Type
{
$this->name = ucfirst($name ?? '');
return $this;
@@ -106,7 +106,7 @@ public function getFields(): array
/**
* @throws SchemaBuilderException
*/
- public function setFields(array $fields): self
+ public function setFields(array $fields): Type
{
Schema::assertValidConfig($fields);
foreach ($fields as $fieldName => $fieldConfig) {
@@ -125,7 +125,7 @@ public function setFields(array $fields): self
* @param callable|null $callback
* @return Type
*/
- public function addField(string $fieldName, $fieldConfig, ?callable $callback = null): self
+ public function addField(string $fieldName, $fieldConfig, ?callable $callback = null): Type
{
if (!$fieldConfig instanceof Field) {
$config = is_string($fieldConfig) ? ['type' => $fieldConfig] : $fieldConfig;
@@ -145,7 +145,7 @@ public function addField(string $fieldName, $fieldConfig, ?callable $callback =
* @param string $field
* @return Type
*/
- public function removeField(string $field): self
+ public function removeField(string $field): Type
{
unset($this->fields[$field]);
@@ -165,7 +165,7 @@ public function getDescription(): ?string
/**
* @throws SchemaBuilderException
*/
- public function mergeWith(Type $type): self
+ public function mergeWith(Type $type): Type
{
Schema::invariant(
$type->getIsInput() === $this->getIsInput(),
@@ -233,13 +233,13 @@ public function getEncodedInterfaces(): string
return var_export($this->interfaces, true);
}
- public function setInterfaces(array $interfaces): self
+ public function setInterfaces(array $interfaces): Type
{
$this->interfaces = $interfaces;
return $this;
}
- public function addInterface(string $name): self
+ public function addInterface(string $name): Type
{
if (!in_array($name, $this->interfaces ?? [])) {
$this->interfaces[] = $name;
@@ -258,7 +258,7 @@ public function getIsInput(): bool
return $this->isInput;
}
- public function setIsInput(bool $isInput): self
+ public function setIsInput(bool $isInput): Type
{
$this->isInput = $isInput;
return $this;
@@ -273,7 +273,7 @@ public function getFieldResolver(): ?ResolverReference
* @param array|string|ResolverReference|null $fieldResolver
* @return Type
*/
- public function setFieldResolver($fieldResolver): self
+ public function setFieldResolver($fieldResolver): Type
{
if ($fieldResolver) {
$this->fieldResolver = $fieldResolver instanceof ResolverReference
diff --git a/src/Schema/Type/UnionType.php b/src/Schema/Type/UnionType.php
index 999f92a0..1889dd80 100644
--- a/src/Schema/Type/UnionType.php
+++ b/src/Schema/Type/UnionType.php
@@ -71,7 +71,7 @@ public function getName(): ?string
/**
* @throws SchemaBuilderException
*/
- public function setName(string $name): self
+ public function setName(string $name): UnionType
{
Schema::assertValidName($name);
$this->name = $name;
@@ -83,7 +83,7 @@ public function getTypes(): array
return $this->types;
}
- public function setTypes(array $types): self
+ public function setTypes(array $types): UnionType
{
$this->types = $types;
return $this;
@@ -106,7 +106,7 @@ public function getTypeResolver()
* @param array|string|ResolverReference|null $resolver
* @return $this
*/
- public function setTypeResolver($resolver): self
+ public function setTypeResolver($resolver): UnionType
{
if ($resolver) {
$this->typeResolver = $resolver instanceof ResolverReference
@@ -129,7 +129,7 @@ public function getDescription(): ?string
return $this->description;
}
- public function setDescription(?string $description): self
+ public function setDescription(?string $description): UnionType
{
$this->description = $description;
return $this;
diff --git a/tests/Fake/FakeSiteTree.php b/tests/Fake/FakeSiteTree.php
index 087fff07..99712a18 100644
--- a/tests/Fake/FakeSiteTree.php
+++ b/tests/Fake/FakeSiteTree.php
@@ -16,11 +16,11 @@ class FakeSiteTree extends DataObject implements TestOnly
];
private static $has_one = [
- 'Parent' => self::class,
+ 'Parent' => FakeSiteTree::class,
];
private static $has_many = [
- 'Children' => self::class,
+ 'Children' => FakeSiteTree::class,
];
private static $extensions = [
diff --git a/tests/Schema/AbstractTypeRegistryTest.php b/tests/Schema/AbstractTypeRegistryTest.php
index e332520c..8fca02d4 100644
--- a/tests/Schema/AbstractTypeRegistryTest.php
+++ b/tests/Schema/AbstractTypeRegistryTest.php
@@ -22,7 +22,7 @@ class AbstractTypeRegistryTest extends SapphireTest
protected function setUp(): void
{
- $dir = self::SOURCE_DIRECTORY;
+ $dir = AbstractTypeRegistryTest::SOURCE_DIRECTORY;
if (!file_exists($dir)) {
mkdir($dir);
}
@@ -30,7 +30,7 @@ protected function setUp(): void
protected function tearDown(): void
{
- $dir = self::SOURCE_DIRECTORY;
+ $dir = AbstractTypeRegistryTest::SOURCE_DIRECTORY;
if (file_exists($dir)) {
$fs = new Filesystem();
$fs->remove($dir);
@@ -45,7 +45,7 @@ public function testRebuildOnMissingPath()
{
list($registry, $_, $getRebuildOnMissingPathMethod, $getRebuildOnMissingFilename) = $this->getInstance();
$this->assertSame(
- self::SOURCE_DIRECTORY . '/' . $getRebuildOnMissingFilename->invoke($registry),
+ AbstractTypeRegistryTest::SOURCE_DIRECTORY . '/' . $getRebuildOnMissingFilename->invoke($registry),
$getRebuildOnMissingPathMethod->invoke($registry)
);
}
@@ -87,7 +87,7 @@ public function testRebuildOnMissing(
// put in a timestamp that is in the future, so it can never be above the interval threshold
$time = time() + 100;
}
- file_put_contents(self::SOURCE_DIRECTORY . '/' . $getRebuildOnMissingFilename->invoke($registry), $time);
+ file_put_contents(AbstractTypeRegistryTest::SOURCE_DIRECTORY . '/' . $getRebuildOnMissingFilename->invoke($registry), $time);
// assert
$this->assertSame($expected, $canRebuildOnMissingMethod->invoke($registry));
diff --git a/tests/Schema/DataObject/FakeInheritanceUnionBuilder.php b/tests/Schema/DataObject/FakeInheritanceUnionBuilder.php
index 3b69fd8e..735f115c 100644
--- a/tests/Schema/DataObject/FakeInheritanceUnionBuilder.php
+++ b/tests/Schema/DataObject/FakeInheritanceUnionBuilder.php
@@ -14,8 +14,8 @@ class FakeInheritanceUnionBuilder extends InheritanceUnionBuilder implements Tes
public static function reset()
{
- self::$createCalls = [];
- self::$applyCalls = [];
+ FakeInheritanceUnionBuilder::$createCalls = [];
+ FakeInheritanceUnionBuilder::$applyCalls = [];
}
public function createUnions(ModelType $type): InheritanceUnionBuilder
diff --git a/tests/Schema/DataObject/FakeInterfaceBuilder.php b/tests/Schema/DataObject/FakeInterfaceBuilder.php
index dc663d5b..4a73016f 100644
--- a/tests/Schema/DataObject/FakeInterfaceBuilder.php
+++ b/tests/Schema/DataObject/FakeInterfaceBuilder.php
@@ -15,9 +15,9 @@ class FakeInterfaceBuilder extends InterfaceBuilder implements TestOnly
public static function reset()
{
- self::$createCalls = [];
- self::$baseCalled = false;
- self::$applyCalls = [];
+ FakeInterfaceBuilder::$createCalls = [];
+ FakeInterfaceBuilder::$baseCalled = false;
+ FakeInterfaceBuilder::$applyCalls = [];
}
public function createInterfaces(ModelType $modelType, array $interfaceStack = []): InterfaceBuilder
@@ -34,7 +34,7 @@ public function applyBaseInterface(): InterfaceBuilder
public function applyInterfacesToQueries(ModelType $type): InterfaceBuilder
{
- self::$applyCalls[$type->getName()] = true;
+ FakeInterfaceBuilder::$applyCalls[$type->getName()] = true;
return $this;
}
}