Update vendor folder
This commit is contained in:
parent
6644bce167
commit
c6e7d1b6a2
|
|
@ -111,21 +111,21 @@
|
|||
},
|
||||
{
|
||||
"name": "eluceo/ical",
|
||||
"version": "0.16.0",
|
||||
"version_normalized": "0.16.0.0",
|
||||
"version": "0.16.1",
|
||||
"version_normalized": "0.16.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/markuspoerschke/iCal.git",
|
||||
"reference": "97da0d94c9716e65c141066a2d96aa098379721b"
|
||||
"reference": "7043337feaeacbc016844e7e52ef41bba504ad8f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/markuspoerschke/iCal/zipball/97da0d94c9716e65c141066a2d96aa098379721b",
|
||||
"reference": "97da0d94c9716e65c141066a2d96aa098379721b",
|
||||
"url": "https://api.github.com/repos/markuspoerschke/iCal/zipball/7043337feaeacbc016844e7e52ef41bba504ad8f",
|
||||
"reference": "7043337feaeacbc016844e7e52ef41bba504ad8f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
"php": ">=7.1 || ~8.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.0"
|
||||
|
|
@ -133,7 +133,7 @@
|
|||
"suggest": {
|
||||
"ext-mbstring": "Massive performance enhancement of line folding"
|
||||
},
|
||||
"time": "2019-12-29T22:08:56+00:00",
|
||||
"time": "2020-10-04T17:41:11+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
|
@ -267,31 +267,31 @@
|
|||
},
|
||||
{
|
||||
"name": "pimple/pimple",
|
||||
"version": "v3.2.3",
|
||||
"version_normalized": "3.2.3.0",
|
||||
"version": "v3.3.0",
|
||||
"version_normalized": "3.3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silexphp/Pimple.git",
|
||||
"reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32"
|
||||
"reference": "e55d12f9d6a0e7f9c85992b73df1267f46279930"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/silexphp/Pimple/zipball/9e403941ef9d65d20cba7d54e29fe906db42cf32",
|
||||
"reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32",
|
||||
"url": "https://api.github.com/repos/silexphp/Pimple/zipball/e55d12f9d6a0e7f9c85992b73df1267f46279930",
|
||||
"reference": "e55d12f9d6a0e7f9c85992b73df1267f46279930",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"php": "^7.2.5",
|
||||
"psr/container": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^3.2"
|
||||
"symfony/phpunit-bridge": "^3.4|^4.4|^5.0"
|
||||
},
|
||||
"time": "2018-01-21T07:42:36+00:00",
|
||||
"time": "2020-03-03T09:12:48+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.2.x-dev"
|
||||
"dev-master": "3.3.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
|
|
@ -311,7 +311,7 @@
|
|||
}
|
||||
],
|
||||
"description": "Pimple, a simple Dependency Injection Container",
|
||||
"homepage": "http://pimple.sensiolabs.org",
|
||||
"homepage": "https://pimple.symfony.com",
|
||||
"keywords": [
|
||||
"container",
|
||||
"dependency injection"
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
"php": ">=7.1 || ~8.0.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring" : "Massive performance enhancement of line folding"
|
||||
|
|
|
|||
|
|
@ -1,40 +1,17 @@
|
|||
language: php
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- PIMPLE_EXT=no
|
||||
- PIMPLE_EXT=yes
|
||||
global:
|
||||
- REPORT_EXIT_STATUS=1
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
- 7.4
|
||||
|
||||
before_script:
|
||||
- composer self-update
|
||||
- COMPOSER_ROOT_VERSION=dev-master composer install
|
||||
- if [ "$PIMPLE_EXT" == "yes" ]; then sh -c "cd ext/pimple && phpize && ./configure && make && sudo make install"; fi
|
||||
- if [ "$PIMPLE_EXT" == "yes" ]; then echo "extension=pimple.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi
|
||||
|
||||
script:
|
||||
- cd ext/pimple
|
||||
- if [ "$PIMPLE_EXT" == "yes" ]; then yes n | make test | tee output ; grep -E 'Tests failed +. +0' output; fi
|
||||
- if [ "$PIMPLE_EXT" == "yes" ]; then export SYMFONY_DEPRECATIONS_HELPER=weak; fi
|
||||
- cd ../..
|
||||
- ./vendor/bin/simple-phpunit
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: hhvm
|
||||
dist: trusty
|
||||
env: PIMPLE_EXT=no
|
||||
exclude:
|
||||
- php: 7.0
|
||||
env: PIMPLE_EXT=yes
|
||||
- php: 7.1
|
||||
env: PIMPLE_EXT=yes
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
* 3.2.3 (2017-XX-XX)
|
||||
* 3.3.0 (2020-03-03)
|
||||
|
||||
* n/a
|
||||
* Drop PHP extension
|
||||
* Bump min PHP version to 7.2.5
|
||||
|
||||
* 3.2.3 (2018-01-21)
|
||||
|
||||
* prefixed all function calls with \ for extra speed
|
||||
|
||||
* 3.2.2 (2017-07-23)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2009-2017 Fabien Potencier
|
||||
Copyright (c) 2009-2020 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"type": "library",
|
||||
"description": "Pimple, a simple Dependency Injection Container",
|
||||
"keywords": ["dependency injection", "container"],
|
||||
"homepage": "http://pimple.sensiolabs.org",
|
||||
"homepage": "https://pimple.symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
|
|
@ -12,18 +12,18 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"php": "^7.2.5",
|
||||
"psr/container": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^3.2"
|
||||
"symfony/phpunit-bridge": "^3.4|^4.4|^5.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Pimple": "src/" }
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.2.x-dev"
|
||||
"dev-master": "3.3.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
*.sw*
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.fragments
|
||||
Makefile.global
|
||||
Makefile.objects
|
||||
acinclude.m4
|
||||
aclocal.m4
|
||||
build/
|
||||
config.cache
|
||||
config.guess
|
||||
config.h
|
||||
config.h.in
|
||||
config.log
|
||||
config.nice
|
||||
config.status
|
||||
config.sub
|
||||
configure
|
||||
configure.in
|
||||
install-sh
|
||||
libtool
|
||||
ltmain.sh
|
||||
missing
|
||||
mkinstalldirs
|
||||
run-tests.php
|
||||
*.loT
|
||||
.libs/
|
||||
modules/
|
||||
*.la
|
||||
*.lo
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
This is Pimple 2 implemented in C
|
||||
|
||||
* PHP >= 5.3
|
||||
* Not tested under Windows, might work
|
||||
|
||||
Install
|
||||
=======
|
||||
|
||||
> phpize
|
||||
> ./configure
|
||||
> make
|
||||
> make install
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
dnl $Id$
|
||||
dnl config.m4 for extension pimple
|
||||
|
||||
dnl Comments in this file start with the string 'dnl'.
|
||||
dnl Remove where necessary. This file will not work
|
||||
dnl without editing.
|
||||
|
||||
dnl If your extension references something external, use with:
|
||||
|
||||
dnl PHP_ARG_WITH(pimple, for pimple support,
|
||||
dnl Make sure that the comment is aligned:
|
||||
dnl [ --with-pimple Include pimple support])
|
||||
|
||||
dnl Otherwise use enable:
|
||||
|
||||
PHP_ARG_ENABLE(pimple, whether to enable pimple support,
|
||||
dnl Make sure that the comment is aligned:
|
||||
[ --enable-pimple Enable pimple support])
|
||||
|
||||
if test "$PHP_PIMPLE" != "no"; then
|
||||
dnl Write more examples of tests here...
|
||||
|
||||
dnl # --with-pimple -> check with-path
|
||||
dnl SEARCH_PATH="/usr/local /usr" # you might want to change this
|
||||
dnl SEARCH_FOR="/include/pimple.h" # you most likely want to change this
|
||||
dnl if test -r $PHP_PIMPLE/$SEARCH_FOR; then # path given as parameter
|
||||
dnl PIMPLE_DIR=$PHP_PIMPLE
|
||||
dnl else # search default path list
|
||||
dnl AC_MSG_CHECKING([for pimple files in default path])
|
||||
dnl for i in $SEARCH_PATH ; do
|
||||
dnl if test -r $i/$SEARCH_FOR; then
|
||||
dnl PIMPLE_DIR=$i
|
||||
dnl AC_MSG_RESULT(found in $i)
|
||||
dnl fi
|
||||
dnl done
|
||||
dnl fi
|
||||
dnl
|
||||
dnl if test -z "$PIMPLE_DIR"; then
|
||||
dnl AC_MSG_RESULT([not found])
|
||||
dnl AC_MSG_ERROR([Please reinstall the pimple distribution])
|
||||
dnl fi
|
||||
|
||||
dnl # --with-pimple -> add include path
|
||||
dnl PHP_ADD_INCLUDE($PIMPLE_DIR/include)
|
||||
|
||||
dnl # --with-pimple -> check for lib and symbol presence
|
||||
dnl LIBNAME=pimple # you may want to change this
|
||||
dnl LIBSYMBOL=pimple # you most likely want to change this
|
||||
|
||||
dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
|
||||
dnl [
|
||||
dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $PIMPLE_DIR/lib, PIMPLE_SHARED_LIBADD)
|
||||
dnl AC_DEFINE(HAVE_PIMPLELIB,1,[ ])
|
||||
dnl ],[
|
||||
dnl AC_MSG_ERROR([wrong pimple lib version or lib not found])
|
||||
dnl ],[
|
||||
dnl -L$PIMPLE_DIR/lib -lm
|
||||
dnl ])
|
||||
dnl
|
||||
dnl PHP_SUBST(PIMPLE_SHARED_LIBADD)
|
||||
|
||||
PHP_NEW_EXTENSION(pimple, pimple.c, $ext_shared)
|
||||
fi
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
// $Id$
|
||||
// vim:ft=javascript
|
||||
|
||||
// If your extension references something external, use ARG_WITH
|
||||
// ARG_WITH("pimple", "for pimple support", "no");
|
||||
|
||||
// Otherwise, use ARG_ENABLE
|
||||
// ARG_ENABLE("pimple", "enable pimple support", "no");
|
||||
|
||||
if (PHP_PIMPLE != "no") {
|
||||
EXTENSION("pimple", "pimple.c");
|
||||
}
|
||||
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
|
||||
/*
|
||||
* This file is part of Pimple.
|
||||
*
|
||||
* Copyright (c) 2014 Fabien Potencier
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PHP_PIMPLE_H
|
||||
#define PHP_PIMPLE_H
|
||||
|
||||
extern zend_module_entry pimple_module_entry;
|
||||
#define phpext_pimple_ptr &pimple_module_entry
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
# define PHP_PIMPLE_API __declspec(dllexport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
# define PHP_PIMPLE_API __attribute__ ((visibility("default")))
|
||||
#else
|
||||
# define PHP_PIMPLE_API
|
||||
#endif
|
||||
|
||||
#ifdef ZTS
|
||||
#include "TSRM.h"
|
||||
#endif
|
||||
|
||||
#define PIMPLE_VERSION "3.2.3-DEV"
|
||||
|
||||
#define PIMPLE_NS "Pimple"
|
||||
#define PSR_CONTAINER_NS "Psr\\Container"
|
||||
#define PIMPLE_EXCEPTION_NS "Pimple\\Exception"
|
||||
|
||||
#define PIMPLE_DEFAULT_ZVAL_CACHE_NUM 5
|
||||
#define PIMPLE_DEFAULT_ZVAL_VALUES_NUM 10
|
||||
|
||||
#define PIMPLE_DEPRECATE do { \
|
||||
int er = EG(error_reporting); \
|
||||
EG(error_reporting) = 0;\
|
||||
php_error(E_DEPRECATED, "The Pimple C extension is deprecated since version 3.1 and will be removed in 4.0."); \
|
||||
EG(error_reporting) = er; \
|
||||
} while (0);
|
||||
|
||||
zend_module_entry *get_module(void);
|
||||
|
||||
PHP_MINIT_FUNCTION(pimple);
|
||||
PHP_MINFO_FUNCTION(pimple);
|
||||
|
||||
PHP_METHOD(FrozenServiceException, __construct);
|
||||
PHP_METHOD(InvalidServiceIdentifierException, __construct);
|
||||
PHP_METHOD(UnknownIdentifierException, __construct);
|
||||
|
||||
PHP_METHOD(Pimple, __construct);
|
||||
PHP_METHOD(Pimple, factory);
|
||||
PHP_METHOD(Pimple, protect);
|
||||
PHP_METHOD(Pimple, raw);
|
||||
PHP_METHOD(Pimple, extend);
|
||||
PHP_METHOD(Pimple, keys);
|
||||
PHP_METHOD(Pimple, register);
|
||||
PHP_METHOD(Pimple, offsetSet);
|
||||
PHP_METHOD(Pimple, offsetUnset);
|
||||
PHP_METHOD(Pimple, offsetGet);
|
||||
PHP_METHOD(Pimple, offsetExists);
|
||||
|
||||
PHP_METHOD(PimpleClosure, invoker);
|
||||
|
||||
typedef struct _pimple_bucket_value {
|
||||
zval *value; /* Must be the first element */
|
||||
zval *raw;
|
||||
zend_object_handle handle_num;
|
||||
enum {
|
||||
PIMPLE_IS_PARAM = 0,
|
||||
PIMPLE_IS_SERVICE = 2
|
||||
} type;
|
||||
zend_bool initialized;
|
||||
zend_fcall_info_cache fcc;
|
||||
} pimple_bucket_value;
|
||||
|
||||
typedef struct _pimple_object {
|
||||
zend_object zobj;
|
||||
HashTable values;
|
||||
HashTable factories;
|
||||
HashTable protected;
|
||||
} pimple_object;
|
||||
|
||||
typedef struct _pimple_closure_object {
|
||||
zend_object zobj;
|
||||
zval *callable;
|
||||
zval *factory;
|
||||
} pimple_closure_object;
|
||||
|
||||
static const char sensiolabs_logo[] = "<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHYAAAAUCAMAAABvRTlyAAAAz1BMVEUAAAAAAAAAAAAsThWB5j4AAACD6T8AAACC6D+C6D6C6D+C6D4AAAAAAACC6D4AAAAAAACC6D8AAAAAAAAAAAAAAAAAAAAAAACC6D4AAAAAAAAAAACC6D4AAAAAAAAAAAAAAAAAAAAAAACC6D8AAACC6D4AAAAAAAAAAAAAAAAAAACC6D8AAACC6D6C6D+B6D+C6D+C6D+C6D8AAACC6D6C6D4AAACC6D/K/2KC6D+B6D6C6D6C6D+C6D8sTxUyWRhEeiEAAACC6D+C5z6B6D7drnEVAAAAQXRSTlMAE3oCNSUuDHFHzxaF9UFsu+irX+zlKzYimaJXktyOSFD6BolxqT7QGMMdarMIpuO28r9EolXKgR16OphfXYd4V14GtB4AAAMpSURBVEjHvVSJctowEF1jjME2RziMwUCoMfd9heZqG4n//6buLpJjkmYm03byZmxJa2nf6u2uQcG2bfhqRN4LoTKBzyGDm68M7mAwcOEdjo4zhA/Rf9Go/CVtTgiRhXfIC3EDH8F/eUX1/9KexRo+QgOdtHDsEe/sM7QT32/+K61Z1LFXcXJxN4pTbu1aTQUzuy2PIA0rDo0/0Aa5XFaJvKaVTrubywXvaa1Wq4Vu/Snr3Y7Aojh4VccwykW2N2oQ8wmjyut6+Q1t5ywIG5Npj1sh5E0B7YOzFDjfuRfaOh3O+MbbVNfTWS9COZk3Obd2su5d0a6IU9KLREbw8gEehWSr1r2sPWciXLG38r5NdW0xu9eioU87omjC9yNaMi5GNf6WppVSOqXCFkmCvMB3p9SROLoYQn5pDgQOujA1xjYvqH+plUdkwnmII8VxR/PKYkrfLLomhVlE3b/LhNbNr7hp0H2JaOc4v8dFB58HSsFTSafaqtY1sT3GO8wsy5rhokYPlRJdjPMajyYqTt1EHF/2uqSWQWmAjCUSmQ1MS3g8Btf1XOsy7YIC0CB1b5Xw1Vhba0zbxiCAQLH9TNPmHJXQUtJAN0KcDsoqLxsNvJrJExa7mKIdp2lRE2WexiS4pqWk/0jROlw6K6bV9YOBDGAuqMJ0bnuUKGB0L27bxgRhGEbzihbhxxXaQC88Vkwq8ldCi86RApWUb0Q+4VDosBCc+1s81lUdnBavH4Zp2mm3O44USwOfvSo9oBiwpFg71lMS1VKJLKljS3j9p+fOTvXXlsSNuEv6YPaZda9uRope0VJfKdo7fPiYfSmvFjXQbkhY0d9hCbBWIktRgEDieDhf1N3wbbkmNNgRy8hyl620yGQat/grV3HMpc2HDKTVmOPFz6ylPCKt/nXcAyV260jaAowwIW0YuBzrOgb/KrddZS9OmJaLgpWK4JX2DDuklcLZSDGcn8Vmx9YDNvT6UsjyBApRyFQVX7Vxm9TGxE16nmfRd8/zQoDmggQOTRh5Hv8pMt9Q/L2JmSwkMCE7dA4BuDjHJwfu0Om4QAhOjrN5XkIatglfiN/bUPdCQFjTYgAAAABJRU5ErkJggg==\">";
|
||||
|
||||
static void pimple_exception_call_parent_constructor(zval *this_ptr, const char *format, const char *arg1 TSRMLS_DC);
|
||||
|
||||
static int pimple_zval_to_pimpleval(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC);
|
||||
static int pimple_zval_is_valid_callback(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC);
|
||||
|
||||
static void pimple_bucket_dtor(pimple_bucket_value *bucket);
|
||||
static void pimple_free_bucket(pimple_bucket_value *bucket);
|
||||
|
||||
static zval *pimple_object_read_dimension(zval *object, zval *offset, int type TSRMLS_DC);
|
||||
static void pimple_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC);
|
||||
static int pimple_object_has_dimension(zval *object, zval *offset, int check_empty TSRMLS_DC);
|
||||
static void pimple_object_unset_dimension(zval *object, zval *offset TSRMLS_DC);
|
||||
static zend_object_value pimple_object_create(zend_class_entry *ce TSRMLS_DC);
|
||||
static void pimple_free_object_storage(pimple_object *obj TSRMLS_DC);
|
||||
|
||||
static void pimple_closure_free_object_storage(pimple_closure_object *obj TSRMLS_DC);
|
||||
static zend_object_value pimple_closure_object_create(zend_class_entry *ce TSRMLS_DC);
|
||||
static zend_function *pimple_closure_get_constructor(zval * TSRMLS_DC);
|
||||
static int pimple_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zval **zobj_ptr TSRMLS_DC);
|
||||
|
||||
#ifdef ZTS
|
||||
#define PIMPLE_G(v) TSRMG(pimple_globals_id, zend_pimple_globals *, v)
|
||||
#else
|
||||
#define PIMPLE_G(v) (pimple_globals.v)
|
||||
#endif
|
||||
|
||||
#endif /* PHP_PIMPLE_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,81 +0,0 @@
|
|||
|
||||
/*
|
||||
* This file is part of Pimple.
|
||||
*
|
||||
* Copyright (c) 2014 Fabien Potencier
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PIMPLE_COMPAT_H_
|
||||
#define PIMPLE_COMPAT_H_
|
||||
|
||||
#include "Zend/zend_extensions.h" /* for ZEND_EXTENSION_API_NO */
|
||||
|
||||
#define PHP_5_0_X_API_NO 220040412
|
||||
#define PHP_5_1_X_API_NO 220051025
|
||||
#define PHP_5_2_X_API_NO 220060519
|
||||
#define PHP_5_3_X_API_NO 220090626
|
||||
#define PHP_5_4_X_API_NO 220100525
|
||||
#define PHP_5_5_X_API_NO 220121212
|
||||
#define PHP_5_6_X_API_NO 220131226
|
||||
|
||||
#define IS_PHP_56 ZEND_EXTENSION_API_NO == PHP_5_6_X_API_NO
|
||||
#define IS_AT_LEAST_PHP_56 ZEND_EXTENSION_API_NO >= PHP_5_6_X_API_NO
|
||||
|
||||
#define IS_PHP_55 ZEND_EXTENSION_API_NO == PHP_5_5_X_API_NO
|
||||
#define IS_AT_LEAST_PHP_55 ZEND_EXTENSION_API_NO >= PHP_5_5_X_API_NO
|
||||
|
||||
#define IS_PHP_54 ZEND_EXTENSION_API_NO == PHP_5_4_X_API_NO
|
||||
#define IS_AT_LEAST_PHP_54 ZEND_EXTENSION_API_NO >= PHP_5_4_X_API_NO
|
||||
|
||||
#define IS_PHP_53 ZEND_EXTENSION_API_NO == PHP_5_3_X_API_NO
|
||||
#define IS_AT_LEAST_PHP_53 ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO
|
||||
|
||||
#if IS_PHP_53
|
||||
#define object_properties_init(obj, ce) do { \
|
||||
zend_hash_copy(obj->properties, &ce->default_properties, zval_copy_property_ctor(ce), NULL, sizeof(zval *)); \
|
||||
} while (0);
|
||||
#endif
|
||||
|
||||
#define ZEND_OBJ_INIT(obj, ce) do { \
|
||||
zend_object_std_init(obj, ce TSRMLS_CC); \
|
||||
object_properties_init((obj), (ce)); \
|
||||
} while(0);
|
||||
|
||||
#if IS_PHP_53 || IS_PHP_54
|
||||
static void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos) {
|
||||
Bucket *p;
|
||||
|
||||
p = pos ? (*pos) : ht->pInternalPointer;
|
||||
|
||||
if (!p) {
|
||||
Z_TYPE_P(key) = IS_NULL;
|
||||
} else if (p->nKeyLength) {
|
||||
Z_TYPE_P(key) = IS_STRING;
|
||||
Z_STRVAL_P(key) = estrndup(p->arKey, p->nKeyLength - 1);
|
||||
Z_STRLEN_P(key) = p->nKeyLength - 1;
|
||||
} else {
|
||||
Z_TYPE_P(key) = IS_LONG;
|
||||
Z_LVAL_P(key) = p->h;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PIMPLE_COMPAT_H_ */
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
--TEST--
|
||||
Test for read_dim/write_dim handlers
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$p = new Pimple\Container();
|
||||
$p[42] = 'foo';
|
||||
$p['foo'] = 42;
|
||||
|
||||
echo $p[42];
|
||||
echo "\n";
|
||||
echo $p['foo'];
|
||||
echo "\n";
|
||||
try {
|
||||
var_dump($p['nonexistant']);
|
||||
echo "Exception excpected";
|
||||
} catch (InvalidArgumentException $e) { }
|
||||
|
||||
$p[54.2] = 'foo2';
|
||||
echo $p[54];
|
||||
echo "\n";
|
||||
$p[242.99] = 'foo99';
|
||||
echo $p[242];
|
||||
|
||||
echo "\n";
|
||||
|
||||
$p[5] = 'bar';
|
||||
$p[5] = 'baz';
|
||||
echo $p[5];
|
||||
|
||||
echo "\n";
|
||||
|
||||
$p['str'] = 'str';
|
||||
$p['str'] = 'strstr';
|
||||
echo $p['str'];
|
||||
?>
|
||||
|
||||
--EXPECTF--
|
||||
foo
|
||||
42
|
||||
foo2
|
||||
foo99
|
||||
baz
|
||||
strstr
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
--TEST--
|
||||
Test for constructor
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$p = new Pimple\Container();
|
||||
var_dump($p[42]);
|
||||
|
||||
$p = new Pimple\Container(array(42=>'foo'));
|
||||
var_dump($p[42]);
|
||||
?>
|
||||
--EXPECT--
|
||||
NULL
|
||||
string(3) "foo"
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
--TEST--
|
||||
Test empty dimensions
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$p = new Pimple\Container();
|
||||
$p[] = 42;
|
||||
var_dump($p[0]);
|
||||
$p[41] = 'foo';
|
||||
$p[] = 'bar';
|
||||
var_dump($p[42]);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(42)
|
||||
string(3) "bar"
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
--TEST--
|
||||
Test has/unset dim handlers
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$p = new Pimple\Container();
|
||||
$p[] = 42;
|
||||
var_dump($p[0]);
|
||||
unset($p[0]);
|
||||
var_dump($p[0]);
|
||||
$p['foo'] = 'bar';
|
||||
var_dump(isset($p['foo']));
|
||||
unset($p['foo']);
|
||||
try {
|
||||
var_dump($p['foo']);
|
||||
echo "Excpected exception";
|
||||
} catch (InvalidArgumentException $e) { }
|
||||
var_dump(isset($p['bar']));
|
||||
$p['bar'] = NULL;
|
||||
var_dump(isset($p['bar']));
|
||||
var_dump(empty($p['bar']));
|
||||
?>
|
||||
--EXPECT--
|
||||
int(42)
|
||||
NULL
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(true)
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
--TEST--
|
||||
Test simple class inheritance
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
class MyPimple extends Pimple\Container
|
||||
{
|
||||
public $someAttr = 'fooAttr';
|
||||
|
||||
public function offsetget($o)
|
||||
{
|
||||
var_dump("hit");
|
||||
return parent::offsetget($o);
|
||||
}
|
||||
}
|
||||
|
||||
$p = new MyPimple;
|
||||
$p[42] = 'foo';
|
||||
echo $p[42];
|
||||
echo "\n";
|
||||
echo $p->someAttr;
|
||||
?>
|
||||
--EXPECT--
|
||||
string(3) "hit"
|
||||
foo
|
||||
fooAttr
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
--TEST--
|
||||
Test complex class inheritance
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
class MyPimple extends Pimple\Container
|
||||
{
|
||||
public function offsetget($o)
|
||||
{
|
||||
var_dump("hit offsetget in " . __CLASS__);
|
||||
return parent::offsetget($o);
|
||||
}
|
||||
}
|
||||
|
||||
class TestPimple extends MyPimple
|
||||
{
|
||||
public function __construct($values)
|
||||
{
|
||||
array_shift($values);
|
||||
parent::__construct($values);
|
||||
}
|
||||
|
||||
public function offsetget($o)
|
||||
{
|
||||
var_dump('hit offsetget in ' . __CLASS__);
|
||||
return parent::offsetget($o);
|
||||
}
|
||||
|
||||
public function offsetset($o, $v)
|
||||
{
|
||||
var_dump('hit offsetset');
|
||||
return parent::offsetset($o, $v);
|
||||
}
|
||||
}
|
||||
|
||||
$defaultValues = array('foo' => 'bar', 88 => 'baz');
|
||||
|
||||
$p = new TestPimple($defaultValues);
|
||||
$p[42] = 'foo';
|
||||
var_dump($p[42]);
|
||||
var_dump($p[0]);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(13) "hit offsetset"
|
||||
string(27) "hit offsetget in TestPimple"
|
||||
string(25) "hit offsetget in MyPimple"
|
||||
string(3) "foo"
|
||||
string(27) "hit offsetget in TestPimple"
|
||||
string(25) "hit offsetget in MyPimple"
|
||||
string(3) "baz"
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
--TEST--
|
||||
Test for read_dim/write_dim handlers
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$p = new Pimple\Container();
|
||||
$p[42] = 'foo';
|
||||
$p['foo'] = 42;
|
||||
|
||||
echo $p[42];
|
||||
echo "\n";
|
||||
echo $p['foo'];
|
||||
echo "\n";
|
||||
try {
|
||||
var_dump($p['nonexistant']);
|
||||
echo "Exception excpected";
|
||||
} catch (InvalidArgumentException $e) { }
|
||||
?>
|
||||
--EXPECTF--
|
||||
foo
|
||||
42
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
--TEST--
|
||||
Test frozen services
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$p = new Pimple\Container();
|
||||
$p[42] = 'foo';
|
||||
$p[42] = 'bar';
|
||||
|
||||
$p['foo'] = function () { };
|
||||
$p['foo'] = function () { };
|
||||
|
||||
$a = $p['foo'];
|
||||
|
||||
try {
|
||||
$p['foo'] = function () { };
|
||||
echo "Exception excpected";
|
||||
} catch (RuntimeException $e) { }
|
||||
|
||||
$p[42] = function() { };
|
||||
$a = $p[42];
|
||||
|
||||
try {
|
||||
$p[42] = function () { };
|
||||
echo "Exception excpected";
|
||||
} catch (RuntimeException $e) { }
|
||||
?>
|
||||
--EXPECTF--
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
--TEST--
|
||||
Test service is called as callback, and only once
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$p = new Pimple\Container();
|
||||
$p['foo'] = function($arg) use ($p) { var_dump($p === $arg); };
|
||||
$a = $p['foo'];
|
||||
$b = $p['foo']; /* should return not calling the callback */
|
||||
?>
|
||||
--EXPECTF--
|
||||
bool(true)
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
--TEST--
|
||||
Test service is called as callback for every callback type
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
function callme()
|
||||
{
|
||||
return 'called';
|
||||
}
|
||||
|
||||
$a = function() { return 'called'; };
|
||||
|
||||
class Foo
|
||||
{
|
||||
public static function bar()
|
||||
{
|
||||
return 'called';
|
||||
}
|
||||
}
|
||||
|
||||
$p = new Pimple\Container();
|
||||
$p['foo'] = 'callme';
|
||||
echo $p['foo'] . "\n";
|
||||
|
||||
$p['bar'] = $a;
|
||||
echo $p['bar'] . "\n";
|
||||
|
||||
$p['baz'] = "Foo::bar";
|
||||
echo $p['baz'] . "\n";
|
||||
|
||||
$p['foobar'] = array('Foo', 'bar');
|
||||
var_dump($p['foobar']);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
callme
|
||||
called
|
||||
Foo::bar
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(3) "Foo"
|
||||
[1]=>
|
||||
string(3) "bar"
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
--TEST--
|
||||
Test service callback throwing an exception
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
class CallBackException extends RuntimeException { }
|
||||
|
||||
$p = new Pimple\Container();
|
||||
$p['foo'] = function () { throw new CallBackException; };
|
||||
try {
|
||||
echo $p['foo'] . "\n";
|
||||
echo "should not come here";
|
||||
} catch (CallBackException $e) {
|
||||
echo "all right!";
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
all right!
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
--TEST--
|
||||
Test service factory
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$p = new Pimple\Container();
|
||||
|
||||
$p->factory($f = function() { var_dump('called-1'); return 'ret-1';});
|
||||
|
||||
$p[] = $f;
|
||||
|
||||
$p[] = function () { var_dump('called-2'); return 'ret-2'; };
|
||||
|
||||
var_dump($p[0]);
|
||||
var_dump($p[0]);
|
||||
var_dump($p[1]);
|
||||
var_dump($p[1]);
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(8) "called-1"
|
||||
string(5) "ret-1"
|
||||
string(8) "called-1"
|
||||
string(5) "ret-1"
|
||||
string(8) "called-2"
|
||||
string(5) "ret-2"
|
||||
string(5) "ret-2"
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
--TEST--
|
||||
Test keys()
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$p = new Pimple\Container();
|
||||
|
||||
var_dump($p->keys());
|
||||
|
||||
$p['foo'] = 'bar';
|
||||
$p[] = 'foo';
|
||||
|
||||
var_dump($p->keys());
|
||||
|
||||
unset($p['foo']);
|
||||
|
||||
var_dump($p->keys());
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(0) {
|
||||
}
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(3) "foo"
|
||||
[1]=>
|
||||
int(0)
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(0)
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
--TEST--
|
||||
Test raw()
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$p = new Pimple\Container();
|
||||
$f = function () { var_dump('called-2'); return 'ret-2'; };
|
||||
|
||||
$p['foo'] = $f;
|
||||
$p[42] = $f;
|
||||
|
||||
var_dump($p['foo']);
|
||||
var_dump($p->raw('foo'));
|
||||
var_dump($p[42]);
|
||||
|
||||
unset($p['foo']);
|
||||
|
||||
try {
|
||||
$p->raw('foo');
|
||||
echo "expected exception";
|
||||
} catch (InvalidArgumentException $e) { }
|
||||
--EXPECTF--
|
||||
string(8) "called-2"
|
||||
string(5) "ret-2"
|
||||
object(Closure)#%i (0) {
|
||||
}
|
||||
string(8) "called-2"
|
||||
string(5) "ret-2"
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
--TEST--
|
||||
Test protect()
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$p = new Pimple\Container();
|
||||
$f = function () { return 'foo'; };
|
||||
$p['foo'] = $f;
|
||||
|
||||
$p->protect($f);
|
||||
|
||||
var_dump($p['foo']);
|
||||
--EXPECTF--
|
||||
object(Closure)#%i (0) {
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
--TEST--
|
||||
Test extend()
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
/*
|
||||
This is part of Pimple::extend() code :
|
||||
|
||||
$extended = function ($c) use ($callable, $factory) {
|
||||
return $callable($factory($c), $c);
|
||||
};
|
||||
*/
|
||||
|
||||
$p = new Pimple\Container();
|
||||
$p[12] = function ($v) { var_dump($v); return 'foo';}; /* $factory in code above */
|
||||
|
||||
$c = $p->extend(12, function ($w) { var_dump($w); return 'bar'; }); /* $callable in code above */
|
||||
|
||||
var_dump($c('param'));
|
||||
--EXPECTF--
|
||||
string(5) "param"
|
||||
string(3) "foo"
|
||||
string(3) "bar"
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
--TEST--
|
||||
Test extend() with exception in service extension
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$p = new Pimple\Container();
|
||||
$p[12] = function ($v) { return 'foo';};
|
||||
|
||||
$c = $p->extend(12, function ($w) { throw new BadMethodCallException; });
|
||||
|
||||
try {
|
||||
$p[12];
|
||||
echo "Exception expected";
|
||||
} catch (BadMethodCallException $e) { }
|
||||
--EXPECTF--
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
--TEST--
|
||||
Test extend() with exception in service factory
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$p = new Pimple\Container();
|
||||
$p[12] = function ($v) { throw new BadMethodCallException; };
|
||||
|
||||
$c = $p->extend(12, function ($w) { return 'foobar'; });
|
||||
|
||||
try {
|
||||
$p[12];
|
||||
echo "Exception expected";
|
||||
} catch (BadMethodCallException $e) { }
|
||||
--EXPECTF--
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
--TEST--
|
||||
Test register()
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class Foo implements Pimple\ServiceProviderInterface
|
||||
{
|
||||
public function register(Pimple\Container $p)
|
||||
{
|
||||
var_dump($p);
|
||||
}
|
||||
}
|
||||
|
||||
$p = new Pimple\Container();
|
||||
$p->register(new Foo, array(42 => 'bar'));
|
||||
|
||||
var_dump($p[42]);
|
||||
--EXPECTF--
|
||||
object(Pimple\Container)#1 (0) {
|
||||
}
|
||||
string(3) "bar"
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
--TEST--
|
||||
Test register() returns static and is a fluent interface
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("pimple")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class Foo implements Pimple\ServiceProviderInterface
|
||||
{
|
||||
public function register(Pimple\Container $p)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
$p = new Pimple\Container();
|
||||
var_dump($p === $p->register(new Foo));
|
||||
--EXPECTF--
|
||||
bool(true)
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
if (!class_exists('Pimple\Container')) {
|
||||
require_once __DIR__ . '/../../../src/Pimple/Container.php';
|
||||
} else {
|
||||
echo "pimple-c extension detected, using...\n\n";
|
||||
}
|
||||
|
||||
$time = microtime(true);
|
||||
|
||||
function foo() { }
|
||||
$factory = function () { };
|
||||
|
||||
for ($i=0; $i<10000; $i++) {
|
||||
|
||||
$p = new Pimple\Container;
|
||||
|
||||
$p['foo'] = 'bar';
|
||||
|
||||
if (!isset($p[3])) {
|
||||
$p[3] = $p['foo'];
|
||||
$p[] = 'bar';
|
||||
}
|
||||
|
||||
$p[2] = 42;
|
||||
|
||||
if (isset($p[2])) {
|
||||
unset($p[2]);
|
||||
}
|
||||
|
||||
$p[42] = $p['foo'];
|
||||
|
||||
$p['cb'] = function($arg) { };
|
||||
|
||||
$p[] = $p['cb'];
|
||||
|
||||
echo $p['cb'];
|
||||
echo $p['cb'];
|
||||
echo $p['cb'];
|
||||
|
||||
//$p->factory($factory);
|
||||
|
||||
$p['factory'] = $factory;
|
||||
|
||||
echo $p['factory'];
|
||||
echo $p['factory'];
|
||||
echo $p['factory'];
|
||||
|
||||
}
|
||||
|
||||
echo microtime(true) - $time;
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
if (!class_exists('Pimple\Container')) {
|
||||
require_once __DIR__ . '/../../../src/Pimple/Container.php';
|
||||
} else {
|
||||
echo "pimple-c extension detected, using...\n\n";
|
||||
}
|
||||
|
||||
$time = microtime(true);
|
||||
|
||||
|
||||
$service = function ($arg) { return "I'm a service"; };
|
||||
|
||||
for ($i=0; $i<10000; $i++) {
|
||||
|
||||
$p = new Pimple\Container;
|
||||
$p['my_service'] = $service;
|
||||
|
||||
$a = $p['my_service'];
|
||||
$b = $p['my_service'];
|
||||
|
||||
}
|
||||
|
||||
echo microtime(true) - $time;
|
||||
?>
|
||||
|
|
@ -11,4 +11,8 @@
|
|||
<directory>./src/Pimple/Tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<listeners>
|
||||
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
|
||||
</listeners>
|
||||
</phpunit>
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ use Pimple\Exception\UnknownIdentifierException;
|
|||
*/
|
||||
class Container implements \ArrayAccess
|
||||
{
|
||||
private $values = array();
|
||||
private $values = [];
|
||||
private $factories;
|
||||
private $protected;
|
||||
private $frozen = array();
|
||||
private $raw = array();
|
||||
private $keys = array();
|
||||
private $frozen = [];
|
||||
private $raw = [];
|
||||
private $keys = [];
|
||||
|
||||
/**
|
||||
* Instantiates the container.
|
||||
|
|
@ -52,7 +52,7 @@ class Container implements \ArrayAccess
|
|||
*
|
||||
* @param array $values The parameters or objects
|
||||
*/
|
||||
public function __construct(array $values = array())
|
||||
public function __construct(array $values = [])
|
||||
{
|
||||
$this->factories = new \SplObjectStorage();
|
||||
$this->protected = new \SplObjectStorage();
|
||||
|
|
@ -246,7 +246,7 @@ class Container implements \ArrayAccess
|
|||
}
|
||||
|
||||
if (isset($this->protected[$this->values[$id]])) {
|
||||
@\trigger_error(\sprintf('How Pimple behaves when extending protected closures will be fixed in Pimple 4. Are you sure "%s" should be protected?', $id), \E_USER_DEPRECATED);
|
||||
@\trigger_error(\sprintf('How Pimple behaves when extending protected closures will be fixed in Pimple 4. Are you sure "%s" should be protected?', $id), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if (!\is_object($callable) || !\method_exists($callable, '__invoke')) {
|
||||
|
|
@ -285,7 +285,7 @@ class Container implements \ArrayAccess
|
|||
*
|
||||
* @return static
|
||||
*/
|
||||
public function register(ServiceProviderInterface $provider, array $values = array())
|
||||
public function register(ServiceProviderInterface $provider, array $values = [])
|
||||
{
|
||||
$provider->register($this);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ use Psr\Container\ContainerInterface;
|
|||
class ServiceLocator implements ContainerInterface
|
||||
{
|
||||
private $container;
|
||||
private $aliases = array();
|
||||
private $aliases = [];
|
||||
|
||||
/**
|
||||
* @param PimpleContainer $container The Container instance used to locate services
|
||||
|
|
|
|||
|
|
@ -26,12 +26,13 @@
|
|||
|
||||
namespace Pimple\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Pimple\Container;
|
||||
|
||||
/**
|
||||
* @author Dominik Zogg <dominik.zogg@gmail.com>
|
||||
* @author Dominik Zogg <dominik.zogg@gmail.com>
|
||||
*/
|
||||
class PimpleServiceProviderInterfaceTest extends \PHPUnit_Framework_TestCase
|
||||
class PimpleServiceProviderInterfaceTest extends TestCase
|
||||
{
|
||||
public function testProvider()
|
||||
{
|
||||
|
|
@ -56,9 +57,9 @@ class PimpleServiceProviderInterfaceTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$pimple = new Container();
|
||||
|
||||
$pimple->register(new Fixtures\PimpleServiceProvider(), array(
|
||||
$pimple->register(new Fixtures\PimpleServiceProvider(), [
|
||||
'anotherParameter' => 'anotherValue',
|
||||
));
|
||||
]);
|
||||
|
||||
$this->assertEquals('value', $pimple['param']);
|
||||
$this->assertEquals('anotherValue', $pimple['anotherParameter']);
|
||||
|
|
|
|||
|
|
@ -26,12 +26,13 @@
|
|||
|
||||
namespace Pimple\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Pimple\Container;
|
||||
|
||||
/**
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*/
|
||||
class PimpleTest extends \PHPUnit_Framework_TestCase
|
||||
class PimpleTest extends TestCase
|
||||
{
|
||||
public function testWithString()
|
||||
{
|
||||
|
|
@ -99,29 +100,29 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testConstructorInjection()
|
||||
{
|
||||
$params = array('param' => 'value');
|
||||
$params = ['param' => 'value'];
|
||||
$pimple = new Container($params);
|
||||
|
||||
$this->assertSame($params['param'], $pimple['param']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Pimple\Exception\UnknownIdentifierException
|
||||
* @expectedExceptionMessage Identifier "foo" is not defined.
|
||||
*/
|
||||
public function testOffsetGetValidatesKeyIsPresent()
|
||||
{
|
||||
$this->expectException(\Pimple\Exception\UnknownIdentifierException::class);
|
||||
$this->expectExceptionMessage('Identifier "foo" is not defined.');
|
||||
|
||||
$pimple = new Container();
|
||||
echo $pimple['foo'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Identifier "foo" is not defined.
|
||||
*/
|
||||
public function testLegacyOffsetGetValidatesKeyIsPresent()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Identifier "foo" is not defined.');
|
||||
|
||||
$pimple = new Container();
|
||||
echo $pimple['foo'];
|
||||
}
|
||||
|
|
@ -184,7 +185,9 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
public function testRaw()
|
||||
{
|
||||
$pimple = new Container();
|
||||
$pimple['service'] = $definition = $pimple->factory(function () { return 'foo'; });
|
||||
$pimple['service'] = $definition = $pimple->factory(function () {
|
||||
return 'foo';
|
||||
});
|
||||
$this->assertSame($definition, $pimple->raw('service'));
|
||||
}
|
||||
|
||||
|
|
@ -201,23 +204,23 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertSame($pimple, $pimple->register($this->getMockBuilder('Pimple\ServiceProviderInterface')->getMock()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Pimple\Exception\UnknownIdentifierException
|
||||
* @expectedExceptionMessage Identifier "foo" is not defined.
|
||||
*/
|
||||
public function testRawValidatesKeyIsPresent()
|
||||
{
|
||||
$this->expectException(\Pimple\Exception\UnknownIdentifierException::class);
|
||||
$this->expectExceptionMessage('Identifier "foo" is not defined.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple->raw('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Identifier "foo" is not defined.
|
||||
*/
|
||||
public function testLegacyRawValidatesKeyIsPresent()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Identifier "foo" is not defined.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple->raw('foo');
|
||||
}
|
||||
|
|
@ -254,13 +257,17 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testExtendDoesNotLeakWithFactories()
|
||||
{
|
||||
if (extension_loaded('pimple')) {
|
||||
if (\extension_loaded('pimple')) {
|
||||
$this->markTestSkipped('Pimple extension does not support this test');
|
||||
}
|
||||
$pimple = new Container();
|
||||
|
||||
$pimple['foo'] = $pimple->factory(function () { return; });
|
||||
$pimple['foo'] = $pimple->extend('foo', function ($foo, $pimple) { return; });
|
||||
$pimple['foo'] = $pimple->factory(function () {
|
||||
return;
|
||||
});
|
||||
$pimple['foo'] = $pimple->extend('foo', function ($foo, $pimple) {
|
||||
return;
|
||||
});
|
||||
unset($pimple['foo']);
|
||||
|
||||
$p = new \ReflectionProperty($pimple, 'values');
|
||||
|
|
@ -272,25 +279,27 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertCount(0, $p->getValue($pimple));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Pimple\Exception\UnknownIdentifierException
|
||||
* @expectedExceptionMessage Identifier "foo" is not defined.
|
||||
*/
|
||||
public function testExtendValidatesKeyIsPresent()
|
||||
{
|
||||
$this->expectException(\Pimple\Exception\UnknownIdentifierException::class);
|
||||
$this->expectExceptionMessage('Identifier "foo" is not defined.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple->extend('foo', function () {});
|
||||
$pimple->extend('foo', function () {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Identifier "foo" is not defined.
|
||||
*/
|
||||
public function testLegacyExtendValidatesKeyIsPresent()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Identifier "foo" is not defined.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple->extend('foo', function () {});
|
||||
$pimple->extend('foo', function () {
|
||||
});
|
||||
}
|
||||
|
||||
public function testKeys()
|
||||
|
|
@ -299,7 +308,7 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
$pimple['foo'] = 123;
|
||||
$pimple['bar'] = 123;
|
||||
|
||||
$this->assertEquals(array('foo', 'bar'), $pimple->keys());
|
||||
$this->assertEquals(['foo', 'bar'], $pimple->keys());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
|
@ -322,11 +331,12 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
/**
|
||||
* @dataProvider badServiceDefinitionProvider
|
||||
* @expectedException \Pimple\Exception\ExpectedInvokableException
|
||||
* @expectedExceptionMessage Service definition is not a Closure or invokable object.
|
||||
*/
|
||||
public function testFactoryFailsForInvalidServiceDefinitions($service)
|
||||
{
|
||||
$this->expectException(\Pimple\Exception\ExpectedInvokableException::class);
|
||||
$this->expectExceptionMessage('Service definition is not a Closure or invokable object.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple->factory($service);
|
||||
}
|
||||
|
|
@ -334,22 +344,24 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* @group legacy
|
||||
* @dataProvider badServiceDefinitionProvider
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Service definition is not a Closure or invokable object.
|
||||
*/
|
||||
public function testLegacyFactoryFailsForInvalidServiceDefinitions($service)
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Service definition is not a Closure or invokable object.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple->factory($service);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider badServiceDefinitionProvider
|
||||
* @expectedException \Pimple\Exception\ExpectedInvokableException
|
||||
* @expectedExceptionMessage Callable is not a Closure or invokable object.
|
||||
*/
|
||||
public function testProtectFailsForInvalidServiceDefinitions($service)
|
||||
{
|
||||
$this->expectException(\Pimple\Exception\ExpectedInvokableException::class);
|
||||
$this->expectExceptionMessage('Callable is not a Closure or invokable object.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple->protect($service);
|
||||
}
|
||||
|
|
@ -357,38 +369,43 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* @group legacy
|
||||
* @dataProvider badServiceDefinitionProvider
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Callable is not a Closure or invokable object.
|
||||
*/
|
||||
public function testLegacyProtectFailsForInvalidServiceDefinitions($service)
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Callable is not a Closure or invokable object.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple->protect($service);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider badServiceDefinitionProvider
|
||||
* @expectedException \Pimple\Exception\InvalidServiceIdentifierException
|
||||
* @expectedExceptionMessage Identifier "foo" does not contain an object definition.
|
||||
*/
|
||||
public function testExtendFailsForKeysNotContainingServiceDefinitions($service)
|
||||
{
|
||||
$this->expectException(\Pimple\Exception\InvalidServiceIdentifierException::class);
|
||||
$this->expectExceptionMessage('Identifier "foo" does not contain an object definition.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple['foo'] = $service;
|
||||
$pimple->extend('foo', function () {});
|
||||
$pimple->extend('foo', function () {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider badServiceDefinitionProvider
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Identifier "foo" does not contain an object definition.
|
||||
*/
|
||||
public function testLegacyExtendFailsForKeysNotContainingServiceDefinitions($service)
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Identifier "foo" does not contain an object definition.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple['foo'] = $service;
|
||||
$pimple->extend('foo', function () {});
|
||||
$pimple->extend('foo', function () {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -411,57 +428,61 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
/**
|
||||
* @dataProvider badServiceDefinitionProvider
|
||||
* @expectedException \Pimple\Exception\ExpectedInvokableException
|
||||
* @expectedExceptionMessage Extension service definition is not a Closure or invokable object.
|
||||
*/
|
||||
public function testExtendFailsForInvalidServiceDefinitions($service)
|
||||
{
|
||||
$this->expectException(\Pimple\Exception\ExpectedInvokableException::class);
|
||||
$this->expectExceptionMessage('Extension service definition is not a Closure or invokable object.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple['foo'] = function () {};
|
||||
$pimple['foo'] = function () {
|
||||
};
|
||||
$pimple->extend('foo', $service);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @dataProvider badServiceDefinitionProvider
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Extension service definition is not a Closure or invokable object.
|
||||
*/
|
||||
public function testLegacyExtendFailsForInvalidServiceDefinitions($service)
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Extension service definition is not a Closure or invokable object.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple['foo'] = function () {};
|
||||
$pimple['foo'] = function () {
|
||||
};
|
||||
$pimple->extend('foo', $service);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Pimple\Exception\FrozenServiceException
|
||||
* @expectedExceptionMessage Cannot override frozen service "foo".
|
||||
*/
|
||||
public function testExtendFailsIfFrozenServiceIsNonInvokable()
|
||||
{
|
||||
$this->expectException(\Pimple\Exception\FrozenServiceException::class);
|
||||
$this->expectExceptionMessage('Cannot override frozen service "foo".');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple['foo'] = function () {
|
||||
return new Fixtures\NonInvokable();
|
||||
};
|
||||
$foo = $pimple['foo'];
|
||||
|
||||
$pimple->extend('foo', function () {});
|
||||
$pimple->extend('foo', function () {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Pimple\Exception\FrozenServiceException
|
||||
* @expectedExceptionMessage Cannot override frozen service "foo".
|
||||
*/
|
||||
public function testExtendFailsIfFrozenServiceIsInvokable()
|
||||
{
|
||||
$this->expectException(\Pimple\Exception\FrozenServiceException::class);
|
||||
$this->expectExceptionMessage('Cannot override frozen service "foo".');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple['foo'] = function () {
|
||||
return new Fixtures\Invokable();
|
||||
};
|
||||
$foo = $pimple['foo'];
|
||||
|
||||
$pimple->extend('foo', function () {});
|
||||
$pimple->extend('foo', function () {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -469,10 +490,10 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function badServiceDefinitionProvider()
|
||||
{
|
||||
return array(
|
||||
array(123),
|
||||
array(new Fixtures\NonInvokable()),
|
||||
);
|
||||
return [
|
||||
[123],
|
||||
[new Fixtures\NonInvokable()],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -480,15 +501,15 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function serviceDefinitionProvider()
|
||||
{
|
||||
return array(
|
||||
array(function ($value) {
|
||||
return [
|
||||
[function ($value) {
|
||||
$service = new Fixtures\Service();
|
||||
$service->value = $value;
|
||||
|
||||
return $service;
|
||||
}),
|
||||
array(new Fixtures\Invokable()),
|
||||
);
|
||||
}],
|
||||
[new Fixtures\Invokable()],
|
||||
];
|
||||
}
|
||||
|
||||
public function testDefiningNewServiceAfterFreeze()
|
||||
|
|
@ -505,12 +526,11 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertSame('bar', $pimple['bar']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Pimple\Exception\FrozenServiceException
|
||||
* @expectedExceptionMessage Cannot override frozen service "foo".
|
||||
*/
|
||||
public function testOverridingServiceAfterFreeze()
|
||||
{
|
||||
$this->expectException(\Pimple\Exception\FrozenServiceException::class);
|
||||
$this->expectExceptionMessage('Cannot override frozen service "foo".');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple['foo'] = function () {
|
||||
return 'foo';
|
||||
|
|
@ -524,11 +544,12 @@ class PimpleTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage Cannot override frozen service "foo".
|
||||
*/
|
||||
public function testLegacyOverridingServiceAfterFreeze()
|
||||
{
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessage('Cannot override frozen service "foo".');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple['foo'] = function () {
|
||||
return 'foo';
|
||||
|
|
|
|||
|
|
@ -44,12 +44,11 @@ class ContainerTest extends TestCase
|
|||
$this->assertSame($pimple['service'], $psr->get('service'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Psr\Container\NotFoundExceptionInterface
|
||||
* @expectedExceptionMessage Identifier "service" is not defined.
|
||||
*/
|
||||
public function testGetThrowsExceptionIfServiceIsNotFound()
|
||||
{
|
||||
$this->expectException(\Psr\Container\NotFoundExceptionInterface::class);
|
||||
$this->expectExceptionMessage('Identifier "service" is not defined.');
|
||||
|
||||
$pimple = new Container();
|
||||
$psr = new PsrContainer($pimple);
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class ServiceLocatorTest extends TestCase
|
|||
$pimple['service'] = function () {
|
||||
return new Fixtures\Service();
|
||||
};
|
||||
$locator = new ServiceLocator($pimple, array('service'));
|
||||
$locator = new ServiceLocator($pimple, ['service']);
|
||||
|
||||
$this->assertSame($pimple['service'], $locator->get('service'));
|
||||
}
|
||||
|
|
@ -55,52 +55,49 @@ class ServiceLocatorTest extends TestCase
|
|||
$pimple['service'] = function () {
|
||||
return new Fixtures\Service();
|
||||
};
|
||||
$locator = new ServiceLocator($pimple, array('alias' => 'service'));
|
||||
$locator = new ServiceLocator($pimple, ['alias' => 'service']);
|
||||
|
||||
$this->assertSame($pimple['service'], $locator->get('alias'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Pimple\Exception\UnknownIdentifierException
|
||||
* @expectedExceptionMessage Identifier "service" is not defined.
|
||||
*/
|
||||
public function testCannotAccessAliasedServiceUsingRealIdentifier()
|
||||
{
|
||||
$this->expectException(\Pimple\Exception\UnknownIdentifierException::class);
|
||||
$this->expectExceptionMessage('Identifier "service" is not defined.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple['service'] = function () {
|
||||
return new Fixtures\Service();
|
||||
};
|
||||
$locator = new ServiceLocator($pimple, array('alias' => 'service'));
|
||||
$locator = new ServiceLocator($pimple, ['alias' => 'service']);
|
||||
|
||||
$service = $locator->get('service');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Pimple\Exception\UnknownIdentifierException
|
||||
* @expectedExceptionMessage Identifier "foo" is not defined.
|
||||
*/
|
||||
public function testGetValidatesServiceCanBeLocated()
|
||||
{
|
||||
$this->expectException(\Pimple\Exception\UnknownIdentifierException::class);
|
||||
$this->expectExceptionMessage('Identifier "foo" is not defined.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple['service'] = function () {
|
||||
return new Fixtures\Service();
|
||||
};
|
||||
$locator = new ServiceLocator($pimple, array('alias' => 'service'));
|
||||
$locator = new ServiceLocator($pimple, ['alias' => 'service']);
|
||||
|
||||
$service = $locator->get('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Pimple\Exception\UnknownIdentifierException
|
||||
* @expectedExceptionMessage Identifier "invalid" is not defined.
|
||||
*/
|
||||
public function testGetValidatesTargetServiceExists()
|
||||
{
|
||||
$this->expectException(\Pimple\Exception\UnknownIdentifierException::class);
|
||||
$this->expectExceptionMessage('Identifier "invalid" is not defined.');
|
||||
|
||||
$pimple = new Container();
|
||||
$pimple['service'] = function () {
|
||||
return new Fixtures\Service();
|
||||
};
|
||||
$locator = new ServiceLocator($pimple, array('alias' => 'invalid'));
|
||||
$locator = new ServiceLocator($pimple, ['alias' => 'invalid']);
|
||||
|
||||
$service = $locator->get('alias');
|
||||
}
|
||||
|
|
@ -114,7 +111,7 @@ class ServiceLocatorTest extends TestCase
|
|||
$pimple['service2'] = function () {
|
||||
return new Fixtures\Service();
|
||||
};
|
||||
$locator = new ServiceLocator($pimple, array('service1'));
|
||||
$locator = new ServiceLocator($pimple, ['service1']);
|
||||
|
||||
$this->assertTrue($locator->has('service1'));
|
||||
$this->assertFalse($locator->has('service2'));
|
||||
|
|
@ -126,7 +123,7 @@ class ServiceLocatorTest extends TestCase
|
|||
$pimple['service'] = function () {
|
||||
return new Fixtures\Service();
|
||||
};
|
||||
$locator = new ServiceLocator($pimple, array('foo' => 'service', 'bar' => 'invalid'));
|
||||
$locator = new ServiceLocator($pimple, ['foo' => 'service', 'bar' => 'invalid']);
|
||||
|
||||
$this->assertTrue($locator->has('foo'));
|
||||
$this->assertFalse($locator->has('bar'));
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ class ServiceIteratorTest extends TestCase
|
|||
$pimple['service3'] = function () {
|
||||
return new Service();
|
||||
};
|
||||
$iterator = new ServiceIterator($pimple, array('service1', 'service2'));
|
||||
$iterator = new ServiceIterator($pimple, ['service1', 'service2']);
|
||||
|
||||
$this->assertSame(array('service1' => $pimple['service1'], 'service2' => $pimple['service2']), iterator_to_array($iterator));
|
||||
$this->assertSame(['service1' => $pimple['service1'], 'service2' => $pimple['service2']], iterator_to_array($iterator));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue