Skip to content

Initial basic implementation #1

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 10 commits into from
Feb 17, 2018
Merged

Initial basic implementation #1

merged 10 commits into from
Feb 17, 2018

Conversation

asgrim
Copy link
Member

@asgrim asgrim commented Oct 27, 2017

No description provided.


foreach ($oldApi->getAllClasses() as $oldClass) {
try {
$newClass = $newApi->reflect($oldClass->getName());
Copy link
Member

Choose a reason for hiding this comment

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

This approach only looks for BC breaks, not API additions

Copy link

Choose a reason for hiding this comment

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

As I understand, this one is to look for public API removal, see catch.

@asgrim
Copy link
Member Author

asgrim commented Oct 27, 2017

Jeez man, gimme a break, I literally just started this :P

continue;
}

foreach ($oldClass->getMethods() as $oldMethod) {
Copy link
Member

Choose a reason for hiding this comment

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

To be isolated into a private method

continue;
}

foreach ($oldMethod->getParameters() as $oldParameter) {
Copy link
Member

Choose a reason for hiding this comment

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

And again

}

foreach ($oldMethod->getParameters() as $oldParameter) {
$newParameter = $newMethod->getParameter($oldParameter->getName());
Copy link
Member

Choose a reason for hiding this comment

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

The parameter should not be fetched by name, but by position. A simple test of a BC compliant change is:

before:

function foo(int $a, string $b) {}

after:

function foo(int $b, string $a) {}

Also, a rename per-se does not cause a BC break:

before:

function foo(int $a, string $b) {}

after:

function foo(int $a, string $c) {}

@asgrim asgrim force-pushed the initial-basic-implementation branch from 4475b2c to f6d4790 Compare October 27, 2017 12:58
@Ocramius
Copy link
Member

Ocramius commented Oct 27, 2017

gimme a break

rageface

Copy link

@samdark samdark left a comment

Choose a reason for hiding this comment

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

Great idea. I think supporting http://symfony.com/doc/current/contributing/code/bc.html would be really good.

@asgrim
Copy link
Member Author

asgrim commented Oct 31, 2017

@samdark thanks for your comments; it's still a little way off yet, hopefully I'll find time soon to work on this again :)

@asgrim asgrim requested a review from Ocramius January 28, 2018 11:03
@asgrim asgrim assigned Ocramius and unassigned asgrim Jan 28, 2018
@asgrim asgrim removed the WIP label Jan 28, 2018

final class Comparator
{
public function compare(ClassReflector $oldApi, ClassReflector $newApi): array
Copy link
Member

Choose a reason for hiding this comment

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

Do we only compare classes?

Copy link
Member

Choose a reason for hiding this comment

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

Return type array is too limited

Copy link
Member Author

Choose a reason for hiding this comment

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

For now yes, if you want to support functions, add an issue :P

return $changelog;
}

private function examineClass(array $changelog, ReflectionClass $oldClass, ClassReflector $newApi): array
Copy link
Member

Choose a reason for hiding this comment

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

Can we avoid returning array?


final class Comparator
{
public function compare(ClassReflector $oldApi, ClassReflector $newApi): array
Copy link
Member

Choose a reason for hiding this comment

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

Return type array is too limited

ReflectionClass $oldClass,
ReflectionMethod $oldMethod,
ReflectionClass $newClass
): array {
Copy link
Member

Choose a reason for hiding this comment

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

Same here: array is too limited

@asgrim asgrim added this to the 0.0.1 milestone Feb 17, 2018
@asgrim
Copy link
Member Author

asgrim commented Feb 17, 2018

Created #13 to discuss the actual API to be used further 👍 for now merging so other functionality can start to be added

@asgrim asgrim merged commit 4123136 into master Feb 17, 2018
@asgrim asgrim deleted the initial-basic-implementation branch February 17, 2018 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants