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

[Step 1] Bump requirement to PHP 8.2 and parser-reflection 4.0.0-RC1 #492

Merged
merged 40 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a0ea9b9
Bump requirement to PHP 8.2 and parser-reflection 4.0.0-RC1
samsonasik Feb 4, 2024
29ccdf1
bump github action to use php 8.2
samsonasik Feb 6, 2024
399213e
run github action on pull request
samsonasik Feb 6, 2024
7c5208a
bump to phpunit 10
samsonasik Feb 6, 2024
295a20f
bump to phpunit 10
samsonasik Feb 6, 2024
8dd74ee
migrate to new phpunit config
samsonasik Feb 6, 2024
5af067a
bump to phpunit 10 syntax
samsonasik Feb 6, 2024
f77096d
update signature params and returns
samsonasik Feb 6, 2024
a96572e
fixing signatures
samsonasik Feb 7, 2024
e71dd12
fix var_dump() signature
samsonasik Feb 7, 2024
584f523
remove ignore error
samsonasik Feb 7, 2024
9d55bcc
Fix AbstractJoinpointTest static usage
samsonasik Feb 7, 2024
626730e
Revert "Fix AbstractJoinpointTest static usage"
samsonasik Feb 7, 2024
febb3df
fix var_dumps() test
samsonasik Feb 7, 2024
c8a5be6
use phpstan baseline
samsonasik Feb 10, 2024
b57082d
ignore generated phpstan-baseline.php
samsonasik Feb 10, 2024
c675e82
bump laminas-code and add tracy for debugging
samsonasik Feb 10, 2024
869549e
bump to phpunit 10.5.10
samsonasik Feb 10, 2024
5f5dd7d
use AllowDynamicProperties on CachedAspectLoader
samsonasik Feb 10, 2024
1cd6f43
fix abstract test class warning
samsonasik Feb 10, 2024
b76ab5e
fix warning on abstract class BaseFunctionalTest
samsonasik Feb 10, 2024
a1d357c
update to use walterwoshid/dissect
samsonasik Feb 18, 2024
906890c
Remove deprecated Serializable interface.
lisachenko Feb 18, 2024
8b0786e
Switch to the goaop/dissect library
lisachenko Feb 18, 2024
f75614d
Enable AllowDynamicProperties for the LazyAdvisorAccessor to avoid de…
lisachenko Feb 18, 2024
1b78619
trigger CI
samsonasik Feb 18, 2024
d3df92a
use 4.x-dev of parser-reflection
samsonasik Feb 18, 2024
daae991
Bump the goaop/dissect to the stable ^3.0 version
lisachenko Feb 19, 2024
ff11d07
Implement PHP8.1 never return type
lisachenko Feb 29, 2024
41debc1
Switch to the PhpToken native tokens and migrate to php-parser version 5
lisachenko Mar 18, 2024
612add9
Fix deprecation warning on PHP8.3 version
lisachenko Mar 18, 2024
5c1341b
Remove unused setAccessible() call for Reflection
lisachenko Mar 18, 2024
5c85d48
[BC BREAK] Remove AnnotationAccess interface and implementations.
lisachenko Mar 18, 2024
f2d5c9e
Switch framework from matching annotations to attributes
lisachenko Mar 18, 2024
5854b55
Rename Lang\Annotation into Lang\Attribute namespace
lisachenko Mar 19, 2024
a8a5ada
[BC Break] Switch framework from annotations to attributes
lisachenko Mar 20, 2024
6f10288
Fix an error in test, array was used instead of PhpToken DTO
lisachenko Mar 21, 2024
a3e0e4b
Bump composer dev-master alias to 4.x
lisachenko Mar 26, 2024
67ed310
Remove deprecated ReflectionFunction->isDisabled() call
lisachenko Mar 26, 2024
872633c
Fix phpstan error with unknown property
lisachenko Mar 31, 2024
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
7 changes: 4 additions & 3 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: "PHPStan analysis"

on:
pull_request:
push:

jobs:
Expand All @@ -12,7 +13,7 @@ jobs:
- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
php-version: "8.2"
ini-values: memory_limit=-1
tools: composer:v2
- name: "Cache dependencies"
Expand All @@ -21,8 +22,8 @@ jobs:
path: |
~/.composer/cache
vendor
key: "php-7.4"
restore-keys: "php-7.4"
key: "php-8.2"
restore-keys: "php-8.2"
- name: "Install dependencies"
run: "composer install --no-interaction --no-progress --no-suggest"
- name: "Static analysis"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: "PHPUnit tests"

