diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6022e5e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +.gitattributes export-ignore +.gitignore export-ignore +.travis.yml export-ignore +docs export-ignore +tests export-ignore diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..7579f74 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +vendor +composer.lock diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ceef256 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: php + +php: + - 5.3.3 + - 5.4 + - 5.5 + +before_script: + - composer self-update + - composer install --no-interaction --prefer-source --dev + +script: php tests/lint.php src/Kdyby/ tests/KdybyTests/ && VERBOSE=true ./tests/run-tests.sh -s tests/KdybyTests/ diff --git a/README.md b/README.md new file mode 100755 index 0000000..66d9e9c --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +Kdyby/Events [![Build Status](https://secure.travis-ci.org/Kdyby/Events.png?branch=master)](http://travis-ci.org/Kdyby/Events) +=========================== + + +Requirements +------------ + +Kdyby/Events requires PHP 5.3.2 or higher. + +- [Nette Framework 2.0.x](https://github.com/nette/nette) + + +Kdyby/Events are also compatible with events dispatcher in [doctrine/common](https://github.com/doctrine/common), so you can use them with Doctrine. + + +Installation +------------ + +The best way to install Kdyby/Events is using [Composer](http://getcomposer.org/): + +```sh +$ composer require kdyby/events:@dev +``` + + +----- + +Homepage [http://www.kdyby.org](http://www.kdyby.org) and repository [http://github.com/kdyby/events](http://github.com/kdyby/events). diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..cffdf9c --- /dev/null +++ b/composer.json @@ -0,0 +1,33 @@ +{ + "name": "kdyby/aop", + "type": "library", + "description": "AOP for Nette Framework Dependency Injection Container", + "keywords": ["nette", "kdyby", "aop", "di", "dic", "aspect"], + "homepage": "http://kdyby.org", + "license": ["BSD-3-Clause", "GPL-2.0", "GPL-3.0"], + "authors": [ + { + "name": "Filip Procházka", + "homepage": "http://filip-prochazka.com" + } + ], + "support": { + "email": "filip@prochazka.su", + "issues": "https://github.com/kdyby/aop/issues" + }, + "require": { + "nette/nette": "@dev", + "doctrine/common": "~2.3" + }, + "require-dev": { + "nette/tester": "@dev" + }, + "autoload": { + "psr-0": { + "Kdyby\\Aop\\": "src/" + }, + "classmap": [ + "src/Kdyby/Aop/exceptions.php" + ] + } +} diff --git a/license.md b/license.md new file mode 100644 index 0000000..835b659 --- /dev/null +++ b/license.md @@ -0,0 +1,57 @@ +Licenses +======== + +Good news! You may use Kdyby Framework under the terms of either +the New BSD License or the GNU General Public License (GPL) version 2 or 3. + +The BSD License is recommended for most projects. It is easy to understand and it +places almost no restrictions on what you can do with the framework. If the GPL +fits better to your project, you can use the framework under this license. + +You don't have to notify anyone which license you are using. You can freely +use Kdyby Framework in commercial projects as long as the copyright header +remains intact. + + + +New BSD License +--------------- + +Copyright (c) 2008 Filip Procházka (http://filip-prochazka.com) +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 "Kdyby Framework" nor the names of its 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 owner or contributors 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. + + + +GNU General Public License +-------------------------- + +GPL licenses are very very long, so instead of including them here we offer +you URLs with full text: + +- [GPL version 2](http://www.gnu.org/licenses/gpl-2.0.html) +- [GPL version 3](http://www.gnu.org/licenses/gpl-3.0.html) diff --git a/src/Kdyby/Aop/annotations.php b/src/Kdyby/Aop/annotations.php new file mode 100644 index 0000000..091d0d5 --- /dev/null +++ b/src/Kdyby/Aop/annotations.php @@ -0,0 +1,13 @@ + + */ +interface Exception +{ + +} + + + +/** + * @author Filip Procházka + */ +class InvalidStateException extends \RuntimeException implements Exception +{ + +} diff --git a/tests/KdybyTests/.gitignore b/tests/KdybyTests/.gitignore new file mode 100755 index 0000000..9632c82 --- /dev/null +++ b/tests/KdybyTests/.gitignore @@ -0,0 +1,3 @@ +coverage.dat +*.actual +*.expected diff --git a/tests/KdybyTests/bootstrap.php b/tests/KdybyTests/bootstrap.php new file mode 100755 index 0000000..18da9c2 --- /dev/null +++ b/tests/KdybyTests/bootstrap.php @@ -0,0 +1,43 @@ +run(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : NULL); +} diff --git a/tests/conventions.txt b/tests/conventions.txt new file mode 100644 index 0000000..bf471e6 --- /dev/null +++ b/tests/conventions.txt @@ -0,0 +1,26 @@ +Test case file name +=================== + +Nette\....phpt + +Nette\Debug.phpt - tests for a class's basic behaviour +Nette\Debug.fireLog().phpt - tests for a method's basic behaviour +Nette\Debug.fireLog().inc - common code for more test cases +Nette\Debug.fireLog().expect - expected raw output +Nette\Debug.fireLog().area.phpt - tests for a specified area of class/method + +- areas: basic, error, bug#123 +- numbers have three digits + + +Test case phpDoc +================ + +/** + * Test: some test name + * + * @author John Doe + * @phpVersion < 5.3 default operator is >= + * @skip some reason why test is skipped + * @phpIni short_open_tag=on + */ diff --git a/tests/lint.php b/tests/lint.php new file mode 100644 index 0000000..7998d7e --- /dev/null +++ b/tests/lint.php @@ -0,0 +1,103 @@ +#!/usr/bin/php + false, 'files' => array()); + foreach (array_keys(getopt('qh', array('quiet', 'help'))) as $arg) { + switch ($arg) { + case 'q': + case 'quiet': + $options['quiet'] = true; + break; + + case 'h': + case 'help': + default: + echo << 1) { + foreach ($_SERVER['argv'] as $i => $arg) { + if (substr($arg, 0, 1) === '-' || $i === 0) continue; + $options['files'][] = $arg; + } + } + + if (empty($options['files'])) $options['files'][] = $_SERVER['PWD']; + + foreach ($options['files'] as $i => $file) { + if (($options['files'][$i] = realpath($file)) !== false) continue; + echo "$file is not a file or directory.\n"; + exit(1); + } + + return $options; +}; + +$echo = function () use (&$context) { + if ($context['quiet']) return; + foreach (func_get_args() as $arg) echo $arg; +}; + +$lintFile = function ($path) use (&$echo, &$context) { + if (substr($path, -4) != '.php') return; + + if ($context['filesCount'] % 63 == 0) { + $echo("\n"); + } + + exec("php -l " . escapeshellarg($path) . " 2>&1 1> /dev/null", $output, $code); + if ($code) { + $context['errors'][] = implode($output); + $echo('E'); + } else { + $echo('.'); + } + + $context['filesCount']++; +}; + +$check = function ($path) use (&$check, &$lintFile, &$context) { + if (!is_dir($path)) return $lintFile($path); + foreach (scandir($path) as $item) { + if ($item == '.' || $item == '..') continue; + $check(rtrim($path, '/') . '/' . $item); + } +}; + + +$context = $parseOptions(); +$context['filesCount'] = 0; +$context['errors'] = array(); +foreach ($context['files'] as $file) $check($file); +if ($context['errors']) { + $echo("\n\n", implode($context['errors'])); +} + +$echo( + "\n\n", ($context['errors'] ? 'FAILED' : 'OK'), + ' (', $context['filesCount'], " files checked, ", count($context['errors']), " errors)\n" +); +exit($context['errors'] ? 1 : 0); diff --git a/tests/php.ini-unix b/tests/php.ini-unix new file mode 100644 index 0000000..e69de29 diff --git a/tests/run-tests.sh b/tests/run-tests.sh new file mode 100755 index 0000000..ff71cc5 --- /dev/null +++ b/tests/run-tests.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# Path to this script's directory +dir=$(cd `dirname $0` && pwd) + +# Path to test runner script +runnerScript="$dir/../vendor/nette/tester/Tester/tester.php" +if [ ! -f "$runnerScript" ]; then + echo "Nette Tester is missing. You can install it using Composer:" >&2 + echo "php composer.phar update --dev." >&2 + exit 2 +fi + +# Path to php.ini if passed as argument option +phpIni= +while getopts ":c:" opt; do + case $opt in + c) phpIni="$OPTARG" + ;; + + :) echo "Missing argument for -$OPTARG option" >&2 + exit 2 + ;; + esac +done + +# Runs tests with script's arguments, add default php.ini if not specified +# Doubled -c option intentionally +if [ -n "$phpIni" ]; then + php -c "$phpIni" "$runnerScript" -j 20 "$@" +else + php -c "$dir/php.ini-unix" "$runnerScript" -j 20 -c "$dir/php.ini-unix" "$@" +fi +error=$? + +# Print *.actual content if tests failed +if [ "${VERBOSE-false}" != "false" -a $error -ne 0 ]; then + for i in $(find . -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done + exit $error +fi