Skip to content

[Feature] Added support for class initializations asserts.#354

Merged
lisachenko merged 4 commits into
goaop:2.xfrom
RunOpenCode:feature/support-for-class-initialization-asserts
Aug 22, 2017
Merged

[Feature] Added support for class initializations asserts.#354
lisachenko merged 4 commits into
goaop:2.xfrom
RunOpenCode:feature/support-for-class-initialization-asserts

Conversation

@TheCelavi

Copy link
Copy Markdown
Contributor

Added support for class initializations asserts. Fixed documentation. Minor code improvements.

No BC breaks.

@TheCelavi TheCelavi requested a review from lisachenko August 22, 2017 10:24
@TheCelavi TheCelavi changed the base branch from master to 2.x August 22, 2017 10:26
@TheCelavi

Copy link
Copy Markdown
Contributor Author

Sorry, today is not my day...

@lisachenko

Copy link
Copy Markdown
Member

Sorry, today is not my day...

Hey, mate, everything is ok ) 👍 😄

/**
* Before class instance initialization.
*
* @Pointcut\Before("initialization(Go\Tests\TestProject\Application\Main)")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fragile joinpoint, maybe we shouldn't use it in framework at all? And just leave it as experimental feature with special configuration?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know about that, however, I know that if we have it in code, we should have way to test it. Right?

/**
* After class initialization.
*
* @Pointcut\Before("staticinitialization(Go\Tests\TestProject\Application\Main)")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment name and method name "After" differs from the actual pointcut type, which is "Before"

}

$wovenAdvisorIdentifiers = $this->getWovenAdvisorIdentifiers($other->getClass());
$reflectionClass = ReflectionClass::create($other->getClass(), $this->configuration);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what is this? I can't remember ::create() method in the ReflectionClass.

UPD1 Ah, ok, you have introduced new helper class for that. Maybe rename it to more meaningful name to prevent collision with native ReflectionClass and same class from goaop/parser-reflection? I would vote for ProxyClassReflectionHelper or similar.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, lets make it util class/factory class, that is its purpose.

Comment thread tests/Go/PhpUnit/ReflectionClass.php Outdated
use Go\ParserReflection\ReflectionEngine;
use Go\ParserReflection\ReflectionFile;

final class ReflectionClass extends BaseReflectionClass

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename it to the ProxyReflectionClass? To prevent collision in names with original ReflectionClass

$advisorIdentifier,
$index
);
$constraint = new ClassMemberWovenConstraint($this->configuration);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I like how one single constraint class now handles every assertion.

*
* @Pointcut\Before("staticinitialization(Go\Tests\TestProject\Application\Main)")
*/
public function afterClassStaticInitialization()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about method name itself and method body? ) It's unmatched with doc block and pointcut

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is seriously wrong with my brain today... sorry. I am going to close up for today, no use for me to keep working... :D

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's always cool to have some time for relax 👍 Don't hurry, this project is maintained for 6 years ) Just keep going slowly

// noop
}

public static function createReflectionClass($className, array $configuration)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc block for typehint and IDE?

use Go\ParserReflection\ReflectionEngine;
use Go\ParserReflection\ReflectionFile;

final class ProxyClassReflectionHelper

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing doc block?

@lisachenko

Copy link
Copy Markdown
Member

Looks good!

@lisachenko lisachenko merged commit 96afb72 into goaop:2.x Aug 22, 2017
@lisachenko lisachenko changed the title [FEATURE] Added support for class initializations asserts. [Feature] Added support for class initializations asserts. Aug 22, 2017
@lisachenko lisachenko added this to the 2.x milestone Aug 22, 2017
@lisachenko

Copy link
Copy Markdown
Member

BTW,
This block:

        if (null === $wovenAdvisorIdentifiers) { // there are no advisor identifiers
            return true;
        }

        if (!isset($wovenAdvisorIdentifiers[$target])) {
            return true;
        }

        if (!isset($wovenAdvisorIdentifiers[$target][$other->getSubject()])) {
            return true;
        }

can be replaced with one single check

        if (!isset($wovenAdvisorIdentifiers[$target][$other->getSubject()])) {
            return true;
        }

Need to clean this block later in future PR.

lisachenko added a commit that referenced this pull request Aug 22, 2017
* origin/2.x:
  [Feature] Add support for class initializations asserts. (#354)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants