Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
Changelog
======

4.x-dev (Work in Progress)
* [Feature] Full PHP 8.2+ compatibility with comprehensive syntax support
* [Feature] Added PHP 8 compatibility tests and documentation
* [Feature] Support for PHP 8.0+ features: union types, named parameters, attributes, constructor property promotion, mixed type, static return type
* [Feature] Support for PHP 8.1+ features: readonly properties, enums, intersection types, never return type, final class constants
* [Feature] Support for PHP 8.2+ features: readonly classes, DNF types, null/false/true types, constants in traits
* [Documentation] Added UPGRADE-PHP8.md guide for PHP 8 migration
* [Known Issue] getConstants() filter parameter accepted but not fully implemented in parser-reflection dependency
* [BC BREAK] Minimum PHP version raised to 8.2

3.0.0 (December 4, 2019)
* [BC BREAK] Switched to the PHP7.2 and upper, strict types, return type hints and new syntax
* [BC BREAK] Removed the Joinpoint->getThis() method, as not all joinpoints belongs to classes (eg. FunctionInvocation)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ Installation

Go! AOP framework can be installed with composer. Installation is quite easy:

### Requirements

- **PHP 8.2+** (for PHP 8 compatibility details, see [UPGRADE-PHP8.md](UPGRADE-PHP8.md))
- **Composer** for dependency management

1. Download the framework using composer
2. Create an application aspect kernel
3. Configure the aspect kernel in the front controller
Expand Down
84 changes: 84 additions & 0 deletions UPGRADE-PHP8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# PHP 8 Compatibility Guide

This document outlines the PHP 8 compatibility status of the Go! AOP Framework and provides guidance for users upgrading to PHP 8+.

## Current Status

The Go! AOP Framework has been updated to support PHP 8.2+ and includes comprehensive support for PHP 8 language features:

- βœ… **PHP 8.0 Features**: Union types, named parameters, attributes, constructor property promotion, mixed type, static return type
- βœ… **PHP 8.1 Features**: Readonly properties, enums, intersection types, never return type, final class constants
- βœ… **PHP 8.2 Features**: Readonly classes, DNF types, null/false/true types, constants in traits
- βœ… **Basic Framework Functionality**: All core framework components work correctly with PHP 8+

## Known Issues

### getConstants() Method Filter Parameter

The `goaop/parser-reflection` dependency includes a compatibility implementation of `ReflectionClass::getConstants(?int $filter = null)` that accepts the PHP 8 filter parameter but **does not properly implement the filtering logic**.

**Impact**: Code that relies on filtering constants by visibility (public, protected, private) will receive all constants instead of filtered results.

**Example**:
```php
// This will return ALL constants instead of just public ones
$constants = $parserReflectionClass->getConstants(ReflectionClassConstant::IS_PUBLIC);
```

**Workaround**: If you need filtered constants, use the native PHP ReflectionClass when possible:
```php
// Use native reflection when the class is already loaded
$nativeReflection = new \ReflectionClass($className);
$publicConstants = $nativeReflection->getConstants(\ReflectionClassConstant::IS_PUBLIC);
```

## Requirements

- **PHP Version**: 8.2 or higher
- **Dependencies**:
- `goaop/parser-reflection`: 4.x-dev (PHP 8 compatible)
- `nikic/php-parser`: ^5.0
- Other dependencies are automatically resolved

## Migration from Older Versions

If you're upgrading from an older version of the framework that used `goaop/parser-reflection` 2.x:

1. **Update your composer.json**:
```json
{
"require": {
"goaop/framework": "^3.0",
"php": "^8.2"
}
}
```

2. **Run composer update**:
```bash
composer update
```

3. **Test your application** with the updated dependencies.

## Reporting Issues

If you encounter PHP 8 compatibility issues:

