Skip to content

Commit 91dbacb

Browse files
authored
Merge pull request #492 from samsonasik/patch-1
[Step 1] Bump requirement to PHP 8.2 and parser-reflection 4.0.0-RC1
2 parents 501d013 + 872633c commit 91dbacb

File tree

118 files changed

+622
-954
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+622
-954
lines changed

Diff for: .github/workflows/phpstan.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: "PHPStan analysis"
22

33
on:
4+
pull_request:
45
push:
56

67
jobs:
@@ -12,7 +13,7 @@ jobs:
1213
- name: "Install PHP"
1314
uses: shivammathur/setup-php@v2
1415
with:
15-
php-version: "7.4"
16+
php-version: "8.2"
1617
ini-values: memory_limit=-1
1718
tools: composer:v2
1819
- name: "Cache dependencies"
@@ -21,8 +22,8 @@ jobs:
2122
path: |
2223
~/.composer/cache
2324
vendor
24-
key: "php-7.4"
25-
restore-keys: "php-7.4"
25+
key: "php-8.2"
26+
restore-keys: "php-8.2"
2627
- name: "Install dependencies"
2728
run: "composer install --no-interaction --no-progress --no-suggest"
2829
- name: "Static analysis"

Diff for: .github/workflows/phpunit.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: "PHPUnit tests"
22

33
on:
4+
pull_request:
45
push:
56

67
jobs:
@@ -15,7 +16,7 @@ jobs:
1516
- "lowest"
1617
- "highest"
1718
php-version:
18-
- "7.4"
19+
- "8.2"
1920
operating-system:
2021
- "ubuntu-latest"
2122

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ composer.lock
33
phpunit.xml
44
tests/Fixtures/project/var/cache/*
55
build/
6+
/.phpunit.result.cache

Diff for: composer.json

+9-10
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,22 @@
88
"license": "MIT",
99

1010
"require": {
11-
"php": "^7.4.0",
12-
"doctrine/annotations": "^1.11.1",
13-
"doctrine/cache": "^1.10",
14-
"goaop/parser-reflection": "^3.0.1",
15-
"jakubledl/dissect": "~1.0",
16-
"laminas/laminas-code": "^4.0",
17-
"symfony/finder": "^4.4|^5.1"
11+
"php": "^8.2.0",
12+
"goaop/parser-reflection": "4.x-dev",
13+
"goaop/dissect": "^3.0",
14+
"laminas/laminas-code": "^4.13",
15+
"symfony/finder": "^5.1"
1816
},
1917

2018
"require-dev": {
2119
"adlawson/vfs": "^0.12.1",
2220
"doctrine/orm": "^2.5",
23-
"phpstan/phpstan": "^0.12.64",
24-
"phpunit/phpunit": "^9.5",
21+
"phpstan/phpstan": "^1.10.57",
22+
"phpunit/phpunit": "^10.5.10",
2523
"symfony/console": "^4.4|^5.1",
2624
"symfony/filesystem": "^4.4|^5.1",
2725
"symfony/process": "^4.4|^5.1",
26+
"tracy/tracy": "^2.10",
2827
"webmozart/glob": "^4.1"
2928
},
3029

@@ -61,7 +60,7 @@
6160
"minimum-stability": "stable",
6261
"extra": {
6362
"branch-alias": {
64-
"dev-master": "3.0-dev"
63+
"dev-master": "4.0-dev"
6564
}
6665
},
6766
"config": {

Diff for: demos/Demo/Annotation/Cacheable.php

-27
This file was deleted.

Diff for: demos/Demo/Aspect/CachingAspect.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
namespace Demo\Aspect;
1414

15-
use Demo\Annotation\Cacheable;
15+
use Demo\Attribute\Cacheable;
1616
use Go\Aop\Aspect;
1717
use Go\Aop\Intercept\MethodInvocation;
18-
use Go\Lang\Annotation\Around;
18+
use Go\Lang\Attribute\Around;
1919

2020
/**
2121
* Caching aspect
@@ -29,12 +29,9 @@ class CachingAspect implements Aspect
2929
* then invoke original method and store it's result in the cache.
3030
*
3131
* Real-life examples will use APC or Memcache to store value in the cache
32-
*
33-
* @return mixed Result of invocation
34-
*
35-
* @Around("@execution(Demo\Annotation\Cacheable)")
3632
*/
37-
public function aroundCacheable(MethodInvocation $invocation)
33+
#[Around('@execution(Demo\Attribute\Cacheable)')]
34+
protected function aroundCacheable(MethodInvocation $invocation): mixed
3835
{
3936
static $memoryCache = [];
4037

@@ -44,8 +41,8 @@ public function aroundCacheable(MethodInvocation $invocation)
4441
$class = is_object($obj) ? get_class($obj) : $obj;
4542
$key = $class . ':' . $invocation->getMethod()->name;
4643
if (!isset($memoryCache[$key])) {
47-
// We can use ttl value from annotation, but Doctrine annotations doesn't work under GAE
48-
echo "Ttl is: ", $invocation->getMethod()->getAnnotation(Cacheable::class)->time, PHP_EOL;
44+
$attributeArgs = $invocation->getMethod()->getAttributes(Cacheable::class)[0]->getArguments();
45+
echo "Ttl is: ", $attributeArgs['time'], PHP_EOL;
4946

5047
$memoryCache[$key] = $invocation->proceed();
5148
}

Diff for: demos/Demo/Aspect/DeclareErrorAspect.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace Demo\Aspect;
1414

1515
use Go\Aop\Aspect;
16-
use Go\Lang\Annotation\DeclareError;
16+
use Go\Lang\Attribute\DeclareError;
1717

1818
/**
1919
* This aspect can be very useful for development to generate an error when executing prohibited methods
@@ -22,15 +22,13 @@ class DeclareErrorAspect implements Aspect
2222
{
2323
/**
2424
* Message to show when calling the method
25-
*
26-
* @DeclareError("@execution(Demo\Annotation\Deprecated)", level=16384) // E_USER_DEPRECATED
2725
*/
26+
#[DeclareError('@execution(Demo\Attribute\Deprecated)', level: E_USER_DEPRECATED)]
2827
protected string $message = 'Method is deprecated and should not be called in debug mode';
2928

3029
/**
3130
* Prevent developers from using this method by always generating a warning
32-
*
33-
* @DeclareError("execution(public Demo\Example\ErrorDemo->notSoGoodMethod(*))", level=512) // E_USER_WARNING
3431
*/
32+
#[DeclareError('execution(public Demo\Example\ErrorDemo->notSoGoodMethod(*))', level: E_USER_WARNING)]
3533
protected string $badMethod = 'Method can generate division by zero! Do not use it!';
3634
}

Diff for: demos/Demo/Aspect/DynamicMethodsAspect.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use Go\Aop\Aspect;
1616
use Go\Aop\Intercept\MethodInvocation;
17-
use Go\Lang\Annotation\Before;
17+
use Go\Lang\Attribute\Before;
1818

1919
/**
2020
* Aspect that intercepts specific magic methods, declared with __call and __callStatic
@@ -26,9 +26,8 @@ class DynamicMethodsAspect implements Aspect
2626
*
2727
* Unlike traditional "execution" pointcut, "dynamic" is checking the name of method in
2828
* the runtime, allowing to write interceptors for __call more transparently.
29-
*
30-
* @Before("dynamic(public Demo\Example\DynamicMethodsDemo->save*(*))")
3129
*/
30+
#[Before('dynamic(public Demo\Example\DynamicMethodsDemo->save*(*))')]
3231
public function beforeMagicMethodExecution(MethodInvocation $invocation): void
3332
{
3433
// we need to unpack args from invocation args
@@ -45,10 +44,8 @@ public function beforeMagicMethodExecution(MethodInvocation $invocation): void
4544

4645
/**
4746
* This advice intercepts an execution of methods via __callStatic
48-
*
49-
* @param MethodInvocation $invocation
50-
* @Before("dynamic(public Demo\Example\DynamicMethodsDemo::find*(*))")
5147
*/
48+
#[Before('dynamic(public Demo\Example\DynamicMethodsDemo::find*(*))')]
5249
public function beforeMagicStaticMethodExecution(MethodInvocation $invocation): void
5350
{
5451
// we need to unpack args from invocation args

Diff for: demos/Demo/Aspect/FluentInterfaceAspect.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use Go\Aop\Aspect;
1616
use Go\Aop\Intercept\MethodInvocation;
17-
use Go\Lang\Annotation\Around;
17+
use Go\Lang\Attribute\Around;
1818

1919
/**
2020
* Fluent interface aspect provides an easy way to reuse "chain" interface for classes
@@ -29,12 +29,9 @@ class FluentInterfaceAspect implements Aspect
2929
{
3030
/**
3131
* Fluent interface advice
32-
*
33-
* @Around("within(Demo\Aspect\FluentInterface+) && execution(public **->set*(*))")
34-
*
35-
* @return mixed Result of invocation
3632
*/
37-
protected function aroundMethodExecution(MethodInvocation $invocation)
33+
#[Around('within(Demo\Aspect\FluentInterface+) && execution(public **->set*(*))')]
34+
protected function aroundMethodExecution(MethodInvocation $invocation): mixed
3835
{
3936
$result = $invocation->proceed();
4037

Diff for: demos/Demo/Aspect/FunctionInterceptorAspect.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use Go\Aop\Aspect;
1616
use Go\Aop\Intercept\FunctionInvocation;
17-
use Go\Lang\Annotation\Around;
17+
use Go\Lang\Attribute\Around;
1818

1919
/**
2020
* Function interceptor can intercept an access to the system functions
@@ -23,12 +23,9 @@ class FunctionInterceptorAspect implements Aspect
2323
{
2424
/**
2525
* This advice intercepts an access to the array_*** function in Demo\Example\ namespace
26-
*
27-
* @Around("execution(Demo\Example\array_*(*))")
28-
*
29-
* @return mixed
3026
*/
31-
public function aroundArrayFunctions(FunctionInvocation $invocation)
27+
#[Around('execution(Demo\Example\array_*(*))')]
28+
public function aroundArrayFunctions(FunctionInvocation $invocation): mixed
3229
{
3330
echo 'Calling Around Interceptor for ',
3431
$invocation,
@@ -41,9 +38,8 @@ public function aroundArrayFunctions(FunctionInvocation $invocation)
4138

4239
/**
4340
* This advice intercepts an access to the file_get_contents() function
44-
*
45-
* @Around("execution(Demo\Example\file_get_contents(*))")
4641
*/
42+
#[Around('execution(Demo\Example\file_get_contents(*))')]
4743
public function aroundFileGetContents(FunctionInvocation $invocation): string
4844
{
4945
echo 'Calling Around Interceptor for ',

Diff for: demos/Demo/Aspect/HealthyLiveAspect.php

+7-11
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
use Demo\Example\HumanDemo;
1616
use Go\Aop\Aspect;
1717
use Go\Aop\Intercept\MethodInvocation;
18-
use Go\Lang\Annotation\After;
19-
use Go\Lang\Annotation\Before;
20-
use Go\Lang\Annotation\Pointcut;
18+
use Go\Lang\Attribute\After;
19+
use Go\Lang\Attribute\Before;
20+
use Go\Lang\Attribute\Pointcut;
2121

2222
/**
2323
* Healthy live aspect
@@ -26,18 +26,16 @@ class HealthyLiveAspect implements Aspect
2626
{
2727
/**
2828
* Pointcut for eat method
29-
*
30-
* @Pointcut("execution(public Demo\Example\HumanDemo->eat(*))")
3129
*/
30+
#[Pointcut('execution(public Demo\Example\HumanDemo->eat(*))')]
3231
protected function humanEat(): void
3332
{
3433
}
3534

3635
/**
3736
* Washing hands before eating
38-
*
39-
* @Before("$this->humanEat")
4037
*/
38+
#[Before('$this->humanEat')]
4139
protected function washUpBeforeEat(MethodInvocation $invocation): void
4240
{
4341
/** @var $person HumanDemo */
@@ -47,9 +45,8 @@ protected function washUpBeforeEat(MethodInvocation $invocation): void
4745

4846
/**
4947
* Method that advices to clean the teeth after eating
50-
*
51-
* @After("$this->humanEat")
5248
*/
49+
#[After('$this->humanEat')]
5350
protected function cleanTeethAfterEat(MethodInvocation $invocation): void
5451
{
5552
/** @var $person HumanDemo */
@@ -59,9 +56,8 @@ protected function cleanTeethAfterEat(MethodInvocation $invocation): void
5956

6057
/**
6158
* Method that advice to clean the teeth before going to sleep
62-
*
63-
* @Before("execution(public Demo\Example\HumanDemo->sleep(*))")
6459
*/
60+
#[Before('execution(public Demo\Example\HumanDemo->sleep(*))')]
6561
protected function cleanTeethBeforeSleep(MethodInvocation $invocation): void
6662
{
6763
/** @var $person HumanDemo */

Diff for: demos/Demo/Aspect/IntroductionAspect.php

+9-12
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212

1313
namespace Demo\Aspect;
1414

15+
use Demo\Aspect\Introduce\SerializableImpl;
1516
use Go\Aop\Aspect;
16-
use Go\Lang\Annotation\DeclareParents;
17+
use Go\Lang\Attribute\DeclareParents;
18+
use Serializable;
1719

1820
/**
1921
* Introduction aspect can dynamically add new interfaces and traits to the class
@@ -22,16 +24,11 @@ class IntroductionAspect implements Aspect
2224
{
2325
/**
2426
* Add a single interface and trait to the class.
25-
*
26-
* You can also give several interfaces/traits via []
27-
*
28-
* @DeclareParents(
29-
* value="within(Demo\Example\IntroductionDemo)",
30-
* interface="Serializable",
31-
* defaultImpl="Demo\Aspect\Introduce\SerializableImpl"
32-
* )
33-
*
34-
* @var null
3527
*/
36-
protected $introduction;
28+
#[DeclareParents(
29+
'within(Demo\Example\IntroductionDemo)',
30+
interface: Serializable::class,
31+
trait: SerializableImpl::class
32+
)]
33+
protected null $introduction;
3734
}

Diff for: demos/Demo/Aspect/LoggingAspect.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use Go\Aop\Aspect;
1616
use Go\Aop\Intercept\MethodInvocation;
17-
use Go\Lang\Annotation\Before;
17+
use Go\Lang\Attribute\Before;
1818

1919
/**
2020
* Logging aspect
@@ -32,9 +32,8 @@ class LoggingAspect implements Aspect
3232
* Also you can choose "After" or "Around" advice to access an return value from method.
3333
*
3434
* To inject logger into this aspect you can look at Warlock framework with DI+AOP
35-
*
36-
* @Before("@execution(Demo\Annotation\Loggable)")
3735
*/
36+
#[Before("@execution(Demo\Attribute\Loggable)")]
3837
public function beforeMethodExecution(MethodInvocation $invocation): void
3938
{
4039
echo 'Calling Before Interceptor for ',

0 commit comments

Comments
 (0)