Code Monkey home page Code Monkey logo

workbench-issues's Introduction

workbench-issues's People

Contributors

laravel-shift avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

workbench-issues's Issues

composer/laravel-package-dependencies duplicates constrains

Desktop:

  • OS: [e.g. Intel Mac
  • OS Version: Big Sur,
  • App Version: 0.2.1

Describe the bug
composer/laravel-package-dependencies duplicates some constrains.
E.g.:

"nunomaduro/collision": "^5.0|^5.0",

To Reproduce
just running the task should be enough.

Fatal error: Uncaught RuntimeException: unknown task: php/early-returns

Desktop:

  • OS: Windows
  • OS Version: 10
  • App Version: 0.4.0.0

Describe the bug
No changes made. Shows error in the log.

To Reproduce
Steps to reproduce the behavior:

  1. Run task
Fatal error: Uncaught RuntimeException: unknown task: php/early-returns in phar:///opt/shift/workbench/src/Factories/TaskFactory.php:111
Stack trace:
#0 phar:///opt/shift/workbench/src/Shifts/Laravel/WorkbenchBuild.php(40): Shift\Factories\TaskFactory::createTaskFromUses(Array)
#1 [internal function]: Shift\Shifts\Laravel\WorkbenchBuild->Shift\Shifts\Laravel\{closure}(Array, 0)
#2 phar:///opt/shift/workbench/vendor/illuminate/collections/Collection.php(642): array_map(Object(Closure), Array, Array)
#3 phar:///opt/shift/workbench/src/Shifts/Laravel/WorkbenchBuild.php(41): Illuminate\Support\Collection->map(Object(Closure))
#4 [internal function]: Shift\Shifts\Laravel\WorkbenchBuild->Shift\Shifts\Laravel\{closure}(Object(Illuminate\Support\Collection), 'php/early-retur...')
#5 phar:///opt/shift/workbench/vendor/illuminate/collections/Collection.php(642): array_map(Object(Closure), Array, Array)
#6 phar:///opt/shift/workbench/src/Shifts/Laravel/WorkbenchBuild.php(42): Illuminate\Support\Collection->map(Object(Closure))
#7 phar:///opt/shift/workbench/workbench.php(63): Shift\Shifts\Laravel\WorkbenchBuild->__construct(Array)
#8 /opt/shift/workbench(9): require('phar:///opt/shi...')
#9 {main}
  thrown in phar:///opt/shift/workbench/src/Factories/TaskFactory.php on line 111
--------------

Unlike the other errors where it would show the error in the log but show the checkmark icon, now it shows the running icon moving. It seems despite throwing a fatal error it managed to shut down docker the docker image.

image

Adopt anonymous migrations adds extra semicolon when rerun

Desktop:

  • OS: Windows
  • OS Version: 10
  • App Version: 0.4.0.0

Describe the bug
I added a migration with Laracast Generators and I noticed it didn't use the stubs so I ran the task again. The diff is showing an extra semicolon in every migration. Ideally they shouldn't be affected if they're already anonymous.

To Reproduce
Steps to reproduce the behavior:

  1. Run task

phpstorm64_ywaq3ElfxW

Adopt anonymous migrations deleted the content of the stubs

Desktop:

  • OS: Windows
  • OS Version: 10
  • App Version: 0.4.4.0

Describe the bug
The stubs were created when I previously ran the task. After running it again to convert a new migration it has emptied the content of the stubs.

To Reproduce
Steps to reproduce the behaviour:

  1. Run Task

I added the return type to the stubs. That might have caused the issue.

image

image

nullsafe-operator only changing first one

Desktop:

  • OS: Windows 10
  • OS Version: 20H2
  • App Version: 0.5.2

Describe the bug
The nullsafe-operator task only changes the first sentence inside an if statement.

To Reproduce
Steps to reproduce the behavior:

  1. I have this code:
if ($this->variable !== null) {
    $this->something = $this->variable->name;
    $this->something2 = $this->variable->first_name;
    $this->something3 = $this->variable->last_name;
    $this->something4 = $this->variable->phone_number;
}
  1. I run nullsafe-operator.
  2. Then i have this code:
$this->something = $this->variable?->name;
  1. Expected to have:
$this->something = $this->variable?->name;
$this->something2 = $this->variable?->first_name;
$this->something3 = $this->variable?->last_name;
$this->something4 = $this->variable?->phone_number;

Docker build fails on 0.4.7 and 0.5.0

Desktop:

  • OS: Windows
  • OS Version: 10
  • App Version: 0.5.0

Describe the bug
Docker build fails after update to 0.4.7 and 0.5.0, though worked fine on 0.4.6:

#8 [ 5/14] RUN adduser -D -u -1 shift
#8 sha256:fd91e786836ea8626df9570a8ba8c9ef87fa309894547ddadd58520276225572
#8 0.490 adduser: invalid number '-1'
#8 ERROR: executor failed running [/bin/sh -c adduser -D -u -1 shift]: exit code: 1
------
 > [ 5/14] RUN adduser -D -u -1 shift:
------
executor failed running [/bin/sh -c adduser -D -u -1 shift]: exit code: 1

To Reproduce
Steps to reproduce the behavior:

  1. Update to 0.4.7 or 0.5.0
    2, Try to run any task

image

Convert optional helper to php8 ?->

Hello,
thanks for the great tool!

What would you like to do?
Would be nice to convert all optional($var)->name to $var?->name (for PHP8).

Before/After code snippets
Before:

optional(optional(optional($products->get($i))->manufacturer)->address)->street

After:

$products->get($i)?->manufacturer?->address?->street

Best regards

Format Test Cases incorrectly formatting "setUp" method

Desktop:
Mac
Montery
12.0.1

Describe the bug
When running the Format Test Cases task, and selecting the "annotation" method, I expect it to only add annotations that don't exist IF the method is prefixed by test. The behavior of the task instead seems to add the annotation to all methods (most noticeably, the setUp method)

To Reproduce
Steps to reproduce the behavior:

  1. Have a test suite with a setUp method
  2. Run the Format Test Case task
  3. Notice that the setUp method now has a test annotation, when it really shouldn't

Screen Shot 2021-12-01 at 6 24 46 PM

Screen Shot 2021-12-01 at 6 24 56 PM

Screen Shot 2021-12-01 at 6 25 49 PM

PHP tasks are failing

Desktop:

  • OS: Mac
  • OS Version: Big Sur
  • App Version: 0.2.3

Describe the bug
Some tasks fail when I run them.

To Reproduce
Steps to reproduce the behavior:
Just run the following tasks

  1. php/create_function
  2. php/array-functions
  3. php/arrow-functions
  4. php/null-coalesce
  5. php/convert-each
  6. php/array-destructuring

Basically the same errors for all of them.

Screen Shot 2021-07-02 at 7 51 54 PM

Spinner icon keeps rotating

Desktop:

  • OS: Linux
  • OS Version: Linux Mint 20.2 Cinnamon
  • App Version: 0.7.0

Describe the bug
After running a Global Facade task, the cog icon keeps on spinning, though the task seems completed:
{"event":"step-completed","data":{"step":"laravelglobal-facades","runtime":"3.027063"}}

To Reproduce
Steps to reproduce the behavior:

  1. Open Workbench desktop app (AppImage) and select 'Global Facades' tool
  2. Click on 'Run'
  3. The task seems to finish, facade imports are replaced, but the cog icon keeps spinning, which is confusing.

facade

Suggestion: Ability to see Docker Setup Instructions after first-installation

What would you like to do?
I installed Docker for Win10 via WSL, but after rebooting I needed to recheck the setup instructions / articles as running Docker isn't quite working for me yet. My problem, not yours. (I'll solve it.) It would have been nice to be able to reference those setup instructions / references again within Workbench without having to Google. Uninstalling the program and reinstalling didn't work [to reshow the onboarding instructions].

'Class based routes' shift ignoring namespace method.

Desktop:

  • OS: Mac
  • OS Version: 10.14.6
  • App Version: 0.6.0 (0.6.0)

Describe the bug
Ran the 'Class based routes' shift on an app and ended up with incorrect paths to classes. Shift did not seem to take the namespace into consideration when creating class path.

Default path in RouteServiceProvider was: App\Http\Controllers
Namespace method adds: Clients

To Reproduce
Steps to reproduce the behavior:

  1. Create a route group using a namespace.
        // Clients
        Route::name('clients.')
            ->namespace('Clients')
            ->prefix('clients')
            ->group(function () {
                Route::get('/', 'ClientsController@index')->name('list');
                Route::post('/', 'EditController@create')->name('new');

                Route::get('create', 'EditController@index')->name('create');

                Route::get('/{id}', 'EditController@index')->name('edit')->where('id', '\d+');
                Route::put('/{id}', 'EditController@update')->name('update')->where('id', '\d+');
            });
  1. Run 'Class based routes'
$ php artisan route:list --json

   Illuminate\Contracts\Container\BindingResolutionException

  Target class [App\Http\Controllers\UsersController] does not exist.

  at vendor/laravel/framework/src/Illuminate/Container/Container.php:875
    871▕
    872▕         try {
    873▕             $reflector = new ReflectionClass($concrete);
    874▕         } catch (ReflectionException $e) {
  ➜ 875▕             throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
    876▕         }
    877▕
    878▕         // If the type is not instantiable, the developer is attempting to resolve
    879▕         // an abstract type such as an Interface or Abstract Class and there is

Result of shift:

use App\Http\Controllers\ClientsController;
use App\Http\Controllers\EditController;
use Illuminate\Support\Facades\Route;

        Route::name('clients.')
            ->prefix('clients')
            ->group(function () {
                Route::get('/', [ClientsController::class, 'index'])->name('list');
                Route::post('/', [EditController::class, 'create'])->name('new');

                Route::get('create', [EditController::class, 'index'])->name('create');

                Route::get('/{id}', [EditController::class, 'index'])->name('edit')->where('id', '\d+');
                Route::put('/{id}', [EditController::class, 'update'])->name('update')->where('id', '\d+');
            });

Expected result shift:

use App\Http\Controllers\Clients\ClientsController;
use App\Http\Controllers\Clients\EditController;
use Illuminate\Support\Facades\Route;

        Route::name('clients.')
            ->prefix('clients')
            ->group(function () {
                Route::get('/', [ClientsController::class, 'index'])->name('list');
                Route::post('/', [EditController::class, 'create'])->name('new');

                Route::get('create', [EditController::class, 'index'])->name('create');

                Route::get('/{id}', [EditController::class, 'index'])->name('edit')->where('id', '\d+');
                Route::put('/{id}', [EditController::class, 'update'])->name('update')->where('id', '\d+');
            });

Class not found in "Class based factories" Task

Desktop:

  • OS: Mac
  • OS Version: Big Sur
  • App Version: 0.2.3

Describe the bug
Error when running the "Class based factories" task

Analyzing project...

Fatal error: Uncaught Error: Class "Shift\Tasks\Laravel\Eight\Factories" not found in phar:///opt/shift/workbench/src/Tasks/Workbench/ClassBasedFactories.php:10
Stack trace:
#0 phar:///opt/shift/workbench/vendor/composer/ClassLoader.php(480): include()
#1 phar:///opt/shift/workbench/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile('phar:///opt/shi...')
#2 phar:///opt/shift/workbench/src/Factories/TaskFactory.php(93): Composer\Autoload\ClassLoader->loadClass('Shift\\Tasks\\Wor...')
#3 phar:///opt/shift/workbench/src/Shifts/Laravel/WorkbenchBuild.php(40): Shift\Factories\TaskFactory::createTaskFromUses(Array)
#4 [internal function]: Shift\Shifts\Laravel\WorkbenchBuild->Shift\Shifts\Laravel\{closure}(Array, 0)
#5 phar:///opt/shift/workbench/vendor/illuminate/collections/Collection.php(642): array_map(Object(Closure), Array, Array)
#6 phar:///opt/shift/workbench/src/Shifts/Laravel/WorkbenchBuild.php(41): Illuminate\Support\Collection->map(Object(Closure))
#7 [internal function]: Shift\Shifts\Laravel\WorkbenchBuild->Shift\Shifts\Laravel\{closure}(Object(Illuminate\Support\Collection), 'laravel/class-b...')
#8 phar:///opt/shift/workbench/vendor/illuminate/collections/Collection.php(642): array_map(Object(Closure), Array, Array)
#9 phar:///opt/shift/workbench/src/Shifts/Laravel/WorkbenchBuild.php(42): Illuminate\Support\Collection->map(Object(Closure))
#10 phar:///opt/shift/workbench/workbench.php(57): Shift\Shifts\Laravel\WorkbenchBuild->__construct(Array)
#11 /opt/shift/workbench(9): require('phar:///opt/shi...')
#12 {main}
  thrown in phar:///opt/shift/workbench/src/Tasks/Workbench/ClassBasedFactories.php on line 10

To Reproduce
Run the task.

Task log hangs with "..." on when running "Spawning Docker" or "Analyzing project"

Desktop:

  • OS: Mac (Intel)
  • OS Version: Big Sur
  • App Version: 0.2.0

Describe the bug
When running any task, the "Task Log" will hang just showing the "..." animation on either the "Spawning Docker" or "Analyzing project" steps.

To Reproduce
This doesn't always happen, so there are not any specific reproduction steps other than attempting to run a task.

Multiple "Task log" for concurrent builds

Desktop:

  • OS: Mac
  • OS Version: Big Sur 11.4
  • App Version: 0.2.0

Describe the bug
Spinning cog on Cleaning Up and Generating Report does not stop even though the docker process already finished and closed.

To Reproduce
Steps to reproduce the behavior:

  1. Run common-helpers
  2. Run global-facades (don't wait for step one to finish)
  3. Run other tasks (don't wait for other tasks to finish)

Screen Shot 2021-07-01 at 9 02 47 AM

Ability to stop long running task

What would you like to do?
sometimes I run task that may take long time or I some times I run task by mistake on different project ... so I think the ability to stop a task that would be awsome

New task: Change usages of FakerPHP property accessors to method calls

What would you like to do?

FakerPHP/Faker#164

In that pull request FakerPHP has marked property access as deprecated

    /**
     * @param string $attribute
     *
     * @deprecated Use a method instead.
     */
    public function __get($attribute)
    {
        trigger_deprecation('fakerphp/faker', '1.14', 'Accessing property "%s" is deprecated, use "%s()" instead.', $attribute, $attribute);


        return $this->format($attribute);
    }

Before/After code snippets

- $this->faker->lastName;
+ $this->faker->lastName();

Code Format: Custom => Also check new config file .php-cs-fixer.php

What would you like to do?
At this moment, the custom code format "workbench" only checks the existence of .php_cs, and uses it (correctly) if it does exist.

Since PHP CS Fixer v2.19.0 it supports using .php-cs-fixer.php as the config file, and since v3 the old (.php_cs) file name is no longer supported.

Would be great if both file names could be checked and can be used.

laravel/tuple-action also runs laravel/fluent-routes

Desktop:

  • OS: Ubuntu
  • OS Version: 20.04
  • App Version: 0.5.2

Describe the bug
Running the laravel/tuple-action shift also runs laravel/fluent-routes.
This is unexpected, since it isn't mentioned in the task description.

Workaround: Running laravel/class-based-routes will also run tuple-action, but not fluent-routes.

To Reproduce
Steps to reproduce the behavior:
Run laravel/tuple-action on a project containing the routes defined with array syntax.

Fatal error on null-coalesce task

Desktop:

  • OS: Windows
  • OS Version: 10
  • App Version: 0.3.2.0

Describe the bug
Got a fatal error when running the task

To Reproduce
Steps to reproduce the behavior:

  1. open workbench
  2. select project
  3. Run php/null-coalesce task
Fatal error: Cannot redeclare dump_node() (previously declared in /root/.composer/vendor/rector/rector/vendor/scoper-autoload.php:3303) in /project/vendor/rector/rector/src/functions/node_helper.php on line 9
Failed to run rector: adopt-null-coalesce: #0 phar:///opt/shift/workbench/src/Tasks/Workbench/AdoptNullCoalesce.php(18): Shift\Tasks\Workbench\AdoptNullCoalesce->rector('/opt/shift/reso...')
#1 phar:///opt/shift/workbench/workbench.php(95): Shift\Tasks\Workbench\AdoptNullCoalesce->perform()
#2 /opt/shift/workbench(9): require('phar:///opt/shi...')
#3 {main}
--------------

The section was collapsed with the green checkmark so for I while I didn't know what had happened or why it was taking long

image

image

php/switch-to-match warnings and then failed to run

Desktop:

  • OS: Mac
  • OS Version: Big Sur 11.4
  • App Version: 0.2.1

Describe the bug
I ran the php/switch-match task and got some warnings and then it failed. It seemed to take a long time but this is my first time running a task that uses Rector so maybe they are always slower. I am wondering if it is scanning all files instead of just *.php files. In the warning message you can see it could not read rr which is the RoadRunner server from when I was testing Laravel Octane. I am not even sure why it would need to read that file. I am not sure if the warnings are the reason it failed or just coincidence.

Warning: sha1_file(/project/rr): Failed to open stream: Operation not permitted in /root/.composer/vendor/rector/rector/packages/Caching/Detector/ChangedFilesDetector.php on line 92
Warning: sha1_file(/project/rr): Failed to open stream: Operation not permitted in /root/.composer/vendor/rector/rector/packages/Caching/Detector/ChangedFilesDetector.php on line 92
Failed to run rector: convert-switch-to-match: #0 phar:///opt/shift/workbench/src/Tasks/Workbench/ConvertSwitchToMatch.php(18): Shift\Tasks\Workbench\ConvertSwitchToMatch->rector('/opt/shift/reso...')
#1 phar:///opt/shift/workbench/workbench.php(89): Shift\Tasks\Workbench\ConvertSwitchToMatch->perform()
#2 /opt/shift/workbench(9): require('phar:///opt/shi...')
#3 {main}
{"event":"step-failed","data":{"step":"phpswitch-to-match","runtime":"632.194897"}}

Class based routes mishandles parameter in name (edge case)

Desktop:

  • OS: Windows
  • OS Version: 10
  • App Version: 0.6.0.0

Describe the bug
While upgrading an app with a non conventional route naming convention I found the the names were not converted correctly.

To Reproduce
Steps to reproduce the behavior:
3. Run Class based routes task

-Route::get('/event/{event}', 'EventController@show')->name('events@show');
+Route::get('/event/{event}', [EventController::class, 'show'])->name([events::class, 'show']);

image

Remove Dead Code: also removes variable assignments used in compact function

Desktop:

  • OS: Mac
  • OS Version: Big Sur
  • App Version: 0.4.1

Describe the bug
When running the new "Remove Dead Code" worker, a variable assignment that is used in a compact() call afterwards is also removed.

Before

$transports = $driver->transports();

return view('drivers.processTransports', compact(['driver', 'transports', 'driverLinks', 'period']));

After

$driver->transports();

return view('drivers.processTransports', compact(['driver', 'transports', 'driverLinks', 'period']));

Licence Activation not working

Desktop:

  • OS: MacOS
  • OS Version: Big Sur 11.4
  • App Version: 0.2.0

Describe the bug
Licence Activation doesn't work - button stays at 'activating...' and doesn't change. The application hasn't crashed, can still access menus, and they all work, but the licence key modal doesn't go away. Quitting ad restarting app shows app still unlicenced.

To Reproduce
Steps to reproduce the behavior:

  1. WorkBench > Licence Key
  2. Enter licence key
  3. Click activate

Code Fixer Support for Packages.

What would you like to do?
I'd like to run the Laravel code fixer against my package's src folder without setting up my own .php_cs.laravel file.

Currently the php/code-format task fails with this error:

In Finder.php line 590:
                                                
  The "/project/app" directory does not exist.

Convert 'magic' accessors or mutators in to traditional methods

As mentioned on Twitter we have projects where devs have in the past make extreme uses of accessors and mutators.
So for example a User class has something like:

public function getContactsAttribute()
    {
        $users = Cache::remember(
            'user-contacts-' . $this->id,
            240,
            function () {
                return User::NetworkUsers($this->id)
                           ->havingPermissions([MenuPermissions::conversations(true)])
                           ->orderBy('firstname')
                           ->get();
            }
        );

        return $users;
    }

which is then used all over the codebase as $user->contacts

For simple stuff like concatenating firstname and lastname into a fullname property i think accessors are great.
But i think this example shows there's way too much code/logic in it. This is hardly a property anymore.

Now if there was full support for it in IDE's there wouldn't be much issue to refactor it by hand, but this is not the case.
Laravel ide-helper does add property decorations for these properties, but when a model using this is passed to a blade view for example the knowledge about these properties is lost.

given the previous example code snippet, i'd be happy if workbench could at least generate normal corresponding methods.

public function getContacts()
    {
        $users = Cache::remember(
            'user-contacts-' . $this->id,
            240,
            function () {
                return User::NetworkUsers($this->id)
                           ->havingPermissions([MenuPermissions::conversations(true)])
                           ->orderBy('firstname')
                           ->get();
            }
        );

        return $users;
    }

And maybe also modify the original accessor as:

public function getContactsAttribute()
{
   return $this->getContacts();
}

for backwards compatibility.

But ofcourse it would be even more fantastic if it could detect all the uses of the original accessor property and change to use the new methods directly.

Common docker issues

What would you like to do?
after I installed docker on ubuntu machine .... i found workbench still giving this error

Screenshot from 2021-07-15 13-20-28

after I spend an hour or two search,ing I found this article solved my problem

i know that docker issues will be different from one machine to another .... but I would suggest something like common docker issues with links to solve them ... or if possible a short youtube video of quick start guide with docker and some common issues that can happen

Prefill OS, OS Version and App version in bug report

Absolutely not needed, but it would be cool.

What would you like to do?
In the spirit of automation, if Workbench knows those params (OS, OS Version and App version) it could prefill them on the link to the GitHub issue.

I tried and it seems the body can be passed through the get param just like with mailto:

&body=issue_body_here

image

Before/After code snippets

-      - OS: [e.g. Mac, Windows, Linux]
+      - OS: Windows
-      - OS Version: [e.g. Big Sur, 10, 18.12]
+      - OS Version: 10
-       - App Version: [e.g. 0.1.0]
+       - App Version: 0.4.0.0

No changes made on task laravel/request-injection, warning thrown

Desktop:

  • OS: Windows
  • OS Version: 10
  • App Version: 0.3.2.0

Describe the bug
log shows this error

Warning: foreach() argument must be of type array|object, null given in phar:///opt/shift/workbench/src/Tasks/Laravel/Fixer/RequestAccess.php on line 38

No files were changed.

To Reproduce
Steps to reproduce the behavior:

  1. open workbench
  2. select project
  3. Run laravel/request-injection

(I followed the instructions here #14 (comment))

Workbench_jqLk0tUaCk

This piece of code should have had the task applied, right?

cwE3rPpSQT

php/switch-to-match wrong transformation

Desktop:

  • OS: Windows
  • OS Version: 10
  • App Version: 0.3.1.0

Describe the bug
In specific following scenario tranformation applied is not equivalent to original snippet (tests are failing proving that ✌).
You can notice the tranformed form is missing the orginal default value ($quote = 0 removed) and the original return (return $quote).
In the expected result is my suggested form given this scenario.

To Reproduce
Steps to reproduce the behavior:

  1. Given the following snippet:
    public function quote()
    {
        $quote = 0;
        switch ($this->comboType) {
            case self::COMBO_OR:
                $quote = $this->quoteForComboOr();
                break;
            case self::COMBO_AND:
                $quote = $this->quoteForComboAnd();
                break;
        }

        return $quote;
    }
  1. Run 'switch to match' task on it

Expected result

    public function quote()
    {
        return match ($this->comboType) {
            self::COMBO_OR => $this->quoteForComboOr(),
            self::COMBO_AND => $this->quoteForComboAnd(),
            default => 0,
        };
    }

Actual result

    public function quote()
    {
        $quote = match ($this->comboType) {
            self::COMBO_OR => $this->quoteForComboOr(),
            self::COMBO_AND => $this->quoteForComboAnd(),
            default => $quote,
        };
    }

Please let me know if you need any further information 👍

PS: shift and its workbench rocks 🤘

Workbench grouped tasks

What would you like to do?
sometimes I want to run multiple tasks together on different projects so my suggestion is :

  • have yaml file same as web interface ... to run multiple tasks after each other

  • ability to save those tasks under a certain name in order to run them on different projects

Allow running tasks as non-root user

What would you like to do?
When I run Workbench locally, the modified files end up being owned by root. It would be great if I could choose a different user:group to run the tasks as. Or if Workbench could just leave the ownership unchanged, that would be even better.

I'm running Workbench in Ubuntu 20.04 (through WSL2 on Windows 10)

Minor: "Streamline order methods" PHP warning

Desktop:

  • OS: Windows
  • OS Version: 10
  • App Version: 0.5.2

Describe the bug
In the output log of the "Streamline Order by task" there was this PHP warning:

Warning: Undefined property: PhpParser\Node\Expr\BinaryOp\Concat::$name in phar:///opt/shift/workbench/src/Parsers/Finders/QueryOrderByFinder.php on line 23

The task still works perfectly in converting a bunch of orderBy statements.

To Reproduce
Steps to reproduce the behavior:

  1. Run 'Streamline order methods' task using Desktop Workbench

image

Duplicate namespace path in tuple action

Desktop:

  • OS: Mac
  • OS Version: 12 beta
  • App Version: 0.5.2

Describe the bug

When running actions to tuples (tuple-action) on a file that has the full class path in action() it appends a duplicate namespace in front. This code is probably not really great to begin with but it does work.

To Reproduce
Steps to reproduce the behavior:

  1. Have a file that contains code like: action('App\Http\Controllers\FooController@function')
  2. Run the actions to tuples job
  3. Code generated is action([\App\Http\Controllers\App\Http\Controllers\FooController::class, 'function']

Laravel fixes not working

Desktop:

  • OS: Mac
  • OS Version: Big Sur
  • App Version: 0.4.7

Describe the bug
The normal fixes run just fine. But the 'Laravel' fixes finish within 1 second and don't show any output. Maybe it's just me but it doesn't seem to be working no matter what I do.

To Reproduce
Steps to reproduce the behavior:

  1. Run a Laravel fix (make sure there are things to fix)
  2. Wait for the result

https://imgur.com/a/ReSCpc1

Not running in windows

Desktop:

  • OS: Windows
  • OS Version: 10
  • App Version: [e.g. 0.1.0]

Describe the bug
Spawned Docker background process with PID 10628
docker: Error response from daemon: error while creating mount source path '/run/desktop/mnt/host/c/Users/mateu/AppData/Roaming/Workbench/build.json': mkdir /run/desktop/mnt/host/c: file exists.

To Reproduce
1 - select any task
2 - run

image

Convert Model scopes to Query Builder class

What would you like to do?
The new task should convert scope methods on Models to Query-Builder classes.

https://twitter.com/RienvanVelzen/status/1434522901714190346

Before/After code snippets

class Article extends Model
{
    public function scopePublished(Builder $builder)
    {
        return $builder->whereNotNull('published_at');
    }
}
class ArticleBuilder extends Builder
{
    public function published(): self
    {
        return $this->whereNotNull('published_at');
    }
}


class Article extends Model
{
    public function newEloquentBuilder($query): Builder
    {
        return new ArticleBuilder($query);
    }
}

WSL path to project recognised but won't run check - "Failed to find artisan"

Desktop:

  • OS: Windows
  • OS Version: 10
  • App Version:0.4.2.0

Describe the bug
My project is stored in WSL so the path to the project can be either Z:\home\colin\project or \\wsl$\home\colin\project when I browse in Windows Explorer. Only the mapped drive version is recognised as a valid project path in Workbench. When I run a check the docker image spawns fine but at the preparing build step I get the error

Analyzing project...
Failed to find artisan

I

To Reproduce
Steps to reproduce the behaviour:

  1. Create Laravel project in WSL
  2. Run Workbench
  3. Set project path
  4. Run a check

image

Property Promotion not working

Desktop:

  • OS: MacOS
  • OS Version: Big Sur
  • App Version: 0.2.0

Describe the bug
Property promotion fails with Failed to run rector: adopt-property-promotion: #0 phar:///opt/shift/workbench/src/Tasks/Workbench/AdoptPropertyPromotion.php(18):

To Reproduce
Steps to reproduce the behavior:

  1. run property promotion task

screenshot2021-06-30 at 22 49 10@2x

Fluent Routes bug

Desktop:

  • OS: Mac
  • OS Version: Big Sur, 11.5.2
  • App Version: 0.6.3

Describe the bug
I have run the Fluent Routes task but it is not translating the route correctly. A image of the diff:
image

To Reproduce
Steps to reproduce the behavior:

This:

Route::prefix('{product}')->group(function () {
    Route::resource('contact', ContactController::class, ['only' => ['store', 'index', 'show']]);
    Route::resource('nieuws', ProductNewsController::class, ['only' => ['index', 'show'], 'parameters' => ['nieuws' => 'news']]);
});

Gets translated to:

Route::prefix('{product}')->group(function () {
    Route::resource('contact', ContactController::class)->only('store', 'index', 'show');
    Route::resource('nieuws', ProductNewsController::class, [ 'parameters' => ['nieuws' => 'news']]);
});

But should be:

Route::prefix('{product}')->group(function () {
    Route::resource('contact', ContactController::class)->only('store', 'index', 'show');
    Route::resource('nieuws', ProductNewsController::class)->only('index', 'show')->parameters(['nieuws' => 'news']);
});

(So in short; it removed the only and did not move the parameters.)

Better handling for PHP fatal errors

What would you like to do?
When a fatal error is thrown, it would be great to have a bit more context about what file was being processed when the error occured.

Example output when running the PHP7.3 Array Functions task:

>>> Event: Processing paths: app, database/factories, database/seeders, vendor-custom/brilliantpackages/laravel-mysql-spatial/src/Eloquent, config, database/migrations, routes, tests
Fatal error: Cannot declare class Illuminate\Support\Collection, because the name is already in use in /project/vendor/laravel/framework/src/Illuminate/Collections/Collection.php on line 11
Failed to run rector: adopt-new-array-functions: #0 phar:///opt/shift/workbench/src/Tasks/Workbench/AdoptNewArrayFunctions.php(18): Shift\Tasks\Workbench\AdoptNewArrayFunctions->rector('/opt/shift/reso...')
#1 phar:///opt/shift/workbench/workbench.php(95): Shift\Tasks\Workbench\AdoptNewArrayFunctions->perform()
#2 /opt/shift/workbench(9): require('phar:///opt/shi...')
#3 {main}

I’ve searched my codebase for class Collection and it’s not coming up just found it in _ide_helper.php from this package.

If possible, it would be nice to see the file being processed when the error occurred so I can more easily track it down.

Before/After code snippets
Perhaps something like this:

>>> Event: Processing paths: app, database/factories, database/seeders, vendor-custom/brilliantpackages/laravel-mysql-spatial/src/Eloquent, config, database/migrations, routes, tests
Fatal error: Cannot declare class Illuminate\Support\Collection, because the name is already in use in /project/vendor/laravel/framework/src/Illuminate/Collections/Collection.php on line 11
+ File currently being processed: _ide_helper.php
Failed to run rector: adopt-new-array-functions: #0 phar:///opt/shift/workbench/src/Tasks/Workbench/AdoptNewArrayFunctions.php(18): Shift\Tasks\Workbench\AdoptNewArrayFunctions->rector('/opt/shift/reso...')
#1 phar:///opt/shift/workbench/workbench.php(95): Shift\Tasks\Workbench\AdoptNewArrayFunctions->perform()
#2 /opt/shift/workbench(9): require('phar:///opt/shi...')
#3 {main}

"Failed to run rector" on a few tasks

Desktop:

  • OS: Mac
  • OS Version: 11.4
  • App Version: 0.4.4

Describe the bug

I've been running a few simple refactoring tasks to dip my toes in, but have been receiving this error:

Running: php/null-coalesce
7s
>>> Event: Processing paths: app, database/factories, database/seeders, config, database/migrations, routes, tests
Fatal error: Class PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode contains 3 abstract methods and must therefore be declared abstract or implement the remaining methods (PHPStan\PhpDocParser\Ast\Node::setAttribute, PHPStan\PhpDocParser\Ast\Node::hasAttribute, PHPStan\PhpDocParser\Ast\Node::getAttribute) in /project/vendor/phpstan/phpdoc-parser/src/Ast/Type/IdentifierTypeNode.php on line 5
Failed to run rector: adopt-null-coalesce: #0 phar:///opt/shift/workbench/src/Tasks/Workbench/AdoptNullCoalesce.php(18): Shift\Tasks\Workbench\AdoptNullCoalesce->rector('/opt/shift/reso...')
#1 phar:///opt/shift/workbench/workbench.php(91): Shift\Tasks\Workbench\AdoptNullCoalesce->perform()
#2 /opt/shift/workbench(9): require('phar:///opt/shi...')
#3 {main}

At first, I thought it was to do with my project's dependencies, but my project's PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode had no abstract methods.

I experienced this issue on the following tasks:

  • Convert create_function
  • Null Coalesce
  • Array Destructuring

Stopped running tasks after that assuming this would likely come up a few more times.

Tasks running slow

Describe the bug
A few of the tasks, particularly the PHP tasks, take several minutes to run.


This is likely due to Docker's file I/O. Which is known to be slow, especially on a Mac. Projects with either many files or large files are likely to be affected.

A few things you may do to reduce project size:

  • Remove any temporarily files: caches, logs, db dumps, etc
  • Temporarily remove the node_modules folder
  • Temporarily remove your development dependencies by removing the vendor folder and running composer install --no-dev
  • For long-lived repositories, manually run git gc to optimize your local project .git folder.

We will continue to optimize the volume options using by the Workbench. We're also hopeful Docker will continue to improve this issue.

No changes made on task laravel/unguarded-models, warning thrown

Desktop:

  • OS: Windows
  • OS Version: 10
  • App Version: 0.3.2.0 - 0.4.0.0

Describe the bug
The log shows this:

cp: can't stat '/opt/shift/scripts/find-fillable-models.php': No such file or directory
rm: can't remove 'find-fillable-models.php': No such file or directory

To Reproduce
Steps to reproduce the behavior:

  1. open workbench
  2. select project
  3. Run task

Workbench_sLw5uvOAAR

$fillables arrays in the code:

zMj9vnf44p

Workbench doesn't respect excluded_paths from .shiftrc

Desktop:

  • OS: Ubuntu
  • OS Version: 20-04
  • App Version: 0.4.6.0

Describe the bug
Apparently Workbench doesn't read excluded_paths from .shiftrc when running tasks.

I've added excluded_paths = "app/Subfolder" to .shiftrc because the folder contains some problematic classes that trigger an infinite loop/recursion when PhpStan tries to analyze them. I can process the project with Rector, as long as this folder is ignored.

Is there some other way to get Workbench to ignore certain files or folders?

To Reproduce
Steps to reproduce the behavior:

  1. Add a folder path (containing files that would be modified by the task) to excluded_paths in .shiftrc
  2. Run the task
  3. Check if any files in the excluded folder are modified

PHP tags in blade files

Desktop:

  • OS: Mac
  • OS Version: Big Sur
  • App Version: 0.4.7

Describe the bug
When running some tasks it adds PHP tags to blade files. It sees these as actual problems fixed, whilst it messes up the files.

To Reproduce
Steps to reproduce the behavior:

  1. Have a Laravel project with blade files
  2. Run php/create_function
  3. Check changes

https://imgur.com/a/Yxq4agt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.