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

Compare to uncommitted changes #246

Open
sebastianbergmann opened this issue Jun 16, 2020 · 2 comments
Open

Compare to uncommitted changes #246

sebastianbergmann opened this issue Jun 16, 2020 · 2 comments

Comments

@sebastianbergmann
Copy link

It is confusing, at least to me, that this tool does not compare to the current state of the working copy and ignores uncommitted changes.

$ git status                                                                                           
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Token/Stream.php
	modified:   src/Token/Stream/CachingFactory.php

no changes added to commit (use "git add" and/or "git commit -a")
$ git diff
diff --git a/src/Token/Stream.php b/src/Token/Stream.php
index 513fc79..167bb36 100644
--- a/src/Token/Stream.php
+++ b/src/Token/Stream.php
@@ -290,7 +290,7 @@ public function getLinesOfCode()
         return $this->linesOfCode;
     }
 
-    public function rewind(): void
+    public function rewind()/*: void*/
     {
         $this->position = 0;
     }
@@ -319,7 +319,7 @@ public function current()
         return $this->tokens[$this->position];
     }
 
-    public function next(): void
+    public function next()/*: void*/
     {
         $this->position++;
     }
@@ -356,7 +356,7 @@ public function offsetGet($offset)
     /**
      * @param int $offset
      */
-    public function offsetSet($offset, $value): void
+    public function offsetSet($offset, $value)/*: void*/
     {
         $this->tokens[$offset] = $value;
     }
@@ -366,7 +366,7 @@ public function offsetSet($offset, $value): void
      *
      * @throws OutOfBoundsException
      */
-    public function offsetUnset($offset): void
+    public function offsetUnset($offset)/*: void*/
     {
         if (!$this->offsetExists($offset)) {
             throw new OutOfBoundsException(
@@ -387,7 +387,7 @@ public function offsetUnset($offset): void
      *
      * @throws OutOfBoundsException
      */
-    public function seek($position): void
+    public function seek($position)/*: void*/
     {
         $this->position = $position;
 
@@ -407,7 +407,7 @@ public function seek($position): void
      *
      * @param string $sourceCode
      */
-    protected function scan($sourceCode): void
+    protected function scan($sourceCode)/*: void*/
     {
         $id        = 0;
         $line      = 1;
@@ -468,7 +468,7 @@ protected function scan($sourceCode): void
                                       $this->linesOfCode['cloc'];
     }
 
-    protected function parse(): void
+    protected function parse()/*: void*/
     {
         $this->interfaces = [];
         $this->classes    = [];
diff --git a/src/Token/Stream/CachingFactory.php b/src/Token/Stream/CachingFactory.php
index b81f978..2c8d0e0 100644
--- a/src/Token/Stream/CachingFactory.php
+++ b/src/Token/Stream/CachingFactory.php
@@ -34,7 +34,7 @@ public static function get($filename)
     /**
      * @param string $filename
      */
-    public static function clear($filename = null): void
+    public static function clear($filename = null)/*: void*/
     {
         if (\is_string($filename)) {
             unset(self::$cache[$filename]);
$ ./tools/roave-backward-compatibility-check --from=4.0.0
Comparing from 72273e715ebf358a8d35ebf073739764ccc1be81 to c48f2716357fba91e107ab631d1fe972fc2e21a4...
Loading composer repositories with package information
Updating dependencies
Writing lock file
Loading composer repositories with package information
Updating dependencies
Writing lock file
PHP Deprecated:  Function ReflectionType::__toString() is deprecated in phar:///usr/local/src/php-token-stream/tools/roave-backward-compatibility-check/vendor/roave/better-reflection/src/SourceLocator/SourceStubber/ReflectionSourceStubber.php on line 478
PHP Deprecated:  Function ReflectionType::__toString() is deprecated in phar:///usr/local/src/php-token-stream/tools/roave-backward-compatibility-check/vendor/roave/better-reflection/src/SourceLocator/SourceStubber/ReflectionSourceStubber.php on line 478
PHP Deprecated:  Function ReflectionType::__toString() is deprecated in phar:///usr/local/src/php-token-stream/tools/roave-backward-compatibility-check/vendor/roave/better-reflection/src/SourceLocator/SourceStubber/ReflectionSourceStubber.php on line 478
PHP Deprecated:  Function ReflectionType::__toString() is deprecated in phar:///usr/local/src/php-token-stream/tools/roave-backward-compatibility-check/vendor/roave/better-reflection/src/SourceLocator/SourceStubber/ReflectionSourceStubber.php on line 478
[BC] CHANGED: The return type of PHP_Token_Stream#scan() changed from no type to void
[BC] CHANGED: The return type of PHP_Token_Stream#scan() changed from no type to void
[BC] CHANGED: The return type of PHP_Token_Stream#parse() changed from no type to void
[BC] CHANGED: The return type of PHP_Token_Stream#rewind() changed from no type to void
[BC] CHANGED: The return type of PHP_Token_Stream#next() changed from no type to void
[BC] CHANGED: The return type of PHP_Token_Stream#offsetSet() changed from no type to void
[BC] CHANGED: The return type of PHP_Token_Stream#offsetUnset() changed from no type to void
[BC] CHANGED: The return type of PHP_Token_Stream#seek() changed from no type to void
[BC] CHANGED: The return type of PHP_Token_Stream_CachingFactory::clear() changed from no type to void
[BC] CHANGED: The return type of PHP_Token_Stream_CachingFactory::clear() changed from no type to void
$ git add .
$ git commit -m"Fix backward compatibility breaks introduced in version 4.0.1"
$ ./tools/roave-backward-compatibility-check --from=4.0.0
./tools/roave-backward-compatibility-check --from=4.0.0                                       
Comparing from 72273e715ebf358a8d35ebf073739764ccc1be81 to e61c593e9734b47ef462340c24fca8d6a57da14e...
Loading composer repositories with package information
Updating dependencies
Writing lock file
Loading composer repositories with package information
Updating dependencies
Writing lock file
PHP Deprecated:  Function ReflectionType::__toString() is deprecated in phar:///usr/local/src/php-token-stream/tools/roave-backward-compatibility-check/vendor/roave/better-reflection/src/SourceLocator/SourceStubber/ReflectionSourceStubber.php on line 478
PHP Deprecated:  Function ReflectionType::__toString() is deprecated in phar:///usr/local/src/php-token-stream/tools/roave-backward-compatibility-check/vendor/roave/better-reflection/src/SourceLocator/SourceStubber/ReflectionSourceStubber.php on line 478
PHP Deprecated:  Function ReflectionType::__toString() is deprecated in phar:///usr/local/src/php-token-stream/tools/roave-backward-compatibility-check/vendor/roave/better-reflection/src/SourceLocator/SourceStubber/ReflectionSourceStubber.php on line 478
PHP Deprecated:  Function ReflectionType::__toString() is deprecated in phar:///usr/local/src/php-token-stream/tools/roave-backward-compatibility-check/vendor/roave/better-reflection/src/SourceLocator/SourceStubber/ReflectionSourceStubber.php on line 478
No backwards-incompatible changes detected

I think it would make sense to use the current state of the working copy instead of the latest commit when --to is not used.

@Ocramius
Copy link
Member

I think this makes a lot of sense: when we designed this package, a lot of focus was put into trying to keep the current repo isolated from the rest, but the --to could indeed be the current state of the project, rather than a clean copy.

@Ocramius Ocramius modified the milestones: 5.0.0, 5.1.0 Jun 16, 2020
@Ocramius Ocramius modified the milestones: 5.1.0, 6.0.0 Nov 5, 2021
@Ocramius
Copy link
Member

Ocramius commented Nov 5, 2021

Not going to be able to drag this into 6.0 - removing milestone for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants