pax_global_header00006660000000000000000000000064141741077650014526gustar00rootroot0000000000000052 comment=27a3d7c39181461f05b5fc3df0a43e054b86b04e Autoload-1.27.1/000077500000000000000000000000001417410776500133665ustar00rootroot00000000000000Autoload-1.27.1/.github/000077500000000000000000000000001417410776500147265ustar00rootroot00000000000000Autoload-1.27.1/.github/FUNDING.yml000066400000000000000000000001011417410776500165330ustar00rootroot00000000000000# These are supported funding model platforms github: [theseer] Autoload-1.27.1/.github/workflows/000077500000000000000000000000001417410776500167635ustar00rootroot00000000000000Autoload-1.27.1/.github/workflows/ci.yml000066400000000000000000000026511417410776500201050ustar00rootroot00000000000000name: Test on: # Run on all pushes and on all pull requests. push: pull_request: # Allow manually triggering the workflow. workflow_dispatch: jobs: test: runs-on: ubuntu-latest strategy: # Keys: # - experimental: Whether the build is "allowed to fail". matrix: php: ['7.2', '7.3', '7.4', '8.0'] experimental: [false] include: # Nightly. - php: '8.1' experimental: true name: "PHP: ${{ matrix.php }}" continue-on-error: ${{ matrix.experimental }} steps: - name: Checkout code uses: actions/checkout@v2 - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} ini-values: error_reporting=-1, display_errors=On, log_errors_max_len=0 coverage: none tools: phive - name: Install java uses: actions/setup-java@v2 with: java-version: 11 distribution: 'zulu' # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-composer-dependencies - name: Install Composer dependencies uses: "ramsey/composer-install@v2" - name: Lint the code run: ant lint - name: Install tools run: ant install-tools - name: Run unit tests run: ./tools/phpunit --configuration phpunit.xml.dist Autoload-1.27.1/.gitignore000066400000000000000000000001771417410776500153630ustar00rootroot00000000000000build phpunit.xml .project .buildpath .settings .gitignore .idea vendor composer /tools cache.properties .phpunit.result.cache Autoload-1.27.1/CHANGELOG.md000066400000000000000000000142051417410776500152010ustar00rootroot00000000000000# Changelog ## Release 1.27.1 * Fix/Avoid deprecation notices in PHP 8.1 ## Release 1.27.0 * Update ConsoleTools to 1.7.3. for better PHP 8.1 compatibilty * Add support for ENUM types (basic and backed) ## Release 1.26.3 * Update DirectoryScanner to 1.3.3 for PHP 8.1 compatibilty ## Release 1.26.2 * Fix Issue [#99](https://github.com/theseer/Autoload/pull/99): Fix PHP 8.0 deprecation warnings [jrfnl] ## Release 1.26.1 * Fix Issue [#98](https://github.com/theseer/Autoload/issues/98): Array to string conversion on parsing composer.json ## Release 1.26.0 * Fix Issue [#95](https://github.com/theseer/Autoload/pull/95): Update Parser to work with PHP 8.0's new tokens * Fix Issue [#90](https://github.com/theseer/Autoload/pull/90): Warnings and Notices in ComposerIterator * Merge PR [#97](https://github.com/theseer/Autoload/pull/97): Fix for xdebug v3 * Raise build requirement to PHP 7.2+ and PHPUnit 8.5; No change for runtime Version, so 5.3 is _still_ supported ## Release 1.25.9 * Merge PR [#89](https://github.com/theseer/Autoload/pull/89): Throw an exception if the template file cannot be read * Update ConsoleTools, Fixes [#91](https://github.com/theseer/Autoload/issues/91) - Zeta Components ConsoleTools uses PHP syntax deprecated in PHP 7.4 ## Release 1.25.8 * Fix Regression [#92](https://github.com/theseer/Autoload/issues/92): PHPAB 1.25.7 generates broken PHAR for PHPUnit ## Release 1.25.7 * Fix: Static require or compile lists now properly process pathes relative to and above the base directory ## Release 1.25.6 * Fix: Add `lib-` prefixed dependencies in composer.json to ignore list ## Release 1.25.5 * Merge PR [#86](https://github.com/theseer/Autoload/pull/86): Restore PHP 5.3 compatibility [Remi] ## Release 1.25.4 * Ensure include/exclude filter gets applied also in composer.json mode when files are explicitly set * Ensure files do not get processed multiple times in case composer.json has duplicate definitions in autoload section ## Release 1.25.3 * Fix [#83](https://github.com/theseer/Autoload/issues/83): Error with recursive Composer dependencies ## Release 1.25.2 * Fix Parser to ignore "inline" use of keywords `class`, `interface` and `trait` ## Release 1.25.1 * Merge PR [#81](https://github.com/theseer/Autoload/pull/81): Fix PHP 7.3 warnings [Remi] ## Release 1.25.0 * Add support for generating static files to use for opcache warming (-w, optionally with --reset) * Minor internal cleanup ## Release 1.24.1 * Merge PR [#78](https://github.com/theseer/Autoload/pull/78): Restore PHP 5.3 compatibility [Remi] ## Release 1.24.0 * [#77](https://github.com/theseer/Autoload/issues/77): Change duplicate detection to collect all rather than exit on first ## Release 1.23.0 * Add support for parsing code containing anonymous classes (PHP 7) * Some internal code cleanup ## Release 1.22.0 * Merge PR [#73](https://github.com/theseer/Autoload/pull/73): no cs/ci dir for static tpl [Remi] * Merge PR [#74](https://github.com/theseer/Autoload/pull/74): auto add suffix to (short) template name [Remi] ## Release 1.21.0 * Added --hash option to explicitly choose hash algorithm for phar generation (defaults to best available) ## Release 1.20.3 * Merge PR [#68](https://github.com/theseer/Autoload/pull/68): return parent dir when 2 dirs have a common prefix * Merge PR [#67](https://github.com/theseer/Autoload/pull/67): don't use 'vendor' in test suite * Some internal code cleanup ## Release 1.20.2 * Merge PR [#66](https://github.com/theseer/Autoload/pull/66): fix PathComparator when 0 in path [Remi] ## Release 1.20.1 * Fix issue #65: Trait sorted after using class when --static is used * Fix issue #63: Workdirectory included as subdirectory in phar archive (Regression as of 1.19.0) ## Release 1.20.0 * PHP 7: Added parsing support for new (grouped use syntax)[https://wiki.php.net/rfc/group_use_declarations] ## Release 1.19.2 * Remove debugging artefact ## Release 1.19.1 * Fix regression since 1.15.0: paranoid and trusting mode handling was switched ## Release 1.19.0 * Fix filenames via CLI to actually work [Remi] * Changed default basedir to be based on the output file rather than the directory to be scanned [Remi] ## Release 1.18.0 * Allow filenames as source instead of only allowing directories (this also fixes composer classmap issues) ## Release 1.17.0 * Added support for parameter 'prepend' of spl_autoload_register to allow for prepending without changing templates * Added support for parameter 'exception' of spl_autoload_register to optionally disable exceptions on errors ## Release 1.16.1 * Fix minor issues with composer.json handling * define date.timezone to avoid warning (in buildystem) [Remi] * Pear installation now deploys as phar ## Release 1.16.0 * Added whitelist/blacklist filter for classnames/namespaces * Ensure ext/fileinfo is loaded ## Release 1.15.1 * Fix regression for sorted static require lists ## Release 1.15.0 * Added support for composer.json parsing * Added (optional) caching * Added explicit wildcard support for directory name matching * Changed error messages on unit redeclarations * Some code cleanup and refactoring of internals ## Release 1.14.2 * Fix Trait handling in PHP 5.3 * Changed file type for phpunit.xml.dist in pear package ## Release 1.14.1 * Providing --alias in phar mode now sets ___PHAR___ accordingly * Updated DirectoryScanner to 1.3.0 ## Release 1.14.0 * Added support for PHP 5.5's classname::class constant to parser ## Release 1.13.1 * Fix Regression, make composer installs work again ## Release 1.13.0 * Added alias support to phar mode building ## Release 1.12.0 * Added composer support (Thanks to HCO) * Made parser code more robust to not crash on invalid names ## Release 1.11.0 * Added support for symlinks (Thanks to Jan Peterson) ## Release 1.10.3 * Support empty indent * Fixed Trait parsing ## Release 1.10.2 * Fixed mode flag handling on phar mode ## Release 1.10.1 * Various regression fixes after internal cleanup * Use git version info for development checkouts ## Release 1.10.0 * Added multi directory support * Added compression support to phar mode * Added support for openssl key signing of phars ##### Older Releases Please refer to the git history log for details Autoload-1.27.1/LICENSE000066400000000000000000000030101417410776500143650ustar00rootroot00000000000000Autoload Builder Copyright (c) 2010-2016 Arne Blankerts and Contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Arne Blankerts nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Autoload-1.27.1/README.md000066400000000000000000000153221417410776500146500ustar00rootroot00000000000000# PHP Autoload Builder The PHP AutoloadBuilder CLI tool **phpab** is a command line application to automate the process of generating an autoload require file with the option of creating static require lists as well as phar archives. ## Features * scan multiple directories recursively in one run, optionally follow symlinks, wildcards or based on composer.json * Cache scan results * Template based autoload code * Custom variables for templates * Compatibility mode for PHP 5.2 compliant autoloader * Case sensitive as well as case insensitive classname mapping * Phar generation, with or without compression and openssl key signing * Static require list generation * Opcache warming list generation * Linting of generated code ## Requirements * PHP 5.3+ (Runtime, for development / tests: 7.2+) * Fileinfo (ext/fileinfo) * Tokenizer (ext/tokenizer) * For PHAR generation support: + ext/phar (write enabled: phar.readonly = Off) + ext/gzip (optional) + ext/bzip2 (optional) + ext/openssl (optional, for phar signing only) ## Installation ### Executable PHAR The recommended way to install **phpab** is by using [phive](https://phar.io): ``` phive install phpab ``` #### Manual install If you do not have phive installed or want to install manually, you can download the PHAR archive from the [Releases](https://github.com/theseer/Autoload/releases) tab. _Please note:_ On Linux/Unix based system the phar needs to be marked executable for direct execution: ``` [theseer@rikka ~]$ chmod +x phpab*.phar ``` ## Other Downloads * [Latest development snapshot](https://github.com/theseer/Autoload/archive/master.zip) (ZIP Archive) * [Releases (Source)](https://github.com/theseer/Autoload/tags) ## Usage ``` Usage: phpab [switches] [...] -i, --include File pattern to include (default: *.php) -e, --exclude File pattern to exclude --blacklist Blacklist classname or namespace (wildcards supported) --whitelist Whitelist classname or namespace (wildcards supported) -b, --basedir Basedir for filepaths -t, --template Path to code template to use -o, --output Output file for generated code (default: STDOUT) -p, --phar Create a phar archive (requires -o ) --all Include all files in given directory when creating a phar --alias Specify explicit internal phar alias filename (default: output filename) --hash Force given hash algorithm (SHA-1, SHA-256 or SHA-512) (requires -p, conflicts with --key) --bzip2 Compress phar archive using bzip2 (requires -p) (bzip2 required) --gzip Compress phar archive using gzip (requires -p) (gzip required) --key OpenSSL key file to use for signing phar archive (requires -p) (openssl required) -c, --compat Generate PHP 5.2 compatible code -s, --static Generate a static require file -w, --warm Generate a static opcache warming file --reset Add opcache reset call when generating opcache warming file -1, --prepend Register as first autoloader (prepend to stack, default: append) -d, --no-exception Do not throw exception on registration problem (default: throw exception) -n, --nolower Do not lowercase classnames for case insensitivity -q, --quiet Quiet mode, do not output any processing errors or information --cache Enable caching and set filename to use for cache storage --follow Enables following symbolic links (not compatible with phar mode) --format Dateformat string for timestamp --linebreak Linebreak style (CR, CRLF or LF, default: LF) --indent String used for indenting or number of spaces (default: 16 (compat 12) spaces) --tolerant Ignore Class Redeclarations in the same file --once Use require_once instead of require when creating a static require file --trusting Do not check mimetype of files prior to parsing (default) --paranoid Do check mimetype of files prior to parsing --var name=foo Assign value 'foo' to variable 'name' to be used in (custom) templates --lint Run lint on generated code and exit --lint-php PHP binary to use for linting (default: /usr/bin/php or c:\php\php.exe) -h, --help Prints this usage information -v, --version Prints the version and exits ``` ### Usage Examples [theseer@rikka ~]$ phpab -o src/autoload.php -b src composer.json [theseer@rikka ~]$ phpab -o opcache_warming.php -w --reset src [theseer@rikka ~]$ phpab -o src/autoload.inc.php src [theseer@rikka ~]$ phpab -c -o src/autoload.inc.php src [theseer@rikka ~]$ phpab -o src/core/autoload.inc.php -b src src [theseer@rikka ~]$ phpab -p -o framework.phar -b src composer.json [theseer@rikka ~]$ phpab -p -o framework.phar framework/src [theseer@rikka ~]$ phpab -p -o framework.phar --bzip2 --key sign.key framework/src [theseer@rikka ~]$ phpab -b . --tolerant -o zf1_autoload.php -e '*/Test/*' Zend ### Automation When using *phpab* it is necessary to recreate the autoload file every time a new class is created. This usually also happens after pulling from a repo or when switchting branches. Using a git `post-checkout` hook placed in `.git/hooks/post-update` this can be automated for most cases. #### Basic Sample: ```bash #!/bin/bash phpab -c -o src/autoload.inc.php src ``` #### Sample using an `ant build.xml` file. ```bash #!/bin/bash if [ -f build.xml ]; then ant -p | grep phpab > /dev/null if [ $? -eq 0 ]; then ant phpab > /dev/null & fi fi ``` ## Template Variables The generated code is based uppon templates provided by default in the templates subfolder. The template engine allows for simply replacing of name based placeholders. For now, only a few default variables are defined but API hooks / CLI parameters exist to set custom variables. Known variables are: * ```___CREATED___``` Set to a timestamp of creation, format can be adjusted * ```___CLASSLIST___``` The found list classes in form of a generated map * ```___BASEDIR___``` If a Basedir is set, the value will get removed from the file path and get replaced by __DIR__ Used in PHAR Mode only: * ```___PHAR___``` The filename of the generated phar or it's alias when --alias is given (see src/templates/phar.php.tpl) Custom variables as defined by passing --var name=value via cli are accessed by pre- and appending ___ to it: * ```___name___``` Going to be replaced by the value provided via cli param ## Changelog The [changelog](https://github.com/theseer/Autoload/blob/master/CHANGELOG.md) moved to its own document Autoload-1.27.1/build.xml000066400000000000000000000131341417410776500152110ustar00rootroot00000000000000 Autoload-1.27.1/composer.json000066400000000000000000000010761417410776500161140ustar00rootroot00000000000000{ "name": "theseer/autoload", "description": "A tool and library to generate autoload code.", "require": { "php": ">=5.3", "theseer/directoryscanner": "^1.3.3", "zetacomponents/console-tools": "^1.7" }, "require-dev": { "php": ">=7.2" }, "autoload": { "classmap": [ "src/" ] }, "license": "BSD-3-Clause", "authors": [ { "name": "Arne Blankerts", "email": "arne@blankerts.de" } ], "bin": [ "composer/bin/phpab" ] } Autoload-1.27.1/composer.lock000066400000000000000000000157511417410776500161000ustar00rootroot00000000000000{ "_readme": [ "This file locks the dependencies of your project to a known state", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], "content-hash": "799a08a42874d2be88175b317929e370", "packages": [ { "name": "theseer/directoryscanner", "version": "1.3.3", "source": { "type": "git", "url": "https://github.com/theseer/DirectoryScanner.git", "reference": "4cdce31c1b5120779a01225b5b0968f9321342d6" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/theseer/DirectoryScanner/zipball/4cdce31c1b5120779a01225b5b0968f9321342d6", "reference": "4cdce31c1b5120779a01225b5b0968f9321342d6", "shasum": "" }, "require": { "php": ">=5.3.1" }, "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, "autoload": { "classmap": [ "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-2-Clause" ], "authors": [ { "name": "Arne Blankerts", "email": "arne@blankerts.de", "role": "Developer" } ], "description": "A recursive directory scanner and filter", "support": { "issues": "https://github.com/theseer/DirectoryScanner/issues", "source": "https://github.com/theseer/DirectoryScanner/tree/1.3.3" }, "time": "2021-07-24T18:41:34+00:00" }, { "name": "zetacomponents/base", "version": "1.9.3", "source": { "type": "git", "url": "https://github.com/zetacomponents/Base.git", "reference": "2f432f4117a5aa2164d4fb1784f84db91dbdd3b8" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zetacomponents/Base/zipball/2f432f4117a5aa2164d4fb1784f84db91dbdd3b8", "reference": "2f432f4117a5aa2164d4fb1784f84db91dbdd3b8", "shasum": "" }, "require-dev": { "phpunit/phpunit": "~8.0", "zetacomponents/unit-test": "*" }, "type": "library", "autoload": { "classmap": [ "src" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "Apache-2.0" ], "authors": [ { "name": "Sergey Alexeev" }, { "name": "Sebastian Bergmann" }, { "name": "Jan Borsodi" }, { "name": "Raymond Bosman" }, { "name": "Frederik Holljen" }, { "name": "Kore Nordmann" }, { "name": "Derick Rethans" }, { "name": "Vadym Savchuk" }, { "name": "Tobias Schlitt" }, { "name": "Alexandru Stanoi" } ], "description": "The Base package provides the basic infrastructure that all packages rely on. Therefore every component relies on this package.", "homepage": "https://github.com/zetacomponents", "support": { "issues": "https://github.com/zetacomponents/Base/issues", "source": "https://github.com/zetacomponents/Base/tree/1.9.3" }, "time": "2021-07-25T15:46:08+00:00" }, { "name": "zetacomponents/console-tools", "version": "1.7.3", "source": { "type": "git", "url": "https://github.com/zetacomponents/ConsoleTools.git", "reference": "fbc31f1be66ccd178c68d846d7c0ae09dbb97c89" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/zetacomponents/ConsoleTools/zipball/fbc31f1be66ccd178c68d846d7c0ae09dbb97c89", "reference": "fbc31f1be66ccd178c68d846d7c0ae09dbb97c89", "shasum": "" }, "require": { "zetacomponents/base": "~1.8" }, "require-dev": { "phpunit/phpunit": "~8.0", "zetacomponents/unit-test": "*" }, "type": "library", "autoload": { "classmap": [ "src" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "Apache-2.0" ], "authors": [ { "name": "Sergey Alexeev" }, { "name": "Sebastian Bergmann" }, { "name": "Jan Borsodi" }, { "name": "Raymond Bosman" }, { "name": "Frederik Holljen" }, { "name": "Kore Nordmann" }, { "name": "Derick Rethans" }, { "name": "Vadym Savchuk" }, { "name": "Tobias Schlitt" }, { "name": "Alexandru Stanoi" } ], "description": "A set of classes to do different actions with the console (also called shell). It can render a progress bar, tables and a status bar and contains a class for parsing command line options.", "homepage": "https://github.com/zetacomponents", "support": { "issues": "https://github.com/zetacomponents/ConsoleTools/issues", "source": "https://github.com/zetacomponents/ConsoleTools/tree/1.7.3" }, "time": "2022-01-19T11:16:04+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { "php": ">=5.3" }, "platform-dev": { "php": ">=7.2" }, "plugin-api-version": "2.0.0" } Autoload-1.27.1/composer/000077500000000000000000000000001417410776500152155ustar00rootroot00000000000000Autoload-1.27.1/composer/bin/000077500000000000000000000000001417410776500157655ustar00rootroot00000000000000Autoload-1.27.1/composer/bin/phpab000077500000000000000000000043731417410776500170140ustar00rootroot00000000000000#!/usr/bin/env php * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License * * Exit codes: * 0 - No error * 1 - Execution Error * 3 - Parameter Error * 4 - Lint Error */ define('PHPAB_VERSION', '%development%'); $files = array( __DIR__ . '/../../vendor/autoload.php', __DIR__ . '/../../../../autoload.php' ); foreach ($files as $file) { if (file_exists($file)) { require $file; break; } } require __DIR__ . '/../../src/autoload.php'; $factory = new \TheSeer\Autoload\Factory(); $factory->getCLI()->run(); exit(0); Autoload-1.27.1/phive.xml000066400000000000000000000002711417410776500152230ustar00rootroot00000000000000 Autoload-1.27.1/phpab.bat000066400000000000000000000033251417410776500151530ustar00rootroot00000000000000@echo off REM phpab REM REM Copyright (c) 2009-2019, Arne Blankerts and contributors * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License * * Exit codes: * 0 - No error * 1 - Execution Error * 3 - Parameter Error * 4 - Lint Error * 5 - Duplicates found Error */ define('PHPAB_VERSION', '%development%'); if (!ini_get('date.timezone')) { ini_set('date.timezone', 'UTC'); } require __DIR__ . '/src/autoload.php'; $factory = new \TheSeer\Autoload\Factory(); $factory->getCLI()->run(); exit(0); Autoload-1.27.1/phpcs.xml000066400000000000000000000026111417410776500152250ustar00rootroot00000000000000 Arne Blankerts' coding standard Autoload-1.27.1/phpunit.xml.dist000066400000000000000000000015411417410776500165420ustar00rootroot00000000000000 tests src src/templates src/cli.php Autoload-1.27.1/samples/000077500000000000000000000000001417410776500150325ustar00rootroot00000000000000Autoload-1.27.1/samples/sample.php000066400000000000000000000004651417410776500170310ustar00rootroot00000000000000parse(new \TheSeer\Autoload\SourceFile(__DIR__ . '/../src/Parser.php')); var_dump($result->getUnits(), $result->getDependenciesForUnit(strtolower(\TheSeer\Autoload\ParserException::class))); Autoload-1.27.1/src/000077500000000000000000000000001417410776500141555ustar00rootroot00000000000000Autoload-1.27.1/src/Application.php000066400000000000000000000231121417410776500171300ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License * */ namespace TheSeer\Autoload { class Application { private $logger; private $factory; private $config; public function __construct(Logger $logger, Config $config, Factory $factory) { $this->logger = $logger; $this->config = $config; $this->factory = $factory; } public function run() { $result = $this->runCollector(); if (!$result->hasUnits()) { throw new ApplicationException('No units were found - process aborted.', ApplicationException::NoUnitsFound); } if ($result->hasDuplicates()) { return $this->showDuplicatesError($result->getDuplicates()); } if ($this->config->isCacheEnabled()) { $this->factory->getCache()->persist($this->config->getCacheFile()); } $template = @file_get_contents($this->config->getTemplate()); if ($template === false) { throw new ApplicationException("Failed to read the template file."); } $builder = $this->factory->getRenderer($result); $code = $builder->render($template); if ($this->config->isLintMode()) { return $this->runLint($code); } return $this->runSaver($code); } /** * @return CollectorResult */ private function runCollector() { if ($this->config->isFollowSymlinks()) { $this->logger->log('Following symbolic links is enabled.' . "\n\n"); } $collector = $this->factory->getCollector(); foreach ($this->config->getDirectories() as $directory) { if (is_dir($directory)) { $this->logger->log('Scanning directory ' . $directory . "\n"); $scanner = $this->factory->getScanner()->getIterator($directory); $collector->processDirectory($scanner); // this unset is needed to "fix" a segfault on shutdown in some PHP Versions unset($scanner); } else { $file = new \SplFileInfo($directory); $filter = $this->factory->getFilter(new \ArrayIterator(array($file))); foreach($filter as $file) { $this->logger->log('Scanning file ' . $file . "\n"); $collector->processFile($file); } } } return $collector->getResult(); } private function runSaver($code) { $output = $this->config->getOutputFile(); if (!$this->config->isPharMode()) { if ($output === 'STDOUT') { $this->logger->log("\n"); echo $code; $this->logger->log("\n\n"); return CLI::RC_OK; } // @codingStandardsIgnoreStart $written = @file_put_contents($output, $code); // @codingStandardsIgnoreEnd if ($written != strlen($code)) { $this->logger->log("Writing to file '$output' failed.", STDERR); return CLI::RC_EXEC_ERROR; } $this->logger->log("\nAutoload file {$output} generated.\n\n"); return CLI::RC_OK; } if (strpos($code, '__HALT_COMPILER();') === FALSE) { $this->logger->log( "Warning: Template used in phar mode did not contain required __HALT_COMPILER() call\n" . "which has been added automatically. The used stub code may not work as intended.\n\n", STDERR); $code .= $this->config->getLinebreak() . '__HALT_COMPILER();'; } $pharBuilder = $this->factory->getPharBuilder(); if ($keyfile = $this->config->getPharKey()) { $pharBuilder->setSignatureKey($this->loadPharSignatureKey($keyfile)); } if ($aliasName = $this->config->getPharAliasName()) { $pharBuilder->setAliasName($aliasName); } if ($this->config->hasPharHashAlgorithm()) { $pharBuilder->setSignatureType($this->config->getPharHashAlgorithm()); } $pharBuilder->build($output, $code); $this->logger->log("\nphar archive '{$output}' generated.\n\n"); return CLI::RC_OK; } private function loadPharSignatureKey($keyfile) { if (!extension_loaded('openssl')) { throw new ApplicationException('Extension for OpenSSL not loaded - cannot sign phar archive - process aborted.', ApplicationException::OpenSSLError); } $keydata = file_get_contents($keyfile); if (strpos($keydata, 'ENCRYPTED') !== FALSE) { $this->logger->log("Passphrase for key '$keyfile': "); $g = shell_exec('stty -g'); shell_exec('stty -echo'); $passphrase = trim(fgets(STDIN)); $this->logger->log("\n"); shell_exec('stty ' . $g); $private = openssl_pkey_get_private($keydata, $passphrase); } else { $private = openssl_pkey_get_private($keydata); } if (!$private) { throw new ApplicationException("Opening private key '$keyfile' failed - process aborted.\n\n", ApplicationException::OpenSSLError); } return $private; } /** * Execute a lint check on generated code * * @param string $code Generated code to lint * * @return boolean */ protected function runLint($code) { $dsp = array( 0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w') ); $binary = $this->config->getPhp(); $process = proc_open($binary . ' -l', $dsp, $pipes); if (!is_resource($process)) { $this->logger->log("Opening php binary for linting failed.\n", STDERR); return 1; } fwrite($pipes[0], $code); fclose($pipes[0]); fclose($pipes[1]); $stderr = stream_get_contents($pipes[2]); fclose($pipes[2]); $rc = proc_close($process); if ($rc == 255) { $this->logger->log("Syntax errors during lint:\n" . str_replace('in - on line', 'in generated code on line', $stderr) . "\n", STDERR); return CLI::RC_LINT_ERROR; } $this->logger->log("Lint check of geneated code okay\n\n"); return CLI::RC_OK; } /** * @param array $duplicates * * @return int */ private function showDuplicatesError(array $duplicates) { $this->logger->log( sprintf("\nMultiple declarations of trait(s), interface(s) or class(es). Could not generate autoload map.\n"), STDERR ); foreach($duplicates as $unit => $files) { $this->logger->log( sprintf("\nUnit '%s' defined in:\n", $unit), STDERR ); /** @var array $files */ foreach($files as $file) { $this->logger->log( sprintf(" - %s\n", $file), STDERR ); } } return CLI::RC_DUPLICATES_ERROR; } } class ApplicationException extends \Exception { const NoUnitsFound = 1; const OpenSSLError = 2; } } Autoload-1.27.1/src/AutoloadRenderer.php000066400000000000000000000215431417410776500201320ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\Autoload { /** * Builds spl based autoload code for inclusion into projects * * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. */ class AutoloadRenderer { /** * Associative array of classes (key) and the files (value) they are in * * @var array */ protected $classes; /** * An optional base dir to strip for the realpath of the filename * * @var string */ protected $baseDir = ''; /** * Indenting char(s) * * @var string */ protected $indent = ' '; /** * Char(s) used as linebreak * * @var string */ protected $linebreak = "\n"; /** * Timestamp of production start * * @var integer */ protected $timestamp; /** * Format string supplied to date() for use with ___CREATED___ * * @var string */ protected $dateformat = 'r'; /** * Variables for templates * * @var array */ protected $variables = array(); /** * Flag to toggle PHP 5.2 compat mode * * @var boolean */ protected $compat = false; /** * Flag to pass on to spl_autoload_register to prepend * * @var bool */ private $usePrepend = false; /** * Flag to pass on to spl_autoload_register to optionally throw exceptions on registration error * * @var bool */ private $throwExceptions = false; /** * Constructor of AutoloadRenderer class * * @param array $classlist Array of classes * */ public function __construct(array $classlist) { $this->classes = $classlist; ksort($this->classes); } /** * Toggle PHP 5.2 compat mode * * @param boolean $mode Mode to set compat to */ public function setCompat($mode) { $this->compat = $mode; } public function enableExceptions() { $this->throwExceptions = true; } public function prependAutoloader() { $this->usePrepend = true; } /** * Setter for the Basedir * * @param string $dir Path to strip from beginning of filenames * * @return void */ public function setBaseDir($dir) { $this->baseDir = $dir; } /** * Overwrite default or previously set indenting option * * @param string $indent Char(s) to use for indenting * * @return void */ public function setIndent($indent) { $this->indent = $indent; } /** * Overwrite default or previously set linebreak chars * * @param string $lbs Code to set linebreak * * @return void */ public function setLineBreak($lbs) { $this->linebreak = $lbs; } /** * Accessor for current linebreak setting * * @return string */ public function getLineBreak() { return $this->linebreak; } /** * Setter to use allow usage of fixed date/time for ___CREATED___ * * @param integer $time unix timestamp * * @throws AutoloadBuilderException */ public function setTimestamp($time) { if (!is_int($time) && null !== $time) { throw new AutoloadBuilderException("'$time' is not a unix timestamp", AutoloadBuilderException::InvalidTimestamp); } $this->timestamp = $time; } /** * Setter to adjust the date/time format output of ___CREATED___ * * @param string $frmt Date/Time format string */ public function setDateTimeFormat($frmt) { $this->dateformat = $frmt; } /** * Set a variable for use with template code * * @param string $name Key name (use as ___key___ in template) * @param string $value Value to use */ public function setVariable($name, $value) { $this->variables['___'.$name.'___'] = $value; } /** * Resolve relative location of file path to basedir if one is set and fix potential * broken windows pathnames when run on windows. * * @param string $fname * * @return string */ protected function resolvePath($fname) { if (empty($this->baseDir)) { return str_replace('\\', '/', $fname); } $basedir = explode(DIRECTORY_SEPARATOR, $this->baseDir); $filedir = explode(DIRECTORY_SEPARATOR, dirname(realpath($fname))); $pos = 0; $max = count($basedir); while (isset($filedir[$pos]) && $filedir[$pos] == $basedir[$pos]) { $pos++; if ($pos == $max) { break; } } if ($pos == 0) { return str_replace('\\', '/', $fname); } $rel = join('/', array_slice($filedir, $pos)); if (!empty($rel)) { $rel .= '/'; } if ($posclasses as $class => $file) { $fname = $this->resolvePath($file); $entries[] = "'". addslashes($class). "' => '$fname'"; } $baseDir = ''; if ($this->baseDir) { $baseDir = $this->compat ? 'dirname(__FILE__) . ' : '__DIR__ . '; } $replace = array_merge($this->variables, array( '___CREATED___' => date( $this->dateformat, $this->timestamp ? $this->timestamp : time()), '___CLASSLIST___' => join( ',' . $this->linebreak . $this->indent, $entries), '___BASEDIR___' => $baseDir, '___AUTOLOAD___' => 'autoload' . md5(serialize($entries)), '___EXCEPTION___' => $this->throwExceptions ? 'true' : 'false', '___PREPEND___' => $this->usePrepend ? 'true' : 'false' )); return str_replace(array_keys($replace), array_values($replace), $template); } } class AutoloadBuilderException extends \Exception { const TemplateNotFound = 1; const InvalidTimestamp = 2; } } Autoload-1.27.1/src/CLI.php000066400000000000000000000572031417410776500153040ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\Autoload { /** * CLI interface to AutoloadRenderer / StaticRenderer * * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. */ class CLI { const RC_OK = 0; const RC_EXEC_ERROR = 1; const RC_PARAM_ERROR = 3; const RC_LINT_ERROR = 4; const RC_DUPLICATES_ERROR = 5; private $pharOption; private $staticOption; private $helpOption; private $versionOption; private $onceOption; /** * @var Factory */ private $factory; public function __construct(Factory $factory) { $this->factory = $factory; } /** * Main executor method * * @return void */ public function run() { try { $this->preBootstrap(); $input = $this->setupInput(); $input->process(); if ($input->getOption('help')->value === TRUE) { $this->showVersion(); $this->showUsage(); exit(CLI::RC_OK); } if ($input->getOption('version')->value === TRUE ) { $this->showVersion(); exit(CLI::RC_OK); } $config = $this->configure($input); $this->factory->setConfig($config); if (!$config->isQuietMode()) { $this->showVersion(); } $rc = $this->factory->getApplication()->run(); exit($rc); } catch (CLIEnvironmentException $e) { $this->showVersion(); fwrite(STDERR, 'Sorry, but your PHP environment is currently not able to run phpab due to'); fwrite(STDERR, "\nthe following issue(s):\n\n" . $e->getMessage() . "\n\n"); fwrite(STDERR, "Please adjust your PHP configuration and try again.\n\n"); exit(CLI::RC_EXEC_ERROR); } catch (\ezcConsoleException $e) { $this->showVersion(); echo $e->getMessage() . "\n\n"; $this->showUsage(); exit(CLI::RC_PARAM_ERROR); } catch (CollectorException $e) { switch($e->getCode()) { case CollectorException::InFileRedeclarationFound: case CollectorException::RedeclarationFound: case CollectorException::ParseErrror: { $message = $e->getMessage(); break; } default: { $message = 'Unexpected error in collector process: ' . $e->getMessage() . "\n\nPlease report this as a bug.\n\n"; } } $this->showVersion(); fwrite(STDERR, $message . "\n\n"); exit(CLI::RC_EXEC_ERROR); } catch (\Exception $e) { $this->showVersion(); fwrite(STDERR, "\nError while processing request:\n - " . $e->getMessage()."\n"); exit(CLI::RC_EXEC_ERROR); } } /** * @param \ezcConsoleInput $input * * @return \TheSeer\Autoload\Config */ private function configure(\ezcConsoleInput $input) { $config = new Config($input->getArguments()); if ($input->getOption('quiet')->value) { $config->setQuietMode(TRUE); } if ($input->getOption('compat')->value) { $config->setCompatMode(TRUE); } if ($input->getOption('tolerant')->value) { $config->setTolerantMode(TRUE); } if ($output = $input->getOption('output')->value) { $config->setOutputFile($output); } if ($input->getOption('phar')->value) { $compression = \Phar::NONE; if ($input->getOption('bzip2')->value === TRUE) { $compression = \Phar::BZ2; } else if ($input->getOption('gzip')->value === TRUE) { $compression = \Phar::GZ; } $config->enablePharMode( $compression, $input->getOption('all')->value, $input->getOption('key')->value, $input->getOption('alias')->value ); $config->setVariable('PHAR', $input->getOption('alias')->value ? $input->getOption('alias')->value : basename($output) ); if ($hashAlgorithm = $input->getOption('hash')->value) { $config->setPharHashAlgorithm($hashAlgorithm); } } if ($input->getOption('cache')->value) { $config->setCacheFile($input->getOption('cache')->value); } if ($basedir = $input->getOption('basedir')->value) { $config->setBaseDirectory($basedir); } $include = $input->getOption('include')->value; if (!is_array($include)) { $include = array($include); } $config->setInclude($include); if ($exclude = $input->getOption('exclude')->value) { if (!is_array($exclude)) { $exclude = array($exclude); } $config->setExclude($exclude); } $whitelist = $input->getOption('whitelist')->value; if (!is_array($whitelist)) { $whitelist = array($whitelist); } $config->setWhitelist($whitelist); if ($blacklist = $input->getOption('blacklist')->value) { if (!is_array($blacklist)) { $blacklist = array($blacklist); } $config->setBlacklist($blacklist); } if ($input->getOption('static')->value) { $config->setStaticMode(TRUE); } if ($input->getOption('once')->value) { $config->setOnceMode(TRUE); } if ($input->getOption('warm')->value) { $config->setWarmMode(TRUE); } if ($input->getOption('reset')->value) { $config->setResetMode(TRUE); } if ($input->getOption('follow')->value) { $config->setFollowSymlinks(TRUE); } if ($input->getOption('prepend')->value) { $config->enablePrepend(); } if ($input->getOption('no-exception')->value) { $config->disableExceptions(); } $indent = $input->getOption('indent')->value; if ($indent !== FALSE) { $config->setIndent($indent); } if ($template = $input->getOption('template')->value) { $config->setTemplate($template); } if ($linebreak = $input->getOption('linebreak')->value) { $config->setLinebreak($linebreak); } if ($input->getOption('nolower')->value) { $config->setLowercaseMode(FALSE); } if ($variables = $input->getOption('var')->value) { foreach($variables as $var) { if (strpos($var, '=')===FALSE) { throw new \RuntimeException("Variable defintion '$var' is invalid and cannot be processed."); } list($name, $value) = explode('=', $var, 2); $config->setVariable($name, $value); } } if ($input->getOption('paranoid')->value || !$input->getOption('trusting')->value) { $config->setTrusting(FALSE); } return $config; } /** * Helper to output version information */ protected function showVersion() { static $shown = false; if (!$shown) { $shown = true; echo Version::getInfoString() . "\n\n"; } } /** * Helper to output usage information */ protected function showUsage() { print << [...] -i, --include File pattern to include (default: *.php) -e, --exclude File pattern to exclude --blacklist Blacklist classname or namespace (wildcards supported) --whitelist Whitelist classname or namespace (wildcards supported) -b, --basedir Basedir for filepaths -t, --template Path to code template to use -o, --output Output file for generated code (default: STDOUT) -p, --phar Create a phar archive (requires -o ) --all Include all files in given directory when creating a phar --alias Specify explicit internal phar alias filename (default: output filename) --hash Force given hash algorithm (SHA-1, SHA-256 or SHA-512) (requires -p, conflicts with --key) --bzip2 Compress phar archive using bzip2 (requires -p) (bzip2 required) --gzip Compress phar archive using gzip (requires -p) (gzip required) --key OpenSSL key file to use for signing phar archive (requires -p) (openssl required) -c, --compat Generate PHP 5.2 compatible code -s, --static Generate a static require file -w, --warm Generate a static opcache warming file --reset Add opcache reset call when generating opcache warming file -1, --prepend Register as first autoloader (prepend to stack, default: append) -d, --no-exception Do not throw exception on registration problem (default: throw exception) -n, --nolower Do not lowercase classnames for case insensitivity -q, --quiet Quiet mode, do not output any processing errors or information --cache Enable caching and set filename to use for cache storage --follow Enables following symbolic links (not compatible with phar mode) --format Dateformat string for timestamp --linebreak Linebreak style (CR, CRLF or LF, default: LF) --indent String used for indenting or number of spaces (default: 16 (compat 12) spaces) --tolerant Ignore Class Redeclarations in the same file --once Use require_once instead of require when creating a static require file --trusting Do not check mimetype of files prior to parsing (default) --paranoid Do check mimetype of files prior to parsing --var name=foo Assign value 'foo' to variable 'name' to be used in (custom) templates --lint Run lint on generated code and exit --lint-php PHP binary to use for linting (default: /usr/bin/php or c:\php\php.exe) -h, --help Prints this usage information -v, --version Prints the version and exits EOF; } /** * @return \ezcConsoleInput */ protected function setupInput() { $input = new \ezcConsoleInput(); $this->versionOption = $input->registerOption( new \ezcConsoleOption( 'v', 'version' ) ); $this->versionOption->shorthelp = 'Prints the version and exits'; $this->versionOption->isHelpOption = TRUE; $this->helpOption = $input->registerOption( new \ezcConsoleOption( 'h', 'help' ) ); $this->helpOption->isHelpOption = TRUE; $this->helpOption->shorthelp = 'Prints this usage information'; $input->registerOption( new \ezcConsoleOption( '', 'cache', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Enable cache and set cache filename' )); $this->outputOption = $input->registerOption( new \ezcConsoleOption( 'o', 'output', \ezcConsoleInput::TYPE_STRING, 'STDOUT', FALSE, 'Output file for generated code (default: STDOUT)' )); $this->pharOption = $input->registerOption( new \ezcConsoleOption( 'p', 'phar', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Build a phar archive of directory contents', NULL, array( new \ezcConsoleOptionRule( $input->getOption( 'o' ) ) ) )); $input->registerOption( new \ezcConsoleOption( '', 'all', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Add all files from src dir to phar', NULL, array( new \ezcConsoleOptionRule( $input->getOption( 'p' ) ) ) )); $input->registerOption( new \ezcConsoleOption( '', 'alias', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Provide explicit internal alias filename for phar', NULL, array( new \ezcConsoleOptionRule( $input->getOption( 'p' ) ) ) )); $bzip2 = $input->registerOption( new \ezcConsoleOption( '', 'bzip2', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Compress files phar with bzip2', NULL, array( new \ezcConsoleOptionRule( $input->getOption( 'p' ) ) ) )); $gzip = $input->registerOption( new \ezcConsoleOption( '', 'gzip', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Compress files phar with gzip', NULL, array( new \ezcConsoleOptionRule( $input->getOption( 'p' ) ) ), array( new \ezcConsoleOptionRule( $bzip2 ) ) )); $bzip2->addExclusion(new \ezcConsoleOptionRule($gzip)); $input->registerOption( new \ezcConsoleOption( '', 'key', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Keyfile to use for signing phar archive', NULL, array( new \ezcConsoleOptionRule( $input->getOption( 'p' ) ) ) )); $this->outputOption = $input->registerOption( new \ezcConsoleOption( '', 'hash', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Force given hash algorithm (SHA-1, SHA-256 or SHA-512) (requires -p)', NULL, array( new \ezcConsoleOptionRule( $input->getOption( 'p' ) ) ), array( new \ezcConsoleOptionRule( $input->getOption( 'key' ) ) ) )); $input->registerOption( new \ezcConsoleOption( 'i', 'include', \ezcConsoleInput::TYPE_STRING, '*.php', TRUE, 'File pattern to include (default: *.php)' )); $input->registerOption( new \ezcConsoleOption( '', 'blacklist', \ezcConsoleInput::TYPE_STRING, NULL, TRUE, 'Name pattern to exclude' )); $input->registerOption( new \ezcConsoleOption( '', 'whitelist', \ezcConsoleInput::TYPE_STRING, '*', TRUE, 'Name pattern to include (default: *)' )); $input->registerOption( new \ezcConsoleOption( 'e', 'exclude', \ezcConsoleInput::TYPE_STRING, NULL, TRUE, 'File pattern to exclude' )); $input->registerOption( new \ezcConsoleOption( 'b', 'basedir', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Basedir for filepaths' )); $input->registerOption( new \ezcConsoleOption( 't', 'template', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Path to code template to use' )); $input->registerOption( new \ezcConsoleOption( '', 'follow', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Enables following symbolic links', NULL, array(), array( new \ezcConsoleOptionRule($this->pharOption) ) )); $input->registerOption( new \ezcConsoleOption( '', 'format', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Dateformat string for timestamp' )); $input->registerOption( new \ezcConsoleOption( '', 'linebreak', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'Linebreak style (CR, CR/LF or LF)' )); $input->registerOption( new \ezcConsoleOption( '', 'indent', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'String used for indenting (default: 3 spaces)' )); $this->lintOption = $input->registerOption( new \ezcConsoleOption( '', 'lint', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Run lint on generated code' )); $input->registerOption( new \ezcConsoleOption( '', 'lint-php', \ezcConsoleInput::TYPE_STRING, NULL, FALSE, 'PHP binary path for linting (default: /usr/bin/php or c:\\php\\php.exe)', NULL, array( new \ezcConsoleOptionRule( $input->getOption( 'lint' ) ) ) )); $compat = $input->registerOption( new \ezcConsoleOption( 'c', 'compat', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Generate PHP 5.2 compliant code' )); $this->staticOption = $input->registerOption( new \ezcConsoleOption( 's', 'static', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Build a static require file' )); $input->registerOption( new \ezcConsoleOption( '', 'tolerant', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Ignore Class Redeclarations in the same file' )); $trusting = $input->registerOption( new \ezcConsoleOption( '', 'trusting', \ezcConsoleInput::TYPE_NONE, TRUE, FALSE, 'Do not check mimetype of files prior to parsing' )); $paranoid = $input->registerOption( new \ezcConsoleOption( '', 'paranoid', \ezcConsoleInput::TYPE_NONE, FALSE, FALSE, 'Do check mimetype of files prior to parsing', NULL, array(), array( new \ezcConsoleOptionRule($trusting) ) )); $trusting->addExclusion(new \ezcConsoleOptionRule($paranoid)); $this->onceOption = $input->registerOption( new \ezcConsoleOption( '', 'once', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Use require_once in static require mode', NULL, array( new \ezcConsoleOptionRule( $input->getOption( 's' ) ) ) )); $input->registerOption( new \ezcConsoleOption( 'n', 'nolower', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Do not lowercase classnames for case insensitivity' )); $input->registerOption( new \ezcConsoleOption( 'q', 'quiet', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Run in quiet mode, no output' )); $input->registerOption( new \ezcConsoleOption( '1', 'prepend', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Prepend autoloader to stack', NULL, array(), array( new \ezcConsoleOptionRule( $compat ) ) )); $input->registerOption( new \ezcConsoleOption( 'd', 'no-exception', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'Disable exceptions on registration error' )); $input->registerOption( new \ezcConsoleOption( '', 'var', \ezcConsoleInput::TYPE_STRING, array(), TRUE, 'Assign variable' )); $warm = $input->registerOption( new \ezcConsoleOption( 'w', 'warm', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'generate opcache warming file', NULL, array(), array( new \ezcConsoleOptionRule($this->pharOption), new \ezcConsoleOptionRule($this->staticOption) ) )); $input->registerOption( new \ezcConsoleOption( '', 'reset', \ezcConsoleInput::TYPE_NONE, NULL, FALSE, 'add reset call to generated opcache warming file', NULL, array( new \ezcConsoleOptionRule($warm) ) )); $input->argumentDefinition = new \ezcConsoleArguments(); $input->argumentDefinition[0] = new \ezcConsoleArgument('directory'); $input->argumentDefinition[0]->shorthelp = 'The directory to process.'; $input->argumentDefinition[0]->multiple = TRUE; return $input; } private function preBootstrap() { $required = array('tokenizer', 'fileinfo'); $missing = array(); foreach($required as $test) { if (!extension_loaded($test)) { $missing[] = sprintf('ext/%s not installed/enabled', $test); } } if (count($missing)) { throw new CLIEnvironmentException( join("\n", $missing), CLIEnvironmentException::ExtensionMissing ); } if (extension_loaded('xdebug')) { ini_set('xdebug.scream', 0); ini_set('xdebug.max_nesting_level', 8192); ini_set('xdebug.show_exception_trace', 0); if (function_exists('xdebug_disable')) { // Xdebug v2 xdebug_disable(); } } } } class CLIEnvironmentException extends \Exception { const ExtensionMissing = 1; } } Autoload-1.27.1/src/Cache.php000066400000000000000000000031001417410776500156630ustar00rootroot00000000000000loadedEntries = $initialEntries; } /** * @param SourceFile $file * * @return bool */ public function hasResult(SourceFile $file) { $pathname = $file->getPathname(); if (!isset($this->loadedEntries[$pathname])) { return false; } return $this->loadedEntries[$pathname]->getTimestamp() === $file->getMTime(); } public function getResult(SourceFile $file) { if (!$this->hasResult($file)) { throw new CacheException('Entry not found'); } $pathname = $file->getPathname(); $entry = $this->loadedEntries[$pathname]; $this->usedEntries[$pathname] = $entry; return $entry->getResult(); } public function addResult(SourceFile $file, ParseResult $result) { $this->usedEntries[$file->getPathname()] = new CacheEntry($file->getMTime(), $result); } public function persist($fname) { if (file_exists($fname)) { unlink($fname); } file_put_contents($fname, serialize($this->usedEntries)); } } class CacheException extends \Exception { } } Autoload-1.27.1/src/CacheEntry.php000066400000000000000000000012211417410776500167070ustar00rootroot00000000000000timestamp = $timestamp; $this->result = $result; } /** * @return ParseResult */ public function getResult() { return $this->result; } /** * @return int */ public function getTimestamp() { return $this->timestamp; } } } Autoload-1.27.1/src/CacheWarmingListRenderer.php000066400000000000000000000016311417410776500215420ustar00rootroot00000000000000addReset = $addReset; $this->indent = $indent; $this->linebreak = $linebreak; } /** * @return string */ public function render(array $list) { $line = $this->indent . 'opcache_compile_file(___BASEDIR___\''; $glue = '\');' . $this->linebreak . $line; $firstLine = $this->addReset ? $this->indent . 'opcache_reset();' . $this->linebreak : ''; return $firstLine . $line . implode($glue, $list) . '\');'; } } Autoload-1.27.1/src/CachingParser.php000066400000000000000000000016571417410776500174100ustar00rootroot00000000000000cache = $cache; $this->parser = $parser; } /** * Parse a given file for defintions of classes, traits and interfaces * * @param SourceFile $source file to process * * @return ParseResult */ public function parse(SourceFile $source) { if ($this->cache->hasResult($source)) { return $this->cache->getResult($source); } $result = $this->parser->parse($source); $this->cache->addResult($source, $result); return $result; } } } Autoload-1.27.1/src/Collector.php000066400000000000000000000062101417410776500166130ustar00rootroot00000000000000parser = $parser; $this->tolerantMode = $tolerantMode; $this->trustingMode = $trustingMode; $this->collectorResult = new CollectorResult($whitelist, $blacklist); } public function getResult() { return $this->collectorResult; } public function processDirectory(\Iterator $sources) { $worker = $this->trustingMode ? $sources : new PHPFilterIterator($sources); foreach($worker as $file) { $this->processFile($file); } } public function processFile(\SplFileInfo $file) { if ($this->collectorResult->hasResultFor($file)) { return; } try { $parseResult = $this->parser->parse(new SourceFile($file->getRealPath())); if ($parseResult->hasRedeclarations() && !$this->tolerantMode) { throw new CollectorException( sprintf( "Duplicate (potentially conditional) definitions of the following unit(s) found:\n\n\tUnit(s): %s\n\tFile: %s", join(', ', $parseResult->getRedeclarations()), $file->getRealPath() ), CollectorException::InFileRedeclarationFound ); } $this->collectorResult->addParseResult($file, $parseResult); } catch(ParserException $e) { throw new CollectorException( sprintf( "Could not process file '%s' due to parse errors: %s", $file->getRealPath(), $e->getMessage() ), CollectorException::ParseErrror, $e ); } catch(CollectorResultException $e) { throw new CollectorException( $e->getMessage(), CollectorException::RedeclarationFound ); } } } class CollectorException extends \Exception { const ParseErrror = 1; const RedeclarationFound = 2; const InFileRedeclarationFound = 3; } } Autoload-1.27.1/src/CollectorResult.php000066400000000000000000000055241417410776500200210ustar00rootroot00000000000000whitelist = $whitelist; $this->blacklist = $blacklist; } public function hasResultFor(\SplFileInfo $file) { return isset($this->seenFiles[$file->getRealPath()]); } public function addParseResult(\SplFileInfo $file, ParseResult $result) { if (!$result->hasUnits()) { return; } $filename = $file->getRealPath(); $this->seenFiles[$filename] = true; foreach($result->getUnits() as $unit) { if (!$this->accept($unit)) { continue; } if (isset($this->units[$unit])) { if (!isset($this->duplicates[$unit])) { $this->duplicates[$unit] = array( $this->units[$unit] ); } $this->duplicates[$unit][] = $filename; continue; } $this->units[$unit] = $filename; $this->dependencies[$unit] = $result->getDependenciesForUnit($unit); } } public function hasUnits() { return count($this->units) > 0; } public function hasDuplicates() { return count($this->duplicates) > 0; } /** * @return array */ public function getDependencies() { return $this->dependencies; } /** * @return array */ public function getUnits() { return $this->units; } /** * @param string $unit * * @return bool */ private function accept($unit) { foreach($this->blacklist as $entry) { if (fnmatch($entry, $unit)) { return false; } } foreach($this->whitelist as $entry) { if (fnmatch($entry, $unit)) { return true; } } return false; } public function getDuplicates() { return $this->duplicates; } } class CollectorResultException extends \Exception { const DuplicateUnitName = 1; } } Autoload-1.27.1/src/ComposerIterator.php000066400000000000000000000134601417410776500201730ustar00rootroot00000000000000isFile() || !$composerFile->isReadable()) { throw new ComposerIteratorException( sprintf('Composer file "%s" not found or not readable', $composerFile->getPathname()), ComposerIteratorException::InvalidComposerJsonFile ); } $composerDir = dirname($composerFile->getRealPath()); $composerData = json_decode(file_get_contents($composerFile->getRealPath()), true); if (isset($composerData['require'])) { foreach($composerData['require'] as $require => $version) { if ($require === 'php' || strpos($require, 'ext-') === 0) { continue; } $this->processRequire($composerDir, $require); } } if (isset($composerData['autoload'])) { $this->processAutoload($composerDir, $composerData['autoload']); } } private function processAutoload($baseDir, array $map) { if (isset($map['classmap'])) { foreach($map['classmap'] as $dir) { $this->addDirectory($baseDir . '/' . $dir); } } foreach(array('psr-0', 'psr-4') as $psr) { if (isset($map[$psr])) { foreach ($map[$psr] as $node => $dir) { if ($dir === '') { $this->addDirectory($baseDir); continue; } if (is_array($dir)) { foreach($dir as $d) { $this->addDirectory($baseDir . '/' . $d); } continue; } $this->addDirectory($baseDir . '/' . $dir); } } } } private function processRequire($basedir, $require) { if (isset($this->seen[$require])) { return; } $this->seen[$require] = true; $requireDir = $basedir . '/vendor/' . $require; $jsonFile = $this->findComposerJson($requireDir); if ($jsonFile === null) { return; } $jsonData = json_decode(file_get_contents($jsonFile), true); if (isset($jsonData['require'])) { foreach($jsonData['require'] as $entry => $version) { if ($entry === 'php' || strpos($entry, 'ext-') === 0 || strpos($entry, 'lib-') === 0) { continue; } $this->processRequire($basedir, $entry); } } if (isset($jsonData['autoload'])) { $this->processAutoload($requireDir, $jsonData['autoload']); return; } $this->addDirectory($requireDir); } private function findComposerJson($dir) { if (file_exists($dir . '/composer.json')) { return $dir . '/composer.json'; } foreach(glob($dir . '/*', GLOB_ONLYDIR) as $subDir) { $result = $this->findComposerJson($subDir); if ($result !== NULL) { return $result; } } } private function addDirectory($dir) { $dir = rtrim($dir, '/'); if (!in_array($dir, $this->directories)) { $this->directories[] = $dir; } } /** * (PHP 5 >= 5.0.0)
* Return the current element * * @link http://php.net/manual/en/iterator.current.php * @return mixed Can return any type. */ #[\ReturnTypeWillChange] public function current() { return $this->directories[$this->pos]; } /** * (PHP 5 >= 5.0.0)
* Move forward to next element * * @link http://php.net/manual/en/iterator.next.php * @return void Any returned value is ignored. */ #[\ReturnTypeWillChange] public function next() { $this->pos++; } /** * (PHP 5 >= 5.0.0)
* Return the key of the current element * * @link http://php.net/manual/en/iterator.key.php * @return mixed scalar on success, or null on failure. */ #[\ReturnTypeWillChange] public function key() { return $this->pos; } /** * (PHP 5 >= 5.0.0)
* Checks if current position is valid * * @link http://php.net/manual/en/iterator.valid.php * @return boolean The return value will be casted to boolean and then evaluated. * Returns true on success or false on failure. */ #[\ReturnTypeWillChange] public function valid() { return $this->pos < count($this->directories); } /** * (PHP 5 >= 5.0.0)
* Rewind the Iterator to the first element * * @link http://php.net/manual/en/iterator.rewind.php * @return void Any returned value is ignored. */ #[\ReturnTypeWillChange] public function rewind() { $this->pos = 0; } } class ComposerIteratorException extends \Exception { const InvalidComposerJsonFile = 1; } } Autoload-1.27.1/src/Config.php000066400000000000000000000315031417410776500160750ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License * */ namespace TheSeer\Autoload { class Config { private $quietMode = FALSE; private $directories = array(); private $outputFile = 'STDOUT'; private $pharMode = FALSE; private $include = array('*.php'); private $exclude = array(); private $whitelist = array('*'); private $blacklist = array(); private $baseDirectory = NULL; private $template; private $linebreak = "\n"; private $indent; private $lint = FALSE; private $php; private $compatMode = FALSE; private $staticMode = FALSE; private $warmMode = FALSE; private $tolerant = FALSE; private $trusting = TRUE; private $once = FALSE; private $reset = FALSE; private $lowercase = TRUE; private $dateFormat; private $variable = array(); private $pharCompression = 'NONE'; private $pharKey; private $pharAll = false; private $pharAliasName = ''; private $pharHashAlgorithm; private $followSymlinks = false; private $cacheFilename; private $prepend = false; private $exceptions = true; public function __construct(Array $directories) { $this->directories = $directories; $this->php = (PHP_OS === 'WIN' ? 'C:\php\php.exe' : '/usr/bin/php'); } public function setBaseDirectory($baseDirectory) { $this->baseDirectory = $baseDirectory; } public function getBaseDirectory() { if ($this->baseDirectory !== NULL) { return realpath($this->baseDirectory); } if ($this->isPharMode()) { $comparator = new PathComparator($this->directories); return $comparator->getCommonBase(); } if ($this->outputFile != 'STDOUT') { return realpath(dirname($this->outputFile) ?: '.'); } $tmp = $this->getDirectories(); return realpath(is_dir($tmp[0]) ? $tmp[0] : (dirname($tmp[0]) ?: '.')); } public function setCompatMode($compatMode) { $this->compatMode = $compatMode; } public function isCompatMode() { return $this->compatMode === true; } public function setDateFormat($dateFormat) { $this->dateFormat = $dateFormat; } public function getDateFormat() { return $this->dateFormat; } public function setExclude(Array $exclude) { $this->exclude = $exclude; } public function getExclude() { return $this->exclude; } public function setInclude(Array $include) { $this->include = $include; } public function getInclude() { return $this->include; } /** * @return array */ public function getBlacklist() { return $this->blacklist; } /** * @param array $blacklist */ public function setBlacklist($blacklist) { $this->blacklist = $blacklist; } /** * @return array */ public function getWhitelist() { return $this->whitelist; } /** * @param array $whitelist */ public function setWhitelist($whitelist) { $this->whitelist = $whitelist; } public function setIndent($indent) { $this->indent = $indent; } public function getIndent() { if ($this->indent !== NULL) { if (is_numeric($this->indent) && (int)$this->indent == $this->indent) { return str_repeat(' ', (int)$this->indent); } return $this->indent; } if ($this->isStaticMode() || $this->isWarmMode()) { return ''; } return str_repeat(' ', $this->isCompatMode() ? 12 : 16); } public function setLinebreak($linebreak) { $lbr = array('LF' => "\n", 'CR' => "\r", 'CRLF' => "\r\n" ); if (isset($lbr[$linebreak])) { $this->linebreak = $lbr[$linebreak]; } else { $this->linebreak = $linebreak; } } public function getLinebreak() { return $this->linebreak; } public function setLintMode($lint) { $this->lint = (boolean)$lint; } public function isLintMode() { return $this->lint; } public function setLowercaseMode($lowercase) { $this->lowercase = (boolean)$lowercase; } public function isLowercaseMode() { return $this->lowercase; } public function setOnceMode($once) { $this->once = (boolean)$once; } public function isOnceMode() { return $this->once; } public function setOutputFile($outputFile) { $this->outputFile = $outputFile; } public function getOutputFile() { return $this->outputFile; } public function enablePharMode($compression = 'NONE', $all = true, $key = NULL, $alias = NULL) { $this->pharMode = true; $this->pharCompression = $compression; $this->pharAll = (boolean)$all; $this->pharKey = $key; $this->pharAliasName = $alias; } public function isPharMode() { return $this->pharMode; } public function isPharAllMode() { return $this->pharAll; } public function getPharCompression() { return $this->pharCompression; } public function getPharKey() { return $this->pharKey; } public function getPharAliasName() { return $this->pharAliasName; } public function hasPharHashAlgorithm() { return $this->pharHashAlgorithm !== null; } /** * @return string */ public function getPharHashAlgorithm() { return $this->pharHashAlgorithm; } /** * @param string $pharHashAlgorithm */ public function setPharHashAlgorithm($pharHashAlgorithm) { if (!in_array($pharHashAlgorithm, array('SHA-512','SHA-256','SHA-1'))) { throw new \InvalidArgumentException( sprintf('Algorithm %s not supported', $pharHashAlgorithm) ); } $this->pharHashAlgorithm = $pharHashAlgorithm; } public function setPhp($php) { $this->php = $php; } public function getPhp() { return $this->php; } public function setQuietMode($quietMode) { $this->quietMode = (boolean)$quietMode; } public function setStaticMode($staticMode) { $this->staticMode = (boolean)$staticMode; $this->warmMode = FALSE; } public function isStaticMode() { return $this->staticMode; } public function setWarmMode($warmMode) { $this->warmMode = (boolean)$warmMode; $this->staticMode = FALSE; } public function isWarmMode() { return $this->warmMode; } public function setResetMode($resetMode) { $this->reset = (boolean)$resetMode; } public function isResetMode() { return $this->reset; } public function setTemplate($template) { $this->template = $template; } public function getTemplate() { $tplType = $this->isLowercaseMode() ? 'ci' : 'cs'; $template = $this->template; if ($template !== NULL) { if (!file_exists($template)) { $alternative = __DIR__.'/templates/'. $tplType .'/'.$template; if (file_exists($alternative)) { $template = $alternative; } $alternative .= '.php.tpl'; if (file_exists($alternative)) { $template = $alternative; } } return $template; } // determine auto template to use $tplFile = 'default.php.tpl'; if ($this->isCompatMode()) { $tplFile = 'php52.php.tpl'; } if ($this->isPharMode()) { if ($this->isStaticMode()) { $tplFile = 'staticphar.php.tpl'; $tplType = '.'; } else { $tplFile = 'phar.php.tpl'; } } elseif ($this->isStaticMode() || $this->isWarmMode()) { $tplFile = 'static.php.tpl'; $tplType = '.'; } return __DIR__.'/templates/'.$tplType.'/'.$tplFile; } public function setTolerantMode($tolerant) { $this->tolerant = (boolean)$tolerant; } public function isTolerantMode() { return $this->tolerant; } public function setTrusting($trusting) { $this->trusting = (boolean)$trusting; } public function setFollowSymlinks($followSymlinks) { $this->followSymlinks = (boolean)$followSymlinks; } public function isFollowSymlinks() { return $this->followSymlinks; } public function isTrustingMode() { return $this->trusting; } public function setVariable($name, $value) { $this->variable[$name] = $value; } public function getVariables() { return $this->variable; } public function isQuietMode() { return $this->quietMode; } public function getDirectories() { $list = array(); foreach($this->directories as $dir) { if (is_file($dir) && basename($dir) == 'composer.json') { foreach(new ComposerIterator(new \SplFileInfo($dir)) as $d) { $list[] = $d; } } else { foreach(glob($dir) as $match) { $list[] = $match; } } } return $list; } public function setCacheFile($filename) { $this->cacheFilename = $filename; } public function isCacheEnabled() { return $this->cacheFilename !== NULL; } public function getCacheFile() { return $this->cacheFilename; } public function enablePrepend() { $this->prepend = true; } public function usePrepend() { return $this->prepend; } public function disableExceptions() { $this->exceptions = false; } public function useExceptions() { return $this->exceptions; } } } Autoload-1.27.1/src/DependencySorter.php000066400000000000000000000071551417410776500201530ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\Autoload { /** * Sorting classes by depdendency for static requires * * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. */ class ClassDependencySorter { private $classList; private $dependencies; private $level; private $sorted = array(); public function __construct(Array $classes, Array $dependencies) { $this->classList = $classes; $this->dependencies = $dependencies; } public function process() { $this->level = 0; foreach($this->classList as $class => $file) { if (!in_array($class, $this->sorted)) { $this->resolve($class); } } $res = array(); foreach($this->sorted as $class) { if (!isset($this->classList[$class])) { continue; } $res[$class] = $this->classList[$class]; } return $res; } private function resolve($class) { $this->level++; if ($this->level == 50) { throw new ClassDependencySorterException("Can't resolve more than 50 levels of dependencies", ClassDependencySorterException::TooManyDependencyLevels); } if (isset($this->dependencies[$class])) { foreach($this->dependencies[$class] as $depclass) { if (!in_array($depclass, $this->sorted)) { $this->resolve($depclass); } } } $this->sorted[] = $class; $this->level--; } } class ClassDependencySorterException extends \Exception { const TooManyDependencyLevels = 1; } } Autoload-1.27.1/src/Factory.php000066400000000000000000000202071417410776500162760ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License * */ namespace TheSeer\Autoload { use TheSeer\DirectoryScanner\DirectoryScanner; use TheSeer\DirectoryScanner\IncludeExcludeFilterIterator; class Factory { /** * @var Config */ private $config; /** * @var Cache */ private $cache; /** * @param \TheSeer\Autoload\Config $config */ public function setConfig(Config $config) { $this->config = $config; } /** * @return CLI */ public function getCLI() { return new CLI($this); } /** * @return Application */ public function getApplication() { return new Application($this->getLogger(), $this->config, $this); } public function getLogger() { return new Logger($this->config->isQuietMode()); } /** * @return Parser */ public function getParser() { $parser = new Parser( $this->config->isLowercaseMode() ); if (!$this->config->isCacheEnabled()) { return $parser; } return new CachingParser( $this->getCache(), $parser ); } /** * @return Cache */ public function getCache() { if (!$this->cache instanceof Cache) { $fname = $this->config->getCacheFile(); if (file_exists($fname)) { $data = unserialize(file_get_contents($fname)); } else { $data = array(); } $this->cache = new Cache($data); } return $this->cache; } public function getCollector() { return new Collector( $this->getParser(), $this->config->isTolerantMode(), $this->config->isTrustingMode(), $this->config->getWhitelist(), $this->config->getBlacklist() ); } /** * Get instance of DirectoryScanner with filter options applied * * @param bool $filter * @return DirectoryScanner */ public function getScanner($filter = TRUE) { $scanner = new DirectoryScanner; if ($filter) { $scanner->setIncludes($this->config->getInclude()); $scanner->setExcludes($this->config->getExclude()); } if ($this->config->isFollowSymlinks()) { $scanner->setFlag(\FilesystemIterator::FOLLOW_SYMLINKS); } return $scanner; } public function getFilter(\Iterator $files) { $filter = new IncludeExcludeFilterIterator($files); $filter->setInclude($this->config->getInclude()); $filter->setExclude($this->config->getExclude()); return $filter; } public function getPharBuilder() { $builder = new PharBuilder( $this->getScanner(!$this->config->isPharAllMode()), $this->config->getBaseDirectory() ); $builder->setCompressionMode($this->config->getPharCompression()); foreach($this->config->getDirectories() as $directory) { $builder->addDirectory($directory); } return $builder; } /** * Helper to get instance of AutoloadRenderer with cli options applied * * @param CollectorResult $result * * @throws \RuntimeException * @return \TheSeer\Autoload\AutoloadRenderer|\TheSeer\Autoload\StaticRenderer */ public function getRenderer(CollectorResult $result) { $isStatic = $this->config->isStaticMode(); $isPhar = $this->config->isPharMode(); $isCompat = $this->config->isCompatMode(); $isOnce = $this->config->isOnceMode(); $isWarm = $this->config->isWarmMode(); $isReset = $this->config->isResetMode(); if ($isWarm === TRUE) { $renderer = new StaticRenderer( $result->getUnits(), $this->getCacheWarmingListRenderer($isReset) ); $renderer->setDependencies($result->getDependencies()); $renderer->setPharMode($isPhar); } else if ($isStatic === TRUE) { $renderer = new StaticRenderer( $result->getUnits(), $this->getStaticRequireListRenderer($isOnce) ); $renderer->setDependencies($result->getDependencies()); $renderer->setPharMode($isPhar); } else { $renderer = new AutoloadRenderer($result->getUnits()); if ($this->config->usePrepend()) { $renderer->prependAutoloader(); } if ($this->config->useExceptions()) { $renderer->enableExceptions(); } } $renderer->setCompat($isCompat); $basedir = $this->config->getBaseDirectory(); if (!$basedir || !is_dir($basedir)) { throw new \RuntimeException("Given basedir '{$basedir}' does not exist or is not a directory"); } $renderer->setBaseDir($basedir); $format = $this->config->getDateFormat(); if ($format) { $renderer->setDateTimeFormat($format); } $renderer->setIndent($this->config->getIndent()); $renderer->setLineBreak($this->config->getLinebreak()); foreach($this->config->getVariables() as $name => $value) { $renderer->setVariable($name, $value); } return $renderer; } private function getStaticRequireListRenderer($useOnce) { return new StaticRequireListRenderer( $useOnce, $this->config->getIndent(), $this->config->getLinebreak() ); } private function getCacheWarmingListRenderer($addReset) { return new CacheWarmingListRenderer( $addReset, $this->config->getIndent(), $this->config->getLinebreak() ); } } } Autoload-1.27.1/src/Logger.php000066400000000000000000000042671417410776500161160ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License * */ namespace TheSeer\Autoload { class Logger { private $quiet = FALSE; /** * @param bool $quietMode */ public function __construct($quietMode = FALSE) { $this->quiet = $quietMode; } public function log($message, $target = STDOUT) { if ($this->quiet) { return; } fwrite($target, $message); } } } Autoload-1.27.1/src/ParseResult.php000066400000000000000000000025471417410776500171470ustar00rootroot00000000000000units = $units; $this->dependencies = $dependencies; $this->redeclarations = $redeclarations; } public function hasUnits() { return count($this->units) > 0; } public function hasRedeclarations() { return count($this->redeclarations) > 0; } /** * * @param string $unit * * @return array */ public function getDependenciesForUnit($unit) { if (!isset($this->dependencies[$unit])) { return array(); } return $this->dependencies[$unit]; } /** * @return \string[] */ public function getRedeclarations() { return $this->redeclarations; } /** * @return \string[] */ public function getUnits() { return $this->units; } } } Autoload-1.27.1/src/Parser.php000066400000000000000000000517721417410776500161360ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\Autoload { // PHP 5.3 compat define('T_TRAIT_53', 10355); if (!defined('T_TRAIT')) { define('T_TRAIT', -1); } // PHP 8.0 forward compat if (!defined('T_NAME_FULLY_QUALIFIED')) { define('T_NAME_FULLY_QUALIFIED', -1); define('T_NAME_QUALIFIED', -1); } // PHP 8.1 forward compat if (!defined('T_ENUM')) { define('T_ENUM', -1); } /** * Namespace aware parser to find and extract defined classes within php source files * * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. */ class Parser implements ParserInterface { private $methodMap = array( T_TRAIT => 'processClass', T_TRAIT_53 => 'processClass', T_CLASS => 'processClass', T_ENUM => 'processEnum', //T_CASE => 'processEnumCase', T_INTERFACE => 'processInterface', T_NAMESPACE => 'processNamespace', T_USE => 'processUse', '}' => 'processBracketClose', '{' => 'processBracketOpen', T_CURLY_OPEN => 'processBracketOpen', T_DOLLAR_OPEN_CURLY_BRACES => 'processBracketOpen' ); private $typeMap = array( T_INTERFACE => 'interface', T_CLASS => 'class', T_ENUM => 'enum', T_TRAIT => 'trait', T_TRAIT_53 => 'trait' ); private $caseInsensitive; private $tokenArray = array(); private $inNamespace = ''; private $inUnit = ''; private $nsBracket = 0; private $classBracket = 0; private $bracketLevel = 0; private $aliases = array(); private $found = array(); private $dependencies = array(); private $redeclarations = array(); public function __construct($caseInsensitive = true) { $this->caseInsensitive = $caseInsensitive; } /** * Parse a given file for defintions of classes, traits and interfaces * * @param SourceFile $source file to process * * @return ParseResult */ public function parse(SourceFile $source) { $this->found = array(); $this->redeclarations = array(); $this->inNamespace = ''; $this->aliases = array(); $this->bracketLevel = 0; $this->inUnit = ''; $this->nsBracket = 0; $this->classBracket = 0; $this->tokenArray = $source->getTokens(); $tokenCount = count($this->tokenArray); $tokList = array_keys($this->methodMap); for($t=0; $t<$tokenCount; $t++) { $current = (array)$this->tokenArray[$t]; if ($current[0]===T_STRING && $current[1]==='trait' && T_TRAIT===-1) { // PHP < 5.4 compat fix $current[0] = T_TRAIT_53; $this->tokenArray[$t] = $current; } if (!in_array($current[0], $tokList)) { continue; } $t = call_user_func(array($this, $this->methodMap[$current[0]]), $t); } return new ParseResult($this->found, $this->dependencies, $this->redeclarations); } private function processBracketOpen($pos) { $this->bracketLevel++; return $pos + 1; } private function processBracketClose($pos) { $this->bracketLevel--; if ($this->nsBracket !== 0 && $this->bracketLevel < $this->nsBracket) { $this->inNamespace = ''; $this->nsBracket = 0; $this->aliases = array(); } if ($this->bracketLevel <= $this->classBracket) { $this->classBracket = 0; $this->inUnit = ''; } return $pos + 1; } private function processClass($pos) { if (!$this->classTokenNeedsProcessing($pos)) { return $pos; } $list = array('{'); $stack = $this->getTokensTill($pos, $list); $stackSize = count($stack); $classname = $this->inNamespace !== '' ? $this->inNamespace . '\\' : ''; $extends = ''; $extendsFound = false; $implementsFound = false; $implementsList = array(); $implements = ''; $mode = 'classname'; foreach(array_slice($stack, 1, -1) as $tok) { switch ($tok[0]) { case T_COMMENT: case T_DOC_COMMENT: case T_WHITESPACE: { break; } case T_NAME_FULLY_QUALIFIED: case T_NAME_QUALIFIED: case T_STRING: { $$mode .= $tok[1]; break; } case T_NS_SEPARATOR: { $$mode .= '\\'; break; } case T_EXTENDS: { $extendsFound = true; $mode = 'extends'; break; } case T_IMPLEMENTS: { $implementsFound = true; $mode = 'implements'; break; } case ',': { if ($mode === 'implements') { $implementsList[] = $this->resolveDependencyName($implements); $implements = ''; } break; } default: { throw new ParserException(sprintf( 'Parse error while trying to process class definition (unexpected token "%s" in name).', \token_name($tok[0]) ), ParserException::ParseError ); } } } if ($implements != '') { $implementsList[] = $this->resolveDependencyName($implements); } if ($implementsFound && count($implementsList)==0) { throw new ParserException(sprintf( 'Parse error while trying to process class definition (extends or implements).' ), ParserException::ParseError ); } $classname = $this->registerUnit($classname, $stack[0][0]); $this->dependencies[$classname] = $implementsList; if ($extendsFound) { $this->dependencies[$classname][] = $this->resolveDependencyName($extends); } $this->inUnit = $classname; $this->classBracket = $this->bracketLevel + 1; return $pos + $stackSize - 1; } private function processEnum($pos) { $list = array('{'); $stack = $this->getTokensTill($pos, $list); $stackSize = count($stack); $enumName = $this->inNamespace !== '' ? $this->inNamespace . '\\' : ''; $implementsFound = false; $implementsList = array(); $implements = ''; $backType = ''; $mode = 'enumName'; foreach(array_slice($stack, 1, -1) as $tok) { switch ($tok[0]) { case T_COMMENT: case T_DOC_COMMENT: case T_WHITESPACE: { break; } case T_NAME_FULLY_QUALIFIED: case T_NAME_QUALIFIED: case T_STRING: { $$mode .= $tok[1]; break; } case T_NS_SEPARATOR: { $$mode .= '\\'; break; } case T_IMPLEMENTS: { $implementsFound = true; $mode = 'implements'; break; } case ':': { $isBacked = true; $mode = 'backType'; break; } case ',': { if ($mode === 'implements') { $implementsList[] = $this->resolveDependencyName($implements); $implements = ''; } break; } default: { throw new ParserException(sprintf( 'Parse error while trying to process class definition (unexpected token "%s" in name).', is_int($tok[0]) ? \token_name($tok[0]) : $tok[0] ), ParserException::ParseError ); } } } if ($implements != '') { $implementsList[] = $this->resolveDependencyName($implements); } if ($implementsFound && count($implementsList)==0) { throw new ParserException(sprintf( 'Parse error while trying to process enum definition (implements).' ), ParserException::ParseError ); } $enumName = $this->registerUnit($enumName, $stack[0][0]); $this->dependencies[$enumName] = $implementsList; return $pos + $stackSize - 1; } private function processInterface($pos) { $list = array('{'); $stack = $this->getTokensTill($pos, $list); $stackSize = count($stack); $next = $stack[1]; if (is_array($next) && $next[0] === '(') { // sort of inline use - ignore return $pos + $stackSize; } $name = $this->inNamespace != '' ? $this->inNamespace . '\\' : ''; $extends = ''; $extendsList = array(); $mode = 'name'; foreach(array_slice($stack, 1, -1) as $tok) { switch ($tok[0]) { case T_NS_SEPARATOR: case T_NAME_QUALIFIED: case T_NAME_FULLY_QUALIFIED: case T_STRING: { $$mode .= $tok[1]; break; } case T_EXTENDS: { $mode = 'extends'; break; } case ',': { if ($mode == 'extends') { $extendsList[] = $this->resolveDependencyName($extends); $extends = ''; } } } } $name = $this->registerUnit($name, T_INTERFACE); if ($extends != '') { $extendsList[] = $this->resolveDependencyName($extends); } $this->dependencies[$name] = $extendsList; $this->inUnit = $name; return $pos + $stackSize - 1; } private function resolveDependencyName($name) { if ($name == '') { throw new ParserException(sprintf( 'Parse error while trying to process class definition (extends or implements).' ), ParserException::ParseError ); } if ($name[0] == '\\') { $name = substr($name, 1); } else { $parts = explode('\\', $name, 2); $search = $this->caseInsensitive ? strtolower($parts[0]) : $parts[0]; $key = array_search($search, $this->aliases); if (!$key) { $name = ($this->inNamespace != '' ? $this->inNamespace . '\\' : ''). $name; } else { $name = $key; if (isset($parts[1])) { $name .= '\\' . $parts[1]; } } } if ($this->caseInsensitive) { $name = strtolower($name); } return $name; } private function registerUnit($name, $type) { if ($name == '' || substr($name, -1) == '\\') { throw new ParserException(sprintf( 'Parse error while trying to process %s definition.', $this->typeMap[$type] ), ParserException::ParseError ); } if ($this->caseInsensitive) { $name = strtolower($name); } if (in_array($name, $this->found)) { $this->redeclarations[] = $name; } else { $this->found[] = $name; } return $name; } private function processNamespace($pos) { $list = array(';', '{'); $stack = $this->getTokensTill($pos, $list); $stackSize = count($stack); $newpos = $pos + $stackSize; if ($stackSize < 3) { // empty namespace defintion == root namespace $this->inNamespace = ''; $this->aliases = array(); return $newpos - 1; } $next = $stack[1]; if (is_array($next) && ($next[0] === T_NS_SEPARATOR || $next[0] === '(')) { // sort of inline use - ignore return $newpos; } $this->inNamespace = ''; foreach(array_slice($stack, 1, -1) as $tok) { $this->inNamespace .= $tok[1]; } $this->aliases = array(); return $pos + $stackSize - 1; } private function processUse($pos) { $list = array(';','('); $stack = $this->getTokensTill($pos, $list); $stackSize = count($stack); $ignore = array( '(', // closue use T_CONST, // use const foo\bar; T_FUNCTION // use function foo\bar; ); if (in_array($stack[1][0], $ignore)) { return $pos + $stackSize - 1; } if ($this->classBracket > 0) { $this->parseUseOfTrait($stackSize, $stack); } else { $this->parseUseAsImport($stack); } return $pos + $stackSize - 1; } private function getTokensTill($start, $list) { $list = (array)$list; $stack = array(); $skip = array( T_WHITESPACE, T_COMMENT, T_DOC_COMMENT ); $limit = count($this->tokenArray); for ($t=$start; $t<$limit; $t++) { $current = (array)$this->tokenArray[$t]; if (in_array($current[0], $skip)) { continue; } $stack[] = $current; if (in_array($current[0], $list)) { break; } } return $stack; } /** * @param $stackSize * @param $stack */ private function parseUseOfTrait($stackSize, $stack) { $use = ''; for ($t = 0; $t < $stackSize; $t++) { $current = (array)$stack[$t]; switch ($current[0]) { case '{': { // find closing bracket to skip contents for ($x = $t + 1; $x < $stackSize; $x++) { $tok = $stack[$x]; if ($tok[0] == '}') { $t = $x; break; } } break; } case ';': case ',': { $this->dependencies[$this->inUnit][] = $this->resolveDependencyName($use); $use = ''; break; } case T_NS_SEPARATOR: case T_NAME_QUALIFIED: case T_NAME_FULLY_QUALIFIED: case T_STRING: { $use .= $current[1]; break; } } } } /** * @param $stack */ private function parseUseAsImport($stack) { $use = ''; $alias = ''; $mode = 'use'; $group = ''; $ignore = false; foreach ($stack as $tok) { $current = $tok; switch ($current[0]) { case T_CONST: case T_FUNCTION: { $ignore = true; break; } case '{': { $group = $use; break; } case ';': case ',': { if (!$ignore) { if ($alias == '') { $nss = strrpos($use, '\\'); if ($nss !== FALSE) { $alias = substr($use, $nss + 1); } else { $alias = $use; } } if ($this->caseInsensitive) { $alias = strtolower($alias); } $this->aliases[$use] = $alias; } $alias = ''; $use = $group; $mode = 'use'; $ignore = false; break; } case T_NS_SEPARATOR: case T_NAME_QUALIFIED: case T_NAME_FULLY_QUALIFIED: case T_STRING: { $$mode .= $current[1]; break; } case T_AS: { $mode = 'alias'; break; } } } } private function classTokenNeedsProcessing($position) { // PHP 5.5 has classname::class, reusing T_CLASS if ($this->tokenArray[$position-1][0] == T_DOUBLE_COLON) { return false; } // PHP 7 has anonymous classes: $x = new class { ... } if ($position > 2 && $this->tokenArray[$position-2][0] === T_NEW) { return false; } if ($this->tokenArray[$position + 1] === '(' || $this->tokenArray[$position + 2] === '(') { return false; } return true; } } class ParserException extends \Exception { const ParseError = 1; } } Autoload-1.27.1/src/ParserInterface.php000066400000000000000000000010011417410776500177330ustar00rootroot00000000000000 * @copyright Arne Blankerts , All rights reserved. */ interface ParserInterface { /** * Parse a given file for defintions of classes, traits and interfaces * * @param SourceFile $source file to process * * @return ParseResult */ public function parse(SourceFile $source); } Autoload-1.27.1/src/PathComparator.php000066400000000000000000000021461417410776500176150ustar00rootroot00000000000000directories[] = realpath($dir).'/'; } } public function getCommonBase() { if (count($this->directories) == 0) { return '/'; } $result = $this->directories[0]; foreach($this->directories as $dir) { $result = substr($dir, 0, $this->commonPrefix($result, $dir)); } return ($result ?: '/'); } private function commonPrefix( $s1, $s2 ) { $l1 = strlen($s1); $l2 = strlen($s2); $i=0; while($i < $l1 && $i < $l2 && $s1[$i] == $s2[$i]) { $i++; } return strrpos(substr($s1, 0, $i), '/'); } } } Autoload-1.27.1/src/PharBuilder.php000066400000000000000000000121471417410776500170740ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License * */ namespace TheSeer\Autoload { use TheSeer\DirectoryScanner\DirectoryScanner; class PharBuilder { private $scanner; private $compression; private $key; private $basedir; private $aliasName; private $signatureType; private $directories = array(); private $supportedSignatureTypes = array( 'SHA-512' => \Phar::SHA512, 'SHA-256' => \Phar::SHA256, 'SHA-1' => \Phar::SHA1 ); public function __construct(DirectoryScanner $scanner, $basedir) { $this->scanner = $scanner; $this->basedir = $basedir; } public function setCompressionMode($mode) { $this->compression = $mode; } public function setSignatureType($type) { if (!in_array($type, array_keys($this->supportedSignatureTypes))) { throw new \InvalidArgumentException( sprintf('Signature type "%s" not known or not supported by this PHP installation.', $type) ); } $this->signatureType = $type; } public function setSignatureKey($key) { $this->key = $key; } public function addDirectory($directory) { $this->directories[] = $directory; } public function setAliasName($name) { $this->aliasName = $name; } public function build($filename, $stub) { if (file_exists($filename)) { unlink($filename); } $phar = new \Phar($filename, 0, $this->aliasName != '' ? $this->aliasName : basename($filename)); $phar->startBuffering(); $phar->setStub($stub); if ($this->key !== NULL) { $privateKey = ''; openssl_pkey_export($this->key, $privateKey); $phar->setSignatureAlgorithm(\Phar::OPENSSL, $privateKey); $keyDetails = openssl_pkey_get_details($this->key); file_put_contents($filename . '.pubkey', $keyDetails['key']); } else { $phar->setSignatureAlgorithm($this->selectSignatureType()); } $basedir = $this->basedir ? $this->basedir : $this->directories[0]; foreach($this->directories as $directory) { $phar->buildFromIterator($this->scanner->__invoke($directory), $basedir); } if ($this->compression !== \Phar::NONE) { $phar->compressFiles($this->compression); } $phar->stopBuffering(); } private function selectSignatureType() { if ($this->signatureType !== NULL) { return $this->supportedSignatureTypes[$this->signatureType]; } $supported = \Phar::getSupportedSignatures(); foreach($this->supportedSignatureTypes as $candidate => $type) { if (in_array($candidate, $supported)) { return $type; } } // Is there any PHP Version out there that does not support at least SHA-1? // But hey, fallback to md5, better than nothing return \Phar::MD5; } } } Autoload-1.27.1/src/SourceFile.php000066400000000000000000000003261417410776500167270ustar00rootroot00000000000000getRealPath())); } } } Autoload-1.27.1/src/StaticListRenderer.php000066400000000000000000000002241417410776500204360ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\Autoload { /** * Builds static require list for inclusion into projects * * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. */ class StaticRenderer extends AutoloadRenderer { private $dependencies; private $phar; private $require = 'require'; /** * @var StaticListRenderer */ private $renderHelper; public function __construct(array $classlist, StaticListRenderer $renderHelper) { parent::__construct($classlist); $this->renderHelper = $renderHelper; } /** * Setter for Dependency Array * @param array $dep Dependency Array from classfinder */ public function setDependencies(Array $dep) { $this->dependencies = $dep; } /** * Toggle phar outut mode * * @param boolean $phar */ public function setPharMode($phar) { $this->phar = (boolean)$phar; } /** * Toggle wether or not to use require_once over require * * @param boolean $mode */ public function setRequireOnce($mode) { } /** * @param string $template * * @return string */ public function render($template) { $baseDir = ''; if ($this->phar) { $baseDir = "'phar://". $this->variables['___PHAR___']."' . "; } else if ($this->baseDir) { $baseDir = $this->compat ? 'dirname(__FILE__) . ' : '__DIR__ . '; } $entries = array(); foreach($this->sortByDependency() as $fname) { $entries[] = $this->resolvePath($fname); } $replace = array_merge( $this->variables, array( '___CREATED___' => date( $this->dateformat, $this->timestamp ? $this->timestamp : time()), '___FILELIST___' => $this->renderHelper->render($entries), '___BASEDIR___' => $baseDir, '___AUTOLOAD___' => uniqid('autoload', true) ) ); return str_replace(array_keys($replace), array_values($replace), $template); } /** * Helper to sort classes/interfaces and traits based on their depdendency info * * @return array */ protected function sortByDependency() { $sorter = new ClassDependencySorter($this->classes, $this->dependencies); $list = $sorter->process(); return array_unique($list); } } } Autoload-1.27.1/src/StaticRequireListRenderer.php000066400000000000000000000014421417410776500217760ustar00rootroot00000000000000useOnce = $useOnce; $this->indent = $indent; $this->linebreak = $linebreak; } /** * @return string */ public function render(array $list) { $require = (boolean)$this->useOnce ? 'require_once' : 'require'; $require .= ' ___BASEDIR___\''; $glue = '\';' . $this->linebreak . $this->indent . $require; return $this->indent . $require . implode($glue, $list) . '\';'; } } Autoload-1.27.1/src/Version.php000066400000000000000000000053771417410776500163270ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License * */ namespace TheSeer\Autoload { class Version { private static $version = NULL; public static function getVersion() { if (self::$version === NULL) { self::$version = PHPAB_VERSION; if (PHPAB_VERSION == '%development%') { $cwd = getcwd(); chdir(__DIR__); $git = exec('command -p git describe --always --dirty 2>/dev/null', $foo, $rc); chdir($cwd); if ($rc === 0) { self::$version = $git; } } } return self::$version; } public static function getInfoString() { return 'phpab ' . self::getVersion() . ' - Copyright (C) 2009 - ' . date('Y') . ' by Arne Blankerts and Contributors'; } } } Autoload-1.27.1/src/autoload.php000066400000000000000000000356021417410776500165040ustar00rootroot00000000000000 '/../vendor/zetacomponents/base/src/base.php', 'ezcbaseautoloadexception' => '/../vendor/zetacomponents/base/src/exceptions/autoload.php', 'ezcbaseautoloadoptions' => '/../vendor/zetacomponents/base/src/options/autoload.php', 'ezcbaseconfigurationinitializer' => '/../vendor/zetacomponents/base/src/interfaces/configuration_initializer.php', 'ezcbasedoubleclassrepositoryprefixexception' => '/../vendor/zetacomponents/base/src/exceptions/double_class_repository_prefix.php', 'ezcbaseexception' => '/../vendor/zetacomponents/base/src/exceptions/exception.php', 'ezcbaseexportable' => '/../vendor/zetacomponents/base/src/interfaces/exportable.php', 'ezcbaseextensionnotfoundexception' => '/../vendor/zetacomponents/base/src/exceptions/extension_not_found.php', 'ezcbasefeatures' => '/../vendor/zetacomponents/base/src/features.php', 'ezcbasefile' => '/../vendor/zetacomponents/base/src/file.php', 'ezcbasefileexception' => '/../vendor/zetacomponents/base/src/exceptions/file_exception.php', 'ezcbasefilefindcontext' => '/../vendor/zetacomponents/base/src/structs/file_find_context.php', 'ezcbasefileioexception' => '/../vendor/zetacomponents/base/src/exceptions/file_io.php', 'ezcbasefilenotfoundexception' => '/../vendor/zetacomponents/base/src/exceptions/file_not_found.php', 'ezcbasefilepermissionexception' => '/../vendor/zetacomponents/base/src/exceptions/file_permission.php', 'ezcbasefunctionalitynotsupportedexception' => '/../vendor/zetacomponents/base/src/exceptions/functionality_not_supported.php', 'ezcbaseinit' => '/../vendor/zetacomponents/base/src/init.php', 'ezcbaseinitcallbackconfiguredexception' => '/../vendor/zetacomponents/base/src/exceptions/init_callback_configured.php', 'ezcbaseinitinvalidcallbackclassexception' => '/../vendor/zetacomponents/base/src/exceptions/invalid_callback_class.php', 'ezcbaseinvalidparentclassexception' => '/../vendor/zetacomponents/base/src/exceptions/invalid_parent_class.php', 'ezcbasemetadata' => '/../vendor/zetacomponents/base/src/metadata.php', 'ezcbasemetadatapearreader' => '/../vendor/zetacomponents/base/src/metadata/pear.php', 'ezcbasemetadatatarballreader' => '/../vendor/zetacomponents/base/src/metadata/tarball.php', 'ezcbaseoptions' => '/../vendor/zetacomponents/base/src/options.php', 'ezcbasepersistable' => '/../vendor/zetacomponents/base/src/interfaces/persistable.php', 'ezcbasepropertynotfoundexception' => '/../vendor/zetacomponents/base/src/exceptions/property_not_found.php', 'ezcbasepropertypermissionexception' => '/../vendor/zetacomponents/base/src/exceptions/property_permission.php', 'ezcbaserepositorydirectory' => '/../vendor/zetacomponents/base/src/structs/repository_directory.php', 'ezcbasesettingnotfoundexception' => '/../vendor/zetacomponents/base/src/exceptions/setting_not_found.php', 'ezcbasesettingvalueexception' => '/../vendor/zetacomponents/base/src/exceptions/setting_value.php', 'ezcbasestruct' => '/../vendor/zetacomponents/base/src/struct.php', 'ezcbasevalueexception' => '/../vendor/zetacomponents/base/src/exceptions/value.php', 'ezcbasewhateverexception' => '/../vendor/zetacomponents/base/src/exceptions/whatever.php', 'ezcconsoleargument' => '/../vendor/zetacomponents/console-tools/src/input/argument.php', 'ezcconsoleargumentalreadyregisteredexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/argument_already_registered.php', 'ezcconsoleargumentexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/argument.php', 'ezcconsoleargumentmandatoryviolationexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/argument_mandatory_violation.php', 'ezcconsolearguments' => '/../vendor/zetacomponents/console-tools/src/input/arguments.php', 'ezcconsoleargumenttypeviolationexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/argument_type_violation.php', 'ezcconsoledialog' => '/../vendor/zetacomponents/console-tools/src/interfaces/dialog.php', 'ezcconsoledialogabortexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/dialog_abort.php', 'ezcconsoledialogoptions' => '/../vendor/zetacomponents/console-tools/src/options/dialog.php', 'ezcconsoledialogvalidator' => '/../vendor/zetacomponents/console-tools/src/interfaces/dialog_validator.php', 'ezcconsoledialogviewer' => '/../vendor/zetacomponents/console-tools/src/dialog_viewer.php', 'ezcconsoleexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/exception.php', 'ezcconsoleinput' => '/../vendor/zetacomponents/console-tools/src/input.php', 'ezcconsoleinputhelpgenerator' => '/../vendor/zetacomponents/console-tools/src/interfaces/input_help_generator.php', 'ezcconsoleinputstandardhelpgenerator' => '/../vendor/zetacomponents/console-tools/src/input/help_generators/standard.php', 'ezcconsoleinputvalidator' => '/../vendor/zetacomponents/console-tools/src/interfaces/input_validator.php', 'ezcconsoleinvalidoptionnameexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/invalid_option_name.php', 'ezcconsoleinvalidoutputtargetexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/invalid_output_target.php', 'ezcconsolemenudialog' => '/../vendor/zetacomponents/console-tools/src/dialog/menu_dialog.php', 'ezcconsolemenudialogdefaultvalidator' => '/../vendor/zetacomponents/console-tools/src/dialog/validators/menu_dialog_default.php', 'ezcconsolemenudialogoptions' => '/../vendor/zetacomponents/console-tools/src/options/menu_dialog.php', 'ezcconsolemenudialogvalidator' => '/../vendor/zetacomponents/console-tools/src/interfaces/menu_dialog_validator.php', 'ezcconsolenopositionstoredexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/no_position_stored.php', 'ezcconsolenovaliddialogresultexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/no_valid_dialog_result.php', 'ezcconsoleoption' => '/../vendor/zetacomponents/console-tools/src/input/option.php', 'ezcconsoleoptionalreadyregisteredexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/option_already_registered.php', 'ezcconsoleoptionargumentsviolationexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/option_arguments_violation.php', 'ezcconsoleoptiondependencyviolationexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/option_dependency_violation.php', 'ezcconsoleoptionexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/option.php', 'ezcconsoleoptionexclusionviolationexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/option_exclusion_violation.php', 'ezcconsoleoptionmandatoryviolationexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/option_mandatory_violation.php', 'ezcconsoleoptionmissingvalueexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/option_missing_value.php', 'ezcconsoleoptionnoaliasexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/option_no_alias.php', 'ezcconsoleoptionnotexistsexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/option_not_exists.php', 'ezcconsoleoptionrule' => '/../vendor/zetacomponents/console-tools/src/structs/option_rule.php', 'ezcconsoleoptionstringnotwellformedexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/option_string_not_wellformed.php', 'ezcconsoleoptiontoomanyvaluesexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/option_too_many_values.php', 'ezcconsoleoptiontypeviolationexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/option_type_violation.php', 'ezcconsoleoutput' => '/../vendor/zetacomponents/console-tools/src/output.php', 'ezcconsoleoutputformat' => '/../vendor/zetacomponents/console-tools/src/structs/output_format.php', 'ezcconsoleoutputformats' => '/../vendor/zetacomponents/console-tools/src/structs/output_formats.php', 'ezcconsoleoutputoptions' => '/../vendor/zetacomponents/console-tools/src/options/output.php', 'ezcconsoleprogressbar' => '/../vendor/zetacomponents/console-tools/src/progressbar.php', 'ezcconsoleprogressbaroptions' => '/../vendor/zetacomponents/console-tools/src/options/progressbar.php', 'ezcconsoleprogressmonitor' => '/../vendor/zetacomponents/console-tools/src/progressmonitor.php', 'ezcconsoleprogressmonitoroptions' => '/../vendor/zetacomponents/console-tools/src/options/progressmonitor.php', 'ezcconsolequestiondialog' => '/../vendor/zetacomponents/console-tools/src/dialog/question_dialog.php', 'ezcconsolequestiondialogcollectionvalidator' => '/../vendor/zetacomponents/console-tools/src/dialog/validators/question_dialog_collection.php', 'ezcconsolequestiondialogmappingvalidator' => '/../vendor/zetacomponents/console-tools/src/dialog/validators/question_dialog_mapping.php', 'ezcconsolequestiondialogoptions' => '/../vendor/zetacomponents/console-tools/src/options/question_dialog.php', 'ezcconsolequestiondialogregexvalidator' => '/../vendor/zetacomponents/console-tools/src/dialog/validators/question_dialog_regex.php', 'ezcconsolequestiondialogtypevalidator' => '/../vendor/zetacomponents/console-tools/src/dialog/validators/question_dialog_type.php', 'ezcconsolequestiondialogvalidator' => '/../vendor/zetacomponents/console-tools/src/interfaces/question_dialog_validator.php', 'ezcconsolestandardinputvalidator' => '/../vendor/zetacomponents/console-tools/src/input/validators/standard.php', 'ezcconsolestatusbar' => '/../vendor/zetacomponents/console-tools/src/statusbar.php', 'ezcconsolestatusbaroptions' => '/../vendor/zetacomponents/console-tools/src/options/statusbar.php', 'ezcconsolestringtool' => '/../vendor/zetacomponents/console-tools/src/tools/string.php', 'ezcconsoletable' => '/../vendor/zetacomponents/console-tools/src/table.php', 'ezcconsoletablecell' => '/../vendor/zetacomponents/console-tools/src/table/cell.php', 'ezcconsoletableoptions' => '/../vendor/zetacomponents/console-tools/src/options/table.php', 'ezcconsoletablerow' => '/../vendor/zetacomponents/console-tools/src/table/row.php', 'ezcconsoletoomanyargumentsexception' => '/../vendor/zetacomponents/console-tools/src/exceptions/argument_too_many.php', 'theseer\\autoload\\application' => '/Application.php', 'theseer\\autoload\\applicationexception' => '/Application.php', 'theseer\\autoload\\autoloadbuilderexception' => '/AutoloadRenderer.php', 'theseer\\autoload\\autoloadrenderer' => '/AutoloadRenderer.php', 'theseer\\autoload\\cache' => '/Cache.php', 'theseer\\autoload\\cacheentry' => '/CacheEntry.php', 'theseer\\autoload\\cacheexception' => '/Cache.php', 'theseer\\autoload\\cachewarminglistrenderer' => '/CacheWarmingListRenderer.php', 'theseer\\autoload\\cachingparser' => '/CachingParser.php', 'theseer\\autoload\\classdependencysorter' => '/DependencySorter.php', 'theseer\\autoload\\classdependencysorterexception' => '/DependencySorter.php', 'theseer\\autoload\\cli' => '/CLI.php', 'theseer\\autoload\\clienvironmentexception' => '/CLI.php', 'theseer\\autoload\\collector' => '/Collector.php', 'theseer\\autoload\\collectorexception' => '/Collector.php', 'theseer\\autoload\\collectorresult' => '/CollectorResult.php', 'theseer\\autoload\\collectorresultexception' => '/CollectorResult.php', 'theseer\\autoload\\composeriterator' => '/ComposerIterator.php', 'theseer\\autoload\\composeriteratorexception' => '/ComposerIterator.php', 'theseer\\autoload\\config' => '/Config.php', 'theseer\\autoload\\factory' => '/Factory.php', 'theseer\\autoload\\logger' => '/Logger.php', 'theseer\\autoload\\parser' => '/Parser.php', 'theseer\\autoload\\parseresult' => '/ParseResult.php', 'theseer\\autoload\\parserexception' => '/Parser.php', 'theseer\\autoload\\parserinterface' => '/ParserInterface.php', 'theseer\\autoload\\pathcomparator' => '/PathComparator.php', 'theseer\\autoload\\pharbuilder' => '/PharBuilder.php', 'theseer\\autoload\\sourcefile' => '/SourceFile.php', 'theseer\\autoload\\staticlistrenderer' => '/StaticListRenderer.php', 'theseer\\autoload\\staticrenderer' => '/StaticRenderer.php', 'theseer\\autoload\\staticrequirelistrenderer' => '/StaticRequireListRenderer.php', 'theseer\\autoload\\version' => '/Version.php', 'theseer\\directoryscanner\\directoryscanner' => '/../vendor/theseer/directoryscanner/src/directoryscanner.php', 'theseer\\directoryscanner\\exception' => '/../vendor/theseer/directoryscanner/src/directoryscanner.php', 'theseer\\directoryscanner\\filesonlyfilteriterator' => '/../vendor/theseer/directoryscanner/src/filesonlyfilter.php', 'theseer\\directoryscanner\\includeexcludefilteriterator' => '/../vendor/theseer/directoryscanner/src/includeexcludefilter.php', 'theseer\\directoryscanner\\phpfilteriterator' => '/../vendor/theseer/directoryscanner/src/phpfilter.php' ); } $cn = strtolower($class); if (isset($classes[$cn])) { require __DIR__ . $classes[$cn]; } }, true, false ); // @codeCoverageIgnoreEnd Autoload-1.27.1/src/templates/000077500000000000000000000000001417410776500161535ustar00rootroot00000000000000Autoload-1.27.1/src/templates/ci/000077500000000000000000000000001417410776500165465ustar00rootroot00000000000000Autoload-1.27.1/src/templates/ci/default.php.tpl000066400000000000000000000010001417410776500214700ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\Autoload\Tests { use TheSeer\Autoload\AutoloadBuilderException; use TheSeer\Autoload\AutoloadRenderer; /** * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. */ class AutoloadRendererTest extends \PHPUnit\Framework\TestCase { private $classlist; private $template; public function setUp(): void { $this->classlist = array(); $this->classlist['demo1'] = realpath(__DIR__ . '/_data/parser/class.php'); $this->classlist['demo2'] = realpath(__DIR__ . '/_data/parser/class.php'); $this->template = file_get_contents(__DIR__ . '/_data/templates/default.php.tpl'); } /** * @covers \TheSeer\Autoload\AutoloadRenderer::__construct * @covers \TheSeer\Autoload\AutoloadRenderer::render */ public function testDefaultRendering() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $expected = " \$classes = array(\n 'demo1' => '".__DIR__."/_data/parser/class.php',\n"; $expected = strtr($expected, '\\', '/'); $this->assertStringContainsString($expected, $ab->render($this->template)); $expected = "require \$classes[\$cn]"; $this->assertStringContainsString($expected, $ab->render($this->template)); } /** * * @covers \TheSeer\Autoload\AutoloadRenderer::setLinebreak * @covers \TheSeer\Autoload\AutoloadRenderer::render */ public function testWindowsLFRendering() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $ab->setLineBreak("\r\n"); $expected = "_data/parser/class.php',\r\n"; $this->assertStringContainsString($expected, $ab->render($this->template)); } /** * * @covers \TheSeer\Autoload\AutoloadRenderer::setLinebreak * @covers \TheSeer\Autoload\AutoloadRenderer::getLinebreak */ public function testSettingAndGettingLinebreakWorks() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $ab->setLineBreak('foo'); $this->assertEquals('foo', $ab->getLineBreak()); } /** * * @covers \TheSeer\Autoload\AutoloadRenderer::setIndent * @covers \TheSeer\Autoload\AutoloadRenderer::render */ public function testIndentWithTabsRendering() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $ab->setIndent("\t"); $expected = "\t'demo2'"; $this->assertStringContainsString($expected, $ab->render($this->template)); } /** * * @covers \TheSeer\Autoload\AutoloadRenderer::setBaseDir * @covers \TheSeer\Autoload\AutoloadRenderer::render */ public function testSetBaseDirRendering() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $ab->setBaseDir(realpath(__DIR__ . '/..')); $result = $ab->render($this->template); $expected = "require __DIR__ . \$classes[\$cn];"; $expected = strtr($expected, '\\', '/'); $this->assertStringContainsString($expected, $result); $expected = " \$classes = array(\n 'demo1' => '/tests/_data/parser/class.php',\n"; $this->assertStringContainsString($expected, $result); } /** * * @covers \TheSeer\Autoload\AutoloadRenderer::render */ public function testRenderingInCompatMode() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $ab->setCompat(true); $ab->setBaseDir(realpath(__DIR__)); $expected = "require dirname(__FILE__) . \$classes[\$cn];"; $this->assertStringContainsString($expected, $ab->render($this->template)); } /** * @covers \TheSeer\Autoload\AutoloadRenderer::resolvePath */ public function testRelativeSubBaseDirRendering() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $ab->setBaseDir(realpath(__DIR__.'/_data/dependency')); $expected = "'demo1' => '/../parser/class.php'"; $this->assertStringContainsString($expected, $ab->render($this->template)); } public function testSettingInvalidTimestamp() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $this->expectException(AutoloadBuilderException::class); $ab->setTimestamp('Bad'); } public function testSettingTimestamp() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $now = time(); $ab->setTimestamp($now); $this->assertEquals(date('r',$now), $ab->render('___CREATED___')); } /** * * @depends testSettingTimestamp */ public function testSettingDateTimeFormat() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $now = time(); $ab->setTimestamp($now); $ab->setDateTimeFormat('dmYHis'); $this->assertEquals(date('dmYHis',$now), $ab->render('___CREATED___')); } /** * * @covers \TheSeer\Autoload\AutoloadRenderer::setVariable */ public function testSetVariable() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $ab->setVariable('TEST','variableValue'); $this->assertEquals('variableValue', $ab->render('___TEST___')); } /** * * @covers \TheSeer\Autoload\AutoloadRenderer::render */ public function testGetUniqueReproducibleValueForAutoloadName() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $first = $ab->render('___AUTOLOAD___'); $this->assertEquals($first, $ab->render('___AUTOLOAD___')); } /** * * @covers \TheSeer\Autoload\AutoloadRenderer::render */ public function testGetUniqueValueForAutoloadName() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $first = $ab->render('___AUTOLOAD___'); $aSecond = $this->classlist; array_pop($aSecond); $ab = new \TheSeer\Autoload\AutoloadRenderer($aSecond); $this->assertNotEquals($first, $ab->render('___AUTOLOAD___')); } /** * @covers \TheSeer\Autoload\AutoloadRenderer::setCompat */ public function testSetCompatMode() { $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); $ab->setCompat(true); $ab->setBaseDir('.'); $this->assertEquals('dirname(__FILE__) . ', $ab->render('___BASEDIR___')); } } } Autoload-1.27.1/tests/ComposerIteratorTest.php000066400000000000000000000020471417410776500214050ustar00rootroot00000000000000 $entry) { $this->assertEquals($expected[$pos], $entry); } } public function testPSR14ArrayIsSupported() { $iterator = new ComposerIterator(new \SplFileInfo(__DIR__ . '/_data/composer-array-issue-98/composer.json')); $expected = array( __DIR__ . '/_data/composer-array-issue-98/../src', __DIR__ . '/_data/composer-array-issue-98/modules', __DIR__ . '/_data/composer-array-issue-98/src' ); foreach($iterator as $pos => $entry) { $this->assertEquals($expected[$pos], $entry); } } } Autoload-1.27.1/tests/DuplicateDetectionTest.php000066400000000000000000000052721417410776500216600ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\Autoload\Tests { use TheSeer\Autoload\Config; use TheSeer\Autoload\Factory; class DuplicateDetectionTest extends \PHPUnit\Framework\TestCase { public function testBugIsFixed() { $config = new Config(array()); $config->setLowercaseMode(true); $factory = new Factory(); $factory->setConfig($config); $collector = $factory->getCollector(); $scanner = $factory->getScanner()->getIterator(__DIR__ . '/_data/duplicates'); $collector->processDirectory($scanner); $result = $collector->getResult(); $this->assertTrue($result->hasDuplicates()); $duplicates = $result->getDuplicates(); $this->assertCount(1, $duplicates); $this->assertArrayHasKey('a\\b\\c\\duplicate', $duplicates); $this->assertCount(3, $duplicates['a\\b\\c\\duplicate']); } } } Autoload-1.27.1/tests/FactoryTest.php000066400000000000000000000047461417410776500175230ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\Autoload\Tests { use TheSeer\Autoload\Application; use TheSeer\Autoload\Config; use TheSeer\Autoload\CLI; use TheSeer\Autoload\Factory; class FactoryTest extends \PHPUnit\Framework\TestCase { public function setUp(): void { $this->factory = new Factory(); $this->config = new Config(array()); $this->factory->setConfig($this->config); } public function testApp() { $app = $this->factory->getApplication(); $this->assertTrue($app instanceof Application); } public function testCli() { $app = $this->factory->getCLI(); $this->assertTrue($app instanceof CLI); } } } Autoload-1.27.1/tests/ParserTest.php000066400000000000000000000611201417410776500173350ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\Autoload\Tests { use TheSeer\Autoload\Parser; use TheSeer\Autoload\ParserException; use TheSeer\Autoload\SourceFile; class ParserTest extends \PHPUnit\Framework\TestCase { public function testNoClassDefined() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/noclass.php'))); $this->assertFalse($rc->hasUnits()); $this->assertCount(0,$rc->getUnits()); } public function testOneClass() { $parser = new \TheSeer\Autoload\Parser; $result = $parser->parse(new SourceFile((__DIR__.'/_data/parser/class.php'))); $this->assertTrue($result->hasUnits()); $this->assertCount(1, $result->getUnits()); $this->assertContains('demo', $result->getUnits()); } public function testOneClassCaseSensitive() { $parser = new \TheSeer\Autoload\Parser(false,false,true); $result = $parser->parse(new SourceFile((__DIR__.'/_data/parser/class.php'))); $this->assertTrue($result->hasUnits()); $this->assertContains('Demo', $result->getUnits()); } public function testClassKeywordReusageForResolvingGetsIgnored() { $parser = new \TheSeer\Autoload\Parser; $units = $parser->parse(new SourceFile((__DIR__.'/_data/parser/classname.php')))->getUnits(); $this->assertCount(1,$units); $this->assertContains('x\\demo', $units); } public function testRedeclaringThrowsException() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/redeclaration.php'))); $this->assertTrue($rc->hasRedeclarations()); $this->assertContains('demo', $rc->getRedeclarations()); } public function testInvalidClassnameThrowsException() { $parser = new \TheSeer\Autoload\Parser; $this->expectException(ParserException::class); $this->expectExceptionCode(ParserException::ParseError); $parser->parse(new SourceFile((__DIR__.'/_data/parser/parseerror1.php'))); } public function testInvalidClassnameWithExtendsThrowsException() { $parser = new \TheSeer\Autoload\Parser; $this->expectException(ParserException::class); $this->expectExceptionCode(ParserException::ParseError); $parser->parse(new SourceFile((__DIR__.'/_data/parser/parseerror2.php'))); } public function testInvalidClassnameForExtendsThrowsException() { $parser = new \TheSeer\Autoload\Parser(true); $this->expectException(ParserException::class); $this->expectExceptionCode(ParserException::ParseError); $parser->parse(new SourceFile((__DIR__.'/_data/parser/parseerror3.php'))); } public function testInvalidClassnameForImplementsThrowsException() { $parser = new \TheSeer\Autoload\Parser(true); $this->expectException(ParserException::class); $this->expectExceptionCode(ParserException::ParseError); $parser->parse(new SourceFile((__DIR__.'/_data/parser/parseerror4.php'))); } public function testSyntacticallyInvalidClassnameThrowsException() { $parser = new \TheSeer\Autoload\Parser; $this->expectException(ParserException::class); $this->expectExceptionCode(ParserException::ParseError); $parser->parse(new SourceFile((__DIR__.'/_data/parser/invalid1.php'))); } public function testInvalidTokenInClassnameThrowsException() { $parser = new \TheSeer\Autoload\Parser; $this->expectException(ParserException::class); $this->expectExceptionCode(ParserException::ParseError); $parser->parse(new SourceFile((__DIR__.'/_data/parser/invalid2.php'))); } public function testInvalidTokenInClassnameWithinNamespaceThrowsException() { $parser = new \TheSeer\Autoload\Parser; $this->expectException(ParserException::class); $this->expectExceptionCode(ParserException::ParseError); $parser->parse(new SourceFile((__DIR__.'/_data/parser/invalid3.php'))); } public function testMultipleClasses() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/multiclass.php'))); $classes = $rc->getUnits(); $this->assertCount(3,$classes); $this->assertContains('demo1', $classes); $this->assertContains('demo2', $classes); $this->assertContains('demo3', $classes); } public function testExtends() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/extends.php'))); $classes = $rc->getUnits(); $this->assertCount(2,$classes); $this->assertContains('demo1', $classes); $this->assertContains('demo2', $classes); } public function testExtendsWithDependency() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/extends.php'))); $this->assertEquals(array('demo1'), $rc->getDependenciesForUnit('demo2')); } public function testInterface() { $parser = new \TheSeer\Autoload\Parser(); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/interface.php'))); $interfaces = $rc->getUnits(); $this->assertCount(1,$interfaces); $this->assertContains('demo', $interfaces); } public function testInterfaceExtendsWithDependency() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/interfaceextends1.php'))); $this->assertContains('demo2', $rc->getUnits()); $this->assertEquals(array('demo1'), $rc->getDependenciesForUnit('demo2')); } public function testInterfaceExtendsWithDependencyAndNamespaceChange() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/interfaceextends2.php'))); $this->assertEquals(array('a\\demo1','iterator'), $rc->getDependenciesForUnit('a\\demo2')); } public function testSingleImplements() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/implements1.php'))); $classes = $rc->getUnits(); $this->assertCount(2,$classes); $this->assertContains('demo1', $classes); $this->assertContains('demo2', $classes); } public function testMultiImplements() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/implements2.php'))); $classes = $rc->getUnits(); $this->assertCount(3,$classes); $this->assertContains('demo1', $classes); $this->assertContains('demo2', $classes); $this->assertContains('demo3', $classes); } public function testMultiImplementsDepdencies() { $parser = new \TheSeer\Autoload\Parser(true); $result = $parser->parse(new SourceFile((__DIR__.'/_data/parser/implements2.php'))); $this->assertEquals(array('demo1','demo2'), $result->getDependenciesForUnit('demo3')); } public function testMultiImplementsDepdenciesWithNamespace() { $parser = new \TheSeer\Autoload\Parser(true); $result = $parser->parse(new SourceFile((__DIR__.'/_data/parser/implements3.php'))); $expect = array('a\\demo1','b\\demo2'); $this->assertEquals($expect, $result->getDependenciesForUnit('b\\demo3')); } public function testImplementsExtends() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/implementsextends.php'))); $classes = $rc->getUnits(); $this->assertCount(3, $classes); $this->assertContains('test', $classes); $this->assertContains('demo1', $classes); $this->assertContains('demo2', $classes); } public function testNamespaceBracketSyntax() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/namespace1.php'))); $this->assertCount(1,$rc->getUnits()); $this->assertContains('demo\\demo1', $rc->getUnits()); } public function testNamespaceBracketSyntaxMultiLevel() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/namespace2.php'))); $this->assertCount(1,$rc->getUnits()); $this->assertContains('demo\\level2\\demo1', $rc->getUnits()); } public function testNamespaceSemicolonSyntax() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/namespace3.php'))); $this->assertCount(1,$rc->getUnits()); $this->assertContains('demo\\demo1', $rc->getUnits()); } public function testNamespaceSemicolonSyntaxMultiLevel() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/namespace4.php'))); $this->assertCount(1,$rc->getUnits()); $this->assertContains('demo\\level2\\demo1', $rc->getUnits()); } public function testNamespaceBracketCounting() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/namespace5.php'))); $this->assertCount(1,$rc->getUnits()); $this->assertContains('demo\\level2\\demo1', $rc->getUnits()); } public function testNamespaceSemicolonSyntaxMultiNS() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/namespace6.php'))); $classes = $rc->getUnits(); $this->assertCount(2,$classes); $this->assertContains('demo\\level2\\demo1', $classes); $this->assertContains('demo\\level2\\level3\\demo2', $classes); } public function testNamespaceBracketSyntaxMultiNS() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/namespace7.php'))); $classes = $rc->getUnits(); $this->assertCount(2,$classes); $this->assertContains('demo\\level2\\demo1', $classes); $this->assertContains('demo\\level2\\level3\\demo2', $classes); } public function testNamespaceParsingIgnoresConstantAccessUseOfNamespaceKeyword() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/namespaceconstant.php'))); $classes = $rc->getUnits(); $this->assertCount(1,$classes); $this->assertContains('demo\\level2\\demo1', $classes); } public function testEmptyNamespaceNameParsingWorks() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/namespace8.php'))); $classes = $rc->getUnits(); $this->assertCount(1,$classes); $this->assertContains('demo', $classes); } public function testBracketParsingBugTest1() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/brackettest1.php'))); $classes = $rc->getUnits(); $this->assertCount(2,$classes); $this->assertContains('x\\foo', $classes); $this->assertContains('x\\baz', $classes); } public function testBracketParsingBugTest2() { $parser = new \TheSeer\Autoload\Parser; $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/brackettest2.php'))); $classes = $rc->getUnits(); $this->assertCount(2,$classes); $this->assertContains('x\\foo', $classes); $this->assertContains('x\\baz', $classes); } public function testDependenciesFound() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/dependency/file1.php'))); $expect = array('test\\demo1','test\\demo2'); $this->assertEquals($expect, $rc->getDependenciesForUnit('foo\\demo3')); } public function testParseTraitWorks() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/trait0.php'))); $this->assertContains('test', $rc->getUnits()); } public function testParseUseTraitWorks() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/trait1.php'))); $classes = $rc->getUnits(); $this->assertContains('test', $classes); $this->assertContains('bar', $classes); $this->assertEquals(array('test'), $rc->getDependenciesForUnit('bar')); } public function testParseUseTraitWorksWhenDependencyIsDisabled() { $parser = new \TheSeer\Autoload\Parser(); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/trait1.php'))); $classes = $rc->getUnits(); $this->assertContains('test', $classes); $this->assertContains('bar', $classes); } public function testParseUseMultipleTraitWorks() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/trait2.php'))); $classes = $rc->getUnits(); $this->assertContains('test', $classes); $this->assertContains('trait1', $classes); $this->assertContains('trait2', $classes); $expect = array('trait1', 'trait2'); $this->assertEquals($expect, $rc->getDependenciesForUnit('test')); } public function testParseUseTraitWorksEvenWithUseStatementInMethodForClosure() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/trait3.php'))); $classes = $rc->getUnits(); $this->assertContains('test', $classes); $this->assertContains('trait1', $classes); $expect = array('trait1'); $this->assertEquals($expect, $rc->getDependenciesForUnit('test')); } public function testParseUseTraitsWithOverwriteSkipsBracketContent() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/trait4.php'))); $classes = $rc->getUnits(); $this->assertContains('test', $classes); $this->assertContains('trait1', $classes); $expect = array('trait1', 'trait2'); $this->assertEquals($expect, $rc->getDependenciesForUnit('test')); } public function testNamespaceImportViaUse() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/use1.php'))); $classes = $rc->getUnits(); $this->assertContains('demo\\a\\demo1', $classes); $this->assertContains('demo\\b\\demo2', $classes); $expect = array('demo\\a\\demo1'); $this->assertEquals($expect, $rc->getDependenciesForUnit('demo\\b\\demo2')); } public function testNamespaceMultiImportViaUse() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/use2.php'))); $classes = $rc->getUnits(); $this->assertContains('demo\\a\\demo1', $classes); $this->assertContains('demo\\b\\demo2', $classes); $this->assertContains('demo\\c\\demo3', $classes); $expect = array('demo\\a\\demo1'); $this->assertEquals($expect, $rc->getDependenciesForUnit('demo\\c\\demo3')); } public function testNamespaceImportWithAlias() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/use3.php'))); $classes = $rc->getUnits(); $this->assertContains('demo\\a\\demo1', $classes); $this->assertContains('demo\\b\\demo2', $classes); $expect = array('demo\\a\\demo1'); $this->assertEquals($expect, $rc->getDependenciesForUnit('demo\\b\\demo2')); } public function testNamespaceImportWithRelativeAlias() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/use4.php'))); $classes = $rc->getUnits(); $this->assertContains('demo\\a\\demo1', $classes); $this->assertContains('demo\\b\\demo2', $classes); $this->assertEquals(array('demo\\a\\demo1'), $rc->getDependenciesForUnit('demo\\b\\demo2')); } public function testAliasViaUseGetsIgnoredIfNotNeeded() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/use5.php'))); $classes = $rc->getUnits(); $this->assertContains('demo', $classes); $this->assertEquals(array(), $rc->getDependenciesForUnit('demo')); } public function testUseInClosurewithinAClassGetsIgnored() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/use6.php'))); $classes = $rc->getUnits(); $this->assertContains('demo\\a\\demo2', $classes); $this->assertEquals(array(), $rc->getDependenciesForUnit('demo\\a\\demo2')); } public function testGlobalUseInClosureGetsIgnored() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/use7.php'))); $classes = $rc->getUnits(); $this->assertContains('demo\\a\\demo2', $classes); $this->assertEquals(array(), $rc->getDependenciesForUnit('demo\\a\\demo2')); } public function testUseConstIsIgnored() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/use9.php'))); $this->assertEquals(array('demo'), $rc->getUnits()); $this->assertEquals(array('name'), $rc->getDependenciesForUnit('demo')); } public function testUseFunctionIsIgnored() { $parser = new \TheSeer\Autoload\Parser(true); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/use10.php'))); $this->assertEquals(array('demo'), $rc->getUnits()); $this->assertEquals(array('name'), $rc->getDependenciesForUnit('demo')); } public function testGroupUseSyntaxIsHandeled() { $parser = new Parser(); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/groupuse.php'))); $units = array('some\\name\\space\\classd'); $dependencies = array( 'foo\bar\interfacea', 'my\other\name\interfaceb', 'my\other\some\interfaced', 'my\other\name\classa' ); $this->assertEquals($units, $rc->getUnits()); $this->assertEquals($dependencies, $rc->getDependenciesForUnit('some\\name\\space\\classd')); } public function testGroupUseSyntaxWithConstIsHandeled() { $parser = new Parser(); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/groupuse2.php'))); $units = array('some\\name\\space\\classd'); $dependencies = array( 'my\other\name\interfaceb', 'some\name\space\foo' ); $this->assertEquals($units, $rc->getUnits()); $this->assertEquals($dependencies, $rc->getDependenciesForUnit('some\\name\\space\\classd')); } public function testAnonymousClassGetsIgnored() { $parser = new Parser(); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/anonymousclass.php'))); $this->assertEmpty($rc->getUnits()); } public function testAnonymousClassImplementingInterfaceGetsIgnored() { $parser = new Parser(); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/anonymousclass2.php'))); $this->assertEquals(array('foo'), $rc->getUnits()); } public function testInlineUseOfKeywordClassGetsIgnored() { $parser = new Parser(); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/inline-class.php'))); $this->assertEquals(array('demo'), $rc->getUnits()); } public function testInlineUseOfKeywordInterfaceGetsIgnored() { $parser = new Parser(); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/inline-interface.php'))); $this->assertEquals(array('demo'), $rc->getUnits()); } public function testInlineUseOfKeywordTraitGetsIgnored() { $parser = new Parser(); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/inline-trait.php'))); $this->assertEquals(array('demo'), $rc->getUnits()); } public function testPHP80Relative() { $parser = new Parser(); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/relative.php'))); $this->assertEquals(array('foo\\demo'), $rc->getUnits()); } /** * @requires PHP 8.1 */ public function testCanParseSimpleEnums() { $parser = new Parser(); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/basic-enum.php'))); $this->assertEquals(array('test\\foo','test\\barinterface','test\\bazenum','test\\barenum'), $rc->getUnits()); } /** * @requires PHP 8.1 */ public function testCanParseBackedEnums() { $parser = new Parser(); $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/backed-enum.php'))); $this->assertEquals(array('sample'), $rc->getDependenciesForUnit('foo')); $this->assertEquals(array('sample','foo'), $rc->getUnits()); } } } Autoload-1.27.1/tests/PathComparatorTest.php000066400000000000000000000026361417410776500210340ustar00rootroot00000000000000assertEquals($common, $comparator->getCommonBase()); } public function directoriesProvider() { return array( 'empty' => array( array(), '/' ), 'single' => array( array(__DIR__), __DIR__ ), 'two' => array( array(__DIR__, dirname(__DIR__)), dirname(__DIR__) ), 'parents' => array( array(__DIR__ . '/../src', __DIR__ . '/../tests/_data'), dirname(__DIR__) ), 'with0' => array( array($a=__DIR__.'/_data/parser/trait0.php'), $a ), 'dirwithprefix' => array( array(__DIR__.'/_data/parser/trait0.php', __DIR__.'/_data/parser/trait1.php'), __DIR__.'/_data/parser' ), 'dirwithoutprefix' => array( array(__DIR__, '/usr'), '/' ) ); } } } Autoload-1.27.1/tests/_data/000077500000000000000000000000001417410776500156005ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/bug65/000077500000000000000000000000001417410776500165305ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/bug65/class.php000066400000000000000000000002261417410776500203460ustar00rootroot00000000000000= 5.5.9", "bar/foo": "0.0" }, "autoload": { "psr-4": { "": ["../src/", "modules/"], "MyApp\\": "src/" } } } Autoload-1.27.1/tests/_data/dependency/000077500000000000000000000000001417410776500177165ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/dependency/file1.php000066400000000000000000000004501417410776500214260ustar00rootroot00000000000000 Autoload-1.27.1/tests/_data/dependency/file2.php000066400000000000000000000002371417410776500214320ustar00rootroot00000000000000 Autoload-1.27.1/tests/_data/dependency/ns01.php000066400000000000000000000001331417410776500212050ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/classname.php000066400000000000000000000001671417410776500215570ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/groupuse.php000066400000000000000000000004021417410776500214520ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/implements2.php000066400000000000000000000001301417410776500220360ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/inline-class.php000066400000000000000000000000661417410776500221700ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/interfaceextends1.php000066400000000000000000000000771417410776500232250ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/interfaceextends2.php000066400000000000000000000001401417410776500232150ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/namespace1.php000066400000000000000000000000611417410776500216170ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/namespace2.php000066400000000000000000000000701417410776500216200ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/namespace3.php000066400000000000000000000000541417410776500216230ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/namespace4.php000066400000000000000000000000631417410776500216240ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/namespace5.php000066400000000000000000000002051417410776500216230ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/namespace6.php000066400000000000000000000001421417410776500216240ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/namespace7.php000066400000000000000000000001561417410776500216320ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/namespace8.php000066400000000000000000000000461417410776500216310ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/nested.php000066400000000000000000000001331417410776500210640ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/parseerror1.php000066400000000000000000000000271417410776500220510ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/use10.php000066400000000000000000000000741417410776500205430ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/use3.php000066400000000000000000000002061417410776500204620ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/use4.php000066400000000000000000000001751417410776500204700ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/use5.php000066400000000000000000000001221417410776500204610ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/use6.php000066400000000000000000000002341417410776500204660ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/parser/use7.php000066400000000000000000000001451417410776500204700ustar00rootroot00000000000000= 5.5.9", "bar/foo": "0.0" } } Autoload-1.27.1/tests/_data/recursion/vendor/000077500000000000000000000000001417410776500211065ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/recursion/vendor/bar/000077500000000000000000000000001417410776500216525ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/recursion/vendor/bar/foo/000077500000000000000000000000001417410776500224355ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/recursion/vendor/bar/foo/composer.json000066400000000000000000000001321417410776500251530ustar00rootroot00000000000000{ "name": "recursion", "require": { "php": ">= 5.5.9", "foo/bar": "0.0" } } Autoload-1.27.1/tests/_data/recursion/vendor/bar/foo/src/000077500000000000000000000000001417410776500232245ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/recursion/vendor/bar/foo/src/foo.php000066400000000000000000000001351417410776500245170ustar00rootroot00000000000000= 5.5.9", "bar/foo": "0.0" } } Autoload-1.27.1/tests/_data/recursion/vendor/foo/bar/src/000077500000000000000000000000001417410776500232245ustar00rootroot00000000000000Autoload-1.27.1/tests/_data/recursion/vendor/foo/bar/src/bar.php000066400000000000000000000001351417410776500245000ustar00rootroot00000000000000Autoload-1.27.1/tests/bug65Test.php000066400000000000000000000054771417410776500170460ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\Autoload\Tests { use TheSeer\Autoload\ClassDependencySorter; use TheSeer\Autoload\Config; use TheSeer\Autoload\Factory; class Bug65Test extends \PHPUnit\Framework\TestCase { public function testBugIsFixed() { $config = new Config(array()); $config->setLowercaseMode(true); $factory = new Factory(); $factory->setConfig($config); $collector = $factory->getCollector(); $scanner = $factory->getScanner()->getIterator(__DIR__ . '/_data/bug65'); $collector->processDirectory($scanner); $result = $collector->getResult(); $sorter = new ClassDependencySorter($result->getUnits(), $result->getDependencies()); $expected = array( 'phpunit_extensions_database_testcase_trait' => __DIR__ . "/_data/bug65/trait.php", 'phpunit_extensions_database_testcase' => __DIR__ . "/_data/bug65/class.php" ); $this->assertEquals($expected, $sorter->process()); } } } Autoload-1.27.1/tests/classdependencysorterTest.php000066400000000000000000000103661417410776500225120ustar00rootroot00000000000000 * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\Autoload\Tests { use TheSeer\Autoload\ClassDependencySorterException; use TheSeer\Autoload\Parser; use TheSeer\Autoload\AutoloadRenderer; use TheSeer\Autoload\ClassDependencySorter; /** * Unit tests for ClassDependencySorter class * * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. */ class ClassDependencySorterTest extends \PHPUnit\Framework\TestCase { public function testProcessingDependenciesInOneFile() { $classes = array( 'class1' => 'file1', 'class2' => 'file1' ); $dependency=array( 'class1' => array('class2') ); $x = new ClassDependencySorter($classes, $dependency); $r = $x->process(); $expectOrder=array('class2','class1'); $this->assertEquals(2, count($r)); $this->assertEquals($expectOrder, array_keys($r)); } public function testProcessingDependenciesOverFileBounderies() { $classes = array( 'class3' => 'file3', 'class1' => 'file1', 'class2' => 'file2' ); $dependency=array( 'class2' => array('class3'), 'class1' => array('class2') ); $x = new ClassDependencySorter($classes, $dependency); $r = $x->process(); $expectOrder=array( 'class3','class2','class1' ); $expectFilesOrder=array( 'file3','file2','file1' ); $this->assertEquals(3, count($r)); $this->assertEquals($expectOrder, array_keys($r)); $this->assertEquals($expectFilesOrder, array_unique(array_values($r))); } public function testRecusriveDependencyThrowsException() { $classes=array('test1' => 'file1'); $dependency=array('test1' => array('test1')); $x = new ClassDependencySorter($classes, $dependency); $this->expectException(ClassDependencySorterException::class); $r = $x->process(); } public function testUnkownDependencyGetsSkippedSilently() { $classes=array('test1' => 'file1'); $dependency=array('test1' => array('test2')); $x = new ClassDependencySorter($classes, $dependency); $r = $x->process(); $this->assertTrue(true); } } } Autoload-1.27.1/tests/init.php000066400000000000000000000000611417410776500162010ustar00rootroot00000000000000