diff options
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | composer.json | 33 | ||||
| -rw-r--r-- | phan-autoload.patch | 88 | ||||
| -rw-r--r-- | phan-autoload.php | 9 | ||||
| -rw-r--r-- | phan.spec | 145 | 
5 files changed, 278 insertions, 0 deletions
| diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cd3c95f --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../common/Makefile diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..926f961 --- /dev/null +++ b/composer.json @@ -0,0 +1,33 @@ +{ +    "name": "etsy/phan", +    "description": "A static analyzer for PHP", +    "keywords": ["php", "static", "analyzer"], +    "type": "project", +    "license": "MIT", +    "authors": [ +        { +            "name": "Rasmus Lerdorf" +        }, +        { +            "name": "Andrew S. Morrison" +        } +    ], +    "require": { +        "php": ">=7.0", +        "ext-ast": "*", +        "ext-sqlite3": "0.7-dev", +        "symfony/console": "~2.3|~3.0" +    }, +    "require-dev": { +        "phpunit/phpunit": "~5", +        "phpdocumentor/phpdocumentor": "dev-master", +        "squizlabs/php_codesniffer": "^2.5" +    }, +    "autoload": { +        "psr-4": {"Phan\\": "src/Phan"} +    }, +    "autoload-dev": { +        "psr-4": {"Phan\\Tests\\": "tests/Phan"} +    }, +    "bin": ["phan", "tocheckstyle"] +} diff --git a/phan-autoload.patch b/phan-autoload.patch new file mode 100644 index 0000000..4eb8753 --- /dev/null +++ b/phan-autoload.patch @@ -0,0 +1,88 @@ +diff -up ./src/codebase.php.rpm ./src/codebase.php +--- ./src/codebase.php.rpm	2016-11-24 16:15:15.615092571 +0100 ++++ ./src/codebase.php	2016-11-24 16:15:23.848136345 +0100 +@@ -7,14 +7,8 @@ $internal_trait_name_list = get_declared + $internal_function_name_list = get_defined_functions()['internal']; +  +  +-if (file_exists(__DIR__ . '/../vendor/autoload.php')) { +-  // This is the normal path when Phan is installed only in the scope of a project. +-  require_once __DIR__ . '/../vendor/autoload.php'; +-} +-else { +-  // This is the path to autoload.php when Phan is installed globally. +-  require_once __DIR__ . '/../../../autoload.php'; +-} ++// Use the fedora autoloader ++require_once __DIR__ . '/autoload.php'; +  + use Phan\CodeBase; +  +diff -up ./src/Phan/Bootstrap.php.rpm ./src/Phan/Bootstrap.php +--- ./src/Phan/Bootstrap.php.rpm	2016-11-24 16:12:00.366054438 +0100 ++++ ./src/Phan/Bootstrap.php	2016-11-24 16:16:28.316479122 +0100 +@@ -11,16 +11,8 @@ ini_set("memory_limit", '-1'); + define('CLASS_DIR', __DIR__ . '/../'); + set_include_path(get_include_path().PATH_SEPARATOR.CLASS_DIR); +  +-// Use the composer autoloader +-foreach ([ +-    __DIR__.'/../../vendor/autoload.php',          // autoloader is in this project +-    __DIR__.'/../../../../../vendor/autoload.php', // autoloader is in parent project +-    ] as $file) { +-    if (file_exists($file)) { +-        require_once($file); +-        break; +-    } +-} ++// Use the fedora autoloader ++require_once __DIR__ . '/autoload.php'; +  + define('EXIT_SUCCESS', 0); + define('EXIT_FAILURE', 1); +diff -up ./src/phan.php.rpm ./src/phan.php +--- ./src/phan.php.rpm	2016-11-24 16:08:41.223995606 +0100 ++++ ./src/phan.php	2016-11-24 16:11:41.311953128 +0100 +@@ -1,3 +1,4 @@ ++#!/usr/bin/env php + <?php declare(strict_types=1); +  + // Phan does a ton of GC and this offers a major speed +@@ -13,7 +14,7 @@ require_once(__DIR__ . '/requirements.ph + // own + $code_base = require_once(__DIR__ . '/codebase.php'); +  +-require_once(__DIR__ . '/Phan/Bootstrap.php'); ++require_once(__DIR__ . '/Bootstrap.php'); +  + use Phan\CLI; + use Phan\CodeBase; +diff -up ./src/prep.php.rpm ./src/prep.php +--- ./src/prep.php.rpm	2016-11-24 16:08:59.122090771 +0100 ++++ ./src/prep.php	2016-11-24 16:11:34.003914271 +0100 +@@ -1,3 +1,4 @@ ++#!/usr/bin/env php + <?php declare(strict_types=1); +  + // Phan does a ton of GC and this offers a major speed +@@ -7,7 +8,7 @@ gc_disable(); +  + // Check the environment to make sure Phan can run successfully + require_once(__DIR__ . '/requirements.php'); +-require_once(__DIR__ . '/Phan/Bootstrap.php'); ++require_once(__DIR__ . '/Bootstrap.php'); +  + use Phan\CLI; + use Phan\Prep; +diff -up ./src/requirements.php.rpm ./src/requirements.php +--- ./src/requirements.php.rpm	2016-11-24 16:15:45.623252123 +0100 ++++ ./src/requirements.php	2016-11-24 16:16:13.253399032 +0100 +@@ -11,7 +11,7 @@ assert( + ); +  + assert( +-    file_exists(__DIR__ . '/../vendor/autoload.php') || file_exists(__DIR__ . '/../../../autoload.php'), ++    file_exists(__DIR__ . '/autoload.php'), +     'Autoloader not found. Make sure you run `composer install` before running Phan. See https://github.com/etsy/phan#getting-it-running for more details.' + ); +  diff --git a/phan-autoload.php b/phan-autoload.php new file mode 100644 index 0000000..323e5b1 --- /dev/null +++ b/phan-autoload.php @@ -0,0 +1,9 @@ +<?php +/* Autoloader for etsy/phan and its dependencies */ + +require_once '/usr/share/php/Fedora/Autoloader/autoload.php'; + +\Fedora\Autoloader\Autoload::addPsr4('Phan\\', __DIR__); +\Fedora\Autoloader\Dependencies::required(array( +    '/usr/share/php/Symfony/Component/Console/autoload.php', +)); diff --git a/phan.spec b/phan.spec new file mode 100644 index 0000000..02ddbcb --- /dev/null +++ b/phan.spec @@ -0,0 +1,145 @@ +# remirepo/fedora spec file for phan +# +# Copyright (c) 2016 Remi Collet +# License: CC-BY-SA +# http://creativecommons.org/licenses/by-sa/4.0/ +# +# Please, preserve the changelog entries +# +%global gh_commit    ea92e93008491b780fbaf3e97487845e3f60c78f +%global gh_short     %(c=%{gh_commit}; echo ${c:0:7}) +%global gh_owner     etsy +#global gh_date      20150820 +%global gh_project   phan +%global psr0         Phan +%global with_tests   0%{!?_without_tests:1} + +Name:           %{gh_project} +Version:        0.6 +Release:        1%{?gh_date?%{gh_date}git%{gh_short}}%{?dist} +Summary:        A static analyzer for PHP + +Group:          Development/Libraries +License:        MIT +URL:            https://github.com/%{gh_owner}/%{gh_project} +Source0:        https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}-%{?gh_short}.tar.gz + +# Use fedora autoloader +Source1:        %{name}-autoload.php +Patch0:         %{name}-autoload.patch + +BuildArch:      noarch +%if %{with_tests} +BuildRequires:  php(language) >= 7.0 +BuildRequires:  php-ast +BuildRequires:  php-sqlite3 +BuildRequires:  php-composer(symfony/console) >= 2.8 +BuildRequires:  php-reflection +BuildRequires:  php-pcntl +BuildRequires:  php-pcre +BuildRequires:  php-posix +BuildRequires:  php-spl +BuildRequires:  php-sysvmsg +BuildRequires:  php-sysvsem +# For tests, from composer.json "require-dev": { +#        "phpunit/phpunit": "~5", +#        "phpdocumentor/phpdocumentor": "dev-master", +#        "squizlabs/php_codesniffer": "^2.5" +BuildRequires:  php-composer(phpunit/phpunit) >= 5 +%endif +# For autoloader +BuildRequires:  php-composer(fedora/autoloader) + +# From composer.json, "require": { +#        "php": ">=7.0", +#        "ext-ast": "*", +#        "ext-sqlite3": "0.7-dev", +#        "symfony/console": "~2.3|~3.0" +Requires:       php(language) >= 7.0 +Requires:       php-ast +Requires:       php-sqlite3 +Requires:       php-composer(symfony/console) >= 2.3 +# From phpcompatinfo report for 0.6 +Requires:       php-cli +Requires:       php-reflection +Requires:       php-pcntl +Requires:       php-pcre +Requires:       php-posix +Requires:       php-spl +Requires:       php-sysvmsg +Requires:       php-sysvsem +# For autoloader +Requires:       php-composer(fedora/autoloader) + +# Composer +Provides:       php-composer(%{gh_owner}/%{gh_project}) = %{version} + + +%description +Phan is a static analyzer that looks for common issues and will verify type +compatibility on various operations when type information is available or can +be deduced. Phan does not make any serious attempt to understand flow control +and narrow types based on conditionals. + + +%prep +%setup -q -n %{gh_project}-%{gh_commit} + +%patch0 -p1 + +cp %{SOURCE1} src/%{psr0}/autoload.php + + +%build +: Nothing to build + + +%install +: Library +mkdir -p           %{buildroot}%{_datadir}/php +cp -pr src/%{psr0} %{buildroot}%{_datadir}/php/%{psr0} + +: Relocated tools +cp -pr src/*php    %{buildroot}%{_datadir}/php/%{psr0}/ +install -Dpm 755 src/phan.php %{buildroot}%{_datadir}/php/%{psr0}/phan.php +install -Dpm 755 src/prep.php %{buildroot}%{_datadir}/php/%{psr0}/prep.php + +: Commands +mkdir -p %{buildroot}%{_bindir} +ln -s ../share/php/%{psr0}/phan.php %{buildroot}%{_bindir}/phan +ln -s ../share/php/%{psr0}/prep.php %{buildroot}%{_bindir}/phan-prep + + +%check +%if %{with_tests} +mkdir vendor +cat << 'EOF' | tee vendor/autoload.php +<?php +require '%{buildroot}%{_datadir}/php/%{psr0}/Bootstrap.php'; +\Fedora\Autoloader\Autoload::addPsr4('Phan\\Tests\\', dirname(__DIR__).'/tests/Phan'); +EOF + +%{_bindir}/phpunit -d memory_limit=1G --bootstrap vendor/autoload.php --verbose +%else +: Test suite disabled +%endif + + +%clean +rm -rf %{buildroot} + + +%files +%defattr(-,root,root,-) +%{!?_licensedir:%global license %%doc} +%license LICENSE +%doc composer.json +%doc *.md +%{_datadir}/php/%{psr0} +%{_bindir}/phan* + + +%changelog +* Thu Nov 24 2016 Remi Collet <remi@fedoraproject.org> - 0.6-1 +- initial package + | 