on:
pull_request:
push:

jobs:
Expand All @@ -15,7 +16,7 @@ jobs:
- "lowest"
- "highest"
php-version:
- "7.4"
- "8.2"
operating-system:
- "ubuntu-latest"

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.lock
phpunit.xml
tests/Fixtures/project/var/cache/*
build/
/.phpunit.result.cache
19 changes: 9 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,22 @@
"license": "MIT",

"require": {
"php": "^7.4.0",
"doctrine/annotations": "^1.11.1",
"doctrine/cache": "^1.10",
"goaop/parser-reflection": "^3.0.1",
"jakubledl/dissect": "~1.0",
"laminas/laminas-code": "^4.0",
"symfony/finder": "^4.4|^5.1"
"php": "^8.2.0",
"goaop/parser-reflection": "4.x-dev",
"goaop/dissect": "^3.0",
"laminas/laminas-code": "^4.13",
"symfony/finder": "^5.1"
},

"require-dev": {
"adlawson/vfs": "^0.12.1",
"doctrine/orm": "^2.5",
"phpstan/phpstan": "^0.12.64",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.10.57",
"phpunit/phpunit": "^10.5.10",
"symfony/console": "^4.4|^5.1",
"symfony/filesystem": "^4.4|^5.1",
"symfony/process": "^4.4|^5.1",
"tracy/tracy": "^2.10",
"webmozart/glob": "^4.1"
},

Expand Down Expand Up @@ -61,7 +60,7 @@
"minimum-stability": "stable",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "4.0-dev"
}
},
"config": {
Expand Down
27 changes: 0 additions & 27 deletions demos/Demo/Annotation/Cacheable.php

This file was deleted.

15 changes: 6 additions & 9 deletions demos/Demo/Aspect/CachingAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

namespace Demo\Aspect;

use Demo\Annotation\Cacheable;
use Demo\Attribute\Cacheable;
use Go\Aop\Aspect;
use Go\Aop\Intercept\MethodInvocation;
use Go\Lang\Annotation\Around;
use Go\Lang\Attribute\Around;

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

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

$memoryCache[$key] = $invocation->proceed();
}
Expand Down
8 changes: 3 additions & 5 deletions demos/Demo/Aspect/DeclareErrorAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace Demo\Aspect;

use Go\Aop\Aspect;
use Go\Lang\Annotation\DeclareError;
use Go\Lang\Attribute\DeclareError;

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

/**
* Prevent developers from using this method by always generating a warning
*
* @DeclareError("execution(public Demo\Example\ErrorDemo->notSoGoodMethod(*))", level=512) // E_USER_WARNING
*/
#[DeclareError('execution(public Demo\Example\ErrorDemo->notSoGoodMethod(*))', level: E_USER_WARNING)]
protected string $badMethod = 'Method can generate division by zero! Do not use it!';
}
9 changes: 3 additions & 6 deletions demos/Demo/Aspect/DynamicMethodsAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use Go\Aop\Aspect;
use Go\Aop\Intercept\MethodInvocation;
use Go\Lang\Annotation\Before;
use Go\Lang\Attribute\Before;

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

