Skip to content
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

Mark classes as internal that nobody should be depending on. #711

Merged
merged 1 commit into from
May 31, 2018

Conversation

jwage
Copy link
Member

@jwage jwage commented May 31, 2018

Q A
Type improvement
BC Break no
Fixed issues #710

Summary

Mark classes as internal that nobody should be depending on. The only thing I see that people should be depending on are:

  • Doctrine\Migrations\Configuration\Configuration
  • Doctrine\Migrations\Events
  • Doctrine\Migrations\Finder\MigrationFinder
  • Doctrine\Migrations\Provider\SchemaProviderInterface
  • Doctrine\Migrations\Provider\StubSchemaProvider
  • Doctrine\Migrations\AbstractMigration
    • isTransactional
    • getDescription
    • warnIf
    • abortIf
    • skipIf
    • preUp
    • postUp
    • preDown
    • postDown
    • up
    • down
    • addSql
    • write
    • throwIrreversibleMigrationException
  • Doctrine\Migrations\Tools\Console\Command\AbstractCommand
  • Doctrine\Migrations\Tools\Console\Command\DiffCommand
  • Doctrine\Migrations\Tools\Console\Command\DumpSchemaCommand
  • Doctrine\Migrations\Tools\Console\Command\ExecuteCommand
  • Doctrine\Migrations\Tools\Console\Command\GenerateCommand
  • Doctrine\Migrations\Tools\Console\Command\LatestCommand
  • Doctrine\Migrations\Tools\Console\Command\MigrateCommand
  • Doctrine\Migrations\Tools\Console\Command\RollupCommand
  • Doctrine\Migrations\Tools\Console\Command\StatusCommand
  • Doctrine\Migrations\Tools\Console\Command\UpToDateCommand
  • Doctrine\Migrations\Tools\Console\Command\VersionCommand

@jwage jwage added this to the 2.0 milestone May 31, 2018
@jwage jwage self-assigned this May 31, 2018
@jwage jwage requested review from stof and Majkl578 May 31, 2018 15:21
@jwage
Copy link
Member Author

jwage commented May 31, 2018

@Majkl578 @stof Can you take a look? Any classes I marked as internal that shouldn't be?

@jwage jwage force-pushed the internal-classes branch 2 times, most recently from 254d29a to 84eb10d Compare May 31, 2018 15:50
@@ -4,6 +4,9 @@

namespace Doctrine\Migrations\Configuration;

/**
* @internal
Copy link
Member

Choose a reason for hiding this comment

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

@jwage should these configuration classes really be internal ? How are they used then ?

Copy link
Member Author

Choose a reason for hiding this comment

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

They don't get used directly, they are a part of the internals of the console commands but are never used directly. They produce a Configuration instance that then gets used in the console commands.

Copy link
Member

Choose a reason for hiding this comment

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

should these classes actually be extending Configuration then ?

Copy link
Member Author

Choose a reason for hiding this comment

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

@stof arguably no, they should not. A better design would be to inject the Configuration in to ArrayConfiguration, etc. and then call the public getters on Configuration and have no inheritance at all. I could try tackling that refactoring in another PR.

@@ -4,6 +4,9 @@

namespace Doctrine\Migrations;

/**
* @internal
Copy link
Member

Choose a reason for hiding this comment

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

this must not be internal. The events are extension points of the library, so the event names need to be public (otherwise they are not usable).

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixing.

@@ -4,6 +4,9 @@

namespace Doctrine\Migrations\Finder;

/**
* @internal
Copy link
Member

Choose a reason for hiding this comment

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

Aren't these meant to be an extension point of the library ? Otherwise, how would people choose a different finder ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this shouldn't be internal. Changing it.

Copy link
Member

Choose a reason for hiding this comment

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

implementations should not be internal either. Otherwise, the only way to use the extension point is to write your own implementation from scratch, even if you want the same behavior than one of the built-in implementations (as you cannot use them due to being internal and so not covered by BC).

@@ -15,6 +15,9 @@
use function rtrim;
use function sprintf;

/**
* @internal
Copy link
Member

Choose a reason for hiding this comment

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

console helpers should not be internal either, as they must be registered in the CLI Application too (cli-config.php is expected to instantiate a HelperSet with the appropriate helpers in it)

Copy link
Member Author

Choose a reason for hiding this comment

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

To be honest I am not sure why this is a symfony console helper. It should not be. It is only used directly here as an internal dependency

$directoryHelper = new MigrationDirectoryHelper($this->configuration);

Copy link
Member

Choose a reason for hiding this comment

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

well, this one should not be a console helper then. But other console helpers should not be internal.

@@ -6,6 +6,9 @@

use Doctrine\DBAL\Schema\Schema;

/**
* @internal
Copy link
Member

Choose a reason for hiding this comment

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

isn't this meant to be an extension point ?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, only SchemaProviderInterface is an extension point that can be passed through here https://github.com/doctrine/migrations/blob/master/lib/Doctrine/Migrations/Tools/Console/Command/DiffCommand.php

I think the interface might have been created to ease unit testing whenever it was added.

Copy link
Member

Choose a reason for hiding this comment

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

the interface has been added because the lazy one is implemented through decoration

Copy link
Member Author

Choose a reason for hiding this comment

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

Understood. So I think this should not be public still, right?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, this one is OK. I confused it with SchemaProviderInterface

@jwage jwage force-pushed the internal-classes branch from 84eb10d to fd2428f Compare May 31, 2018 16:44
@@ -10,6 +10,9 @@
use UnexpectedValueException;
use function count;

/**
* @internal
Copy link
Member

Choose a reason for hiding this comment

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

should not be internal. ORM users should be able to use this implementation of the non-internal SchemaProviderInterface

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

If they don't provide their own schema provider that implements the SchemaProviderInterface then it uses the OrmSchemaProvider.

@jwage jwage force-pushed the internal-classes branch from fd2428f to 970e89f Compare May 31, 2018 16:51
@jwage jwage merged commit c2325fd into master May 31, 2018
@jwage jwage deleted the internal-classes branch May 31, 2018 18:15
@sserbin
Copy link
Contributor

sserbin commented Jan 31, 2019

@jwage was Doctrine\Migrations\Version\Version accidentally marked as @internal? (it's also not in a list in op)

It seems like it shouldn't have, as Doctrine\Migrations\Configuration::getMigrations() is public (as well as a few others Configuration's methods, accepting or returning Versions )

@lcobucci
Copy link
Member

@sserbin the implementation has been rightfully marked as @internal. It looks like we forgot to use the interface for those operations, though.

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.

4 participants