Code Monkey home page Code Monkey logo

marabesi / php-import-checker Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 5.0 12.14 MB

php-import-checker helps you know when a given class is imported but not used, providing a easy way to keep your code clean and organized.

Home Page: https://marketplace.visualstudio.com/items?itemName=marabesi.php-import-checker

License: MIT License

TypeScript 52.27% PHP 47.08% JavaScript 0.48% Hack 0.16%
php vscode extension import checker use namespaces php5 php7

php-import-checker's Introduction

php-import-checker

Codacy Badge Build status Coverage Status Buy Me A Coffee

php-import-checker helps you know when a given class is imported but not used, providing a easy way to keep your code clean and organized.

Features

  • Highlight every unused class that is imported with use
  • Change the color to fit your theme
  • opt-in for latest changes and give feedback

Settings

The settings described in this section go under the json option php.import.highlight, a basic configuration that would change the highlight color, would be something like:

"php.import.highlight": {
  "color": "#EDF791",
  "use_next_version": false
  "ignore_comments": true
}
Option Type Description
color String Uses the RGB color defined in this option to highlight the unused imports - helpful to match the color with your preferred theme.
use_next_version Boolean Opt-in to the latest changes to the extension without breaking current behavior. Note: if you are using this option and find anything wrong, please open an issue.
ignore_comments Boolean If set to true, does not take into account commented code - this option only works if use_next_version is set to true

Requirements

Visual Code 1.6 +

Demos

  • Manually invoke the extension checker

Highlight unused imports

  • Change the color to the one you want to

Change highlight color

Publications

php-import-checker's People

Contributors

adeattwood avatar codacy-badger avatar dependabot-preview[bot] avatar dependabot[bot] avatar jackwilsdon avatar marabesi avatar sardoj avatar tiagopaes avatar trowbotham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

php-import-checker's Issues

Not working with type hints of "Union Types" and "Intersection Types"

<?php

use App\Models\Bar1;
use App\Models\Bar2;
use App\Models\Bar3;

class Foo
{
    public function __construct(array|Bar1 $bar = null)
    {
    }
}

"Using type hints of "Union Types" or "Intersection Types" such as array|Bar1 or Bar1&Bar2 can cause the highlighting of the entire PHP file to malfunction."

image
image
image

Last update broke extension for me

Thank you for a great plugin!
It seems today's update has broken the integration for me. Now all imports are marked red as unused.
Is there anything I need to do on my local VS Code instance to get this working again, or is it a bug?

php 8 support

This extension uses the popular php-parser package to parse the code and highlight the unused classes. So far, the extension has support for 5/7, but not 8 yet.

I am opening this issue to keep track of this issue on php-parser and work on that once the release is made.

Publish this extension to Open VSX

Dear extension author,
Please publish this extension to the Open VSX marketplace.

Context

Unfortunately, as Microsoft prohibits usages of the Microsoft marketplace by any other products or redistribution of .vsix files from it, in order to use VS Code extensions in non-Microsoft products, we kindly ask that you take ownership of the VS Code extension namespace in Open VSX and publish this extension on Open VSX.

What is Open VSX? Why does it exist?

Open VSX is a vendor neutral alternative to the MS marketplace used by most other derivatives of VS Code like VSCodium, Gitpod, OpenVSCode, Theia-based IDEs, and so on.

You can read on about Open VSX at the Eclipse Foundation's Open VSX FAQ.

How can you publish to Open VSX?

The docs to publish an extension can be found here. This process is straightforward and shouldn't take too long. Essentially, you need an authentication token and to execute the ovsx publish command to publish your extension. There's also a doc explaining the whole process with an example GitHub Action workflow.

Supporting return types

When using PHP return types, this package things the use statement is unused.

<?php

namespace App;

// This gets highlighted incorrectly
use Example;

class Test
{
    public function foo() : Example
    {
         // ...
    }
}

highlight unused imports on save

Would be great to highlight unused imports after saving the file.
So you don't have to set a shortcut or trigger command all the time.

Showing unused class after class is added back.

VS Code - Version 1.28.2 (1.28.2)

When I save, the file instantly highlights the unused class as expected, but when I then undo to add the class back, and save, the unused warning is still there until I click on another file and go back, or close the file an reopen it.

Thoughts?

Group use declarations

Any chance to implement group use declarations for php 7?

use Foo\Bar\{
    ClassA, 
    ClassB, 
    ClassC
};

change highlight red color

VSCode Version: 1.28.0
Extension Version: 0.1.7

The red background highlighting seems too harsh. It's similar to what I see when errors are shown in my terminal.
screenshot from 2018-11-18 12-31-50

In my opinion, a more friendly highlight color/option should be used.
Or let there be an option to set this in User Settings.

A similar extension for typescript, does this:
screenshot from 2018-11-18 12-38-16

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.