Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PSR-4 namespace standard #1

Merged
merged 4 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/generate_schema_objects
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (!$autoLoadFound) {
}

use GraphQL\Client;
use GraphQL\SchemaGenerator\SchemaClassGenerator;
use gmostafa\GraphQL\SchemaGenerator\SchemaClassGenerator;

$endpointUrl = readline('GraphlQL endpoint URL: ');

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
],
"autoload": {
"psr-4": {
"GraphQL\\": "src/",
"GraphQL\\SchemaObject\\": "schema_object/"
"gmostafa\\GraphQL\\": "src/",
"gmostafa\\GraphQL\\SchemaObject\\": "schema_object/"
}
},
"autoload-dev": {
Expand Down
4 changes: 2 additions & 2 deletions examples/query_object_example.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use GraphQL\Client;
use GraphQL\Exception\QueryError;
use GraphQL\SchemaObject\RootPokemonArgumentsObject;
use GraphQL\SchemaObject\RootQueryObject;
use gmostafa\GraphQL\SchemaObject\RootPokemonArgumentsObject;
use gmostafa\GraphQL\SchemaObject\RootQueryObject;

// Create Client object to contact the GraphQL endpoint
$client = new Client(
Expand Down
Empty file removed schema_object/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion src/Enumeration/FieldTypeKindEnum.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace GraphQL\Enumeration;
namespace gmostafa\GraphQL\Enumeration;

/**
* Class FieldTypeKindEnum
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace GraphQL\SchemaGenerator\CodeGenerator;
namespace gmostafa\GraphQL\SchemaGenerator\CodeGenerator;

use GraphQL\SchemaGenerator\CodeGenerator\CodeFile\ClassFile;
use gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\ClassFile;
use GraphQL\Util\StringLiteralFormatter;

/**
Expand All @@ -24,7 +24,7 @@ public function __construct(string $writeDir, string $objectName, string $namesp
$this->classFile = new ClassFile($writeDir, $objectName);
$this->classFile->setNamespace($namespace);
if ($namespace !== self::DEFAULT_NAMESPACE) {
$this->classFile->addImport('GraphQL\\SchemaObject\\ArgumentsObject');
$this->classFile->addImport('gmostafa\\GraphQL\\SchemaObject\\ArgumentsObject');
}
$this->classFile->extendsClass('ArgumentsObject');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace GraphQL\SchemaGenerator\CodeGenerator\CodeFile;
namespace gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile;

use RuntimeException;

Expand Down
2 changes: 1 addition & 1 deletion src/SchemaGenerator/CodeGenerator/CodeFile/ClassFile.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace GraphQL\SchemaGenerator\CodeGenerator\CodeFile;
namespace gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile;

/**
* Class ClassFile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace GraphQL\SchemaGenerator\CodeGenerator\CodeFile;
namespace gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile;

/**
* Interface that all classes which represent code files have to implement
Expand Down
2 changes: 1 addition & 1 deletion src/SchemaGenerator/CodeGenerator/CodeFile/TraitFile.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace GraphQL\SchemaGenerator\CodeGenerator\CodeFile;
namespace gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile;

use GraphQL\Util\StringLiteralFormatter;

Expand Down
6 changes: 3 additions & 3 deletions src/SchemaGenerator/CodeGenerator/EnumObjectBuilder.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace GraphQL\SchemaGenerator\CodeGenerator;
namespace gmostafa\GraphQL\SchemaGenerator\CodeGenerator;

use GraphQL\SchemaGenerator\CodeGenerator\CodeFile\ClassFile;
use gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\ClassFile;

/**
* Class EnumObjectBuilder
Expand Down Expand Up @@ -30,7 +30,7 @@ public function __construct(string $writeDir, string $objectName, string $namesp
$this->classFile = new ClassFile($writeDir, $className);
$this->classFile->setNamespace($namespace);
if ($namespace !== self::DEFAULT_NAMESPACE) {
$this->classFile->addImport('GraphQL\\SchemaObject\\EnumObject');
$this->classFile->addImport('gmostafa\\GraphQL\\SchemaObject\\EnumObject');
}
$this->classFile->extendsClass('EnumObject');
}
Expand Down
6 changes: 3 additions & 3 deletions src/SchemaGenerator/CodeGenerator/InputObjectClassBuilder.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace GraphQL\SchemaGenerator\CodeGenerator;
namespace gmostafa\GraphQL\SchemaGenerator\CodeGenerator;

use GraphQL\SchemaGenerator\CodeGenerator\CodeFile\ClassFile;
use gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\ClassFile;
use GraphQL\Util\StringLiteralFormatter;

/**
Expand All @@ -26,7 +26,7 @@ public function __construct(string $writeDir, string $objectName, string $namesp
$this->classFile = new ClassFile($writeDir, $className);
$this->classFile->setNamespace($namespace);
if ($namespace !== self::DEFAULT_NAMESPACE) {
$this->classFile->addImport('GraphQL\\SchemaObject\\InputObject');
$this->classFile->addImport('gmostafa\\GraphQL\\SchemaObject\\InputObject');
}
$this->classFile->extendsClass('InputObject');
}
Expand Down
4 changes: 2 additions & 2 deletions src/SchemaGenerator/CodeGenerator/ObjectBuilderInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace GraphQL\SchemaGenerator\CodeGenerator;
namespace gmostafa\GraphQL\SchemaGenerator\CodeGenerator;

/**
* Interface ObjectBuilderInterface
Expand All @@ -9,7 +9,7 @@
*/
interface ObjectBuilderInterface
{
const DEFAULT_NAMESPACE = 'GraphQL\\SchemaObject';
const DEFAULT_NAMESPACE = 'gmostafa\\GraphQL\\SchemaObject';

/**
* @return void
Expand Down
4 changes: 2 additions & 2 deletions src/SchemaGenerator/CodeGenerator/ObjectClassBuilder.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace GraphQL\SchemaGenerator\CodeGenerator;
namespace gmostafa\GraphQL\SchemaGenerator\CodeGenerator;

use GraphQL\SchemaGenerator\CodeGenerator\CodeFile\ClassFile;
use gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\ClassFile;

/**
* Class ObjectClassBuilder
Expand Down
8 changes: 4 additions & 4 deletions src/SchemaGenerator/CodeGenerator/QueryObjectClassBuilder.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace GraphQL\SchemaGenerator\CodeGenerator;
namespace gmostafa\GraphQL\SchemaGenerator\CodeGenerator;

use GraphQL\SchemaGenerator\CodeGenerator\CodeFile\ClassFile;
use GraphQL\SchemaObject\QueryObject;
use gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\ClassFile;
use gmostafa\GraphQL\SchemaObject\QueryObject;
use GraphQL\Util\StringLiteralFormatter;

/**
Expand All @@ -27,7 +27,7 @@ public function __construct(string $writeDir, string $objectName, string $namesp
$this->classFile = new ClassFile($writeDir, $className);
$this->classFile->setNamespace($namespace);
if ($namespace !== self::DEFAULT_NAMESPACE) {
$this->classFile->addImport('GraphQL\\SchemaObject\\QueryObject');
$this->classFile->addImport('gmostafa\\GraphQL\\SchemaObject\\QueryObject');
}
$this->classFile->extendsClass('QueryObject');

Expand Down
16 changes: 8 additions & 8 deletions src/SchemaGenerator/SchemaClassGenerator.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace GraphQL\SchemaGenerator;
namespace gmostafa\GraphQL\SchemaGenerator;

use GraphQL\Client;
use GraphQL\Enumeration\FieldTypeKindEnum;
use GraphQL\SchemaGenerator\CodeGenerator\ArgumentsObjectClassBuilder;
use GraphQL\SchemaGenerator\CodeGenerator\EnumObjectBuilder;
use GraphQL\SchemaGenerator\CodeGenerator\InputObjectClassBuilder;
use GraphQL\SchemaGenerator\CodeGenerator\ObjectBuilderInterface;
use GraphQL\SchemaGenerator\CodeGenerator\QueryObjectClassBuilder;
use GraphQL\SchemaObject\QueryObject;
use gmostafa\GraphQL\Enumeration\FieldTypeKindEnum;
use gmostafa\GraphQL\SchemaGenerator\CodeGenerator\ArgumentsObjectClassBuilder;
use gmostafa\GraphQL\SchemaGenerator\CodeGenerator\EnumObjectBuilder;
use gmostafa\GraphQL\SchemaGenerator\CodeGenerator\InputObjectClassBuilder;
use gmostafa\GraphQL\SchemaGenerator\CodeGenerator\ObjectBuilderInterface;
use gmostafa\GraphQL\SchemaGenerator\CodeGenerator\QueryObjectClassBuilder;
use gmostafa\GraphQL\SchemaObject\QueryObject;
use GraphQL\Util\StringLiteralFormatter;
use RuntimeException;

Expand Down
2 changes: 1 addition & 1 deletion src/SchemaGenerator/SchemaInspector.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace GraphQL\SchemaGenerator;
namespace gmostafa\GraphQL\SchemaGenerator;

use GraphQL\Client;

Expand Down
2 changes: 1 addition & 1 deletion src/SchemaObject/ArgumentsObject.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace GraphQL\SchemaObject;
namespace gmostafa\GraphQL\SchemaObject;

/**
* Class ArgumentsObject
Expand Down
2 changes: 1 addition & 1 deletion src/SchemaObject/EnumObject.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace GraphQL\SchemaObject;
namespace gmostafa\GraphQL\SchemaObject;

/**
* Class EnumObject
Expand Down
2 changes: 1 addition & 1 deletion src/SchemaObject/InputObject.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace GraphQL\SchemaObject;
namespace gmostafa\GraphQL\SchemaObject;

use GraphQL\RawObject;
use GraphQL\Util\StringLiteralFormatter;
Expand Down
2 changes: 1 addition & 1 deletion src/SchemaObject/QueryObject.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace GraphQL\SchemaObject;
namespace gmostafa\GraphQL\SchemaObject;

use GraphQL\Exception\EmptySelectionSetException;
use GraphQL\Query;
Expand Down
32 changes: 16 additions & 16 deletions tests/AbstractCodeFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace GraphQL\Tests;

use GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile;
use gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile;

/**
* Class AbstractCodeFileTest
Expand Down Expand Up @@ -45,8 +45,8 @@ protected function setUp(): void
/**
* @testdox Test the behavior of the constructor when provided with an invalid directory
*
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::__construct
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::validateDirectory
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::__construct
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::validateDirectory
*/
public function testInvalidWriteDirInConstructor()
{
Expand All @@ -61,8 +61,8 @@ public function testInvalidWriteDirInConstructor()
/**
* @testdox Test the behavior of the constructor when provided with a non-writable directory
*
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::__construct()
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::validateDirectory
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::__construct()
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::validateDirectory
*/
public function testUnwritableDirInConstructor()
{
Expand All @@ -81,8 +81,8 @@ public function testUnwritableDirInConstructor()
/**
* @testdox Test the behavior of changeWriteDir method when provided with an invalid directory
*
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::changeWriteDir
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::validateDirectory
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::changeWriteDir
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::validateDirectory
*/
public function testInvalidWriteDir()
{
Expand All @@ -93,8 +93,8 @@ public function testInvalidWriteDir()
/**
* @testdox Test the behavior of changeWriteDir method when provided with a non-writable directory
*
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::changeWriteDir
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::validateDirectory
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::changeWriteDir
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::validateDirectory
*/
public function testUnwritableDir()
{
Expand All @@ -107,7 +107,7 @@ public function testUnwritableDir()
}

/**
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::getWritePath
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::getWritePath
*/
public function testWritePathGetter()
{
Expand All @@ -117,9 +117,9 @@ public function testWritePathGetter()
/**
* @depends testWritePathGetter
*
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::writeFile
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::writeFileToPath
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::generateFileContents
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::writeFile
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::writeFileToPath
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::generateFileContents
*/
public function testFileWritingWorks()
{
Expand All @@ -130,9 +130,9 @@ public function testFileWritingWorks()
/**
* @depends testFileWritingWorks
*
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::changeWriteDir
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::changeFileName
* @covers \GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::WriteFile
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::changeWriteDir
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::changeFileName
* @covers \gmostafa\GraphQL\SchemaGenerator\CodeGenerator\CodeFile\AbstractCodeFile::WriteFile
*/
public function testFileWritingWorksWithTrailingSlash()
{
Expand Down
Loading