Skip to content

Develop #1

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

Merged
merged 18 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Refactored code
  • Loading branch information
WalterWoshid committed Apr 19, 2023
commit 03ae131f2ba297af53b096cf99493986af73b62c
64 changes: 32 additions & 32 deletions src/CodeTransformerKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
namespace Okapi\CodeTransformer;

use DI\Attribute\Inject;
use Okapi\CodeTransformer\Exception\Kernel\DirectKernelInitializationException;
use Okapi\CodeTransformer\Service\AutoloadInterceptor;
use Okapi\CodeTransformer\Service\CacheStateManager;
use Okapi\CodeTransformer\Service\DI;
use Okapi\CodeTransformer\Service\Options;
use Okapi\CodeTransformer\Service\StreamFilter;
use Okapi\CodeTransformer\Service\TransformerContainer;
use Okapi\CodeTransformer\Core\AutoloadInterceptor;
use Okapi\CodeTransformer\Core\Cache\CacheStateManager;
use Okapi\CodeTransformer\Core\Container\TransformerManager;
use Okapi\CodeTransformer\Core\DI;
use Okapi\CodeTransformer\Core\Exception\Kernel\DirectKernelInitializationException;
use Okapi\CodeTransformer\Core\Options;
use Okapi\CodeTransformer\Core\StreamFilter;
use Okapi\Singleton\Singleton;

/**
* # Code Transformer Kernel
*
* The `CodeTransformerKernel` is the heart of the Code Transformer library.
* This class is the heart of the Code Transformer library.
* It manages an environment for Code Transformation.
*
* 1. Extends this class and define a list of transformers in the
Expand All @@ -26,6 +26,30 @@ abstract class CodeTransformerKernel
{
use Singleton;

// region DI

#[Inject]
private Options $options;

#[Inject]
protected TransformerManager $transformerContainer;

#[Inject]
private CacheStateManager $cacheStateManager;

#[Inject]
private StreamFilter $streamFilter;

#[Inject]
private AutoloadInterceptor $autoloadInterceptor;

/**
* Make the constructor public to allow the DI container to instantiate the class.
*/
public function __construct() {}

// endregion

// region Settings

/**
Expand Down Expand Up @@ -61,30 +85,6 @@ abstract class CodeTransformerKernel
*/
protected array $transformers = [];

// region DI

#[Inject]
private Options $options;

#[Inject]
protected TransformerContainer $transformerContainer;

#[Inject]
private CacheStateManager $cacheStateManager;

#[Inject]
private StreamFilter $streamFilter;

#[Inject]
private AutoloadInterceptor $autoloadInterceptor;

/**
* Make the constructor public to allow the DI container to instantiate the class.
*/
public function __construct() {}

// endregion

/**
* Resolve instance with dependency injection.
*
Expand Down
8 changes: 5 additions & 3 deletions src/Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Okapi\CodeTransformer;

use Okapi\CodeTransformer\Service\StreamFilter\Metadata\Code;
use Okapi\CodeTransformer\Transformer\Code;

/**
* # Code Transformer
*
* The `CodeTransformer` class provides a foundation for creating a transformer.
* This class provides a foundation for creating a transformer.
*
* Transformers extend this class and implement following methods:
* - `getTargetClass()` - Returns the target class name(s) that this transformer
Expand All @@ -25,14 +25,16 @@ abstract class Transformer
/**
* Get the target class name that this transformer will be applied to.
*
* Wildcards are supported. See Okapi/Wildcards for more information.
*
* @return class-string|class-string[]
*/
abstract public function getTargetClass(): string|array;

/**
* Transform the source code.
*
* @param Code $code
* @param Code $code
*
* @return void
*/
Expand Down