Skip to content

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

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 40 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from 34 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
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@
"license": "MIT",

"require": {
"php": "^7.4.0",
"php": "^8.2.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"
"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
8 changes: 4 additions & 4 deletions demos/Demo/Aspect/CachingAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

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;
Expand All @@ -32,7 +32,7 @@ class CachingAspect implements Aspect
*
* @return mixed Result of invocation
*
* @Around("@execution(Demo\Annotation\Cacheable)")
* @Around("@execution(Demo\Attribute\Cacheable)")
*/
public function aroundCacheable(MethodInvocation $invocation)
{
Expand All @@ -44,8 +44,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
2 changes: 1 addition & 1 deletion demos/Demo/Aspect/DeclareErrorAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ 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=16384) // E_USER_DEPRECATED
*/
protected string $message = 'Method is deprecated and should not be called in debug mode';

Expand Down
2 changes: 1 addition & 1 deletion demos/Demo/Aspect/LoggingAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class LoggingAspect implements Aspect
*
* 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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@
* with this source code in the file LICENSE.
*/

namespace Demo\Annotation;
namespace Demo\Attribute;

use Doctrine\Common\Annotations\Annotation;
use Attribute;

/**
* @Annotation
* @Target("METHOD")
*/
class Cacheable extends Annotation
#[Attribute(Attribute::TARGET_METHOD)]
readonly class Cacheable
{
/**
* Time to cache
*/
public int $time = 0;
public function __construct(public int $time) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
* with this source code in the file LICENSE.
*/

namespace Demo\Annotation;
namespace Demo\Attribute;

use Doctrine\Common\Annotations\Annotation;
use Attribute;

/**
* @Annotation
* @Target("METHOD")
*/
class Deprecated extends Annotation
#[Attribute(Attribute::TARGET_METHOD)]
class Deprecated extends \JetBrains\PhpStorm\Deprecated
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
* with this source code in the file LICENSE.
*/

namespace Demo\Annotation;
namespace Demo\Attribute;

use Doctrine\Common\Annotations\Annotation;
use Attribute;

/**
* @Annotation
* @Target("METHOD")
*/
class Loggable extends Annotation
#[Attribute(Attribute::TARGET_METHOD)]
class Loggable
{
}
8 changes: 2 additions & 6 deletions demos/Demo/Example/CacheableDemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Demo\Example;

use Demo\Annotation\Cacheable;
use Demo\Attribute\Cacheable;

/**
* Example class to show how to use caching with AOP
Expand All @@ -23,12 +23,8 @@ class CacheableDemo
* Returns a report and explicitly cache a result for future use
*
* In this example we use "Cacheable" annotation to explicit mark a method
*
* @param string $from This can be any value
* @Cacheable(time=10)
*
* @return string
*/
#[Cacheable(time: 10)]
public function getReport(string $from): string
{
// long calculation for 100ms
Expand Down
5 changes: 2 additions & 3 deletions demos/Demo/Example/ErrorDemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Demo\Example;

use Demo\Annotation\Deprecated as deprecated; // <== We import specific system annotation
use Demo\Attribute\Deprecated;

/**
* In this class we use system functions that will be intercepted by aspect
Expand All @@ -21,9 +21,8 @@ class ErrorDemo
{
/**
* Some old method that is used by system in production, but shouldn't be used for the new code
*
* @deprecated
*/
#[Deprecated]
public function oldMethod(): void
{
echo "Hello, I'm old method", PHP_EOL;
Expand Down
11 changes: 4 additions & 7 deletions demos/Demo/Example/LoggingDemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Demo\Example;

use Demo\Annotation\Loggable;
use Demo\Attribute\Loggable;

/**
* Example class to show how to use logging with AOP
Expand All @@ -23,10 +23,9 @@ class LoggingDemo
/**
* Executes a task and logs all incoming arguments
*
* @Loggable
*
* @param string $task Some specific argument
*/
#[Loggable]
public function execute(string $task): void
{
$this->perform($task, 'first');
Expand All @@ -36,11 +35,10 @@ public function execute(string $task): void
/**
* Protected method can be also loggable
*
* @Loggable
*
* @param string $task Specific task
* @param string $level
*/
#[Loggable]
protected function perform(string $task, string $level): void
{
// some logic here
Expand All @@ -49,10 +47,9 @@ protected function perform(string $task, string $level): void
/**
* Everything is possible with AOP, so static methods can be intercepted too
*
* @Loggable
*
* @param string $task Some specific argument
*/
#[Loggable]
public static function runByName(string $task): void
{
$instance = new static(); // Go! AOP requires LSB to work correctly
Expand Down
3 changes: 2 additions & 1 deletion nitpick.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"ignore": [
"tests/*"
"tests/*",
"phpstan-baseline.php"
]
}
20 changes: 20 additions & 0 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php declare(strict_types = 1);

$ignoreErrors = [];
$ignoreErrors[] = [
'message' => '#^Instanceof between stdClass and Go\\\\ParserReflection\\\\ReflectionFileNamespace will always evaluate to false\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Aop/Support/SimpleNamespaceFilter.php',
];
$ignoreErrors[] = [
'message' => '#^Property Doctrine\\\\ORM\\\\Mapping\\\\ClassMetadataInfo\\<object\\>\\:\\:\\$table \\(array\\{name\\: string, schema\\?\\: string, indexes\\?\\: array, uniqueConstraints\\?\\: array, options\\?\\: array\\<string, mixed\\>, quoted\\?\\: bool\\}\\) does not accept array\\{\\}\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Bridge/Doctrine/MetadataLoadInterceptor.php',
];
$ignoreErrors[] = [
'message' => '#^Call to function file_get_contents\\(\\) on a separate line has no effect\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Instrument/ClassLoading/CacheWarmer.php',
];

return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
includes:
- phpstan-baseline.php

parameters:
level: 4
paths:
Expand Down
47 changes: 21 additions & 26 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="./vendor/autoload.php">
<testsuites>
<testsuite name="Go! AOP Test Suite">
<directory>./tests/Go/</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory>./src/</directory>
</include>
<report>
<clover outputFile="./build/logs/clover.xml"/>
<crap4j outputFile="./build/logs/crap4j.xml"/>
<xml outputDirectory="./build/coverage/xml"/>
</report>
</coverage>


<logging>
<junit outputFile="./build/logs/junit.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" colors="true" bootstrap="./vendor/autoload.php">
<testsuites>
<testsuite name="Go! AOP Test Suite">
<directory>./tests/Go/</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<clover outputFile="./build/logs/clover.xml"/>
<crap4j outputFile="./build/logs/crap4j.xml"/>
<xml outputDirectory="./build/coverage/xml"/>
</report>
</coverage>
<logging>
<junit outputFile="./build/logs/junit.xml"/>
</logging>
<source>
<include>
<directory>./src/</directory>
</include>
</source>
</phpunit>
Loading
Loading