1. Verify you're using the latest version of the framework
2. Check that all dependencies are up to date
3. Review this guide for known issues
4. Report new issues on the [GitHub repository](https://github.com/goaop/framework/issues)

## Contributing

Help improve PHP 8 compatibility by:

- Testing the framework with your PHP 8+ applications
- Reporting compatibility issues
- Contributing test cases for new PHP features
- Submitting pull requests for fixes

---

*Last updated: 2025-07-09*
130 changes: 130 additions & 0 deletions bin/check-php8-compatibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/usr/bin/env php
<?php
/**
* Go! AOP Framework PHP 8 Compatibility Checker
*
* This script helps verify that your environment is properly configured
* for PHP 8 compatibility with the Go! AOP Framework.
*/

if (PHP_VERSION_ID < 80200) {
echo "❌ PHP 8.2+ is required. Current version: " . PHP_VERSION . "\n";
echo "Please upgrade to PHP 8.2 or higher.\n";
exit(1);
}

echo "βœ… PHP Version: " . PHP_VERSION . " (compatible)\n";

// Check if composer is available
$autoloadPath = __DIR__ . '/../vendor/autoload.php';
if (!file_exists($autoloadPath)) {
echo "❌ Composer dependencies not installed\n";
echo "Run: composer install\n";
exit(1);
}

require_once $autoloadPath;

echo "βœ… Composer autoloader available\n";

// Check parser-reflection version
try {
if (!class_exists('\Go\ParserReflection\ReflectionFile')) {
echo "❌ Parser-reflection library not available\n";
echo "Run: composer install\n";
exit(1);
}
$reflection = new \Go\ParserReflection\ReflectionFile(__FILE__);
echo "βœ… Parser-reflection library loaded\n";
} catch (Exception $e) {
echo "❌ Parser-reflection error: " . $e->getMessage() . "\n";
exit(1);
}

// Test getConstants compatibility
echo "\n--- Testing getConstants() PHP 8 compatibility ---\n";

$testCode = '<?php
namespace CompatTest;
class TestClass {
const PUBLIC_CONST = "public";
protected const PROTECTED_CONST = "protected";
private const PRIVATE_CONST = "private";
}';

$testFile = sys_get_temp_dir() . '/compat_test.php';
file_put_contents($testFile, $testCode);

try {
$reflectionFile = new \Go\ParserReflection\ReflectionFile($testFile);
include_once $testFile;

$namespace = $reflectionFile->getFileNamespace('CompatTest');
$class = $namespace->getClass('CompatTest\TestClass');

$allConstants = $class->getConstants();
$publicConstants = $class->getConstants(\ReflectionClassConstant::IS_PUBLIC);

echo " All constants: " . count($allConstants) . "\n";
echo " Public constants (with filter): " . count($publicConstants) . "\n";

if (count($publicConstants) === count($allConstants)) {
echo " ⚠️ Filter parameter accepted but not properly implemented\n";
echo " This is a known issue. See UPGRADE-PHP8.md for details.\n";
} else {
echo " βœ… Filter parameter working correctly\n";
}

} catch (Exception $e) {
echo "❌ Error testing getConstants(): " . $e->getMessage() . "\n";
} finally {
unlink($testFile);
}

// Test PHP 8 syntax parsing
echo "\n--- Testing PHP 8 syntax parsing ---\n";

$syntaxTests = [
'Union Types' => '<?php class Test { public string|int $prop; }',
'Attributes' => '<?php #[\Attribute] class A {} #[A] class B {}',
'Named Parameters' => '<?php class Test { function f($a = "", $b = "") {} function g() { $this->f(b: "x", a: "y"); } }',
];

foreach ($syntaxTests as $name => $code) {
$testFile = sys_get_temp_dir() . '/syntax_test_' . md5($name) . '.php';
file_put_contents($testFile, $code);

try {
new \Go\ParserReflection\ReflectionFile($testFile);
echo " βœ… $name\n";
} catch (Exception $e) {
echo " ❌ $name: " . $e->getMessage() . "\n";
} finally {
unlink($testFile);
}
}

echo "\n--- Framework Core Classes ---\n";

// Test core framework classes
$coreClasses = [
'Go\Core\AdviceMatcher',
'Go\Instrument\Transformer\MagicConstantTransformer',
'Go\Aop\Pointcut\TruePointcut',
];

foreach ($coreClasses as $className) {
try {
$reflection = new ReflectionClass($className);
echo " βœ… $className\n";
} catch (Exception $e) {
echo " ❌ $className: " . $e->getMessage() . "\n";
}
}

echo "\nπŸŽ‰ PHP 8 compatibility check complete!\n";
echo "\nFor detailed information about PHP 8 compatibility, see:\n";
echo " - UPGRADE-PHP8.md\n";
echo " - CHANGELOG.md\n";
echo "\nIf you encounter issues, please report them at:\n";
echo " https://github.com/goaop/framework/issues\n";
Loading
Loading