Skip to content

Commit

Permalink
Merge pull request #210 from marcovtwout/php8-compatibility
Browse files Browse the repository at this point in the history
PHP 8.2 compatibility
  • Loading branch information
Naktibalda authored Nov 16, 2024
2 parents bec82f5 + 37a8f26 commit 7247230
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
}
},
"require": {
"php": "^7.4",
"goaop/framework": "^3.0",
"php": "^8.2",
"goaop/framework": "^4.0@dev",
"goaop/parser-reflection": "^4.0@dev",
"phpunit/phpunit": "^9.5",
"symfony/finder": "^4.4 | ^5.4 | ^6.0"
},
Expand All @@ -24,5 +25,10 @@
"codeception/verify": "^2.2",
"codeception/specify": "^2.0",
"consolidation/robo": "^3.0"
},
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
}
}
}
4 changes: 2 additions & 2 deletions src/AspectMock/Intercept/BeforeMockTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public function transform(StreamMetaData $metadata): string
$beforeDefinition = sprintf($beforeDefinition, $params);
$tokenPosition = $method->getNode()->getAttribute('startTokenPos');
do {
if (($metadata->tokenStream[$tokenPosition][1] ?? '') === '{') {
$metadata->tokenStream[$tokenPosition][1] .= $beforeDefinition;
if (($metadata->tokenStream[$tokenPosition]->text ?? '') === '{') {
$metadata->tokenStream[$tokenPosition]->text .= $beforeDefinition;
$result = self::RESULT_TRANSFORMED;
break;
}
Expand Down
9 changes: 6 additions & 3 deletions src/AspectMock/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use AspectMock\Intercept\BeforeMockTransformer;
use Go\Core\AspectContainer;
use Go\Core\AspectKernel;
use Go\Core\AdviceMatcher;
use Go\Core\CachedAspectLoader;
use Go\Instrument\ClassLoading\CachePathManager;
use Go\Instrument\ClassLoading\SourceTransformingLoader;
use Go\Instrument\Transformer\CachingTransformer;
use Go\Instrument\Transformer\FilterInjectorTransformer;
Expand Down Expand Up @@ -61,16 +64,16 @@ public function loadFile(string $file)

protected function registerTransformers(): array
{
$cachePathManager = $this->getContainer()->get('aspect.cache.path.manager');
$cachePathManager = $this->getContainer()->getService(CachePathManager::class);

$sourceTransformers = [
new FilterInjectorTransformer($this, SourceTransformingLoader::getId(), $cachePathManager),
new MagicConstantTransformer($this),
new BeforeMockTransformer(
$this,
$this->getContainer()->get('aspect.advice_matcher'),
$this->getContainer()->getService(AdviceMatcher::class),
$cachePathManager,
$this->getContainer()->get('aspect.cached.loader')
$this->getContainer()->getService(CachedAspectLoader::class)
)
];

Expand Down

0 comments on commit 7247230

Please sign in to comment.