Skip to content

Version 2.0.0 of Go! AOP Framework

Compare
Choose a tag to compare
@lisachenko lisachenko released this 14 May 12:24
· 379 commits to master since this release
2.0.0

Here it is! Shiny 2.0.0 version!

This version contains a lot of fixes and improvements:

  • Added a support for the PHP5.6 and 7.0 features: variadic arguments for methods, scalar type hints, return type hints
  • Migrated from the Andrewswille/Token-Reflection to the goaop/parser-reflection library for PHP5.6 and PHP7.0 support
  • Command-line tools for debugging aspects and advisors
  • Dropped support for PHP<5.6, cleaned all old code
  • [BC BREAK] Removed ability to rebind closures because of PHP restrictions, see #247
  • [BC BREAK] Removed getDefaultFeatures() method from the AspectKernel, no need in it since PHP5.6

Changes from the 1.x branch:

  • Fixed cache files permission, now all cache files will be created with given cache mode, resolves #275
  • Added context-sensitive matching that allows new checks #274 and resolves #272 by providing a new pointcut expression !matchInherited() to exclude all inherited methods from matching
  • Fixed logic for complex pointcut expressions, combined with OR logic, resolves #217
  • Fixed broken property interception generated source code for the constructor, resolves #271
  • Property interceptor now use trait for common logic as well returns values by reference, see #54 and #232

Pay attention, that some internal parts are changed, so be careful when updated. Also property interceptors logic is changed now and to modify values in advices, you should use returning by reference methods like following:

    /**
     * Advice that controls an access to the properties
     *
     * @param FieldAccess $fieldAccess Joinpoint
     *
     * @Around("access(public|protected Demo\Example\PropertyDemo->*)")
     * @return mixed
     */
    public function aroundFieldAccess(FieldAccess $fieldAccess)
    {
        $isRead = $fieldAccess->getAccessType() == FieldAccess::READ;
        // proceed all internal advices
        $fieldAccess->proceed();

        if ($isRead) {
            // if you want to change original property value, then return it by reference
            $value = /* & */$fieldAccess->getValue();
        } else {
            // if you want to change value to set, then return it by reference
            $value = /* & */$fieldAccess->getValueToSet();
        }

        echo $fieldAccess, ", value: ", json_encode($value), PHP_EOL;
    }