Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
CS
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy-j committed Feb 7, 2017
1 parent d156612 commit 5c17d2d
Show file tree
Hide file tree
Showing 23 changed files with 121 additions and 122 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RequestsFilters, Records, Documents and etc.
## Install

```
composer require spiral/idehelper
composer require spiral/ide-helper
./spiral register spiral/ide-helper && ./spiral console:reload
```

Expand All @@ -15,10 +15,6 @@ composer require spiral/idehelper
```
./spiral spiral:ide-helper
```
or
```
./spiral spiral:ide-helper -l locator1,locator2 -w writer1,writer2
```

## Configuration and Terminology

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "spiral/idehelper",
"name": "spiral/ide-helper",
"description": "Spiral Framework IDE helper",
"authors": [
{
Expand All @@ -13,7 +13,7 @@
},
"autoload": {
"psr-4": {
"Spiral\\": "src/"
"Spiral\\": "source/"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function locate(): array
* @param RecordSchema $context
* @param AbstractColumn[] $columns
* @param RelationInterface[] $relations
*
* @return ClassMember[]
*/
private function scan(RecordSchema $context, array $columns, array $relations)
Expand All @@ -102,6 +103,7 @@ private function scan(RecordSchema $context, array $columns, array $relations)

/**
* @param AbstractColumn[] $columns
*
* @return array
*/
private function processColumns(array $columns): array
Expand All @@ -124,6 +126,7 @@ private function processColumns(array $columns): array
/**
* @param array $fields
* @param AbstractColumn[] $columns
*
* @return array
*/
private function processFields(array $fields, array $columns): array
Expand All @@ -146,6 +149,7 @@ private function processFields(array $fields, array $columns): array
/**
* @param string $class
* @param RelationInterface[] $relations
*
* @return array
*/
private function findRelations(string $class, array $relations): array
Expand Down
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
<?php
/**
* Spiral Framework, IDE Helper
*
* @author Dmitry Mironov <[email protected]>
* @licence MIT
*/

namespace Spiral\IdeHelper\Renderer;

use Spiral\IdeHelper\Helpers;
use Spiral\IdeHelper\Model\ClassProperty;
use Spiral\Reactor\ClassDeclaration;
use Spiral\Reactor\ClassDeclaration\PropertyDeclaration;
use Spiral\Reactor\FileDeclaration;


/**
* Class ReactorBasedPropertyRenderer
*
* WARNING: this class only support rendering multiple classes in the same namespace.
*
* @package Spiral\IdeHelper\Renderer
*/
class ReactorBasedPropertyRenderer implements RendererInterface
{
/**
* @inheritdoc
*/
public function render(array $classes): string
{
if (count($classes) === 0) {
$declaration = new FileDeclaration();

return $declaration->render();
}

$namespace = $classes[0]->getNamespace() ?? '';
$fileDeclaration = new FileDeclaration($namespace);
foreach ($classes as $class) {
$classDeclaration = new ClassDeclaration($class->getShortName());
$properties = $classDeclaration->getProperties();

foreach ($class->getMembers() as $member) {
if ($member instanceof ClassProperty) {
$name = $member->getName();
$comment = $this->renderProperty($member->getTypes());

$property = new PropertyDeclaration($name, null, $comment);
$property->setAccess("protected");

$properties->add($property);
}
}

$fileDeclaration->addElement($classDeclaration);
}

return $fileDeclaration->render();
}

/**
* @param array $types
* @return string
*/
private function renderProperty(array $types): string
{
$type = implode('|', array_map([Helpers::class, 'fqcn'], $types));

return "@var {$type}";
}
<?php
/**
* Spiral Framework, IDE Helper
*
* @author Dmitry Mironov <[email protected]>
* @licence MIT
*/

namespace Spiral\IdeHelper\Renderer;

use Spiral\IdeHelper\Helpers;
use Spiral\IdeHelper\Model\ClassProperty;
use Spiral\Reactor\ClassDeclaration;
use Spiral\Reactor\ClassDeclaration\PropertyDeclaration;
use Spiral\Reactor\FileDeclaration;


/**
* Class ReactorBasedPropertyRenderer
*
* WARNING: this class only support rendering multiple classes in the same namespace.
*
* @package Spiral\IdeHelper\Renderer
*/
class ReactorBasedPropertyRenderer implements RendererInterface
{
/**
* @inheritdoc
*/
public function render(array $classes): string
{
if (count($classes) === 0) {
$declaration = new FileDeclaration();

return $declaration->render();
}

$namespace = $classes[0]->getNamespace() ?? '';
$fileDeclaration = new FileDeclaration($namespace);
foreach ($classes as $class) {
$classDeclaration = new ClassDeclaration($class->getShortName());
$properties = $classDeclaration->getProperties();

foreach ($class->getMembers() as $member) {
if ($member instanceof ClassProperty) {
$name = $member->getName();
$comment = $this->renderProperty($member->getTypes());

$property = new PropertyDeclaration($name, null, $comment);
$property->setAccess("protected");

$properties->add($property);
}
}

$fileDeclaration->addElement($classDeclaration);
}

return $fileDeclaration->render();
}

/**
* @param array $types
* @return string
*/
private function renderProperty(array $types): string
{
$type = implode('|', array_map([Helpers::class, 'fqcn'], $types));

return "@var {$type}";
}
}
87 changes: 43 additions & 44 deletions src/IdeHelperModule.php → source/IdeHelperModule.php
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
<?php
/**
* Spiral Framework, IDE Helper
*
* @author Dmitry Mironov <[email protected]>
* @licence MIT
*/

namespace Spiral;


use Spiral\Core\DirectoriesInterface;
use Spiral\IdeHelper\IdeHelperConfig;
use Spiral\Modules\ModuleInterface;
use Spiral\Modules\PublisherInterface;
use Spiral\Modules\RegistratorInterface;

/**
* Class IdeHelperModule
*
* @package Spiral\IdeHelper
*/
class IdeHelperModule implements ModuleInterface
{
/**
* @inheritdoc
*/
public function register(RegistratorInterface $registrator)
{
$registrator->configure('tokenizer', 'directories', 'spiral/idehelper', [
"directory('libraries') . 'spiral/idehelper/src/',",
]);
}

/**
* @inheritdoc
*/
public function publish(PublisherInterface $publisher, DirectoriesInterface $directories)
{
$publisher->publish(
__DIR__ . '/../resources/config.php',
$directories->directory('config') . IdeHelperConfig::CONFIG . '.php'
);
}
<?php
/**
* Spiral Framework, IDE Helper
*
* @author Dmitry Mironov <[email protected]>
* @licence MIT
*/

namespace Spiral;

use Spiral\Core\DirectoriesInterface;
use Spiral\IdeHelper\IdeHelperConfig;
use Spiral\Modules\ModuleInterface;
use Spiral\Modules\PublisherInterface;
use Spiral\Modules\RegistratorInterface;

/**
* Class IdeHelperModule
*
* @package Spiral\IdeHelper
*/
class IdeHelperModule implements ModuleInterface
{
/**
* @inheritdoc
*/
public function register(RegistratorInterface $registrator)
{
$registrator->configure('tokenizer', 'directories', 'spiral/idehelper', [
"directory('libraries') . 'spiral/ide-helper/src/',",
]);
}

/**
* @inheritdoc
*/
public function publish(PublisherInterface $publisher, DirectoriesInterface $directories)
{
$publisher->publish(
__DIR__ . '/../resources/config.php',
$directories->directory('config') . IdeHelperConfig::CONFIG . '.php'
);
}
}

0 comments on commit 5c17d2d

Please sign in to comment.