/**
* This advice intercepts an execution of methods via __callStatic
*
* @param MethodInvocation $invocation
* @Before("dynamic(public Demo\Example\DynamicMethodsDemo::find*(*))")
*/
#[Before('dynamic(public Demo\Example\DynamicMethodsDemo::find*(*))')]
public function beforeMagicStaticMethodExecution(MethodInvocation $invocation): void
{
// we need to unpack args from invocation args
Expand Down
9 changes: 3 additions & 6 deletions demos/Demo/Aspect/FluentInterfaceAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use Go\Aop\Aspect;
use Go\Aop\Intercept\MethodInvocation;
use Go\Lang\Annotation\Around;
use Go\Lang\Attribute\Around;

/**
* Fluent interface aspect provides an easy way to reuse "chain" interface for classes
Expand All @@ -29,12 +29,9 @@ class FluentInterfaceAspect implements Aspect
{
/**
* Fluent interface advice
*
* @Around("within(Demo\Aspect\FluentInterface+) && execution(public **->set*(*))")
*
* @return mixed Result of invocation
*/
protected function aroundMethodExecution(MethodInvocation $invocation)
#[Around('within(Demo\Aspect\FluentInterface+) && execution(public **->set*(*))')]
protected function aroundMethodExecution(MethodInvocation $invocation): mixed
{
$result = $invocation->proceed();

Expand Down
12 changes: 4 additions & 8 deletions demos/Demo/Aspect/FunctionInterceptorAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use Go\Aop\Aspect;
use Go\Aop\Intercept\FunctionInvocation;
use Go\Lang\Annotation\Around;
use Go\Lang\Attribute\Around;

/**
* Function interceptor can intercept an access to the system functions
Expand All @@ -23,12 +23,9 @@ class FunctionInterceptorAspect implements Aspect
{
/**
* This advice intercepts an access to the array_*** function in Demo\Example\ namespace
*
* @Around("execution(Demo\Example\array_*(*))")
*
* @return mixed
*/
public function aroundArrayFunctions(FunctionInvocation $invocation)
#[Around('execution(Demo\Example\array_*(*))')]
public function aroundArrayFunctions(FunctionInvocation $invocation): mixed
{
echo 'Calling Around Interceptor for ',
$invocation,
Expand All @@ -41,9 +38,8 @@ public function aroundArrayFunctions(FunctionInvocation $invocation)

/**
* This advice intercepts an access to the file_get_contents() function
*
* @Around("execution(Demo\Example\file_get_contents(*))")
*/
#[Around('execution(Demo\Example\file_get_contents(*))')]
public function aroundFileGetContents(FunctionInvocation $invocation): string
{
echo 'Calling Around Interceptor for ',
Expand Down
18 changes: 7 additions & 11 deletions demos/Demo/Aspect/HealthyLiveAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use Demo\Example\HumanDemo;
use Go\Aop\Aspect;
use Go\Aop\Intercept\MethodInvocation;
use Go\Lang\Annotation\After;
use Go\Lang\Annotation\Before;
use Go\Lang\Annotation\Pointcut;
use Go\Lang\Attribute\After;
use Go\Lang\Attribute\Before;
use Go\Lang\Attribute\Pointcut;

/**
* Healthy live aspect
Expand All @@ -26,18 +26,16 @@ class HealthyLiveAspect implements Aspect
{
/**
* Pointcut for eat method
*
* @Pointcut("execution(public Demo\Example\HumanDemo->eat(*))")
*/
#[Pointcut('execution(public Demo\Example\HumanDemo->eat(*))')]
protected function humanEat(): void
{
}

/**
* Washing hands before eating
*
* @Before("$this->humanEat")
*/
#[Before('$this->humanEat')]
protected function washUpBeforeEat(MethodInvocation $invocation): void
{
/** @var $person HumanDemo */
Expand All @@ -47,9 +45,8 @@ protected function washUpBeforeEat(MethodInvocation $invocation): void

/**
* Method that advices to clean the teeth after eating
*
* @After("$this->humanEat")
*/
#[After('$this->humanEat')]
protected function cleanTeethAfterEat(MethodInvocation $invocation): void
{
/** @var $person HumanDemo */
Expand All @@ -59,9 +56,8 @@ protected function cleanTeethAfterEat(MethodInvocation $invocation): void

/**
* Method that advice to clean the teeth before going to sleep
*
* @Before("execution(public Demo\Example\HumanDemo->sleep(*))")
*/
#[Before('execution(public Demo\Example\HumanDemo->sleep(*))')]
protected function cleanTeethBeforeSleep(MethodInvocation $invocation): void
{
/** @var $person HumanDemo */
Expand Down
21 changes: 9 additions & 12 deletions demos/Demo/Aspect/IntroductionAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

namespace Demo\Aspect;

use Demo\Aspect\Introduce\SerializableImpl;
use Go\Aop\Aspect;
use Go\Lang\Annotation\DeclareParents;
use Go\Lang\Attribute\DeclareParents;
use Serializable;

/**
* Introduction aspect can dynamically add new interfaces and traits to the class
Expand All @@ -22,16 +24,11 @@ class IntroductionAspect implements Aspect
{
/**
* Add a single interface and trait to the class.
*
* You can also give several interfaces/traits via []
*
* @DeclareParents(
* value="within(Demo\Example\IntroductionDemo)",
* interface="Serializable",
* defaultImpl="Demo\Aspect\Introduce\SerializableImpl"
* )
*
* @var null
*/
protected $introduction;
#[DeclareParents(
'within(Demo\Example\IntroductionDemo)',
interface: Serializable::class,
trait: SerializableImpl::class
)]
protected null $introduction;
}
5 changes: 2 additions & 3 deletions demos/Demo/Aspect/LoggingAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use Go\Aop\Aspect;
use Go\Aop\Intercept\MethodInvocation;
use Go\Lang\Annotation\Before;
use Go\Lang\Attribute\Before;

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