PHPackages                             gariev/xref - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. gariev/xref

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gariev/xref
===========

xref-lint

11483[2 issues](https://github.com/gariev/xref/issues)PHP

Since Jan 24Pushed 12y ago3 watchersCompare

[ Source](https://github.com/gariev/xref)[ Packagist](https://packagist.org/packages/gariev/xref)[ RSS](/packages/gariev-xref/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

WHAT IS XREF?
=============

[](#what-is-xref)

XRef is a set of tools to work with PHP source files. Currently it includes:

- xref-lint

    A lint, i.e. static code analysis tool that finds errors. PHP is not a perfect language to catch programmer's errors, so xref will do. See section "ERROR MESSAGES REPORTED BY LINT" below.
- xref-ci

    Continuous Integration tool to monitor your project repository and send e-mail notifications about errors.
- GIT lint plugin

    Just type 'git xref-lint' in your git repository root before doing a commit and you'll get lint report of modified files
- xref-doc

    A tool to create cross-reference documentation about your project (which classes/methods/properties are defined and where they are used)
- Try it online!

INSTALL
=======

[](#install)

PEAR installation
-----------------

[](#pear-installation)

```
pear channel-discover pear.xref-lint.net
pear install xref/XRef
```

Composer installation
---------------------

[](#composer-installation)

```
php composer.phar --stability=dev create-project gariev/xref
export PATH=$PATH:`pwd`/vendor/bin
```

Install from git/source code
----------------------------

[](#install-from-gitsource-code)

```
git clone git@github.com:gariev/xref.git
export PATH=$PATH:xref/bin
```

Any of the above will give you working command-line lint tool xref-lint (or xref-lint.bat on Windows platform).

SETUP
=====

[](#setup)

To get most of the xref package, configure it for your project after the installation.

```
cd
xref-lint --init
```

This will create a xref data directory (.xref), default config file (.xref/xref.ini) and will index files for faster checks.

1. Edit the config file (.xref/xref.ini). See section CONFIG FILE below; also see sample config in examples/xref.ini.sample
2. \[If installed via Composer, Smarty will be installed as dependency and the step is not needed\] Download and install Smarty template engine. ; any of versions 2.x or 3.x should work, version 2 takes less memory. Set the path to Smarty.class.php file in *xref.smarty-class* param of config file.
3. \[The step is optional\] Configure web server to run scripts from web-scripts dir XRef/web-scripts/, see sample Apache config file in examples/httpd.conf. To view where examples and web-scripts are intalled, run 'xref-lint --help'.
4. Set up crontab to run xref-ci to monitor your project, see sample cronab script in examples/ci.crontab

REPORTED ERRORS
===============

[](#reported-errors)

-  **Can't parse file (%s)** (severity: fatal, code: xr001)

    There is a syntax error in source PHP file.
-  **Use of unknown variable (%s)** (severity: error, code: xr010)

    This error is caused by using a variable that was never introduced in this scope. Most often it's because of misspelled variable name or refactoring that went wrong.

    Sample code:

```
    // COUNTEREXAMPLE
    function example1() {
        $message = "hello, world";
        echo $Message;  //
