Giter Site home page Giter Site logo

xhazt / phpweaver Goto Github PK

View Code? Open in Web Editor NEW

This project forked from troelskn/phpweaver

0.0 0.0 0.0 230 KB

A combined runtime/static code-analysis tool, that can trace parameter types

License: MIT License

Shell 0.13% PHP 98.56% Dockerfile 1.31%

phpweaver's Introduction

phpweaver

Build Status Codacy Badge Maintainability BCH compliance Coverage Status

phpweaver is a tool for analysing parameter types in PHP code, using a combination of static and runtime analysis. It relies on the xdebug extension to trace function calls. The result of the analysis can then be used to generate docblock comments, with the proper type annotations.

Usage

The basic usage of phpweaver is to write a piece of code (If you have unit tests/examples, they would be a good candidate), that utilises the code to manipulate. Run this example with the tracer, then use weaver to generate docblocks from the trace.

See the example/ folder for a basic example.

The project has two main commands:

  • trace
  • weave

trace

This is just a wrapper around php + xdebug. Use it in lieu of php to execute a php script. It will run normally, but the code is traced and the output is dumped in dumpfile.xt. You can also manually configure xdebug to generate the tracefile.

Sample usage:

phpweaver trace test.php

If your script requires it's own paremeter you can stop paramerter pasing in bash with the double dash:

phpweaver trace -- vendor/bin/phpunit "-c phpunit.xml"

weave

This command takes a dumpfile (Generated by the trace process) and a php-source path (directory or file), and injects docblock comments into the php-source, using the type-information from the trace. It will look for dumpfile.xt in the current directory, or a trace file specifyed using the --tracefile option, printing the modified file to stdout.

Sample usage:

phpweaver weave somelibrary.php

The same dumpfile can be used to weave multiple files, by specifying a folder or multiple paths.

Running tests

There is a Dockerfile for getting an environment up and running. First install docker somehow, then issue:

docker build -t phpweaver .
docker run -it phpweaver

This will log you in to the machine. Run tests with:

phpunit

For development, you will probably want to mount the repo into the container, so run it like this:

docker run -it --mount type=bind,source="$(pwd)",target=/usr/src/app phpweaver

Any changes you make inside the container will now be reflected on your host system.

phpweaver's People

Contributors

ajenbo avatar troelskn avatar muglug avatar staabm avatar

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.