-
Notifications
You must be signed in to change notification settings - Fork 59
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
The changes in @internal classes shouldn't be ignored completely #256
Comments
Would need a reproducer: AFAIK, we already skip internal class analysis completely:
|
This is the gist of it. I'll see if I can put together a test. // library
class Parent1 extends Exception
{
}
class Parent2 extends Exception
{
}
/**
* @internal
*/
class Internal extends Parent1
{
}
function x() {
throw new Internal();
}
// consumer
try {
x();
} catch (Parent1 $e) {
} Breaking changes: - class Internal extends Parent1
+ class Internal extends Parent2 |
Hmm, I think it's a sufficient scenario: needs to be tried in integration first, to see whether the bug is in a specific change detector, or in the default configuration. |
Okay, then I'll leave it up to you. |
note that changing the parent from Parent1 to Parent2 would not be a BC break if Parent1 was internal (as the consumer should not rely on the Parent1 type) |
@stof I am not sure about that one: the API inherited by parents is still observable downstream. I'm also not sure why you'd inherit from an That would probably need to be tested separately. |
I tried this locally with a repo like following: commit a8aaf1f42c4157e76c29975ee31c0001ca8c5efa
Author: Marco Pivetta <[email protected]>
Date: Tue Jun 30 23:26:21 2020 +0200
Initial state
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..74f79fe
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,12 @@
+{
+ "name": "ocramius/example-apicompare",
+ "authors": [
+ {
+ "name": "Marco Pivetta",
+ "email": "[email protected]"
+ }
+ ],
+ "autoload": {
+ "classmap": ["src"]
+ }
+}
diff --git a/src/source.php b/src/source.php
new file mode 100644
index 0000000..4e1fd7a
--- /dev/null
+++ b/src/source.php
@@ -0,0 +1,16 @@
+<?php
+
+class Parent1
+{
+}
+
+class Parent2
+{
+}
+
+/**
+ * @internal
+ */
+class Internal extends Parent1
+{
+} commit b0c35e689841c509a6a3a69a71ee86d4446c7e2a
Author: Marco Pivetta <[email protected]>
Date: Wed Jul 1 01:05:20 2020 +0200
Breaking change
diff --git a/src/source.php b/src/source.php
index 4e1fd7a..4d928ca 100644
--- a/src/source.php
+++ b/src/source.php
@@ -11,6 +11,6 @@ class Parent2
/**
* @internal
*/
-class Internal extends Parent1
+class Internal extends Parent2
{
} The tool did not report breaking changes, so I probably need a more precise reproducer |
Well, this is the bug. It is a breaking change that should have been reported. |
Hmm, no, if the class is internal, it isn't covered by BC at all |
It's not about the class itself, it's about |
Aaaaah, I totally misunderstood the issue then. Will try again, bit not today at this point 😬 |
Hmm, we don't have any BC check on Few things come to mind:
Overall, the source of the BC break is not the internal class (which cannot be referenced in any way: consider it "private"), but rather the Right now, this library has no handling for |
@Ocramius the BC break is the fact that the internal class (the internal implementation of the exception being thrown) is not catched anymore by consuming code which is catching the public type |
Yep, I think this is to be checked by an |
An
@internal
class still may be used by the consuming code as one of its non-internal parent types. If a breaking change happens in the non-internal subset of the ancestry tree (e.g. the class loses one of its parents), it will affect the consumers of the class even if it's internal.See doctrine/dbal#4100 (comment).
The text was updated successfully, but these errors were encountered: