Skip to content

Commit

Permalink
removed PostConstruct Annotation / Interceptor / PointCut (#90)
Browse files Browse the repository at this point in the history
* removed PostConstruct

* Update php.yml
  • Loading branch information
ytake authored Jan 15, 2023
1 parent efe752e commit 5b7c7b0
Show file tree
Hide file tree
Showing 29 changed files with 33 additions and 1,438 deletions.
3 changes: 0 additions & 3 deletions .coveralls.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.3', '7.4', '8.0']
php-versions: ['8.0', '8.1']
name: PHP ${{ matrix.php-versions }} Test
steps:
- uses: actions/checkout@v2
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ vendor
composer.lock
composer.phar
*.result.cache

15 changes: 0 additions & 15 deletions .scrutinizer.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .sensiolabs.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

59 changes: 3 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
aspect-oriented programming Package for laravel framework

![Build Status](https://github.com/ytake/Laravel-Aspect/workflows/Tests/badge.svg?branch=master)
[![Coverage Status](http://img.shields.io/coveralls/ytake/Laravel-Aspect/master.svg?style=flat-square)](https://coveralls.io/r/ytake/Laravel-Aspect?branch=master)
[![Scrutinizer Code Quality](http://img.shields.io/scrutinizer/g/ytake/Laravel-Aspect.svg?style=flat-square)](https://scrutinizer-ci.com/g/ytake/Laravel-Aspect/?branch=master)

[![StyleCI](https://styleci.io/repos/40900709/shield)](https://styleci.io/repos/40900709)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/70dace68-fe04-4039-aeb4-47a64c6acca3/mini.png)](https://insight.sensiolabs.com/projects/70dace68-fe04-4039-aeb4-47a64c6acca3)

[![License](http://img.shields.io/packagist/l/ytake/laravel-aspect.svg?style=flat-square)](https://packagist.org/packages/ytake/laravel-aspect)
[![Latest Version](http://img.shields.io/packagist/v/ytake/laravel-aspect.svg?style=flat-square)](https://packagist.org/packages/ytake/laravel-aspect)
Expand All @@ -31,6 +27,7 @@ This library is heavily inspired by the [jcabi/jcabi-aspects](https://github.com
6.0.x | 4.0
7.x | 6.0
8.x | 7.0
9.x | 8.0

### install

Expand All @@ -40,25 +37,15 @@ $ composer require ytake/laravel-aspect

*Supported Auto-Discovery(^Laravel5.5)*

#### for Laravel5.1, 5.2
[branch](https://github.com/ytake/Laravel-Aspect/tree/master-laravel5-legacy)

```json
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.*",
"ytake/laravel-aspect": "^1.0"
},
```

#### for Laravel5.6
#### for Laravel9
[Laravel-Aspect Supported Laravel5.6](https://github.com/ytake/Laravel-Aspect/blob/master-laravel5.6)

```json
"require": {
"php": ">=7.1.3",
"laravel/framework": "^5.7",
"ytake/laravel-aspect": "^3.0.0"
"ytake/laravel-aspect": "^8.0.0"
},
```

Expand Down Expand Up @@ -448,46 +435,6 @@ class AspectQueryLog
testing.INFO: QueryLog:AspectQueryLog.multipleDatabaseAppendRecord {"queries":[{"query":"CREATE TABLE tests (test varchar(255) NOT NULL)","bindings":[],"time":0.58,"connectionName":"testing"},{"query":"CREATE TABLE tests (test varchar(255) NOT NULL)","bindings":[],"time":0.31,"connectionName":"testing_second"} ...
```

### @PostConstruct
The PostConstruct annotation is used on a method that needs to be executed after dependency injection is done to perform any initialization.

you must use the PostConstructModule

```php
use Ytake\LaravelAspect\Annotation\PostConstruct;

class Something
{
protected $abstract;

protected $counter = 0;

public function __construct(ExampleInterface $abstract)
{
$this->abstract = $abstract;
}

/**
* @PostConstruct
*/
public function init()
{
$this->counter += 1;
}

/**
* @return int
*/
public function returning()
{
return $this->counter;
}
}

```

**The method MUST NOT have any parameters**

### @RetryOnFailure

Retry the method in case of exception.
Expand Down
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"php": "^7.3|^8.0",
"php": "^8.0",
"illuminate/console": "^9.0",
"illuminate/filesystem": "^9.0",
"illuminate/support": "^9.0",
Expand All @@ -30,16 +30,15 @@
"illuminate/bus": "^9.0",
"illuminate/queue": "^9.0",
"ray/aop": "^2.9",
"doctrine/annotations": "^1.11",
"nikic/php-parser": "^4.0",
"psr/log": "~1.0"
"doctrine/annotations": "^1.10",
"nikic/php-parser": "^4.2",
"psr/log": "^1.0.1 || ^2.0 || ^3.0"
},
"require-dev": {
"symfony/framework-bundle": "^5.2",
"symfony/console": "^5.2|^6.0",
"symfony/framework-bundle": "^6.0",
"symfony/console": "^6.0.9",
"phpunit/phpunit": "^9.3.3",
"mockery/mockery": "*",
"satooshi/php-coveralls": "*",
"sebastian/phpcpd": "*",
"phploc/phploc": "*",
"pdepend/pdepend" : "^2.2.4",
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
<logging/>
<php>
<includePath>./tests</includePath>
<ini name="memory_limit" value="512M"/>
</php>
</phpunit>
54 changes: 0 additions & 54 deletions src/AnnotateClass.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Annotation/MessageDriven.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Doctrine\Common\Annotations\Annotation;

/**
* Class PostConstruct
* Class MessageDriven
*
* @Annotation
* @Target("METHOD")
Expand Down
31 changes: 0 additions & 31 deletions src/Annotation/PostConstruct.php

This file was deleted.

1 change: 0 additions & 1 deletion src/AnnotationConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class AnnotationConfiguration
Annotation\LogExceptions::class,
Annotation\Loggable::class,
Annotation\MessageDriven::class,
Annotation\PostConstruct::class,
Annotation\QueryLog::class,
Annotation\RetryOnFailure::class,
Annotation\Transactional::class,
Expand Down
1 change: 0 additions & 1 deletion src/Console/ModulePublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class ModulePublishCommand extends Command
'TransactionalModule' => 'Ytake\LaravelAspect\Modules\TransactionalModule',
'LoggableModule' => 'Ytake\LaravelAspect\Modules\LoggableModule',
'LogExceptionsModule' => 'Ytake\LaravelAspect\Modules\LogExceptionsModule',
'PostConstructModule' => 'Ytake\LaravelAspect\Modules\PostConstructModule',
'RetryOnFailureModule' => 'Ytake\LaravelAspect\Modules\RetryOnFailureModule',
'MessageDrivenModule' => 'Ytake\LaravelAspect\Modules\MessageDrivenModule',
'QueryLogModule' => 'Ytake\LaravelAspect\Modules\QueryLogModule',
Expand Down
13 changes: 1 addition & 12 deletions src/ContainerInterceptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,12 @@ final class ContainerInterceptor
/** @var Container|\Illuminate\Container\Container */
private $container;

/** @var AnnotateClass */
private $annotateClass;

/**
* @param Container $container
* @param AnnotateClass $annotateClass
*/
public function __construct(Container $container, AnnotateClass $annotateClass)
public function __construct(Container $container)
{
$this->container = $container;
$this->annotateClass = $annotateClass;
}

/**
Expand All @@ -64,12 +59,6 @@ public function intercept(string $abstract, BindInterface $bind, string $classNa
/** @var WeavedInterface $instance */
$instance = $app->make($className, $params);
$instance->bindings = $bind->getBindings();
$method = $this->annotateClass->getPostConstructMethod($instance);
if (!empty($method)) {
$instance->bindings = $bind->getBindings();
$instance->$method();
}

return $instance;
});

Expand Down
40 changes: 0 additions & 40 deletions src/Modules/PostConstructModule.php

This file was deleted.

Loading

0 comments on commit 5b7c7b0

Please sign in to comment.