GithubHelp home page GithubHelp logo

phpactor / phpactor Goto Github PK

View Code? Open in Web Editor NEW
1.3K 23.0 117.0 8.69 MB

Mainly a PHP Language Server with more features than you can shake a stick at

License: MIT License

PHP 98.54% Makefile 0.03% Twig 0.27% Perl 0.14% Gherkin 0.01% Vim Script 0.97% Nix 0.03% Dockerfile 0.02%
php completion refactoring vim

phpactor's Introduction

Phpactor

phpactor2sm

CI

This project aims to provide heavy-lifting refactoring and introspection tools which can be used standalone or as the backend for a text editor to provide intelligent code completion.

Installation

Phpactor is a general tool, it is not intended that it be installed as a project dependency.

See Installation for installation instructions.

Requirements

Project Recommendations

Phpactor will perform better with Composer and, to a lesser extent, with GiT.

Documentation

Full documentation can be found on Read the Docs

Community

  • Follow @phpactor on 🦣 Mastodon for latest news.
  • Join the #phpactor channel on the Slack Symfony Devs channel.

Contributing

This package is open source and welcomes contributions! Feel free to open a pull request on this repository.

Support

  • Create an issue on the main Phpactor repository.
  • Join the #phpactor channel on the Slack Symfony Devs channel.

Sponsors

The following organisations are providing either financial support or free services. If you would like to support Phpactor development financially you can sponsor me.

Tinkerwell

Tinkerwell

Blackfire

Blackfire

phpactor's People

Contributors

allendoerfer avatar bart-jaskulski avatar camilledejoye avatar cizordj avatar dantleech avatar dependabot[bot] avatar dshoreman avatar einenlum avatar fcojavierdomenech avatar gbprod avatar gerardroche avatar ging-dev avatar greg0ire avatar kermorgant avatar kristijanhusak avatar lalanikarim avatar lens0021 avatar lizhineng avatar lumnn avatar mamazu avatar matmarex avatar przepompownia avatar still-dreaming-1 avatar talbergs avatar taluu avatar vlada-dudr avatar voronkovich avatar weirdan avatar yaegassy avatar zonuexe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpactor's Issues

Project specific configuration

For example, some annoying projects use 2 autoloaders - in which case we would need a chain autoloader to take advantage of both of them.

Other options might include choosing the file location strategies (simple, git, compoesr), etc.

Closure support

Doesn't parse files with closures (??) won't complete in them.

Teleport to different aspects of the source code

Create a feature which will allow easy navigation to / or generation of related files (e.g. from a unit test, the source, from the source the unit test, from the unit test the benchmark, etc. etc. etc.)


Below each target represents an aspect of the source code, for example

  • Source
  • Unit test
  • Benchmark

The kernel is the part of the file name (or class name) which remains constant.

When the teleporter is invoked:

  • We replace <kernel> with (.*?) and run a regex on the current file name
    for each of the targets and find a match.
  • We offer the user a choice of destinations from the remaining targets.
  • When selected the kernel is replaced in the selected target
  • The file is opened, if it does not exist it is created (using the existing
    create functionality).
teleport:
    targets:
        source: 
            pattern: "src/<kernel>.php$"
            create: default
        phpunit: 
            pattern: "tests/Unit/<kernel>Test.php$"
            create: phpunit_test
        benchmark: 
            pattern: "benchmark/<kernel>Bench.php$"
            create: benchmark

BR performance

Type resolution (TypeFromAst)

With static caching:

\Phpactor\Benchmark\PhpunitCompleteBench

    benchPhpunit                  I0 P0         [μ Mo]/r: 12,032,643.000 12,032,643.000 (μs)    [μSD μRSD]/r: 0.000μs 0.00%

Without

\Phpactor\Benchmark\PhpunitCompleteBench

    benchPhpunit                  I0 P0         [μ Mo]/r: 23,366,917.000 23,366,917.000 (μs)    [μSD μRSD]/r: 0.000μs 0.00%

Do not pollute autoloader

Currently the project autoloader(s) are require 'd causing contamination. This should be avoided.

Class copy fails silently

When copying a class/interface with a file/class name mismatch, the new file is created but the class in it is not renamed as is expected (because the class name of the original file was not resolved).

There should probably be some sort of warning in this case (maybe a generic health check on save)

Copy

As with mv but just copy the file (class) and replace the class name and namespace with the new filename (classname)

List "child" classes for given class.

Perform a search for child classes in the GIT Tree.

$ phpactor class:children Acme\AbstractCollection
Acme\RabbitCollection:/path/to/Acme/RabbitCollection
Acme\BearCollection:/path/to/Acme/BearCollection

Move type-inference stuff into Worse Reflection

Create a good frame builder and consider merging the type-inference library into Worse Reflection (i.e. better than the one in type-inference actually):

Track:

  • Variable assignments
  • Method injection.
  • Class property assigns (types lazily evaluated)
  • Variable positions.
  • Store unresolved assigns (lazily evaluate types).

Final product should be able to:

  • Produce an overlay showing the types of all variables in a script.

[Move] Transactional move

Support transactional moves, i.e. if an exception is encountered when moving things should be reverted to their original state before exiting.

This could be achieved by copying original files to temporary locations for the duration of the transaction and then removing them.

Falls back to the last resolved reflection instead of null.

Object calls fall back to the last reflection instead of returning null e.g.

$this->foobar->barfoo->asd;

If barfoo cannot be resolved then it will fall back to the reflection class of foobar. But it should return NULL (as the completions for foobar have nothing to do with barfoo)

Implement contract on PHPUnit testcase implements all the things

Implementing contracts on a PHPUnit test case implements about 100 static methods things.

    /**
     * {@inheritDoc}
     */
    public static function assertArrayHasKey($key, $array, $message = '')
    {
    }

    /**
     * {@inheritDoc}
     */
    public static function assertArraySubset($subset, $array, $strict = false, $message = '')
    {
    }

    /**
     * {@inheritDoc}
     */
    public static function assertArrayNotHasKey($key, $array, $message = '')
    {
    }

    /**
     * {@inheritDoc}
     */
    public static function assertContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
    {
    }

    /**
     * {@inheritDoc}
     */
    public static function assertAttributeContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
    {
    }

    /**
     * {@inheritDoc}
     */
    public static function assertNotContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
    {
    }

    /**
     * {@inheritDoc}
     */
    public static function assertAttributeNotContains($needle, $haystackAttributeName, $haystackClassOrObject, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
    {
    }

    /**
     * {@inheritDoc}
     */
    public static function assertContainsOnly($type, $haystack, $isNativeType = null, $message = '')
    {
    }

    /**
     * {@inheritDoc}
     */
    public static function assertContainsOnlyInstancesOf($classname, $haystack, $message = '')
    {
    }

    /**
     * {@inheritDoc}
     */
    public static function assertAttributeContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '')
    {
    }

    /**
     * {@inheritDoc}
     */
    public static function assertNotContainsOnly($type, $haystack, $isNativeType = null, $message = '')
    {
    }

    /**
     * {@inheritDoc}
     */
    public static function assertAttributeNotContainsOnly($type, $haystackAttributeName, $haystackClassOrObject, $isNativeType = null, $message = '')
    {
    }

    /**
     * {@inheritDoc}
     */
    public static function assertCount($expectedCount, $haystack, $message = '')
    {
    }

    /**
     * {@inheritDoc}
     */
...

VIM Plugin

VIM Plugin:

  • Execute command from within VIM and reload affected files.
  • Execute commands based on cursor context.

Goto definition

Using the class-to-file package it should be easy to use the tolerant-php-parser to get the FQN of any class reference and convert it to a file path.

[Application] Extract interface

Extract interface from a given class specifier or a glob:

$ phpactor class:extract:interface lib/Foobar.php lib/FoobarInterface.php

or

$ phpactor class:extract:interface lib/Foobar/* lib/Foobar/Api

Consider a way to transform names, e.g.:

$ phpactor class:extract:interface lib/Foobar/* lib/Foobar --transform="/^(.*+).php$/\1Interface.php"

Generate method from offset

e.g. given that testMethod does not exist:

$rabbit = new Rabbit();
$rabbit->thump(Times::fromInt(12));

will generate the Thump method in Rabbit with the correct method signature.

Include use statement

It should be reasonably fast to iterate over the composer paths for a given class name MyClass.php and use the class-to-file package to covert the found file to an FQN.

The service should provide 2 operations: returning a list of candidates and including the use statement (or could this be better done by VIM?).

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.